summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--debian/README.Debian60
-rw-r--r--debian/changelog355
-rw-r--r--debian/control118
-rw-r--r--debian/copyright23
-rwxr-xr-xdebian/rules3
-rw-r--r--debian/source/format1
-rw-r--r--debian/usr-is-merged.postinst28
-rw-r--r--debian/usr-is-merged.preinst56
-rw-r--r--debian/usrmerge.install1
-rw-r--r--debian/usrmerge.maintscript1
-rw-r--r--debian/usrmerge.postinst92
-rw-r--r--debian/usrmerge.preinst42
12 files changed, 780 insertions, 0 deletions
diff --git a/debian/README.Debian b/debian/README.Debian
new file mode 100644
index 0000000..222e5b7
--- /dev/null
+++ b/debian/README.Debian
@@ -0,0 +1,60 @@
+FAQ
+~~~
+* What is the purpose of this package?
+The usrmerge package will convert the system it is installed on to the
+everything-in-usr directories scheme, i.e. the /{bin,sbin,lib}/ directories
+become symbolic links to /usr/{bin,sbin,lib}/.
+In addition to the conversion program it provides a dpkg configuration
+file that works around the few packages that install a file in the same
+directories in / and /usr, until they will be fixed.
+
+* Will usrmerge also merge /usr/bin/ and /usr/sbin/?
+No.
+
+* Does this require systemd?
+No.
+
+* Does this really not require systemd?
+Yes, I promise.
+
+* Does this require an initramfs?
+Only if /usr is on a standalone file system.
+
+* But I hate initramfses and I really do not want to use one!
+Maybe you only hate initramfs-tools? If you build your own custom kernel
+with static drivers for your block device and file system then you can
+mount /usr with just a 12 KB initramfs image containing
+https://github.com/chris-se/tiny-initramfs .
+
+* What are the benefits of everything-in-usr?
+Please consult the web pages listed in the "Other documentation" section
+of this file.
+
+* What are the downsides of everything-in-usr?
+If you can find any then please contact the maintainer of this package.
+
+* If I convert my system to everything-in-usr, how will I be able to
+ recover it from a failure of the /usr filesystem without the tools in /?
+This question is not relevant to everything-in-usr, because Debian has
+not supported booting without /usr being mounted for a long time anyway.
+I recommend to install the grml-rescueboot package which will not only
+allow one to recover from corruption of /usr but also of /.
+
+* Is it safe to do the live conversion of a running system?
+Almost totally safe: currently the conversion process has some races,
+but they are very small and can only be noticed if a daemon tries to
+run a program at the wrong time. I recommend to not worry about this.
+
+* The conversion program has failed with an error, now what?
+Fix the error and run it again. Repeat until no more errors are reported.
+
+Removal of this package
+~~~~~~~~~~~~~~~~~~~~~~~
+The usrmerge package can be removed once the system has been converted,
+and it will be replaced by the empty usr-is-merged package.
+
+Other documentation
+~~~~~~~~~~~~~~~~~~~
+http://www.freedesktop.org/wiki/Software/systemd/TheCaseForTheUsrMerge
+https://fedoraproject.org/wiki/Features/UsrMove
+http://lists.busybox.net/pipermail/busybox/2010-December/074114.html
diff --git a/debian/changelog b/debian/changelog
new file mode 100644
index 0000000..8ab1010
--- /dev/null
+++ b/debian/changelog
@@ -0,0 +1,355 @@
+usrmerge (39) unstable; urgency=medium
+
+ [ Helmut Grohne ]
+ * Support working with cp already moved to /usr/bin/. (Closes: #1060002)
+
+ -- Marco d'Itri <md@linux.it> Sat, 20 Jan 2024 21:35:46 +0100
+
+usrmerge (38) unstable; urgency=medium
+
+ * Remove support for the /etc/unsupported-skip-usrmerge-conversion flag
+ file: usr-is-merged.preinst will ignore it and usrmerge.postinst will
+ fail if it exists. (Closes: #1053671)
+
+ -- Marco d'Itri <md@linux.it> Sat, 28 Oct 2023 01:21:36 +0200
+
+usrmerge (37) unstable; urgency=medium
+
+ [ Johannes Schauer Marin Rodrigues ]
+ * Use $DPKG_ROOT in usr-is-merged.postinst. (Closes: #1050755)
+
+ -- Marco d'Itri <md@linux.it> Tue, 29 Aug 2023 02:14:10 +0200
+
+usrmerge (36) unstable; urgency=medium
+
+ * Added code by Andreas Beckmann to clean up the biarch libraries
+ directories when they are not needed. (Closes: #1038853)
+ * Changed postinst to not run convert-etc-shells again on already
+ converted systems and to run update-shells to make sure that the
+ new shells.state file introduced in bookworm is up to date.
+ (Closes: #1033167)
+ * Improved the instructions to deal with a mounted /lib/modules/,
+ which can also happen on some Xen-based systems. (Closes: 1034346)
+ * Greatly improved the error messages when commands execution fails
+ (see #1037362).
+ * Added a versioned conflict with libc-bin, only relevant for the
+ conversion script. (Closes: #1037362)
+ * Added a versioned conflict with dhcpcd. (Closes: #1038832)
+ * Added a versioned conflict with libparted1.8-10. (Closes: #1038832)
+ * Added a versioned conflict with lustre-utils. (Closes: #1038832)
+
+ -- Marco d'Itri <md@linux.it> Sun, 27 Aug 2023 13:56:49 +0200
+
+usrmerge (35) unstable; urgency=medium
+
+ * Partially revert and further change the fix for #1024596, because it
+ was incomplete and would fail when the directory containing the RTLD
+ (e.g. /lib64) did not exist in /usr. (Closes: #1025926)
+
+ -- Marco d'Itri <md@linux.it> Mon, 12 Dec 2022 00:36:05 +0100
+
+usrmerge (34) unstable; urgency=medium
+
+ * Stopped creating the empty biarch directories, because glibc >= 2.35-4
+ does that in preinst. (Closes: #1024596)
+ * preinst: use mountpoint(1) to check if /usr is standalone instead
+ if comparing st_dev, because this does not work with BTRFS subvolumes.
+ (Closes: #1023816)
+ * Updated the versioned conflict with kbd. (Closes: #1022936)
+ * Made debian/copyright machine-readable. (Closes: #1025684)
+ * Fixed a typo. (Closes: #1022790)
+
+ -- Marco d'Itri <md@linux.it> Sun, 11 Dec 2022 18:59:21 +0100
+
+usrmerge (33) unstable; urgency=medium
+
+ * Added a version number to the conflict with cruft. (See #941998.)
+ * convert-usrmerge: stop if /lib/modules/ is a mount point, which is
+ common on User Mode Linux. (Closes: #1021180)
+ * Implemented only for Hurd systems a modified algorithm provided by
+ Samuel Thibault. (Closes: #1020463)
+
+ -- Marco d'Itri <md@linux.it> Mon, 10 Oct 2022 23:52:46 +0200
+
+usrmerge (32) unstable; urgency=medium
+
+ * convert-usrmerge: fix handling the link X directory case.
+ The case in which the source and destination are a symlink and a
+ directory (or a directory and a symlink) actually was never handled.
+ (Closes: #1020312)
+ * Updated the versioned conflict with libpng12-0. (Closes: #1020549)
+ * Relabel for SELinux the newly created directories and /etc/shells,
+ courtesy of Christian Göttsche.
+
+ -- Marco d'Itri <md@linux.it> Thu, 29 Sep 2022 05:51:16 +0200
+
+usrmerge (31) unstable; urgency=medium
+
+ [ Luca Boccassi ]
+ * usr-is-merged.preinst: run the check on upgrades too, because something
+ may have un-merged the system since the last install. (See #926699.)
+
+ -- Marco d'Itri <md@linux.it> Mon, 19 Sep 2022 13:26:09 +0200
+
+usrmerge (30+nmu2) unstable; urgency=medium
+
+ [ Luca Boccassi ]
+ * Non-maintainer upload.
+ * overlayfs: attempt to move directory before bailing out (Closes:
+ #1020228)
+
+ [ Dimitri John Ledkov ]
+ * Update regexp for new (temporary) ldd output
+
+ -- Luca Boccassi <bluca@debian.org> Sun, 18 Sep 2022 21:20:53 +0100
+
+usrmerge (30+nmu1) unstable; urgency=medium
+
+ * Non-maintainer upload.
+ * maintainer scripts: shellcheck fixes
+ * maintainer scripts: fix running arm64 on nspawn (Closes: #1019575)
+
+ -- Luca Boccassi <bluca@debian.org> Sat, 17 Sep 2022 02:12:55 +0100
+
+usrmerge (30) unstable; urgency=medium
+
+ * Use in usrmerge.postinst the same logic to determine if /usr is
+ merged or not that was already being in usr-is-merged.preinst and
+ convert-usrmerge. (Closes: #1019506)
+
+ -- Marco d'Itri <md@linux.it> Mon, 12 Sep 2022 01:10:54 +0200
+
+usrmerge (29) unstable; urgency=medium
+
+ * Made postinst skip convert-etc-shells too if the flag file is present,
+ to avoid a piuparts failure.
+
+ -- Marco d'Itri <md@linux.it> Sun, 17 Jul 2022 18:12:29 +0200
+
+usrmerge (28) unstable; urgency=medium
+
+ * Reupload for the buildds.
+
+ -- Marco d'Itri <md@linux.it> Sun, 17 Jul 2022 11:12:03 +0200
+
+usrmerge (27) unstable; urgency=medium
+
+ * Created a dummy usr-is-merged package which will fail in preinst if
+ the system does not have a merged /usr. (See the TC decision #994388.)
+ * Implemented a flag file to skip the conversion, for the benefit of
+ buildds. (Closes: #1008203)
+ * Made postinst always fail if the conversion is not possible.
+ * Made postinst fail if overlayfs is involved. (Closes: #1008202)
+ * Removed the debconf question: now the conversion is unconditional.
+ * Created a list of files in / to be ignored if also present in /usr, on
+ request of Ubuntu. (Closes: #997866)
+ * Conflict with cruft. (Closes: #1002888)
+
+ -- Marco d'Itri <md@linux.it> Thu, 14 Jul 2022 23:58:40 +0200
+
+usrmerge (25) unstable; urgency=medium
+
+ * Remove prerm, which has not been needed or even possibly used since
+ usrmerge version 19 started removing /etc/dpkg/dpkg.cfg.d/usrmerge on
+ upgrades. (Closes: #982867)
+ * New debconf translation(s): es. (Closes: #987519)
+
+ -- Marco d'Itri <md@linux.it> Tue, 27 Apr 2021 01:21:48 +0200
+
+usrmerge (24) unstable; urgency=medium
+
+ * Moved the scripts to /usr/lib/usrmerge/ on request of Ubuntu for better
+ FHS compliance.
+ * README.Debian: removed a reference to /etc/dpkg/dpkg.cfg.d/usrmerge:
+ the file can be ignored since it has been empty or missing since 2016.
+ (Closes: #940077)
+
+ -- Marco d'Itri <md@linux.it> Sat, 16 Jan 2021 06:02:21 +0100
+
+usrmerge (23) unstable; urgency=medium
+
+ * Converted to dh.
+
+ -- Marco d'Itri <md@linux.it> Tue, 03 Sep 2019 02:20:46 +0200
+
+usrmerge (22) unstable; urgency=medium
+
+ * Added a version to the conflict with molly-guard (see #914716).
+ (Closes: #914716)
+
+ -- Marco d'Itri <md@linux.it> Sun, 09 Jun 2019 14:54:21 +0200
+
+usrmerge (21) unstable; urgency=medium
+
+ * Added a version to the conflict with ebtables (see #912046).
+ * Added a versioned conflict with arptables (see #916106).
+
+ -- Marco d'Itri <md@linux.it> Sun, 17 Feb 2019 17:44:25 +0100
+
+usrmerge (20) unstable; urgency=medium
+
+ * Use dh_perl to add a missing dependency on perl. (Closes: #915883)
+ * Documented that packages can be removed while a conversion is in
+ progress. (Closes: #914409)
+ * Added a conflict with molly-guard, again (see #914716).
+ * Added a conflict with ebtables (see #913883).
+
+ -- Marco d'Itri <md@linux.it> Sat, 08 Dec 2018 23:37:38 +0100
+
+usrmerge (19) unstable; urgency=medium
+
+ * Added a version to the conflict with safe-rm (see #759410).
+ * Removed the /etc/dpkg/dpkg.cfg.d/usrmerge file which has been empty
+ since version 11.
+
+ -- Marco d'Itri <md@linux.it> Sun, 30 Sep 2018 19:09:42 +0200
+
+usrmerge (18) unstable; urgency=medium
+
+ * New debconf translation(s): ru. (Closes: #883204)
+
+ -- Marco d'Itri <md@linux.it> Mon, 16 Jul 2018 03:58:40 +0200
+
+usrmerge (17) unstable; urgency=medium
+
+ * Defer the conversion of temporarily-broken symlinks in subdirectories
+ too, to prevent leaving them broken if the program aborts.
+ (Closes: #848504, #871706)
+ * Added again a version to the conflict with molly-guard (see #837928).
+
+ -- Marco d'Itri <md@linux.it> Sun, 05 Nov 2017 19:14:38 +0100
+
+usrmerge (16) unstable; urgency=medium
+
+ * Added a version to the conflict with ksh (see #810158).
+
+ -- Marco d'Itri <md@linux.it> Wed, 31 May 2017 14:37:35 +0200
+
+usrmerge (15) unstable; urgency=medium
+
+ * Updated the version of the conflict with xfslibs-dev, because the
+ package was broken again later (see #766811).
+ * Added a version to the conflict with yp-tools (see #812532).
+
+ -- Marco d'Itri <md@linux.it> Tue, 21 Mar 2017 23:19:50 +0100
+
+usrmerge (14) unstable; urgency=medium
+
+ * Make convert-usrmerge restore the SELinux context for the newly
+ created top level symlinks. (Closes: #850274)
+
+ -- Marco d'Itri <md@linux.it> Mon, 27 Feb 2017 02:03:26 +0100
+
+usrmerge (13) unstable; urgency=medium
+
+ * Do not run convert-usrmerge on NFS systems. (Closes: #842145)
+ * Added a version to the conflict with elvis-tiny (see #813857).
+ * Added a versioned conflict with libjson-c-dev (see #843145).
+
+ -- Marco d'Itri <md@linux.it> Mon, 12 Dec 2016 05:23:20 +0100
+
+usrmerge (12) unstable; urgency=medium
+
+ * Added a conflict with molly-guard. (Closes: #837925)
+ * Updated the versioned conflict with zsh. (Closes: #824205)
+ * New debconf translation(s): pt, de, nl, pt_BR.
+ (Closes: #818636, 818656, 823443, 829342)
+
+ -- Marco d'Itri <md@linux.it> Thu, 29 Sep 2016 18:42:37 +0200
+
+usrmerge (11) unstable; urgency=medium
+
+ * dpkg.cfg: removed libpng12-0 (see #766809).
+ No dpkg.cfg workarounds are used anymore.
+ * After the conversion, use the new convert-etc-shells program to add
+ to /etc/shells /usr-based paths for each shell in /. (Closes: #817119)
+ * New debconf translation(s): fr. (Closes: #818144)
+
+ -- Marco d'Itri <md@linux.it> Tue, 15 Mar 2016 08:42:53 +0100
+
+usrmerge (10) unstable; urgency=medium
+
+ * dpkg.cfg: removed open-iscsi and tcsh (see #810276 and #767927).
+ * Ask with debconf if convert-usrmerge should be run. (Closes: #797417)
+ * New debconf translation(s): it.
+
+ -- Marco d'Itri <md@linux.it> Sun, 28 Feb 2016 02:02:03 +0100
+
+usrmerge (9) unstable; urgency=medium
+
+ * dpkg.cfg: removed acl, policycoreutils and musl-dev (see #767925,
+ #767930 and #766812).
+ * Added conflicts with elvis-tiny and yp-tools (see #813857 and #812532).
+ * Added a version to the conflicts with mksh and zsh (see #807185 and
+ #768079).
+ * Updated the versioned conflict with davfs2, molly-guard and xfslibs-dev
+ (see #812535 and #766811).
+
+ -- Marco d'Itri <md@linux.it> Wed, 10 Feb 2016 04:56:33 +0100
+
+usrmerge (8) unstable; urgency=medium
+
+ * Added Breaks with older cruft-ng and initramfs-tools.
+ (Closes: #810860, #811317)
+ * dpkg.cfg: removed coreutils.
+ * Added a conflict with older open-vm-tools.
+
+ -- Marco d'Itri <md@linux.it> Fri, 22 Jan 2016 07:07:50 +0100
+
+usrmerge (7) unstable; urgency=medium
+
+ * On EBUSY, list the services using ProtectSystem.
+ * dpkg.cfg: removed less and libbrlapi-dev.
+
+ -- Marco d'Itri <md@linux.it> Sat, 16 Jan 2016 03:51:37 +0100
+
+usrmerge (6) unstable; urgency=high
+
+ * Add support for ppc64el to directories_to_merge().
+ * Check for free space in /usr before attempting the conversion.
+ * dpkg.cfg: removed cryptsetup, libusb-0.1-4, xfsdump and xfslibs-dev.
+ * dpkg.cfg: added open-iscsi.
+ * Added a conflict with open-vm-tools.
+ * Added a conflict with older vsearch.
+
+ -- Marco d'Itri <md@linux.it> Sat, 09 Jan 2016 04:33:13 +0100
+
+usrmerge (5) unstable; urgency=medium
+
+ * Create empty multilib and multiarch library directories.
+ (Closes: #810091)
+ * dpkg.cfg: removed davfs2, kbd and libdm0-dev.
+ * Added a conflict with ksh.
+
+ -- Marco d'Itri <md@linux.it> Thu, 07 Jan 2016 02:55:40 +0100
+
+usrmerge (4) unstable; urgency=medium
+
+ * Fixed the conversion of symlinks with the same name in / and /usr,
+ which was broken in many cases and broke libpng12-0. (Closes: #809495)
+ The code still does not handle automatically all possible combinations,
+ but we only need it to work around the few buggy packages with
+ duplicated symlinks.
+ * Preinst: check if an initramfs is being used.
+
+ -- Marco d'Itri <md@linux.it> Mon, 04 Jan 2016 05:12:46 +0100
+
+usrmerge (3) unstable; urgency=medium
+
+ * Added a conflict with mksh (see #807185).
+ * debian/control: add the Homepage field. (Closes: #798056)
+
+ -- Marco d'Itri <md@linux.it> Sun, 27 Dec 2015 14:26:51 +0100
+
+usrmerge (2) unstable; urgency=medium
+
+ * Uploaded to the archive.
+
+ -- Marco d'Itri <md@linux.it> Wed, 05 Aug 2015 05:09:52 +0200
+
+usrmerge (1) UNRELEASED; urgency=medium
+
+ * Initial release.
+ * Added a conflict with zsh (see #768079).
+
+ -- Marco d'Itri <md@linux.it> Tue, 04 Nov 2014 22:42:44 +0100
diff --git a/debian/control b/debian/control
new file mode 100644
index 0000000..e790077
--- /dev/null
+++ b/debian/control
@@ -0,0 +1,118 @@
+Source: usrmerge
+Section: admin
+Priority: optional
+Maintainer: Marco d'Itri <md@linux.it>
+Standards-Version: 4.6.2.0
+Rules-Requires-Root: no
+Build-Depends: debhelper-compat (= 13)
+Vcs-Git: https://salsa.debian.org/md/usrmerge.git
+Vcs-Browser: https://salsa.debian.org/md/usrmerge
+Homepage: https://wiki.debian.org/UsrMerge
+
+Package: usrmerge
+Architecture: all
+Multi-Arch: foreign
+Provides: usr-is-merged
+Depends: ${misc:Depends}, ${perl:Depends}, libfile-find-rule-perl
+Breaks:
+ cruft-ng (<< 0.4.4~),
+ initramfs-tools (<< 0.121~),
+Conflicts:
+ libc-bin (<< 2.36-9~),
+ safe-rm (<< 0.12-6~),
+ ksh (<< 93u+20120801-3.1~),
+ acl (<< 2.2.52-3~),
+ arptables (<< 0.0.4+snapshot20181021-1~),
+ coreutils (<< 8.24-1~),
+ cruft (<< 0.9.44~),
+ cryptsetup (<< 2:1.7.0-1~),
+ davfs2 (<< 1.5.2-1.2~),
+ debianutils (<< 4.5~),
+ dhcpcd (<< 1:5~),
+ ebtables (<< 2.0.10.4+snapshot20181205-1~),
+ elvis-tiny (<< 1.4-24~),
+ kbd (<< 2.0.4-4~),
+ less (<< 481-2~),
+ libbrlapi-dev (<< 5.3.1-1~),
+ libc6 (<< 2.35-4),
+ libc6.1 (<< 2.35-4),
+ libc0.1 (<< 2.35-4),
+ libc0.3 (<< 2.35-4),
+ libdm0-dev,
+ libjson-c-dev (<< 0.12.1-1.1~),
+ libparted1.8-10 (<< 1.8.8.git.2008.03.24-11.2~),
+ libpng12-0 (<< 1.2.54-6~),
+ libusb-0.1-4 (<< 2:0.1.12-28~),
+ lustre-utils (<< 1.8.5+dfsg-3.2~),
+ mksh (<< 52b-1~),
+ molly-guard (<< 0.7.1+exp1~),
+ musl-dev (<< 1.1.9-1.1~),
+ nano (<< 2.3.99pre3-1~),
+ open-iscsi (<< 2.0.873+git0.3b4b4500-13~),
+ open-vm-tools (<< 2:10.0.5-3227872-2~),
+ policycoreutils (<< 2.4-4~),
+ tcsh (<< 6.18.01-4~),
+ vsearch (<< 1.9.5-2~),
+ xfsdump (<< 3.1.6+nmu1~),
+ xfslibs-dev (<< 4.9.0+nmu1~),
+ yp-tools (<< 3.3-5~),
+ zsh (<< 5.2-4~),
+Description: Convert the system to the merged /usr directories scheme
+ This package will automatically convert the system to the merged
+ /usr directory scheme, in which the /{bin,sbin,lib}/ directories are
+ symlinked to their counterparts in /usr/.
+ .
+ There is no automatic method to restore the precedent configuration, so
+ there is no going back once this package has been installed.
+
+Package: usr-is-merged
+Section: oldlibs
+Architecture: all
+Multi-Arch: foreign
+Depends: ${misc:Depends}
+Breaks:
+ cruft-ng (<< 0.4.4~),
+ initramfs-tools (<< 0.121~),
+Conflicts:
+ safe-rm (<< 0.12-6~),
+ ksh (<< 93u+20120801-3.1~),
+ acl (<< 2.2.52-3~),
+ arptables (<< 0.0.4+snapshot20181021-1~),
+ coreutils (<< 8.24-1~),
+ cruft (<< 0.9.44~),
+ cryptsetup (<< 2:1.7.0-1~),
+ davfs2 (<< 1.5.2-1.2~),
+ debianutils (<< 4.5~),
+ dhcpcd (<< 1:5~),
+ ebtables (<< 2.0.10.4+snapshot20181205-1~),
+ elvis-tiny (<< 1.4-24~),
+ kbd (<< 2.0.4-4~),
+ less (<< 481-2~),
+ libbrlapi-dev (<< 5.3.1-1~),
+ libc6 (<< 2.35-4),
+ libc6.1 (<< 2.35-4),
+ libc0.1 (<< 2.35-4),
+ libc0.3 (<< 2.35-4),
+ libdm0-dev,
+ libjson-c-dev (<< 0.12.1-1.1~),
+ libparted1.8-10 (<< 1.8.8.git.2008.03.24-11.2~),
+ libpng12-0 (<< 1.2.54-6~),
+ libusb-0.1-4 (<< 2:0.1.12-28~),
+ lustre-utils (<< 1.8.5+dfsg-3.2~),
+ mksh (<< 52b-1~),
+ molly-guard (<< 0.7.1+exp1~),
+ musl-dev (<< 1.1.9-1.1~),
+ nano (<< 2.3.99pre3-1~),
+ open-iscsi (<< 2.0.873+git0.3b4b4500-13~),
+ open-vm-tools (<< 2:10.0.5-3227872-2~),
+ policycoreutils (<< 2.4-4~),
+ tcsh (<< 6.18.01-4~),
+ vsearch (<< 1.9.5-2~),
+ xfsdump (<< 3.1.6+nmu1~),
+ xfslibs-dev (<< 4.9.0+nmu1~),
+ yp-tools (<< 3.3-5~),
+ zsh (<< 5.2-4~),
+Description: Transitional package to assert a merged-/usr system
+ This package can be successfully installed only on merged-/usr systems.
+ .
+ It can be safely removed once no other package depends on it anymore.
diff --git a/debian/copyright b/debian/copyright
new file mode 100644
index 0000000..0c7dc9c
--- /dev/null
+++ b/debian/copyright
@@ -0,0 +1,23 @@
+Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
+Comment:
+ This package was created by Marco d'Itri <md@linux.it> on
+ Sat Nov 1 04:27:59 CET 2014.
+
+Files: *
+Copyright: 2014-2022 Marco d'Itri <md@linux.it>
+License: GPL-2+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 2 of the License, or
+ (at your option) any later version.
+ .
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+ .
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+Comment:
+ On Debian systems the complete text of the license can be found in
+ /usr/share/common-licenses/GPL-2 .
diff --git a/debian/rules b/debian/rules
new file mode 100755
index 0000000..cbe925d
--- /dev/null
+++ b/debian/rules
@@ -0,0 +1,3 @@
+#!/usr/bin/make -f
+%:
+ dh $@
diff --git a/debian/source/format b/debian/source/format
new file mode 100644
index 0000000..89ae9db
--- /dev/null
+++ b/debian/source/format
@@ -0,0 +1 @@
+3.0 (native)
diff --git a/debian/usr-is-merged.postinst b/debian/usr-is-merged.postinst
new file mode 100644
index 0000000..333f04b
--- /dev/null
+++ b/debian/usr-is-merged.postinst
@@ -0,0 +1,28 @@
+#!/bin/sh
+set -e
+
+cleanup_biarch_dirs() {
+ dpkg --compare-versions "$2" lt "36~" || return 0
+
+ # bootstrapping or earlier conversions may have created empty biarch
+ # directories and links. glibc 2.35-4 or later will create them if needed,
+ # so clean up the unused (and unowned) ones
+ local arch_directories="/lib64 /lib32 /libo32 /libx32"
+ for dir in $arch_directories; do
+ [ -e "$DPKG_ROOT$dir" ] || continue
+ if ! dpkg-query -S $dir >/dev/null 2>&1; then
+ rm -v "$DPKG_ROOT$dir"
+ if [ -e "$DPKG_ROOT/usr$dir" ] && ! dpkg-query -S /usr$dir >/dev/null 2>&1 ; then
+ rmdir --ignore-fail-on-non-empty -v "$DPKG_ROOT/usr$dir"
+ fi
+ fi
+ done
+}
+
+case "$1" in
+ configure)
+ cleanup_biarch_dirs
+ ;;
+esac
+
+#DEBHELPER#
diff --git a/debian/usr-is-merged.preinst b/debian/usr-is-merged.preinst
new file mode 100644
index 0000000..9cb6228
--- /dev/null
+++ b/debian/usr-is-merged.preinst
@@ -0,0 +1,56 @@
+#!/bin/sh -e
+
+is_merged() {
+ local directories="/bin /sbin /lib"
+ for dir in $directories; do
+ [ -e "$DPKG_ROOT$dir" ] || continue
+ [ "$(readlink -f "$DPKG_ROOT$dir")" = "$DPKG_ROOT/usr$dir" ] || return 1
+ done
+
+ # Avoid an exact match, as the target might vary depending on the tool
+ # building the image. For example, systemd-nspawn links /lib64 to
+ # /usr/lib/aarch64-linux-gnu on arm64, while on amd64 debootstrap links it to
+ # /usr/lib64 and doesn't create it at all on arm64.
+ # See: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1019575
+ local arch_directories="/lib64 /lib32 /libo32 /libx32"
+ for dir in $arch_directories; do
+ [ -e "$DPKG_ROOT$dir" ] || continue
+ case "$(readlink -f "$DPKG_ROOT$dir")" in
+ "$DPKG_ROOT/usr/lib"*) ;;
+ *) return 1;;
+ esac
+ done
+
+ return 0
+}
+
+fail_if_unmerged() {
+ if is_merged; then return; fi
+
+ cat << END
+
+
+******************************************************************************
+*
+* The usr-is-merged package cannot be installed because this system does
+* not have a merged /usr.
+*
+* Please install the usrmerge package to convert this system to merged-/usr.
+*
+* For more information please read https://wiki.debian.org/UsrMerge.
+*
+******************************************************************************
+
+
+END
+ exit 1
+}
+
+case "$1" in
+ install|upgrade)
+ fail_if_unmerged
+ ;;
+esac
+
+#DEBHELPER#
+
diff --git a/debian/usrmerge.install b/debian/usrmerge.install
new file mode 100644
index 0000000..3384513
--- /dev/null
+++ b/debian/usrmerge.install
@@ -0,0 +1 @@
+convert-usrmerge convert-etc-shells /usr/lib/usrmerge/
diff --git a/debian/usrmerge.maintscript b/debian/usrmerge.maintscript
new file mode 100644
index 0000000..30f3c48
--- /dev/null
+++ b/debian/usrmerge.maintscript
@@ -0,0 +1 @@
+rm_conffile /etc/dpkg/dpkg.cfg.d/usrmerge 19~ usrmerge
diff --git a/debian/usrmerge.postinst b/debian/usrmerge.postinst
new file mode 100644
index 0000000..4f2482d
--- /dev/null
+++ b/debian/usrmerge.postinst
@@ -0,0 +1,92 @@
+#!/bin/sh
+set -e
+
+is_fs() {
+ local fs_type
+ fs_type="$(stat --file-system --format=%T "$2" 2> /dev/null)"
+
+ if [ "$fs_type" = "$1" ]; then return 0; fi
+ return 1
+}
+
+is_merged() {
+ local directories="/bin /sbin /lib"
+ for dir in $directories; do
+ [ -e "$dir" ] || continue
+ [ "$(readlink -f "$dir")" = "/usr$dir" ] || return 1
+ done
+
+ # Avoid an exact match, as the target might vary depending on the tool
+ # building the image. For example, systemd-nspawn links /lib64 to
+ # /usr/lib/aarch64-linux-gnu on arm64, while on amd64 debootstrap links it to
+ # /usr/lib64 and doesn't create it at all on arm64.
+ # See: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1019575
+ local arch_directories="/lib64 /lib32 /libo32 /libx32"
+ for dir in $arch_directories; do
+ [ -e "$dir" ] || continue
+ case "$(readlink -f "$dir")" in
+ "/usr/lib"*) ;;
+ *) return 1;;
+ esac
+ done
+
+ return 0
+}
+
+maybe_convert() {
+ # do not try to run the program if the system has already been converted
+ if is_merged; then return; fi
+
+ if is_fs nfs / || is_fs nfs /usr; then
+ cat << 'END' >&2
+
+Warning: NFS detected, /usr/lib/usrmerge/convert-usrmerge will not be run
+automatically. See #842145 for details.
+
+END
+ return 1
+ fi
+
+ /usr/lib/usrmerge/convert-usrmerge || return $?
+
+ if which update-shells > /dev/null; then
+ update-shells
+ fi
+ /usr/lib/usrmerge/convert-etc-shells || return $?
+}
+
+cleanup_biarch_dirs() {
+ dpkg --compare-versions "$2" lt "36~" || return 0
+
+ # bootstrapping or earlier conversions may have created empty biarch
+ # directories and links. glibc 2.35-4 or later will create them if needed,
+ # so clean up the unused (and unowned) ones
+ local arch_directories="/lib64 /lib32 /libo32 /libx32"
+ for dir in $arch_directories; do
+ [ -e "$dir" ] || continue
+ if ! dpkg-query -S $dir >/dev/null 2>&1; then
+ rm -v $dir
+ if [ -e /usr$dir ] && ! dpkg-query -S /usr$dir >/dev/null 2>&1 ; then
+ rmdir --ignore-fail-on-non-empty -v /usr$dir
+ fi
+ fi
+ done
+}
+
+case "$1" in
+ configure)
+ # skipping the conversion is not supported anymore
+ if [ -e /etc/unsupported-skip-usrmerge-conversion ] && \
+ grep -q 'this system will not be supported in the future' \
+ /etc/unsupported-skip-usrmerge-conversion; then
+ echo "E: /etc/unsupported-skip-usrmerge-conversion exists." >&2
+ exit 1
+ else
+ maybe_convert "$@" || { echo "E: usrmerge failed." >&2; exit 1; }
+ cleanup_biarch_dirs
+ fi
+ ;;
+esac
+
+#DEBHELPER#
+
diff --git a/debian/usrmerge.preinst b/debian/usrmerge.preinst
new file mode 100644
index 0000000..cc356eb
--- /dev/null
+++ b/debian/usrmerge.preinst
@@ -0,0 +1,42 @@
+#!/bin/sh -e
+
+is_mountpoint() {
+ if mountpoint -q "$1"; then
+ return 0
+ fi
+ return 1 # not a mount point
+}
+
+standalone_usr() {
+ if is_mountpoint /usr; then
+ return 0
+ fi
+ return 1
+}
+
+booted_with_initramfs() {
+ # created by update-initramfs
+ if [ -d /run/initramfs/ ]; then
+ return 1
+ fi
+ return 0
+}
+
+has_initramfs() {
+ standalone_usr || return 0
+ booted_with_initramfs || return 0
+ echo "/usr is a standalone filesystem, this requires using an initramfs."
+ exit 1
+}
+
+case "$1" in
+ install)
+ # check the prerequisites on the first install
+ if [ -z "$2" ]; then
+ has_initramfs
+ fi
+ ;;
+esac
+
+#DEBHELPER#
+