some code cleanup
This commit is contained in:
parent
352aed0dde
commit
c005b20a58
4 changed files with 109 additions and 109 deletions
132
bin/build-set.in
132
bin/build-set.in
|
@ -17,6 +17,70 @@ shopt -s nullglob
|
|||
[[ -r @libdir@/util.sh ]] && source @libdir@/util.sh
|
||||
[[ -r @libdir@/util-build.sh ]] && source @libdir@/util-build.sh
|
||||
|
||||
display_settings(){
|
||||
msg "manjaro-tools version: ${version}"
|
||||
|
||||
msg "OPTIONS:"
|
||||
msg2 "arch: ${arch}"
|
||||
msg2 "branch: ${branch}"
|
||||
msg2 "chroots: ${chroots}"
|
||||
|
||||
msg "ARGS:"
|
||||
msg2 "mkchrootpkg_args: ${mkchrootpkg_args[*]}"
|
||||
msg2 "makepkg_args: ${makepkg_args[*]}"
|
||||
|
||||
msg "PATHS:"
|
||||
msg2 "chrootdir: ${chrootdir}"
|
||||
msg2 "profiledir: ${profiledir}"
|
||||
msg2 "pkgdir: ${pkgdir}"
|
||||
msg2 "pacman_conf: ${pacman_conf}"
|
||||
msg2 "makepkg_conf: ${makepkg_conf}"
|
||||
msg2 "pm_conf: ${pm_conf}"
|
||||
|
||||
if ${clean_first};then
|
||||
msg "PKG:"
|
||||
msg2 "base_packages: ${base_packages[*]}"
|
||||
fi
|
||||
|
||||
msg "SETS:"
|
||||
msg2 "profiles: $(get_profiles)"
|
||||
msg2 "profile: ${profile}"
|
||||
msg2 "is_profile: ${is_profile}"
|
||||
|
||||
if ${is_profile};then
|
||||
msg "Build queue:"
|
||||
local list=$(cat ${profiledir}/${profile}.set)
|
||||
for item in ${list[@]}; do
|
||||
msg2 "$item"
|
||||
done
|
||||
else
|
||||
msg "Build queue:"
|
||||
for arg in "${makepkg_args[@]}"; do
|
||||
case ${arg} in
|
||||
--pkg) continue ;;
|
||||
-*) continue ;;
|
||||
*) local split_arg=${arg} ;;
|
||||
esac
|
||||
done
|
||||
if [[ -n ${split_arg} ]]; then
|
||||
local IFS=','
|
||||
for item in ${split_arg}; do
|
||||
msg2 "$item"
|
||||
done
|
||||
unset IFS
|
||||
else
|
||||
msg2 "${profile}"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
eval_profile(){
|
||||
eval "case $1 in
|
||||
$(load_sets)) is_profile=true ;;
|
||||
*) is_profile=false ;;
|
||||
esac"
|
||||
}
|
||||
|
||||
chroot_create(){
|
||||
mkdir -p "${chrootdir}"
|
||||
setarch "${arch}" mkchroot \
|
||||
|
@ -69,48 +133,6 @@ chroot_init(){
|
|||
fi
|
||||
}
|
||||
|
||||
display_settings(){
|
||||
msg "manjaro-tools version: ${version}"
|
||||
|
||||
msg "OPTIONS:"
|
||||
msg2 "arch: ${arch}"
|
||||
msg2 "branch: ${branch}"
|
||||
msg2 "chroots: ${chroots}"
|
||||
|
||||
msg "ARGS:"
|
||||
msg2 "mkchrootpkg_args: ${mkchrootpkg_args[*]}"
|
||||
msg2 "makepkg_args: ${makepkg_args[*]}"
|
||||
|
||||
msg "PATHS:"
|
||||
msg2 "chrootdir: ${chrootdir}"
|
||||
msg2 "profiledir: ${profiledir}"
|
||||
msg2 "pkgdir: ${pkgdir}"
|
||||
msg2 "pacman_conf: ${pacman_conf}"
|
||||
msg2 "makepkg_conf: ${makepkg_conf}"
|
||||
msg2 "pm_conf: ${pm_conf}"
|
||||
|
||||
if ${clean_first};then
|
||||
msg "PKG:"
|
||||
msg2 "base_packages: ${base_packages[*]}"
|
||||
fi
|
||||
|
||||
msg "SETS:"
|
||||
msg2 "profiles: $(get_profiles)"
|
||||
msg2 "profile: ${profile}"
|
||||
msg2 "is_profile: ${is_profile}"
|
||||
|
||||
if ${is_profile};then
|
||||
msg "Build queue:"
|
||||
local list=$(cat ${profiledir}/${profile}.set)
|
||||
for item in ${list[@]}; do
|
||||
msg2 "$item"
|
||||
done
|
||||
else
|
||||
msg "Build queue:"
|
||||
msg2 "${profile}"
|
||||
fi
|
||||
}
|
||||
|
||||
export LC_MESSAGES=C
|
||||
|
||||
load_config '@sysconfdir@'
|
||||
|
@ -129,6 +151,7 @@ load_vars /etc/makepkg.conf
|
|||
arch=$(uname -m)
|
||||
|
||||
pacman_conf_arch='default'
|
||||
base_packages=('base-devel')
|
||||
|
||||
clean_first=false
|
||||
wipe_clean=false
|
||||
|
@ -137,12 +160,6 @@ pretend=false
|
|||
is_profile=false
|
||||
sign=false
|
||||
|
||||
base_packages=('base-devel')
|
||||
|
||||
mkchroot_args=()
|
||||
mkchrootpkg_args=()
|
||||
makepkg_args=()
|
||||
|
||||
usage() {
|
||||
echo "Usage: ${0##*/} [options] [--] [makepkg args]"
|
||||
echo " -p <profile> Set profile or pkg [default: ${profile}]"
|
||||
|
@ -205,13 +222,12 @@ check_root "$0" "${orig_argv[@]}"
|
|||
|
||||
eval_profile "${profile}"
|
||||
|
||||
if ${pretend}; then
|
||||
display_settings
|
||||
exit $?
|
||||
else
|
||||
${wipe_clean} && clean_up
|
||||
display_settings
|
||||
chroot_init
|
||||
chroot_build
|
||||
${sign} && sign_pkgs "${pkg_owner}"
|
||||
fi
|
||||
${pretend} && display_settings && exit
|
||||
|
||||
${wipe_clean} && clean_up
|
||||
|
||||
chroot_init
|
||||
|
||||
chroot_build
|
||||
|
||||
${sign} && sign_pkgs "${pkg_owner}"
|
||||
|
|
|
@ -46,20 +46,6 @@ show_set(){
|
|||
done
|
||||
}
|
||||
|
||||
run(){
|
||||
if ${create};then
|
||||
create_set
|
||||
elif ${remove};then
|
||||
remove_set
|
||||
elif ${display};then
|
||||
show_set
|
||||
else
|
||||
msg "Available sets: ${profiles}"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
profiles=$(get_profiles)
|
||||
query=false
|
||||
create=false
|
||||
remove=false
|
||||
|
@ -71,7 +57,7 @@ usage() {
|
|||
echo " -c <name> Create set"
|
||||
echo " -r <name> Remove set"
|
||||
echo " -d <name> Display set"
|
||||
echo " -q Query sets"
|
||||
echo " -q Show sets"
|
||||
echo ' -h This help'
|
||||
echo ''
|
||||
echo ''
|
||||
|
@ -96,4 +82,12 @@ shift $(($OPTIND - 1))
|
|||
|
||||
check_root "$0" "${orig_argv[@]}"
|
||||
|
||||
run $@
|
||||
if ${create};then
|
||||
create_set
|
||||
elif ${remove};then
|
||||
remove_set
|
||||
elif ${display};then
|
||||
show_set
|
||||
else
|
||||
msg "Available sets: $(load_sets)"
|
||||
fi
|
||||
|
|
|
@ -26,58 +26,34 @@ move_pkg(){
|
|||
chown -R "$1:users" "${pkgdir}"
|
||||
}
|
||||
|
||||
get_profiles(){
|
||||
local prof= temp=
|
||||
for item in $(ls ${profiledir}/*.set);do
|
||||
temp=${item##*/}
|
||||
prof=${prof:-}${prof:+|}${temp%.set}
|
||||
done
|
||||
echo $prof
|
||||
}
|
||||
|
||||
prepare_dir(){
|
||||
mkdir -p $1
|
||||
chown -R "$2:users" "$(dirname $1)"
|
||||
}
|
||||
|
||||
clean_up(){
|
||||
msg "Cleaning up ..."
|
||||
|
||||
local query=$(find ${pkgdir} -maxdepth 1 -name "*.*")
|
||||
if [[ -n $query ]];then
|
||||
rm -v $query
|
||||
fi
|
||||
|
||||
[[ -n $query ]] && rm -v $query
|
||||
|
||||
if [[ -z $LOGDEST ]];then
|
||||
query=$(find $(pwd) -maxdepth 2 -name '*.log')
|
||||
if [[ -n $query ]];then
|
||||
rm -v $query
|
||||
fi
|
||||
[[ -n $query ]] && rm -v $query
|
||||
fi
|
||||
|
||||
if [[ -z $SRCDEST ]];then
|
||||
query=$(find $(pwd) -maxdepth 2 -name '*.?z?')
|
||||
if [[ -n $query ]];then
|
||||
rm -v $query
|
||||
fi
|
||||
[[ -n $query ]] && rm -v $query
|
||||
fi
|
||||
}
|
||||
|
||||
eval_profile(){
|
||||
eval "case $1 in
|
||||
$(get_profiles)) is_profile=true ;;
|
||||
*) is_profile=false ;;
|
||||
esac"
|
||||
}
|
||||
|
||||
blacklist_pkg(){
|
||||
local blacklist=('libsystemd') cmd=$(pacman -Q ${blacklist[@]} -r $1/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[@]}] ..."
|
||||
pacman -Rdd "${blacklist[@]}" -r $1/root --noconfirm
|
||||
else
|
||||
msg2 "Blacklisted [${blacklist[@]}] not present."
|
||||
chroot-run $1/root pacman -Rdd "${blacklist[@]}" --noconfirm
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
chroot_clean(){
|
||||
for copy in "$1"/*; do
|
||||
[[ -d ${copy} ]] || continue
|
||||
|
|
14
lib/util.sh
14
lib/util.sh
|
@ -195,4 +195,18 @@ load_config(){
|
|||
else
|
||||
pkgdir='/var/cache/manjaro-tools/pkg'
|
||||
fi
|
||||
}
|
||||
|
||||
load_sets(){
|
||||
local prof= temp=
|
||||
for item in $(ls ${profiledir}/*.set);do
|
||||
temp=${item##*/}
|
||||
prof=${prof:-}${prof:+|}${temp%.set}
|
||||
done
|
||||
echo $prof
|
||||
}
|
||||
|
||||
prepare_dir(){
|
||||
mkdir -p $1
|
||||
chown -R "$2:users" "$(dirname $1)"
|
||||
}
|
Loading…
Reference in a new issue