make-apt-setup 5.38 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191
#!/bin/sh
#
#    Copyright (C) 2009-2010  Rubén Rodríguez <ruben@gnu.org>
#
#    This program is free software; you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation; either version 2 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program; if not, write to the Free Software
#    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
#

VERSION=1
NETINST=true
. ./config

cat << EOF > debian/rules
#! /usr/bin/make -f
%:
	dh \$@
EOF

rm debian/apt-mirror-setup.templates-ubuntu

# getline "seed" file
getline(){
grep -n "$1" "$2" |cut -d: -f1
}

START=$(getline apt-setup/non-free debian/apt-mirror-setup.templates)
END=$(getline "Please choose whether you want to have it available anyway." debian/apt-mirror-setup.templates)
sed ${START},${END}d debian/apt-mirror-setup.templates -i
START=$(getline apt-setup/contrib debian/apt-mirror-setup.templates)
END=$(getline "Please choose whether you want this software to be made available to you." debian/apt-mirror-setup.templates)
sed ${START},${END}d debian/apt-mirror-setup.templates -i

sed '/canonical/d;
/Canonical/d;
s/main restricted universe multiverse/main/g;
s/dists restricted/dists/g;
s/archive.ubuntu.com/archive.trisquel.info/g;
s/security.ubuntu.com/archive.trisquel.info/g;
s/ports.ubuntu.com/archive.trisquel.info/g;
s/Ubuntu/Trisquel/g;
s/ubuntu/trisquel/g;
s/universe/main/g;
s/main main/main/g;
s:help.trisquel.com/community/UpgradeNotes:trisquel.info/wiki/:g;' generators/* -i

replace "Default: /ubuntu" "Default: /trisquel" .
replace "security.ubuntu.com" "archive.trisquel.info" .
replace "archive.ubuntu.com" "archive.trisquel.info" .
replace "Ubuntu" "Trisquel" .

cd release-files
rm -rf *
for DIST in $CODENAME $CODENAME-security $CODENAME-updates $CODENAME-backports
do
    wget -r -l1 -np http://archive.trisquel.info/trisquel/dists/$DIST
done
find archive.trisquel.info/ |egrep '(index.html|robots.txt)'|xargs rm
cd ..

rm generators/9[1-9]* generators/50mirror generators/50mirror.ubuntu
sed -i '/generators\/9[1-9]*/d' debian/*.install

echo "generators/50mirror.trisquel usr/lib/apt-setup/generators
release-files/archive.trisquel.info usr/share/apt-setup/release-files" > debian/apt-mirror-setup.install

echo '#!/bin/sh
set -e

. /usr/share/debconf/confmodule

file="$1"

log() {
	logger -t apt-setup "$@"
}
warning() {
	log "warning: $@"
}

# Ask if a mirror should be used if the base system can be installed from CD
if [ -e /cdrom/.disk/base_installable ] || [ "$OVERRIDE_BASE_INSTALLABLE" ]; then
	if ! search-path choose-mirror; then
		warning "choose-mirror is not available; cannot offer network mirror"
		exit 1
	fi

	# Default to false if no network selected in netcfg
	if db_get netcfg/dhcp_options && \
	   [ "$RET" = "Do not configure the network at this time" ]; then
		use_mirror=false
	fi

	# Set default if no value (see Debian mirror generator)
	db_get apt-setup/use_mirror
	[ "$RET" ] || db_set apt-setup/use_mirror true 

	# Text is variable for Debian
	db_metaget apt-mirror/use/netinst_old description
	db_subst apt-setup/use_mirror EXPLANATION "$RET"

	db_input medium apt-setup/use_mirror || [ $? -eq 30 ]
	db_go # or exit 10

	db_get apt-setup/use_mirror
	if [ "$RET" = false ]; then
		exit 1
	fi

	if db_get cdrom/codename && [ "$RET" ]; then
		db_set mirror/codename $RET
	fi
	if db_get cdrom/suite && [ "$RET" ]; then
		db_set mirror/suite $RET
	fi
	choose-mirror -n # no progress bar
fi

db_input low apt-setup/backports || true

dists="main"

db_get mirror/protocol
protocol="$RET"
db_get mirror/codename
codename="$RET"
db_get mirror/$protocol/hostname
hostname="$RET"
db_get mirror/$protocol/directory
directory="/${RET#/}"

if [ "$protocol" = http ]; then
	db_get mirror/$protocol/proxy
	proxy="$RET"
	if [ -n "$proxy" ]; then
		if ! grep -iq "Acquire::$protocol::Proxy" $ROOT/etc/apt/apt.conf.new; then
			echo "Acquire::$protocol::Proxy \"$proxy\";" >> $ROOT/etc/apt/apt.conf.new
		fi
	fi
fi


cat > $file <<EOF
# See http://trisquel.info/wiki/ for how to upgrade to
# newer versions of the distribution.

deb $protocol://$hostname$directory $codename $dists
deb-src $protocol://$hostname$directory $codename $dists

deb $protocol://$hostname$directory $codename-updates $dists
deb-src $protocol://$hostname$directory $codename-updates $dists

deb $protocol://$hostname$directory $codename-security $dists
deb-src $protocol://$hostname$directory $codename-security $dists
EOF

# Even if the backports repository is not enabled, we write example lines for
# it.
echo >> $file
if db_get apt-setup/backports && [ "$RET" = true ]; then
	COMMENT=
else
	cat >> $file <<EOF
EOF
	COMMENT="# "
fi
cat >> $file <<EOF
# Uncomment this lines to enable the backports optional repository
${COMMENT}deb $protocol://$hostname$directory $codename-backports main
${COMMENT}deb-src $protocol://$hostname$directory $codename-backports main
EOF

apt-setup-signed-release archive.trisquel.info "$file"

exit 0
' > generators/50mirror.trisquel

chmod 755 generators/50mirror.trisquel

changelog "Rebranded and adapted for Trisquel"
compile