source: ubiquity/trunk/fuentes/d-i/get-sources

Last change on this file was 1053, checked in by kbut, 4 years ago

add ubiquity

  • Property svn:executable set to *
File size: 3.2 KB
Line 
1#!/bin/sh
2#
3# get-sources <package> | <update> ...
4#
5# Download source packages with the help of apt-get
6#
7# Files:
8#   sources.list / sources.list.local
9#
10# Environment:
11#   APTDIR       - basename for the apt directory (default: apt.$TYPE)
12#   ONLINE       - update Packages files (default: y)
13#
14# This is loosely based on get-packages in debian-installer, copyright (C)
15# 2001-2005 by Joey Hess <joeyh@debian.org> and the d-i team, and licensed
16# under the terms of the GNU General Public License.
17
18set -e
19
20PACKAGES=$*
21
22# Setup environment
23if [ ! $APTDIR ]; then
24        APTDIR="apt"
25fi
26if [ ! $SOURCEDIR ]; then
27        SOURCEDIR="source"
28fi
29if [ ! $ONLINE ]; then
30        ONLINE="y"
31fi
32
33# Set sources.list file
34if [ -f sources.list.local ]; then
35        LIST=sources.list.local
36else
37        LIST=sources.list
38fi
39
40# All these options make apt read the right sources list, and use APTDIR for
41# everything so it need not run as root.
42APT_GET="apt-get --assume-yes \
43        -o Dir::Etc::sourcelist=`pwd`/$LIST \
44        -o Dir::Etc::sourceparts=#clear \
45        -o Dir::State=`pwd`/$APTDIR/state \
46        -o Debug::NoLocking=true \
47        -o Dir::Cache=`pwd`/$APTDIR/cache \
48        -o Acquire::Retries=3"
49
50# Prepare APTDIR
51mkdir -p $APTDIR/state/lists/partial
52mkdir -p $APTDIR/cache/archives/partial
53echo -n > $APTDIR/state/status
54
55# Update package lists and autoclean cache.
56if [ "$ONLINE" = "y" ]; then
57        $APT_GET update || {
58                echo "Failed to update the Packages file. This usually means either of:"
59                echo
60                echo "A) $LIST does not contain a valid repository."
61                echo "   You can override the generated sources.list.$TYPE"
62                echo "   with sources.list.$TYPE.local if you haven't done so yet."
63                echo
64                echo "B) The repository in $LIST is not reachable."
65                echo "   If you are not working online, use 'export ONLINE=n' to skip updating"
66                echo "   the Packages files. Beware that this can result in images with"
67                echo "   out-of-date packages and should be used for private development only."
68                exit 1
69        }
70        $APT_GET autoclean
71else
72        # A Release.gpg may not be cached, allow continuing w/o it in
73        # offline mode.
74        APT_GET="$APT_GET --allow-unauthenticated"
75       
76        $APT_GET --no-list-cleanup update || echo "Ignoring update failure in offline mode"
77fi
78
79if [ "$PACKAGES" = update ]; then
80        exit 0
81fi
82
83if [ -f manifest ]; then
84        mv manifest manifest.old
85elif ! [ -f manifest.old ]; then
86        echo "Building manifest ..."
87        ./build-manifest > manifest.old
88fi
89
90rm -rf $SOURCEDIR
91mkdir -p $SOURCEDIR
92
93# Get source packages.
94echo Need to download: $PACKAGES
95if [ -n "$PACKAGES" ]; then (
96        set -e
97        cd $SOURCEDIR
98        $APT_GET source $PACKAGES
99        rm -f *.dsc *.tar.gz *.tar.xz
100        rename 's/-[0-9].*//' *-[0-9]*
101) fi
102
103# We don't build console-setup, as it takes too long, so these aren't
104# needed; we just need a couple of scripts from it.
105for subdir in .svn Fonts Keyboard/acm Keyboard/ckb Keyboard/locale; do
106        rm -rf "$SOURCEDIR/console-setup/$subdir"
107done
108
109# Add a warning to budding hackers.
110cat > "$SOURCEDIR/README" <<EOF
111The files in this directory are updated automatically from the distribution
112archive. Any changes you make under this directory will be lost!
113
114New ubiquity-specific scripts should be added to scripts/ instead; you can
115make local modifications here if you need to, but for inclusion in official
116builds the changes need to be applied to the corresponding source packages
117and uploaded.
118EOF
Note: See TracBrowser for help on using the repository browser.