debmaker/lib/function.sh

133 lines
2.3 KiB
Bash

#!/bin/bash
CACHE_APP=cache/${APP}/
CACHE_STEP1=cache/${DEBIAN_VERSION_CODENAME}
CACHE_STEP2=cache/${APP}/envinit
CACHE_STEP3=cache/${APP}/prebuild
CACHE_STEP4=cache/${APP}/build
#DownloadOs
step1() {
if [ ! -e ${CACHE_STEP1} ]
then
mkdir -p ${CACHE_STEP1}/proc
mount -t proc proc ${CACHE_STEP1}/proc
sleep 2
debootstrap ${DEBIAN_VERSION_CODENAME} ${CACHE_STEP1}
umount ${CACHE_STEP1}/proc
fi
}
#InstallOs
step2(){
if [ ! -e ${CACHE_STEP2} ] ; then
mkdir -p ${CACHE_APP}
cp -a ${CACHE_STEP1}/ ${CACHE_STEP2}
cp ressources/${APP}/recette ${CACHE_STEP2}/tmp/recette
mount -t proc proc ${CACHE_STEP2}/proc
sleep 2
chroot ${CACHE_STEP2} /tmp/recette envinit
umount ${CACHE_STEP2}/proc
rm ${CACHE_STEP2}/tmp/envinit
fi
}
#ConfigureBeforeBuild
step3(){
if [ ! -e ${CACHE_STEP3} ]; then
cp -a ${CACHE_STEP2} ${CACHE_STEP3}
cp ressources/${APP}/recette ${CACHE_STEP3}/tmp/recette
chroot ${CACHE_STEP3} /tmp/recette prebuild ${GIT_VERSION}
rm ${CACHE_STEP3}/tmp/prebuild
fi
}
#Build
step4(){
if [ ! -e ${CACHE_STEP4} ] ; then
cp -a ${CACHE_STEP3} ${CACHE_STEP4}
cp ressources/${APP}/recette ${CACHE_STEP4}/tmp/recette
mount -t proc proc ${CACHE_STEP4}/proc/
sleep 2
chroot ${CACHE_STEP4} /tmp/recette build
umount ${CACHE_STEP4}/proc/
fi
}
#PackageDeb
step5(){
rm -fr dist/${APP}
mkdir dist/${APP}
cp -pfr ressources/${APP}/rootfs/* dist/$APP/
bash ressources/${APP}/recette makedeb ${CACHE_STEP4} dist/${APP} ${GIT_VERSION}
sed -i "s/%VERSION%/$DEB_VERSION/" dist/${APP}/DEBIAN/control
fakeroot dpkg-deb -Z gzip --build dist/${APP} dist
rm -fr dist/${APP}
}
allstep(){
step1
step2
step3
step4
step5
}
DeleteStep1(){
rm -fr ${CACHE_STEP1} ${CACHE_STEP2} ${CACHE_STEP3} ${CACHE_STEP4}
}
DeleteStep2(){
rm -fr ${CACHE_STEP2} ${CACHE_STEP3} ${CACHE_STEP4}
}
DeleteStep3(){
rm -fr ${CACHE_STEP3} ${CACHE_STEP4}
}
DeleteStep4(){
rm -fr ${CACHE_STEP4}
}
StartFromStep1(){
DeleteStep1
allstep
}
StartFromStep2(){
DeleteStep2
allstep
}
StartFromStep3(){
DeleteStep3
allstep
}
StartFromStep4(){
DeleteStep4
allstep
}
GotoStep1(){
chroot ${CACHE_STEP1}
}
GotoStep2(){
chroot ${CACHE_STEP2}
}
GotoStep3(){
chroot ${CACHE_STEP3}
}
GotoStep4(){
mount -t proc proc ${CACHE_STEP4}/proc/
chroot ${CACHE_STEP4}
umount ${CACHE_STEP4}/proc/
}
Clean(){
rm -fr cache/*
}
CleanAll(){
rm -fr cache/*
}