Use the host's package cache

Signed-off-by: Pierre Schmitz <pierre@archlinux.de>
Signed-off-by: Gerardo Exequiel Pozzi <vmlinuz386@yahoo.com.ar>
This commit is contained in:
Pierre Schmitz 2012-06-23 11:37:56 +02:00 committed by Gerardo Exequiel Pozzi
parent 344dd0064a
commit dd368b5a81

View File

@ -13,7 +13,14 @@ verbose=""
cmd_args="" cmd_args=""
script_path=$(readlink -f ${0%/*}) script_path=$(readlink -f ${0%/*})
pacman_conf="${script_path}/pacman.conf"
setup_workdir() {
cache_dirs=($(pacman -v 2>&1 | grep '^Cache Dirs:' | sed 's/Cache Dirs:\s*//g'))
mkdir -p "${work_dir}"
pacman_conf="${work_dir}/pacman.conf"
sed -r "s|^#?\\s*CacheDir.+|CacheDir = $(echo -n ${cache_dirs[@]})|g" \
"${script_path}/pacman.conf" > "${pacman_conf}"
}
# Base installation (root-image) # Base installation (root-image)
make_basefs() { make_basefs() {
@ -169,7 +176,7 @@ make_usr_share() {
# Make [core] repository, keep "any" pkgs in a separate fs (makes more "dual-iso" friendly) # Make [core] repository, keep "any" pkgs in a separate fs (makes more "dual-iso" friendly)
make_core_repo() { make_core_repo() {
if [[ ! -e ${work_dir}/build.${FUNCNAME} ]]; then if [[ ! -e ${work_dir}/build.${FUNCNAME} ]]; then
local _url _urls _pkg_name _dst _pkgs _cache_dir _cache_dirs local _url _urls _pkg_name _dst _pkgs _cache_dir
mkdir -p ${work_dir}/repo-core-any mkdir -p ${work_dir}/repo-core-any
mkdir -p ${work_dir}/repo-core-${arch} mkdir -p ${work_dir}/repo-core-${arch}
mkdir -p ${work_dir}/pacman.db/var/lib/pacman mkdir -p ${work_dir}/pacman.db/var/lib/pacman
@ -178,11 +185,10 @@ make_core_repo() {
<(grep -v ^# ${script_path}/core.exclude.${arch} | sort | sed 's@^@core/@')) <(grep -v ^# ${script_path}/core.exclude.${arch} | sort | sed 's@^@core/@'))
_urls=$(pacman --config "${pacman_conf}" -Sddp -r ${work_dir}/pacman.db ${_pkgs}) _urls=$(pacman --config "${pacman_conf}" -Sddp -r ${work_dir}/pacman.db ${_pkgs})
pacman --config "${pacman_conf}" -Swdd -r ${work_dir}/pacman.db --noprogressbar --noconfirm ${_pkgs} pacman --config "${pacman_conf}" -Swdd -r ${work_dir}/pacman.db --noprogressbar --noconfirm ${_pkgs}
_cache_dirs=($(pacman --config "${pacman_conf}" -v 2>&1 | grep '^Cache Dirs:' | sed 's/Cache Dirs:\s*//g'))
for _url in ${_urls}; do for _url in ${_urls}; do
_pkg_name=${_url##*/} _pkg_name=${_url##*/}
_dst=${work_dir}/repo-core-${arch}/${_pkg_name} _dst=${work_dir}/repo-core-${arch}/${_pkg_name}
for _cache_dir in ${_cache_dirs[@]}; do for _cache_dir in ${cache_dirs[@]}; do
if [[ -e "${_cache_dir}/${_pkg_name}" ]]; then if [[ -e "${_cache_dir}/${_pkg_name}" ]]; then
cp "${_cache_dir}/${_pkg_name}" ${_dst} cp "${_cache_dir}/${_pkg_name}" ${_dst}
fi fi
@ -431,6 +437,8 @@ if [[ ${command_mode} == "single" ]]; then
work_dir=${work_dir}/${arch} work_dir=${work_dir}/${arch}
fi fi
setup_workdir
case "${command_name}" in case "${command_name}" in
build) build)
case "${command_mode}" in case "${command_mode}" in