[distri] Re: Building distri packages on distri

  • From: Michael Stapelberg <michael+distri@xxxxxxxxxxxxx>
  • To: distri@xxxxxxxxxxxxx
  • Date: Sun, 19 Sep 2021 16:31:00 +0200

Hey Jan

On Sun, 19 Sept 2021 at 13:52, Jan Bölsche <jan@xxxxxxxxxxxx> wrote:

Hi Michael,

thanks, that got me started!

To better understand what is going on, I looped over (with
/root/distri/pkgs/bash as cwd)
   distri build
   see form the error message what package is missing
   distri install $MISSINGPKG
   cp --link /roimg/$MISSINGPKG* ~/distri/_build/distri/pkg

I was surprised by the fact that bash wouldn't build without mpc .. (the
music player daemon client). The only dependency that is listed in
bash/build.textproto is ncurses (which in turn lists one runtime_dep
(glibc) in /roimg/ncurses....meta.textproto)


The mpc package is the multiprecision floating point library (
https://directory.fsf.org/wiki/Mpc),
which has nothing to do with the music player client, except for a similar
name :)
mpc is required by gcc, hence it’s part of a bash build.



Is there a way to automatically discover needed build dependencies, other
than repeatedly trying `distri build`?


Well, `distri batch` builds multiple packages in correct order, thereby
fulfilling all dependencies.
The only downside is that it might attempt to build much more than you are
looking for, depending on what’s in your $DISTRIROOT/_build.
If you clone the entire mirror, it shouldn’t build anything, and if you
then change something, it should build all that’s necessary.


Just for my better understanding: Are build dependencies supposed to be
listed in build.textproto in their entirety? (not including transitive deps
I suppose)


Correct, build deps are listed in build.textproto, and there is no need to
list the entire transitive closure (only direct dependencies should be
listed).


Or do we assume a set of packages to be present on all dev machines (like
the package group "base-devel" on Arch)


Depending on which builder is used for the package, that builder determines
which dependencies are always there, and deps specified in the package’s
build.textproto take care of the rest.

In this case, the C builder pulls in the packages defined here:
https://github.com/distr1/distri/blob/1c7fc9ad7e93e1de8fb85d5c4f0ca59f1f8c15e2/internal/build/build.go#L965



If build deps are supposed to be listed in build.textproto: is there a way
to declare them as build deps explicitly? (or do all listed deps in
build.textproto count as build deps, because runtime_deps are discovered
automatically?)


Correct, all deps are build deps. There is a TODO to rename the dep field
to build_dep for clarity:
https://github.com/distr1/distri/blob/1c7fc9ad7e93e1de8fb85d5c4f0ca59f1f8c15e2/pb/build.proto#L234



I could work on a script that generates a patch to add missing build deps
for all build.textproto (by using the loop approach described above, but
automated) if that makes sense at all. (which I am not sure of). It could
help uncover some surprising things like bash not building without mpc
installed, at the very least.


No need, but thank you :)
distri builds are done hermetically in a container, so deps can’t be
missing.
I think it’s possible for deps to be under-specified (e.g. a package is
already present due to a transitive dependency),
but I’m not sure we need to fix that.

The other way around should be possible, by the way: when making all
packages available during the build,
we should be able to look at which packages were accessed and thereby
declare an approximation of the build dependencies.
I haven’t had time to explore this idea in more detail, though.

Best regards
Michael



Thanks for your time and quick answer!
Jan


On Sun, Sep 19, 2021 at 10:24 AM Michael Stapelberg <
michael+distri@xxxxxxxxxxxxx> wrote:

Hey Jan

Thanks for your interest!

You have multiple options to get the build to work.

The quickest option if you just want to build OpenSSH
is to install the build dependencies in your running distri instance,
and then hardlink the package images into your
$DISTRIROOT/_build/distri/pkg/, for example:

distri0# distri install git bzip2 patch diffutils file make musl strace
gcc binutils zlib openssl pam xauth bash
distri0# cp --link /roimg/* ~/distri/_build/distri/pkg/
distri0# distri build

The other option, to build without having to change your running instance
(and only work within $DISTRIROOT),
is to download all distri packages from our mirror server, see:
https://github.com/distr1/distri/issues/84#issuecomment-744575431

If you’re curious about prior discussion, see

https://www.freelists.org/post/distri/Setting-up-development-environment-for-packaging,1

We should really make distri build pull these images by default, so that
builds work out of the box :)

Best regards
Michael


On Sun, 19 Sept 2021 at 09:43, Jan Bölsche <jan@xxxxxxxxxxxx> wrote:

Hey!

I am excited about distri's approach to package management and
system-building. I'd like to take part in exploring the problem space,
especially the aspect of peer-to-peer package installation, peer-to-peer
system updates and reproducible system image building.

I did my first stumbling around in the world of distri by downloading
the supersilverhaze image, and booting it from USB. I then:

distri0# source <(distri env)
distri0# git clone https://github.com/distr1/distri $DISTRIROOT

Then I tried, just for fun, to build openssh:

distri0# cd $DISTRIROOT/pkgs/openssh
distri0# distri build
2021/09/18 15:16:00 building openssh-amd64-8.2p1-11
2021/09/18 15:16:00 downloading
https://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-8.2p1.tar.gz
to openssh-8.2p1.tar.gz
2021/09/18 15:16:04 verifying openssh-8.2p1.tar.gz
patching file sshd_config
2021/09/18 15:16:04 cherry picked config.patch
patching file ssh.service
2021/09/18 15:16:04 cherry picked service.patch
build: build: builddeps: glob: glob1(bash-amd64): package "bash" not
found (pattern /root/distri/_build/distri/pkg/bash-amd64-*.meta.textproto)

Since it is missing metadata for bash, I tried `distri build` in
pkgs/bash, but that fails with the same error message. Seems I can't build
bash because I haven't build bash ...?

I am probably missing some bootstrapping step. Can you give me a quick
hint?

Thanks!
Jan



Other related posts: