File: apt-offline-tests-github.sh

package info (click to toggle)
apt-offline 1.8.6-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 692 kB
  • sloc: python: 4,327; sh: 310; makefile: 19
file content (187 lines) | stat: -rwxr-xr-x 4,250 bytes parent folder | download
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
#!/bin/sh

DISLIKED_PACKAGES="gcc golang gnome-terminal"
DISLIKED_SRC_PACKAGES="glibc gcc golang gnome-terminal"
RELEASE=`lsb_release -c -s`
DIR="$(mktemp --tmpdir --directory apt-offline-tests-XXXXXXXX)"
#cleanup () { rm --recursive --force "$DIR"; }
#trap cleanup EXIT
URI="$DIR/set.uris"
CACHE_DIR="/var/cache/apt/archives"
DOWNLOAD_DIR="$DIR/download-dir"
BUNDLE_FILE="$DIR/bundle-file.zip"
THREADS=5
APT_OFFLINE="./apt-offline "

run()
{
    echo "Executing command: $1"
    $1
}

set_features () {
	if [ ! -z $1 ]; then
		URI=$1
	fi

	# Needs root
	APT_OFFLINE="sudo $APT_OFFLINE"

        run "sudo apt update"

	run "$APT_OFFLINE set $URI --simulate --update --upgrade"

	run "$APT_OFFLINE set $URI --update"

	run "$APT_OFFLINE set $URI --upgrade"

	run "$APT_OFFLINE set $URI --update --upgrade"

	run "$APT_OFFLINE set $URI --update --upgrade --upgrade-type upgrade"

	run "$APT_OFFLINE set $URI --update --upgrade --upgrade-type upgrade --release $RELEASE"

	run "$APT_OFFLINE set $URI --install-packages $DISLIKED_PACKAGES"

	run "$APT_OFFLINE set $URI --install-packages $DISLIKED_PACKAGES --release $RELEASE"

	run "$APT_OFFLINE set $URI --install-src-packages $DISLIKED_SRC_PACKAGES"

	run "$APT_OFFLINE set $URI --install-src-packages $DISLIKED_SRC_PACKAGES --release $RELEASE"

	run "$APT_OFFLINE set $URI --src-build-dep --install-src-packages $DISLIKED_SRC_PACKAGES"

	run "$APT_OFFLINE set $URI --src-build-dep --install-src-packages $DISLIKED_SRC_PACKAGES --release $RELEASE"

}

get_features () {
	if [ ! -z $1 ]; then
		URI=$1
	fi

        run "sudo apt update"

	run "$APT_OFFLINE get $URI --quiet --bundle $BUNDLE_FILE"
	rm -f $BUNDLE_FILE

	run "$APT_OFFLINE get $URI --quiet --threads $THREADS --bundle $BUNDLE_FILE"
	rm -f $BUNDLE_FILE

	run "$APT_OFFLINE get $URI --quiet --threads $THREADS --socket-timeout 30 --bundle $BUNDLE_FILE --bug-reports"

	run "$APT_OFFLINE get $URI --quiet --threads $THREADS -d $DOWNLOAD_DIR"
	rm -rf $DOWNLOAD_DIR

	run "$APT_OFFLINE get $URI --quiet --threads $THREADS -d $DOWNLOAD_DIR --cache-dir $CACHE_DIR"
	rm -rf $DOWNLOAD_DIR

	run "$APT_OFFLINE get $URI --quiet --no-checksum -d $DOWNLOAD_DIR --cache-dir $CACHE_DIR"
	rm -rf $DOWNLOAD_DIR

	run "$APT_OFFLINE get $URI --quiet --threads $THREADS --bug-reports -d $DOWNLOAD_DIR --cache-dir $CACHE_DIR"

}

install_features () {
	if [ ! -z $1 ]; then
		DOWNLOAD_DIR=$1
		BUNDLE_FILE=$1
	fi

	# Needs root
	APT_OFFLINE="sudo $APT_OFFLINE"

        run "sudo apt update"

	run "$APT_OFFLINE install $DOWNLOAD_DIR  --skip-bug-reports"

	run "$APT_OFFLINE install $DOWNLOAD_DIR --skip-bug-reports  --allow-unauthenticated"

	run "$APT_OFFLINE install $BUNDLE_FILE  --skip-bug-reports"

	run "$APT_OFFLINE install $BUNDLE_FILE --skip-bug-reports  --allow-unauthenticated"
}

install_features_prompt () {
	if [ ! -z $1 ]; then
		DOWNLOAD_DIR=$1
		BUNDLE_FILE=$1
	fi

	# Needs root
	APT_OFFLINE="sudo $APT_OFFLINE"

        run "sudo apt update"

	run "$APT_OFFLINE install $DOWNLOAD_DIR"

	run "$APT_OFFLINE install $DOWNLOAD_DIR --simulate"

	run "$APT_OFFLINE install $DOWNLOAD_DIR --simulate"

	run "$APT_OFFLINE install $DOWNLOAD_DIR --simulate --allow-unauthenticated"

	run "$APT_OFFLINE install $BUNDLE_FILE"

	run "$APT_OFFLINE install $BUNDLE_FILE --simulate"

	run "$APT_OFFLINE install $BUNDLE_FILE --simulate"

	run "$APT_OFFLINE install $BUNDLE_FILE --simulate --allow-unauthenticated"
}

all_features () {
	echo "Executing function set_features"
	set_features

	echo "Executing function get_features"
	get_features

	echo "Executing function install_features"
	install_features
}

case $1 in
	"set")
		if [ ! -z $2 ]; then
			set_features $2
		else
			set_features
		fi
		;;
	"get")
		if [ ! -z $2 ]; then
			get_features $2
		else
			get_features
		fi
		;;
	"install_features_promptless")
		if [ ! -z $2 ]; then
			install_features $2
		else
			install_features
		fi
		;;
	"install")
		# With prompts for bug reports
		if [ ! -z $2 ]; then
			install_features_prompt $2
		else
			install_features_prompt
		fi
		;;
	"--help")
		echo "$0 [set || get || install_features_promptless || install]"
		exit 0;
		;;
	"-h")
		echo "$0 [set || get || install_features_promptless || install]"
		exit 0;
		;;
	*)
		all_features
		;;
esac