tools-musl: pull out code in run scripts

This commit is contained in:
Anthony G. Basile 2014-06-28 06:44:04 -04:00
parent 1b1c6c367c
commit 54ad5b197e
4 changed files with 65 additions and 159 deletions

62
tools-musl/common.sh Normal file
View file

@ -0,0 +1,62 @@
#!/bin/bash
source /etc/catalyst/catalyst.conf
mydate=`date +%Y%m%d`
undo_grsec() {
[[ -d /proc/sys/kernel/grsecurity ]] || return
for i in /proc/sys/kernel/grsecurity/chroot_* ; do
echo 0 > $i
done
}
banner() {
cat << EOF | tee -a zzz.log > stage$1-$2-musl-$3.log
************************************************************************
* stage$1-$2-musl-$3
************************************************************************"
EOF
}
do_stages() {
local arch=$1
local flavor=$2
for s in 1 2 3; do
local tgpath="${storedir}/builds/musl/${flavor}/${arch}"
local target="stage${s}-${arch}-musl-${flavor}-${mydate}.tar.bz2"
local tglink="stage${s}-${arch}-musl-${flavor}.tar.bz2"
if [[ ! -f "${tgpath}/${tglink}" ]]; then
touch stage${s}-${arch}-musl-${flavor}.log
echo "!!! ${tglink} at ${tgpath} doesn't exist" \
| tee -a zzz.log \
> stage${s}-${arch}-musl-${flavor}.err
return 1
fi
banner ${s} ${arch} ${flavor}
catalyst -f stage${s}-${arch}-musl-${flavor}.conf \
| tee -a zzz.log \
> stage${s}-${arch}-musl-${flavor}.log \
2> stage${s}-${arch}-musl-${flavor}.err
if [[ -f "${tgpath}/${target}" ]]; then
rm -f "${tgpath}/${tglink}"
ln -s ${target} "${tgpath}/${tglink}"
else
echo "!!! ${target} was not generated" \
| tee -a zzz.log \
>stage${s}-${arch}-musl-${flavor}.err
return 1
fi
done
return 0
}

View file

@ -1,8 +1,6 @@
#!/bin/bash
source /etc/catalyst/catalyst.conf
mydate=`date +%Y%m%d`
source common.sh
prepare_confs() {
local arch=$1
@ -42,54 +40,6 @@ prepare_confs() {
sed -i "/^chost/d" stage3-${arch}-musl-${flavor}.conf
}
banner() {
cat << EOF | tee -a zzz.log > stage$1-$2-musl-$3.log
************************************************************************
* stage$1-$2-musl-$3
************************************************************************"
EOF
}
do_stages() {
local arch=$1
local flavor=$2
for s in 1 2 3; do
local tgpath="${storedir}/builds/musl/${flavor}/${arch}"
local target="stage${s}-${arch}-musl-${flavor}-${mydate}.tar.bz2"
local tglink="stage${s}-${arch}-musl-${flavor}.tar.bz2"
if [[ ! -f "${tgpath}/${tglink}" ]]; then
touch stage${s}-${arch}-musl-${flavor}.log
echo "!!! ${target} at ${tgpath} doesn't exit" \
| tee -a zzz.log \
> stage${s}-${arch}-musl-${flavor}.err
return 1
fi
banner ${s} ${arch} ${flavor}
catalyst -f stage${s}-${arch}-musl-${flavor}.conf \
| tee -a zzz.log \
> stage${s}-${arch}-musl-${flavor}.log \
2> stage${s}-${arch}-musl-${flavor}.err
if [[ -f "${tgpath}/${target}" ]]; then
rm -f "${tgpath}/${tglink}"
ln -s ${target} "${tgpath}/${tglink}"
else
echo "!!! ${target} was not generated" \
| tee -a zzz.log \
>stage${s}-${arch}-musl-${flavor}.err
return 1
fi
done
return 0
}
main() {
>zzz.log

View file

@ -1,8 +1,6 @@
#!/bin/bash
source /etc/catalyst/catalyst.conf
mydate=`date +%Y%m%d`
source common.sh
prepare_confs() {
local arch=$1
@ -34,53 +32,6 @@ prepare_confs() {
sed -i "/^chost/d" stage3-${arch}-musl-${flavor}.conf
}
banner() {
cat << EOF | tee -a zzz.log > stage$1-$2-musl-$3.log
************************************************************************
* stage$1-$2-musl-$3
************************************************************************"
EOF
}
do_stages() {
local arch=$1
local flavor=$2
for s in 1 2 3; do
local tgpath="${storedir}/builds/musl/${flavor}/${arch}"
local target="stage${s}-${arch}-musl-${flavor}-${mydate}.tar.bz2"
local tglink="stage${s}-${arch}-musl-${flavor}.tar.bz2"
if [[ ! -f "${tgpath}/${tglink}" ]]; then
touch stage${s}-${arch}-musl-${flavor}.log
echo "!!! ${target} at ${tgpath} doesn't exit" \
| tee -a zzz.log \
> stage${s}-${arch}-musl-${flavor}.err
return 1
fi
banner ${s} ${arch} ${flavor}
catalyst -f stage${s}-${arch}-musl-${flavor}.conf \
| tee -a zzz.log \
> stage${s}-${arch}-musl-${flavor}.log \
2> stage${s}-${arch}-musl-${flavor}.err
if [[ -f "${tgpath}/${target}" ]]; then
rm -f "${tgpath}/${tglink}"
ln -s ${target} "${tgpath}/${tglink}"
else
echo "!!! ${target} was not generated" \
| tee -a zzz.log \
>stage${s}-${arch}-musl-${flavor}.err
return 1
fi
done
return 0
}
main() {

View file

@ -1,15 +1,6 @@
#!/bin/bash
source /etc/catalyst/catalyst.conf
mydate=`date +%Y%m%d`
undo_grsec() {
[[ -d /proc/sys/kernel/grsecurity ]] || return
for i in /proc/sys/kernel/grsecurity/chroot_* ; do
echo 0 > $i
done
}
source common.sh
prepare_confs() {
local arch=$1
@ -43,54 +34,6 @@ prepare_confs() {
sed -i "/^chost/d" stage3-${arch}-musl-${flavor}.conf
}
banner() {
cat << EOF | tee -a zzz.log > stage$1-$2-musl-$3.log
************************************************************************
* stage$1-$2-musl-$3
************************************************************************"
EOF
}
do_stages() {
local arch=$1
local flavor=$2
for s in 1 2 3; do
local tgpath="${storedir}/builds/musl/${flavor}/${arch}"
local target="stage${s}-${arch}-musl-${flavor}-${mydate}.tar.bz2"
local tglink="stage${s}-${arch}-musl-${flavor}.tar.bz2"
if [[ ! -f "${tgpath}/${tglink}" ]]; then
touch stage${s}-${arch}-musl-${flavor}.log
echo "!!! ${tglink} at ${tgpath} doesn't exist" \
| tee -a zzz.log \
> stage${s}-${arch}-musl-${flavor}.err
return 1
fi
banner ${s} ${arch} ${flavor}
catalyst -f stage${s}-${arch}-musl-${flavor}.conf \
| tee -a zzz.log \
> stage${s}-${arch}-musl-${flavor}.log \
2> stage${s}-${arch}-musl-${flavor}.err
if [[ -f "${tgpath}/${target}" ]]; then
rm -f "${tgpath}/${tglink}"
ln -s ${target} "${tgpath}/${tglink}"
else
echo "!!! ${target} was not generated" \
| tee -a zzz.log \
>stage${s}-${arch}-musl-${flavor}.err
return 1
fi
done
return 0
}
main() {
>zzz.log