~agateau/ubiquity/kde-show-os-name

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
#!/bin/sh
#
# get-sources <package> | <update> ...
#
# Download source packages with the help of apt-get
#
# Files:
#   sources.list / sources.list.local
#
# Environment:
#   APTDIR       - basename for the apt directory (default: apt.$TYPE)
#   ONLINE       - update Packages files (default: y)
#
# This is loosely based on get-packages in debian-installer, copyright (C)
# 2001-2005 by Joey Hess <joeyh@debian.org> and the d-i team, and licensed
# under the terms of the GNU General Public License.

set -e

PACKAGES=$*

# Setup environment
if [ ! $APTDIR ]; then
	APTDIR="apt"
fi
if [ ! $SOURCEDIR ]; then
	SOURCEDIR="source"
fi
if [ ! $ONLINE ]; then
	ONLINE="y"
fi

# Set sources.list file
if [ -f sources.list.local ]; then
	LIST=sources.list.local
else
	LIST=sources.list
fi

# All these options make apt read the right sources list, and use APTDIR for
# everything so it need not run as root.
APT_GET="apt-get --assume-yes \
	-o Dir::Etc::sourcelist=`pwd`/$LIST \
	-o Dir::Etc::sourceparts=#clear \
	-o Dir::State=`pwd`/$APTDIR/state \
	-o Debug::NoLocking=true \
	-o Dir::Cache=`pwd`/$APTDIR/cache \
	-o Acquire::Retries=3"

# Prepare APTDIR
mkdir -p $APTDIR/state/lists/partial
mkdir -p $APTDIR/cache/archives/partial
echo -n > $APTDIR/state/status

# Update package lists and autoclean cache.
if [ "$ONLINE" = "y" ]; then
	$APT_GET update || {
		echo "Failed to update the Packages file. This usually means either of:"
		echo
		echo "A) $LIST does not contain a valid repository."
		echo "   You can override the generated sources.list.$TYPE"
		echo "   with sources.list.$TYPE.local if you haven't done so yet."
		echo
		echo "B) The repository in $LIST is not reachable."
		echo "   If you are not working online, use 'export ONLINE=n' to skip updating"
		echo "   the Packages files. Beware that this can result in images with"
		echo "   out-of-date packages and should be used for private development only."
		exit 1
	}
	$APT_GET autoclean
else
	# A Release.gpg may not be cached, allow continuing w/o it in
	# offline mode.
	APT_GET="$APT_GET --allow-unauthenticated"
	
	$APT_GET --no-list-cleanup update || echo "Ignoring update failure in offline mode"
fi

if [ "$PACKAGES" = update ]; then
	exit 0
fi

if [ -f manifest ]; then
	mv manifest manifest.old
elif ! [ -f manifest.old ]; then
	echo "Building manifest ..."
	./build-manifest > manifest.old
fi

rm -rf $SOURCEDIR
mkdir -p $SOURCEDIR

# Get source packages.
echo Need to download: $PACKAGES
if [ -n "$PACKAGES" ]; then (
	set -e
	cd $SOURCEDIR
	$APT_GET source $PACKAGES
	rm -f *.dsc *.tar.gz
	rename 's/-[0-9].*//' *-[0-9]*
) fi

# We don't build console-setup, as it takes too long, so these aren't
# needed; we just need a couple of scripts from it.
for subdir in .svn Fonts Keyboard/acm Keyboard/ckb Keyboard/locale; do
	rm -rf "$SOURCEDIR/console-setup/$subdir"
done

# Add a warning to budding hackers.
cat > "$SOURCEDIR/README" <<EOF
The files in this directory are updated automatically from the distribution
archive. Any changes you make under this directory will be lost!

New ubiquity-specific scripts should be added to scripts/ instead; you can
make local modifications here if you need to, but for inclusion in official
builds the changes need to be applied to the corresponding source packages
and uploaded.
EOF