/[d-i]/trunk/build/get-packages
ViewVC logotype

Contents of /trunk/build/get-packages

Parent Directory Parent Directory | Revision Log Revision Log


Revision 7394 - (show annotations) (download)
Tue Jan 6 14:08:45 2004 UTC (9 years, 4 months ago) by wouter
File size: 4692 byte(s)
support cross-compiling (not finished yet, but we've got to start somewhere)
1 #!/bin/sh
2 #
3 # get-packages <type> <package> ...
4 #
5 # Download deb or udeb package with the help of apt-get
6 # type : deb | udeb
7 #
8 # Files:
9 # sources.list.udeb / sources.list.udeb.local
10 # sources.list.deb / sources.list.deb.local
11 #
12 # Environment:
13 # APTDIR - basename for the apt directory (default: apt.$TYPE)
14 # DEBUG - build debug udebs from source (default: n)
15 # DEBUGUDEBDIR - directory for debug udebs (default: debugudebs)
16 # UDEBDIR - directory for ready-to-use udebs (default: udebs)
17 # LOCALUDEBDIR - directory for locally provided udebs (default: localudebs)
18 # ONLINE - update Packages files (default: y)
19
20 set -e
21
22 # parse parameters
23 TYPE=$1
24 shift
25 PACKAGES=$*
26
27 # Setup environment
28 if [ ! $APTDIR ]; then
29 APTDIR="apt"
30 fi
31 if [ ! $DEBUGUDEBDIR ]; then
32 DEBUGUDEBDIR="debugudebs"
33 fi
34 if [ ! $UDEBDIR ]; then
35 UDEBDIR="udebs"
36 fi
37 if [ ! $LOCALUDEBDIR ]; then
38 LOCALUDEBDIR="localudebs"
39 fi
40 if [ ! $ONLINE ]; then
41 ONLINE="y"
42 fi
43
44 # Set APTDIR according to type
45 # debs are kept in another apt cache so only the needed Packages files
46 # are downloaded and autoclean doesnt run wild.
47 APTDIR=$APTDIR.$TYPE
48
49 # Set sources.list file
50 if [ -f sources.list.$TYPE.local ]; then
51 LIST=sources.list.$TYPE.local
52 else
53 LIST=sources.list.$TYPE
54 make sources.list.$TYPE
55 fi
56
57 # All these options make apt read the right sources list, and use APTDIR for
58 # everything so it need not run as root.
59 APT_GET="apt-get --assume-yes \
60 -o Dir::Etc::sourcelist=`pwd`/$LIST \
61 -o Dir::State=`pwd`/$APTDIR/state \
62 -o Debug::NoLocking=true \
63 -o Dir::Cache=`pwd`/$APTDIR/cache \
64 -o Apt::Architecture=`dpkg-architecture -qDEB_HOST_ARCH`"
65
66 # Prepare APTDIR
67 mkdir -p $APTDIR/state/lists/partial
68 mkdir -p $APTDIR/cache/archives/partial
69 if [ "$TYPE" = "deb" ]; then
70 echo -n > $APTDIR/state/status
71 APT_GET="$APT_GET -o Dir::State::Status=`pwd`/$APTDIR/state/status"
72 else
73 # Prime status file with system libraries
74 # Currently disabled and we use the system status file, but this
75 # may be used when we transition to using proper library udebs.
76 #echo -n > $APTDIR/state/status
77 # Some archs have libc6 others have libc6.1
78 #dpkg -s libc6 >> $APTDIR/state/status || dpkg -s libc6.1 >> $APTDIR/state/status
79 #for i in libnewt0.51 libdebconfclient0 libdebian-installer4 \
80 # libdb1-compat slang1a-utf8 libdiscover1 discover-data; do
81 # dpkg -s $i >> $APTDIR/state/status
82 #done
83 :
84 fi
85
86 # Update package lists and autoclean cache
87 if [ "$ONLINE" = "y" ]; then
88 $APT_GET update || {
89 echo "Failed to update the Packages file. This usually means either of:"
90 echo
91 echo "A) $LIST does not contain a vaild repository."
92 echo " You can override the generated sources.list.$TYPE"
93 echo " with sources.list.$TYPE.local if you haven't done so yet."
94 echo
95 echo "B) The repository in $LIST is not reachable."
96 echo " If you are not working online, use 'export ONLINE=n' to skip updating"
97 echo " the Packages files. Beware that this can result in images with"
98 echo " out-of-date packages and should be used for private development only."
99 exit 1
100 }
101 $APT_GET autoclean
102 fi
103
104 # If there are local (u)debs, remove them from the list of things to
105 # get. Then get all the (u)debs that are left to get. Note that the
106 # trailing blank on the next line is significant. It makes the sed
107 # below always work.
108
109 needed="$PACKAGES "
110 for file in `find $LOCALUDEBDIR -name "*_*" -printf "%f\n" 2>/dev/null`; do
111 package=`echo $file | cut -d _ -f 1`
112 needed=`echo " $needed " | sed "s/ $package / /g"`
113 done
114 if [ "$DEBUG" = y ]; then
115 mkdir -p $DEBUGUDEBDIR
116 cd $DEBUGUDEBDIR
117 export DEB_BUILD_OPTIONS="debug"
118 $APT_GET source --build --yes $needed
119 cd ..
120 else
121 echo Need to download : $needed
122 if [ -n "$needed" ]; then
123 $APT_GET -dy install $needed
124 fi
125 fi
126
127 # Now the (u)debs are in APTDIR/cache/archives/ and maybe LOCALUDEBDIR
128 # or DEBUGUDEBDIR, but there may be other (u)debs there too besides
129 # those we asked for. So link those we asked for to UDEBDIR, renaming
130 # them to more useful names. Watch out for duplicates and missing
131 # files while doing that.
132 rm -rf $UDEBDIR
133 mkdir -p $UDEBDIR
134
135 lnpkg() {
136 local pkg=$1; local dir=$2 debdir=$3;
137 local L1="`echo $dir/$pkg\_*`"
138 local L2="`echo $L1 | sed -e 's, ,,g'`"
139 if [ "$L1" != "$L2" ]; then
140 echo "Duplicate package $pkg in $dir/";
141 exit 1
142 fi
143 if [ -e $L1 ]; then
144 ln -f $dir/${pkg}_* $debdir/$pkg.$TYPE
145 fi
146 }
147
148 for package in $PACKAGES; do
149 lnpkg $package $APTDIR/cache/archives $UDEBDIR
150 lnpkg $package $LOCALUDEBDIR $UDEBDIR
151 lnpkg $package $DEBUGUDEBDIR $UDEBDIR
152 if [ ! -e $UDEBDIR/$package.$TYPE ]; then
153 echo "Needed $package not found (looked in $APTDIR/cache/archives/, $LOCALUDEBDIR/, $DEBUGUDEBDIR/)";
154 exit 1
155 fi
156 done

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.5