diff --git a/rootfs.py b/rootfs.py index 26e58f54..7edeee66 100755 --- a/rootfs.py +++ b/rootfs.py @@ -12,6 +12,7 @@ you can run bootstap inside chroot. # SPDX-FileCopyrightText: 2021 Bastian Bittorf # SPDX-FileCopyrightText: 2021 Melg Eight # SPDX-FileCopyrightText: 2021-23 fosslinux +# SPDX-FileCopyrightText: 2023-24 Gábor Stefanik import argparse import os @@ -32,6 +33,7 @@ def create_configuration_file(args): config.write(f"UPDATE_CHECKSUMS={args.update_checksums}\n") config.write(f"JOBS={args.cores}\n") config.write(f"FINAL_JOBS={args.cores}\n") + config.write(f"SWAP_SIZE={args.swap}\n") config.write(f"INTERNAL_CI={args.internal_ci or False}\n") config.write(f"INTERACTIVE={args.interactive}\n") config.write(f"BARE_METAL={args.bare_metal}\n") @@ -46,7 +48,7 @@ def create_configuration_file(args): config.write("KERNEL_BOOTSTRAP=False\n") config.write(f"BUILD_KERNELS={args.update_checksums or args.build_kernels}\n") -# pylint: disable=too-many-statements +# pylint: disable=too-many-statements,too-many-branches def main(): """ A few command line arguments to customize bootstrap. @@ -91,6 +93,8 @@ def main(): parser.add_argument("--early-preseed", help="Skip early stages of live-bootstrap", nargs=None) parser.add_argument("--internal-ci", help="INTERNAL for github CI") + parser.add_argument("-s", "--swap", help="Swap space to allocate in Linux", + default=0) # QEMU arguments parser.add_argument("-q", "--qemu", help="Use QEMU", @@ -148,6 +152,13 @@ def main(): else: args.target_size = 0 + # Swap file size validation + if args.qemu or args.bare_metal: + args.swap = (int(str(args.swap).rstrip('gGmM')) * + (1024 if str(args.swap).lower().endswith('g') else 1)) + else: + args.swap = 0 + # bootstrap.cfg try: os.remove(os.path.join('steps', 'bootstrap.cfg')) diff --git a/seed/script-generator.c b/seed/script-generator.c index 8c3b2a41..2d60f284 100644 --- a/seed/script-generator.c +++ b/seed/script-generator.c @@ -214,11 +214,12 @@ Token *logic(Token *tok, char **val) { /* logic = "(" * (name | * (name "==" value) | + * (name "!=" value) | * (logic "||" logic) | * (logic "&&" logic)) * ")" */ - + char *lhs = tok->val; char *rhs; tok = tok->next; @@ -235,8 +236,17 @@ Token *logic(Token *tok, char **val) { } else { lhs = "False"; } - } else { - fputs("Expected == after ", stderr); + } else if (strcmp(tok->val, "!=") == 0) { + /* Case for inequality. */ + rhs = tok->next->val; + tok = tok->next->next; + if (strcmp(get_var(lhs), rhs) == 0) { + lhs = "False"; + } else { + lhs = "True"; + } + } else { + fputs("Expected == or != after ", stderr); fputs(lhs, stderr); fputs(" in logic\n", stderr); exit(1); diff --git a/steps/improve/swap.sh b/steps/improve/swap.sh new file mode 100644 index 00000000..b9d15933 --- /dev/null +++ b/steps/improve/swap.sh @@ -0,0 +1,19 @@ + +#!/bin/sh +# +# SPDX-FileCopyrightText: 2024 Gábor Stefanik +# +# SPDX-License-Identifier: GPL-3.0-or-later +# +# Set up swap + +. /steps/bootstrap.cfg +. /steps/env + +if ! test -f /swap +then + echo "Making swap..." + dd if=/dev/zero of=/swap bs=1M count=${SWAP_SIZE} + mkswap /swap +fi +swapon /swap diff --git a/steps/manifest b/steps/manifest index 691762f3..276fecbc 100644 --- a/steps/manifest +++ b/steps/manifest @@ -121,6 +121,7 @@ jump: linux ( CHROOT == False ) jump: move_disk ( KERNEL_BOOTSTRAP == True ) improve: update_jobs improve: finalize_fhs +improve: swap ( SWAP_SIZE != 0 ) build: musl-1.2.4 build: curl-8.5.0 improve: get_network ( CHROOT == False )