buildiso: Rework how package caches are created

Instead running pacman outside the chroot, this runs it inside:
1. Download the needed packages (the pacman cache is bind to the host pacman cache).
2. Make a list of packages to be copied to the pacman cache.
3. Copy the packages with rsync.

This solves:
- Uses the packages in the right branch (before it used the host's branch).
- Don't need to redownload packages anymore, saving tons of time.
- pkg_dir_cache and lng_dir_cache are not needed anymore, no need to clean them too.
This commit is contained in:
Ramon Buldó 2015-06-08 21:21:46 +02:00
parent f0aa9e4ebf
commit 966404280c
4 changed files with 26 additions and 57 deletions

View file

@ -83,16 +83,12 @@ display_settings(){
msg "ARGS:"
msg2 "clean_first: ${clean_first}"
msg2 "clean_cache_xorg: ${clean_cache_xorg}"
msg2 "clean_cache_lng: ${clean_cache_lng}"
msg2 "images_only: ${images_only}"
msg2 "iso_only: ${iso_only}"
msg "PATHS:"
msg2 "sets_dir_iso: ${sets_dir_iso}"
msg2 "cache_dir_iso: ${cache_dir_iso}"
msg2 "cache_dir_xorg: ${cache_dir_xorg}"
msg2 "cache_dir_lng: ${cache_dir_lng}"
msg "DIST SETTINGS:"
msg2 "dist_name: ${dist_name}"
@ -119,9 +115,6 @@ load_config "${SYSCONFDIR}/manjaro-tools.conf"
clean_first=true
clean_cache_xorg=false
clean_cache_lng=false
pretend=false
images_only=false
iso_only=false
@ -140,8 +133,6 @@ usage() {
echo ' -t <dir> Target directory'
echo " [default: ${cache_dir_iso}]"
echo ' -c Disable clean work dir'
echo ' -x Clean xorg cache'
echo ' -l Clean lng cache'
echo ' -i Build images only'
echo ' -s Generate iso only'
echo ' Requires pre built images (-i)'
@ -155,7 +146,7 @@ usage() {
orig_argv=("$@")
opts='p:a:b:r:t:cxlisvqh'
opts='p:a:b:r:t:cisvqh'
while getopts "${opts}" arg; do
case "${arg}" in
@ -166,8 +157,6 @@ while getopts "${opts}" arg; do
t) cache_dir_iso="$OPTARG" ;;
k) keep_repo="$OPTARG" ;;
c) clean_first=false ;;
x) clean_cache_xorg=true ;;
l) clean_cache_lng=true ;;
i) images_only=true ;;
s) iso_only=true ;;
v) verbose=true ;;
@ -183,9 +172,6 @@ timer_start=$(get_timer)
[[ "$arch" == 'x86_64' ]] && pacman_conf_arch='multilib'
cache_dir_lng="${cache_dir}/lng/${arch}"
cache_dir_xorg="${cache_dir}/xorg/${arch}"
mirrors_conf="${PKGDATADIR}/pacman-mirrors-${branch}.conf"
check_root "$0" "${orig_argv[@]}"

View file

@ -109,23 +109,6 @@
<listitem><para>Disable clean working directory step.</para></listitem>
</varlistentry>
<varlistentry>
<term><option>-x</option></term>
<listitem><para>Clean the xorg packages cache. Xorg packages
are the packages listed in Packages-Xorg file within each profile and are
used for the
<citerefentry project='mhwd'><refentrytitle>mhwd</refentrytitle><manvolnum>1</manvolnum></citerefentry> tool.</para></listitem>
</varlistentry>
<varlistentry>
<term><option>-l</option></term>
<listitem><para>Clean the language packages cache. Language
packages cache are listed in Packages-Lng and are used to bundle multiple
language packages with the iso.</para></listitem>
</varlistentry>
<varlistentry>
<term><option>-i</option></term>

View file

@ -344,12 +344,23 @@ make_repo(){
}
# $1: work dir
# $2: cache dir
# $3: pkglist
# $2: pkglist
download_to_cache(){
pacman -v --config "${pacman_conf}" \
--arch "${arch}" --root "$1" \
--cache $2 -Syw $3 --noconfirm
chroot-run \
-r "${mountargs_ro}" \
-w "${mountargs_rw}" \
-B "${build_mirror}/${branch}" \
"$1" \
pacman -v -Syw $2 --noconfirm
chroot-run \
-r "${mountargs_ro}" \
-w "${mountargs_rw}" \
-B "${build_mirror}/${branch}" \
"$1" \
pacman -v -Sp $2 --noconfirm > /list.xorg
sed -ni '/.pkg.tar.xz/p' "$1"/cache-packages.txt
sed -i "s/.*\///" "$1"/cache-packages.txt
find "$1/etc" -mindepth 1 -delete &> /dev/null
}
# $1: image path

View file

@ -71,28 +71,19 @@ copy_livecd_helpers(){
}
copy_cache_lng(){
msg2 "Copying lng cache ..."
cp ${cache_dir_lng}/* ${work_dir}/lng-image/opt/livecd/lng
msg2 "Trimming lng pkgs ..."
paccache -rv -k1 -c ${work_dir}/lng-image/opt/livecd/lng
msg2 "Copying language package cache ..."
rsync -v --files-from="${work_dir}/lng-image/cache-packages.txt" /var/cache/pacman/pkg "${work_dir}/lng-image/opt/livecd/lng"
rm -f "${work_dir}/lng-image/cache-packages.txt"
}
copy_cache_xorg(){
msg2 "Copying xorg pkgs cache ..."
cp ${cache_dir_xorg}/* ${work_dir}/pkgs-image/opt/livecd/pkgs
msg2 "Trimming xorg pkgs ..."
paccache -rv -k1 -c ${work_dir}/pkgs-image/opt/livecd/pkgs
msg2 "Copying xorg package cache ..."
rsync -v --files-from="${work_dir}/pkgs-image/cache-packages.txt" /var/cache/pacman/pkg "${work_dir}/pkgs-image/opt/livecd/pkgs"
rm -f "${work_dir}/pkgs-image/cache-packages.txt"
}
prepare_cachedirs(){
prepare_dir "${cache_dir_iso}"
prepare_dir "${cache_dir_xorg}"
prepare_dir "${cache_dir_lng}"
}
clean_cache(){
msg2 "Cleaning [$1] ..."
find "$1" -name '*.pkg.tar.xz' -delete &> /dev/null
}
# $1: image path
@ -271,7 +262,7 @@ make_image_xorg() {
else
aufs_mount_root_image "${path}"
fi
download_to_cache "${path}" "${cache_dir_xorg}" "${packages_xorg}"
download_to_cache "${path}" "${packages_xorg}"
copy_cache_xorg
if [[ -n "${packages_xorg_cleanup}" ]]; then
for xorg_clean in ${packages_xorg_cleanup}; do
@ -302,10 +293,10 @@ make_image_lng() {
aufs_mount_root_image "${path}"
fi
if [[ -n ${packages_lng_kde} ]]; then
download_to_cache "${path}" "${cache_dir_lng}" "${packages_lng} ${packages_lng_kde}"
download_to_cache "${path}" "${packages_lng} ${packages_lng_kde}"
copy_cache_lng
else
download_to_cache "${path}" "${cache_dir_lng}" "${packages_lng}"
download_to_cache "${path}" "${packages_lng}"
copy_cache_lng
fi
if [[ -n "${packages_lng_cleanup}" ]]; then
@ -550,8 +541,6 @@ make_profile(){
cd $1
load_profile "$1"
${clean_first} && chroot_clean "${work_dir}"
${clean_cache_xorg} && clean_cache "${cache_dir_xorg}"
${clean_cache_lng} && clean_cache "${cache_dir_lng}"
if ${iso_only}; then
[[ ! -d ${work_dir} ]] && die "Create images: buildiso -p ${buildset_iso} -i"
compress_images