create_offlinerepo.sh 1.14 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
20
21
22
23
24
25
workspace="/workspace"

rm -rf "$workspace"/offlinerepo
mkdir -p "$workspace"/offlinerepo

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

27
28
apt-get -o Dir="$workspace"/offlinerepo/squashfs-root update

29
30
31
32
33
34
35
{
	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
} | cut -d"'" -f2 | while read url; do wget -nc -P "$dest" "$url"; done

{
	cd "$dest"
36
	rm -rf "$dest"/Packages.*
37
38
39
	dpkg-scanpackages . | gzip > Packages.gz
}

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