distr1 / distri

a Linux distribution to research fast package management
https://distr1.org
Other
532 stars 28 forks source link

Can't make image (Re-reading the partition table failed) #84

Open Cretezy opened 3 years ago

Cretezy commented 3 years ago

Trying to build a distri image from a fresh clone.

Steps:

Output:

➜  distri git:(master) make image
DISTRIROOT=$PWD distri pack -diskimg=/tmp/distri-disk.img -base=base-x11 
2020/11/25 12:36:38 next free: 19
Checking that no-one is using this disk right now ... OK

Disk /dev/loop19: 8 GiB, 8589934592 bytes, 16777216 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

>>> Script header accepted.
>>> Created a new GPT disklabel (GUID: 39BE7055-3540-7044-98B7-F8FB008E3C2F).
/dev/loop19p1: Created a new partition 1 of type 'EFI System' and of size 550 MiB.
/dev/loop19p2: Created a new partition 2 of type 'BIOS boot' and of size 1 MiB.
/dev/loop19p3: Created a new partition 3 of type 'Linux filesystem' and of size 250 MiB.
/dev/loop19p4: Created a new partition 4 of type 'Linux filesystem' and of size 7.2 GiB.
/dev/loop19p5: Done.

New situation:
Disklabel type: gpt
Disk identifier: 39BE7055-3540-7044-98B7-F8FB008E3C2F

Device          Start      End  Sectors  Size Type
/dev/loop19p1    2048  1128447  1126400  550M EFI System
/dev/loop19p2 1128448  1130495     2048    1M BIOS boot
/dev/loop19p3 1130496  1642495   512000  250M Linux filesystem
/dev/loop19p4 1642496 16777182 15134687  7.2G Linux filesystem

The partition table has been altered.
Calling ioctl() to re-read partition table.
Re-reading the partition table failed.: Invalid argument
The kernel still uses the old table. The new table will be used at the next reboot or after you run partprobe(8) or partx(8).
Syncing disks.
2020/11/25 12:36:39 base: "/dev/loop19"
mkfs.fat 4.1 (2017-01-24)
mke2fs 1.45.6 (20-Mar-2020)
Discarding device blocks: done                            
Creating filesystem with 64000 4k blocks and 64000 inodes
Filesystem UUID: dc5e7aed-b9ad-40d9-b6e8-911a54a3cad1
Superblock backups stored on blocks: 
    32768

Allocating group tables: done                            
Writing inode tables: done                            
Writing superblocks and filesystem accounting information: done

mke2fs 1.45.6 (20-Mar-2020)
Discarding device blocks: done                            
Creating filesystem with 1891835 4k blocks and 473280 inodes
Filesystem UUID: 9fc1cbac-80c4-4e4e-9975-d9433a098308
Superblock backups stored on blocks: 
    32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: done 

2020/11/25 12:36:39 not updating FUSE daemon: readlink /mnt/ro/ctl: no such file or directory
2020/11/25 12:36:39 done, 0.00 MB/s (0 bytes in 73.536µs)
2020/11/25 12:36:39 scanPackages in 37.575µs
chroot: failed to run command ‘/ro/bin/systemd-firstboot’: No such file or directory
2020/11/25 12:36:39 [sudo losetup -d /dev/loop19]
pack: writeDiskImg: [unshare --user --map-root-user --mount -- chroot /mnt /ro/bin/systemd-firstboot --hostname=distri0 --root-password=peace --copy-timezone --copy-locale --setup-machine-id]: exit status 127

make: *** [Makefile:109: image] Error 1

I could not find any build instructions anywhere. This is definitely something that should be written.

stapelberg commented 3 years ago

I don’t think the partition table error message is the problem.

Rather, you don’t have the systemd-firstboot program, presumably because you have no distri packages in your build directory yet. You’ll need to download the packages (or at least base packages) of a distri release.

Maybe https://www.freelists.org/post/distri/Setting-up-development-environment-for-packaging,1 provides some useful hints.

I can follow up with a more detailed explanation / document when time permits, in case you can’t get it fixed yourself.

Cretezy commented 3 years ago

@stapelberg I couldn't really extract any information from the provided link.

I'm a little confused with what you mean by the distri packages in my build directory. Which packages are those, and where I can get them? I'm assuming those are built packages.

Would it be easier to use the Docker image to build distri itself?

Cretezy commented 3 years ago

As an extra note, I've very interested in the ideas (I was planning on making my own distribution with a lot of the same ideas like images for packages, read-only packages, and shared directories).

If I can get distri working for myself, I'd likely start contributing and trying to make it into a semi-useful distribution. I think there's a lot of potential in these ideas!

stapelberg commented 3 years ago

Would it be easier to use the Docker image to build distri itself?

Yes. Here’s an example session showing you how to rebuild an individual package in docker:

% docker run --privileged --entrypoint /entrypoint -t -i -e TERM=$TERM distr1/distri:supersilverhaze
# mkdir /root
# cd /root
# distri install git bzip2 patch diffutils file make musl strace gcc binutils i3lock
# git clone https://github.com/distr1/distri

# mkdir -p ~/distri/_build/distri/pkg/
# cp --link /roimg/* ~/distri/_build/distri/pkg/

# distri build -pkg=i3lock

I haven’t tried building all of distri in docker, so perhaps there are other stumbling blocks. But this should illustrate which files need to be where.


When building outside of docker, the steps are similar, but instead of just installing+copying select packages from /roimg, you’ll need to download them from our mirror. I recommend downloading all packages (7 GB download!) instead of just the ones you need, because it’s simpler:

~/distri/_build/distri/pkg master % wget --recursive --no-parent -nH -e robots=off --cut-dirs=3 --reject="*.zst" --reject="*.gz" https://repo.distr1.org/distri/supersilverhaze/pkg/
~/distri/_build/distri/pkg master % for f in *-amd64.meta.textproto; do ln -sf $(basename $f .meta.textproto)-*.meta.textproto $f; done

The second step is to restore the symlinks which are turned into regular files when downloading with wget.

Medium term, we should automatically fetch the required packages when building. We already have most of the features needed for this, just not arranged in the correct way :)