Git Product home page Git Product logo

bootstrap's Introduction

bootstrapping pacman for Arch Mac

To correctly kickstart pacman with proper references to dynamic libraries, three stages are needed.

Indeed there's this macOS binary behaviour that makes it store absolute paths to dynamic libraries. Therefore if we stopped at the second stage, some references to the first stage would be kept.

Stage 1: set the ladder up

caffeinate ./bootstrap stage1

Make pacman (which has makepkg) and its build and runtime dependencies from source. This is ignoring /usr/local, thus third-party user-installed binaries, by resetting PATH to a very basic value.

Prefix is set to stage1, so that make install proceeds into an isolated directory. The installation is raw and unmanaged, pacman is not involved.

Here we also configure makepkg to build packages targeting installation into /opt/arch, with proper flags and arch for the platform.

Stage 2: climb the ladder

caffeinate ./bootstrap stage2

We build a minimal selection of packages from mini. The PKGBUILDs are intentionally minimalistic. The build order is hardcoded because of circular dependencies.

stage1/etc/makepkg.conf is copied to stage2 and altered to store source and binary packages in stage2/{packages,srcpackages}.

Once built, each package is installed, progressively populating /opt/arch. Because of logical circular dependencies, makepkg and pacman are run with --nodeps. The circular dependency is logical, but the early packages logically depending on later ones will be built against - and ultimately reference - stage1. This is why we need stage3.

Stage 3: cut the branch we were sitting on

caffeinate ./bootstrap stage3

The mini packages of stage2 get rebuilt, while stage1 is hidden.

/opt/arch/etc/makepkg.conf is copied to stage3 and altered to store source and binary packages in stage3/{packages,srcpackages}.

At this stage we can start to notice some effects of dependencies on the process, as already installed packages will get reinstalled:

  • xz depends on gettext (libintl), thus when xz will fail miserably midway when reinstalling gettext
  • bash gets regularly run by pacman at various stages, and depends on readline and gettext, which causes similar troubles when upgrading these packages

Therefore:

  • bash gets statically built with its own vendored readline and libintl
  • xz should be built statically as well, but it's not as easy, therefore another default compression format than xz is used

Stage 4: build from a repo

That's it. pacman and makepkg are bootstrapped and ready to cleanly build packages from a repo's PKGBUILDs selection.

Such a repo could probably be used at stage3 instead of mini, but the goal was to minimise variability in time. I guess a git commit cold be pinned or something, but then bootstrapping still ends up depending on an external that requires the bootstrapping step, e.g starting a new arch /cough/M1/cough/ would mean altering an external repo. Given the small number of packages it's simpler this way, and that way the bootstrap step is entirely self-contained.

bootstrap's People

Contributors

lloeki avatar

Stargazers

Oleg Utkin avatar justthefracts avatar  avatar

Watchers

James Cloos avatar

Forkers

nanoant

bootstrap's Issues

Some coreutils e.g. md5sum or shaXYZsum necessary for makepkg are missing

makepkg relies md5sum and shaXYZsum which come with coreutils Arch Linux package. macOS does not have this, but it has md5 and shasum commands.

I can only suspect you have them on your system coming from somewhere. Right?

What if we have created wrappers for these commands e.g.:

md5sum

#!/bin/bash
exec /sbin/md5 -r "$@"

sha1sum (and same for 224, 256, 384, 512)

#!/bin/bash
exec /sbin/shasum -a 1 "$@"

And add them to some extra coreutils-wrappers or coreutils-macos-wrappers or whatever name that fits and make this a dependency for pacman on Arch Mac?

Bootstrap on Apple Silicon M1 arm64

fakeroot fails to build because of a deprecation on x86_64 coming in full effect on arm64.

Skipping fakeroot, the remainder is building fine, but fakeroot is a runtime requirement for makepkg and stage 2.

gcc -DHAVE_CONFIG_H -I.     -g -O2 -c -o faked.o faked.c
In file included from faked.c:91:
./communicate.h:54:32: warning: extra tokens at end of #ifndef directive [-Wextra-tokens]
# ifndef MAC_OS_X_VERSION_10_5 1050
                               ^
                               //
./communicate.h:57:32: warning: extra tokens at end of #ifndef directive [-Wextra-tokens]
# ifndef MAC_OS_X_VERSION_10_6 1060
                               ^
                               //
In file included from faked.c:91:
In file included from ./communicate.h:84:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sys/types.h:75:
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sys/cdefs.h:555:8: error: "Can't define _DARWIN_NO_64_BIT_INODE when only 64-bit inodes are available."
#      error "Can't define _DARWIN_NO_64_BIT_INODE when only 64-bit inodes are available."
       ^
In file included from faked.c:91:
In file included from ./communicate.h:164:
./message.h:32:10: warning: 'htonll' macro redefined [-Wmacro-redefined]
# define htonll(n)  (n)
         ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sys/_endian.h:141:9: note: previous definition is here
#define htonll(x)       __DARWIN_OSSwapInt64(x)
        ^
In file included from faked.c:91:
In file included from ./communicate.h:164:
./message.h:33:10: warning: 'ntohll' macro redefined [-Wmacro-redefined]
# define ntohll(n)  (n)
         ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sys/_endian.h:140:9: note: previous definition is here
#define ntohll(x)       __DARWIN_OSSwapInt64(x)
        ^
In file included from faked.c:91:
./communicate.h:208:38: warning: declaration of 'struct stat64' will not be visible outside of this function [-Wvisibility]
extern void send_stat64(const struct stat64 *st, func_id_t f);
                                     ^
./communicate.h:209:36: warning: declaration of 'struct stat64' will not be visible outside of this function [-Wvisibility]
extern void send_get_stat64(struct stat64 *buf);
                                   ^
./communicate.h:210:37: warning: declaration of 'struct stat64' will not be visible outside of this function [-Wvisibility]
extern void send_get_xattr64(struct stat64 *st, xattr_args *xattr);
                                    ^
./communicate.h:216:33: warning: declaration of 'struct stat64' will not be visible outside of this function [-Wvisibility]
extern void stat64from32(struct stat64 *s64, const struct stat *s32);
                                ^
./communicate.h:217:57: warning: declaration of 'struct stat64' will not be visible outside of this function [-Wvisibility]
extern void stat32from64(struct stat *s32, const struct stat64 *s64);
                                                        ^
faked.c:790:47: warning: logical not is only applied to the left hand side of this bitwise operator [-Wlogical-not-parentheses]
        ((buf->st.mode&S_IFMT) != S_IFREG || (!st->mode&(S_IFBLK|S_IFCHR)))) {
                                              ^        ~
faked.c:790:47: note: add parentheses after the '!' to evaluate the bitwise operator first
        ((buf->st.mode&S_IFMT) != S_IFREG || (!st->mode&(S_IFBLK|S_IFCHR)))) {
                                              ^
                                               (                         )
faked.c:790:47: note: add parentheses around left hand side expression to silence this warning
        ((buf->st.mode&S_IFMT) != S_IFREG || (!st->mode&(S_IFBLK|S_IFCHR)))) {
                                              ^
                                              (        )
faked.c:1081:82: warning: format specifies type 'long' but the argument has type 'int64_t' (aka 'long long') [-Wformat]
      fprintf(stderr,"FAKEROOT: r=%i, received message type=%li, message=%i\n",r,buf.mtype,buf.id);
                                                            ~~~                  ^~~~~~~~~
                                                            %lli
11 warnings and 1 error generated.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.