test cleanup

This commit is contained in:
artoo 2014-11-13 01:20:33 +01:00
parent 93287f6582
commit e1966fe955
2 changed files with 67 additions and 55 deletions

View file

@ -36,13 +36,28 @@ fi
load_vars "$USER_HOME/.makepkg.conf"
load_vars /etc/makepkg.conf
chroot_create(){
mkdir -p "${chrootdir}"
setarch "${arch}" mkchroot \
${mkchroot_args[*]} \
"${chrootdir}/root" \
"${base_packages[*]}" || abort
}
chroot_update(){
lock 9 "${chrootdir}/root.lock" "Locking clean chroot"
chroot-run ${mkchroot_args[*]} \
"${chrootdir}/root" \
pacman -Syu --noconfirm || abort
}
chroot_build(){
if ${is_profile};then
msg "Start building profile: [${profile}]"
for pkg in $(cat ${profiledir}/${profile}.set); do
cd $pkg
if [[ $pkg == 'eudev' ]] || [[ $pkg == 'lib32-eudev' ]]; then
blacklist_pkg
blacklist_pkg "${chrootdir}"
fi
setarch "${arch}" \
mkchrootpkg ${mkchrootpkg_args[*]} -- "${makepkg_args[*]}" || break
@ -53,7 +68,7 @@ chroot_build(){
else
cd ${profile}
if [[ ${profile} == 'eudev' ]] || [[ ${profile} == 'lib32-eudev' ]]; then
blacklist_pkg
blacklist_pkg "${chrootdir}"
fi
setarch "${arch}" \
mkchrootpkg ${mkchrootpkg_args[*]} -- "${makepkg_args[*]}" || abort
@ -63,35 +78,17 @@ chroot_build(){
}
chroot_init(){
if ${clean_first} || [[ ! -d "${chrootdir}" ]]; then
if ${clean_first}; then
msg "Creating chroot for [${branch}] (${arch})..."
for copy in "${chrootdir}"/*; do
[[ -d $copy ]] || continue
msg2 "Deleting chroot copy '$(basename "${copy}")'..."
lock 9 "$copy.lock" "Locking chroot copy '$copy'"
if [[ "$(stat -f -c %T "${copy}")" == btrfs ]]; then
{ type -P btrfs && btrfs subvolume delete "${copy}"; } &>/dev/null
fi
rm -rf --one-file-system "${copy}"
done
exec 9>&-
rm -rf --one-file-system "${chrootdir}"
mkdir -p "${chrootdir}"
setarch "${arch}" mkchroot \
${mkchroot_args[*]} \
"${chrootdir}/root" \
"${base_packages[*]}" || abort
clean_up
chroot_clean "${chrootdir}"
chroot_create
elif [[ ! -d "${chrootdir}" ]];then
msg "Creating chroot for [${branch}] (${arch})..."
chroot_create
else
msg "Updating chroot for [${branch}] (${arch})..."
lock 9 "${chrootdir}/root.lock" "Locking clean chroot"
chroot-run \
${mkchroot_args[*]} \
"${chrootdir}/root" \
pacman -Syu --noconfirm || abort
chroot_update
fi
}
@ -136,26 +133,21 @@ display_settings(){
run(){
eval_profile
if ${pretend}; then
if ${wipe_clean}; then
git_clean "n"
fi
display_settings
exit 1
else
if ${wipe_clean}; then
msg "Cleaning up ..."
git_clean "q"
clean_dir "${pkgdir}"
fi
# if ${wipe_clean}; then
# clean_up
# fi
display_settings
chroot_init
prepare_dir "${pkgdir}"
chroot_build
ch_owner "$(dirname ${pkgdir})"
# if ${sign}; then
# sign_pkgs
# fi
if ${sign}; then
sign_pkgs
fi
fi
}
@ -168,7 +160,7 @@ load_config '@sysconfdir@'
pacman_conf_arch='default'
clean_first=false
wipe_clean=false
# wipe_clean=false
namcap=false
pretend=false
is_profile=false
@ -186,8 +178,8 @@ usage() {
echo " -a <arch> Set arch [default: ${arch}]"
echo " -b <branch> Set branch [default: ${branch}]"
echo " -r <dir> Chroots directory [default: ${chroots}]"
echo ' -c Clean chroot'
echo ' -w Wipe clean pkgbuild and pkg directory'
echo ' -c Clean up and recreate chroot'
# echo ' -w Wipe clean pkgbuild and pkg directory'
echo ' -n Run namcap check'
echo ' -s Sign packages'
echo ' -q Query settings and pretend build'
@ -199,7 +191,7 @@ usage() {
orig_argv=("$@")
opts='p:a:b:r:cwnsqh'
opts='p:a:b:r:cnsqh'
while getopts "${opts}" arg; do
case "${arg}" in
@ -208,7 +200,7 @@ while getopts "${opts}" arg; do
b) branch="$OPTARG" ;;
r) chroots="$OPTARG" ;;
c) clean_first=true ;;
w) wipe_clean=true ;;
# w) wipe_clean=true ;;
n) namcap=true; mkchrootpkg_args+=(-n) ;;
s) sign=true ;;
q) pretend=true ;;

View file

@ -48,15 +48,17 @@ prepare_dir(){
fi
}
clean_dir(){
msg2 "Cleaning $1 ..."
rm -r $1/*
}
clean_src(){
if [[ -n
msg2 "Cleaning $(pwd) ..."
git clean -dfx$1
clean_up(){
msg "Cleaning up ..."
if [[ -n $LOGDEST ]];then
msg2 "Cleaning logs $LOGDEST ..."
rm $LOGDEST/*.log
else
msg2 "Cleaning logs $(pwd) ..."
rm $(pwd)/*.log
fi
msg2 "Cleaning ${pkgdir} ..."
rm ${pkgdir}/*.$ext
}
eval_profile(){
@ -67,11 +69,29 @@ eval_profile(){
}
blacklist_pkg(){
local blacklist=('libsystemd') cmd=$(pacman -Q ${blacklist[@]} -r ${chrootdir}/root 2> /dev/null)
local blacklist=('libsystemd') cmd=$(pacman -Q ${blacklist[@]} -r $1/root 2> /dev/null)
if [[ -n $cmd ]] ; then
msg2 "Removing blacklisted [${blacklist[@]}] ..."
setarch "${arch}" pacman -Rdd "${blacklist[@]}" -r ${chrootdir}/root --noconfirm
pacman -Rdd "${blacklist[@]}" -r $1/root --noconfirm
else
msg2 "Blacklisted [${blacklist[@]}] not present."
fi
}
chroot_clean(){
for copy in "$1"/*; do
[[ -d $copy ]] || continue
msg2 "Deleting chroot copy '$(basename "${copy}")'..."
lock 9 "$copy.lock" "Locking chroot copy '$copy'"
if [[ "$(stat -f -c %T "${copy}")" == btrfs ]]; then
{ type -P btrfs && btrfs subvolume delete "${copy}"; } &>/dev/null
fi
rm -rf --one-file-system "${copy}"
done
exec 9>&-
rm -rf --one-file-system "$1"
}