Skip to contentSkip to conversation

rpm: Move postinsts to /var

PATCH In review Colin Walters 3 participants 4 messages Jan 3, 2012 – Jan 4, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rpm: Move postinsts to /var

My OS has read-only bind mounts over most directories (including /etc), with the exception of /var. Since these scripts need to be run once and then deleted, it's better for me if these are in /var, and won't hurt anyone else for them to be there.

From 529d2e5e193c82ddb1e4bee57c650b07cf844ce5 Mon Sep 17 00:00:00 2001
From: Colin Walters <[email protected]>
Date: Tue, 3 Jan 2012 13:45:38 -0500
Subject: [PATCH] rpm: Move postinsts to /var

My OS has read-only bind mounts over most directories (including /etc), with the exception of /var. Since these scripts need to be run once and then deleted, it's better for me if these are in /var, and won't hurt anyone else for them to be there.

---
 meta/classes/package_rpm.bbclass |   12 ++++++------
 meta/classes/rootfs_rpm.bbclass  |   19 +++++++++++--------
 2 files changed, 17 insertions(+), 14 deletions(-)
meta/classes/package_rpm.bbclass +6 -6
index 2ace053..094571b 100644
@@ -394,13 +394,13 @@ export OPKG_OFFLINE_ROOT="\$D"
 
 \$2 \$1/\$3 \$4
 if [ \$? -ne 0 ]; then
-  mkdir -p \$1/etc/rpm-postinsts
+  mkdir -p \$1/var/rpm-postinsts
   num=100
-  while [ -e \$1/etc/rpm-postinsts/\${num} ]; do num=\$((num + 1)); done
-  echo "#!\$2" > \$1/etc/rpm-postinsts/\${num}
-  echo "# Arg: \$4" >> \$1/etc/rpm-postinsts/\${num}
-  cat \$1/\$3 >> \$1/etc/rpm-postinsts/\${num}
-  chmod +x \$1/etc/rpm-postinsts/\${num}
+  while [ -e \$1/var/rpm-postinsts/\${num} ]; do num=\$((num + 1)); done
+  echo "#!\$2" > \$1/var/rpm-postinsts/\${num}
+  echo "# Arg: \$4" >> \$1/var/rpm-postinsts/\${num}
+  cat \$1/\$3 >> \$1/var/rpm-postinsts/\${num}
+  chmod +x \$1/var/rpm-postinsts/\${num}
 fi
 EOF
 
meta/classes/rootfs_rpm.bbclass +11 -8
index 6973008..3a583df 100644
@@ -107,7 +107,7 @@ EOF
 	${ROOTFS_POSTINSTALL_COMMAND}
 
 	# Report delayed package scriptlets
-	for i in ${IMAGE_ROOTFS}/etc/rpm-postinsts/*; do
+	for i in ${IMAGE_ROOTFS}/var/rpm-postinsts/*; do
 		echo "Delayed package scriptlet: `head -n 3 $i | tail -n 1`"
 	done
 
@@ -116,15 +116,18 @@ EOF
 	i=\$i
 	cat > ${IMAGE_ROOTFS}${sysconfdir}/rcS.d/S${POSTINSTALL_INITPOSITION}configure << EOF
 #!/bin/sh
-for i in /etc/rpm-postinsts/*; do
-	echo "Running postinst $i..."
-	if [ -f $i ] && $i; then
-		rm $i
-	else
-		echo "ERROR: postinst $i failed."
+for i in /var/rpm-postinsts/*; do
+	if [ -f $i ]; then
+		echo "Running postinst $i..."
+		if $i; then
+			rm -f $i
+		else
+			echo "ERROR: postinst $i failed."
+		fi
 	fi
 done
-rm -f ${sysconfdir}/rcS.d/S${POSTINSTALL_INITPOSITION}configure
+# Don't show any errors if this fails, e.g. due to /etc being a readonly bind mount
+rm -f ${sysconfdir}/rcS.d/S${POSTINSTALL_INITPOSITION}configure 2>/dev/null
 EOF
 	chmod 0755 ${IMAGE_ROOTFS}${sysconfdir}/rcS.d/S${POSTINSTALL_INITPOSITION}configure
 
Signature · 1 line
1.7.6.4
#1 lore raw
Quoted 6 lines · Colin Walters

My OS has read-only bind mounts over most directories (including /etc), with the exception of /var. Since these scripts need to be run once and then deleted, it's better for me if these are in /var, and won't hurt anyone else for them to be there.

You fixed this for RPM, does it exist for deb and ipkg also?

Sau!

Quoted 6 lines

_______________________________________________
poky mailing list
[email protected]
https://lists.yoctoproject.org/listinfo/poky

#2 lore raw
Quoted 7 lines · Saul Wold
Quoted 6 lines · Colin Walters

My OS has read-only bind mounts over most directories (including /etc), with the exception of /var. Since these scripts need to be run once and then deleted, it's better for me if these are in /var, and won't hurt anyone else for them to be there.

You fixed this for RPM, does it exist for deb and ipkg also?

From a glance, no:

rootfs_deb.bbclass
# Attempt to run postinsts
# Mark packages with postinst failures as unpacked for i in ${IMAGE_ROOTFS}/var/lib/dpkg/info/*.postinst; do
if [ -f $i ] && ! sh $i configure; then
_flag unpacked basename $i .postinst
fi
done

rootfs_ipk.bbclass:

	for i in ${IMAGE_ROOTFS}${opkglibdir}/info/*.postinst; do
		if [ -f $i ] && ! sh $i configure; then
		     	runtime_script_required=1
			opkg-cl ${IPKG_ARGS} flag unpacked `basename $i .postinst`
		fi
	done
#3 lore raw
Quoted 20 lines · Colin Walters
Quoted 7 lines · Saul Wold
Quoted 6 lines · Colin Walters

My OS has read-only bind mounts over most directories (including /etc), with the exception of /var. Since these scripts need to be run once and then deleted, it's better for me if these are in /var, and won't hurt anyone else for them to be there.

You fixed this for RPM, does it exist for deb and ipkg also?

From a glance, no:

rootfs_deb.bbclass
# Attempt to run postinsts
# Mark packages with postinst failures as unpacked for i in ${IMAGE_ROOTFS}/var/lib/dpkg/info/*.postinst; do
if [ -f $i ]&& ! sh $i configure; then
_flag unpacked basename $i .postinst
fi
done

Quoted 7 lines

rootfs_ipk.bbclass:

	for i in ${IMAGE_ROOTFS}${opkglibdir}/info/*.postinst; do
		if [ -f $i ]&&  ! sh $i configure; then
		     	runtime_script_required=1
			opkg-cl ${IPKG_ARGS} flag unpacked `basename $i .postinst`
		fi
	done

Based on the above, I would then suggest you use /var/lib/rpm/info/*.postinst

That way the files are contained within the rpm directory of database and associated files. Otherwise, I agree, this is a bug in the current implementation. It shouldn't be using etc for things that can change.

--Mark

Quoted 5 lines

_______________________________________________
poky mailing list
[email protected]
https://lists.yoctoproject.org/listinfo/poky