1 @@include@@variables.include
3 APT_GET="`which apt-get 2> /dev/null`"
4 APT_CONFIG="`which apt-config 2> /dev/null`"
6 SOURCES_PREAMBLE="### THIS FILE IS AUTOMATICALLY CONFIGURED ###
7 # You may comment out this entry, but any other modifications may be lost.\n"
9 # Parse apt configuration and return requested variable value.
12 if [ -x "$APT_CONFIG" ]; then
13 "$APT_CONFIG" dump | sed -e "/^$APTVAR /"'!d' -e "s/^$APTVAR \"\(.*\)\".*/\1/"
17 # Install the repository signing key (see also:
18 # https://www.google.com/linuxrepositories/)
20 APT_KEY="`which apt-key 2> /dev/null`"
21 if [ -x "$APT_KEY" ]; then
22 "$APT_KEY" add - >/dev/null 2>&1 <<KEYDATA
23 -----BEGIN PGP PUBLIC KEY BLOCK-----
24 Version: GnuPG v1.4.2.2 (GNU/Linux)
26 mQGiBEXwb0YRBADQva2NLpYXxgjNkbuP0LnPoEXruGmvi3XMIxjEUFuGNCP4Rj/a
27 kv2E5VixBP1vcQFDRJ+p1puh8NU0XERlhpyZrVMzzS/RdWdyXf7E5S8oqNXsoD1z
28 fvmI+i9b2EhHAA19Kgw7ifV8vMa4tkwslEmcTiwiw8lyUl28Wh4Et8SxzwCggDcA
29 feGqtn3PP5YAdD0km4S4XeMEAJjlrqPoPv2Gf//tfznY2UyS9PUqFCPLHgFLe80u
30 QhI2U5jt6jUKN4fHauvR6z3seSAsh1YyzyZCKxJFEKXCCqnrFSoh4WSJsbFNc4PN
31 b0V0SqiTCkWADZyLT5wll8sWuQ5ylTf3z1ENoHf+G3um3/wk/+xmEHvj9HCTBEXP
32 78X0A/0Tqlhc2RBnEf+AqxWvM8sk8LzJI/XGjwBvKfXe+l3rnSR2kEAvGzj5Sg0X
33 4XmfTg4Jl8BNjWyvm2Wmjfet41LPmYJKsux3g0b8yzQxeOA4pQKKAU3Z4+rgzGmf
34 HdwCG5MNT2A5XxD/eDd+L4fRx0HbFkIQoAi1J3YWQSiTk15fw7RMR29vZ2xlLCBJ
35 bmMuIExpbnV4I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C KEY BLOCK-----
58 # Set variables for the locations of the apt sources lists.
60 APTDIR=$(apt_config_val Dir)
61 APTETC=$(apt_config_val 'Dir::Etc')
62 APT_SOURCES="$APTDIR$APTETC$(apt_config_val 'Dir::Etc::sourcelist')"
63 APT_SOURCESDIR="$APTDIR$APTETC$(apt_config_val 'Dir::Etc::sourceparts')"
66 # Update the Google repository if it's not set correctly.
67 # Note: this doesn't necessarily enable the repository, it just makes sure the
68 # correct settings are available in the sources list.
70 # 0 - no update necessary
72 update_bad_sources() {
73 if [ ! "$REPOCONFIG" ]; then
79 SOURCELIST="$APT_SOURCESDIR/@@PACKAGE@@.list"
80 # Don't do anything if the file isn't there, since that probably means the
82 if [ ! -r "$SOURCELIST" ]; then
86 # Basic check for active configurations (non-blank, non-comment lines).
87 ACTIVECONFIGS=$(grep -v "^[[:space:]]*\(#.*\)\?$" "$SOURCELIST" 2>/dev/null)
89 # Check if the correct repository configuration is in there.
90 REPOMATCH=$(grep -E "^[[:space:]#]*\b($REPOCONFIG|$SSLREPOCONFIG)\b" "$SOURCELIST" \
93 # Check if the correct repository is disabled.
94 MATCH_DISABLED=$(echo "$REPOMATCH" | grep "^[[:space:]]*#" 2>/dev/null)
96 # Now figure out if we need to fix things.
98 if [ "$REPOMATCH" ]; then
99 # If it's there and active, that's ideal, so nothing to do.
100 if [ ! "$MATCH_DISABLED" ]; then
103 # If it's not active, but neither is anything else, that's fine too.
104 if [ ! "$ACTIVECONFIGS" ]; then
110 if [ $BADCONFIG -eq 0 ]; then
114 # At this point, either the correct configuration is completely missing, or
115 # the wrong configuration is active. In that case, just abandon the mess and
116 # recreate the file with the correct configuration. If there were no active
117 # configurations before, create the new configuration disabled.
119 if [ ! "$ACTIVECONFIGS" ]; then
122 printf "$SOURCES_PREAMBLE" > "$SOURCELIST"
123 printf "$DISABLE$REPOCONFIG\n" >> "$SOURCELIST"
124 if [ $? -eq 0 ]; then
130 # Add the Google repository to the apt sources.
132 # 0 - sources list was created
134 create_sources_lists() {
135 if [ ! "$REPOCONFIG" ]; then
141 SOURCELIST="$APT_SOURCESDIR/@@PACKAGE@@.list"
142 if [ -d "$APT_SOURCESDIR" ]; then
143 printf "$SOURCES_PREAMBLE" > "$SOURCELIST"
144 printf "$REPOCONFIG\n" >> "$SOURCELIST"
145 if [ $? -eq 0 ]; then
152 # Remove our custom sources list file.
154 # 0 - successfully removed, or not configured
155 # !0 - failed to remove
156 clean_sources_lists() {
157 if [ ! "$REPOCONFIG" ]; then
163 rm -f "$APT_SOURCESDIR/@@PACKAGE@@.list" \
164 "$APT_SOURCESDIR/@@PACKAGE@@-@@CHANNEL@@.list"
167 # Detect if the repo config was disabled by distro upgrade and enable if
169 handle_distro_upgrade() {
170 if [ ! "$REPOCONFIG" ]; then
175 SOURCELIST="$APT_SOURCESDIR/@@PACKAGE@@.list"
176 if [ -r "$SOURCELIST" ]; then
177 REPOLINE=$(grep -E "^[[:space:]]*#[[:space:]]*($REPOCONFIG|$SSLREPOCONFIG)[[:space:]]*# disabled on upgrade to .*" "$SOURCELIST")
178 if [ $? -eq 0 ]; then
179 sed -i -e "s,^[[:space:]]*#[[:space:]]*\($REPOCONFIG\|$SSLREPOCONFIG\)[[:space:]]*# disabled on upgrade to .*,\1," \
181 LOGGER=$(which logger 2> /dev/null)
182 if [ "$LOGGER" ]; then
183 "$LOGGER" -t "$0" "Reverted repository modification: $REPOLINE."
189 DEFAULT_ARCH="@@ARCHITECTURE@@"
192 if [ "$DEFAULT_ARCH" = "i386" ]; then
193 LIBDIR=lib/i386-linux-gnu
194 elif [ "$DEFAULT_ARCH" = "amd64" ]; then
195 LIBDIR=lib/x86_64-linux-gnu
197 echo Unknown CPU Architecture: "$DEFAULT_ARCH"