2014-12-08 23:50:56 +01:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# 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.
|
|
|
|
|
|
|
|
chroot_create(){
|
2015-01-12 00:00:48 +01:00
|
|
|
msg "Creating chroot for [${branch}] (${arch})..."
|
2015-01-13 01:32:31 +01:00
|
|
|
mkdir -p "${work_dir}"
|
2014-12-08 23:50:56 +01:00
|
|
|
setarch "${arch}" mkchroot \
|
|
|
|
${mkchroot_args[*]} \
|
2015-01-13 01:32:31 +01:00
|
|
|
"${work_dir}/root" \
|
2014-12-08 23:50:56 +01:00
|
|
|
${base_packages[*]} || abort
|
|
|
|
}
|
|
|
|
|
|
|
|
chroot_clean(){
|
2015-01-13 01:32:31 +01:00
|
|
|
for copy in "${work_dir}"/*; do
|
2014-12-08 23:50:56 +01:00
|
|
|
[[ -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>&-
|
|
|
|
|
2015-01-13 01:32:31 +01:00
|
|
|
rm -rf --one-file-system "${work_dir}"
|
2014-12-08 23:50:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
chroot_update(){
|
2015-01-12 00:00:48 +01:00
|
|
|
msg "Updating chroot for [${branch}] (${arch})..."
|
2015-01-13 01:32:31 +01:00
|
|
|
lock 9 "${work_dir}/root.lock" "Locking clean chroot"
|
2015-01-09 16:23:02 +01:00
|
|
|
chroot-run ${mkchroot_args[*]} \
|
2015-01-13 01:32:31 +01:00
|
|
|
"${work_dir}/root" \
|
2014-12-08 23:50:56 +01:00
|
|
|
pacman -Syu --noconfirm || abort
|
|
|
|
}
|
|
|
|
|
|
|
|
clean_up(){
|
|
|
|
msg "Cleaning up ..."
|
|
|
|
|
2015-01-15 05:19:01 +01:00
|
|
|
local query=$(find ${cache_dir_pkg} -maxdepth 1 -name "*.*")
|
2014-12-08 23:50:56 +01:00
|
|
|
|
|
|
|
[[ -n $query ]] && rm -v $query
|
|
|
|
|
|
|
|
if [[ -z $LOGDEST ]];then
|
|
|
|
query=$(find $PWD -maxdepth 2 -name '*.log')
|
|
|
|
[[ -n $query ]] && rm -v $query
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ -z $SRCDEST ]];then
|
|
|
|
query=$(find $PWD -maxdepth 2 -name '*.?z?')
|
|
|
|
[[ -n $query ]] && rm -v $query
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
blacklist_pkg(){
|
|
|
|
msg "Removing ${blacklist[@]}..."
|
|
|
|
for item in "${blacklist[@]}"; do
|
|
|
|
chroot-run $1/root pacman -Rdd "$item" --noconfirm
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
prepare_cachedir(){
|
2015-01-15 05:19:01 +01:00
|
|
|
[[ ! -d "${cache_dir_pkg}" ]] && mkdir -p "${cache_dir_pkg}"
|
|
|
|
chown -R "${OWNER}:users" "${cache_dir_pkg}"
|
2014-12-08 23:50:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
move_pkg(){
|
|
|
|
local ext='pkg.tar.xz'
|
|
|
|
if [[ -n $PKGDEST ]];then
|
2015-01-15 05:19:01 +01:00
|
|
|
mv $PKGDEST/*{any,$arch}.${ext} ${cache_dir_pkg}/
|
2014-12-08 23:50:56 +01:00
|
|
|
else
|
2015-01-15 05:19:01 +01:00
|
|
|
mv *.${ext} ${cache_dir_pkg}
|
2014-12-08 23:50:56 +01:00
|
|
|
fi
|
2015-01-15 05:19:01 +01:00
|
|
|
chown -R "${OWNER}:users" "${cache_dir_pkg}"
|
2014-12-08 23:50:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
chroot_build(){
|
2015-01-14 22:29:46 +01:00
|
|
|
if ${is_buildset};then
|
2015-01-17 19:05:18 +01:00
|
|
|
msg3 "Start building [${buildset_pkg}]"
|
2015-01-14 22:29:46 +01:00
|
|
|
for pkg in $(cat ${sets_dir_pkg}/${buildset_pkg}.set); do
|
2015-01-15 18:15:24 +01:00
|
|
|
[[ -f $pkg/PKGBUILD ]] || break
|
2014-12-08 23:50:56 +01:00
|
|
|
cd $pkg
|
|
|
|
for p in ${blacklist_trigger[@]}; do
|
2015-01-13 01:32:31 +01:00
|
|
|
[[ $pkg == $p ]] && blacklist_pkg "${work_dir}"
|
2014-12-08 23:50:56 +01:00
|
|
|
done
|
|
|
|
setarch "${arch}" \
|
|
|
|
mkchrootpkg ${mkchrootpkg_args[*]} -- ${makepkg_args[*]} || break
|
|
|
|
move_pkg
|
|
|
|
cd ..
|
|
|
|
done
|
2015-01-17 19:05:18 +01:00
|
|
|
msg3 "Finished building [${buildset_pkg}]"
|
2014-12-08 23:50:56 +01:00
|
|
|
else
|
2015-01-15 18:20:01 +01:00
|
|
|
[[ -f ${buildset_pkg}/PKGBUILD ]] || die "${buildset_pkg} is not a valid profile!"
|
2015-01-14 22:29:46 +01:00
|
|
|
cd ${buildset_pkg}
|
2014-12-08 23:50:56 +01:00
|
|
|
for p in ${blacklist_trigger[@]}; do
|
2015-01-14 22:29:46 +01:00
|
|
|
[[ ${buildset_pkg} == $p ]] && blacklist_pkg "${work_dir}"
|
2014-12-08 23:50:56 +01:00
|
|
|
done
|
|
|
|
setarch "${arch}" \
|
|
|
|
mkchrootpkg ${mkchrootpkg_args[*]} -- ${makepkg_args[*]} || abort
|
|
|
|
move_pkg
|
|
|
|
cd ..
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
chroot_init(){
|
2015-01-12 00:00:48 +01:00
|
|
|
if ${clean_first}; then
|
2014-12-08 23:50:56 +01:00
|
|
|
chroot_clean
|
|
|
|
chroot_create
|
2015-01-13 01:32:31 +01:00
|
|
|
elif [[ ! -d "${work_dir}" ]]; then
|
2015-01-12 00:00:48 +01:00
|
|
|
chroot_create
|
2014-12-08 23:50:56 +01:00
|
|
|
else
|
|
|
|
chroot_update
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
sign_pkgs(){
|
2015-01-15 05:19:01 +01:00
|
|
|
cd ${cache_dir_pkg}
|
2015-01-13 13:41:28 +01:00
|
|
|
su "${OWNER}" <<'EOF'
|
2014-12-08 23:50:56 +01:00
|
|
|
signpkgs
|
|
|
|
EOF
|
|
|
|
}
|