blob: 1c396c5a55d3cf31a227d5d63d2dc13af6546ca0 (
plain)
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
|
#!/bin/sh
# This script builds squashfs-tools-ng packages inside a Docker
# instance.
#
# It can build packages for:
#
# * alpine
# * archlinux
# * centos
# * fedora
# * debian
# * ubuntu
# * opensuse
#
# Currently it can only build package from a release (tag from github).
#
# TODO: Find a way to build packages from git checkout sources
# Path to the source directory mounted in the Docker instance.
ROOT_RO=/source-ro
# Path to which packages will be copied after a successful build.
OUTPUT=/output
. /etc/os-release
build_alpine() {
cp -r $ROOT_RO/packages/APKBUILD .
abuild-keygen -nai
abuild -r
cp ~/packages/*/x86_64/*.apk $OUTPUT
}
build_archlinux() {
cp -r $ROOT_RO/packages/PKGBUILD .
makepkg --noconfirm -Cfsir PKGBUILD
cp ~/*.tar.zst $OUTPUT
}
# This part is a ugly hack.
# TODO: Find a better way to build deb packages.
build_deb() {
# Fetch sources
wget \
https://github.com/AgentD/squashfs-tools-ng/archive/v$version/squashfs-tools-ng-$version.tar.gz \
-O squashfs-tools-ng_$version+$VERSION_CODENAME.orig.tar.gz
tar xfz squashfs-tools-ng_$version+$VERSION_CODENAME.orig.tar.gz
cd squashfs-tools-ng-$version
cp -r $ROOT_RO/packages/debian .
#ln -s packages/debian
DEBFULLNAME="$USER" DEBEMAIL="$USER@localhost" \
dch -v $version+$VERSION_CODENAME-1 \
-D $VERSION_CODENAME "Build $version for $VERSION_CODENAME."
# See https://packages.debian.org/search?searchon=sourcenames&keywords=debhelper
# https://packages.ubuntu.com/search?keywords=debhelper&searchon=names&suite=all§ion=all
case "$VERSION_CODENAME" in
jessie|xenial) dhv=9 ;;
stretch) dhv=10 ;;
bionic) dhv=11 ;;
buster|focal) dhv=12 ;;
bookworm|bullseye|groovy) dhv=13 ;;
sid) dhv=13 ;;
esac
sed -i -e "s/@DEBHELPER_VERSION@/$dhv/" debian/control
echo $dhv > debian/compat
sudo mk-build-deps --install \
--tool='apt-get --no-install-recommends --yes' debian/control
sudo rm -f *-build-deps_*
debuild
debuild -- clean
cat /tmp/squashfs-tools-ng*
cp ../*.deb $OUTPUT
}
build_rpm() {
case "$ID" in
centos)
if test $VERSION_ID -ge 8; then
# install doxygen
sudo sed -i 's/^enabled=.*/enabled=1/' \
/etc/yum.repos.d/CentOS-PowerTools.repo
cat /etc/yum.repos.d/CentOS-PowerTools.repo
fi
;;
esac
cp -r $ROOT_RO/packages/squashfs-tools-ng.spec .
rpmdev-setuptree
spectool -g -R squashfs-tools-ng.spec
rpmspec --parse squashfs-tools-ng.spec \
| grep BuildRequires | cut -d' ' -f2 \
| xargs sudo yum install -y
rpmbuild --clean -ba squashfs-tools-ng.spec
cp ~/rpmbuild/RPMS/x86_64/*.rpm $OUTPUT
}
build_opensuse() {
cp -r $ROOT_RO/packages/squashfs-tools-ng.spec .
# Fetch source
rpmspec --parse squashfs-tools-ng.spec | grep Source0 \
| awk '{print $2}' \
| xargs wget -N -P $(rpm --eval '%{_sourcedir}')
# Install build requirements
rpmspec --parse squashfs-tools-ng.spec | grep BuildRequires \
| cut -d' ' -f2 \
| xargs sudo zypper install -y
rpmbuild --clean -ba squashfs-tools-ng.spec
cp ~/rpmbuild/RPMS/x86_64/*.rpm $OUTPUT
}
case "$ID" in
alpine) build_alpine ;;
archlinux|arch) build_archlinux ;;
centos|fedora) build_rpm;;
debian|ubuntu) build_deb;;
opensuse|opensuse-leap) build_opensuse;;
*) cat <<EOF >&2
Unsupported distro "$ID"
EOF
exit 1
;;
esac
|