Bug 278273 - DVD release for ARM64 contains AMD64 packages
Summary: DVD release for ARM64 contains AMD64 packages
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: arm (show other bugs)
Version: CURRENT
Hardware: arm64 Any
: --- Affects Many People
Assignee: FreeBSD Release Engineering
URL: https://reviews.freebsd.org/D44749
Keywords:
Depends on:
Blocks:
 
Reported: 2024-04-09 09:21 UTC by gatekeeper
Modified: 2024-04-24 05:16 UTC (History)
5 users (show)

See Also:


Attachments
pkg_rootdir.patch (567 bytes, patch)
2024-04-09 22:59 UTC, John Baldwin
no flags Details | Diff
pkg_rootdir.patch (865 bytes, patch)
2024-04-09 23:46 UTC, John Baldwin
no flags Details | Diff
pkg_rootdir.patch (1.85 KB, patch)
2024-04-10 23:31 UTC, John Baldwin
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description gatekeeper 2024-04-09 09:21:09 UTC
Hi. I am not sure if this is the right place to post this issue.
If not, please advice where I can raise awareness for the following issue:

The packages directory in the DVD disk image for ARM64 contains wrongfully only AMD64 binaries.
E.g. in the directory packages/FreeBSD14:amd64/All in FreeBSD-14.0-RELEASE-arm64-aarch64-dvd1.iso all PKG files are for the AMD64 architecture, while the distribution is ARM64. The name of the directory should be FreeBSD:14:aarch64, imho, and only contain ARM binaries...

Thanks!
Comment 1 Mark Linimon freebsd_committer freebsd_triage 2024-04-09 10:48:19 UTC
^Triage: reassign to Release Engineering.
Comment 2 John Baldwin freebsd_committer freebsd_triage 2024-04-09 22:58:37 UTC
Jessica Clarke noticed that pkg-stage.sh just runs 'pkg config ABI' on the host system to determine the packages to download.  This means it always downloads the packages for the running host (both version and architecture), not the target release being built.
Comment 3 John Baldwin freebsd_committer freebsd_triage 2024-04-09 22:59:44 UTC
Created attachment 249869 [details]
pkg_rootdir.patch

Untested possible fix: use --rootdir to point pkg at the installed world in dvd/ to determine the ABI of the package set to fetch.
Comment 4 John Baldwin freebsd_committer freebsd_triage 2024-04-09 23:46:33 UTC
Created attachment 249870 [details]
pkg_rootdir.patch

Add argument to all pkg invocations so the fetch fetches the right thing.
Comment 5 John Baldwin freebsd_committer freebsd_triage 2024-04-09 23:47:48 UTC
Another option might be to use -o ABI_FILE=dvd/bin/sh instead of --rootdir.  One question is where the database updated by 'pkg update' should really live.
Comment 6 John Baldwin freebsd_committer freebsd_triage 2024-04-10 23:31:22 UTC
Created attachment 249887 [details]
pkg_rootdir.patch

So adding --rootdir does have some effects, namely the -o argument to fetch has to be relative to --rootdir, but this version I've tested locally to build a FreeBSD 15 aarch64 release on an FreeBSD 14 host and it did fetch 15.x aarch64 packages and store them in the dvd output directory.  I got an error trying to build the actual dvd.iso, but it got past the packages part:


cp /usr/home/john/work/freebsd/main/release/scripts/FreeBSD_install_cdrom.conf  /usr/obj/usr/home/john/work/freebsd/main/arm64.aarch64/release/dvd/packages/repos/
touch pkg-stage
cd dvd && sh /usr/home/john/work/freebsd/main/release/arm64/mkisoimages.sh -b 15_0_CURRENT_aarch64_DVD ../dvd1.iso . 
Creating `/tmp/efiboot.phxRxv'
/tmp/efiboot.phxRxv: 4039 sectors in 4039 FAT12 clusters (512 bytes/cluster)
BytesPerSec=512 SecPerClust=1 ResSectors=1 FATs=2 RootDirEnts=512 Sectors=4096 Media=0xf0 FATsecs=12 SecPerTrack=63 Heads=255 HiddenSecs=0
Populating `/tmp/efiboot.phxRxv'
Image `/tmp/efiboot.phxRxv' complete
makefs: fseeko: No space left on device
*** Error code 1

> ll /usr/obj/usr/home/john/work/freebsd/main/arm64.aarch64/release/dvd/packages/
total 10
drwxr-xr-x  4 root wheel  9 Apr 10 16:26 FreeBSD:15:aarch64
lrwxr-xr-x  1 root wheel 18 Apr 10 16:24 freebsd:15:aarch64:64 -> FreeBSD:15:aarch64
drwxr-xr-x  2 root wheel  3 Apr 10 16:26 repos
Comment 7 commit-hook freebsd_committer freebsd_triage 2024-04-14 23:46:43 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=ea2663040d524efd84b12edcbe83884437fdceea

commit ea2663040d524efd84b12edcbe83884437fdceea
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2024-04-13 21:16:01 +0000
Commit:     Colin Percival <cperciva@FreeBSD.org>
CommitDate: 2024-04-14 23:45:40 +0000

    release: Use the ABI of the target release to fetch packages

    - Point --rootdir at the installed destdir in the dvd tree.  This
      causes pkg to determine the ABI from the installed destdir instead
      of the host's binaries.  Previously the result was that packages
      for the host's ABI were always downloaded breaking cross-releases
      (e.g. arm64 releases built on an amd64 host included amd64
      packages on the DVD ISO image rather than arm64 packages).  This
      also handles version mismatches, and I tested this by cross-building
      a 15.x arm64 release on a 14.x amd64 host.

    - As a result, pkg now does a chdir(3) to the rootdir before running,
      so the -o argument to fetch needs to be updated to be relative to
      rootdir instead of the CWD as make runs.

    - Add a new ROOTDIR variable to limit references to "dvd" to one
      place.  Ideally ROOTDIR would be an argument to this script so
      that it didn't really know about the dvd layout at all.

    - While here, simplify creation of symlinks by just using a longer
      path to the link name instead of using 'cd' in the shell before
      invoking ln(1).  Also use ln -sf to create the pkg.pkg symlink
      rather than rm + ln.

    PR:             278273
    Reported by:    gatekeeper <tiago.gasiba@gmail.com>
    Reviewed by:    imp, delphij
    MFC after:      3 days
    Differential Revision:  https://reviews.freebsd.org/D44749

 release/scripts/pkg-stage.sh | 23 +++++++++++------------
 1 file changed, 11 insertions(+), 12 deletions(-)
Comment 8 commit-hook freebsd_committer freebsd_triage 2024-04-17 05:45:00 UTC
A commit in branch stable/14 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=70dcf0608cfc767321b16509f615c5dddb9378af

commit 70dcf0608cfc767321b16509f615c5dddb9378af
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2024-04-13 21:16:01 +0000
Commit:     Colin Percival <cperciva@FreeBSD.org>
CommitDate: 2024-04-17 05:43:27 +0000

    release: Use the ABI of the target release to fetch packages

    - Point --rootdir at the installed destdir in the dvd tree.  This
      causes pkg to determine the ABI from the installed destdir instead
      of the host's binaries.  Previously the result was that packages
      for the host's ABI were always downloaded breaking cross-releases
      (e.g. arm64 releases built on an amd64 host included amd64
      packages on the DVD ISO image rather than arm64 packages).  This
      also handles version mismatches, and I tested this by cross-building
      a 15.x arm64 release on a 14.x amd64 host.

    - As a result, pkg now does a chdir(3) to the rootdir before running,
      so the -o argument to fetch needs to be updated to be relative to
      rootdir instead of the CWD as make runs.

    - Add a new ROOTDIR variable to limit references to "dvd" to one
      place.  Ideally ROOTDIR would be an argument to this script so
      that it didn't really know about the dvd layout at all.

    - While here, simplify creation of symlinks by just using a longer
      path to the link name instead of using 'cd' in the shell before
      invoking ln(1).  Also use ln -sf to create the pkg.pkg symlink
      rather than rm + ln.

    PR:             278273
    Reported by:    gatekeeper <tiago.gasiba@gmail.com>
    Reviewed by:    imp, delphij
    MFC after:      3 days
    Differential Revision:  https://reviews.freebsd.org/D44749

    (cherry picked from commit ea2663040d524efd84b12edcbe83884437fdceea)

 release/scripts/pkg-stage.sh | 23 +++++++++++------------
 1 file changed, 11 insertions(+), 12 deletions(-)
Comment 9 gatekeeper 2024-04-18 19:57:13 UTC
Hi.
First of all, thanks for the awesome work you put into fixing the problem that I reported.

Now, sorry if this is a dumb question... :-)
I see that there is a commit to the stable/14 branch that references this bug... Does it mean that this bug report can/should be closed? Should I do it?

Cheers.
Comment 10 Colin Percival freebsd_committer freebsd_triage 2024-04-18 21:43:15 UTC
I'm planning on merging this to stable/13 next week, at which point I'll close this PR (unless I forget, which is always possible).
Comment 11 commit-hook freebsd_committer freebsd_triage 2024-04-24 05:07:23 UTC
A commit in branch stable/13 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=835b1bd4045a7ef56f58868fc150d099b2ce135b

commit 835b1bd4045a7ef56f58868fc150d099b2ce135b
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2024-04-13 21:16:01 +0000
Commit:     Colin Percival <cperciva@FreeBSD.org>
CommitDate: 2024-04-24 05:04:44 +0000

    release: Use the ABI of the target release to fetch packages

    - Point --rootdir at the installed destdir in the dvd tree.  This
      causes pkg to determine the ABI from the installed destdir instead
      of the host's binaries.  Previously the result was that packages
      for the host's ABI were always downloaded breaking cross-releases
      (e.g. arm64 releases built on an amd64 host included amd64
      packages on the DVD ISO image rather than arm64 packages).  This
      also handles version mismatches, and I tested this by cross-building
      a 15.x arm64 release on a 14.x amd64 host.

    - As a result, pkg now does a chdir(3) to the rootdir before running,
      so the -o argument to fetch needs to be updated to be relative to
      rootdir instead of the CWD as make runs.

    - Add a new ROOTDIR variable to limit references to "dvd" to one
      place.  Ideally ROOTDIR would be an argument to this script so
      that it didn't really know about the dvd layout at all.

    - While here, simplify creation of symlinks by just using a longer
      path to the link name instead of using 'cd' in the shell before
      invoking ln(1).  Also use ln -sf to create the pkg.pkg symlink
      rather than rm + ln.

    PR:             278273
    Reported by:    gatekeeper <tiago.gasiba@gmail.com>
    Reviewed by:    imp, delphij
    MFC after:      3 days
    Differential Revision:  https://reviews.freebsd.org/D44749

    (cherry picked from commit ea2663040d524efd84b12edcbe83884437fdceea)

 release/scripts/pkg-stage.sh | 23 +++++++++++------------
 1 file changed, 11 insertions(+), 12 deletions(-)
Comment 12 Colin Percival freebsd_committer freebsd_triage 2024-04-24 05:16:14 UTC
Should be fixed now on all supported branches.  Please take a look at 14.1-BETA1 and 13.4-BETA1 when those happen to make sure everything is working properly. :-)