From 17292f4f5ea4f2eba6788f6b55c48a8c785acd20 Mon Sep 17 00:00:00 2001 From: Oliver Smith Date: Tue, 14 May 2019 21:00:15 +0200 Subject: [PATCH] main/postmarketos-base: fix wpa_supplicant config (!365) Fix wifi on htc-ace by properly setting nl80211 before wext. /etc/conf.d/wpa_supplicant is supposed to get modified twice with the current code in the post-install file. The first one was patched recently to set nl80211 before wext, but that change does not work in practice, for two reasons: 1. The code block does not even get executed, because apk reports that /etc/conf.d/wpa_supplicant was already modified (by a package that was installed before, in its post-install script? I could not find out which one does that though). 2. Even if it worked, the second code block would revert the change and put wext before nl80211 again. Fix this by removing the first code block, and changing the order in the second one. Make it easier to catch such errors in the future, by printing, which files get modified, or get skipped. Set "#!/bin/sh -e", so the script can not fail silently. When doing pmbootstrap -y zap and then pmbootstrap install, the output looks like this: (141/151) Installing postmarketos-base (3-r26) Executing postmarketos-base-3-r26.post-install - Modifying: /etc/fstab - Modifying: /etc/issue - Modifying: /etc/motd - Modifying: /etc/conf.d/syslog - Modifying: /etc/conf.d/wpa_supplicant - Modifying: /etc/sudoers - Modifying: /etc/chrony/chrony.conf --- main/postmarketos-base/APKBUILD | 2 +- .../postmarketos-base.post-install | 27 +++++++++++-------- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/main/postmarketos-base/APKBUILD b/main/postmarketos-base/APKBUILD index 3e18f1f85..d83227917 100644 --- a/main/postmarketos-base/APKBUILD +++ b/main/postmarketos-base/APKBUILD @@ -1,6 +1,6 @@ pkgname=postmarketos-base pkgver=3 -pkgrel=26 +pkgrel=27 pkgdesc="Meta package for minimal postmarketOS base" url="https://postmarketos.org" arch="noarch" diff --git a/main/postmarketos-base/postmarketos-base.post-install b/main/postmarketos-base/postmarketos-base.post-install index b84854d5c..296958cb3 100644 --- a/main/postmarketos-base/postmarketos-base.post-install +++ b/main/postmarketos-base/postmarketos-base.post-install @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/sh -e # Enable udev OpenRC services and runlevels # https://github.com/alpinelinux/aports/blob/master/main/eudev/setup-udev @@ -22,10 +22,16 @@ done mkdir -p /run/openrc touch /run/openrc/shutdowntime +# Replace a config file from stock Alpine, unless apk reports that the user has +# modified it (note that this does not allow properly updating these configs +# when postmarketos-base gets updated yet, see issue pmaports#258). write_unless_modified() { # Redirect the stdin to the file unless it has been modified # $1: file path - if ! apk audit "$(dirname "$1")" | grep -q "${1:1}"; then + if apk audit "$(dirname "$1")" | grep -q "${1:1}"; then + echo "- NOT modifying (file was changed before): $1" + else + echo "- Modifying: $1" cat > "$1" fi } @@ -58,25 +64,24 @@ write_unless_modified() { echo '' } | write_unless_modified /etc/motd -# Change wpa_supplicant into dbus mode and enable both drivers -{ - echo 'wpa_supplicant_args="-u -Dnl80211,wext"' -} | write_unless_modified /etc/conf.d/wpa_supplicant -touch /etc/wpa_supplicant/wpa_supplicant.conf - # Enable syslog to SHM. Note: size is 4048KiB, which *should* be More Than Enough(TM) for all but the most chattiest of devices. +echo "- Modifying: /etc/conf.d/syslog" sed s/=\"/=\""-C4048 "/ -i /etc/conf.d/syslog -# Enable wext, nl80211 & dbus control for wpa_supplicant -if ! grep -q Dwext /etc/conf.d/wpa_supplicant; then - sed -i 's/wpa_supplicant_args=\"/wpa_supplicant_args=\" -u -Dwext,nl80211/' /etc/conf.d/wpa_supplicant +# Enable nl80211,wext & dbus control for wpa_supplicant +if ! grep -q Dnl80211,wext /etc/conf.d/wpa_supplicant; then + echo "- Modifying: /etc/conf.d/wpa_supplicant" + sed -i 's/wpa_supplicant_args=\"/wpa_supplicant_args=\" -u -Dnl80211,wext/' \ + /etc/conf.d/wpa_supplicant fi touch /etc/wpa_supplicant/wpa_supplicant.conf # Enable the 'wheel' group +echo "- Modifying: /etc/sudoers" sed -i 's/# %wheel ALL=(ALL) ALL/%wheel ALL=(ALL) ALL/' /etc/sudoers # Set chrony to quickly correct system time on first boot, if necessary if ! grep -q "makestep" /etc/chrony/chrony.conf; then + echo "- Modifying: /etc/chrony/chrony.conf" echo "makestep 1 -1" >> /etc/chrony/chrony.conf fi