56 lines
1.2 KiB
Bash
Executable File
56 lines
1.2 KiB
Bash
Executable File
#!/bin/bash
|
|
set -e
|
|
|
|
baseDir=$(dirname "$0")
|
|
gitDir="$baseDir/.."
|
|
projectName=$(basename "$(realpath "$gitDir")")
|
|
buildDir="/tmp/git-deploy/$projectName"
|
|
srcDir="$buildDir/src"
|
|
repreproDir="/var/cache/reprepro"
|
|
codename="stable"
|
|
logFile="$buildDir/deploy.log"
|
|
|
|
echo "Building source code."
|
|
echo " * Directory $buildDir"
|
|
|
|
rm -f "$logFile"
|
|
|
|
mkdir -p "$srcDir"
|
|
git --work-tree="$srcDir" --git-dir="$gitDir" checkout -f
|
|
|
|
if [ -f "$srcDir/package.json" ]
|
|
then
|
|
echo "Installing Node dependencies."
|
|
(cd "$srcDir" && npm --silent install >> "$logFile")
|
|
fi
|
|
|
|
if [ -f "$srcDir/debian/changelog" ]
|
|
then
|
|
echo "Cleaning last build."
|
|
rm -f "$buildDir/*.deb"
|
|
rm -f "$buildDir/*.changes"
|
|
rm -f "$buildDir/*.build"
|
|
(cd "$srcDir" && debian/rules clean >> "$logFile")
|
|
|
|
echo "Building Debian packages."
|
|
(cd "$srcDir" && debuild -uc -us -b >> "$logFile")
|
|
|
|
echo "Adding packages to repository."
|
|
packages=""
|
|
|
|
cut -d" " -f1 "$srcDir/debian/files" |
|
|
while read debFile
|
|
do
|
|
if [[ ! "$debFile" =~ .*\.deb$ ]]
|
|
then
|
|
continue
|
|
fi
|
|
|
|
packageName=$(echo $debFile | cut -d"_" -f1)
|
|
packages="$packages $packageName"
|
|
|
|
echo " * Adding $debFile"
|
|
reprepro -b "$repreproDir" includedeb $codename "$buildDir/$debFile" >> "$logFile"
|
|
done
|
|
fi
|