rm useless code

This commit is contained in:
artoo 2014-10-06 02:44:40 +02:00
parent 74765564e7
commit 10acda52c8
2 changed files with 67 additions and 77 deletions

View file

@ -73,13 +73,11 @@ else
fi fi
clean_first=false clean_first=false
clean_rundir=false
namcap=false namcap=false
sign=false
verbose=false
nosystemd=false nosystemd=false
pretend=false pretend=false
is_profile=false is_profile=false
clean_rundir=false
repo=false repo=false
base_packages=('base-devel') base_packages=('base-devel')
@ -98,10 +96,9 @@ usage() {
echo " -r <dir> Chroots directory [default: ${chroots}]" echo " -r <dir> Chroots directory [default: ${chroots}]"
echo ' -c Clean chroot and pkg cache' echo ' -c Clean chroot and pkg cache'
echo ' -n Run namcap check' echo ' -n Run namcap check'
echo ' -q Pretend build'
echo ' -w Wipe clean pkgbuild directory' echo ' -w Wipe clean pkgbuild directory'
echo ' -y Add packages to repo' echo ' -y Add packages to repo'
echo ' -v Verbose' echo ' -q Query settings and pretend build'
echo ' -x Use classic chroot instead of systemd-nspawn' echo ' -x Use classic chroot instead of systemd-nspawn'
echo ' Useful for testing if systemd is running to bypass autodetection' echo ' Useful for testing if systemd is running to bypass autodetection'
echo ' -h This help' echo ' -h This help'
@ -110,7 +107,7 @@ usage() {
exit 1 exit 1
} }
opts='p:a:b:r:cnvxqwyh' opts='p:a:b:r:cnxqwyh'
while getopts "${opts}" arg; do while getopts "${opts}" arg; do
case "${arg}" in case "${arg}" in
@ -120,9 +117,8 @@ while getopts "${opts}" arg; do
r) chroots="$OPTARG" ;; r) chroots="$OPTARG" ;;
c) clean_first=true ;; c) clean_first=true ;;
n) namcap=true;; n) namcap=true;;
v) verbose=true ;;
x) nosystemd=true ;; x) nosystemd=true ;;
q) pretend=true; verbose=true ;; q) pretend=true ;;
w) clean_rundir=true ;; w) clean_rundir=true ;;
y) repo=true ;; y) repo=true ;;
h) usage ;; h) usage ;;
@ -155,64 +151,16 @@ mkchrootpkg_args+=(-b ${branch} -r ${chrootdir})
makepkg_args+=("${*:$OPTIND}") makepkg_args+=("${*:$OPTIND}")
if ${verbose};then
msg "OPTARGS:"
msg2 "arch: $arch"
msg2 "branch: $branch"
msg2 "chroots: $chroots"
msg "PATHS:"
msg2 "chrootdir: $chrootdir"
msg2 "profiledir: $profiledir"
msg2 "pacman_conf: ${pacman_conf}"
msg2 "makepkg_conf: $makepkg_conf"
msg "mkchroot:"
msg2 "args: ${mkchroot_args[*]}"
msg "makechrootpkg:"
msg2 "args: ${mkchrootpkg_args[*]}"
msg "makepkg:"
msg2 "args: ${makepkg_args[*]}"
msg "FLAGS:"
msg2 "clean_first: $clean_first"
msg2 "namcap: ${namcap}"
msg2 "nosystemd: $nosystemd"
msg2 "clean_rundir: $clean_rundir"
msg2 "repo: ${repo}"
msg "PKG:"
msg2 "base_packages: ${base_packages[*]}"
msg2 "pkgdir: ${pkgdir}"
msg2 "PKGDEST: ${PKGDEST}"
msg2 "repodir: ${repodir}"
fi
if ${clean_rundir}; then if ${clean_rundir}; then
if ${pretend};then git_clean
msg "Files to be cleaned ${rundir} ..."
git clean -dfxn
else
msg "Cleaning ${rundir} ..."
if ${verbose};then
git clean -dfx
else
git clean -dfxq
fi
fi
fi fi
if [[ $EUID != 0 ]]; then if [[ $EUID != 0 ]]; then
die 'This script must be run as root.' die 'This script must be run as root.'
else else
if ${pretend};then run $@
run_pretend $@
else
run $@
if ${repo}; then if ${repo}; then
repo_create repo_create
fi
fi fi
fi fi

View file

@ -392,6 +392,20 @@ clean_pkg_cache(){
rm $1/*.${ext} rm $1/*.${ext}
} }
git_clean(){
if ${pretend};then
msg "Files to be cleaned ${rundir} ..."
git clean -dfxn
else
msg "Cleaning ${rundir} ..."
if ${verbose};then
git clean -dfx
else
git clean -dfxq
fi
fi
}
chroot_create(){ chroot_create(){
mkdir -p "${chrootdir}" mkdir -p "${chrootdir}"
setarch ${arch} \ setarch ${arch} \
@ -436,7 +450,7 @@ chroot_build_set(){
fi fi
pacman -U $temp*${arch}*pkg*z -r ${chrootdir}/$(get_user) --noconfirm pacman -U $temp*${arch}*pkg*z -r ${chrootdir}/$(get_user) --noconfirm
fi fi
mv_pkg ${profile} mv_pkg $pkg
cd .. cd ..
done done
msg "Finished building profile: [${profile}]" msg "Finished building profile: [${profile}]"
@ -451,11 +465,31 @@ chroot_build(){
cd .. cd ..
} }
display_build_set(){ display_settings(){
msg "OPTARGS:"
msg2 "arch: $arch"
msg2 "branch: $branch"
msg2 "chroots: $chroots"
msg "PATHS:"
msg2 "chrootdir: $chrootdir"
msg2 "profiledir: $profiledir"
msg2 "pacman_conf: ${pacman_conf}"
msg2 "makepkg_conf: $makepkg_conf"
msg2 "pkgdir: ${pkgdir}"
msg2 "PKGDEST: ${PKGDEST}"
msg2 "repodir: ${repodir}"
if ${clean_first};then
msg "PKG:"
msg2 "base_packages: ${base_packages[*]}"
fi
msg "SETS:" msg "SETS:"
msg2 "profiles: $profiles" msg2 "profiles: ${profiles}"
msg2 "profile: $profile" msg2 "profile: ${profile}"
msg2 "is_profile: ${is_profile}" msg2 "is_profile: ${is_profile}"
if ${is_profile};then if ${is_profile};then
msg "These packages will be built:" msg "These packages will be built:"
local temp=$(cat ${profiledir}/${profile}.set) local temp=$(cat ${profiledir}/${profile}.set)
@ -468,25 +502,33 @@ display_build_set(){
fi fi
} }
run_pretend(){
eval "case ${profile} in
$profiles) is_profile=true ;;
*) is_profile=false ;;
esac"
display_build_set
exit 1
}
run(){ run(){
eval "case ${profile} in eval "case ${profile} in
$profiles) is_profile=true; display_build_set && chroot_build_set ;; $profiles)
*) display_build_set && chroot_build ;; is_profile=true
if ${pretend}; then
display_settings
exit 1
else
display_settings
chroot_build_set
fi
;;
*)
if ${pretend}; then
display_settings
exit 1
else
display_settings
chroot_build
fi
;;
esac" esac"
} }
mv_pkg(){ mv_pkg(){
msg2 "Moving ${profile} to ${pkgdir}" msg2 "Moving $1 to ${pkgdir}"
mv ${profile}*.${ext} ${pkgdir} mv *.${ext} ${pkgdir}/
} }
repo_create(){ repo_create(){