Add deb packaging

Signed-off-by: Krsna Mahapatra <keshto@gmail.com>
This commit is contained in:
Krsna Mahapatra
2020-04-17 15:02:26 -07:00
committed by Patrick East
parent caa4072279
commit bd3a25ab2d
3 changed files with 85 additions and 0 deletions
+10
View File
@@ -115,6 +115,16 @@ docs-%:
man: man:
./build/gen-man.sh man ./build/gen-man.sh man
######################################################
#
# Linux distro package targets
#
######################################################
.PHONY: deb
deb:
VERSION=$(VERSION) ./build/gen-deb.sh
###################################################### ######################################################
# #
# Wasm targets # Wasm targets
+12
View File
@@ -46,6 +46,7 @@ build_release() {
GOOS=linux GOARCH=amd64 make build GOOS=linux GOARCH=amd64 make build
GOOS=windows GOARCH=amd64 make build GOOS=windows GOARCH=amd64 make build
mv opa_windows_amd64 opa_windows_amd64.exe mv opa_windows_amd64 opa_windows_amd64.exe
build_distro_packages
mv opa_*_* $OUTPUT_DIR mv opa_*_* $OUTPUT_DIR
} }
@@ -57,6 +58,17 @@ clone_repo() {
fi fi
} }
build_distro_packages() {
if [ -f build/gen-deb.sh ]; then
make man
# If VERSION is not set, set it to `make version`
VERSION=${VERSION:-`make version`} make deb
mv opa_*.* $OUTPUT_DIR
else
echo "Skip building distro packages. Could not find gen-deb.sh."
fi
}
main() { main() {
clone_repo clone_repo
build_release build_release
+63
View File
@@ -0,0 +1,63 @@
set -e
if [ ! -f "opa_linux_amd64" ]; then
echo "ERROR: File 'opa_linux_amd64' not found. First build it 'make build-linux'."
exit 1
fi
if [ ! -d "man" ]; then
echo "ERROR: The man pages not found. First build them 'make man'."
exit 1
fi
if [ -z "$VERSION" ]; then
echo "ERROR: Need to have VERSION environment variable set."
exit 1
fi
if ! command -v dpkg-deb >/dev/null 2>/dev/null; then
echo "ERROR: 'dpkg-deb' was not found and is required."
exit 1
fi
rm -rf tmp_working_dir_opa
mkdir tmp_working_dir_opa
cd tmp_working_dir_opa
mkdir -p ./usr/bin/
cp ../opa_linux_amd64 ./usr/bin/opa
chmod +x ./usr/bin/opa
mkdir -p ./usr/share/man/man1/
for MAN_PAGE in ../man/*.1; do
gzip --keep --best $MAN_PAGE
done
mv ../man/*.1.gz ./usr/share/man/man1/
echo "Package: opa" > control
echo "Version: $VERSION" >> control
cat << 'EOF' >> control
Architecture: amd64
Maintainer: OPA Maintainers <cncf-opa-maintainers@lists.cncf.io>
Depends: libc6 (>= 2.2.5)
Section: admin
Priority: optional
Homepage: https://openpolicyagent.org
Description: An open source, general-purpose policy engine.
The Open Policy Agent (OPA) is an open source, general-purpose
policy engine that enables unified, context-aware policy
enforcement across the entire stack.
EOF
md5sum ../opa_linux_amd64 > md5sums
mkdir -p opa_$VERSION/DEBIAN
mv control opa_$VERSION/DEBIAN/control
mv md5sums opa_$VERSION/DEBIAN/md5sums
mv ./usr opa_$VERSION/usr
dpkg-deb -b opa_$VERSION/
mv opa_$VERSION.deb ../
cd ..
rm -rf tmp_working_dir_opa