-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·62 lines (52 loc) · 1.28 KB
/
build.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
#!/bin/bash
function init_vars {
dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" # set working directory
src=$dir/apps
out=$dir/upload
}
function reset_out {
rm -rf "$out"
find "$src" -name '*.DS_Store' -type f -delete
mkdir -p "$out/deb"
cp "$dir/repo"/* "$out"
}
function generator {
declare -a packages
while IFS= read -r -d '' n; do
packages+=( "$n" )
done < <(find "$src" -type d -mindepth 1 -maxdepth 1 -print0)
for app in "${packages[@]}"; do
versions=`ls \"$app/versions\" 2>/dev/null`
if [ ! -z $versions ]; then
appname=`echo "$app" | rev | awk -F / '{print $1}' | rev`
make_versions "$appname"
make_apps "$app/tmp"
rm -r "$app/tmp"
else
make_apps "$app"
fi
done
}
function make_versions {
mkdir -p "$app/tmp/var/root/Library/$1"
cp -r "$app/DEBIAN" "$app/tmp"
declare -a versions
while IFS= read -r -d '' n; do
versions+=( "$n" )
done < <(find "$app/versions" -type d -mindepth 1 -maxdepth 1 -print0)
for version in "${versions[@]}"; do
dpkg-deb -b -Zgzip "$version" "$app/tmp/var/root/Library/$1" 2>/dev/null
done
}
function make_apps {
dpkg-deb -b -Zgzip "$1" "$out/deb" 2>/dev/null
}
function composite {
cd "$out"
dpkg-scanpackages -m . >"$out/Packages"
gzip -9 -f "$out/Packages"
}
init_vars
reset_out
generator
composite