2014-10-08 00:11:53 +02:00
|
|
|
#!/bin/bash
|
2014-10-08 11:11:19 +02:00
|
|
|
#
|
2014-10-08 00:11:53 +02:00
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; version 2 of the License.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
|
2014-10-08 11:11:19 +02:00
|
|
|
shopt -s nullglob
|
|
|
|
|
2014-10-08 00:11:53 +02:00
|
|
|
ch_owner(){
|
2014-10-13 21:21:09 +02:00
|
|
|
msg "chown -R [$(get_user):users] [$1]"
|
2014-10-08 00:11:53 +02:00
|
|
|
chown -R "$(get_user):users" "$1"
|
|
|
|
}
|
|
|
|
|
|
|
|
sign_pkgs(){
|
|
|
|
cd $pkgdir
|
|
|
|
su $(get_user) <<'EOF'
|
|
|
|
signpkgs
|
|
|
|
EOF
|
|
|
|
}
|
|
|
|
|
|
|
|
get_profiles(){
|
|
|
|
local prof= temp=
|
2014-10-08 11:11:19 +02:00
|
|
|
for item in $(ls ${profiledir}/*.set);do
|
|
|
|
temp=${item##*/}
|
2014-10-08 00:11:53 +02:00
|
|
|
prof=${prof:-}${prof:+|}${temp%.set}
|
|
|
|
done
|
|
|
|
echo $prof
|
|
|
|
}
|
|
|
|
|
|
|
|
get_user(){
|
|
|
|
echo $(ls ${chrootdir} | cut -d' ' -f1 | grep -v root | grep -v lock)
|
|
|
|
}
|
|
|
|
|
|
|
|
prepare_dir(){
|
|
|
|
if ! [[ -d $1 ]];then
|
|
|
|
mkdir -p $1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2014-11-11 21:19:26 +01:00
|
|
|
clean_dir(){
|
|
|
|
msg2 "Cleaning $1 ..."
|
|
|
|
rm -r $1/*
|
|
|
|
}
|
|
|
|
|
|
|
|
git_clean(){
|
|
|
|
msg2 "Cleaning $(pwd) ..."
|
|
|
|
git clean -dfx$1
|
|
|
|
}
|
|
|
|
|
|
|
|
####chroot controller######
|
|
|
|
|
2014-11-12 02:19:58 +01:00
|
|
|
# chroot_clean(){
|
|
|
|
# for copy in "${chrootdir}"/*; do
|
|
|
|
# [[ -d "${copy}" ]] || continue
|
|
|
|
# msg2 "Deleting chroot copy '$(basename "${copy}")'..."
|
|
|
|
#
|
|
|
|
# exec 9>"${copy}.lock"
|
|
|
|
# if ! flock -n 9; then
|
|
|
|
# stat_busy "Locking chroot copy '${copy}'"
|
|
|
|
# flock 9
|
|
|
|
# stat_done
|
|
|
|
# fi
|
|
|
|
#
|
|
|
|
# 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}"
|
|
|
|
# }
|
|
|
|
#
|
|
|
|
# chroot_create(){
|
|
|
|
# mkdir -p "${chrootdir}"
|
2014-11-11 21:19:26 +01:00
|
|
|
# setarch "${arch}" \
|
2014-11-12 02:19:58 +01:00
|
|
|
# mkchroot ${mkchroot_args[*]} ${chrootdir}/root ${base_packages[*]} || abort
|
2014-11-11 21:19:26 +01:00
|
|
|
# }
|
2014-11-12 02:19:58 +01:00
|
|
|
#
|
|
|
|
# chroot_init(){
|
|
|
|
# if [[ -e ${chrootdir} ]]; then
|
|
|
|
# msg "Creating chroot for [${branch}] (${arch})..."
|
|
|
|
# chroot_clean
|
|
|
|
# chroot_create
|
2014-11-11 21:19:26 +01:00
|
|
|
# else
|
2014-11-12 02:19:58 +01:00
|
|
|
# msg "Creating chroot for [${branch}] (${arch})..."
|
|
|
|
# chroot_create
|
|
|
|
# fi
|
|
|
|
# }
|
2014-10-08 00:11:53 +02:00
|
|
|
|
2014-11-11 21:19:26 +01:00
|
|
|
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
|
|
|
|
fi
|
|
|
|
setarch "${arch}" \
|
|
|
|
mkchrootpkg ${mkchrootpkg_args[*]} -- "${makepkg_args[*]}" || break
|
|
|
|
move_pkg "${pkg}"
|
|
|
|
cd ..
|
|
|
|
done
|
|
|
|
msg "Finished building profile: [${profile}]"
|
|
|
|
else
|
|
|
|
cd ${profile}
|
|
|
|
if [[ ${profile} == 'eudev' ]] || [[ ${profile} == 'lib32-eudev' ]]; then
|
|
|
|
blacklist_pkg
|
|
|
|
fi
|
|
|
|
setarch "${arch}" \
|
|
|
|
mkchrootpkg ${mkchrootpkg_args[*]} -- "${makepkg_args[*]}" || abort
|
|
|
|
move_pkg "${profile}"
|
|
|
|
cd ..
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
####end chroot controller######
|
|
|
|
|
2014-10-08 11:11:19 +02:00
|
|
|
eval_profile(){
|
|
|
|
eval "case ${profile} in
|
|
|
|
$(get_profiles)) is_profile=true ;;
|
|
|
|
*) is_profile=false ;;
|
|
|
|
esac"
|
|
|
|
}
|
|
|
|
|
2014-10-23 00:46:43 +02:00
|
|
|
blacklist_pkg(){
|
|
|
|
local blacklist=('libsystemd') cmd=$(pacman -Q ${blacklist[@]} -r ${chrootdir}/root 2> /dev/null)
|
|
|
|
if [[ -n $cmd ]] ; then
|
|
|
|
msg2 "Removing blacklisted [${blacklist[@]}] ..."
|
2014-11-12 02:19:58 +01:00
|
|
|
setarch "${arch}" pacman -Rdd "${blacklist[@]}" -r ${chrootdir}/root --noconfirm
|
2014-10-23 00:46:43 +02:00
|
|
|
else
|
|
|
|
msg2 "Blacklisted [${blacklist[@]}] not present."
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2014-11-12 02:19:58 +01:00
|
|
|
# install_pkg(){
|
|
|
|
# msg2 "Installing built package ..."
|
|
|
|
# setarch "${arch}" pacman -U *pkg*z -r ${chrootdir}/$(get_user) --noconfirm
|
|
|
|
# }
|
2014-10-23 00:46:43 +02:00
|
|
|
|
|
|
|
move_pkg(){
|
|
|
|
msg2 "Moving [$1] to [${pkgdir}]"
|
|
|
|
local ext='pkg.tar.xz'
|
|
|
|
mv *.${ext} ${pkgdir}/
|
|
|
|
}
|