debmaker/lib/function.sh

133 lines
2.3 KiB
Bash
Raw Normal View History

2022-01-23 21:49:01 +01:00
#!/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}
2022-02-12 18:30:28 +01:00
cp ressources/${APP}/recette ${CACHE_STEP2}/tmp/recette
2022-01-23 21:49:01 +01:00
mount -t proc proc ${CACHE_STEP2}/proc
sleep 2
2022-02-12 18:30:28 +01:00
chroot ${CACHE_STEP2} /tmp/recette envinit
2022-01-23 21:49:01 +01:00
umount ${CACHE_STEP2}/proc
rm ${CACHE_STEP2}/tmp/envinit
fi
}
#ConfigureBeforeBuild
step3(){
if [ ! -e ${CACHE_STEP3} ]; then
cp -a ${CACHE_STEP2} ${CACHE_STEP3}
2022-02-12 18:30:28 +01:00
cp ressources/${APP}/recette ${CACHE_STEP3}/tmp/recette
chroot ${CACHE_STEP3} /tmp/recette prebuild ${GIT_VERSION}
2022-01-23 21:49:01 +01:00
rm ${CACHE_STEP3}/tmp/prebuild
fi
}
#Build
step4(){
if [ ! -e ${CACHE_STEP4} ] ; then
cp -a ${CACHE_STEP3} ${CACHE_STEP4}
2022-02-12 18:30:28 +01:00
cp ressources/${APP}/recette ${CACHE_STEP4}/tmp/recette
2022-01-23 21:49:01 +01:00
mount -t proc proc ${CACHE_STEP4}/proc/
sleep 2
2022-02-12 18:30:28 +01:00
chroot ${CACHE_STEP4} /tmp/recette build
2022-01-23 21:49:01 +01:00
umount ${CACHE_STEP4}/proc/
fi
}
#PackageDeb
step5(){
rm -fr dist/${APP}
mkdir dist/${APP}
2022-02-03 22:51:24 +01:00
cp -pfr ressources/${APP}/rootfs/* dist/$APP/
2022-02-12 18:30:28 +01:00
bash ressources/${APP}/recette makedeb ${CACHE_STEP4} dist/${APP} ${GIT_VERSION}
2022-01-23 21:49:01 +01:00
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
}
2022-02-03 22:51:24 +01:00
DeleteStep1(){
2022-01-23 21:49:01 +01:00
rm -fr ${CACHE_STEP1} ${CACHE_STEP2} ${CACHE_STEP3} ${CACHE_STEP4}
2022-02-03 22:51:24 +01:00
}
DeleteStep2(){
rm -fr ${CACHE_STEP2} ${CACHE_STEP3} ${CACHE_STEP4}
}
DeleteStep3(){
rm -fr ${CACHE_STEP3} ${CACHE_STEP4}
}
DeleteStep4(){
rm -fr ${CACHE_STEP4}
}
StartFromStep1(){
DeleteStep1
2022-01-23 21:49:01 +01:00
allstep
}
StartFromStep2(){
2022-02-03 22:51:24 +01:00
DeleteStep2
2022-01-23 21:49:01 +01:00
allstep
}
StartFromStep3(){
2022-02-03 22:51:24 +01:00
DeleteStep3
2022-01-23 21:49:01 +01:00
allstep
}
StartFromStep4(){
2022-02-03 22:51:24 +01:00
DeleteStep4
2022-01-23 21:49:01 +01:00
allstep
}
GotoStep1(){
chroot ${CACHE_STEP1}
}
GotoStep2(){
chroot ${CACHE_STEP2}
}
GotoStep3(){
chroot ${CACHE_STEP3}
}
GotoStep4(){
2022-02-03 22:51:24 +01:00
mount -t proc proc ${CACHE_STEP4}/proc/
2022-01-23 21:49:01 +01:00
chroot ${CACHE_STEP4}
2022-02-03 22:51:24 +01:00
umount ${CACHE_STEP4}/proc/
2022-01-23 21:49:01 +01:00
}
2022-02-03 22:51:24 +01:00
Clean(){
rm -fr cache/*
}
CleanAll(){
rm -fr cache/*
}