create_offlinerepo.sh 2.54 KB
Newer Older
1
2
3
4
#!/bin/bash

set -e

5
6
7
8
9
10
11
12
13
14
15
16
17
18
usage () {
	echo "usage: create_offlinerepo.sh repodir isofile [list of packages]" >&2
	echo >&2
	echo "Downloads all packages required to fully update the system in 'isofile' and" >&2
	echo "to install the listed packages and adds them to the package archive in 'repodir'." >&2
	exit 1
}

dest="$1"
shift || usage
iso_file="$1"
shift || usage
packages="$@"

19
workspace="/workspace"
20
APT_SOURCE_URL_OVERRIDE="http://ftp.halifax.rwth-aachen.de/ubuntu/"
21
22
23

rm -rf "$workspace"/offlinerepo
mkdir -p "$workspace"/offlinerepo
24
mkdir -p "$dest"
25
26
27

7z e -so "$iso_file" casper/filesystem.squashfs > "$workspace"/offlinerepo/filesystem.squashfs
unsquashfs -no-xattrs -d "$workspace"/offlinerepo/squashfs-root "$workspace"/offlinerepo/filesystem.squashfs 
28

29
30
31
32
33
source "$workspace/offlinerepo/squashfs-root/etc/lsb-release"
echo "deb $APT_SOURCE_URL_OVERRIDE ${DISTRIB_CODENAME} main restricted universe multiverse" > "$workspace/offlinerepo/squashfs-root/etc/apt/sources.list"
echo "deb $APT_SOURCE_URL_OVERRIDE ${DISTRIB_CODENAME}-security main restricted universe multiverse" >> "$workspace/offlinerepo/squashfs-root/etc/apt/sources.list"
echo "deb $APT_SOURCE_URL_OVERRIDE ${DISTRIB_CODENAME}-updates main restricted universe multiverse" >> "$workspace/offlinerepo/squashfs-root/etc/apt/sources.list"
echo "deb $APT_SOURCE_URL_OVERRIDE ${DISTRIB_CODENAME}-backports main restricted universe multiverse" >> "$workspace/offlinerepo/squashfs-root/etc/apt/sources.list"
34
35
apt-get -o Dir="$workspace"/offlinerepo/squashfs-root update

36
37
38
{
	apt-get -o Dir="$workspace"/offlinerepo/squashfs-root upgrade --print-uris -qq
	apt-get -o Dir="$workspace"/offlinerepo/squashfs-root install --reinstall --print-uris -qq $packages
OSAK Buildhauer's avatar
OSAK Buildhauer committed
39
} | cut -d"'" -f2 | while read url; do wget -q -nc -P "$dest" "$url"; done
40
apt-get -o Dir="$workspace"/offlinerepo/squashfs-root install --reinstall --print-uris -qq $packages
41

42
43
mkdir -p "$dest/dists/$DISTRIB_CODENAME/lip/binary-amd64"
( cd "$dest" && dpkg-scanpackages . | gzip > "dists/$DISTRIB_CODENAME/lip/binary-amd64/Packages.gz" )
44

45
46
47
cat <<EOF > "$dest/dists/$DISTRIB_CODENAME/lip/binary-amd64/Release"
Archive: $DISTRIB_CODENAME
Version: $DISTRIB_RELEASE
48
49
50
51
52
53
54
55
56
57
Component: lip
Origin: Ubuntu
Label: Ubuntu
Architecture: amd64
EOF

touch "$dest/.aptignr"
cat <<EOF > "$dest/Release"
Origin: Ubuntu
Label: LIP Ubuntu Extra Packages
58
59
60
Suite: $DISTRIB_CODENAME
Version: $DISTRIB_RELEASE
Codename: $DISTRIB_CODENAME
61
62
63
Date: $(LC_ALL=C date -u)
Architectures: amd64
Components: lip
64
Description: $DISTRIB_DESCRIPTION
65
EOF
66

67
# Maybe sort files into the usual directory structure ("pool/main/g/glib2.0...")