-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#227 make deb script configurable using params
- Loading branch information
Showing
2 changed files
with
38 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
#!/bin/bash -e | ||
#!/bin/bash | ||
set -eo pipefail | ||
|
||
# deb constants | ||
version=1.0 | ||
|
@@ -8,15 +9,34 @@ architecture=amd64 | |
maintainer="The Ehrenamtskarte Team <[email protected]>" | ||
description="Backend server for the Ehrenamtskarte app" | ||
|
||
# read input | ||
while getopts v:r:a:n:t:h flag | ||
do | ||
case "${flag}" in | ||
v) version=${OPTARG};; | ||
r) revision=${OPTARG};; | ||
a) architecture=${OPTARG};; | ||
n) name=${OPTARG};; | ||
t) tarfile=${OPTARG};; | ||
h) | ||
echo "$0 [-v version] [-r revision] [-a architecture] [-n name] -t backend_tar" | ||
exit 0;; | ||
esac | ||
done | ||
|
||
if [[ -z "$tarfile" ]]; then | ||
echo "Must provide input tar file using -t file" 1>&2 | ||
exit 1 | ||
fi | ||
|
||
debworkdir=$(mktemp -d) | ||
fullname=${name}_${version}-${revision}_${architecture} | ||
debworkdir=build/$fullname | ||
debfile=build/${fullname}.deb | ||
ctrlfile=${debworkdir}/DEBIAN/control | ||
debfile=${fullname}.deb | ||
|
||
# init deb workdir | ||
mkdir -p $debworkdir | ||
rm -rf ${debworkdir}/* | ||
mkdir ${debworkdir}/DEBIAN | ||
ctrlfile=${debworkdir}/DEBIAN/control | ||
echo "Creating control file in $ctrlfile …" | ||
touch $ctrlfile | ||
echo "Package: $name" >> $ctrlfile | ||
echo "Version: $version" >> $ctrlfile | ||
|
@@ -25,8 +45,13 @@ echo "Maintainer: $maintainer" >> $ctrlfile | |
echo "Description: $description" >> $ctrlfile | ||
|
||
# copy files to deb workdir | ||
echo "Copying $tarfile …" | ||
mkdir -p ${debworkdir}/var/ehrenamtskarte/backend | ||
tar -xf build/distributions/backend.tar -C ${debworkdir}/var/ehrenamtskarte | ||
tar -xf $tarfile -C ${debworkdir}/var/ehrenamtskarte | ||
|
||
# build the deb | ||
dpkg-deb --build --root-owner-group $debworkdir $debfile | ||
|
||
# clean up | ||
echo "Cleaning up …" | ||
rm -rf $debworkdir |