Skip to content

Commit

Permalink
Remove redundant cache_dirs, fix read only cache_dirs issue
Browse files Browse the repository at this point in the history
Fix #57
  • Loading branch information
bartus committed Mar 3, 2021
1 parent 90ba07d commit ff1a13b
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions arch-nspawn.in
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ for host_mirror in "${host_mirrors[@]}"; do
if [[ $host_mirror == *file://* ]]; then
host_mirror=$(echo "$host_mirror" | sed -r 's#file://(/.*)/\$repo/os/\$arch#\1#g')
for m in "$host_mirror"/pool/*/; do
in_array "$m" "${cache_dirs[@]}" || cache_dirs+=("$m")
in_array "$m" "${cache_dirs[@]}" || extra_cache_dirs+=("$m")
done
fi
done
Expand All @@ -81,14 +81,14 @@ while read -r line; do
for line in "${lines[@]}"; do
if [[ $line = file://* ]]; then
line=${line#file://}
in_array "$line" "${cache_dirs[@]}" || cache_dirs+=("$line")
in_array "$line" "${cache_dirs[@]}" || extra_cache_dirs+=("$line")
fi
done
done < <($pacconf_cmd --config "${pac_conf:-$working_dir/etc/pacman.conf}" --repo-list)

mount_args+=("--bind=${cache_dirs[0]//:/\\:}")

for cache_dir in "${cache_dirs[@]:1}"; do
for cache_dir in "${cache_dirs[@]:1}" "${extra_cache_dirs[@]}"; do
mount_args+=("--bind-ro=${cache_dir//:/\\:}")
done

Expand All @@ -99,16 +99,19 @@ copy_hostconf () {

printf 'Server = %s\n' "${host_mirrors[@]}" >"$working_dir/etc/pacman.d/mirrorlist"

[[ -n $pac_conf ]] && cp "$pac_conf" "$working_dir/etc/pacman.conf"
if [[ -n $pac_conf ]]; then
cp "$pac_conf" "$working_dir/etc/pacman.conf"
if (( ${#extra_cache_dirs[@]} != 0 )); then
echo -e "\n[options]\nCacheDir = ${extra_cache_dirs[*]}" >> "$working_dir/etc/pacman.conf"
fi
fi
[[ -n $makepkg_conf ]] && cp "$makepkg_conf" "$working_dir/etc/makepkg.conf"

local file
for file in "${files[@]}"; do
mkdir -p "$(dirname "$working_dir$file")"
cp -T "$file" "$working_dir$file"
done

sed -r "s|^#?\\s*CacheDir.+|CacheDir = ${cache_dirs[*]}|g" -i "$working_dir/etc/pacman.conf"
}
# }}}

Expand Down

0 comments on commit ff1a13b

Please sign in to comment.