Files
shorter/autogen.sh
2019-03-07 00:45:10 +01:00

101 lines
2.1 KiB
Bash
Executable File

#!/bin/bash
# install | clean | debug | build-deb
function clean() {
echo "clear build"
[ -d build ] && rm -v -R build
mkdir build
}
function copy() {
echo "copy files ..."
# shorter
mkdir -p build/usr/bin/
cp -v src/shorter build/usr/bin/shorter
chmod +x build/usr/bin/shorter
##changelog
#mkdir -p build/usr/share/doc/shorter
#cp -v changes/shorter.md build/usr/share/doc/shorter/changelog
#gzip --best build/usr/share/doc/shorter/changelog
}
#modes
function debug() {
clean
#prebuild
copy
}
function install() {
#überprüfe auf root
[ "`id -u`" != "0" ] && { echo "Error start as root"; exit 1; }
#lösche alltes build dir
clean
#prebuild
copy
#set owner
chown -R root:root build/
#install
cp -f -r build/* /
}
function build-deb() {
#überprüfe auf root
[ "`id -u`" != "0" ] && { echo "Error start as root"; exit 1; }
#lösche alltes build dir
clean
#prebuild
copy
####
## changes for deb file
####
cp -v -r -f DEBIAN build/
#create md5sums
find ./build -type f -exec md5sum {} \; | grep -v './build/DEBIAN' | sed 's/\.\/build\///g' > build/DEBIAN/md5sums
chmod 0644 build/DEBIAN/md5sums
#set size
SIZE="`du --exclude=build/DEBIAN -c build/ | cut -f 1 | tail -n 1`"
sed -i "s/<SIZE>/$SIZE/g" build/DEBIAN/control
#set owner
chown -R root:root build/
##
#build deb
##
dpkg -b build/
version="`cat build/DEBIAN/control | grep Version | cut -d " " -f 2`"
arch="`cat build/DEBIAN/control | grep Arch | cut -d " " -f 2`"
[ -f "release/shorter_"$version"_"$arch".deb" ] && rm "release/shorter_"$version"_"$arch".deb"
mkdir -p release
mv -v "build.deb" "release/shorter_"$version"_"$arch".deb"
}
case "$1" in
install)
install || exit 1
;;
clean)
clean || exit 1
;;
debug)
debug || exit 1
;;
copy)
copy || exit 1
;;
build-deb)
build-deb || exit 1
;;
*)
echo "Usage: install | clean | debug | build-deb"
exit 1
esac