Skip to content

Commit 85eea2c

Browse files
authored
Merge pull request #51 from sgaraev/main
postinst: fix the removal of all extensions
2 parents aa31b3e + 72bce86 commit 85eea2c

1 file changed

Lines changed: 15 additions & 9 deletions

File tree

flatcar-postinst

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -191,16 +191,22 @@ fi
191191
# and when the name is prefixed with a "-" it means that the extension should be disabled if enabled by default in the file from /usr.
192192
# It may contain comments starting with "#" at the beginning of a line or after a name.
193193
# The file is also used in bootengine to know which extensions to enable.
194-
# Note that we don't need "{ grep || true ; }" to suppress the match return code because in for _ in $(grep...) return codes are ignored
195-
for NAME in $(grep -h -o '^[^#]*' /etc/flatcar/enabled-sysext.conf /usr/share/flatcar/enabled-sysext.conf | grep -v -x -f <(grep '^-' /etc/flatcar/enabled-sysext.conf | cut -d - -f 2-) | grep -v -P '^(-).*'); do
196-
KEEP="/etc/flatcar/sysext/flatcar-${NAME}-${VERSION}.raw"
197-
shopt -s nullglob
198-
# Delete sysext images that belonged to the now overwritten /usr partition but keep the sysext image for the current version
199-
for OLD_IMAGE in /etc/flatcar/sysext/flatcar*raw; do
200-
if [ "${OLD_IMAGE}" != "${KEEP}" ] && [ -f "${OLD_IMAGE}" ]; then
201-
rm -f "${OLD_IMAGE}"
202-
fi
194+
ENABLED_EXTENSIONS=$(grep -h -o '^[^#]*' /etc/flatcar/enabled-sysext.conf /usr/share/flatcar/enabled-sysext.conf | grep -v -x -f <(grep '^-' /etc/flatcar/enabled-sysext.conf | cut -d - -f 2-) | grep -v -P '^(-).*' || true)
195+
shopt -s nullglob
196+
# Delete sysext images that belonged to the now overwritten /usr partition but keep the sysext image for the current version
197+
for OLD_IMAGE in /etc/flatcar/sysext/flatcar*raw; do
198+
SHOULD_KEEP=false
199+
for NAME in ${ENABLED_EXTENSIONS}; do
200+
if [ "${OLD_IMAGE}" == "/etc/flatcar/sysext/flatcar-${NAME}-${VERSION}.raw" ]; then
201+
SHOULD_KEEP=true
202+
break
203+
fi
203204
done
205+
if [ "${SHOULD_KEEP}" == false ] && [ -f "${OLD_IMAGE}" ]; then
206+
rm -f "${OLD_IMAGE}"
207+
fi
208+
done
209+
for NAME in ${ENABLED_EXTENSIONS}; do
204210
# Note that in the case of VERSION=NEXT_VERSION we will replace the running sysext and maybe it's better
205211
# to do so than not because it allows to recover from a corrupted file (where the corruption happened on disk)
206212
SUCCESS=false

0 commit comments

Comments
 (0)