-
Notifications
You must be signed in to change notification settings - Fork 20
/
allpkgs.sh
executable file
·75 lines (69 loc) · 1.6 KB
/
allpkgs.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
70
71
72
73
74
75
#!/bin/bash
#################
# This script will populate a "aptly" repository with packages built from freepto
#
#################
tmp_repo=$1
if [ -z "$tmp_repo" ]; then
tmp_repo="freepto_$(date '+%y%m%d%H%M')_$(git rev-parse HEAD | head -c 8)"
fi
aptly repo create "$tmp_repo"
putinrepo() {
aptly repo add "$tmp_repo" "$1"
}
reposummary() {
echo "# Status of repository after building:"
aptly repo show -with-packages "$tmp_repo"
}
# LOAD CONFIGURATION:
if [ -r config/freepto ]; then
echo "Reading freepto configuration file...." >&2
. config/freepto
fi
if [ -r config/freepto.local ]; then
echo "Reading freepto local configuration file...." >&2
. config/freepto.local
fi
_build_packages() {
mkdir -p config/packages.chroot/
find -L pkgs -maxdepth 2 -type f -name '*.deb' -delete
find -L pkgs -maxdepth 1 -mindepth 1 -type d | \
while read pkg; do
_build_package "$pkg" || return 1
if [[ "$?" -ne 0 ]]; then
echo "ERROR: build for package $pkg failed" >&2
fi
done
}
_build_package() {
olddir=$(pwd)
dir=$1
echo "## Build pkg in $dir"
cd "$dir"
set -e
old_proxy=$http_proxy
export http_proxy=
if [ -x make_deb ]; then
./make_deb
elif [ -f deb ]; then
equivs-build -f deb
#TODO: if debian/rules blabla
elif [ -d debian ]; then
debuild -i -F
fi
http_proxy=$old_proxy
cd "$olddir"
}
if [[ -d pkgs/ ]]; then
set -o pipefail
echo "### Build sub-packages"
_build_packages 2>&1 | tee pkgs.log
if [ $? -ne 0 ]; then
echo "Error: Failure at build-packages phase" >&2
exit 1
fi
echo "### Installing build packages"
putinrepo pkgs
reposummary
echo "Repo ready: $tmp_repo"
fi