remaster/autogen.sh

108 lines
2.3 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-06 23:11:25 +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() {
echo "copy files ..."
2018-05-06 23:11:25 +00:00
# remaster
mkdir -p build/usr/bin/
cp -v src/remaster.sh build/usr/bin/remaster
chmod +x build/usr/bin/remaster
# 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
# 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 17:54:34 +00:00
#changelog
mkdir -p build/usr/share/doc/remaster
cp -v changes/remaster.md build/usr/share/doc/remaster/changelog
gzip build/usr/share/doc/remaster/changelog
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-06 23:58:55 +00:00
sed -i "s#<ROOTDIR>#$1#g" build/usr/bin/remaster
2018-05-06 23:30:50 +00:00
for i in proj func mods; do
2018-05-06 23:58:55 +00:00
sed -i "s#<ROOTDIR>#$1#g" build/usr/lib/remaster/$i/*
2018-05-06 23:30:50 +00:00
done
}
function set_libdir() {
2018-05-06 23:58:55 +00:00
sed -i "s#<LIBDIR>#$1#g" build/usr/bin/remaster
2018-05-06 23:30:50 +00:00
for i in proj func mods; do
2018-05-06 23:58:55 +00:00
sed -i "s#<LIBDIR>#$1#g" build/usr/lib/remaster/$i/*
2018-05-06 23:30:50 +00:00
done
}
2018-05-06 23:34:59 +00:00
#modes
2018-05-06 23:30:50 +00:00
function debug() {
clean
2018-05-12 18:19:12 +00:00
copy
2018-05-06 23:30:50 +00:00
set_rootdir "`pwd`/build"
set_libdir "`pwd`/build/usr/lib/remaster"
}
function install() {
clean
2018-05-12 18:19:12 +00:00
copy
2018-05-06 23:30:50 +00:00
set_rootdir ""
set_libdir "/usr/lib/remaster"
#cp -f -r build/* /
}
2018-05-12 18:19:12 +00:00
function build-deb() {
2018-05-12 17:54:34 +00:00
clean
#prebuild
2018-05-12 18:19:12 +00:00
copy
2018-05-12 17:54:34 +00:00
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
#set size
SIZE="`du --exclude=build/DEBIAN -c build/ | cut -f 1 | tail -n 1`"
sed -i "s/<SIZE>/$SIZE/g" build/DEBIAN/control
##
#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-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
install)
2018-05-06 23:11:25 +00:00
install || exit 1
;;
2018-05-06 17:26:21 +00:00
clean)
2018-05-06 23:11:25 +00:00
clean || exit 1
;;
2018-05-06 17:26:21 +00:00
debug)
2018-05-06 23:11:25 +00:00
debug || exit 1
;;
2018-05-12 18:19:12 +00:00
copy)
copy || exit 1
2018-05-06 23:34:59 +00:00
;;
2018-05-12 18:19:12 +00:00
build-deb)
build-deb || exit 1
2018-05-12 17:54:34 +00:00
;;
2018-05-06 17:26:21 +00:00
*)
2018-05-12 18:19:12 +00:00
echo "Usage: install | clean | debug | build-deb"
2018-05-06 23:11:25 +00:00
exit 1
2018-05-06 17:26:21 +00:00
esac