remaster/autogen.sh

133 lines
2.9 KiB
Bash
Raw Normal View History

2018-04-26 11:23:51 +00:00
#!/bin/bash
2018-05-12 18:19:12 +00:00
# install | clean | debug | build-deb
2018-04-26 11:23:51 +00:00
2018-05-06 23:09:19 +00:00
function clean() {
2018-05-12 18:19:38 +00:00
echo "clear build"
[ -d build ] && rm -v -R build
mkdir build
2018-05-06 23:09:19 +00:00
}
2018-05-12 18:19:12 +00:00
function copy() {
2018-05-12 18:19:38 +00:00
echo "copy files ..."
# remaster
mkdir -p build/usr/bin/
cp -v src/remaster.sh build/usr/bin/remaster
chmod +x build/usr/bin/remaster
2018-05-06 23:11:25 +00:00
2018-05-12 18:19:38 +00:00
# modules
mkdir -p build/usr/lib/remaster/
for i in proj func mods; do
mkdir -p build/usr/lib/remaster/$i
cp -v src/$i/* build/usr/lib/remaster/$i/
done
2018-05-06 23:11:25 +00:00
2018-05-12 18:19:38 +00:00
# setting
mkdir -p build/etc/remaster/
cp -v src/config.sample.cfg build/etc/remaster/config.sample.cfg
2018-04-26 18:58:19 +00:00
2018-05-12 18:19:38 +00:00
#changelog
mkdir -p build/usr/share/doc/remaster
cp -v changes/remaster.md build/usr/share/doc/remaster/changelog
2018-05-12 20:37:35 +00:00
gzip --best build/usr/share/doc/remaster/changelog
}
function rights() {
echo ja
2018-05-06 23:09:19 +00:00
}
2018-05-06 17:26:21 +00:00
2018-05-06 23:34:59 +00:00
#config ...
2018-05-06 23:30:50 +00:00
function set_rootdir() {
2018-05-12 18:19:38 +00:00
sed -i "s#<ROOTDIR>#$1#g" build/usr/bin/remaster
for i in proj func mods; do
sed -i "s#<ROOTDIR>#$1#g" build/usr/lib/remaster/$i/*
done
2018-05-06 23:30:50 +00:00
}
function set_libdir() {
2018-05-12 18:19:38 +00:00
sed -i "s#<LIBDIR>#$1#g" build/usr/bin/remaster
for i in proj func mods; do
sed -i "s#<LIBDIR>#$1#g" build/usr/lib/remaster/$i/*
done
2018-05-06 23:30:50 +00:00
}
2018-05-06 23:34:59 +00:00
#modes
2018-05-06 23:30:50 +00:00
function debug() {
2018-05-12 18:19:38 +00:00
clean
2018-05-12 20:37:35 +00:00
#prebuild
2018-05-12 18:19:38 +00:00
copy
set_rootdir "`pwd`/build"
set_libdir "`pwd`/build/usr/lib/remaster"
2018-05-06 23:30:50 +00:00
}
function install() {
2018-05-12 20:37:35 +00:00
#überprüfe auf root
[ "`id -u`" != "0" ] && { echo "Error start as root"; exit 1; }
#lösche alltes build dir
2018-05-12 18:19:38 +00:00
clean
2018-05-12 20:37:35 +00:00
#prebuild
2018-05-12 18:19:38 +00:00
copy
set_rootdir ""
set_libdir "/usr/lib/remaster"
2018-05-12 20:37:35 +00:00
#set owner
chown -r root:root build/
#install
cp -f -r build/* /
2018-05-06 23:30:50 +00:00
}
2018-05-12 18:19:12 +00:00
function build-deb() {
2018-05-12 20:37:35 +00:00
#überprüfe auf root
[ "`id -u`" != "0" ] && { echo "Error start as root"; exit 1; }
#lösche alltes build dir
2018-05-12 18:19:38 +00:00
clean
2018-05-12 20:37:35 +00:00
2018-05-12 18:19:38 +00:00
#prebuild
copy
set_rootdir ""
set_libdir "/usr/lib/remaster"
####
## 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
2018-05-12 20:37:35 +00:00
2018-05-12 18:19:38 +00:00
#set size
SIZE="`du --exclude=build/DEBIAN -c build/ | cut -f 1 | tail -n 1`"
sed -i "s/<SIZE>/$SIZE/g" build/DEBIAN/control
2018-05-12 17:54:34 +00:00
2018-05-12 20:37:35 +00:00
#set owner
chown -r root:root build/
2018-05-12 18:19:38 +00:00
##
#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/remaster_"$version"_"$arch".deb" ] && rm "release/remaster_"$version"_"$arch".deb"
mv -v "build.deb" "release/remaster_"$version"_"$arch".deb"
2018-05-12 17:54:34 +00:00
}
2018-05-06 17:26:21 +00:00
2018-05-06 23:34:59 +00:00
2018-05-06 17:26:21 +00:00
case "$1" in
2018-05-12 18:19:38 +00:00
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
2018-05-06 17:26:21 +00:00
esac