-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuildpackage
executable file
·78 lines (65 loc) · 1.65 KB
/
buildpackage
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
#!/bin/bash
function create_local_debian_repo() {
mkdir -p /tmp/pkgs
cp /mnt/pkgs/*.deb /tmp/pkgs
pushd /tmp/pkgs
dpkg-scanpackages . /dev/null | gzip -9c > Packages.gz
popd
echo "deb [trusted=yes] file:/tmp/pkgs /" > \
/etc/apt/sources.list.d/001local.list
cat > /etc/apt/preferences.d/001local.pref << EOF
Package: *
Pin: origin ""
Pin-Priority: 999
EOF
}
function pin_danos_repos() {
cat > /etc/apt/preferences.d/998danos << EOF
Package: *
Pin: release o=DANOS
Pin-Priority: 998
EOF
}
function setup_apt() {
create_local_debian_repo
pin_danos_repos
apt-get update
}
function import_source() {
cp -a /mnt/src /build/src
chown -R builduser:builduser /build/
}
function install_build_dependencies() {
apt-get -y install base-files-vyatta lintian-profile-vyatta
mk-build-deps --install --remove --tool \
"apt-get -o Debug::pkgProblemResolver=yes \
--no-install-recommends -y" \
debian/control
}
function build_package() {
local gbp_args="--git-verbose \
--git-ignore-branch \
--git-ignore-new \
--git-export-dir=.."
local dpkg_args="-us -uc -i -b"
if git rev-parse --verify --quiet origin/pristine-tar>/dev/null ; then
git branch pristine-tar origin/pristine-tar
else
gbp_args="$gbp_args --git-no-pristine-tar"
fi
local cmd="gbp buildpackage $gbp_args $dpkg_args"
echo "$cmd"
su builduser -c "$cmd"
}
function export_package() {
chmod 666 ../*.deb
cp ../*.deb /mnt/output
}
export DEBIAN_FRONTEND=noninteractive
setup_apt
import_source || exit 1
pushd /build/src
install_build_dependencies || exit 1
build_package || exit 1
export_package
popd