Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove redundant cache_dirs, fix read only cache_dirs issue #58

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 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,16 @@ 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")
extra_cache_dirs+=("$line")
in_array "$line" "${cache_dirs[@]}" && \
mapfile -d $'\0' -t cache_dirs < <(printf '%s\0' "${cache_dirs[@]}" | grep -zvFx "$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 +101,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