def build(build): # TODO: # - Include the configuration in /boot/ # - Symlink or rename vmlinuz to vmlinuz-X.Y.Z. packages = basic.build( configure=lambda: make('olddefconfig'), compile=make, install=install_linux, deplinker=None, ) packages['kernel/linux'].drain( 'usr/lib/*', 'boot/*', ) # Remove useless files with stdlib.pushd(packages['kernel/linux'].wrap_cache): stdlib.cmd( f'find \\( -name .install -o -name ..install.cmd \\) -delete') # Drain documentation packages['kernel/linux-doc'].drain_build_cache('Documentation/*', 'usr/doc/linux/') # Packages member of `raven-os/essentials` should explicitly state all # of their dependencies, including indirect ones. packages['kernel/linux'].requires('raven-os/corefs') return packages
def patch_parted(): stdlib.patch.patch_all() # Fix some includes to prevent a linking error stdlib.cmd( r'''sed -i '/utsname.h/a#include <sys/sysmacros.h>' libparted/arch/linux.c''' )
def check_vim(): # Prepare the tests stdlib.cmd('chown -Rv nobody .') # Run the tests as the nobody user, through 'cat -e' to avoid messing with the building terminal stdlib.cmd( 'su nobody -s /bin/bash -c "LANG=en_US.UTF-8 make -j1 test" | cat -e')
def patch_m4(): build = stdlib.build.current_build() # Fix a bug introduced by glibc 2.28 # http://www.linuxfromscratch.org/lfs/view/stable/chapter06/m4.html with stdlib.pushd(build.build_cache): stdlib.cmd("sed -i 's/IO_ftrylockfile/IO_EOF_SEEN/' lib/*.c") stdlib.cmd('echo "#define _IO_IN_BACKUP 0x100" >> lib/stdio-impl.h')
def patch_systemd(): stdlib.patch.patch_all() # Remove tests that cannot be built in chroot stdlib.cmd("sed '177,$ d' -i src/resolve/meson.build") # Remove an unneeded group, render, from the default udev rules: stdlib.cmd( """sed -i 's/GROUP="render", //' rules/50-udev-default.rules.in""")
def configure_coreutils(): with stdlib.pushenv(): os.environ['FORCE_UNSAFE_CONFIGURE'] = '1' stdlib.cmd('autoreconf -fiv') configure( '--enable-no-install-program=kill,uptime' # Installed by other packages )
def check_coreutils(): make('NON_ROOT_USERNAME=nobody', 'check-root') # Fix some permissions so that the non-root user can compile and run the tests stdlib.cmd('chown -Rv nobody .') stdlib.cmd( 'su nobody -s /bin/bash -c "PATH=$PATH make RUN_EXPENSIVE_TESTS=yes check"', fail_ok=True)
def patch_libffi(): stdlib.patch.patch_all() # Modify the Makefile to install headers into the standard /usr/include directory stdlib.cmd("sed -e '/^includesdir/ s/$(libdir).*$/$(includedir)/' -i include/Makefile.in") stdlib.cmd(""" sed -e '/^includedir/ s/=.*$/=@includedir@/' \ -e 's/^Cflags: -I${includedir}/Cflags:/' \ -i libffi.pc.in """)
def install_rust(): build = stdlib.build.current_build() stdlib.cmd(f'''./install.sh \ --destdir={build.install_cache}/ \ --prefix=/usr/ \ ''') with stdlib.pushd(build.install_cache): shutil.move('usr/etc/', 'etc/')
def patch( path: str, ): """Apply the patch pointed to by ``path`` on the code base. :note: The patch must be a compatible input for the GNU ``patch`` utility. :note: Patch that appeared to already be applied are ignored :param path: The path pointing to the patch file. It must be relative to the current directory. """ stdlib.cmd(f'patch -Np1 -i {path}') stdlib.log.slog(f"Applied patch {os.path.basename(path)}")
def build(build): packages = autotools.build() # TODO FIXME Remove this when Raven is self-hosted with stdlib.pushd(packages['dev-libs/check'].wrap_cache): stdlib.cmd("sed -i '1 s/tools/usr/' usr/bin/checkmk") # Packages member of `raven-os/essentials` should explicitly state all # of their dependencies, including indirect ones. packages['dev-libs/check'].requires('raven-os/corefs') return packages
def cargo_check( *args: str, cargo_binary: str = 'cargo', fail_ok: bool = False, ): """Run ``cargo build``. :param args: Any extra arguments to give to cargo :param cargo_binary: The command or path to use. The default value is ``cargo``. :param fail_ok: If ``False``, the execution is aborted if ``cargo`` fails. The default value is ``False``. """ stdlib.cmd(f'''{cargo_binary} check --release {' '.join(args)} ''', fail_ok=fail_ok)
def build(build): packages = basic.build( compile=lambda: stdlib.cmd('python3 setup.py build'), install=lambda: stdlib.cmd( f'python3 setup.py install --root={build.install_cache}'), split=drain_all, ) # Packages member of `raven-os/essentials` should explicitly state all # of their dependencies, including indirect ones. packages['dev-apps/meson'].requires('raven-os/corefs') return packages
def fetch_git( git: str, tag: str = None, commit: str = None, branch: str = None, folder: str = '.', recursive: bool = True, ): """Download a file from an URL and ensure its integrity The downloaded file is put in the build cache of the current build, but a copy is also stored in the download cache. If :py:func:`.fetch_url` is called again with the same ``url`` argument, the already-downloaded file will be copied instead, avoiding any extra download. :note: Only HTTP, HTTPS and FTP protocols are supported. :param url: The URL pointing to the file to download. :param sha256: The SHA256 used to ensure the integrity of the file. """ build = stdlib.build.current_build() if (tag is not None) + (branch is not None) + (commit is not None) > 1: raise ValueError( f"More than one parameter between tag, commit and branch were provided. Please only pick one." ) if os.path.isabs(folder): raise ValueError( "The folder to operate is given as an absolute path. A relative one is expected." ) if tag is None and commit is None: stdlib.log.elog( "No specific commit or tag specified -- The manifest will not produce a deterministic and reliable result." ) # TODO FIXME: Use libgit instead of using shell commands. with stdlib.pushd(build.build_cache): stdlib.log.ilog(f"Cloning {git}...") stdlib.cmd( f"git clone {'--recursive' if recursive else ''} {git} {folder}") checkout = tag or branch or commit if checkout is not None: stdlib.log.ilog(f"Checking {checkout}...") stdlib.cmd(f'git checkout {checkout}')
def build(build): # Ensures Perl uses the system's zlib and bzip2 libraries. os.environ['BUILD_ZLIB'] = 'False' os.environ['BUILD_BZIP2'] = '0' packages = autotools.build(configure=lambda: stdlib.cmd(f'''sh Configure \ -des \ -Dprefix=/usr \ -Dvendorprefix=/usr \ -Dman1dir=/usr/share/man/man1 \ -Dman3dir=/usr/share/man/man3 \ -Dman1ext=1perl \ -Dman3ext=3perl \ -Dpager="/usr/bin/less -isR" \ -Duseshrplib \ -Dusethreads \ '''), split=split_perl, check=lambda: make('-k', 'check', fail_ok=True)) # Packages member of `raven-os/essentials` should explicitly state all # of their dependencies, including indirect ones. packages['dev-lang/perl'].requires('raven-os/corefs') return packages
def build(build): packages = autotools.build( patch=patch_gmp, configure=lambda: stdlib.cmd(f'''\ ./configure \\ --enable-cxx \\ --enable-shared \\ --enable-static \\ {' '.join(stdlib.template.configure.get_dir_flags())} \\ --infodir="/usr/share/info/gmp/" \\ --docdir="/usr/share/doc/" \\ '''), install=lambda: make( 'install', 'install-html', f'DESTDIR={stdlib.build.current_build().install_cache}'), ) # Rename documentation directory to match the other packages. packages['sys-libs/gmp-doc'].move('usr/share/doc/gmp.html', 'usr/share/doc/gmp') # Packages member of `raven-os/essentials` should explicitly state all # of their dependencies, including indirect ones. packages['sys-libs/gmp'].requires('raven-os/corefs') return packages
def ninja( *args: str, binary: str = 'ninja', folder: str = '.', fail_ok: bool = False, ): """Run ``ninja``. :param args: Any extra arguments to give to ``ninja``. :param binary: The command or path to use. The default value is ``ninja``. :param folder: The target folder. The default value is ``.``. :param fail_ok: If ``False``, the execution is aborted if ``ninja`` fails. The default value is ``False``. """ stdlib.cmd(f'''{binary} -C "{folder}" {' '.join(args)} ''', fail_ok=fail_ok)
def build(build): packages = distutils.build(patch=lambda: stdlib.cmd( f'python{PYTHON_MAJOR}.{PYTHON_MINOR} ./bootstrap.py'), ) packages['dev-python/setuptools'].requires('dev-lang/python#~3.7') return packages
def distutils_check( *args: str, python_binary: str = 'python3', script_path: str = './setup.py', fail_ok: bool = False, ): """Run ``python3 ./setup.py check``. :param args: Any extra arguments to give to ``setup.py`` :param python_binary: The command or path to use. The default value is ``python3``. :param script_path: The path to the distutils script. The default value is ``./setup.py``. :param fail_ok: If ``False``, the execution is aborted if ``setup.py`` fails. The default value is ``False``. """ stdlib.cmd(f'''{python_binary} {script_path} check {' '.join(args)} ''', fail_ok=fail_ok)
def build(build): # TODO FIXME We should create a Perl template when a sufficient amount of # packets will be built this way (providing enough information to make a solid # perl template) # # We're doing it manually in the meantime # - Septembre 2019 packages = autotools.build( configure=lambda: stdlib.cmd('perl Makefile.PL'), check=lambda: make('test', fail_ok=True), ) packages['dev-perl/xml-parser'].drain('usr/lib/perl5/') # We don't want -dev alternatives if they add nothing but mans for perl modules. packages['dev-perl/xml-parser'].drain_package( packages['dev-perl/xml-parser-dev'], '*', ) # Packages member of `raven-os/essentials` should explicitly state all # of their dependencies, including indirect ones. packages['dev-perl/xml-parser'].requires('raven-os/corefs') return packages
def build(build): os.environ[ 'PKG_CONFIG_PATH'] = '/usr/lib/pkgconfig:/tools/lib/pkgconfig' # TODO FIXME os.environ['LANG'] = 'en_US.UTF-8' packages = basic.build( build_folder='build', extract=extract_systemd, patch=patch_systemd, configure=lambda: stdlib.cmd('''meson \ --prefix=/usr \ --sysconfdir=/etc \ --localstatedir=/var \ -Dblkid=true \ -Dbuildtype=release \ -Ddefault-dnssec=no \ -Dfirstboot=false \ -Dinstall-tests=false \ -Dkmod-path=/usr/bin/kmod \ -Dldconfig=false \ -Dmount-path=/usr/bin/mount \ -Drootprefix= \ -Drootlibdir=/usr/lib \ -Dsplit-usr=true \ -Dsulogin-path=/usr/bin/sulogin \ -Dsysusers=false \ -Dumount-path=/usr/bin/umount \ -Db_lto=false \ -Drpmmacrosdir=no \ .. '''), compile=lambda: stdlib.cmd('ninja'), install=lambda: stdlib.cmd('ninja install'), split=split_systemd, ) # Packages member of `raven-os/essentials` should explicitly state all # of their dependencies, including indirect ones. packages['sys-apps/systemd'].requires('raven-os/corefs') packages['sys-apps/systemd'].requires('sys-apps/shadow') packages['sys-apps/systemd'].requires('sys-apps/bash') packages['sys-apps/systemd'].requires('sys-apps/coreutils') packages['sys-apps/systemd'].load_instructions('./instructions.sh') return packages
def patch_bc(): # TODO FIXME Replace all uses of `ed` by `sed` with open('bc/fix-libmath_h', 'w') as f: f.write(textwrap.dedent("""\ #! /bin/bash sed -e '1 s/^/{"/' \\ -e 's/$/",/' \\ -e '2,$ s/^/"/' \\ -e '$ d' \\ -i libmath.h sed -e '$ s/$/0}/' \\ -i libmath.h """)) # TODO FIXME Fix an issue in configure due to missing files in the early stages of Raven-OS stdlib.cmd("sed -i -e '/flex/s/as_fn_error/: ;; # &/' configure")
def build(build): return autotools.build( build_folder='build', patch=lambda: stdlib.cmd( 'sed "s/Supscription/Subscription/g" -i source/conf/*.cpp'), configure=lambda: cmake('..'), split=drain_all_with_doc, )
def cargo_install( *args: str, path='.', cargo_binary: str = 'cargo', fail_ok: bool = False, ): """Run ``cargo install``. :param args: Any extra arguments to give to cargo :param path: The path pointing to the directory or Cargo manifest to install. :param cargo_binary: The command or path to use. The default value is ``cargo``. :param fail_ok: If ``False``, the execution is aborted if ``cargo`` fails. The default value is ``False``. """ build = stdlib.build.current_build() stdlib.cmd(f'''{cargo_binary} install --root={build.install_cache} --path={path} {' '.join(args)}''', fail_ok=fail_ok)
def make( *targets: str, binary: str = 'make', folder: str = '.', fail_ok: bool = False, ): """Run ``make``. :note: Targets are each executed by one instance of ``make``, therefore they are run in parallel. :param targets: The targets to run. :param binary: The command or path to use. The default value is ``make``. :param folder: The target folder. The default value is ``.``. :param fail_ok: If ``True``, the execution is aborted if ``make`` fails. """ stdlib.cmd(f'''{binary} -C {folder} {' '.join(targets)}''', fail_ok=fail_ok)
def distutils_install( *args: str, python_binary: str = 'python3', script_path: str = './setup.py', fail_ok: bool = False, ): """Run ``python3 ./setup.py install``. :param args: Any extra arguments to give to ``setup.py`` :param python_binary: The command or path to use. The default value is ``python3``. :param script_path: The path to the distutils script. The default value is ``./setup.py``. :param fail_ok: If ``False``, the execution is aborted if ``setup.py`` fails. The default value is ``False``. """ build = stdlib.build.current_build() stdlib.cmd( f'''{python_binary} {script_path} install --prefix=/usr --root={build.install_cache} {' '.join(args)} ''', fail_ok=fail_ok)
def build(build): packages = autotools.build( patch=patch_autoconf, # The configure script of autoconf2-13 doesn't have all the usual flags, so we can't # rely on the template to help us here. A manual call is required. configure=lambda: stdlib.cmd("./configure --program-suffix=2.13"), compile=make, ) packages['dev-apps/autoconf2-13'].drain('usr/local/share/autoconf-2.13/') packages['dev-apps/autoconf2-13'].drain_build_cache('autoconf213.info', 'usr/share/info/') return packages
def build(build): packages = basic.build( compile=lambda: stdlib.cmd('python3 configure.py --bootstrap'), check=lambda: stdlib. cmd('./ninja ninja_test && ./ninja_test --gtest_filter=-SubprocessTest.SetWithLots' ), split=split_ninja, ) # Packages member of `raven-os/essentials` should explicitly state all # of their dependencies, including indirect ones. packages['dev-apps/ninja'].requires('raven-os/corefs') return packages
def meson( *args: str, binary: str = 'meson', backend: str = 'ninja', build_type: str = 'release', fail_ok: bool = False, ): """Run ``meson setup``. :note: Most ``--*dir`` flags are automatically added, but can be overriden with the extra ``args`` argument. :param args: Any extra arguments to give to ``meson setup``. :param binary: The command or path to use. The default value is ``meson``. :param backend: Backend to use. Default: ``ninja``. :param build_type: Build type to use. Default: ``release``. :param fail_ok: If ``False``, the execution is aborted if ``meson`` fails. The default value is ``False``. """ stdlib.cmd( f'''\ {binary} setup \ --prefix="/usr" \ --bindir="/usr/bin" \ --sbindir="/usr/bin" \ --libdir="/usr/lib64" \ --libexecdir="/usr/lib64" \ --includedir="/usr/include" \ --datadir="/usr/share" \ --mandir="/usr/share/man" \ --sysconfdir="/etc" \ --localstatedir="/var" \ --backend="{backend}" \ --buildtype="{build_type}" \ {' '.join(args)} \ ''', fail_ok=fail_ok, )
def build(build): os.environ['SHELL'] = '/bin/bash' packages = autotools.build( build_folder='mozjs-build', configure=lambda: stdlib.cmd(f"../js/src/configure --prefix=/usr\ --with-intl-api \ --with-system-zlib \ --with-system-icu \ --disable-jemalloc \ --enable-readline \ "), ) packages['dev-apps/js-dev'].drain('usr/lib/libjs_static.ajs') return packages