Bug 179766 - [PATCH] sysutils/debootstrap fails on freebsd with --foreign option
Summary: [PATCH] sysutils/debootstrap fails on freebsd with --foreign option
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: Normal Affects Only Me
Assignee: William Grzybowski
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-06-20 13:50 UTC by Roman Naumann
Modified: 2014-08-08 18:38 UTC (History)
3 users (show)

See Also:


Attachments
file.diff (960 bytes, patch)
2013-06-20 13:50 UTC, Roman Naumann
no flags Details | Diff
debootstrap - fix --foreign and add Perl dependency (1.44 KB, patch)
2014-08-07 21:35 UTC, Nikolai Lifanov
lifanov: maintainer-approval+
Details | Diff
debootstrap fixes (1023 bytes, patch)
2014-08-08 00:50 UTC, Nikolai Lifanov
lifanov: maintainer-approval+
Details | Diff
debootstrap fixes (2.19 KB, patch)
2014-08-08 01:02 UTC, Nikolai Lifanov
lifanov: maintainer-approval+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Roman Naumann 2013-06-20 13:50:00 UTC
Using the --foreign option with the debootstrap script should install several architecture specific files into /TARGETDIR/debootstrap, but it does not. The reason is, that the script tries to copy a file called devices.tar.gz from /usr/local/share/debootstrap, which does not exist. Since the script uses "set -e", at this point it silently fails. The next part (chroot into /TARGETDIR and calling /debootstrap/debootstrap --second-stage) FAILS because of missing files. 

Note that while a broken --foreign/--second-stage installation in a chroot itself does not necessarily qualify as a critical bug, currently and unrelated to this report and patch, the 'normal' installation is broken as well right now, so that --foreign/--second-stage installations are the only way to install a debian chroot... Right now, as is in ports, debootstrap is of little use.

Also the fix just removes the line which tries to copy the devices.tar.gz file. This is a freebsd specific patch not made to go upstream. If upstream wants to fix the issue, one would have to find our which architectures besides Linux need devices.tar.gz (hurd?) and wrap the copying in a conditional.

Fix: Apply patch to ports svn checkout (in directory: sysutils/debootstrap).
root$ cd /usr/ports/sysutils/debootstrap
root$ make deinstall reinstall clean


Patch attached with submission follows:
How-To-Repeat: root$ kldload tmpfs
root$ mkdir /debian
root$ debootstrap --foreign wheezy http://cdn.debian.net/debian
root$ echo $? # note the erro code 1 !
root$ mount -t devfs devfs /debian/dev
root$ mount -t linprocfs linprocfs /debian/proc
root$ mount -t linsysfs linsysfs /debian/sys
root$ chroot /debian /bin/bash
root$ /debootstrap/debootstrap --second-stage # fails due to missing files
Comment 1 Edwin Groothuis freebsd_committer freebsd_triage 2013-06-23 20:30:09 UTC
Responsible Changed
From-To: freebsd-ports-bugs->mm

Over to maintainer (via the GNATS Auto Assign Tool)
Comment 2 Nikolai Lifanov 2014-08-07 21:35:14 UTC
Created attachment 145489 [details]
debootstrap - fix --foreign and add Perl dependency

Please use this patch instead.
Comment 3 Nikolai Lifanov 2014-08-07 21:38:30 UTC
I'm the maintainer for sysutils/debootstrap now.

Please use this patch: it fixes --foreign as proposed by the originator, rebased on the latest port version, and adds an easy to miss Perl runtime dependency (debootstrap uses Perl to process package lists) to spare an extra revision bump.

I can't reproduce the native bootstrap not working. Can you try it again with the latest port version or provide steps to reproduce?
Comment 4 Nikolai Lifanov 2014-08-08 00:50:23 UTC
Created attachment 145496 [details]
debootstrap fixes

Please use this patch instead. In addition to the previous one, it fixes HOST_ARCH detection if dpkg is installed.

This was pointed out by Andrzej Tobola in a private email.
Comment 5 Nikolai Lifanov 2014-08-08 01:02:21 UTC
Created attachment 145497 [details]
debootstrap fixes

On a second thought, since some scripts require dpkg, just depend on it.
sysutils/debootstrap should have depended on it all along.

So,  issues addressed so far:

o Add a runtime dependency on Perl
o Fix --foreign bootstrap
o Fix HOST_ARCH detection with dpkg
o Add a runtime dependency on dpkg
Comment 6 commit-hook freebsd_committer freebsd_triage 2014-08-08 01:27:08 UTC
A commit references this bug:

Author: wg
Date: Fri Aug  8 01:26:32 UTC 2014
New revision: 364336
URL: http://svnweb.freebsd.org/changeset/ports/364336

Log:
  sysutils/debootstrap: runtime fixes

   - Add a runtime dependency on Perl
   - Fix --foreign bootstrap
   - Fix HOST_ARCH detection with dpkg
   - Add a runtime dependency on dpkg

  PR:		179766
  Submitted by:	maintainer

Changes:
  head/sysutils/debootstrap/Makefile
  head/sysutils/debootstrap/files/patch-debootstrap
Comment 7 Andrzej Toboła 2014-08-08 15:41:20 UTC
Still two minor corrections are necessary for a simple usage test case:
  
   sudo debootstrap wheezy /tmp/debian 

and not anylyzing it deeply:

% diff debootstrap*
402c402
<       HOST_ARCH=`/usr/bin/dpkg --print-architecture`
---
>       HOST_ARCH=k`/usr/local/bin/dpkg --print-architecture`   # freebsd -> kfreebsd

% diff /usr/local/share/debootstrap/functions*
83c83
<               wget $QSWITCH "$@"
---
>               wget --no-check-certificate $QSWITCH "$@"

-a
Comment 8 Andrzej Toboła 2014-08-08 16:00:46 UTC
Are a new Ubuntu wariants expected to work ?

% sudo debootstrap trusty /tmp/trusty
I: Keyring file not available at /usr/share/keyrings/ubuntu-archive-keyring.gpg; switching to https mirror https://mirrors.kernel.org/debian
I: Retrieving Release
E: Failed getting release file https://mirrors.kernel.org/debian/dists/trusty/Release
(1)

% sudo debootstrap utopic /tmp/trusty
I: Keyring file not available at /usr/share/keyrings/ubuntu-archive-keyring.gpg; switching to https mirror https://mirrors.kernel.org/debian
I: Retrieving Release
E: Failed getting release file https://mirrors.kernel.org/debian/dists/utopic/Release
(1)

-a
Comment 9 Nikolai Lifanov 2014-08-08 18:26:48 UTC
I'd rather not force wget to ignore certificates.
The user should teach wget to validate certificates or use http:// URIs.
Debootstrap program prefers https:// on default and expects wget to be configured to work with it.

To debootstrap wheezy (native kfreebsd, works well):

# debootstrap wheezy ./wheezy http://ftp.us.debian.org/debian

Ubuntu doesn't have a kfreebsd version (and doesn't live on Debian mirrors). You can do the first stage of a foreign bootstrap for this, but you will need to boot an actual Linux kernel to finish the installation. You won't be able to use the Linux emulation layer to finish something like this:

# debootstrap --foreign --arch=i386 trusty ./trusty http://archive.ubuntu.com/ubuntu
Comment 10 Nikolai Lifanov 2014-08-08 18:38:47 UTC
To configure wget to handle https://, first install ca_root_nss package, and then add ca_certificate=/usr/local/share/certs/ca-root-nss.crt to your .wgetrc.