forked from mirrored-repos/manjaro-tools
93287f6582
del pacman-mirrors.conf
246 lines
5.6 KiB
Bash
246 lines
5.6 KiB
Bash
#!/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.
|
|
|
|
version=@version@
|
|
|
|
shopt -s nullglob
|
|
|
|
if [[ -r @libdir@/messages.sh ]];then
|
|
source @libdir@/messages.sh
|
|
fi
|
|
|
|
if [[ -r @libdir@/util-build.sh ]];then
|
|
source @libdir@/util-build.sh
|
|
fi
|
|
|
|
if [[ -r @libdir@/util.sh ]];then
|
|
source @libdir@/util.sh
|
|
fi
|
|
|
|
pkg_owner=${SUDO_USER:-$USER}
|
|
|
|
if [[ -n $SUDO_USER ]]; then
|
|
eval "USER_HOME=~$SUDO_USER"
|
|
else
|
|
USER_HOME=$HOME
|
|
fi
|
|
|
|
load_vars "$USER_HOME/.makepkg.conf"
|
|
load_vars /etc/makepkg.conf
|
|
|
|
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
|
|
}
|
|
|
|
chroot_init(){
|
|
if ${clean_first} || [[ ! -d "${chrootdir}" ]]; 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
|
|
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
|
|
fi
|
|
}
|
|
|
|
display_settings(){
|
|
msg "manjaro-tools version: ${version}"
|
|
|
|
msg "OPTARGS:"
|
|
msg2 "arch: ${arch}"
|
|
msg2 "branch: ${branch}"
|
|
msg2 "chroots: ${chroots}"
|
|
|
|
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 "These packages will be built:"
|
|
local list=$(cat ${profiledir}/${profile}.set)
|
|
for item in ${list[@]}; do
|
|
msg2 "$item"
|
|
done
|
|
else
|
|
msg "This package will be built:"
|
|
msg2 "${profile}"
|
|
fi
|
|
}
|
|
|
|
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
|
|
display_settings
|
|
chroot_init
|
|
prepare_dir "${pkgdir}"
|
|
chroot_build
|
|
ch_owner "$(dirname ${pkgdir})"
|
|
|
|
# if ${sign}; then
|
|
# sign_pkgs
|
|
# fi
|
|
fi
|
|
}
|
|
|
|
export LC_MESSAGES=C
|
|
|
|
arch=$(uname -m)
|
|
|
|
load_config '@sysconfdir@'
|
|
|
|
pacman_conf_arch='default'
|
|
|
|
clean_first=false
|
|
wipe_clean=false
|
|
namcap=false
|
|
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}]"
|
|
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 ' -n Run namcap check'
|
|
echo ' -s Sign packages'
|
|
echo ' -q Query settings and pretend build'
|
|
echo ' -h This help'
|
|
echo ''
|
|
echo ''
|
|
exit 1
|
|
}
|
|
|
|
orig_argv=("$@")
|
|
|
|
opts='p:a:b:r:cwnsqh'
|
|
|
|
while getopts "${opts}" arg; do
|
|
case "${arg}" in
|
|
p) profile="$OPTARG" ;;
|
|
a) arch="$OPTARG" ;;
|
|
b) branch="$OPTARG" ;;
|
|
r) chroots="$OPTARG" ;;
|
|
c) clean_first=true ;;
|
|
w) wipe_clean=true ;;
|
|
n) namcap=true; mkchrootpkg_args+=(-n) ;;
|
|
s) sign=true ;;
|
|
q) pretend=true ;;
|
|
h) usage ;;
|
|
esac
|
|
done
|
|
|
|
if [[ "$arch" == 'multilib' ]]; then
|
|
pacman_conf_arch='multilib'
|
|
chrootdir=${chroots}/${branch}/${arch}
|
|
arch='x86_64'
|
|
base_packages+=('multilib-devel')
|
|
else
|
|
chrootdir=${chroots}/${branch}/${arch}
|
|
fi
|
|
|
|
pacman_conf="@pkgdatadir@/pacman-${pacman_conf_arch}.conf"
|
|
makepkg_conf="@pkgdatadir@/makepkg-${arch}.conf"
|
|
pm_conf="@pkgdatadir@/pacman-mirrors-${branch}.conf"
|
|
|
|
if [[ -n ${pkgdir} ]];then
|
|
pkgdir="${pkgdir}/${branch}/${arch}"
|
|
else
|
|
pkgdir="/var/cache/manjaro-tools/pkg/${branch}/${arch}"
|
|
fi
|
|
|
|
mkchroot_args+=(-C ${pacman_conf} -M ${makepkg_conf} -S ${pm_conf})
|
|
|
|
mkchrootpkg_args+=(-r ${chrootdir})
|
|
|
|
makepkg_args+=("${@:$OPTIND}")
|
|
|
|
check_root "$0" "${orig_argv[@]}"
|
|
|
|
run $@
|