Skip to contentSkip to conversation

deb packages support: switch from /var/dpkg to /var/lib/dpkg

PATCH In review Filip Zyzniewski 1 participant 2 messages Feb 12, 2011 – Feb 13, 2011 1 message not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 deb packages support: switch from /var/dpkg to /var/lib/dpkg

OE generally tries to use /var/dpkg, but the change is missing in some places, so it is needed to move completely to one of the options. Keeping the dpkg's default /var/lib/dpkg causes less maintenance overhead for OE.

---
 classes/rootfs_deb.bbclass                         |   36 ++++++++++----------
 recipes/apt/files/apt.conf                         |    4 +-
 recipes/dpkg/dpkg-native.inc                       |    2 +-
 recipes/dpkg/dpkg_1.14.29.bb                       |    1 +
 recipes/meta/run-postinsts/run-postinsts           |    2 +-
 recipes/meta/run-postinsts/run-postinsts.awk       |    2 +-
 .../update-alternatives-dpkg-native_1.13.25.bb     |    3 +-
 .../update-alternatives-dpkg-native_1.14.29.bb     |    3 +-
 .../update-alternatives-dpkg_1.13.25.bb            |    3 +-
 .../update-alternatives-dpkg_1.14.29.bb            |    3 +-
 10 files changed, 32 insertions(+), 27 deletions(-)
classes/rootfs_deb.bbclass +18 -18
index 6a87c7d..2130ad6 100644
@@ -9,14 +9,14 @@ do_rootfs[recrdeptask] += "do_package_write_deb"
 
 fakeroot rootfs_deb_do_rootfs () {
 	set +e
-	mkdir -p ${IMAGE_ROOTFS}/var/dpkg/info
-	mkdir -p ${IMAGE_ROOTFS}/var/dpkg/updates
+	mkdir -p ${IMAGE_ROOTFS}/var/lib/dpkg/info
+	mkdir -p ${IMAGE_ROOTFS}/var/lib/dpkg/updates
 
 	rm -f ${STAGING_ETCDIR_NATIVE}/apt/sources.list.rev
 	rm -f ${STAGING_ETCDIR_NATIVE}/apt/preferences
-	> ${IMAGE_ROOTFS}/var/dpkg/status
-	> ${IMAGE_ROOTFS}/var/dpkg/available
-	mkdir -p ${IMAGE_ROOTFS}/var/dpkg/alternatives
+	> ${IMAGE_ROOTFS}/var/lib/dpkg/status
+	> ${IMAGE_ROOTFS}/var/lib/dpkg/available
+	mkdir -p ${IMAGE_ROOTFS}/var/lib/dpkg/alternatives
 
 	priority=1
 	for arch in ${PACKAGE_ARCHS}; do
@@ -44,8 +44,8 @@ fakeroot rootfs_deb_do_rootfs () {
 
 	cat "${STAGING_ETCDIR_NATIVE}/apt/apt.conf.sample" \
 		| sed -e 's#Architecture ".*";#Architecture "${DPKG_ARCH}";#' \
-	        | sed -e 's#status ".*";#status "${IMAGE_ROOTFS}/var/dpkg/status";#' \ 
-		| sed -e 's#DPkg::Options {".*"};#DPkg::Options {"--root=${IMAGE_ROOTFS}";"--admindir=${IMAGE_ROOTFS}/var/dpkg";"--force-all";"--no-debsig"};#' \
+	        | sed -e 's#status ".*";#status "${IMAGE_ROOTFS}/var/lib/dpkg/status";#' \ 
+		| sed -e 's#DPkg::Options {".*"};#DPkg::Options {"--root=${IMAGE_ROOTFS}";"--admindir=${IMAGE_ROOTFS}/var/lib/dpkg";"--force-all";"--no-debsig"};#' \
 		> "${STAGING_ETCDIR_NATIVE}/apt/apt-rootfs.conf"
 
 	export APT_CONFIG="${STAGING_ETCDIR_NATIVE}/apt/apt-rootfs.conf"
@@ -57,10 +57,10 @@ fakeroot rootfs_deb_do_rootfs () {
 	apt-get update
 
 	_flag () {
-		sed -i -e "/^Package: $2\$/{n; s/Status: install ok .*/Status: install ok $1/;}" ${IMAGE_ROOTFS}/var/dpkg/status
+		sed -i -e "/^Package: $2\$/{n; s/Status: install ok .*/Status: install ok $1/;}" ${IMAGE_ROOTFS}/var/lib/dpkg/status
 	}
 	_getflag () {
-		cat ${IMAGE_ROOTFS}/var/dpkg/status | sed -n -e "/^Package: $2\$/{n; s/Status: install ok .*/$1/; p}"
+		cat ${IMAGE_ROOTFS}/var/lib/dpkg/status | sed -n -e "/^Package: $2\$/{n; s/Status: install ok .*/$1/; p}"
 	}
 
 	if [ x${TARGET_OS} = "xlinux" ] || [ x${TARGET_OS} = "xlinux-gnueabi" ] ; then
@@ -102,11 +102,11 @@ fakeroot rootfs_deb_do_rootfs () {
 	echo ${BUILDNAME} > ${IMAGE_ROOTFS}/${sysconfdir}/version
 
 	# Mark all packages installed
-	sed -i -e "s/Status: install ok unpacked/Status: install ok installed/;" ${IMAGE_ROOTFS}/var/dpkg/status
+	sed -i -e "s/Status: install ok unpacked/Status: install ok installed/;" ${IMAGE_ROOTFS}/var/lib/dpkg/status
 
 	# Attempt to run preinsts
 	# Mark packages with preinst failures as unpacked
-	for i in ${IMAGE_ROOTFS}/var/dpkg/info/*.preinst; do
+	for i in ${IMAGE_ROOTFS}/var/lib/dpkg/info/*.preinst; do
 		if [ -f $i ] && ! sh $i; then
 			_flag unpacked `basename $i .preinst`
 		fi
@@ -114,7 +114,7 @@ fakeroot rootfs_deb_do_rootfs () {
 
 	# Attempt to run postinsts
 	# Mark packages with postinst failures as unpacked
-	for i in ${IMAGE_ROOTFS}/var/dpkg/info/*.postinst; do
+	for i in ${IMAGE_ROOTFS}/var/lib/dpkg/info/*.postinst; do
 		if [ -f $i ] && ! sh $i configure; then
 			_flag unpacked `basename $i .postinst`
 		fi
@@ -124,13 +124,13 @@ fakeroot rootfs_deb_do_rootfs () {
 
 	# Hacks to allow opkg's update-alternatives and opkg to coexist for now
 	mkdir -p ${IMAGE_ROOTFS}${libdir}/opkg/alternatives
-	if [ -e ${IMAGE_ROOTFS}/var/dpkg/alternatives ]; then
-		mv ${IMAGE_ROOTFS}/var/dpkg/alternatives/* ${IMAGE_ROOTFS}${libdir}/opkg/alternatives/
-		rmdir ${IMAGE_ROOTFS}/var/dpkg/alternatives
+	if [ -e ${IMAGE_ROOTFS}/var/lib/dpkg/alternatives ]; then
+		mv ${IMAGE_ROOTFS}/var/lib/dpkg/alternatives/* ${IMAGE_ROOTFS}${libdir}/opkg/alternatives/
+		rmdir ${IMAGE_ROOTFS}/var/lib/dpkg/alternatives
 	fi
-	ln -s ${libdir}/opkg/alternatives ${IMAGE_ROOTFS}/var/dpkg/alternatives
-	ln -s /var/dpkg/info ${IMAGE_ROOTFS}${libdir}/opkg/info
-	ln -s /var/dpkg/status ${IMAGE_ROOTFS}${libdir}/opkg/status
+	ln -s ${libdir}/opkg/alternatives ${IMAGE_ROOTFS}/var/lib/dpkg/alternatives
+	ln -s /var/lib/dpkg/info ${IMAGE_ROOTFS}${libdir}/opkg/info
+	ln -s /var/lib/dpkg/status ${IMAGE_ROOTFS}${libdir}/opkg/status
 
 	${ROOTFS_POSTPROCESS_COMMAND}
 
recipes/apt/files/apt.conf +2 -2
index 2bd9ddb..5b18b91 100644
@@ -3,7 +3,7 @@ Dir "${STAGING_DIR_NATIVE}/"
    State "var/lib/apt/"
    {
       Lists "lists/";
-      status "${IMAGE_ROOTFS}/var/dpkg/status";
+      status "${IMAGE_ROOTFS}/var/lib/dpkg/status";
    };
    Cache "var/cache/apt/"
    {
@@ -39,5 +39,5 @@ APT
   };
 };
 
-DPkg::Options {"--root=${IMAGE_ROOTFS}";"--admindir=${IMAGE_ROOTFS}/var/dpkg";"--force-all";"--no-debsig"};
+DPkg::Options {"--root=${IMAGE_ROOTFS}";"--admindir=${IMAGE_ROOTFS}/var/lib/dpkg";"--force-all";"--no-debsig"};
 };
recipes/dpkg/dpkg-native.inc +1 -1
index f7b243c..e97b511 100644
@@ -18,7 +18,7 @@ EXTRA_OECONF = "--without-static-progs \
 		--with-zlib \
 		--with-bz2lib \
 		--without-selinux \
-		--with-admindir='\$\$$ENV{D}/var/dpkg' \
+		--with-admindir='\$\$$ENV{D}/var/lib/dpkg' \
 		--without-sgml-doc"
 
 do_stage_append() {
recipes/dpkg/dpkg_1.14.29.bb +1 -0
index 92c8a96..aea7bea 100644
@@ -11,4 +11,5 @@ EXTRA_OECONF = "--without-static-progs \
 		--with-start-stop-daemon \
 		--with-zlib \
 		--with-bz2lib \
+		--with-admindir='/var/lib/dpkg' \
 		--without-sgml-doc"
recipes/meta/run-postinsts/run-postinsts +1 -1
index f632d1c..584a92e 100755
@@ -5,7 +5,7 @@
 # Author: Richard Purdie <[email protected]>
 #
 
-PKGSYSTEM=/var/dpkg
+PKGSYSTEM=/var/lib/dpkg
 
 if [ ! -e $PKGSYSTEM/status ]; then
   if [ -e /usr/lib/opkg/status ]; then
recipes/meta/run-postinsts/run-postinsts.awk +1 -1
index 09a1400..d92200b 100644
@@ -9,7 +9,7 @@
 BEGIN {
   rc=system("test -d /usr/dpkg/info/")
   if (rc==0)
-    pkgdir="/var/dpkg/info"
+    pkgdir="/var/lib/dpkg/info"
   else
     pkgdir="/usr/lib/opkg/info"
   package=""
recipes/update-alternatives/update-alternatives-dpkg-native_1.13.25.bb +2 -1
index 0edb7ae..eca5c57 100644
@@ -1,6 +1,7 @@
 require update-alternatives-dpkg.inc
 inherit native
 
+PR = "r1"
 PROVIDES += "virtual/update-alternatives-native"
 DEPENDS = "perl-native"
 DEFAULT_PREFERENCE = "-1"
@@ -9,7 +10,7 @@ SRC_URI += "file://paths.patch"
 
 do_stage () {
     install -d ${sbindir} \
-               ${localstatedir}/dpkg/alternatives \
+               ${localstatedir}/lib/dpkg/alternatives \
                ${sysconfdir}/alternatives
 
     install -m 0755 scripts/update-alternatives ${sbindir}/update-alternatives
recipes/update-alternatives/update-alternatives-dpkg-native_1.14.29.bb +2 -1
index 388988d..fdb084c 100644
@@ -1,6 +1,7 @@
 require update-alternatives-dpkg.inc
 inherit native
 
+PR="r1"
 PROVIDES += "virtual/update-alternatives-native"
 DEPENDS = "perl-native"
 DEFAULT_PREFERENCE = "-1"
@@ -9,7 +10,7 @@ SRC_URI += "file://update-alternatives-native.patch"
 
 do_stage () {
     install -d ${sbindir} \
-               ${localstatedir}/dpkg/alternatives \
+               ${localstatedir}/lib/dpkg/alternatives \
                ${sysconfdir}/alternatives
 
     install -m 0755 scripts/update-alternatives ${sbindir}/update-alternatives
recipes/update-alternatives/update-alternatives-dpkg_1.13.25.bb +2 -1
index fc8701a..57e2741 100644
@@ -1,5 +1,6 @@
 require update-alternatives-dpkg.inc
 
+PR="r1"
 RPROVIDES_${PN} = "update-alternatives"
 RDEPENDS_${PN} = "perl dpkg"
 
@@ -7,7 +8,7 @@ SRC_URI += "file://paths.patch"
 
 do_install () {
     install -d ${D}${sbindir} \
-               ${D}${localstatedir}/dpkg/alternatives \
+               ${D}${localstatedir}/lib/dpkg/alternatives \
                ${D}${sysconfdir}/alternatives
 
     install -m 0755 scripts/update-alternatives ${D}${sbindir}/update-alternatives
recipes/update-alternatives/update-alternatives-dpkg_1.14.29.bb +2 -1
index 4ad681e..24e6b95 100644
@@ -1,11 +1,12 @@
 require update-alternatives-dpkg.inc
 
+PR="r1"
 RPROVIDES_${PN} = "update-alternatives"
 RDEPENDS_${PN} = "perl dpkg"
 
 do_install () {
     install -d ${D}${sbindir} \
-               ${D}${localstatedir}/dpkg/alternatives \
+               ${D}${localstatedir}/lib/dpkg/alternatives \
                ${D}${sysconfdir}/alternatives
 
     install -m 0755 scripts/update-alternatives ${D}${sbindir}/update-alternatives
Signature · 1 line
1.7.1

A message that is not in the archive (sent off-list or not yet received): [email protected]

#2 lore raw
Quoted 8 lines · Martin Jansa

On Sat, Feb 12, 2011 at 08:26:58PM +0100, Filip Zyzniewski wrote:

I'm not using dpkg with OE, so personally I don't care, but be aware that this change breaks upgrade path for every-package which is using u-a. You need another hack moving /var/dpkg/alternatives content to /var/lib/dpkg/alternatives, before first alternative is reinstalled/upgraded, otherwise it will use alternative with lower priority even when there is alternative with higher.

DPKG support was not functional until recently (my patches are an attempt to get it back to working state), so I don't think there is any distro/system I would break by these.

Is it still a concern in this case?

bye,
Filip Zyzniewski