summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2023-01-24 12:08:23 +0100
committerNatanael Copa <ncopa@alpinelinux.org>2023-01-24 12:07:31 +0000
commit04e4624ab54a2c26e03e9df960e1640ceb150ddc (patch)
treeea2832ca6958bcbacbfe627f9c90e526662919b1
parentd0cb8a74038ae77a35fb52752d8977bae87a6614 (diff)
downloadalpine-conf-04e4624ab54a2c26e03e9df960e1640ceb150ddc.zip
setup-*: use fake apk instead of $MOCK apk
-rw-r--r--setup-alpine.in4
-rw-r--r--setup-apkrepos.in2
-rw-r--r--setup-devd.in6
-rw-r--r--setup-interfaces.in8
-rw-r--r--setup-keymap.in4
-rw-r--r--setup-mta.in2
-rw-r--r--setup-ntp.in2
-rw-r--r--setup-proxy.in2
-rw-r--r--setup-sshd.in2
-rw-r--r--setup-timezone.in4
-rw-r--r--setup-user.in2
-rw-r--r--setup-xen-dom0.in2
-rw-r--r--setup-xorg-base.in6
-rwxr-xr-xtests/bin/apk17
-rwxr-xr-xtests/setup_alpine_test29
-rwxr-xr-xtests/setup_proxy_test2
-rwxr-xr-xtests/setup_sshd_test6
17 files changed, 67 insertions, 33 deletions
diff --git a/setup-alpine.in b/setup-alpine.in
index 2da6312..856b0de 100644
--- a/setup-alpine.in
+++ b/setup-alpine.in
@@ -268,7 +268,7 @@ diskmode=$(cat /tmp/alpine-install-diskmode.out 2>/dev/null)
if [ "$diskmode" != "sys" ]; then
setup-lbu ${LBUOPTS}
setup-apkcache ${APKCACHEOPTS}
- if [ -L /etc/apk/cache ]; then
- $MOCK apk cache sync
+ if [ -L "$ROOT"/etc/apk/cache ]; then
+ apk cache sync
fi
fi
diff --git a/setup-apkrepos.in b/setup-apkrepos.in
index 94dff7e..0c6b719 100644
--- a/setup-apkrepos.in
+++ b/setup-apkrepos.in
@@ -257,6 +257,6 @@ done
if $changed; then
printf %s "Updating repository indexes... "
- $MOCK apk update --quiet $apk_root_opt && echo "done."
+ apk update --quiet $apk_root_opt && echo "done."
fi
diff --git a/setup-devd.in b/setup-devd.in
index 7daaa74..58fa6f0 100644
--- a/setup-devd.in
+++ b/setup-devd.in
@@ -37,7 +37,7 @@ disable_mdev () {
}
enable_mdev () {
- $MOCK apk add --quiet busybox-mdev-openrc
+ apk add --quiet busybox-mdev-openrc
rc-update add --quiet mdev sysinit
rc-update add --quiet hwdrivers sysinit
rc-service mdev --ifstopped start
@@ -55,7 +55,7 @@ disable_mdevd () {
}
enable_mdevd () {
- $MOCK apk add --quiet mdevd mdevd-openrc
+ apk add --quiet mdevd mdevd-openrc
rc-update add --quiet mdevd sysinit
rc-update add --quiet mdevd-init sysinit
rc-update add --quiet hwdrivers sysinit
@@ -78,7 +78,7 @@ disable_udev () {
}
enable_udev () {
- $MOCK apk add --quiet eudev udev-init-scripts udev-init-scripts-openrc
+ apk add --quiet eudev udev-init-scripts udev-init-scripts-openrc
rc-update add --quiet udev sysinit
rc-update add --quiet udev-trigger sysinit
rc-update add --quiet udev-settle sysinit
diff --git a/setup-interfaces.in b/setup-interfaces.in
index 3a8a71f..33e9219 100644
--- a/setup-interfaces.in
+++ b/setup-interfaces.in
@@ -198,7 +198,7 @@ config_iface() {
echo "raw_device=\"$raw_device\"" >> $conf
fi
if is_wifi $iface; then
- $MOCK apk add --quiet --no-progress iw wpa_supplicant || return
+ apk add --quiet --no-progress iw wpa_supplicant || return
local wifi_configured=false
while ! $wifi_configured; do
echo "Available wireless networks (scanning):"
@@ -533,14 +533,14 @@ prompt_for_interfaces() {
if ask_yesno "Do you want to do any manual network configuration? (y/n)" n; then
case "$EDITOR" in
- nano) $MOCK apk add nano;;
- vim) $MOCK apk add vim;;
+ nano) apk add nano;;
+ vim) apk add vim;;
esac
${EDITOR:-vi} interfaces
fi
if [ -n "$PKGS" ]; then
- $MOCK apk add --quiet $PKGS
+ apk add --quiet $PKGS
fi
mkdir -p $ROOT/etc/network
diff --git a/setup-keymap.in b/setup-keymap.in
index b8c521d..05a3b02 100644
--- a/setup-keymap.in
+++ b/setup-keymap.in
@@ -96,7 +96,7 @@ select_variant() {
}
goodbye() {
- $MOCK apk del --quiet --no-progress .setup-keymap-deps
+ apk del --quiet --no-progress .setup-keymap-deps
exit $1
}
@@ -109,7 +109,7 @@ done
shift $(( $OPTIND - 1 ))
trap 'goodbye 1' INT
-$MOCK apk add --quiet --virtual .setup-keymap-deps kbd-bkeymaps
+apk add --quiet --virtual .setup-keymap-deps kbd-bkeymaps
deflayout="$1"
defvariant="$2"
diff --git a/setup-mta.in b/setup-mta.in
index fab1d00..9d8242f 100644
--- a/setup-mta.in
+++ b/setup-mta.in
@@ -68,7 +68,7 @@ while [ $# -eq 0 ] && [ "$res" != "221" ]; do
[ "x$res" = "x221" ] && echo "Connection to $mailhub is ok."
done
-$MOCK apk add ssmtp
+apk add ssmtp
setcfg mailhub $mailhub
setcfg FromLineOverride YES
diff --git a/setup-ntp.in b/setup-ntp.in
index 9f48d72..6090aac 100644
--- a/setup-ntp.in
+++ b/setup-ntp.in
@@ -58,6 +58,6 @@ case "$resp" in
;;
esac
-[ -z "$pkgs" ] || $MOCK apk add --quiet $pkgs
+[ -z "$pkgs" ] || apk add --quiet $pkgs
rc-update add $svc default
rc-service $svc start
diff --git a/setup-proxy.in b/setup-proxy.in
index 70522d1..a438fe4 100644
--- a/setup-proxy.in
+++ b/setup-proxy.in
@@ -60,7 +60,7 @@ else
export no_proxy=localhost
__EOF__
# busybox wget does not handle http proxies well
- $MOCK apk add --quiet --no-progress wget
+ apk add --quiet --no-progress wget
fi
if [ -z "$quiet" ] && [ "$proxyurl" != "none" ]; then
diff --git a/setup-sshd.in b/setup-sshd.in
index 7e3d6d1..44bcfc0 100644
--- a/setup-sshd.in
+++ b/setup-sshd.in
@@ -75,7 +75,7 @@ if [ "$sshdchoice" = "openssh" ] && apk info --quiet --installed acf-core; then
pkgs="$pkgs acf-openssh"
fi
-$MOCK apk add --quiet $pkgs
+apk add --quiet $pkgs
users=$(awk -F: '{if ($3<65000 && $3 >= 1000) print $1}' \
"$ROOT"/etc/passwd 2>/dev/null)
diff --git a/setup-timezone.in b/setup-timezone.in
index 01a5e37..2be9321 100644
--- a/setup-timezone.in
+++ b/setup-timezone.in
@@ -89,10 +89,10 @@ else
apkdel=".setup-timezone"
fi
-$MOCK apk add --no-progress --quiet $pkg || die "Failed to install tzdata package"
+apk add --no-progress --quiet $pkg || die "Failed to install tzdata package"
if [ -n "$apkdel" ]; then
- trap "$MOCK apk del --no-progress --quiet $apkdel" EXIT HUP INT TERM
+ trap "apk del --no-progress --quiet $apkdel" EXIT HUP INT TERM
fi
if [ -L "${ROOT}"etc/zoneinfo/localtime ]; then
diff --git a/setup-user.in b/setup-user.in
index a61749c..cd4cbef 100644
--- a/setup-user.in
+++ b/setup-user.in
@@ -151,7 +151,7 @@ if [ -n "$groups" ] && [ "$groups" != "none" ]; then
fi
if [ -n "$admin" ]; then
- $MOCK apk add doas
+ apk add doas
mkdir -p "$ROOT"/etc/doas.d
echo "permit persist :wheel" >> "$ROOT"/etc/doas.d/doas.conf
$MOCK addgroup "$username" "wheel" || exit
diff --git a/setup-xen-dom0.in b/setup-xen-dom0.in
index beab62b..a05ccc9 100644
--- a/setup-xen-dom0.in
+++ b/setup-xen-dom0.in
@@ -11,7 +11,7 @@ for mod in xen_netback xen_blkback xenfs xen_pciback xen_wdt tun; do
done
# install packages
-$MOCK apk add --quiet xen
+apk add --quiet xen
# setup and start services
for svc in xenstored xenconsoled xenqemu; do
diff --git a/setup-xorg-base.in b/setup-xorg-base.in
index 372a9f9..3c1896c 100644
--- a/setup-xorg-base.in
+++ b/setup-xorg-base.in
@@ -38,7 +38,7 @@ if test -f "$orig"; then
fi
done < "$orig" >> "$tmp"
mv -f "$tmp" "$orig"
- $MOCK apk update
+ apk update
fi
# enable community repo
@@ -49,9 +49,9 @@ if [ -f "$ROOT"/etc/apk/repositories ] && ! grep -q '^[^#].*/community$' "$ROOT"
-e "/^#${escaped_repo}$/d" \
"$ROOT"/etc/apk/repositories \
&& echo ">> Enabling community repository"
- $MOCK apk update
+ apk update
fi
-$MOCK apk add xorg-server xf86-input-libinput eudev mesa-dri-gallium "$@"
+apk add xorg-server xf86-input-libinput eudev mesa-dri-gallium "$@"
setup-devd udev
diff --git a/tests/bin/apk b/tests/bin/apk
index df1711c..ceff306 100755
--- a/tests/bin/apk
+++ b/tests/bin/apk
@@ -9,10 +9,9 @@ fi
rootfs=.
kver=5.15.78-0
-audit_prefix="U "
while [ $# -gt 0 ]; do
case "$1" in
- add|del)
+ add|del|cache|update)
echo "DEBUG: fake apk" "$@"
cmd="$1"
;;
@@ -24,7 +23,7 @@ while [ $# -gt 0 ]; do
rootfs="$1"
;;
--quiet)
- audit_prefix=""
+ quiet=1
shift ;;
--arch) shift ;;
--repositories-file) shift ;;
@@ -36,13 +35,21 @@ while [ $# -gt 0 ]; do
shift
done
-if [ "$cmd" = audit ]; then
+case "$cmd" in
+ audit)
mkdir -p etc
touch etc/hosts etc/localtime
+ if [ -z "$quiet" ]; then
+ audit_prefix="U "
+ fi
echo "${audit_prefix}etc/hosts"
echo "${audit_prefix}etc/localtime"
exit 0
-fi
+ ;;
+ cache|update|del)
+ exit 0
+ ;;
+esac
for pkg in $pkgs; do
case "$pkg" in
diff --git a/tests/setup_alpine_test b/tests/setup_alpine_test
index 11fce8e..dc84291 100755
--- a/tests/setup_alpine_test
+++ b/tests/setup_alpine_test
@@ -7,7 +7,8 @@ init_tests \
setup_alpine_create_answerfile \
setup_alpine_kvm_clock \
setup_alpine_restart_network \
- setup_alpine_answerfile_none
+ setup_alpine_answerfile_none \
+ setup_alpine_answerfile_apkcache
export WGETCONTENT="https://mirror.example.com"
setup_alpine_usage_body() {
@@ -139,3 +140,29 @@ setup_alpine_answerfile_none_body() {
done
}
+setup_alpine_answerfile_apkcache_body() {
+ init_env
+
+ cat >opts<<-EOF
+ KEYMAPOPTS=none
+ HOSTNAMEOPTS=alpine
+ INTERFACESOPTS=none
+ DNSOPTS=none
+ TIMEZONEOPTS=none
+ PROXYOPTS=none
+ NTPOPTS=none
+ APKREPOSOPTS=none
+ USEROPTS=none
+ SSHDOPTS=none
+ DISKOPTS=none
+ LBUOPTS=none
+ APKCACHEOPTS="media/LABEL=APKOVL/cache"
+ EOF
+ atf_check -s exit:0 \
+ -o match:"apk cache" \
+ setup-alpine -e -f opts
+ if ! [ -L etc/apk/cache ]; then
+ atf_fail "etc/apk/cache was not created"
+ fi
+}
+
diff --git a/tests/setup_proxy_test b/tests/setup_proxy_test
index 6fab883..5e0073c 100755
--- a/tests/setup_proxy_test
+++ b/tests/setup_proxy_test
@@ -14,7 +14,7 @@ setup_proxy_usage_body() {
setup_proxy_url_body() {
init_env
atf_check -s exit:0 \
- -o match:'^apk add.*wget' \
+ -o match:'apk add.*wget' \
-e empty \
setup-proxy https://example.com
grep http_proxy etc/profile.d/proxy.sh || atf_fail "http_proxy not set in etc/profile.d/proxy.sh"
diff --git a/tests/setup_sshd_test b/tests/setup_sshd_test
index 3d62f62..f44c4a4 100755
--- a/tests/setup_sshd_test
+++ b/tests/setup_sshd_test
@@ -29,7 +29,7 @@ setup_sshd_dropbear_body() {
init_env
atf_check -s exit:0 \
-e empty \
- -o match:"^apk add .* dropbear" \
+ -o match:"apk add .* dropbear" \
-o match:"service dropbear added" \
-o match:"Starting dropbear" \
setup-sshd dropbear
@@ -40,7 +40,7 @@ setup_sshd_openssh_body() {
export WGETCONTENT="ssh-id FOOBAR"
atf_check -s exit:0 \
-e empty \
- -o match:"^apk add .* openssh" \
+ -o match:"apk add .* openssh" \
-o match:"service sshd added" \
-o match:"Starting sshd" \
setup-sshd -k 'https://example.com/user.keys' openssh
@@ -58,7 +58,7 @@ setup_sshd_openssh_c_compat_body() {
init_env
atf_check -s exit:0 \
-e empty \
- -o match:"^apk add .* openssh" \
+ -o match:"apk add .* openssh" \
-o match:"service sshd added" \
-o match:"Starting sshd" \
-o not-match:"Allow root ssh" \