Debian Codegraph @

pbuilder-updatebuildenv

raw
1 #! /bin/bash
2 # pbuilder -- personal Debian package builder
3 # Copyright © 2001-2007 Junichi Uekawa <[email protected]>
4 # 2015 Mattia Rizzolo <[email protected]>
5 #
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
10 #
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 ###############################################################################
20
21 set -e
22
23 . "${BASH_SOURCE%/*}/pbuilder-checkparams"
24
25 if [ -n "$DISTRIBUTION" ] && [ "$OVERRIDE_APTLINES" = "yes" ]; then
26 log.i "Upgrading for distribution $DISTRIBUTION"
27 fi
28 if [ "${PBUILDER_DEBUGMODE}" = "yes" ]; then
29 TRAP="echo ignoring trap "
30 else
31 TRAP=trap
32 fi
33
34 # show the current time before doing anything.
35 echobacktime
36
37 extractbuildplace
38 $TRAP umountproc_cleanbuildplace_trap exit sighup
39
40 log.i "Refreshing the base.tgz "
41 log.i "upgrading packages"
42 $CHROOTEXEC apt-get -q "${APTGETOPT[@]}" update
43
44
45 install_packages_for_optional_features
46
47 if [ -n "$REMOVEPACKAGES" ]; then remove_packages $REMOVEPACKAGES ; fi
48
49 recover_aptcache
50
51 $TRAP saveaptcache_umountproc_cleanbuildplace_trap exit sighup
52 if [ "$DEBDELTA" = "yes" ]; then
53 if $CHROOTEXEC which debdelta-upgrade > /dev/null 2>&1 ; then
54 log.i "Using debdelta-upgrade for available deltas"
55 if $CHROOTEXEC debdelta-upgrade ; then
56 :
57 else
58 log.w "debdelta failed, continue and use plain apt to update the system"
59 fi
60 else
61 log.w "debdelta is enabled but not (yet) installed, not using it"
62 fi
63 fi
64
65 $CHROOTEXEC apt-get -q -y "${APTGETOPT[@]}" "${FORCE_CONFNEW[@]}" dist-upgrade
66 # autoremove: Ignore error in case of etch because apt in etch doesn't
67 # support autoremove. TODO: Do not ignore error when etch is no longer
68 # supported.
69 $CHROOTEXEC apt-get -q -y "${APTGETOPT[@]}" autoremove || true
70 $CHROOTEXEC apt-get -q -y "${APTGETOPT[@]}" install \
71 build-essential \
72 dpkg-dev \
73 $EXTRAPACKAGES
74 # debdelta dependencies are broken (#545831)
75 if [ "$DEBDELTA" = "yes" ]; then
76 $CHROOTEXEC apt-mark auto python-apt xdelta3
77 fi
78
79 save_aptcache
80 add_additional_aptkeyrings
81
82 # optionally auto-clean apt-cache
83 if [ "${AUTOCLEANAPTCACHE}" = "yes" -a -n "$APTCACHE" ]; then
84 log.i "Cleaning the cached apt archive"
85 $CHROOTEXEC apt-get autoclean || true
86 find "$APTCACHE/" -maxdepth 1 -name \*.deb | \
87 while read A; do
88 if [ ! -f "$BUILDPLACE/var/cache/apt/archives/$(basename "$A")" -a \
89 -f "$A" ]; then
90 log.i "obsolete cache content "$(basename "$A")" removed"
91 rm -f "$A" || true
92 fi
93 done
94 fi
95
96 $TRAP umountproc_cleanbuildplace_trap exit sighup
97 executehooks "E"
98
99 umountproc
100 $CHROOTEXEC apt-get clean || true
101
102 $TRAP cleanbuildplace_trap exit sighup
103 if [ ! "${INTERNAL_BUILD_UML}" = "yes" ]; then
104 create_basetgz
105 fi
106 if [ "${PRESERVE_BUILDPLACE}" = "yes" ]; then
107 :
108 else
109 :
110 cleanbuildplace
111 fi
112 trap - exit sighup
113 exit 0