[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#810301: merged /usr support for debootstrap



On Thu, 2016-09-08 at 15:36 +0200, Ansgar Burchardt wrote:
> Could you use the "Codename" field from Release to normalize the
> suite name?  That should work even when the meaning of "stable"
> changes.

I've updated Marco's patch to include this change and prepared
everything as a Git series. The patches below should be applied after
the one I provided for #837075.

Additional testing is of course welcome.

Ansgar
From 55e2452198840684e64b7aad549c2cc92261a7be Mon Sep 17 00:00:00 2001
From: Marco d'Itri <md@linux.it>
Date: Thu, 8 Sep 2016 17:34:14 +0200
Subject: [PATCH 2/6] Merged /usr support for debootstrap

---
 debootstrap   |  6 ++++++
 debootstrap.8 |  3 +++
 functions     | 37 +++++++++++++++++++++++++++++++++++++
 scripts/sid   |  6 ++++++
 4 files changed, 52 insertions(+)

diff --git a/debootstrap b/debootstrap
index 4cea268..ea1d048 100755
--- a/debootstrap
+++ b/debootstrap
@@ -27,6 +27,7 @@ KEYRING=""
 DISABLE_KEYRING=""
 FORCE_KEYRING=""
 VARIANT=""
+MERGED_USR=""
 ARCH=""
 HOST_ARCH=""
 HOST_OS=""
@@ -100,6 +101,7 @@ usage()
       --variant=X            use variant X of the bootstrap scripts
                              (currently supported variants: buildd, fakechroot,
                               scratchbox, minbase)
+      --no-merged-usr        do not make /{bin,sbin,lib}/ symlinks to /usr/
       --keyring=K            check Release files against keyring K
       --no-check-gpg         avoid checking Release file signatures
       --force-check-gpg      force checking Release file signatures
@@ -302,6 +304,10 @@ if [ $# != 0 ] ; then
 			error 1 NEEDARG "option requires an argument %s" "$1"
 		fi
 		;;
+	    --no-merged-usr)
+		MERGED_USR=no
+		shift
+		;;
 	    --keyring|--keyring=?*)
 		if ! gpgv --version >/dev/null 2>&1; then
 			error 1 NEEDGPGV "gpgv not installed, but required for Release verification"
diff --git a/debootstrap.8 b/debootstrap.8
index 5864148..5eeaf04 100644
--- a/debootstrap.8
+++ b/debootstrap.8
@@ -84,6 +84,9 @@ The default, with no \fB\-\-variant=X\fP argument, is to create a base
 Debian installation in
 .IR TARGET .
 .IP
+.IP "\fB\-\-no-merged-usr\fP"
+Do not create /{bin,sbin,lib}/ symlinks pointing to their conterparts in /usr/.
+.IP
 .IP "\fB\-\-keyring=KEYRING\fP"
 Override the default keyring for the distribution being bootstrapped,
 and use
diff --git a/functions b/functions
index 336f220..f633f73 100644
--- a/functions
+++ b/functions
@@ -1136,6 +1136,43 @@ setup_dselect_method () {
 	esac
 }
 
+# Find out where the runtime dynamic linker and the shared libraries
+# can be installed on each architecture: native, multilib and multiarch.
+# This data can be verified by checking the files in the debian/sysdeps/
+# directory of the glibc package.
+#
+# This function must be updated to support any new architecture which
+# either installs the RTLD in a directory different from /lib or builds
+# multilib library packages.
+setup_merged_usr() {
+	if [ "$MERGED_USR" = "no" ]; then return 0; fi
+
+	local link_dir
+	case $ARCH in
+	    hurd-*)	return 0 ;;
+	    amd64)	link_dir="lib32 lib64 libx32" ;;
+	    i386)	link_dir="lib64 libx32" ;;
+	    mips|mipsel)
+			link_dir="lib32 lib64" ;;
+	    mips64*|mipsn32*)
+			link_dir="lib32 lib64 libo32" ;;
+	    powerpc)	link_dir="lib64" ;;
+	    ppc64)	link_dir="lib32 lib64" ;;
+	    ppc64el)	link_dir="lib64" ;;
+	    s390x)	link_dir="lib32" ;;
+	    sparc)	link_dir="lib64" ;;
+	    sparc64)	link_dir="lib32 lib64" ;;
+	    x32)	link_dir="lib32 lib64 libx32" ;;
+	esac
+	link_dir="bin sbin lib $link_dir"
+
+	local dir
+	for dir in $link_dir; do
+		ln -s usr/$dir $TARGET/$dir
+		mkdir -p $TARGET/usr/$dir
+	done
+}
+
 ################################################################ pkgdetails
 
 # NOTE
diff --git a/scripts/sid b/scripts/sid
index 7b32ac2..5866569 100644
--- a/scripts/sid
+++ b/scripts/sid
@@ -41,6 +41,12 @@ work_out_debs () {
 }
 
 first_stage_install () {
+	case $SUITE in
+		etch|etch-m68k|jessie|lenny|squeeze|wheezy) ;;
+		oldstable|stable) ;;
+		*) setup_merged_usr ;;
+	esac
+
 	extract $required
 
 	mkdir -p "$TARGET/var/lib/dpkg"
-- 
2.9.3

From 6b79352a205a96cee441ae0c6247c4616097a517 Mon Sep 17 00:00:00 2001
From: Ansgar Burchardt <ansgar@debian.org>
Date: Thu, 8 Sep 2016 17:30:17 +0200
Subject: [PATCH 3/6] Pass -k to tar when extracting packages

When installing with a merged /usr, the symlinks in / should not be
replaced with real directories when extracting the packages.
---
 functions | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/functions b/functions
index f633f73..60aea99 100644
--- a/functions
+++ b/functions
@@ -821,7 +821,7 @@ extract_dpkg_deb_field () {
 extract_dpkg_deb_data () {
 	local pkg="$1"
 
-	dpkg-deb --fsys-tarfile "$pkg" | tar -xf -
+	dpkg-deb --fsys-tarfile "$pkg" | tar -kxf -
 }
 
 # Raw .deb extractors
@@ -859,7 +859,7 @@ extract_ar_deb_data () {
 	esac
 
 	if type $cat_cmd >/dev/null 2>&1; then
-		ar -p "$pkg" "$tarball" | $cat_cmd | tar -xf -
+		ar -p "$pkg" "$tarball" | $cat_cmd | tar -kxf -
 	else
 		error 1 UNPACKCMDUNVL "Extracting %s requires the %s command, which is not available" "$pkg" "$cat_cmd"
 	fi
-- 
2.9.3

From 542d399677d21ab7148c6723590fcf19acf900a2 Mon Sep 17 00:00:00 2001
From: Ansgar Burchardt <ansgar@debian.org>
Date: Thu, 8 Sep 2016 17:35:27 +0200
Subject: [PATCH 4/6] Typo: conterparts -> counterparts

---
 debootstrap.8 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/debootstrap.8 b/debootstrap.8
index 5eeaf04..0c2f69f 100644
--- a/debootstrap.8
+++ b/debootstrap.8
@@ -85,7 +85,7 @@ Debian installation in
 .IR TARGET .
 .IP
 .IP "\fB\-\-no-merged-usr\fP"
-Do not create /{bin,sbin,lib}/ symlinks pointing to their conterparts in /usr/.
+Do not create /{bin,sbin,lib}/ symlinks pointing to their counterparts in /usr/.
 .IP
 .IP "\fB\-\-keyring=KEYRING\fP"
 Override the default keyring for the distribution being bootstrapped,
-- 
2.9.3

From 3d118f688e8bf28f28ca5f454834b28bf31436a2 Mon Sep 17 00:00:00 2001
From: Ansgar Burchardt <ansgar@debian.org>
Date: Thu, 8 Sep 2016 17:36:18 +0200
Subject: [PATCH 5/6] Use CODENAME to identify suites which support merged-/usr

Unlike suite names (stable, testing, ...), the codename from the Release
file does not change meaning over time. So the codename should be used
for any hacks that should only happen for some releases.
---
 scripts/sid | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/scripts/sid b/scripts/sid
index 5866569..428c676 100644
--- a/scripts/sid
+++ b/scripts/sid
@@ -41,9 +41,8 @@ work_out_debs () {
 }
 
 first_stage_install () {
-	case $SUITE in
+	case "$CODENAME" in
 		etch|etch-m68k|jessie|lenny|squeeze|wheezy) ;;
-		oldstable|stable) ;;
 		*) setup_merged_usr ;;
 	esac
 
-- 
2.9.3

From 282a804ebf108c49c3f205cb23590a326b2dda2b Mon Sep 17 00:00:00 2001
From: Ansgar Burchardt <ansgar@debian.org>
Date: Thu, 8 Sep 2016 17:40:40 +0200
Subject: [PATCH 6/6] Add changelog entry for merged-/usr support.

---
 debian/changelog | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/debian/changelog b/debian/changelog
index 96a1dc9..9b24038 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -2,6 +2,8 @@ debootstrap (1.0.83) UNRELEASED; urgency=medium
 
   * functions: Validate that the requested suite is listed in the
     Release file's Suite or Codename field. (Closes: #837075)
+  * Add support for merged-/usr, enabled by default for stretch and later.
+    (Closes: #810301)
 
  -- Ansgar Burchardt <ansgar@debian.org>  Thu, 08 Sep 2016 17:26:53 +0200
 
-- 
2.9.3


Reply to: