-
Notifications
You must be signed in to change notification settings - Fork 1
/
create-bundle.sh
executable file
·70 lines (58 loc) · 1.16 KB
/
create-bundle.sh
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
#!/bin/bash
OBS_DISTRO="$1"
shift
./setup-sources-list.sh "$OBS_DISTRO"
PACKAGE_LIST=$@
TMP_CACHE_DIR="$PWD/bundle"
function check_args
{
if [ "$#" -lt 1 ]; then
echo "usage: $0 <package names>"
echo "example: $0 syslog-ng-core syslog-ng-mod-pgsql"
exit 1
fi
}
function create_tmp_cache_dir
{
mkdir $TMP_CACHE_DIR
}
function download_package_list
{
apt-get -y --reinstall --download-only -o Dir::Cache="$TMP_CACHE_DIR" \
-o Dir::Cache::archives="$TMP_CACHE_DIR/archives" install $PACKAGE_LIST
}
function targz_packages
{
mv $TMP_CACHE_DIR/archives .
tar czf bundle.tgz archives
rm -rf archives
}
function generate_installer
{
mkdir installer
mv bundle.tgz installer/
cd installer
echo "#!/bin/sh -e" > install.sh
echo "tar xzf bundle.tgz" >> install.sh
echo "dpkg -i archives/*.deb" >> install.sh
chmod +x install.sh
cd ..
tar czf installer.tgz installer
rm -rf installer
}
function remove_tmp_cache_dir
{
if [ -d "$TMP_CACHE_DIR" ]; then
rm -rf "$TMP_CACHE_DIR"
fi
}
function main
{
create_tmp_cache_dir
download_package_list
targz_packages
generate_installer
remove_tmp_cache_dir
}
check_args "$@"
main