├── .gitignore ├── LICENSE ├── Makefile ├── README.md ├── ReleaseNotes.md ├── detect_arch.sh ├── patches └── lvm2 │ └── fix-stdio.patch ├── releases └── src ├── bouncer ├── Makefile ├── README.md └── bouncer.c ├── crossfs ├── Makefile ├── README.md └── crossfs.c ├── etcfs ├── Makefile ├── README.md └── etcfs.c ├── init └── init ├── installer └── installer.sh ├── keyboard_is_present ├── Makefile ├── README.md └── keyboard_is_present.c ├── manage_tty_lock ├── Makefile ├── README.md └── manage_tty_lock.c ├── patches └── busybox-x-opt.patch ├── plymouth-quit ├── Makefile ├── README.md └── plymouth-quit.c ├── slash-bedrock ├── bin │ └── brl ├── etc │ ├── bedrock.conf │ ├── os-release │ └── world ├── gnupg-keys │ └── paradigm.gpg ├── libexec │ ├── brl-alias │ ├── brl-apply │ ├── brl-copy │ ├── brl-deref │ ├── brl-disable │ ├── brl-enable │ ├── brl-fetch │ ├── brl-hide │ ├── brl-import │ ├── brl-list │ ├── brl-remove │ ├── brl-rename │ ├── brl-repair │ ├── brl-report │ ├── brl-show │ ├── brl-status │ ├── brl-tutorial │ ├── brl-update │ ├── brl-version │ ├── brl-which │ └── pmm ├── share │ ├── bash │ │ └── completion │ │ │ ├── brl │ │ │ └── strat │ ├── brl-fetch │ │ └── distros │ │ │ ├── .opensuse │ │ │ ├── .parabola │ │ │ ├── .trisquel │ │ │ ├── alma │ │ │ ├── alpine │ │ │ ├── arch │ │ │ ├── arch-32 │ │ │ ├── arch-arm │ │ │ ├── artix │ │ │ ├── artix-s6 │ │ │ ├── centos │ │ │ ├── clear │ │ │ ├── crux │ │ │ ├── debian │ │ │ ├── devuan │ │ │ ├── exherbo │ │ │ ├── exherbo-musl │ │ │ ├── fedora │ │ │ ├── gentoo │ │ │ ├── kiss │ │ │ ├── manjaro │ │ │ ├── openwrt │ │ │ ├── raspbian │ │ │ ├── rocky │ │ │ ├── slackware │ │ │ ├── solus │ │ │ ├── ubuntu │ │ │ ├── void │ │ │ └── void-musl │ ├── brl-tutorial │ │ ├── common │ │ └── lessons │ │ │ ├── 001_basics │ │ │ └── 002_brl-fetch │ ├── common-code │ ├── dkms │ │ └── include-bedrock │ ├── fish │ │ └── completion │ │ │ ├── brl.fish │ │ │ └── strat.fish │ ├── fonts │ │ └── fontconf.conf │ ├── info │ │ └── .keepinfodir │ ├── pmm │ │ ├── flags │ │ ├── help │ │ ├── operations │ │ └── package_managers │ │ │ ├── apk │ │ │ ├── apt │ │ │ ├── brl │ │ │ ├── dnf │ │ │ ├── pacman │ │ │ ├── paru │ │ │ ├── pmm │ │ │ ├── portage │ │ │ ├── xbps │ │ │ └── yay │ ├── resolvconf │ │ └── 00bedrock │ ├── shells │ │ └── include-bedrock │ ├── sudo │ │ └── include-bedrock │ ├── systemd │ │ ├── bedrock-fix-mounts.service │ │ ├── bedrock-fix-resolv.service │ │ ├── bedrock-stop-fuse-filesystems.service │ │ └── stop-fuse-filesystems.sh │ └── zsh │ │ ├── completion │ │ ├── _brl │ │ ├── _pmm │ │ └── _strat │ │ └── include-bedrock └── var │ └── lock └── strat ├── Makefile ├── README.md └── strat.c /.gitignore: -------------------------------------------------------------------------------- 1 | bedrock-linux-*.sh 2 | build 3 | vendor 4 | -------------------------------------------------------------------------------- /detect_arch.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # detect_arch.sh 4 | # 5 | # This program is free software; you can redistribute it and/or 6 | # modify it under the terms of the GNU General Public License 7 | # version 2 as published by the Free Software Foundation. 8 | # 9 | # Copyright (c) 2019 Daniel Thau 10 | # 11 | # Detects which CPU architecture Bedrock Linux's build system is producing. 12 | # Outputs two lines: 13 | # - First line is Bedrock's name for the architecture. This is used, for 14 | # example, in the output installer/updater file name. 15 | # - Second line is context expected in `file` output on one of the binaries. 16 | # This is used to sanity check the resulting binaries are in fact of the 17 | # expected type. 18 | # - Third line is CPU bit depth. 19 | 20 | if ! gcc --version >/dev/null 2>&1; then 21 | echo "ERROR: gcc not found" >&2 22 | exit 1 23 | fi 24 | 25 | case "$(gcc -dumpmachine)" in 26 | aarch64-*) 27 | echo "aarch64" 28 | echo "ARM aarch64" 29 | echo "64" 30 | ;; 31 | arm-*abi) 32 | echo "armv7l" 33 | echo "EABI5" 34 | echo "32" 35 | ;; 36 | arm-*abihf) 37 | echo "armv7hl" 38 | echo "EABI5" 39 | echo "32" 40 | ;; 41 | i386-*) 42 | echo "i386" 43 | echo "Intel 80386" 44 | echo "32" 45 | ;; 46 | i486-*) 47 | echo "i486" 48 | echo "Intel 80386" 49 | echo "32" 50 | ;; 51 | i586-*) 52 | echo "i586" 53 | echo "Intel 80386" 54 | echo "32" 55 | ;; 56 | i686-*) 57 | echo "i686" 58 | echo "Intel 80386" 59 | echo "32" 60 | ;; 61 | mips-*) 62 | echo "mips" 63 | echo "MIPS\(32\|-I\)" 64 | echo "32" 65 | ;; 66 | mipsel-*) 67 | echo "mipsel" 68 | echo "MIPS\(32\|-I\)" 69 | echo "32" 70 | ;; 71 | mips64el-*) 72 | echo "mips64el" 73 | echo "MIPS64" 74 | echo "64" 75 | ;; 76 | powerpc-*) 77 | echo "ppc" 78 | echo "32-bit.*PowerPC" 79 | echo "32" 80 | ;; 81 | powerpc64-*) 82 | echo "ppc64" 83 | echo "64-bit PowerPC" 84 | echo "64" 85 | ;; 86 | powerpc64le-*) 87 | echo "ppc64le" 88 | echo "64-bit PowerPC" 89 | echo "64" 90 | ;; 91 | s390x-*) 92 | echo "s390x" 93 | echo "IBM S/390" 94 | echo "64" # the x in s390x indicates 64 bit 95 | ;; 96 | x86_64-*) 97 | echo "x86_64" 98 | echo "x86-64" 99 | echo "64" 100 | ;; 101 | *) 102 | echo "Unrecognized CPU architecture" >&2 103 | exit 1 104 | ;; 105 | esac 106 | -------------------------------------------------------------------------------- /patches/lvm2/fix-stdio.patch: -------------------------------------------------------------------------------- 1 | --- lib/commands/toolcontext.c 2 | +++ lib/commands/toolcontext.c 3 | @@ -1667,7 +1667,7 @@ struct cmd_context *create_toolcontext(unsigned is_clvmd, 4 | /* FIXME Make this configurable? */ 5 | reset_lvm_errno(1); 6 | 7 | -#ifndef VALGRIND_POOL 8 | +#if !defined(VALGRIND_POOL) && defined(__GLIBC__) 9 | /* Set in/out stream buffering before glibc */ 10 | if (set_buffering 11 | #ifdef SYS_gettid 12 | @@ -2045,7 +2045,7 @@ void destroy_toolcontext(struct cmd_context *cmd) 13 | dm_hash_destroy(cmd->cft_def_hash); 14 | 15 | dm_device_list_destroy(&cmd->cache_dm_devs); 16 | -#ifndef VALGRIND_POOL 17 | +#if !defined(VALGRIND_POOL) && defined(__GLIBC__) 18 | if (cmd->linebuffer) { 19 | /* Reset stream buffering to defaults */ 20 | if (is_valid_fd(STDIN_FILENO) && 21 | diff --git a/tools/lvmcmdline.c b/tools/lvmcmdline.c 22 | index a5bb6a5c5..0ebfa375c 100644 23 | --- tools/lvmcmdline.c 24 | +++ tools/lvmcmdline.c 25 | @@ -3422,7 +3422,7 @@ static int _check_standard_fds(void) 26 | int err = is_valid_fd(STDERR_FILENO); 27 | 28 | if (!is_valid_fd(STDIN_FILENO) && 29 | - !(stdin = fopen(_PATH_DEVNULL, "r"))) { 30 | + !freopen(_PATH_DEVNULL, "r", stdin)) { 31 | if (err) 32 | perror("stdin stream open"); 33 | else 34 | @@ -3432,7 +3432,7 @@ static int _check_standard_fds(void) 35 | } 36 | 37 | if (!is_valid_fd(STDOUT_FILENO) && 38 | - !(stdout = fopen(_PATH_DEVNULL, "w"))) { 39 | + !freopen(_PATH_DEVNULL, "w", stdout)) { 40 | if (err) 41 | perror("stdout stream open"); 42 | /* else no stdout */ 43 | @@ -3440,7 +3440,7 @@ static int _check_standard_fds(void) 44 | } 45 | 46 | if (!is_valid_fd(STDERR_FILENO) && 47 | - !(stderr = fopen(_PATH_DEVNULL, "w"))) { 48 | + !freopen(_PATH_DEVNULL, "w", stderr)) { 49 | printf("stderr stream open: %s\n", 50 | strerror(errno)); 51 | return 0; 52 | -------------------------------------------------------------------------------- /src/bouncer/Makefile: -------------------------------------------------------------------------------- 1 | # bouncer makefile 2 | # 3 | # This program is free software; you can redistribute it and/or 4 | # modify it under the terms of the GNU General Public License 5 | # version 2 as published by the Free Software Foundation. 6 | # 7 | # Copyright (c) 2017-2018 Daniel Thau 8 | 9 | all: bouncer 10 | 11 | strat: 12 | $(CC) $(CFLAGS) -std=c99 bouncer.c -o bouncer 13 | 14 | clean: 15 | rm -f bouncer 16 | 17 | install: 18 | mkdir -p $(prefix)/bin 19 | install -m 755 strat $(prefix)/bin/bouncer 20 | 21 | uninstall: 22 | rm -f $(prefix)/bin/bouncer 23 | -------------------------------------------------------------------------------- /src/bouncer/README.md: -------------------------------------------------------------------------------- 1 | bouncer 2 | ======= 3 | 4 | bouncer redirects calls to another executable based on the following xattrs as 5 | set on the bouncer executable: 6 | 7 | - `user.bedrock.stratum` indicates the stratum which should provide the 8 | executable 9 | - `user.bedrock.localpath` indicates stratum-local path of the desired 10 | executable 11 | 12 | bouncer passes its arg0 to the executable it is calling. This is in contrast 13 | to a hashbang file such as: 14 | 15 | #!/bin/sh 16 | exec strat 17 | 18 | which would lose its argv[0]. 19 | 20 | Installation 21 | ------------ 22 | 23 | Bedrock Linux should be distributed with a script which handles installation, 24 | but just in case: 25 | 26 | To compile, run 27 | 28 | make 29 | 30 | To install into installdir, run 31 | 32 | make prefix= install 33 | 34 | To clean up, like usual: 35 | 36 | make clean 37 | 38 | And finally, to remove it, run: 39 | 40 | make prefix= uninstall 41 | -------------------------------------------------------------------------------- /src/bouncer/bouncer.c: -------------------------------------------------------------------------------- 1 | /* 2 | * bouncer.c 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License 6 | * version 2 as published by the Free Software Foundation. 7 | * 8 | * Copyright (c) 2017-2019 Daniel Thau 9 | * 10 | * This program redirects to the specified executable in the specified stratum 11 | * via strat. The appropriate stratum and executable are determined by the 12 | * 'user.bedrock_stratum' and 'user.bedrock_localpath' xattrs on 13 | * /proc/self/exe. 14 | * 15 | * This is preferable to a script such as 16 | * 17 | * #!/bin/sh 18 | * exec strat $@ 19 | * 20 | * as it can pass its own argv[0] where as a hashbang loses this information. 21 | */ 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | int main(int argc, char *argv[]) 31 | { 32 | /* 33 | * Which stratum do we want to be in? 34 | */ 35 | char target_stratum[PATH_MAX]; 36 | ssize_t len = getxattr("/proc/self/exe", "user.bedrock.stratum", 37 | target_stratum, sizeof(target_stratum) - 1); 38 | if (len < 0) { 39 | fprintf(stderr, "bouncer: unable to determine target stratum\n"); 40 | return errno; 41 | } 42 | target_stratum[len] = '\0'; 43 | 44 | /* 45 | * Which executable do we want to run? 46 | */ 47 | char target_path[PATH_MAX]; 48 | len = getxattr("/proc/self/exe", "user.bedrock.localpath", target_path, sizeof(target_path) - 1); 49 | if (len < 0) { 50 | fprintf(stderr, "bouncer: unable to determine target path\n"); 51 | return errno; 52 | } 53 | target_path[len] = '\0'; 54 | 55 | /* 56 | * Do we want to restrict the process to its own stratum? 57 | */ 58 | int restrict_flag = 0; 59 | char target_restrict[PATH_MAX]; 60 | len = getxattr("/proc/self/exe", "user.bedrock.restrict", target_restrict, sizeof(target_restrict) - 1); 61 | if (len >= 0) { 62 | restrict_flag = 1; 63 | } 64 | 65 | char *strat = "/bedrock/bin/strat"; 66 | /* 67 | * Example: 68 | * 69 | * incoming: apt install foo bar baz -- (argc does not count NULL) 70 | * \ \ \ \ \___________________________________________________ 71 | * \ \ \ \___________________________________________________ \ 72 | * \ \ \___________________________________________________ \ \ 73 | * \ \__________________________________________________ \ \ \ 74 | * \___________________ \ \ \ \ 75 | * \ \ \ \ \ 76 | * outgoing: /bedrock/bin/strat --arg0 apt --restrict debian /usr/bin/apt install foo bar baz NULL 77 | * /bedrock/bin/strat --arg0 apt --restrict debian /usr/bin/apt install foo bar baz NULL 78 | * \ \ \ \ \ \ 79 | * \- 1 \- 2 \- 3 \- 4 \- 5 \- 6 80 | * 81 | * Potentially need 6 more than argc. 82 | */ 83 | char *new_argv[argc + 6]; 84 | 85 | new_argv[0] = strat; 86 | new_argv[1] = "--arg0"; 87 | new_argv[2] = argv[0]; 88 | if (restrict_flag) { 89 | new_argv[3] = "--restrict"; 90 | } 91 | new_argv[3 + restrict_flag] = target_stratum; 92 | new_argv[4 + restrict_flag] = target_path; 93 | /* start at 1 to skip argv[0] which was already consumed above */ 94 | for (int i = 1; i < argc; i++) { 95 | new_argv[i + 4 + restrict_flag] = argv[i]; 96 | } 97 | new_argv[argc + 4 + restrict_flag] = NULL; 98 | 99 | execv(strat, new_argv); 100 | 101 | fprintf(stderr, "bouncer: could not execute\n %s\n", strat); 102 | switch (errno) { 103 | case EACCES: 104 | fprintf(stderr, "due to: permission denied (EACCES).\n"); 105 | break; 106 | case ENOENT: 107 | fprintf(stderr, "due to: unable to find file (ENOENT).\n"); 108 | break; 109 | default: 110 | perror("due to: execv:\n"); 111 | break; 112 | } 113 | 114 | return 1; 115 | } 116 | -------------------------------------------------------------------------------- /src/crossfs/Makefile: -------------------------------------------------------------------------------- 1 | # crossfs makefile 2 | # 3 | # This program is free software; you can redistribute it and/or 4 | # modify it under the terms of the GNU General Public License 5 | # version 2 as published by the Free Software Foundation. 6 | # 7 | # Copyright (c) 2014-2018 Daniel Thau 8 | 9 | all: crossfs 10 | 11 | crossfs: crossfs.c 12 | $(CC) $(CFLAGS) -std=c99 -D_FILE_OFFSET_BITS=64 crossfs.c -o crossfs -lfuse3 -lpthread 13 | 14 | clean: 15 | rm -f crossfs 16 | 17 | install: 18 | mkdir -p $(prefix)/sbin 19 | install -m 755 crossfs $(prefix)/sbin/crossfs 20 | 21 | uninstall: 22 | rm -f $(prefix)/sbin/crossfs 23 | -------------------------------------------------------------------------------- /src/crossfs/README.md: -------------------------------------------------------------------------------- 1 | crossfs 2 | ======= 3 | 4 | crossfs is a virtual filesystem which dynamically populates a specified 5 | directory with content from other strata, modified as necessary so the files 6 | are consumable across strata. For example, it wraps binary executables so that 7 | they are implicit run through strat to the appropriate stratum. 8 | 9 | crossfs takes the typical libfuse arguments such as `-o allow_other` and `-f`. 10 | See libfuse for details. 11 | 12 | Configuration 13 | ------------- 14 | 15 | crossfs creates a virtual `.bedrock-config-filesystem` file in the root of its 16 | mount point to handle its configuration. `.bedrock-config-filesystem` may be 17 | read to get the current configuration and is written to by `brl reload`. 18 | 19 | Installation 20 | ------------ 21 | 22 | Bedrock Linux should be distributed with a script which handles installation, 23 | but just in case: 24 | 25 | The dependencies are: 26 | 27 | - libfuse 28 | - uthash 29 | 30 | To compile, run 31 | 32 | make 33 | 34 | To install into installdir, run 35 | 36 | make prefix= install 37 | 38 | To clean up, like usual: 39 | 40 | make clean 41 | 42 | And finally, to remove it, run: 43 | 44 | make prefix= uninstall 45 | -------------------------------------------------------------------------------- /src/etcfs/Makefile: -------------------------------------------------------------------------------- 1 | # etcfs makefile 2 | # 3 | # This program is free software; you can redistribute it and/or 4 | # modify it under the terms of the GNU General Public License 5 | # version 2 as published by the Free Software Foundation. 6 | # 7 | # Copyright (c) 2013-2018 Daniel Thau 8 | 9 | all: etcfs 10 | 11 | etcfs: etcfs.c 12 | $(CC) $(CFLAGS) -std=c99 -D_FILE_OFFSET_BITS=64 etcfs.c -o etcfs -lfuse3 -lpthread 13 | 14 | clean: 15 | rm -f etcfs 16 | 17 | install: 18 | mkdir -p $(prefix)/sbin 19 | install -m 755 etcfs $(prefix)/sbin/etcfs 20 | 21 | uninstall: 22 | rm -f $(prefix)/sbin/etcfs 23 | -------------------------------------------------------------------------------- /src/etcfs/README.md: -------------------------------------------------------------------------------- 1 | etcfs 2 | ===== 3 | 4 | etcfs is a virtual filesystem which redirects file access to either the global 5 | stratum's instance of a file, or the calling process' local stratum instance of 6 | a file. It may also modify files as needed to enforce specific file content, 7 | such as configuration file values. 8 | 9 | Configuration 10 | ------------- 11 | 12 | etcfs creates a virtual `.bedrock-config-filesystem` file in the root of its 13 | mount point to handle its configuration. `.bedrock-config-filesystem` may be 14 | read to get the current configuration and is written to by `brl reload`. 15 | 16 | Installation 17 | ------------ 18 | 19 | Bedrock Linux should be distributed with a script which handles installation, 20 | but just in case: 21 | 22 | The dependencies are: 23 | 24 | - libfuse 25 | 26 | To compile, run 27 | 28 | make 29 | 30 | To install into installdir, run 31 | 32 | make prefix= install 33 | 34 | To clean up, like usual: 35 | 36 | make clean 37 | 38 | And finally, to remove it, run: 39 | 40 | make prefix= uninstall 41 | -------------------------------------------------------------------------------- /src/keyboard_is_present/Makefile: -------------------------------------------------------------------------------- 1 | # keyboard_is_present makefile 2 | # 3 | # This program is free software; you can redistribute it and/or 4 | # modify it under the terms of the GNU General Public License 5 | # version 2 as published by the Free Software Foundation. 6 | # 7 | # Copyright (c) 2019 Daniel Thau 8 | 9 | all: keyboard_is_present 10 | 11 | keyboard_is_present: keyboard_is_present.c 12 | $(CC) $(CFLAGS) -std=c99 keyboard_is_present.c -o keyboard_is_present 13 | 14 | clean: 15 | rm -f keyboard_is_present 16 | 17 | install: 18 | mkdir -p $(prefix)/sbin 19 | install -m 755 keyboard_is_present $(prefix)/sbin/keyboard_is_present 20 | 21 | uninstall: 22 | rm -f $(prefix)/sbin/keyboard_is_present 23 | -------------------------------------------------------------------------------- /src/keyboard_is_present/README.md: -------------------------------------------------------------------------------- 1 | keyboard_is_present 2 | =================== 3 | 4 | Detects if Linux system has an initialized keyboard 5 | 6 | Usage 7 | ----- 8 | 9 | Simply run the executable. It will return zero if a keyboard is detected and 10 | non-zero otherwise. 11 | 12 | Installation 13 | ------------ 14 | 15 | Bedrock Linux should be distributed with a script which handles installation, 16 | but just in case: 17 | 18 | To compile, run 19 | 20 | make 21 | 22 | To install into installdir, run 23 | 24 | make prefix= install 25 | 26 | To clean up, like usual: 27 | 28 | make clean 29 | 30 | And finally, to remove it, run: 31 | 32 | make prefix= uninstall 33 | -------------------------------------------------------------------------------- /src/keyboard_is_present/keyboard_is_present.c: -------------------------------------------------------------------------------- 1 | /* 2 | * keyboard_is_present.c 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License 6 | * version 2 as published by the Free Software Foundation. 7 | * 8 | * Copyright (c) 2019 Daniel Thau 9 | * 10 | * Based on the keyboard detection system described here: 11 | * https://www.mattfischer.com/blog/archives/182 12 | * 13 | * Returns zero if a keyboard is detected and non-zero otherwise. 14 | */ 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | /* 23 | * Input device directory 24 | */ 25 | #define INPUT_DIR "/sys/class/input" 26 | /* 27 | * Escape key, the number row, and Q through D 28 | */ 29 | #define KEYBOARD_MASK 0xFFFFFFFE 30 | 31 | int main(int argc, char *argv[]) 32 | { 33 | (void)argc; 34 | (void)argv; 35 | 36 | DIR *dir; 37 | if ((dir = opendir(INPUT_DIR)) == NULL) { 38 | fprintf(stderr, "Unable to open \"%s\"\n", INPUT_DIR); 39 | return 2; 40 | } 41 | 42 | struct dirent *entry; 43 | while ((entry = readdir(dir)) != NULL) { 44 | /* 45 | * Skip `.` and `..`. Also dotfiles if they some how end up 46 | * here. 47 | */ 48 | if (entry->d_name[0] == '.') { 49 | continue; 50 | } 51 | 52 | /* 53 | * Find capabilities directory 54 | */ 55 | char *cap = "capabilities"; 56 | char path[PATH_MAX]; 57 | int s = snprintf(path, sizeof(path), 58 | INPUT_DIR "/%s/%s", entry->d_name, cap); 59 | if (s < 0 || s >= (int)sizeof(path)) { 60 | fprintf(stderr, "Unable to build capabilities path string\n"); 61 | return 2; 62 | } 63 | struct stat stbuf; 64 | if (stat(path, &stbuf) != 0 || !S_ISDIR(stbuf.st_mode)) { 65 | cap = "device/capabilities"; 66 | s = snprintf(path, sizeof(path), INPUT_DIR "/%s/%s", entry->d_name, cap); 67 | if (s < 0 || s >= (int)sizeof(path)) { 68 | fprintf(stderr, "Unable to build capabilities path string\n"); 69 | return 2; 70 | } 71 | } 72 | if (stat(path, &stbuf) != 0 || !S_ISDIR(stbuf.st_mode)) { 73 | continue; 74 | } 75 | 76 | /* 77 | * Check if device has keyboard event code support 78 | */ 79 | s = snprintf(path, sizeof(path), INPUT_DIR "/%s/%s/ev", entry->d_name, cap); 80 | if (s < 0 || s >= (int)sizeof(path)) { 81 | fprintf(stderr, "Unable to build ev path string\n"); 82 | return 2; 83 | } 84 | FILE *f; 85 | if ((f = fopen(path, "r")) == NULL) { 86 | continue; 87 | } 88 | unsigned int bits = 0; 89 | while (fscanf(f, "%x", &bits) == 1) { 90 | ; 91 | } 92 | fclose(f); 93 | if ((bits & EV_KEY) != EV_KEY) { 94 | continue; 95 | } 96 | 97 | /* 98 | * Check if device supports expected keyboard keys such as escape, the number row, and Q through D 99 | */ 100 | s = snprintf(path, sizeof(path), INPUT_DIR "/%s/%s/key", entry->d_name, cap); 101 | if (s < 0 || s >= (int)sizeof(path)) { 102 | fprintf(stderr, "Unable to build key path string\n"); 103 | return 2; 104 | } 105 | if ((f = fopen(path, "r")) == NULL) { 106 | continue; 107 | } 108 | bits = 0; 109 | while (fscanf(f, "%x", &bits) == 1) { 110 | ; 111 | } 112 | fclose(f); 113 | if ((bits & KEYBOARD_MASK) != KEYBOARD_MASK) { 114 | continue; 115 | } 116 | 117 | /* 118 | * Found keyboard 119 | */ 120 | return 0; 121 | } 122 | 123 | return 1; 124 | } 125 | -------------------------------------------------------------------------------- /src/manage_tty_lock/Makefile: -------------------------------------------------------------------------------- 1 | # manage_tty_lock makefile 2 | # 3 | # This program is free software; you can redistribute it and/or 4 | # modify it under the terms of the GNU General Public License 5 | # version 2 as published by the Free Software Foundation. 6 | # 7 | # Copyright (c) 2015-2018 Daniel Thau 8 | 9 | all: manage_tty_lock 10 | 11 | manage_tty_lock: 12 | $(CC) $(CFLAGS) -std=c99 manage_tty_lock.c -o manage_tty_lock 13 | 14 | clean: 15 | rm -f manage_tty_lock 16 | 17 | install: 18 | mkdir -p $(prefix)/sbin 19 | install -m 755 manage_tty_lock $(prefix)/sbin/manage_tty_lock 20 | 21 | uninstall: 22 | rm -f $(prefix)/sbin/manage_tty_lock 23 | -------------------------------------------------------------------------------- /src/manage_tty_lock/README.md: -------------------------------------------------------------------------------- 1 | manage_tty_lock 2 | =============== 3 | 4 | Set/unset the locks on a given terminal. 5 | 6 | Usage 7 | ----- 8 | 9 | To lock a terminal, use `lock` as the first argument. To unlock one, use 10 | `unlock` as the first argument. The second argument can be utilized to specify 11 | which terminal to lock/unlock; if it is left unset, the current terminal is 12 | utilized. 13 | 14 | Example, locking /dev/pts/1: 15 | 16 | manage_stty_lock lock /dev/pts/1 17 | 18 | Example, unlocking the current terminal: 19 | 20 | Example: manage_stty_lock unlock 21 | 22 | Installation 23 | ------------ 24 | 25 | Bedrock Linux should be distributed with a script which handles installation, 26 | but just in case: 27 | 28 | To compile, run 29 | 30 | make 31 | 32 | To install into installdir, run 33 | 34 | make prefix= install 35 | 36 | To clean up, like usual: 37 | 38 | make uninstall 39 | 40 | And finally, to remove it, run: 41 | 42 | make prefix= uninstall 43 | -------------------------------------------------------------------------------- /src/manage_tty_lock/manage_tty_lock.c: -------------------------------------------------------------------------------- 1 | /* 2 | * manage_stty_lock.c 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License 6 | * version 2 as published by the Free Software Foundation. 7 | * 8 | * Copyright (c) 2015-2018 Daniel Thau 9 | * 10 | * This program sets/unsets the locks on a given terminal. See tty_ioctl(4). 11 | */ 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | void print_help() 25 | { 26 | printf("" 27 | "Usage: manage_stty_lock [lock|unlock] [tty]\n" 28 | "Requires root.\n" 29 | "\n" 30 | "To lock a terminal, use `lock` as the first argument. To unlock one, use\n" 31 | "`unlock` as the first argument. The second argument can be utilized to specify\n" 32 | "which terminal to lock/unlock; if it is left unset, the current terminal is\n" 33 | "utilized.\n" 34 | "\n" 35 | "Example, locking /dev/pts/1:\n" 36 | "\n" 37 | " manage_stty_lock lock /dev/pts/1\n" 38 | "\n" "Example, unlocking the current terminal:\n" "\n Example: manage_stty_lock unlock\n"); 39 | } 40 | 41 | int lock_tty(int fd) 42 | { 43 | /* 44 | * Non-zero bits indicate a field to lock. Since we're locking 45 | * everything, set everything to non-zero. 46 | */ 47 | 48 | struct termios term; 49 | memset(&term, 0xff, sizeof(term)); 50 | 51 | errno = 0; 52 | if (ioctl(fd, TIOCSLCKTRMIOS, &term) < 0) { 53 | perror("ioctl error"); 54 | } 55 | 56 | return errno; 57 | } 58 | 59 | int unlock_tty(int fd) 60 | { 61 | /* 62 | * Non-zero bits indicate a field to lock. Since we're unlocking 63 | * everything, set everything to zero. 64 | */ 65 | 66 | struct termios term; 67 | memset(&term, 0, sizeof(term)); 68 | 69 | errno = 0; 70 | if (ioctl(fd, TIOCSLCKTRMIOS, &term) < 0) { 71 | perror("ioctl error"); 72 | } 73 | 74 | return errno; 75 | } 76 | 77 | int main(int argc, char *argv[]) 78 | { 79 | if (argc < 2) { 80 | fprintf(stderr, "Insufficient arguments\n"); 81 | return EINVAL; 82 | } 83 | 84 | if (!strcmp(argv[1], "-h") || !strcmp(argv[1], "--help")) { 85 | print_help(); 86 | return 0; 87 | } 88 | 89 | int fd = 0; 90 | if (argc >= 3) { 91 | fd = open(argv[2], O_RDONLY); 92 | if (fd < 0) { 93 | fprintf(stderr, "Unable to open specified tty \"%s\"\n", argv[2]); 94 | return EBADF; 95 | } 96 | } 97 | 98 | if (!strcmp(argv[1], "lock")) { 99 | return lock_tty(fd); 100 | } else if (!strcmp(argv[1], "unlock")) { 101 | return unlock_tty(fd); 102 | } else { 103 | printf("Unrecognized argument \"%s\"\n", argv[1]); 104 | return EINVAL; 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /src/patches/busybox-x-opt.patch: -------------------------------------------------------------------------------- 1 | From 98f49ddcfbbeeda32de65aefeeb529a8e2aa5281 Mon Sep 17 00:00:00 2001 2 | From: Daniel Thau 3 | Date: Sun, 9 May 2021 10:37:58 -0400 4 | Subject: [PATCH] mount: support "X-" and "x-" options 5 | 6 | util-linux supports userspace application-specific capital "X-" mount 7 | options which serve as /etc/fstab comments. They should be ignored by 8 | mount and should not be passed to mount(2). 9 | 10 | util-linux also supports userspace application-specific lowercase "x-" 11 | mount options which serve as comments both in /etc/fstab and 12 | /run/mount/utab. Similar to "X-", they should not be passed to 13 | mount(2). Had busybox support for /run/mount/utab, they should be 14 | stored there; since busybox does not, they are simply ignored 15 | completely. 16 | 17 | This is commonly used by systemd, e.g. "x-systemd.device-timeout=0". 18 | --- 19 | util-linux/mount.c | 6 ++++++ 20 | 1 file changed, 6 insertions(+) 21 | 22 | diff --git a/util-linux/mount.c b/util-linux/mount.c 23 | index 831dab9e2..e26db33ed 100644 24 | --- a/util-linux/mount.c 25 | +++ b/util-linux/mount.c 26 | @@ -347,6 +347,8 @@ static const int32_t mount_options[] ALIGN4 = { 27 | IF_DESKTOP(/* "nofail" */ MOUNT_NOFAIL,) 28 | /* "_netdev" */ 0, 29 | IF_DESKTOP(/* "comment=" */ 0,) /* systemd uses this in fstab */ 30 | + IF_DESKTOP(/* "X-" */ 0,) /* fstab comment */ 31 | + IF_DESKTOP(/* "x-" */ 0,) /* fstab and utab comment */ 32 | ) 33 | 34 | IF_FEATURE_MOUNT_FLAGS( 35 | @@ -410,6 +412,8 @@ static const char mount_option_str[] ALIGN1 = 36 | IF_DESKTOP("nofail\0") 37 | "_netdev\0" 38 | IF_DESKTOP("comment=\0") /* systemd uses this in fstab */ 39 | + IF_DESKTOP("X-\0") /* fstab comment */ 40 | + IF_DESKTOP("x-\0") /* fstab and utab comment */ 41 | ) 42 | IF_FEATURE_MOUNT_FLAGS( 43 | // vfs flags 44 | @@ -610,6 +614,8 @@ static unsigned long parse_mount_options(char *options, char **unrecognized) 45 | && (options[opt_len] == '\0' 46 | /* or is it "comment=" thingy in fstab? */ 47 | IF_FEATURE_MOUNT_FSTAB(IF_DESKTOP( || option_str[opt_len-1] == '=' )) 48 | + /* or is it a "X-" or "x-" fstab comment? */ 49 | + IF_FEATURE_MOUNT_FSTAB(IF_DESKTOP( || strcasecmp(option_str, "x-") == 0)) 50 | ) 51 | ) { 52 | unsigned long fl = mount_options[i]; 53 | -- 54 | 2.20.1 55 | 56 | -------------------------------------------------------------------------------- /src/plymouth-quit/Makefile: -------------------------------------------------------------------------------- 1 | # plymouth-quit makefile 2 | # 3 | # This program is free software; you can redistribute it and/or 4 | # modify it under the terms of the GNU General Public License 5 | # version 2 as published by the Free Software Foundation. 6 | # 7 | # Copyright (c) 2020 Daniel Thau 8 | 9 | all: plymouth-quit 10 | 11 | plymouth-quit: plymouth-quit.c 12 | $(CC) $(CFLAGS) -std=c99 plymouth-quit.c -o plymouth-quit 13 | 14 | clean: 15 | rm -f plymouth-quit 16 | 17 | install: 18 | mkdir -p $(prefix)/sbin 19 | install -m 755 plymouth-quit $(prefix)/sbin/plymouth-quit 20 | 21 | uninstall: 22 | rm -f $(prefix)/sbin/plymouth-quit 23 | -------------------------------------------------------------------------------- /src/plymouth-quit/README.md: -------------------------------------------------------------------------------- 1 | plymouth-quit 2 | ============= 3 | 4 | Tells plymouth to quit 5 | 6 | Usage 7 | ----- 8 | 9 | Simply run the executable. 10 | 11 | Installation 12 | ------------ 13 | 14 | Bedrock Linux should be distributed with a script which handles installation, 15 | but just in case: 16 | 17 | To compile, run 18 | 19 | make 20 | 21 | To install into installdir, run 22 | 23 | make prefix= install 24 | 25 | To clean up, like usual: 26 | 27 | make clean 28 | 29 | And finally, to remove it, run: 30 | 31 | make prefix= uninstall 32 | -------------------------------------------------------------------------------- /src/plymouth-quit/plymouth-quit.c: -------------------------------------------------------------------------------- 1 | /* 2 | * plymouth-quit.c 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License 6 | * version 2 as published by the Free Software Foundation. 7 | * 8 | * Copyright (c) 2020 Daniel Thau 9 | * 10 | * Tells plymouth to quit. 11 | */ 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | #define PLYMOUTH_ABSTRACT_SOCKET_PATH "/org/freedesktop/plymouthd" 21 | #define PLYMOUTH_QUIT_CHAR 'Q' 22 | 23 | int main(int argc, char *argv[]) 24 | { 25 | (void)argc; 26 | (void)argv; 27 | 28 | int fd = socket(AF_UNIX, SOCK_STREAM, 0); 29 | if (fd < 0) { 30 | perror("socket"); 31 | return -1; 32 | } 33 | 34 | struct sockaddr_un addr; 35 | memset(&addr, 0, sizeof(addr)); 36 | addr.sun_family = AF_UNIX; 37 | addr.sun_path[0] = '\0'; 38 | strncpy(addr.sun_path + 1, PLYMOUTH_ABSTRACT_SOCKET_PATH, strlen(PLYMOUTH_ABSTRACT_SOCKET_PATH) + 1); 39 | 40 | if (connect(fd, (struct sockaddr *)&addr, sizeof(addr) - 81) < 0) { 41 | switch (errno) { 42 | case ECONNREFUSED: 43 | /* 44 | * Plymouth isn't running 45 | */ 46 | return 0; 47 | default: 48 | perror("connect"); 49 | return -1; 50 | } 51 | } 52 | 53 | char buf[4]; 54 | buf[0] = PLYMOUTH_QUIT_CHAR; 55 | buf[1] = '\2'; 56 | buf[2] = '\1'; 57 | buf[3] = '\0'; 58 | write(fd, buf, sizeof(buf)); 59 | return 0; 60 | } 61 | -------------------------------------------------------------------------------- /src/slash-bedrock/bin/brl: -------------------------------------------------------------------------------- 1 | #!/bedrock/libexec/busybox sh 2 | # 3 | # brl 4 | # 5 | # This program is free software; you can redistribute it and/or 6 | # modify it under the terms of the GNU General Public License 7 | # version 2 as published by the Free Software Foundation. 8 | # 9 | # Copyright (c) 2012-2019 Daniel Thau 10 | # 11 | # This program manages and provides information about a Bedrock Linux install 12 | # and its subsystems. 13 | 14 | . /bedrock/share/common-code 15 | 16 | print_help() { 17 | printf "Usage: ${color_cmd}brl ${color_sub} [arguments]${color_norm} 18 | 19 | ${color_bedrock}Bedrock Linux${color_norm} system management and introspection. 20 | 21 | Common commands: 22 | ${color_cmd}strat ${color_norm}Run specified ${color_term}stratum${color_norm}'s executable 23 | ${color_cmd} ${color_norm}Note: ${color_cmd}\`strat\`${color_norm} is available without the ${color_cmd}\`brl\`${color_norm} prefix 24 | ${color_cmd}list ${color_norm}List ${color_term}strata${color_norm} 25 | ${color_cmd}which ${color_norm}Query which ${color_term}stratum${color_norm} provides object 26 | 27 | ${color_term}Strata${color_norm} management commands: 28 | ${color_cmd}fetch ${color_term}Fetch${color_norm} new ${color_term}strata${color_norm} 29 | ${color_cmd}import ${color_term}Import${color_norm} new ${color_term}strata${color_norm} 30 | ${color_cmd}remove ${color_norm}Remove ${color_term}strata${color_norm} (or ${color_term}aliases${color_norm}) 31 | ${color_cmd}rename ${color_norm}Rename a ${color_term}stratum${color_norm} 32 | ${color_cmd}copy ${color_norm}Copy a ${color_term}stratum${color_norm} 33 | 34 | ${color_term}Strata${color_norm} status management commands: 35 | ${color_cmd}status ${color_norm}Query ${color_term}stratum${color_norm} status 36 | ${color_cmd}enable ${color_norm}${color_term}Enable${color_norm} ${color_term}strata${color_norm} 37 | ${color_cmd}disable ${color_norm}${color_term}Disable${color_norm} ${color_term}strata${color_norm} 38 | ${color_cmd}repair ${color_norm}Repairs ${color_term}broken${color_norm} ${color_term}strata${color_norm} 39 | 40 | ${color_term}Strata${color_norm} visibility management commands: 41 | ${color_cmd}hide ${color_norm}${color_term}Hide${color_norm} ${color_term}strata${color_norm} 42 | ${color_cmd}show ${color_norm}${color_term}Show${color_norm} ${color_term}strata${color_norm} 43 | 44 | ${color_term}Alias${color_norm} management commands: 45 | ${color_cmd}alias ${color_norm}Create a ${color_term}stratum${color_norm} ${color_term}alias${color_norm} 46 | ${color_cmd}deref ${color_norm}Dereference ${color_term}stratum${color_norm} ${color_term}aliases${color_norm} 47 | 48 | Miscellaneous commands: 49 | ${color_cmd}apply ${color_norm}Apply configuration changes 50 | ${color_cmd}update ${color_norm}Update ${color_bedrock}Bedrock Linux${color_norm} system 51 | ${color_cmd}version ${color_norm}Query ${color_bedrock}Bedrock Linux${color_norm} version 52 | ${color_cmd}report ${color_norm}Generate report 53 | ${color_cmd}tutorial ${color_norm}Run interactive ${color_bedrock}Bedrock Linux${color_norm} tutorial 54 | 55 | See ${color_cmd}\`brl ${color_sub}${color_cmd} --help\`${color_norm} for further details per command. 56 | " 57 | } 58 | 59 | case "${1:-}" in 60 | "-h" | "--help" | "help" | "") 61 | print_help 62 | exit_success 63 | ;; 64 | "strat" | "list" | "which" | "fetch" | "import" | "remove" | "rename" | "copy" | "status" | "enable" | "disable" | "repair" | "hide" | "show" | "alias" | "deref" | "apply" | "update" | "version" | "report" | "tutorial") 65 | backend="/bedrock/libexec/brl-${1}" 66 | shift 67 | exec "${backend}" "${@}" 68 | abort "Unable to execute \`${backend}\`" 69 | ;; 70 | *) 71 | abort "Unrecognized brl subcommand. See \`${0} --help\`" 72 | ;; 73 | esac 74 | 75 | exit_success 76 | -------------------------------------------------------------------------------- /src/slash-bedrock/etc/os-release: -------------------------------------------------------------------------------- 1 | NAME="Bedrock Linux" 2 | ID=bedrock 3 | ID_LIKE=bedrocklinux 4 | VERSION= 5 | VERSION_ID= 6 | PRETTY_NAME= 7 | HOME_URL="https://bedrocklinux.org" 8 | -------------------------------------------------------------------------------- /src/slash-bedrock/etc/world: -------------------------------------------------------------------------------- 1 | # 2 | # Package Manager Manager world file 3 | # 4 | # This file is expected to contain a list of 5 | # 6 | # : 7 | # 8 | # entries which `pmm` can utilize synchronize against the system's list of 9 | # explicitly installed packages. A given line may contain multiple white space 10 | # separated package names. For example: 11 | # 12 | # ### Bedrock Linux `make check` dependencies 13 | # # compilers 14 | # arch:pacman gcc clang 15 | # # static check tools 16 | # arch:pacman cppcheck shellcheck 17 | # # formatting tools 18 | # arch:pacman indent shfmt 19 | # # libraries 20 | # arch:pacman fuse3 uthash 21 | # 22 | # See `pmm --help | grep world` for a list of world file 23 | # operations. 24 | # 25 | 26 | -------------------------------------------------------------------------------- /src/slash-bedrock/gnupg-keys/paradigm.gpg: -------------------------------------------------------------------------------- 1 | -----BEGIN PGP PUBLIC KEY BLOCK----- 2 | 3 | mQINBFM8nLkBEADmFjFEW2HUC1Z4YF8ij4hI/3/QI8Qbecax8bwfQcxQDjMmSNrN 4 | V51lon4Ww2B2dGVBtBtpqcGtS8fyTWP1MvOnJ0QyEO0wygv1GmUAkAzo2BMKm20k 5 | DPQEU1hk5R3QRpSC27WXQHklfr8OXb7YyKalV8gcpeIwX0rJll4to247fhmUDZ1H 6 | zrMZ1xd2WLHsmMhsUfcr2Ivg+olR+bSBYXa4sV8kWGTRE4DGXDt39oEClFhyoKif 7 | KrAwCueQlyW9h+PKbzVvh4hDRm+Ql8UUOXUn7f18+KMAcck1f9gEI1NKYR5Bho02 8 | yYdMrA2ohiEmFqJRPGxruSChHY1hv9PyD8e2dAjg7amdqIu9tP1Yue7i2iDzDIyV 9 | 3yc59dbec7gFaKuCNEuyg/uycyFiNO24Luof0Icb8LKBePqGiJr+U08T7Gkgqmms 10 | YksGAi99vhafd6KGHIH8kGcI/ugVdmn2stqPTG0Tu3BpPrB0dR1Zor/ILE4Iv4M4 11 | TmNdnWrWRA/Y4ueuqFEsM+p8zwv+QBLXqx7a/Xni6OSvMA4z/pN8bc+Z2pwB5r8V 12 | phedtxVZ5EslwjZOgAfOLEu4nZiGnSWazrmEOIwpD0aEwklFkLEcX9Bi+pTyOCPe 13 | 3RNtHHp2kUlz4oQdTR9I+4be9qCKh8DicOLhFB19icnoN0sXt+q9UTxt+QARAQAB 14 | tDFEYW5pZWwgVGhhdSAocGFyYWRpZ20pIDxkYW50aGF1QGJlZHJvY2tsaW51eC5v 15 | cmc+iQJVBBMBAgA/AhsDBgsJCAcDAgYVCAIJCgsEFgIDAQIeAQIXgBYhBLebcnTR 16 | OrCfZoPlWA8lNQyY97IHBQJdWHaKBQkRoKfRAAoJEA8lNQyY97IHbkIQANU+Bf6F 17 | KPeyBZKdOBzpdpPVKIhoeV8G7ahjkGo2Cnm3GsWRXMW0uQKBWiT+GhirfVzR05w+ 18 | QZ69y84InKG7sGAF0AOkPbZJFAEEVGSWGpmgjpFsOGW1v0VsA+s77LnYokFu2U6S 19 | 0iOQIqAq0ly24+hrBymyEl1LuGHjKphcfI+x5BcE0HbUb16rE196Gqcr+uHBCXy0 20 | 5I1GbR9qtYd7LKHyKbqQg340wVu4RBKfutEvcaarPDwm/kLVGXaOlqYzOqxMtVDp 21 | WB9NmPzIdpf1EQWiyg91Jn3cZibe+RjjxS1kqjx03xl/zHjq7vwRJDshD8tMHCYS 22 | m222I1JfLKejpiOyqOPcCNFENOCsI9g4dVclb+EHlYQ2XbErhMSvsjWe1P8eWka1 23 | O3U5k2P31mXQkvN3VBVxAb7d/ad4rIj5AFMbTiAWjH9GYdiL5HAissXiCevOATyC 24 | ARmsGU5vJ+jqQ/L3dgX3hRkvqV84pSl3Sut3LQISbh9KI/HS5NJ4d7sDOtxOZIxz 25 | tYrBzw1gIK4QHiTdWmGU41vPyN+YlfOeYwhaN6z9lWEa7oQcoLVApMsmBMYzzS+f 26 | sbDo22IgtsU5LGR4wd9w+2pSby3e6i62NIhvEPwgDKOUSplGdUZByCYniv9VFlSw 27 | 0xUYpYCNMFi38cxl5cdfa9byy6SIAXKZpiAuuQINBFM8nLkBEADi3uIVcHvvovA7 28 | AEskKU5HeqJYv/tFeN8Z8VeYrh4o3VyvhjW+yVAYwjWvVAYLiW9LyX/tQfLXVC25 29 | Hzyghf7OU9Fjvil84OmfatAdYQssQeGIDb+QWUzQx7GTGRpO/JMOxUXoLVjCAuAm 30 | GlfTjbjqgmnS57tYRvkZjwVI47Q2R1d70da2fKPlwE8bCesRd0GyaCvSMdztCmgR 31 | LCa6zTZGWPTic6ej54kxA388BE7zUlp6trSe5QkQNv9gmBBsm8uMEZw54EMjnUmq 32 | JR855yPM2M9HQ0CCjtde4XmdqIn2ykAu25XnmPEly1Xadux+2LTauPrfeBvBQRrm 33 | yK8A4/xcJ0Z2IT5ShQ1POZbzeMdqTEP2zBt/vwho0RaguSUctCv8WeEHA9gkgfI4 34 | gP2mSpGonsHj8Tv0S1UnsAJbO7+1orui2uCA/yFVzzwK4w9e+QJRK3Ovy7m1ds/C 35 | 4v4yxmZRrX7DuYuQdtvhLFEDALGXBV/aCM5NQGo9HA8+OyhY7FLr8cflHbOWgTMp 36 | p/B71ZUkyKv4qyYxv1keJlf5Dny67FHCBGr+iNw7c7qRkI/PQyzYPk87HjBvSPYo 37 | WILuky9UWs4anefJss6h9so1Ns99oAbgxJjlRtCg+9gmTg01+NCTB2HD4dpIuo8r 38 | 3oimkANOJF9qEwjqNimi81a0uJmBGQARAQABiQI8BBgBAgAmAhsMFiEEt5tydNE6 39 | sJ9mg+VYDyU1DJj3sgcFAl1YdscFCRGgqA4ACgkQDyU1DJj3sgcGcRAAmpmgmqlX 40 | Mt0T62chqUGdP3TrwzIq0Xl6zc7lxAGu3WJerGAPnSCnRiq3PdkRSs0Oz0XQCK42 41 | LnmPoZeRoHJCWdtG3v0JCy6TlV/13vG56Fi/CFJ7LX/fectgXxdRXfOZjPyxBccj 42 | cUuVnbF2NUoAhDWCn+P7Cc2Gu2ZbAR+usP91cgooH38vlHx97eP5Z/wdjY4ltznG 43 | oZz9hC6de/6Gi9VZYSzqUjeWSK4s/Ah5oo3v4j3/oOv6Q3Tv0jAfRlv0dYDHGZiS 44 | 5BcN6zu69waI1H1SMCkfYncUOEiafNdsKwKlwxHfgh0FKISS+ot4D/5b9XYJ5YNJ 45 | 7mMm9zIv2IDLQPMAh5KFmISP+6KlIXFL6to7X0xFuBpzdlBJETLgMKD2xM/yPYnj 46 | Z294Dx54tzp91UDaDtUCSNgzmZ36F97aWCWdgJPPVfsQY0l4wMIpGHN0de26CyH8 47 | /OL3tjqPTfkWskgYBjb1uibd+fL41MQwRHjLwFVotlGGM9SPAkz1rbm58re5Hq3c 48 | 7aBskBLvheJd/s4WAqaApxs4iaQ8BB0IuIuzq3zDDtVrvAM3j1DyoKiKLeS40lTw 49 | 9r2XlOa2IJBXmaA3i8UENGJbvXR1nsJBwWXlkwjjMxJ/U/X0rFbdyMtd+zY8B03T 50 | pDFSUaW25oAiCPhToTk5q2F5nl/VzMhgXd8= 51 | =vp73 52 | -----END PGP PUBLIC KEY BLOCK----- 53 | -------------------------------------------------------------------------------- /src/slash-bedrock/libexec/brl-alias: -------------------------------------------------------------------------------- 1 | #!/bedrock/libexec/busybox sh 2 | # 3 | # brl alias 4 | # 5 | # This program is free software; you can redistribute it and/or 6 | # modify it under the terms of the GNU General Public License 7 | # version 2 as published by the Free Software Foundation. 8 | # 9 | # Copyright (c) 2018 Daniel Thau 10 | # 11 | # Create stratum aliases. 12 | 13 | . /bedrock/share/common-code 14 | 15 | print_help() { 16 | printf "Usage: ${color_cmd}brl alias ${color_sub}[options] ${color_norm} 17 | 18 | Creates an ${color_term}alias${color_norm}. References to this ${color_term}alias${color_norm} can be used in place of the ${color_term}stratum${color_norm} 19 | name in most contexts. Requires root. 20 | 21 | Options: 22 | ${color_cmd}-h${color_norm}, ${color_cmd}--help${color_norm} print this message 23 | 24 | Example: 25 | ${color_rcmd}# brl fetch fedora --release 27 --name fedora27 26 | ${color_cmd}$ brl list | grep fedora 27 | ${color_strat}fedora27 28 | ${color_rcmd}# brl alias fedora27 fedora 29 | ${color_cmd}$ brl deref fedora 30 | ${color_strat}fedora27 31 | ${color_cmd}$ brl status fedora 32 | ${color_strat}fedora27${color_norm}: ${color_okay}enabled 33 | ${color_cmd}$ cat /bedrock/strata/fedora27/etc/fedora-release 34 | ${color_norm}Fedora release 27 (Twenty Seven) 35 | ${color_cmd}$ cat /bedrock/strata/fedora/etc/fedora-release 36 | ${color_norm}Fedora release 27 (Twenty Seven) 37 | ${color_cmd}$ strat fedora27 cat /etc/fedora-release 38 | ${color_norm}Fedora release 27 (Twenty Seven) 39 | ${color_cmd}$ strat fedora cat /etc/fedora-release 40 | ${color_norm}Fedora release 27 (Twenty Seven) 41 | ${color_norm}" 42 | } 43 | 44 | handle_help "${@:-}" 45 | min_args "${#}" "2" 46 | stratum="${1}" 47 | alias="${2}" 48 | 49 | require_root 50 | lock 51 | 52 | ensure_legal_stratum_name "${alias}" 53 | 54 | if ! is_stratum "${stratum}"; then 55 | abort "No (non-alias) stratum found called \"${stratum}\". Refusing to make broken alias." 56 | elif is_stratum_or_alias "${alias}"; then 57 | abort "Pre-existing stratum or alias found called \"${alias}\". Remove with \`brl remove ${alias}\` first if you wish to change it." 58 | fi 59 | 60 | ln -s "${stratum}" "/bedrock/strata/${alias}" 61 | 62 | exit_success 63 | -------------------------------------------------------------------------------- /src/slash-bedrock/libexec/brl-copy: -------------------------------------------------------------------------------- 1 | #!/bedrock/libexec/busybox sh 2 | # 3 | # brl copy 4 | # 5 | # This program is free software; you can redistribute it and/or 6 | # modify it under the terms of the GNU General Public License 7 | # version 2 as published by the Free Software Foundation. 8 | # 9 | # Copyright (c) 2018-2019 Daniel Thau 10 | # 11 | # Copies strata. 12 | 13 | . /bedrock/share/common-code 14 | 15 | print_help() { 16 | printf "Usage: ${color_cmd}brl copy ${color_sub}[options] ${color_norm} 17 | 18 | Copies a disabled ${color_term}stratum${color_norm}. Requires root. 19 | 20 | Options: 21 | ${color_cmd}-h${color_norm}, ${color_cmd}--help${color_norm} print this message 22 | 23 | Examples: 24 | ${color_rcmd}# brl fetch ubuntu 25 | ${color_cmd}$ brl list | grep ubu 26 | ${color_strat}ubuntu 27 | ${color_rcmd}# brl disable ubuntu 28 | ${color_rcmd}# brl copy ubuntu ubu-lts 29 | ${color_cmd}$ brl list -a | grep ubu 30 | ${color_strat}ubuntu 31 | ${color_strat}ubu-lts 32 | ${color_rcmd}# strat ubuntu apt dist-upgrade 33 | ${color_norm}" 34 | } 35 | 36 | handle_help "${@:-}" 37 | min_args "${#}" "2" 38 | alias="${1}" 39 | new_stratum="${2}" 40 | 41 | require_root 42 | lock 43 | 44 | ensure_legal_stratum_name "${new_stratum}" 45 | 46 | if ! is_stratum_or_alias "${alias}"; then 47 | abort "No stratum or alias found called \"${alias}\"." 48 | elif ! stratum="$(deref "${alias}")"; then 49 | abort "Unable to dereference \"${alias}\"." 50 | elif is_enabled "${stratum}"; then 51 | abort "Cannot copy enabled stratum. Disable first." 52 | elif is_stratum_or_alias "${new_stratum}"; then 53 | abort "Pre-existing stratum or alias found called \"${new_stratum}\". Remove with \`brl remove ${new_stratum}\` first if you wish to change it." 54 | fi 55 | 56 | if is_stratum "${stratum}"; then 57 | disable_stratum "${stratum}" 58 | fi 59 | cp -a "/bedrock/strata/${stratum}" "/bedrock/strata/${new_stratum}" 60 | 61 | for xattr in "show_boot" "show_cross" "show_init" "show_list"; do 62 | if has_attr "/bedrock/strata/${stratum}" "${xattr}"; then 63 | set_attr "/bedrock/strata/${new_stratum}" "${xattr}" "" 64 | fi 65 | done 66 | 67 | exit_success 68 | -------------------------------------------------------------------------------- /src/slash-bedrock/libexec/brl-deref: -------------------------------------------------------------------------------- 1 | #!/bedrock/libexec/busybox sh 2 | # 3 | # brl deref 4 | # 5 | # This program is free software; you can redistribute it and/or 6 | # modify it under the terms of the GNU General Public License 7 | # version 2 as published by the Free Software Foundation. 8 | # 9 | # Copyright (c) 2018 Daniel Thau 10 | # 11 | # Dereference stratum aliases. 12 | 13 | . /bedrock/share/common-code 14 | 15 | print_help() { 16 | printf "Usage: ${color_cmd}brl deref ${color_sub}[options] ${color_norm} 17 | 18 | Dereferences ${color_term}aliases${color_norm}. Dereferencing a non-${color_term}alias${color_norm} ${color_term}stratum${color_norm} returns the ${color_term}stratum${color_norm}. 19 | 20 | Options: 21 | ${color_cmd}-h${color_norm}, ${color_cmd}--help${color_norm} print this message 22 | 23 | Example: 24 | ${color_rcmd}# brl fetch fedora --release 27 --name fedora27 25 | ${color_rcmd}# brl fetch debian --release unstable --name sid 26 | ${color_rcmd}# brl alias fedora27 fedora 27 | ${color_rcmd}# brl alias sid unstable 28 | ${color_cmd}$ brl deref fedora 29 | ${color_strat}fedora27 30 | ${color_cmd}$ brl deref fedora27 31 | ${color_strat}fedora27 32 | ${color_cmd}$ brl deref unstable 33 | ${color_strat}sid 34 | ${color_cmd}$ brl deref sid 35 | ${color_strat}sid 36 | ${color_norm}" 37 | } 38 | 39 | handle_help "${@:-}" 40 | min_args "${#}" "1" 41 | 42 | for alias in "${@}"; do 43 | if ! is_stratum_or_alias "${alias}"; then 44 | abort "No stratum or alias called \"${alias}\"." 45 | elif ! stratum="$(deref "${alias}")"; then 46 | abort "Unable to dereference \"${alias}\"." 47 | else 48 | printf "${color_strat}%s${color_norm}\\n" "${stratum}" 49 | fi 50 | done 51 | 52 | exit_success 53 | -------------------------------------------------------------------------------- /src/slash-bedrock/libexec/brl-disable: -------------------------------------------------------------------------------- 1 | #!/bedrock/libexec/busybox sh 2 | # 3 | # brl disable 4 | # 5 | # This program is free software; you can redistribute it and/or 6 | # modify it under the terms of the GNU General Public License 7 | # version 2 as published by the Free Software Foundation. 8 | # 9 | # Copyright (c) 2012-2018 Daniel Thau 10 | # 11 | # De-integrates strata from the system. 12 | 13 | . /bedrock/share/common-code 14 | 15 | print_help() { 16 | printf "Usage: ${color_cmd}brl disable ${color_sub}[options] ${color_norm} 17 | 18 | De-integrates ${color_term}strata${color_norm} from the system. 19 | 20 | Options: 21 | ${color_cmd}-h${color_norm}, ${color_cmd}--help${color_norm} print this message 22 | 23 | Examples: 24 | ${color_cmd}$ brl status solus 25 | ${color_strat}solus${color_norm}: ${color_okay}enabled 26 | ${color_rcmd}# brl disable solus 27 | ${color_cmd}$ brl status solus 28 | ${color_norm}disabled 29 | ${color_rcmd}# brl disable alpine arch centos 30 | ${color_cmd}$ brl status alpine arch centos 31 | ${color_strat}alpine${color_norm}: ${color_norm}disabled 32 | ${color_strat}arch${color_norm}: ${color_norm}disabled 33 | ${color_strat}centos${color_norm}: ${color_norm}disabled 34 | ${color_norm}" 35 | } 36 | 37 | handle_help "${@:-}" 38 | min_args "${#}" "1" 39 | 40 | require_root 41 | lock 42 | 43 | for alias in "${@}"; do 44 | if ! is_stratum_or_alias "${alias}"; then 45 | abort "No stratum or alias called \"${alias}\"." 46 | elif ! stratum="$(deref "${alias}")"; then 47 | abort "Unable to dereference \"${alias}\"." 48 | elif is_init "${stratum}"; then 49 | abort "Cannot disable init-providing stratum." 50 | elif is_bedrock "${stratum}"; then 51 | abort "Cannot disable bedrock stratum." 52 | else 53 | disable_stratum "${stratum}" 54 | fi 55 | done 56 | 57 | exit_success 58 | -------------------------------------------------------------------------------- /src/slash-bedrock/libexec/brl-enable: -------------------------------------------------------------------------------- 1 | #!/bedrock/libexec/busybox sh 2 | # 3 | # brl enable 4 | # 5 | # This program is free software; you can redistribute it and/or 6 | # modify it under the terms of the GNU General Public License 7 | # version 2 as published by the Free Software Foundation. 8 | # 9 | # Copyright (c) 2012-2019 Daniel Thau 10 | # 11 | # Integrates strata into the system. 12 | 13 | . /bedrock/share/common-code 14 | 15 | print_help() { 16 | printf "Usage: ${color_cmd}brl enable ${color_sub}[options] ${color_norm} 17 | 18 | Integrates ${color_term}disabled${color_norm} ${color_term}strata${color_norm} into the system. Requires root. 19 | 20 | Options: 21 | ${color_cmd}-h${color_norm}, ${color_cmd}--help${color_norm} print this message 22 | 23 | Examples: 24 | ${color_cmd}$ brl status solus 25 | ${color_strat}solus${color_norm}: disabled 26 | ${color_rcmd}# brl enable solus 27 | ${color_cmd}$ brl status solus 28 | ${color_strat}solus${color_norm}: ${color_okay}enabled 29 | ${color_rcmd}# brl enable solus 30 | ${color_alert}ERROR: \"solus\" is already enabled. Consider \`brl repair\` to fix a broken stratum. 31 | ${color_rcmd}# brl enable alpine arch centos 32 | ${color_cmd}$ brl status alpine arch centos 33 | ${color_strat}alpine${color_norm}: ${color_okay}enabled 34 | ${color_strat}arch${color_norm}: ${color_okay}enabled 35 | ${color_strat}centos${color_norm}: ${color_okay}enabled 36 | ${color_norm}" 37 | } 38 | 39 | handle_help "${@:-}" 40 | min_args "${#}" "1" 41 | 42 | require_root 43 | lock 44 | 45 | enable_stratum() { 46 | stratum="${1}" 47 | root="$(stratum_root "${stratum}")" 48 | br_root="/bedrock/strata/bedrock" 49 | 50 | # Set an attribute on the stratum's root indicating to which stratum it 51 | # belongs. This allows processes to look up their stratum by reading 52 | # the attribute off of their root directory. 53 | if ! cur_attr="$(get_attr "/proc/1/root/${root}" "stratum" 2>/dev/null)" || [ "${cur_attr}" != "${stratum}" ]; then 54 | set_attr "/proc/1/root/${root}" "stratum" "${stratum}" 55 | fi 56 | 57 | # Ensure the stratum's root directory is a mount point. 58 | stinit busybox mount --bind "${root}" "${root}" 59 | 60 | for mnt in $(cfg_values "global" "share"); do 61 | stinit busybox mkdir -p "${br_root}${mnt}" "${root}${mnt}" 62 | stinit busybox mount --make-rshared "${br_root}${mnt}" 2>/dev/null || true 63 | stinit busybox mount --rbind "${br_root}${mnt}" "${root}${mnt}" 64 | stinit busybox mount --make-rshared "${root}${mnt}" 65 | done 66 | 67 | for mnt in $(cfg_values "global" "bind"); do 68 | stinit busybox mkdir -p "${br_root}${mnt}" "${root}${mnt}" 69 | stinit busybox mount --make-private "${br_root}${mnt}" 2>/dev/null || true 70 | stinit busybox mount --bind "${br_root}${mnt}" "${root}${mnt}" 71 | stinit busybox mount --make-private "${root}${mnt}" 72 | done 73 | 74 | ( 75 | drop_lock 76 | mkdir -p "/proc/1/root${root}/etc" 77 | if cfg_value "miscellaneous" "debug" | grep -q etcfs; then 78 | cache="/bedrock/var/cache/etcfs-${stratum}" 79 | lock --nonblock "${cache}" || true 80 | rm -f "${cache}/log" 81 | touch "${cache}/log" 82 | chmod go-rwx "${cache}/log" 83 | chroot "/proc/1/root${root}" /bedrock/libexec/etcfs -d -o allow_other "/etc" >>"${cache}/log" 2>&1 & 84 | sleep 1 85 | else 86 | chroot "/proc/1/root${root}" /bedrock/libexec/etcfs -o allow_other "/etc" 87 | fi 88 | cfg_etcfs "/proc/1/root${root}/etc" 89 | ) 90 | 91 | setup_binfmt_misc "${stratum}" 92 | 93 | enforce_symlinks "${stratum}" 94 | 95 | stinit busybox touch "/bedrock/strata/bedrock/bedrock/run/enabled_strata/${1}" 96 | 97 | enforce_shells 98 | enforce_id_ranges 99 | 100 | if ! "${skip_crossfs}"; then 101 | cfg_crossfs "/proc/1/root/bedrock/strata/bedrock/bedrock/cross" 102 | fi 103 | } 104 | 105 | skip_crossfs="false" 106 | if [ "${1:-}" = "--skip-crossfs" ]; then 107 | skip_crossfs="true" 108 | shift 109 | fi 110 | 111 | for alias in "${@}"; do 112 | if ! is_stratum_or_alias "${alias}"; then 113 | abort "No stratum or alias called \"${alias}\"." 114 | elif ! stratum="$(deref "${alias}")"; then 115 | abort "Unable to dereference \"${alias}\"." 116 | elif is_enabled "${stratum}"; then 117 | abort "\"${stratum}\" is already enabled. Consider \`brl repair\` to fix a broken stratum." 118 | elif is_bedrock "${stratum}" || is_init "${stratum}"; then 119 | abort "Cannot enable bedrock or init-providing stratum, as neither should ever be disabled." 120 | else 121 | disable_stratum "${stratum}" 122 | enable_stratum "${stratum}" 123 | fi 124 | done 125 | 126 | exit_success 127 | -------------------------------------------------------------------------------- /src/slash-bedrock/libexec/brl-hide: -------------------------------------------------------------------------------- 1 | #!/bedrock/libexec/busybox sh 2 | # 3 | # brl hide 4 | # 5 | # This program is free software; you can redistribute it and/or 6 | # modify it under the terms of the GNU General Public License 7 | # version 2 as published by the Free Software Foundation. 8 | # 9 | # Copyright (c) 2016-2020 Daniel Thau 10 | # 11 | # Marks strata to be hidden. 12 | 13 | . /bedrock/share/common-code 14 | 15 | print_help() { 16 | printf "Usage: ${color_cmd}brl hide ${color_sub}[options] ${color_norm} 17 | 18 | ${color_term}Hides${color_norm} ${color_term}strata${color_norm} from various ${color_bedrock}Bedrock Linux${color_norm} subsystems. Requires root. 19 | 20 | Options: 21 | ${color_sub}${color_norm} defaults to ${color_cmd}--all${color_norm} 22 | ${color_cmd}-a${color_norm},${color_cmd} --all ${color_norm}${color_term}hide${color_norm} ${color_term}stratum${color_norm} in all available subsystems 23 | ${color_cmd}-b${color_norm},${color_cmd} --boot ${color_norm}do not automatically ${color_term}enable${color_norm} ${color_term}stratum${color_norm} during boot 24 | ${color_cmd}-c${color_norm},${color_cmd} --cross ${color_norm}do not include ${color_term}stratum${color_norm}'s files in ${color_file}/bedrock/cross${color_norm} 25 | ${color_cmd}-i${color_norm},${color_cmd} --init ${color_norm}do not list ${color_term}stratum${color_norm}'s init options during boot 26 | ${color_cmd}-l${color_norm},${color_cmd} --list ${color_norm}do not list with ${color_cmd}\`brl list\`${color_norm} without ${color_cmd}\`-i\`${color_norm} flag. 27 | ${color_cmd}-p${color_norm},${color_cmd} --pmm ${color_norm}do not consider for ${color_cmd}\`pmm\`${color_norm} operations 28 | ${color_cmd}-h${color_norm},${color_cmd} --help ${color_norm}print this message 29 | 30 | Examples: 31 | ${color_cmd}$ brl list | grep centos 32 | ${color_strat}centos 33 | ${color_rcmd}# brl hide centos 34 | ${color_cmd}$ brl list | grep centos 35 | ${color_norm}" 36 | } 37 | 38 | handle_help "${@:-}" 39 | min_args "${#}" "1" 40 | 41 | hide_boot=false 42 | hide_cross=false 43 | hide_init=false 44 | hide_list=false 45 | hide_pmm=false 46 | strata="" 47 | 48 | OPTL="all,boot,cross,init,list,pmm,help" 49 | OPTO="abcilp" 50 | eval set -- "$(getopt -q -l "${OPTL}" -- "${OPTO}" "${@}")" || true 51 | saw_non_positional=false 52 | 53 | while [ -n "${1:-}" ]; do 54 | case "${1}" in 55 | -a | --all) 56 | hide_boot=true 57 | hide_cross=true 58 | hide_init=true 59 | hide_list=true 60 | hide_pmm=true 61 | shift 62 | ;; 63 | -b | --boot) 64 | hide_boot=true 65 | shift 66 | ;; 67 | -c | --cross) 68 | hide_cross=true 69 | shift 70 | ;; 71 | -i | --init) 72 | hide_init=true 73 | shift 74 | ;; 75 | -l | --list) 76 | hide_list=true 77 | shift 78 | ;; 79 | -p | --pmm) 80 | hide_pmm=true 81 | shift 82 | ;; 83 | --) 84 | shift 85 | ;; 86 | -*) 87 | if "${saw_non_positional}"; then 88 | eval set -- "$(getopt -q -l "${OPTL}" -- "${OPTO}" "${@}")" || true 89 | saw_non_positional=false 90 | else 91 | abort "Unrecognized argument: ${1}" 92 | fi 93 | ;; 94 | *) 95 | saw_non_positional=true 96 | strata="${strata} ${1}" 97 | shift 98 | ;; 99 | esac 100 | done 101 | 102 | if [ -z "${strata}" ]; then 103 | abort "No stratum or alias specified." 104 | fi 105 | 106 | # Default to --all if none are specified 107 | if ! "${hide_boot}" && 108 | ! "${hide_cross}" && 109 | ! "${hide_init}" && 110 | ! "${hide_list}" && 111 | ! "${hide_pmm}"; then 112 | hide_boot=true 113 | hide_cross=true 114 | hide_init=true 115 | hide_list=true 116 | hide_pmm=true 117 | fi 118 | 119 | lock 120 | 121 | for stratum in ${strata}; do 122 | if ! is_stratum_or_alias "${stratum}"; then 123 | abort "No stratum or alias named \"${stratum}\"." 124 | elif "${hide_boot}" && is_bedrock "${stratum}"; then 125 | abort "Cannot hide bedrock stratum from boot-time enabling. You may hide it from everything else, however. See --help for other options." 126 | fi 127 | "${hide_boot}" && rm_attr "/bedrock/strata/${stratum}" "show_boot" 128 | "${hide_cross}" && rm_attr "/bedrock/strata/${stratum}" "show_cross" 129 | "${hide_init}" && rm_attr "/bedrock/strata/${stratum}" "show_init" 130 | "${hide_list}" && rm_attr "/bedrock/strata/${stratum}" "show_list" 131 | "${hide_pmm}" && rm_attr "/bedrock/strata/${stratum}" "show_pmm" 132 | done 133 | 134 | if "${hide_cross}"; then 135 | cfg_crossfs "/proc/1/root/bedrock/strata/bedrock/bedrock/cross" 136 | fi 137 | 138 | exit_success 139 | -------------------------------------------------------------------------------- /src/slash-bedrock/libexec/brl-list: -------------------------------------------------------------------------------- 1 | #!/bedrock/libexec/busybox sh 2 | # 3 | # brl list 4 | # 5 | # This program is free software; you can redistribute it and/or 6 | # modify it under the terms of the GNU General Public License 7 | # version 2 as published by the Free Software Foundation. 8 | # 9 | # Copyright (c) 2012-2018 Daniel Thau 10 | # 11 | # List strata and aliases. 12 | 13 | . /bedrock/share/common-code 14 | 15 | print_help() { 16 | printf "Usage: ${color_cmd}brl list ${color_sub}[options]${color_norm} 17 | 18 | Lists ${color_term}strata${color_norm}. 19 | 20 | Options: 21 | ${color_sub}${color_norm} defaults to ${color_cmd}--enabled${color_norm} 22 | ${color_cmd}-e${color_norm},${color_cmd} --enabled-strata ${color_norm}${color_term}enabled${color_norm} ${color_term}stratum${color_norm} 23 | ${color_cmd}-E${color_norm},${color_cmd} --enabled-aliases ${color_norm}${color_term}aliases${color_norm} to ${color_term}enabled${color_norm} ${color_term}stratum${color_norm} 24 | ${color_cmd}-d${color_norm},${color_cmd} --disabled-strata ${color_norm}${color_term}disabled${color_norm} ${color_term}stratum${color_norm} 25 | ${color_cmd}-D${color_norm},${color_cmd} --disabled-aliases ${color_norm}${color_term}aliases${color_norm} to ${color_term}disabled${color_norm} ${color_term}stratum${color_norm} 26 | ${color_cmd}-a${color_norm},${color_cmd} --all-strata ${color_norm}all ${color_term}strata${color_norm} 27 | ${color_cmd}-A${color_norm},${color_cmd} --all-aliases ${color_norm}all ${color_term}aliases${color_norm} 28 | ${color_cmd}-r${color_norm},${color_cmd} --deref ${color_norm}dereference ${color_term}aliases${color_norm} 29 | ${color_cmd}-i${color_norm},${color_cmd} --include-hidden ${color_norm}include ${color_term}hidden strata${color_norm} in list 30 | may require pairing with ${color_cmd}-E${color_norm} or ${color_cmd}-a${color_norm} 31 | ${color_cmd}-v${color_norm},${color_cmd} --everything ${color_norm}equivalent to ${color_cmd}-aAir 32 | ${color_cmd}-h${color_norm},${color_cmd} --help ${color_norm}print this message 33 | 34 | Examples: 35 | ${color_cmd}$ brl list 36 | ${color_strat}arch 37 | ${color_strat}bedrock 38 | ${color_strat}gentoo 39 | ${color_strat}void 40 | ${color_cmd}$ brl list -Dr 41 | ${color_alias}unstable -> sid 42 | ${color_norm}" 43 | } 44 | 45 | handle_help "${@:-}" 46 | 47 | list_enabled_strata=false 48 | list_enabled_aliases=false 49 | list_disabled_strata=false 50 | list_disabled_aliases=false 51 | include_hidden=false 52 | deref_aliases=false 53 | 54 | OPTL="enabled-strata,enabled-aliases,disabled-strata,disabled-aliases,all-strata,all-aliases,deref,include-hidden,everything" 55 | OPTO="eEdDaAriv" 56 | eval set -- "$(getopt -q -l "${OPTL}" -- "${OPTO}" "${@}")" || true 57 | saw_non_positional=false 58 | 59 | while [ -n "${1:-}" ]; do 60 | case "${1}" in 61 | -e | --enabled-strata) 62 | list_enabled_strata=true 63 | shift 64 | ;; 65 | -E | --enabled-aliases) 66 | list_enabled_aliases=true 67 | shift 68 | ;; 69 | -d | --disabled-strata) 70 | list_disabled_strata=true 71 | shift 72 | ;; 73 | -D | --disabled-aliases) 74 | list_disabled_aliases=true 75 | shift 76 | ;; 77 | -a | --all-strata) 78 | list_enabled_strata=true 79 | list_disabled_strata=true 80 | shift 81 | ;; 82 | -A | --all-aliases) 83 | list_enabled_aliases=true 84 | list_disabled_aliases=true 85 | shift 86 | ;; 87 | -r | --deref) 88 | deref_aliases=true 89 | shift 90 | ;; 91 | -i | --include-hidden) 92 | include_hidden=true 93 | shift 94 | ;; 95 | -v | --everything) 96 | list_enabled_strata=true 97 | list_disabled_strata=true 98 | list_enabled_aliases=true 99 | list_disabled_aliases=true 100 | deref_aliases=true 101 | include_hidden=true 102 | shift 103 | ;; 104 | --) 105 | shift 106 | ;; 107 | -*) 108 | if "${saw_non_positional}"; then 109 | eval set -- "$(getopt -q -l "${OPTL}" -- "${OPTO}" "${@}")" || true 110 | saw_non_positional=false 111 | else 112 | abort "Unrecognized argument: ${1}" 113 | fi 114 | ;; 115 | *) 116 | abort "Unrecognized argument: ${1}" 117 | ;; 118 | esac 119 | done 120 | 121 | if ! "${list_enabled_strata}" && 122 | ! "${list_enabled_aliases}" && 123 | ! "${list_disabled_strata}" && 124 | ! "${list_disabled_aliases}"; then 125 | list_enabled_strata=true 126 | fi 127 | 128 | ( 129 | if "${list_enabled_strata}" || "${list_disabled_strata}"; then 130 | list_strata 131 | fi 132 | if "${list_enabled_aliases}" || "${list_disabled_aliases}"; then 133 | list_aliases 134 | fi 135 | ) | sort | while read -r stratum; do 136 | if ! "${include_hidden}" && ! has_attr "/bedrock/strata/$stratum" show_list; then 137 | continue 138 | elif "${list_enabled_strata}" && is_stratum "${stratum}" && is_enabled "${stratum}"; then 139 | printf "${color_strat}%s${color_norm}\\n" "$stratum" 140 | elif "${list_disabled_strata}" && is_stratum "${stratum}" && ! is_enabled "${stratum}"; then 141 | printf "${color_disabled_strat}%s${color_norm}\\n" "$stratum" 142 | elif "${list_enabled_aliases}" && is_alias "${stratum}" && is_enabled "${stratum}"; then 143 | if "${deref_aliases}"; then 144 | printf "${color_alias}%s${color_glue} -> ${color_strat}%s${color_norm}\\n" "$stratum" "$(deref "$stratum")" 145 | else 146 | printf "${color_alias}%s${color_norm}\\n" "$stratum" 147 | fi 148 | elif "${list_disabled_aliases}" && is_alias "${stratum}" && ! is_enabled "${stratum}"; then 149 | if "${deref_aliases}"; then 150 | printf "${color_alias}%s${color_glue} -> ${color_strat}%s${color_norm}\\n" "$stratum" "$(deref "$stratum")" 151 | else 152 | printf "${color_alias}%s${color_norm}\\n" "$stratum" 153 | fi 154 | fi 155 | done 156 | 157 | exit_success 158 | -------------------------------------------------------------------------------- /src/slash-bedrock/libexec/brl-remove: -------------------------------------------------------------------------------- 1 | #!/bedrock/libexec/busybox sh 2 | # 3 | # brl remove 4 | # 5 | # This program is free software; you can redistribute it and/or 6 | # modify it under the terms of the GNU General Public License 7 | # version 2 as published by the Free Software Foundation. 8 | # 9 | # Copyright (c) 2016-2019 Daniel Thau 10 | # 11 | # Removes strata and aliases. 12 | 13 | . /bedrock/share/common-code 14 | 15 | print_help() { 16 | printf "Usage: ${color_cmd}brl remove ${color_sub}[options] ${color_norm} 17 | 18 | Removes specified ${color_term}strata${color_norm} and ${color_term}aliases${color_norm}. Requires root. 19 | 20 | Options: 21 | ${color_cmd}-d${color_norm}, ${color_cmd}--disable${color_norm} disable then remove enabled strata rather than abort 22 | ${color_cmd}-h${color_norm}, ${color_cmd}--help${color_norm} print this message 23 | 24 | Examples: 25 | ${color_cmd}$ brl list -d | grep '^a' 26 | ${color_strat}alpine 27 | ${color_strat}arch 28 | ${color_rcmd}# brl remove alpine arch 29 | ${color_cmd}$ brl list -d | grep '^a' 30 | ${color_cmd}$ brl list -e | grep '^c' 31 | ${color_strat}crux 32 | ${color_rcmd}# brl remove crux 33 | ${color_alert}ERROR: \"crux\" is enabled, refusing to remove. To disable and remove use \`-d\`. 34 | ${color_rcmd}# brl remove -d crux 35 | ${color_cmd}$ brl list -e | grep '^c' 36 | ${color_norm}" 37 | } 38 | 39 | handle_help "${@:-}" 40 | min_args "${#}" "1" 41 | 42 | require_root 43 | lock 44 | 45 | force_disable=false 46 | strata="" 47 | 48 | OPTL="enabled-strata,enabled-aliases,disabled-strata,disabled-aliases,all-strata,all-aliases,deref,include-hidden" 49 | OPTO="eEdDaAri" 50 | eval set -- "$(getopt -q -l "${OPTL}" -- "${OPTO}" "${@}")" || true 51 | saw_non_positional=false 52 | 53 | while [ -n "${1:-}" ]; do 54 | case "${1}" in 55 | -d | --disable) 56 | force_disable=true 57 | shift 58 | ;; 59 | --) 60 | shift 61 | ;; 62 | -*) 63 | if "${saw_non_positional}"; then 64 | eval set -- "$(getopt -q -l "${OPTL}" -- "${OPTO}" "${@}")" || true 65 | saw_non_positional=false 66 | else 67 | abort "Unrecognized argument: ${1}" 68 | fi 69 | ;; 70 | *) 71 | saw_non_positional=true 72 | strata="${strata} ${1}" 73 | shift 74 | ;; 75 | esac 76 | done 77 | 78 | for stratum in ${strata}; do 79 | if ! is_stratum_or_alias "${stratum}"; then 80 | abort "No \"${stratum}\" stratum or alias." 81 | elif [ "${stratum}" = "init" ]; then 82 | abort "Removing init alias is disallowed." 83 | elif is_alias "${stratum}"; then 84 | rm "/bedrock/strata/${stratum}" 85 | elif is_init "${stratum}"; then 86 | abort "Cannot remove or disable init stratum while in use. Reboot and select another stratum to provide init first." 87 | elif is_bedrock "${stratum}"; then 88 | abort "Removing bedrock stratum is disallowed." 89 | elif is_enabled "${stratum}" && ! "${force_disable}"; then 90 | abort "\"${stratum}\" is enabled, refusing to remove. To disable and remove use \`-d\`." 91 | else 92 | for alias in $(list_aliases); do 93 | if [ "$(deref "${alias}")" = "${stratum}" ]; then 94 | rm "/bedrock/strata/${alias}" 95 | fi 96 | done 97 | 98 | disable_stratum "${stratum}" 99 | less_lethal_rm_rf "/bedrock/strata/${stratum}" 100 | fi 101 | done 102 | 103 | exit_success 104 | -------------------------------------------------------------------------------- /src/slash-bedrock/libexec/brl-rename: -------------------------------------------------------------------------------- 1 | #!/bedrock/libexec/busybox sh 2 | # 3 | # brl rename 4 | # 5 | # This program is free software; you can redistribute it and/or 6 | # modify it under the terms of the GNU General Public License 7 | # version 2 as published by the Free Software Foundation. 8 | # 9 | # Copyright (c) 2016-2018 Daniel Thau 10 | # 11 | # Renames strata and aliases. 12 | 13 | . /bedrock/share/common-code 14 | 15 | print_help() { 16 | printf " 17 | Usage: ${color_cmd}brl rename ${color_sub}[options] ${color_norm} 18 | 19 | Renames ${color_term}strata${color_norm} and ${color_term}aliases${color_norm}. Requires root. Can only be applied to ${color_term}disabled${color_norm} 20 | ${color_term}strata${color_norm}. 21 | 22 | Options: 23 | ${color_cmd}-h${color_norm}, ${color_cmd}--help${color_norm} print this message 24 | 25 | Examples: 26 | ${color_cmd}$ brl list unignored | grep -e debian -e stretch 27 | ${color_strat}debian 28 | ${color_rcmd}# brl rename debian stretch 29 | ${color_cmd}$ brl list unignored | grep -e debian -e stretch 30 | ${color_strat}stretch 31 | ${color_norm}" 32 | } 33 | 34 | handle_help "${@:-}" 35 | min_args "${#}" "2" 36 | stratum="${1}" 37 | new_name="${2}" 38 | 39 | require_root 40 | lock 41 | 42 | if ! is_stratum_or_alias "${stratum}"; then 43 | abort "No stratum or alias found called \"${stratum}\"." 44 | elif is_stratum_or_alias "${new_name}"; then 45 | abort "Pre-existing stratum or alias found called \"${new_name}\". Remove with \`brl remove ${stratum}\` first." 46 | elif [ "${stratum}" = "init" ]; then 47 | abort "Renaming init alias is disallowed." 48 | elif is_bedrock "${stratum}"; then 49 | abort "Renaming bedrock stratum is disallowed." 50 | elif is_init "${stratum}"; then 51 | abort "Renaming init-providing stratum is disallowed." 52 | elif is_stratum "${stratum}" && is_enabled "${stratum}"; then 53 | abort "\"${stratum}\" is enabled. Disable with \`brl disable ${stratum}\` first." 54 | fi 55 | 56 | ensure_legal_stratum_name "${new_name}" 57 | 58 | if is_stratum "${stratum}"; then 59 | disable_stratum "${stratum}" 60 | fi 61 | mv "/bedrock/strata/${stratum}" "/bedrock/strata/${new_name}" 62 | 63 | exit_success 64 | -------------------------------------------------------------------------------- /src/slash-bedrock/libexec/brl-report: -------------------------------------------------------------------------------- 1 | #!/bedrock/libexec/busybox sh 2 | # 3 | # brl report 4 | # 5 | # This program is free software; you can redistribute it and/or 6 | # modify it under the terms of the GNU General Public License 7 | # version 2 as published by the Free Software Foundation. 8 | # 9 | # Copyright (c) 2015-2019 Daniel Thau 10 | # 11 | # Generates report about system status 12 | 13 | . /bedrock/share/common-code 14 | # Continue if there are errors 15 | set +eu 16 | trap '' EXIT 17 | 18 | print_help() { 19 | printf " 20 | Usage: ${color_cmd}brl report ${color_sub}[options] ${color_norm} 21 | 22 | Generates a report about the current ${color_bedrock}Bedrock Linux${color_norm} system for use in debugging 23 | issues. Output must be a file path to store the resulting report. 24 | 25 | Options: 26 | ${color_cmd}-h${color_norm}, ${color_cmd}--help ${color_norm}print this message 27 | ${color_cmd}-o${color_norm}, ${color_cmd}--overwrite ${color_norm}overwrite file at report path 28 | 29 | Example: 30 | ${color_cmd}$ brl report /tmp/log 31 | ${color_cmd}$ cat /tmp/log | xclip 32 | ${color_norm}" 33 | } 34 | 35 | handle_help "${@:-}" 36 | min_args "${#}" "1" 37 | 38 | overwrite="false" 39 | if [ "${1:-}" = "-o" ] || [ "${1:-}" = "--overwrite" ]; then 40 | overwrite="true" 41 | shift 42 | fi 43 | report="${1}" 44 | shift 45 | if [ "${1:-}" = "-o" ] || [ "${1:-}" = "--overwrite" ]; then 46 | overwrite="true" 47 | shift 48 | fi 49 | 50 | if [ -e "${report}" ]; then 51 | if "${overwrite}"; then 52 | rm -f "${report}" 53 | else 54 | abort "file exists at \"${report}\" and --overwrite was not specified." 55 | fi 56 | fi 57 | 58 | run() { 59 | notice "Running ${color_cmd}\`${*}\`${color_norm}" 60 | ( 61 | echo '$ '"${*}" 62 | eval "${@}" | sed 's/^/ /' 63 | echo "" 64 | ) >>"${report}" 2>&1 || true 65 | } 66 | 67 | notice "Creating report at ${color_file}\`$report\`${color_norm}." 68 | echo "Bedrock Linux system report" >>"${report}" 69 | echo "" >>"${report}" 70 | 71 | run "cat /bedrock/etc/bedrock-release" 72 | run "cat /bedrock/etc/bedrock.conf" 73 | run "/bedrock/bin/brl list -v" 74 | run "/bedrock/bin/brl status \$(/bedrock/bin/brl list -aA)" 75 | run "echo \$PATH" 76 | run "echo \$MANPATH" 77 | run "echo \$INFOPATH" 78 | run "echo \$XDG_DATA_DIRS" 79 | run "echo \$SHELL" 80 | run "ls -la /bedrock/strata/" 81 | run "ls -Rl /bedrock/run/" 82 | run "grep secure_path /etc/sudoers" 83 | run "grep \"^\$(whoami):\" /etc/passwd" 84 | run "grep \"^root:\" /etc/passwd" 85 | run "cat /etc/hostname" 86 | run "cat /etc/os-release" 87 | run "cat /etc/lsb-release" 88 | run "cat /etc/fstab" 89 | run "cat /proc/1/mountinfo" 90 | run "lsmod" 91 | run "ps" 92 | run "cd /proc && for x in *; do echo \"\$x\" | grep -q \"^[0-9]*\$\" && echo \"\$x: \$(/bedrock/bin/brl which -p \"\$x\" 2>/dev/null)\"; done | sort -n" 93 | run "cat /bedrock/cross/.bedrock-config-filesystem" 94 | run "cat /proc/1/root/etc/.bedrock-config-filesystem" 95 | run "uname -m" 96 | run "uname -a" 97 | run "env" 98 | run "/bedrock/libexec/getfattr -d /bedrock/strata/bedrock" 99 | 100 | notice "Completed creating report at ${color_file}\`$report\`${color_norm}." 101 | 102 | exit_success 103 | -------------------------------------------------------------------------------- /src/slash-bedrock/libexec/brl-show: -------------------------------------------------------------------------------- 1 | #!/bedrock/libexec/busybox sh 2 | # 3 | # brl show 4 | # 5 | # This program is free software; you can redistribute it and/or 6 | # modify it under the terms of the GNU General Public License 7 | # version 2 as published by the Free Software Foundation. 8 | # 9 | # Copyright (c) 2016-2020 Daniel Thau 10 | # 11 | # Marks strata to be visible 12 | 13 | . /bedrock/share/common-code 14 | 15 | print_help() { 16 | printf "Usage: ${color_cmd}brl show ${color_sub}[options] ${color_norm} 17 | 18 | ${color_term}Shows${color_norm} ${color_term}strata${color_norm} from various ${color_bedrock}Bedrock Linux${color_norm} subsystems. Requires root. 19 | 20 | Options: 21 | ${color_sub}${color_norm} defaults to ${color_cmd}--all${color_norm} 22 | ${color_cmd}-a${color_norm},${color_cmd} --all ${color_norm}${color_term}show${color_norm} ${color_term}stratum${color_norm} in all available subsystems 23 | ${color_cmd}-b${color_norm},${color_cmd} --boot ${color_norm}automatically ${color_term}enable${color_norm} ${color_term}stratum${color_norm} during boot 24 | ${color_cmd}-c${color_norm},${color_cmd} --cross ${color_norm}include ${color_term}stratum${color_norm}'s files in ${color_file}/bedrock/cross${color_norm} 25 | ${color_cmd}-i${color_norm},${color_cmd} --init ${color_norm}list ${color_term}stratum${color_norm}'s init options during boot 26 | ${color_cmd}-l${color_norm},${color_cmd} --list ${color_norm}list with ${color_cmd}\`brl list\`${color_norm} even without ${color_cmd}\`-i\`${color_norm} flag 27 | ${color_cmd}-p${color_norm},${color_cmd} --pmm ${color_norm}consider for ${color_cmd}\`pmm\`${color_norm} operations 28 | ${color_cmd}-h${color_norm},${color_cmd} --help ${color_norm}print this message 29 | 30 | Examples: 31 | ${color_cmd}$ brl list | grep centos 32 | ${color_strat}centos 33 | ${color_rcmd}# brl hide centos 34 | ${color_cmd}$ brl list | grep centos 35 | ${color_rcmd}# brl show centos 36 | ${color_cmd}$ brl list | grep centos 37 | ${color_strat}centos 38 | ${color_norm}" 39 | } 40 | 41 | handle_help "${@:-}" 42 | min_args "${#}" "1" 43 | 44 | show_boot=false 45 | show_cross=false 46 | show_init=false 47 | show_list=false 48 | show_pmm=false 49 | strata="" 50 | 51 | OPTL="all,boot,cross,init,list,pmm,help" 52 | OPTO="abcilp" 53 | eval set -- "$(getopt -q -l "${OPTL}" -- "${OPTO}" "${@}")" || true 54 | saw_non_positional=false 55 | 56 | while [ -n "${1:-}" ]; do 57 | case "${1}" in 58 | -a | --all) 59 | show_boot=true 60 | show_cross=true 61 | show_init=true 62 | show_list=true 63 | show_pmm=true 64 | shift 65 | ;; 66 | -b | --boot) 67 | show_boot=true 68 | shift 69 | ;; 70 | -c | --cross) 71 | show_cross=true 72 | shift 73 | ;; 74 | -i | --init) 75 | show_init=true 76 | shift 77 | ;; 78 | -l | --list) 79 | show_list=true 80 | shift 81 | ;; 82 | -p | --pmm) 83 | show_pmm=true 84 | shift 85 | ;; 86 | --) 87 | shift 88 | ;; 89 | -*) 90 | if "${saw_non_positional}"; then 91 | eval set -- "$(getopt -q -l "${OPTL}" -- "${OPTO}" "${@}")" || true 92 | saw_non_positional=false 93 | else 94 | abort "Unrecognized argument: ${1}" 95 | fi 96 | ;; 97 | *) 98 | saw_non_positional=true 99 | strata="${strata} ${1}" 100 | shift 101 | ;; 102 | esac 103 | done 104 | 105 | if [ -z "${strata}" ]; then 106 | abort "No stratum or alias specified." 107 | fi 108 | 109 | # Default to --all if none are specified 110 | if ! "${show_boot}" && 111 | ! "${show_cross}" && 112 | ! "${show_init}" && 113 | ! "${show_list}" && 114 | ! "${show_pmm}"; then 115 | show_boot=true 116 | show_cross=true 117 | show_init=true 118 | show_list=true 119 | show_pmm=true 120 | fi 121 | 122 | lock 123 | 124 | for stratum in ${strata}; do 125 | if ! is_stratum_or_alias "${stratum}"; then 126 | abort "no stratum or alias named \"${stratum}\"" 127 | fi 128 | "${show_boot}" && set_attr "/bedrock/strata/${stratum}" "show_boot" "" 129 | "${show_cross}" && set_attr "/bedrock/strata/${stratum}" "show_cross" "" 130 | "${show_init}" && set_attr "/bedrock/strata/${stratum}" "show_init" "" 131 | "${show_list}" && set_attr "/bedrock/strata/${stratum}" "show_list" "" 132 | "${show_pmm}" && set_attr "/bedrock/strata/${stratum}" "show_pmm" "" 133 | done 134 | 135 | if "${show_cross}"; then 136 | cfg_crossfs "/proc/1/root/bedrock/strata/bedrock/bedrock/cross" 137 | fi 138 | 139 | exit_success 140 | -------------------------------------------------------------------------------- /src/slash-bedrock/libexec/brl-tutorial: -------------------------------------------------------------------------------- 1 | #!/bedrock/libexec/busybox sh 2 | # 3 | # brl tutorial 4 | # 5 | # This program is free software; you can redistribute it and/or 6 | # modify it under the terms of the GNU General Public License 7 | # version 2 as published by the Free Software Foundation. 8 | # 9 | # Copyright (c) 2019-2020 Daniel Thau 10 | # 11 | # Interactive tutorial front-end 12 | 13 | # shellcheck source=src/slash-bedrock/share/brl-tutorial/common 14 | . /bedrock/share/brl-tutorial/common 15 | 16 | lesson_directory="/bedrock/share/brl-tutorial/lessons/" 17 | 18 | print_help() { 19 | printf "Usage: ${color_cmd}brl tutorial${color_norm} ${color_sub}${color_norm} 20 | 21 | Provides an interactive tutorial of various Bedrock Linux features. 22 | 23 | Lessons: 24 | $( 25 | cd "${lesson_directory}" 26 | for file in *; do 27 | name="$(echo "${file}" | sed 's/^[0-9]*_//')" 28 | printf " ${color_cmd}%-15s${color_norm}%s\n" "${name}" "$(sh "${file}" help)" 29 | done 30 | ) 31 | ${color_sub}(more lessons may be added in the future)${color_norm} 32 | 33 | Options: 34 | ${color_cmd}-h${color_norm}, ${color_cmd}--help${color_norm} print this message 35 | 36 | Examples: 37 | ${color_cmd}$ brl tutorial basics 38 | ${color_norm} 39 | ${color_norm}" 40 | } 41 | 42 | cmd() { 43 | printf "\t${color_cmd}\$ $*${color_norm}" 44 | } 45 | 46 | rcmd() { 47 | printf "\t${color_alert}# $*${color_norm}" 48 | } 49 | 50 | flag() { 51 | printf "${color_cmd}$1${color_norm}" 52 | } 53 | 54 | section() { 55 | title="${1}" 56 | text="${2}" 57 | condition="${3:-}" 58 | 59 | spinner="|/-\\" 60 | cursor="1" 61 | 62 | clear 63 | step "Lesson: ${lesson}, section: ${title}" 64 | printf "${text}" 65 | echo "" 66 | if [ -n "${condition:-}" ]; then 67 | while ! sh -c "${condition}" >/dev/null 2>&1; do 68 | cursor="$((cursor + 1))" 69 | if [ "${cursor}" -gt 4 ]; then 70 | cursor=1 71 | fi 72 | c="$(echo "${spinner}" | head -c "${cursor}" | tail -c1)" 73 | printf "\r[Run specified commands in another terminal to continue ${c}]" 74 | sleep 1 75 | done 76 | else 77 | printf "[Press ${color_cmd}${color_norm} to continue]" 78 | # Prompt is just used to block. We're purposefully not using 79 | # populated variable. 80 | # shellcheck disable=SC2034 81 | read -r PAUSE 82 | fi 83 | printf "\n" 84 | } 85 | 86 | standard_intro() { 87 | printf "This tutorial assumes familiarity with common Linux environment concepts such 88 | as a bourne shell-like command line as well as a working internet connection 89 | and a couple gigabytes of free disk space. 90 | 91 | Open another terminal with a bourne-like shell along side this one to follow 92 | along with the tutorial. 93 | 94 | If you see a \`${color_cmd}\$${color_norm}\` prompt: 95 | 96 | $(cmd "ls") 97 | 98 | run the command as your normal, non-root user. If you see a \`${color_alert}#${color_norm}\` prompt: 99 | 100 | $(rcmd "whoami") 101 | 102 | run the command as root (e.g. ${color_alert}sudo${color_norm}, ${color_cmd}su${color_norm}, etc). 103 | 104 | You may press ${color_cmd}${color_norm} to exit the tutorial at any point. 105 | " 106 | } 107 | 108 | handle_help "${@:-}" 109 | 110 | # Find user specified lesson implementation 111 | lesson="${*}" 112 | if [ -z "${lesson}" ]; then 113 | abort "No lesson specified, see --help" 114 | elif ! file="$(echo "${lesson_directory}"*"_${lesson}")"; then 115 | abort "No such lesson \"${lesson}\"" 116 | fi 117 | 118 | # Run lesson 119 | step_init "$(grep -c "^section " "${file}")" 120 | . "${file}" 121 | 122 | clear 123 | printf "This completes the lesson: ${lesson} 124 | Thank you for taking the time to learn about ${Bedrock_Linux}. 125 | " 126 | 127 | exit_success 128 | -------------------------------------------------------------------------------- /src/slash-bedrock/libexec/brl-version: -------------------------------------------------------------------------------- 1 | #!/bedrock/libexec/busybox sh 2 | # 3 | # brl version 4 | # 5 | # This program is free software; you can redistribute it and/or 6 | # modify it under the terms of the GNU General Public License 7 | # version 2 as published by the Free Software Foundation. 8 | # 9 | # Copyright (c) 2016-2018 Daniel Thau 10 | # 11 | # Prints current install's Bedrock Linux version 12 | 13 | . /bedrock/share/common-code 14 | 15 | print_help() { 16 | printf "Usage: ${color_cmd}brl version ${color_sub}[options]${color_norm} 17 | 18 | Prints ${color_bedrock}Bedrock Linux${color_norm} install's version. 19 | 20 | Options: 21 | ${color_cmd}-h${color_norm}, ${color_cmd}--help${color_norm} print this message 22 | 23 | Examples: 24 | ${color_cmd}$ brl version 25 | ${color_norm}Bedrock Linux 0.7.0 Poki 26 | ${color_norm}" 27 | } 28 | 29 | handle_help "${@:-}" 30 | 31 | cat /bedrock/etc/bedrock-release 32 | 33 | exit_success 34 | -------------------------------------------------------------------------------- /src/slash-bedrock/share/bash/completion/strat: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # bash tab completion for strat 4 | # 5 | # This program is free software; you can redistribute it and/or 6 | # modify it under the terms of the GNU General Public License 7 | # version 2 as published by the Free Software Foundation. 8 | # 9 | # Copyright (c) 2018-2019 Daniel Thau 10 | # 11 | 12 | _strat() { 13 | cur=${COMP_WORDS[COMP_CWORD]} 14 | 15 | # stages: 16 | # - parsing flags 17 | # - arg0's arg 18 | # - stratum 19 | # - command 20 | saw_help=0 21 | saw_local=0 22 | saw_restrict=0 23 | saw_arg0=0 24 | saw_arg0_arg=0 25 | saw_stratum=0 26 | saw_command=0 27 | for ((i = 1; i < COMP_CWORD; i++)); do 28 | case "${COMP_WORDS[i]}" in 29 | "-h" | "--help") 30 | saw_help=${i} 31 | ;; 32 | "-l" | "--local") 33 | saw_local=${i} 34 | ;; 35 | "-r" | "--restrict") 36 | saw_restrict=${i} 37 | ;; 38 | "-a" | "--arg0") 39 | saw_arg0=${i} 40 | [[ "${COMP_CWORD}" -gt $((i + 1)) ]] && saw_arg0_arg=$((++i)) 41 | ;; 42 | *) 43 | if [[ "${saw_stratum}" -eq 0 ]]; then 44 | saw_stratum=${i} 45 | else 46 | saw_command=${i} 47 | break 48 | fi 49 | ;; 50 | esac 51 | done 52 | 53 | opts="" 54 | 55 | if [[ "${saw_arg0}" -gt 0 ]] && [[ "${saw_arg0_arg}" -eq 0 ]]; then 56 | # no completion for arg0 57 | return 58 | elif [[ "${saw_stratum}" -eq 0 ]]; then 59 | opts="${opts} $(/bedrock/bin/brl list)" 60 | [ "${saw_help}" -eq 0 ] && opts="${opts} -h --help" 61 | [ "${saw_local}" -eq 0 ] && opts="${opts} -l --local" 62 | [ "${saw_restrict}" -eq 0 ] && opts="${opts} -r --restrict" 63 | [ "${saw_arg0}" -eq 0 ] && opts="${opts} -a --arg0" 64 | elif [[ "${saw_command}" -eq 0 ]]; then 65 | prefix="/bedrock/strata/${COMP_WORDS[saw_stratum]}" 66 | for dir in ${PATH//:/ }; do 67 | if ! echo "${dir}" | grep -q "^/bedrock/cross/"; then 68 | opts="${opts} $(/bedrock/libexec/busybox ls -1 "${prefix}${dir}" 2>/dev/null)" 69 | fi 70 | done 71 | else 72 | _command_offset "${saw_command}" 73 | return 74 | fi 75 | 76 | # Explicitly desire splitting here. 77 | # shellcheck disable=SC2207 78 | COMPREPLY=($(compgen -W "${opts}" -- "${cur}")) 79 | } 80 | 81 | complete -F _strat strat 82 | -------------------------------------------------------------------------------- /src/slash-bedrock/share/brl-fetch/distros/.opensuse: -------------------------------------------------------------------------------- 1 | #!/bedrock/libexec/busybox sh 2 | # 3 | # openSUSE bootstrap support 4 | # 5 | # This program is free software; you can redistribute it and/or 6 | # modify it under the terms of the GNU General Public License 7 | # version 2 as published by the Free Software Foundation. 8 | # 9 | # Copyright (c) 2016-2019 Daniel Thau 10 | # 11 | 12 | # 13 | # Some package has a dependency on "this-is-only-for-build-envs" but a 14 | # corresponding provider does not appear in the repository. Given this, the 15 | # fetch fails. Thus, this is disabled. 16 | # 17 | 18 | . /bedrock/share/common-code 19 | trap 'fetch_abort "Unexpected error occurred."' EXIT 20 | 21 | check_supported() { 22 | false 23 | } 24 | 25 | speed_test_url() { 26 | echo "distribution/leap/${target_release:-}/repo/oss/suse/repodata/appdata-screenshots.tar" 27 | } 28 | 29 | list_mirrors() { 30 | # from https://mirrors.opensuse.org/ 31 | # 32 | # The master download server, download.opensuse.org, automatically redirects you to a server near you 33 | # 34 | echo "https://download.opensuse.org" 35 | } 36 | 37 | # Could not find adequate evidence of support for non-x86_64 architectures. For example, the repo here: 38 | # 39 | # https://download.opensuse.org/distribution/leap/15.1/repo/oss/ 40 | # 41 | # only lists the x86_64 architecture. 42 | brl_arch_to_distro() { 43 | case "${1}" in 44 | "x86_64") echo "x86_64" ;; 45 | *) abort "brl does not know how to translate arch \"${1}\" to ${distro:-} format" ;; 46 | esac 47 | } 48 | 49 | list_architectures() { 50 | echo "x86_64" 51 | } 52 | 53 | # 54 | # OpenSUSE 14 was named 42. However, the following version went back 15. For 55 | # sorting purposes, place 42 where 14 would normally go. 56 | # 57 | 58 | default_release() { 59 | list_releases | 60 | sed 's/^42\>/14/' | 61 | sort -n | 62 | sed 's/^14\>/42/' | 63 | tail -n1 64 | } 65 | 66 | list_releases() { 67 | wget -O- 'https://download.opensuse.org/distribution/leap/' 2>/dev/null | 68 | awk '/folder/,/<\/table>/' | 69 | list_links | 70 | grep '^[0-9][0-9.]*/$' | 71 | sed 's,/$,,' | 72 | sed 's/^42\>/14/' | 73 | sort -n | 74 | sed 's/^14\>/42/' | 75 | uniq 76 | } 77 | 78 | fetch() { 79 | step "Downloading package information database" 80 | url="$(find_link "${target_mirror:-}/distribution/leap/${target_release:-}/repo/oss/repodata/" "primary.xml.gz")" 81 | wget -O "${bootstrap_dir:-}/primary.xml.gz" "${url}" 82 | 83 | step "Converting distro package information database to brl format" 84 | gunzip "${bootstrap_dir:-}/primary.xml.gz" 85 | rpmdb_to_brldb "${bootstrap_dir:-}/primary.xml" "${bootstrap_dir:-}/brldb" 86 | 87 | step "Calculating required bootstrap packages" 88 | brldb_calculate_paths_with_deps "${bootstrap_dir:-}/brldb" "${bootstrap_dir:-}/package_paths" "zypper rpm openSUSE-release filesystem ca-certificates ca-certificates-cacert" 89 | 90 | step "Downloading bootstrap packages" 91 | download_files "${bootstrap_dir:-}" "$(awk -v"m=${target_mirror:-}/distribution/leap/${target_release:-}/repo/oss/" '{print m"/"$0}' "${bootstrap_dir:-}/package_paths")" 92 | 93 | step "Extracting bootstrap packages" 94 | # This round is just to bootstrap the distro's rpm. 95 | # Next step we'll use the distro's rpm to install everything properly. 96 | # Need to extract filesystem first to ensure symlinks are set up 97 | extract_rpms "${bootstrap_dir:-}" "${bootstrap_dir:-}"/filesystem*.rpm "${bootstrap_dir:-}"/*.rpm 98 | 99 | step "Installing bootstrap packages" 100 | setup_chroot "${bootstrap_dir:-}" 101 | LC_ALL=C chroot "${bootstrap_dir:-}" rpm -i ./*.rpm 102 | 103 | step "Running bootstrap software" 104 | chroot "${bootstrap_dir:-}" rpm -i --root=/target-root --nodeps openSUSE-release-*.rpm 105 | chroot "${bootstrap_dir:-}" zypper --non-interactive --root=/target-root ar -f "http://download.opensuse.org/distribution/leap/${target_release:-}/repo/oss/" repo-oss 106 | chroot "${bootstrap_dir:-}" zypper --non-interactive --root=/target-root ar -f "http://download.opensuse.org/update/leap/${target_release:-}/oss/" update-oss 107 | chroot "${bootstrap_dir:-}" zypper --non-interactive --gpg-auto-import-keys --root=/target-root refresh 108 | chroot "${bootstrap_dir:-}" zypper --non-interactive --gpg-auto-import-keys --root=/target-root install -f zypper rpm openSUSE-release filesystem ca-certificates ca-certificates-cacert 109 | 110 | step "Configuring" 111 | # Some pre/post install hooks do not seem to take from the bootstrap environment. Need to be installed in the environment proper. 112 | setup_chroot "${target_dir:-}" 113 | chroot "${target_dir:-}" zypper --non-interactive ar -f "http://download.opensuse.org/distribution/leap/${target_release:-}/repo/oss/" repo-oss || true 114 | chroot "${target_dir:-}" zypper --non-interactive ar -f "http://download.opensuse.org/update/leap/${target_release:-}/oss/" update-oss || true 115 | chroot "${target_dir:-}" zypper --non-interactive --gpg-auto-import-keys refresh 116 | chroot "${target_dir:-}" zypper --non-interactive --gpg-auto-import-keys install -f zypper rpm openSUSE-release filesystem ca-certificates ca-certificates-cacert 117 | } 118 | -------------------------------------------------------------------------------- /src/slash-bedrock/share/brl-fetch/distros/.parabola: -------------------------------------------------------------------------------- 1 | #!/bedrock/libexec/busybox sh 2 | # 3 | # Parabola GNU/Linux-libre bootstrap support 4 | # 5 | # This program is free software; you can redistribute it and/or 6 | # modify it under the terms of the GNU General Public License 7 | # version 2 as published by the Free Software Foundation. 8 | # 9 | # Copyright (c) 2016-2020 Daniel Thau 10 | # 11 | 12 | # shellcheck source=src/slash-bedrock/libexec/brl-fetch 13 | . /bedrock/share/common-code 14 | trap 'fetch_abort "Unexpected error occurred."' EXIT 15 | 16 | check_supported() { 17 | false 18 | } 19 | 20 | speed_test_url() { 21 | echo "core/os/${distro_arch}/core.db.tar.gz" 22 | } 23 | 24 | list_mirrors() { 25 | mirror_list_url='https://www.parabola.nu/mirrorlist/all/' 26 | wget -O- "${mirror_list_url}" 2>/dev/null | 27 | awk -F "[ $]" ' /^#Server/ {print$3} ' 28 | } 29 | 30 | brl_arch_to_distro() { 31 | case "${1}" in 32 | "armv7hl") echo "armv7h" ;; 33 | "i686") echo "i686" ;; 34 | "ppc64le") echo "ppc64le" ;; 35 | "x86_64") echo "x86_64" ;; 36 | *) abort "brl does not know how to translate arch \"${1}\" to ${distro} format" ;; 37 | esac 38 | } 39 | 40 | list_architectures() { 41 | cat <>"${1}/etc/pacman.d/mirrorlist" 76 | echo "Server = ${target_mirror}/\$repo/os/\$arch" >>"$1/etc/pacman.d/mirrorlist" 77 | fi 78 | } 79 | 80 | fetch() { 81 | bootstrap_deps="arch-install-scripts" 82 | 83 | step "Downloading package information database" 84 | wget -O "${bootstrap_dir}/core.db.tar.gz" "${target_mirror}/core/os/${distro_arch}/core.db.tar.gz" 85 | wget -O "${bootstrap_dir}/extra.db.tar.gz" "${target_mirror}/extra/os/${distro_arch}/extra.db.tar.gz" 86 | wget -O "${bootstrap_dir}/libre.db.tar.gz" "${target_mirror}/libre/os/${distro_arch}/libre.db.tar.gz" 87 | 88 | step "Decompressing package information database" 89 | mkdir -p "${bootstrap_dir}/pacmandb/core" "${bootstrap_dir}/pacmandb/extra" "${bootstrap_dir}/pacmandb/libre" 90 | ( 91 | tar -xv -f "${bootstrap_dir}/core.db.tar.gz" -C "${bootstrap_dir}/pacmandb/core/" 92 | tar -xv -f "${bootstrap_dir}/extra.db.tar.gz" -C "${bootstrap_dir}/pacmandb/extra/" 93 | tar -xv -f "${bootstrap_dir}/libre.db.tar.gz" -C "${bootstrap_dir}/pacmandb/libre/" 94 | ) | awk 'NR%100==0' | progress_unknown 95 | 96 | step "Converting distro package information database to brl format" 97 | pacmandb_to_brldb "${bootstrap_dir}/pacmandb" "${bootstrap_dir}/brldb" 98 | 99 | step "Calculating required bootstrap packages" 100 | brldb_calculate_required_packages "${bootstrap_dir}/brldb" "${bootstrap_dir}/required_packages" "${bootstrap_deps}" 101 | 102 | step "Downloading bootstrap packages" 103 | # brldb contains repo/filename 104 | # files are at mirror/repo/os/arch/filename 105 | checksum_downloads "${cache}/packages/" "$(awk -v"a=${distro_arch}" -v"m=${target_mirror}" '{sub("/", "/os/"a"/"); print m"/"$0}' "${bootstrap_dir}/required_packages")" 106 | 107 | step "Extracting bootstrap packages" 108 | bootstrap_packages="$(awk -v"d=${cache}/packages/" '{sub(/^.*\//,d);print $1}' "${bootstrap_dir}/required_packages")" 109 | # shellcheck disable=SC2086 110 | extract_pacman_pkgs "${bootstrap_dir}" ${bootstrap_packages} 111 | 112 | step "Running bootstrap software" 113 | # pacstrap mounts devtmpfs (which is shared with the host system) and 114 | # chowns files in it based on /etc/passwd and /etc/group. Ensure 115 | # system copies of files are used to avoid problematic file ownership 116 | # change in /dev. 117 | mkdir -p "${target_dir}/etc" 118 | cp -a "/etc/passwd" "${target_dir}/etc/passwd" 119 | cp -a "/etc/group" "${target_dir}/etc/group" 120 | 121 | setup_chroot "${bootstrap_dir}" 122 | setup_pacman "${bootstrap_dir}" 123 | share_cache "packages" "${bootstrap_dir}/target-root/var/cache/pacman/pkg/" 124 | LC_ALL=C chroot "${bootstrap_dir}" pacstrap "/target-root" base 125 | 126 | step "Configuring" 127 | setup_chroot "${target_dir}" 128 | setup_pacman "${target_dir}" 129 | cp "${cache}/packages/"* "${target_dir}/var/cache/pacman/" 130 | if LC_ALL=C chroot "${target_dir}" pacman -Q linux >/dev/null 2>&1; then 131 | LC_ALL=C chroot "${target_dir}" pacman --noconfirm -R linux 132 | fi 133 | } 134 | -------------------------------------------------------------------------------- /src/slash-bedrock/share/brl-fetch/distros/.trisquel: -------------------------------------------------------------------------------- 1 | #!/bedrock/libexec/busybox sh 2 | # 3 | # Trisquel bootstrap support 4 | # 5 | # This program is free software; you can redistribute it and/or 6 | # modify it under the terms of the GNU General Public License 7 | # version 2 as published by the Free Software Foundation. 8 | # 9 | # Copyright (c) 2016-2020 Daniel Thau 10 | # 11 | 12 | # shellcheck source=src/slash-bedrock/libexec/brl-fetch 13 | . /bedrock/share/common-code 14 | trap 'fetch_abort "Unexpected error occurred."' EXIT 15 | 16 | check_supported() { 17 | false 18 | } 19 | 20 | speed_test_url() { 21 | echo "dists/${target_release}/Release" 22 | } 23 | 24 | list_mirrors() { 25 | echo 'http://archive.trisquel.info/trisquel' 26 | mirror_list_url='https://trisquel.info/mirmon/index.html' 27 | wget -O- "${mirror_list_url}" 2>/dev/null | 28 | awk '/

report<.H2>/,/<.TABLE>/' | 29 | list_links | 30 | grep "^http" 31 | } 32 | 33 | brl_arch_to_distro() { 34 | case "${1}" in 35 | "i686") echo "i386" ;; 36 | "x86_64") echo "amd64" ;; 37 | *) abort "brl does not know how to translate arch \"${1}\" to ${distro} format" ;; 38 | esac 39 | } 40 | 41 | list_architectures() { 42 | cat </dev/null | awk ' 50 | $1 == "Name:" { 51 | name = tolower($2) 52 | } 53 | $1 == "Version:" { 54 | version = $2 55 | gsub(/[^0-9.]/, "", version) 56 | } 57 | name != "" && version != "" { 58 | if (version > best_version) { 59 | best_name = name 60 | best_version = version 61 | } 62 | } 63 | END { 64 | print best_name 65 | } 66 | ' 67 | } 68 | 69 | list_releases() { 70 | wget -O- 'http://mirror.fsf.org/trisquel/meta-release' 2>/dev/null | awk '$1=="Name:" {print $2}' 71 | } 72 | 73 | fetch() { 74 | # trisquel 8.0 flidas does not have debootstrap? 75 | bootstrap_deps="debootstrap apt dpkg coreutils dash bash grep sed awk perl bzip2 gzip tar gpgv trisquel-keyring" 76 | 77 | step "Downloading package information database" 78 | wget -O "${bootstrap_dir}/Packages.gz" "${target_mirror}/dists/${target_release}/main/binary-${distro_arch}/Packages.gz" 79 | gunzip "${bootstrap_dir}/Packages.gz" 80 | 81 | step "Converting distro package information database to brl format" 82 | debdb_to_brldb "${bootstrap_dir}/Packages" "${bootstrap_dir}/brldb" 83 | 84 | step "Calculating required bootstrap packages" 85 | brldb_calculate_required_packages "${bootstrap_dir}/brldb" "${bootstrap_dir}/required_packages" "${bootstrap_deps}" 86 | 87 | step "Downloading bootstrap packages" 88 | checksum_downloads "${cache}/packages/" "$(awk -v"m=${target_mirror}" '{print m"/"$0}' "${bootstrap_dir}/required_packages")" 89 | 90 | step "Extracting bootstrap packages" 91 | bootstrap_packages="$(awk -v"d=${cache}/packages/" '{sub(/^.*\//,d);print $1}' "${bootstrap_dir}/required_packages")" 92 | # shellcheck disable=SC2086 93 | extract_debs "${bootstrap_dir}" ${bootstrap_packages} 94 | 95 | step "Running bootstrap software" 96 | setup_chroot "${bootstrap_dir}" 97 | set +o pipefail 98 | if LANG=C chroot "${bootstrap_dir}" debootstrap --help | grep -q "cache-dir"; then 99 | share_cache "packages" "${bootstrap_dir}/packages" 100 | yes "" | LANG=C chroot "${bootstrap_dir}" debootstrap --variant=minbase --cache-dir="/packages" "${target_release}" "/target-root" "${target_mirror}" 101 | else 102 | yes "" | LANG=C chroot "${bootstrap_dir}" debootstrap --variant=minbase "${target_release}" "/target-root" "${target_mirror}" 103 | fi 104 | set -o pipefail 105 | 106 | step "Configuring" 107 | echo "deb ${target_mirror} ${target_release}-security main" >>"${target_dir}/etc/apt/sources.list" 108 | echo "deb ${target_mirror} ${target_release}-updates main" >>"${target_dir}/etc/apt/sources.list" 109 | setup_chroot "${target_dir}" 110 | autopkgs="$(LANG=C chroot "${target_dir}" /usr/bin/apt-mark showmanual)" 111 | set +o pipefail 112 | # word splitting is desired here 113 | # shellcheck disable=SC2086 114 | yes "" | LANG=C chroot "${target_dir}" /usr/bin/apt-mark auto ${autopkgs} 115 | yes "" | LANG=C chroot "${target_dir}" /usr/bin/apt-get update 116 | set -o pipefail 117 | } 118 | -------------------------------------------------------------------------------- /src/slash-bedrock/share/brl-fetch/distros/alma: -------------------------------------------------------------------------------- 1 | #!/bedrock/libexec/busybox sh 2 | # 3 | # Alma bootstrap support 4 | # 5 | # This program is free software; you can redistribute it and/or 6 | # modify it under the terms of the GNU General Public License 7 | # version 2 as published by the Free Software Foundation. 8 | # 9 | # Copyright (c) 2016-2021 Daniel Thau 10 | # 11 | 12 | # shellcheck source=src/slash-bedrock/libexec/brl-fetch 13 | . /bedrock/share/common-code 14 | trap 'fetch_abort "Unexpected error occurred."' EXIT 15 | 16 | check_supported() { 17 | false 18 | } 19 | 20 | get_mirror_suffix() { 21 | if [ "$(echo "${target_release}" | sed 's/-[a-z]*$//')" -lt 8 ]; then 22 | echo "${target_release}/os/${distro_arch}/" 23 | else 24 | echo "${target_release}/BaseOS/${distro_arch}/os" 25 | fi 26 | } 27 | 28 | speed_test_url() { 29 | echo "$(get_mirror_suffix)/repodata/repomd.xml" 30 | } 31 | 32 | list_mirrors() { 33 | mirror_list_url='https://mirrors.almalinux.org/' 34 | download -q "${mirror_list_url}" - | 35 | awk '/]/\n/g' | 37 | grep 'a href="http' | 38 | list_links 39 | } 40 | 41 | brl_arch_to_distro() { 42 | case "${1}" in 43 | "x86_64") echo "x86_64" ;; 44 | "aarch64") echo "aarch64" ;; 45 | *) abort "brl does not know how to translate arch \"${1}\" to ${distro} format" ;; 46 | esac 47 | } 48 | 49 | list_architectures() { 50 | cat <>"${bootstrap_dir}/brldb/provides/u" 101 | fi 102 | 103 | step "Calculating required bootstrap packages" 104 | brldb_calculate_required_packages "${bootstrap_dir}/brldb" "${bootstrap_dir}/required_packages" "$(bootstrap_deps)" 105 | 106 | step "Downloading bootstrap packages" 107 | checksum_downloads "${cache}/packages/" "$(awk -v"m=${target_mirror}/${suffix}" '{print m"/"$0}' "${bootstrap_dir}/required_packages")" 108 | 109 | step "Extracting bootstrap packages" 110 | # This round is just to bootstrap the distro's rpm. 111 | # Next step we'll use the distro's rpm to install everything properly. 112 | # Need to extract filesystem first to ensure symlinks are set up 113 | bootstrap_packages="$(awk -v"d=${cache}/packages/" '{sub(/^.*\//,d);print $1}' "${bootstrap_dir}/required_packages")" 114 | # shellcheck disable=SC2086 115 | extract_rpms "${bootstrap_dir}" "${cache}/packages"/filesystem*.rpm ${bootstrap_packages} 116 | 117 | step "Installing bootstrap packages" 118 | setup_chroot "${bootstrap_dir}" 119 | # setup_ssl "${bootstrap_dir}" # fights with yum/dnf later on, not actually needed 120 | share_cache "packages" "${bootstrap_dir}/packages" 121 | bootstrap_packages="$(awk -v"d=/packages/" '{sub(/^.*\//,d);print $1}' "${bootstrap_dir}/required_packages")" 122 | # shellcheck disable=SC2086 123 | LC_ALL=C chroot "${bootstrap_dir}" sh -c 'rpm --import /etc/pki/rpm-gpg/*' 124 | LC_ALL=C chroot "${bootstrap_dir}" rpm -i ${bootstrap_packages} 125 | 126 | step "Running bootstrap software" 127 | # By default, dnf clears anything in its package cache. 128 | # Configure them to retain them so we can leverage previous cached 129 | # packages. 130 | if [ -e "${bootstrap_dir}/etc/dnf/dnf.conf" ] && grep -q "^keepcache=1$" "${bootstrap_dir}/etc/dnf/dnf.conf"; then 131 | share_cache "dnf-cache" "${bootstrap_dir}/target-root/var/cache/dnf" 132 | elif [ -e "${bootstrap_dir}/etc/dnf/dnf.conf" ] && grep -q "^keepcache=0$" "${bootstrap_dir}/etc/dnf/dnf.conf"; then 133 | sed 's/^keepcache=0$/keepcache=1/' "${bootstrap_dir}/etc/dnf/dnf.conf" >"${bootstrap_dir}/etc/dnf/dnf.conf-new" 134 | mv "${bootstrap_dir}/etc/dnf/dnf.conf-new" "${bootstrap_dir}/etc/dnf/dnf.conf" 135 | share_cache "dnf-cache" "${bootstrap_dir}/target-root/var/cache/dnf" 136 | elif [ -r "${bootstrap_dir}/etc/dnf/dnf.conf" ]; then 137 | echo "keepcache=1" >>"${bootstrap_dir}/etc/dnf/dnf.conf" 138 | share_cache "dnf-cache" "${bootstrap_dir}/target-root/var/cache/dnf" 139 | fi 140 | 141 | LC_ALL=C chroot "${bootstrap_dir}" rpm -i --root=/target-root --nodeps ./packages/centos-release-*.rpm 2>/dev/null || true 142 | if [ "$(echo "${target_release}" | sed 's/-[a-z]*$//')" -lt 8 ]; then 143 | LC_ALL=C chroot "${bootstrap_dir}" dnf --installroot=/target-root install -y rpm-build dnf 144 | else 145 | LC_ALL=C chroot "${bootstrap_dir}" dnf --installroot=/target-root --releasever="${target_release}" install -y rpm-build dnf 146 | fi 147 | # Need to set database timestamps for pmm due to `dnf -C` usage 148 | umount -l "${bootstrap_dir}/var/cache/dnf" >/dev/null 2>&1 || true 149 | setup_chroot "${target_dir}" 150 | LC_ALL=C chroot "${target_dir}" dnf -y update 151 | } 152 | -------------------------------------------------------------------------------- /src/slash-bedrock/share/brl-fetch/distros/alpine: -------------------------------------------------------------------------------- 1 | #!/bedrock/libexec/busybox sh 2 | # 3 | # Alpine Linux bootstrap support 4 | # 5 | # This program is free software; you can redistribute it and/or 6 | # modify it under the terms of the GNU General Public License 7 | # version 2 as published by the Free Software Foundation. 8 | # 9 | # Copyright (c) 2016-2019 Daniel Thau 10 | # 11 | 12 | # shellcheck source=src/slash-bedrock/libexec/brl-fetch 13 | . /bedrock/share/common-code 14 | trap 'fetch_abort "Unexpected error occurred."' EXIT 15 | 16 | check_supported() { 17 | true 18 | } 19 | 20 | speed_test_url() { 21 | echo "latest-stable/main/${distro_arch}/APKINDEX.tar.gz" 22 | } 23 | 24 | list_mirrors() { 25 | mirror_list_url='http://nl.alpinelinux.org/alpine/MIRRORS.txt' 26 | download -q "${mirror_list_url}" - 27 | } 28 | 29 | brl_arch_to_distro() { 30 | case "${1}" in 31 | "aarch64") echo "aarch64" ;; 32 | "armv7hl") echo "armhf" ;; 33 | "armv7l") echo "armv7" ;; 34 | "ppc64le") echo "ppc64le" ;; 35 | "s390x") echo "s3960x" ;; 36 | "i586") echo "x86" ;; 37 | "x86_64") echo "x86_64" ;; 38 | *) abort "brl does not know how to translate arch \"${1}\" to ${distro} format" ;; 39 | esac 40 | } 41 | 42 | list_architectures() { 43 | cat <"${bootstrap_dir}/apk" 98 | chmod a+rx "${bootstrap_dir}/apk" 99 | mkdir -p "${target_dir}/etc/apk/" 100 | 101 | step "Running bootstrap software" 102 | setup_chroot "${bootstrap_dir}" 103 | setup_ssl "${bootstrap_dir}" 104 | # apk does not appear to cache downloaded packages anywhere we forward 105 | # from a previous fetch. 106 | set +o pipefail 107 | yes "" | LC_ALL=C chroot "${bootstrap_dir}" /apk -X "${target_mirror}/${mirror_release}/main" -U --allow-untrusted --root "/target-root" --initdb add alpine-base 108 | set -o pipefail 109 | 110 | step "Configuring" 111 | setup_chroot "${target_dir}" 112 | echo "${target_mirror}/${mirror_release}/main" >"${target_dir}/etc/apk/repositories" 113 | LC_ALL=C chroot "${target_dir}" /sbin/rc-update add devfs sysinit 114 | LC_ALL=C chroot "${target_dir}" /sbin/rc-update add dmesg sysinit 115 | LC_ALL=C chroot "${target_dir}" /sbin/rc-update add mdev sysinit 116 | LC_ALL=C chroot "${target_dir}" /sbin/rc-update add networking sysinit 117 | LC_ALL=C chroot "${target_dir}" /sbin/rc-update add hwclock boot 118 | LC_ALL=C chroot "${target_dir}" /sbin/rc-update add modules boot 119 | LC_ALL=C chroot "${target_dir}" /sbin/rc-update add sysctl boot 120 | LC_ALL=C chroot "${target_dir}" /sbin/rc-update add hostname boot 121 | LC_ALL=C chroot "${target_dir}" /sbin/rc-update add bootmisc boot 122 | LC_ALL=C chroot "${target_dir}" /sbin/rc-update add syslog boot 123 | LC_ALL=C chroot "${target_dir}" /sbin/rc-update add mount-ro shutdown 124 | LC_ALL=C chroot "${target_dir}" /sbin/rc-update add killprocs shutdown 125 | LC_ALL=C chroot "${target_dir}" /sbin/rc-update add savecache shutdown 126 | } 127 | -------------------------------------------------------------------------------- /src/slash-bedrock/share/brl-fetch/distros/arch: -------------------------------------------------------------------------------- 1 | #!/bedrock/libexec/busybox sh 2 | # 3 | # Arch Linux bootstrap support 4 | # 5 | # This program is free software; you can redistribute it and/or 6 | # modify it under the terms of the GNU General Public License 7 | # version 2 as published by the Free Software Foundation. 8 | # 9 | # Copyright (c) 2016-2019 Daniel Thau 10 | # 11 | 12 | # shellcheck source=src/slash-bedrock/libexec/brl-fetch 13 | . /bedrock/share/common-code 14 | trap 'fetch_abort "Unexpected error occurred."' EXIT 15 | 16 | check_supported() { 17 | true 18 | } 19 | 20 | speed_test_url() { 21 | echo "core/os/${distro_arch}/core.db.tar.gz" 22 | } 23 | 24 | list_mirrors() { 25 | # All mirrors: 26 | # mirror_list_url='https://www.archlinux.org/mirrorlist/all/' 27 | # Server-side filtered list of mirrors: 28 | mirror_list_url='https://www.archlinux.org/mirrorlist/?country=all&protocol=https&ip_version=4&ip_version=6&use_mirror_status=on' 29 | download -q "${mirror_list_url}" - | 30 | awk -F "[ $]" ' /^#Server/ {print$3} ' 31 | } 32 | 33 | brl_arch_to_distro() { 34 | case "${1}" in 35 | "x86_64") echo "x86_64" ;; 36 | *) abort "brl does not know how to translate arch \"${1}\" to ${distro} format" ;; 37 | esac 38 | } 39 | 40 | list_architectures() { 41 | echo "x86_64" 42 | } 43 | 44 | default_release() { 45 | echo "rolling" 46 | } 47 | 48 | list_releases() { 49 | echo "rolling" 50 | } 51 | 52 | setup_pacman() { 53 | # Remove auto architecture detection, as it will confuse things like 54 | # i686 on an x86_64 box and armv7hl on a aarch64 box. 55 | # 56 | # Also remove CheckSpace, which sometimes gets confused by Bedrock's 57 | # mount setup. 58 | sed 's/^Architecture[ \t]*=.*$//' "${1}/etc/pacman.conf" | 59 | awk -v"a=${distro_arch}" '{print} $0 == "[options]" {print "Architecture = "a}' | 60 | sed 's/^[ \t]*CheckSpace/# &/' \ 61 | >"${1}/etc/pacman.conf-new" 62 | mv "${1}/etc/pacman.conf-new" "${1}/etc/pacman.conf" 63 | 64 | # pacman 7.0 defaults to using a limited-privilege alpm user to fetch packages 65 | # This is a worthwhile idea, but brl-fetch doesn't currently have the infrastructure to support it 66 | sed 's/DownloadUser/# DownloadUser/' "${1}/etc/pacman.conf" > "${1}/etc/pacman.conf-new" 67 | mv "${1}/etc/pacman.conf-new" "${1}/etc/pacman.conf" 68 | 69 | LC_ALL=C chroot "${1}" /usr/bin/update-ca-trust 70 | LC_ALL=C chroot "${1}" /usr/bin/pacman-key --init 71 | LC_ALL=C chroot "${1}" /usr/bin/pacman-key --populate archlinux 72 | 73 | if ! grep -q "^Server" "${1}/etc/pacman.d/mirrorlist"; then 74 | echo "### Set by Bedrock Linux when acquiring this stratum" >>"${1}/etc/pacman.d/mirrorlist" 75 | echo "Server = ${target_mirror}/\$repo/os/\$arch" >>"$1/etc/pacman.d/mirrorlist" 76 | fi 77 | } 78 | 79 | fetch() { 80 | bootstrap_deps="arch-install-scripts archlinux-keyring" 81 | 82 | step "Downloading package information database" 83 | download "${target_mirror}/core/os/${distro_arch}/core.db.tar.gz" "${bootstrap_dir}/core.db.tar.gz" 84 | download "${target_mirror}/extra/os/${distro_arch}/extra.db.tar.gz" "${bootstrap_dir}/extra.db.tar.gz" 85 | 86 | step "Decompressing package information database" 87 | mkdir -p "${bootstrap_dir}/pacmandb/core" "${bootstrap_dir}/pacmandb/extra" 88 | ( 89 | tar -xv -f "${bootstrap_dir}/core.db.tar.gz" -C "${bootstrap_dir}/pacmandb/core/" 90 | tar -xv -f "${bootstrap_dir}/extra.db.tar.gz" -C "${bootstrap_dir}/pacmandb/extra/" 91 | ) | awk 'NR%100==0' | progress_unknown 92 | 93 | step "Converting distro package information database to brl format" 94 | pacmandb_to_brldb "${bootstrap_dir}/pacmandb" "${bootstrap_dir}/brldb" 95 | 96 | step "Calculating required bootstrap packages" 97 | brldb_calculate_required_packages "${bootstrap_dir}/brldb" "${bootstrap_dir}/required_packages" "${bootstrap_deps}" 98 | 99 | step "Downloading bootstrap packages" 100 | # brldb contains repo/filename 101 | # files are at mirror/repo/os/arch/filename 102 | checksum_downloads "${cache}/packages/" "$(awk -v"a=${distro_arch}" -v"m=${target_mirror}" '{sub("/", "/os/"a"/"); print m"/"$0}' "${bootstrap_dir}/required_packages")" 103 | 104 | step "Extracting bootstrap packages" 105 | bootstrap_packages="$(awk -v"d=${cache}/packages/" '{sub(/^.*\//,d);print $1}' "${bootstrap_dir}/required_packages")" 106 | # shellcheck disable=SC2086 107 | extract_pacman_pkgs "${bootstrap_dir}" ${bootstrap_packages} 108 | 109 | step "Running bootstrap software" 110 | # pacstrap mounts devtmpfs (which is shared with the host system) and 111 | # chowns files in it based on /etc/passwd and /etc/group. Ensure 112 | # system copies of files are used to avoid problematic file ownership 113 | # change in /dev. 114 | mkdir -p "${target_dir}/etc" 115 | cp -a "/etc/passwd" "${target_dir}/etc/passwd" 116 | cp -a "/etc/group" "${target_dir}/etc/group" 117 | 118 | setup_chroot "${bootstrap_dir}" 119 | setup_ssl "${bootstrap_dir}" 120 | setup_pacman "${bootstrap_dir}" 121 | share_cache "packages" "${bootstrap_dir}/target-root/var/cache/pacman/pkg/" 122 | LC_ALL=C chroot "${bootstrap_dir}" pacstrap "/target-root" base 123 | 124 | step "Configuring" 125 | setup_chroot "${target_dir}" 126 | setup_pacman "${target_dir}" 127 | cp -r "${cache}/packages/"* "${target_dir}/var/cache/pacman/" 128 | if LC_ALL=C chroot "${target_dir}" pacman -Q linux >/dev/null 2>&1; then 129 | LC_ALL=C chroot "${target_dir}" pacman --noconfirm -R linux 130 | fi 131 | } 132 | -------------------------------------------------------------------------------- /src/slash-bedrock/share/brl-fetch/distros/arch-32: -------------------------------------------------------------------------------- 1 | #!/bedrock/libexec/busybox sh 2 | # 3 | # Arch Linux 32 bootstrap support 4 | # 5 | # This program is free software; you can redistribute it and/or 6 | # modify it under the terms of the GNU General Public License 7 | # version 2 as published by the Free Software Foundation. 8 | # 9 | # Copyright (c) 2016-2019 Daniel Thau 10 | # 11 | 12 | # shellcheck source=src/slash-bedrock/libexec/brl-fetch 13 | . /bedrock/share/common-code 14 | trap 'fetch_abort "Unexpected error occurred."' EXIT 15 | 16 | check_supported() { 17 | true 18 | } 19 | 20 | speed_test_url() { 21 | echo "${distro_arch}/core/core.db.tar.gz" 22 | } 23 | 24 | list_mirrors() { 25 | mirror_list_url='https://www.archlinux32.org/mirrorlist/?country=all' 26 | download -q "${mirror_list_url}" - | 27 | sed 's/^# *//' | 28 | awk -F "[ $]" '/^Server/{print$3}' 29 | } 30 | 31 | brl_arch_to_distro() { 32 | # Arch Linux 32 also supports Pentium 4 / Netburst / i786. However, 33 | # they are the only distro to do so, and at the time of writing it is 34 | # not deemed worthwhile to support an architecture only utilized by one 35 | # distro, especially since it is compatible with i686. 36 | case "${1}" in 37 | "i486") echo "i486" ;; 38 | "i686") echo "i686" ;; 39 | *) abort "brl does not know how to translate arch \"${1}\" to ${distro} format" ;; 40 | esac 41 | } 42 | 43 | list_architectures() { 44 | cat <>"${1}/etc/pacman.d/mirrorlist" 71 | echo "Server = ${target_mirror}/\$arch/\$repo" >>"$1/etc/pacman.d/mirrorlist" 72 | fi 73 | } 74 | 75 | fetch() { 76 | bootstrap_deps="arch-install-scripts archlinux32-keyring" 77 | 78 | step "Downloading package information database" 79 | download "${target_mirror}/${distro_arch}/core/core.db.tar.gz" "${bootstrap_dir}/core.db.tar.gz" 80 | download "${target_mirror}/${distro_arch}/extra/extra.db.tar.gz" "${bootstrap_dir}/extra.db.tar.gz" 81 | 82 | step "Decompressing package information database" 83 | mkdir -p "${bootstrap_dir}/pacmandb/core" "${bootstrap_dir}/pacmandb/extra" 84 | ( 85 | tar -xv -f "${bootstrap_dir}/core.db.tar.gz" -C "${bootstrap_dir}/pacmandb/core/" 86 | tar -xv -f "${bootstrap_dir}/extra.db.tar.gz" -C "${bootstrap_dir}/pacmandb/extra/" 87 | ) | awk 'NR%100==0' | progress_unknown 88 | 89 | step "Converting distro package information database to brl format" 90 | pacmandb_to_brldb "${bootstrap_dir}/pacmandb" "${bootstrap_dir}/brldb" 91 | 92 | step "Calculating required bootstrap packages" 93 | brldb_calculate_required_packages "${bootstrap_dir}/brldb" "${bootstrap_dir}/required_packages" "${bootstrap_deps}" 94 | 95 | step "Downloading bootstrap packages" 96 | # brldb contains repo/filename 97 | # files are at mirror/arch/repo/filename 98 | checksum_downloads "${cache}/packages/" "$(awk -v"a=${distro_arch}" -v"m=${target_mirror}" '{print m"/"a"/"$0}' "${bootstrap_dir}/required_packages")" 99 | 100 | step "Extracting bootstrap packages" 101 | bootstrap_packages="$(awk -v"d=${cache}/packages/" '{sub(/^.*\//,d);print $1}' "${bootstrap_dir}/required_packages")" 102 | # shellcheck disable=SC2086 103 | extract_pacman_pkgs "${bootstrap_dir}" ${bootstrap_packages} 104 | 105 | step "Running bootstrap software" 106 | # pacstrap mounts devtmpfs (which is shared with the host system) and 107 | # chowns files in it based on /etc/passwd and /etc/group. Ensure 108 | # system copies of files are used to avoid problematic file ownership 109 | # change in /dev. 110 | mkdir -p "${target_dir}/etc" 111 | cp -a "/etc/passwd" "${target_dir}/etc/passwd" 112 | cp -a "/etc/group" "${target_dir}/etc/group" 113 | 114 | setup_chroot "${bootstrap_dir}" 115 | setup_ssl "${bootstrap_dir}" 116 | setup_pacman "${bootstrap_dir}" 117 | share_cache "packages" "${bootstrap_dir}/target-root/var/cache/pacman/pkg/" 118 | LC_ALL=C chroot "${bootstrap_dir}" pacstrap "/target-root" base 119 | 120 | step "Configuring" 121 | setup_chroot "${target_dir}" 122 | setup_pacman "${target_dir}" 123 | cp "${cache}/packages/"* "${target_dir}/var/cache/pacman/" 124 | if LC_ALL=C chroot "${target_dir}" pacman -Q linux >/dev/null 2>&1; then 125 | LC_ALL=C chroot "${target_dir}" pacman --noconfirm -R linux 126 | fi 127 | } 128 | -------------------------------------------------------------------------------- /src/slash-bedrock/share/brl-fetch/distros/artix: -------------------------------------------------------------------------------- 1 | #!/bedrock/libexec/busybox sh 2 | # 3 | # Artix Linux bootstrap support 4 | # 5 | # This program is free software; you can redistribute it and/or 6 | # modify it under the terms of the GNU General Public License 7 | # version 2 as published by the Free Software Foundation. 8 | # 9 | # Copyright (c) 2016-2019 Daniel Thau 10 | # 11 | 12 | # shellcheck source=src/slash-bedrock/libexec/brl-fetch 13 | . /bedrock/share/common-code 14 | trap 'fetch_abort "Unexpected error occurred."' EXIT 15 | 16 | check_supported() { 17 | false 18 | } 19 | 20 | speed_test_url() { 21 | echo "system/os/${distro_arch}/system.db.tar.gz" 22 | } 23 | 24 | list_mirrors() { 25 | # All mirrors: 26 | # Server-side filtered list of mirrors: 27 | mirror_list_url="https://raw.githubusercontent.com/artix-linux/packages/master/artix-mirrorlist/repos/core-any/mirrorlist" 28 | download -q "${mirror_list_url}" - | 29 | awk -F "[ $]" ' /^Server/ {print$3} ' 30 | } 31 | 32 | brl_arch_to_distro() { 33 | case "${1}" in 34 | "x86_64") echo "x86_64" ;; 35 | *) abort "brl does not know how to translate arch \"${1}\" to ${distro} format" ;; 36 | esac 37 | } 38 | 39 | list_architectures() { 40 | echo "x86_64" 41 | } 42 | 43 | default_release() { 44 | echo "rolling" 45 | } 46 | 47 | list_releases() { 48 | echo "rolling" 49 | } 50 | 51 | setup_pacman() { 52 | # Remove auto architecture detection, as it will confuse things like 53 | # i686 on an x86_64 box and armv7hl on a aarch64 box. 54 | # 55 | # Also remove CheckSpace, which sometimes gets confused by Bedrock's 56 | # mount setup. 57 | sed 's/^Architecture[ \t]*=.*$//' "${1}/etc/pacman.conf" | 58 | awk -v"a=${distro_arch}" '{print} $0 == "[options]" {print "Architecture = "a}' | 59 | sed 's/^[ \t]*CheckSpace/# &/' \ 60 | >"${1}/etc/pacman.conf-new" 61 | mv "${1}/etc/pacman.conf-new" "${1}/etc/pacman.conf" 62 | 63 | LC_ALL=C chroot "${1}" /usr/bin/update-ca-trust 64 | LC_ALL=C chroot "${1}" /usr/bin/pacman-key --init 65 | LC_ALL=C chroot "${1}" /usr/bin/pacman-key --populate artix 66 | 67 | if ! grep -q "^Server" "${1}/etc/pacman.d/mirrorlist"; then 68 | echo "### Set by Bedrock Linux when acquiring this stratum" >>"${1}/etc/pacman.d/mirrorlist" 69 | echo "Server = ${target_mirror}/\$repo/os/\$arch" >>"$1/etc/pacman.d/mirrorlist" 70 | fi 71 | } 72 | 73 | fetch() { 74 | bootstrap_deps="artools-base util-linux gettext pacman artix-keyring" 75 | 76 | step "Downloading package information database" 77 | download "${target_mirror}/system/os/${distro_arch}/system.db.tar.gz" "${bootstrap_dir}/system.db.tar.gz" 78 | download "${target_mirror}/world/os/${distro_arch}/world.db.tar.gz" "${bootstrap_dir}/world.db.tar.gz" 79 | 80 | step "Decompressing package information database" 81 | mkdir -p "${bootstrap_dir}/pacmandb/system" "${bootstrap_dir}/pacmandb/world" 82 | ( 83 | tar -xv -f "${bootstrap_dir}/system.db.tar.gz" -C "${bootstrap_dir}/pacmandb/system/" 84 | tar -xv -f "${bootstrap_dir}/world.db.tar.gz" -C "${bootstrap_dir}/pacmandb/world/" 85 | ) | awk 'NR%100==0' | progress_unknown 86 | 87 | step "Converting distro package information database to brl format" 88 | pacmandb_to_brldb "${bootstrap_dir}/pacmandb" "${bootstrap_dir}/brldb" 89 | 90 | step "Calculating required bootstrap packages" 91 | brldb_calculate_required_packages "${bootstrap_dir}/brldb" "${bootstrap_dir}/required_packages" "${bootstrap_deps}" 92 | 93 | step "Downloading bootstrap packages" 94 | # brldb contains repo/filename 95 | # files are at mirror/repo/os/arch/filename 96 | checksum_downloads "${cache}/packages/" "$(awk -v"a=${distro_arch}" -v"m=${target_mirror}" '{sub("/", "/os/"a"/"); print m"/"$0}' "${bootstrap_dir}/required_packages")" 97 | 98 | step "Extracting bootstrap packages" 99 | bootstrap_packages="$(awk -v"d=${cache}/packages/" '{sub(/^.*\//,d);print $1}' "${bootstrap_dir}/required_packages")" 100 | # shellcheck disable=SC2086 101 | extract_pacman_pkgs "${bootstrap_dir}" ${bootstrap_packages} 102 | 103 | step "Running bootstrap software" 104 | # pacstrap mounts devtmpfs (which is shared with the host system) and 105 | # chowns files in it based on /etc/passwd and /etc/group. Ensure 106 | # system copies of files are used to avoid problematic file ownership 107 | # change in /dev. 108 | mkdir -p "${target_dir}/etc" 109 | cp -a "/etc/passwd" "${target_dir}/etc/passwd" 110 | cp -a "/etc/group" "${target_dir}/etc/group" 111 | 112 | setup_chroot "${bootstrap_dir}" 113 | setup_ssl "${bootstrap_dir}" 114 | setup_pacman "${bootstrap_dir}" 115 | share_cache "packages" "${bootstrap_dir}/target-root/var/cache/pacman/pkg/" 116 | # sed is not included in base, but is needed to basestrap. 117 | LC_ALL=C chroot "${bootstrap_dir}" basestrap "/target-root" base sed 118 | 119 | step "Configuring" 120 | setup_chroot "${target_dir}" 121 | setup_pacman "${target_dir}" 122 | cp "${cache}/packages/"* "${target_dir}/var/cache/pacman/" 123 | if LC_ALL=C chroot "${target_dir}" pacman -Q linux >/dev/null 2>&1; then 124 | LC_ALL=C chroot "${target_dir}" pacman --noconfirm -R linux 125 | fi 126 | } 127 | -------------------------------------------------------------------------------- /src/slash-bedrock/share/brl-fetch/distros/artix-s6: -------------------------------------------------------------------------------- 1 | #!/bedrock/libexec/busybox sh 2 | # 3 | # Artix Linux with s6 init bootstrap support 4 | # 5 | # This program is free software; you can redistribute it and/or 6 | # modify it under the terms of the GNU General Public License 7 | # version 2 as published by the Free Software Foundation. 8 | # 9 | # Copyright (c) 2016-2021 Daniel Thau 10 | # 11 | 12 | # shellcheck source=src/slash-bedrock/libexec/brl-fetch 13 | . /bedrock/share/common-code 14 | trap 'fetch_abort "Unexpected error occurred."' EXIT 15 | 16 | check_supported() { 17 | false 18 | } 19 | 20 | speed_test_url() { 21 | echo "system/os/${distro_arch}/system.db.tar.gz" 22 | } 23 | 24 | list_mirrors() { 25 | # All mirrors: 26 | # Server-side filtered list of mirrors: 27 | mirror_list_url="https://raw.githubusercontent.com/artix-linux/packages/master/artix-mirrorlist/repos/core-any/mirrorlist" 28 | download -q "${mirror_list_url}" - | 29 | awk -F "[ $]" ' /^Server/ {print$3} ' 30 | } 31 | 32 | brl_arch_to_distro() { 33 | case "${1}" in 34 | "x86_64") echo "x86_64" ;; 35 | *) abort "brl does not know how to translate arch \"${1}\" to ${distro} format" ;; 36 | esac 37 | } 38 | 39 | list_architectures() { 40 | echo "x86_64" 41 | } 42 | 43 | default_release() { 44 | echo "rolling" 45 | } 46 | 47 | list_releases() { 48 | echo "rolling" 49 | } 50 | 51 | setup_pacman() { 52 | # Remove auto architecture detection, as it will confuse things like 53 | # i686 on an x86_64 box and armv7hl on a aarch64 box. 54 | # 55 | # Also remove CheckSpace, which sometimes gets confused by Bedrock's 56 | # mount setup. 57 | sed 's/^Architecture[ \t]*=.*$//' "${1}/etc/pacman.conf" | 58 | awk -v"a=${distro_arch}" '{print} $0 == "[options]" {print "Architecture = "a}' | 59 | sed 's/^[ \t]*CheckSpace/# &/' \ 60 | >"${1}/etc/pacman.conf-new" 61 | mv "${1}/etc/pacman.conf-new" "${1}/etc/pacman.conf" 62 | 63 | LC_ALL=C chroot "${1}" /usr/bin/update-ca-trust 64 | LC_ALL=C chroot "${1}" /usr/bin/pacman-key --init 65 | LC_ALL=C chroot "${1}" /usr/bin/pacman-key --populate artix 66 | 67 | if ! grep -q "^Server" "${1}/etc/pacman.d/mirrorlist"; then 68 | echo "### Set by Bedrock Linux when acquiring this stratum" >>"${1}/etc/pacman.d/mirrorlist" 69 | echo "Server = ${target_mirror}/\$repo/os/\$arch" >>"$1/etc/pacman.d/mirrorlist" 70 | fi 71 | } 72 | 73 | fetch() { 74 | bootstrap_deps="artools-base util-linux gettext pacman artix-keyring" 75 | 76 | step "Downloading package information database" 77 | download "${target_mirror}/system/os/${distro_arch}/system.db.tar.gz" "${bootstrap_dir}/system.db.tar.gz" 78 | download "${target_mirror}/world/os/${distro_arch}/world.db.tar.gz" "${bootstrap_dir}/world.db.tar.gz" 79 | 80 | step "Decompressing package information database" 81 | mkdir -p "${bootstrap_dir}/pacmandb/system" "${bootstrap_dir}/pacmandb/world" 82 | ( 83 | tar -xv -f "${bootstrap_dir}/system.db.tar.gz" -C "${bootstrap_dir}/pacmandb/system/" 84 | tar -xv -f "${bootstrap_dir}/world.db.tar.gz" -C "${bootstrap_dir}/pacmandb/world/" 85 | ) | awk 'NR%100==0' | progress_unknown 86 | 87 | step "Converting distro package information database to brl format" 88 | pacmandb_to_brldb "${bootstrap_dir}/pacmandb" "${bootstrap_dir}/brldb" 89 | 90 | step "Calculating required bootstrap packages" 91 | brldb_calculate_required_packages "${bootstrap_dir}/brldb" "${bootstrap_dir}/required_packages" "${bootstrap_deps}" 92 | 93 | step "Downloading bootstrap packages" 94 | # brldb contains repo/filename 95 | # files are at mirror/repo/os/arch/filename 96 | checksum_downloads "${cache}/packages/" "$(awk -v"a=${distro_arch}" -v"m=${target_mirror}" '{sub("/", "/os/"a"/"); print m"/"$0}' "${bootstrap_dir}/required_packages")" 97 | 98 | step "Extracting bootstrap packages" 99 | bootstrap_packages="$(awk -v"d=${cache}/packages/" '{sub(/^.*\//,d);print $1}' "${bootstrap_dir}/required_packages")" 100 | # shellcheck disable=SC2086 101 | extract_pacman_pkgs "${bootstrap_dir}" ${bootstrap_packages} 102 | 103 | step "Running bootstrap software" 104 | # pacstrap mounts devtmpfs (which is shared with the host system) and 105 | # chowns files in it based on /etc/passwd and /etc/group. Ensure 106 | # system copies of files are used to avoid problematic file ownership 107 | # change in /dev. 108 | mkdir -p "${target_dir}/etc" 109 | cp -a "/etc/passwd" "${target_dir}/etc/passwd" 110 | cp -a "/etc/group" "${target_dir}/etc/group" 111 | 112 | setup_chroot "${bootstrap_dir}" 113 | setup_ssl "${bootstrap_dir}" 114 | setup_pacman "${bootstrap_dir}" 115 | share_cache "packages" "${bootstrap_dir}/target-root/var/cache/pacman/pkg/" 116 | # sed is not included in base, but is needed to basestrap. 117 | LC_ALL=C chroot "${bootstrap_dir}" basestrap "/target-root" base sed s6-base dbus-s6 elogind-s6 eudev-s6 118 | 119 | step "Configuring" 120 | setup_chroot "${target_dir}" 121 | setup_pacman "${target_dir}" 122 | cp "${cache}/packages/"* "${target_dir}/var/cache/pacman/" 123 | if LC_ALL=C chroot "${target_dir}" pacman -Q linux >/dev/null 2>&1; then 124 | LC_ALL=C chroot "${target_dir}" pacman --noconfirm -R linux 125 | fi 126 | } 127 | -------------------------------------------------------------------------------- /src/slash-bedrock/share/brl-fetch/distros/clear: -------------------------------------------------------------------------------- 1 | #!/bedrock/libexec/busybox sh 2 | # 3 | # Clear Linux bootstrap support 4 | # 5 | # This program is free software; you can redistribute it and/or 6 | # modify it under the terms of the GNU General Public License 7 | # version 2 as published by the Free Software Foundation. 8 | # 9 | # Copyright (c) 2019 Daniel Thau 10 | # 11 | 12 | # shellcheck source=src/slash-bedrock/libexec/brl-fetch 13 | . /bedrock/share/common-code 14 | trap 'fetch_abort "Unexpected error occurred."' EXIT 15 | 16 | check_supported() { 17 | false 18 | } 19 | 20 | speed_test_url() { 21 | echo "1/Manifest.MoM.tar" 22 | } 23 | 24 | list_mirrors() { 25 | echo "https://cdn.download.clearlinux.org/" 26 | } 27 | 28 | brl_arch_to_distro() { 29 | case "${1}" in 30 | "x86_64") echo "x86_64" ;; 31 | *) abort "brl does not know how to translate arch \"${1}\" to ${distro} format" ;; 32 | esac 33 | } 34 | 35 | list_architectures() { 36 | echo "x86_64" 37 | } 38 | 39 | default_release() { 40 | echo "rolling" 41 | } 42 | 43 | list_releases() { 44 | echo "rolling" 45 | } 46 | 47 | fetch() { 48 | step "Calculating required bootstrap packages" 49 | clear_update="$(download "${target_mirror}/current/latest" -)" 50 | notice "Using update ${clear_update}" 51 | download -q "${target_mirror}/update/${clear_update}/Manifest.MoM" "${bootstrap_dir}/Manifest.MoM" 52 | loop=true 53 | NL=" 54 | " 55 | required_bundles="os-core-update" 56 | while "${loop}"; do 57 | loop=false 58 | for bundle in ${required_bundles}; do 59 | if [ -e "${bootstrap_dir}/Manifest.${bundle}" ]; then 60 | continue 61 | fi 62 | loop=true 63 | update="$(awk -v"bundle=${bundle}" '$0 ~ /^M/ && $4 == bundle {print $3; exit}' "${bootstrap_dir}/Manifest.MoM")" 64 | download -q "${target_mirror}/update/${update}/Manifest.${bundle}" "${bootstrap_dir}/Manifest.${bundle}" 65 | required_bundles="${required_bundles}${NL}$(awk '$1 == "includes:" {print $2}' "${bootstrap_dir}/Manifest.${bundle}")" 66 | echo "${required_bundles}" | sort | uniq | grep "." >"${bootstrap_dir}/required_bundles" 67 | echo "x" 68 | done 69 | done | progress_unknown 70 | required_bundles="$(cat "${bootstrap_dir}/required_bundles")" 71 | notice "Bundles required to bootstrap swupd: $(echo "${required_bundles}" | tr '\n' ' ')" 72 | 73 | # Packs themselves aren't checksumed; their contents are. There isn't 74 | # a clean way to invalidate cached packs here, so just download them 75 | # every time. 76 | step "Downloading bootstrap software" 77 | total="$(echo "${required_bundles}" | wc -w)" 78 | for bundle in ${required_bundles}; do 79 | update="$(awk -v"bundle=${bundle}" '$0 ~ /^M/ && $4 == bundle {print $3; exit}' "${bootstrap_dir}/Manifest.MoM")" 80 | download -q "${target_mirror}/update/${update}/pack-${bundle}-from-0.tar" "${bootstrap_dir}/pack-${bundle}-from-0.tar" 81 | echo "x" 82 | done | progress_bar "${total}" 83 | 84 | step "Extracting bootstrap packages (1/2)" 85 | for tarball in "${bootstrap_dir}/pack"*.tar; do 86 | tar xf "${tarball}" -C "${bootstrap_dir}" 87 | echo "x" 88 | done | progress_bar "${total}" 89 | 90 | step "Extracting bootstrap packages (2/2)" 91 | rm "${bootstrap_dir}/Manifest.MoM" 92 | total="$(awk 'NF==4' "${bootstrap_dir}/Manifest."* | wc -l)" 93 | awk 'NF==4' "${bootstrap_dir}/Manifest."* | while read -r line; do 94 | type="$(echo "${line}" | cut -d" " -f1)" 95 | if echo "${type}" | grep -q '^[DFL]'; then 96 | hash="$(echo "${line}" | cut -d" " -f2)" 97 | path="$(echo "${line}" | cut -d" " -f4-)" 98 | dest="${bootstrap_dir}/${path}" 99 | mkdir -p "$(dirname "${dest}")" 100 | cp -a "${bootstrap_dir}/staged/${hash}" "${dest}" 101 | fi 102 | echo "x" 103 | done | progress_bar "${total}" 104 | 105 | step "Running bootstrap software" 106 | setup_chroot "${bootstrap_dir}" 107 | setup_ssl "${bootstrap_dir}" 108 | # system passwd/group confuses os-install's hash check 109 | rm -f "${bootstrap_dir}/etc/passwd" "${bootstrap_dir}/etc/group" 110 | # swupd appears to remove packs after use such that we can't cache them between runs. 111 | LC_ALL=en_US.UTF-8 chroot "${bootstrap_dir}" swupd os-install --url "${target_mirror}/update" --no-boot-update --version "${clear_update}" -B os-core-update /target-root 112 | 113 | step "Configuring" 114 | # Setup certs 115 | LC_ALL=C chroot "${target_dir}" clrtrust generate 116 | mkdir -p "${target_dir}/etc/ssl" 117 | ln -s /var/cache/ca-certs/anchors "${target_dir}/etc/ssl/certs" 118 | # Clear Linux does not populate various /etc files on which Bedrock 119 | # depends, even if their corresponding package is installed. Create 120 | # them. 121 | echo "# File created by Bedrock Linux during stratum fetch" >"${target_dir}/etc/profile" 122 | if ! [ -e "${target_dir}/etc/zshenv" ]; then 123 | mkdir -p "${target_dir}/etc/zsh/" 124 | echo "# File created by Bedrock Linux during stratum fetch" >"${target_dir}/etc/zshenv" 125 | fi 126 | } 127 | -------------------------------------------------------------------------------- /src/slash-bedrock/share/brl-fetch/distros/crux: -------------------------------------------------------------------------------- 1 | #!/bedrock/libexec/busybox sh 2 | # 3 | # CRUX bootstrap support 4 | # 5 | # This program is free software; you can redistribute it and/or 6 | # modify it under the terms of the GNU General Public License 7 | # version 2 as published by the Free Software Foundation. 8 | # 9 | # Copyright (c) 2016-2019 Daniel Thau 10 | # 11 | 12 | # shellcheck source=src/slash-bedrock/libexec/brl-fetch 13 | . /bedrock/share/common-code 14 | trap 'fetch_abort "Unexpected error occurred."' EXIT 15 | 16 | check_supported() { 17 | false 18 | } 19 | 20 | speed_test_url() { 21 | echo "loop/crux/handbook.txt" 22 | } 23 | 24 | list_mirrors() { 25 | mirror_list_url='https://crux.nu/Main/Download' 26 | download -q "${mirror_list_url}" - | 27 | awk '/
/dev/null 2>&1 || true 70 | mount -t iso9660 -o loop,ro "${cache}/crux.iso" "${bootstrap_dir}" 71 | cat "${bootstrap_dir}"/crux/core/pkgutils*.tar.xz | xz -d | tar xf - -O usr/bin/pkgadd >"${target_dir}/pkgadd" 72 | chmod a+rx "${target_dir}/pkgadd" 73 | mkdir -p "${target_dir}/var/lib/pkg" 74 | touch "${target_dir}/var/lib/pkg/db" 75 | 76 | step "Running bootstrap software" 77 | total="$(find "${bootstrap_dir}/crux/core/" -mindepth 1 -maxdepth 1 | wc -l)" 78 | for pkg in "${bootstrap_dir}"/crux/core/*; do 79 | echo "${pkg}" 80 | # hiding stderr to ignore noise about .py files not being ELF files 81 | "${target_dir}/pkgadd" -r "${target_dir}" "${pkg}" 2>/dev/null 82 | done | progress_bar "${total}" 83 | 84 | step "Configuring" 85 | 86 | sed \ 87 | -e "s/^HOSTNAME=.*/HOSTNAME=$(hostname)/" \ 88 | -e "s/^TIMEZONE=.*/TIMEZONE=/" \ 89 | "${target_dir}/etc/rc.conf" >"${target_dir}/etc/rc.conf-new" 90 | mv "${target_dir}/etc/rc.conf-new" "${target_dir}/etc/rc.conf" 91 | 92 | # Hack to fix concern around shutdown script running off of bedrock 93 | # fuse filesystem. 94 | # TODO: get this to work properly 95 | mv "${target_dir}/etc/rc.shutdown" "${target_dir}/rc.shutdown" 96 | ln -s "../rc.shutdown" "${target_dir}/etc/rc.shutdown" 97 | } 98 | -------------------------------------------------------------------------------- /src/slash-bedrock/share/brl-fetch/distros/debian: -------------------------------------------------------------------------------- 1 | #!/bedrock/libexec/busybox sh 2 | # 3 | # Debian bootstrap support 4 | # 5 | # This program is free software; you can redistribute it and/or 6 | # modify it under the terms of the GNU General Public License 7 | # version 2 as published by the Free Software Foundation. 8 | # 9 | # Copyright (c) 2016-2021 Daniel Thau 10 | # 11 | 12 | # shellcheck source=src/slash-bedrock/libexec/brl-fetch 13 | . /bedrock/share/common-code 14 | trap 'fetch_abort "Unexpected error occurred."' EXIT 15 | 16 | check_supported() { 17 | true 18 | } 19 | 20 | speed_test_url() { 21 | echo "dists/${target_release}/Release" 22 | } 23 | 24 | list_mirrors() { 25 | mirror_list_url='https://www.debian.org/mirror/list' 26 | download -q "${mirror_list_url}" - | 27 | awk '/
" | 29 | list_links | 30 | grep "^http" 31 | } 32 | 33 | brl_arch_to_distro() { 34 | case "${1}" in 35 | "aarch64") echo "arm64" ;; 36 | "armv7hl") echo "armhf" ;; 37 | "armv7l") echo "armel" ;; 38 | "mips64el") echo "mips64el" ;; 39 | "mipsel") echo "mipsel" ;; 40 | "ppc64le") echo "ppc64el" ;; 41 | "s390x") echo "s390x" ;; 42 | "i686") echo "i386" ;; 43 | "x86_64") echo "amd64" ;; 44 | *) abort "brl does not know how to translate arch \"${1}\" to ${distro} format" ;; 45 | esac 46 | } 47 | 48 | list_architectures() { 49 | cat <>"${target_dir}/etc/apt/sources.list" 132 | else 133 | # new security format 134 | echo "deb http://security.debian.org/debian-security ${target_release}-security main" >>"${target_dir}/etc/apt/sources.list" 135 | fi 136 | set +o pipefail 137 | setup_chroot "${target_dir}" 138 | autopkgs="$(LANG=C chroot "${target_dir}" /usr/bin/apt-mark showmanual)" 139 | # word splitting is desired here 140 | # shellcheck disable=SC2086 141 | yes "" | LANG=C chroot "${target_dir}" /usr/bin/apt-mark auto ${autopkgs} 142 | yes "" | LANG=C chroot "${target_dir}" /usr/bin/apt-get update 143 | yes "" | LANG=C chroot "${target_dir}" /usr/bin/apt-get install locales-all 144 | set -o pipefail 145 | } 146 | -------------------------------------------------------------------------------- /src/slash-bedrock/share/brl-fetch/distros/devuan: -------------------------------------------------------------------------------- 1 | #!/bedrock/libexec/busybox sh 2 | # 3 | # Devuan bootstrap support 4 | # 5 | # This program is free software; you can redistribute it and/or 6 | # modify it under the terms of the GNU General Public License 7 | # version 2 as published by the Free Software Foundation. 8 | # 9 | # Copyright (c) 2016-2020 Daniel Thau 10 | # 11 | 12 | # shellcheck source=src/slash-bedrock/libexec/brl-fetch 13 | . /bedrock/share/common-code 14 | trap 'fetch_abort "Unexpected error occurred."' EXIT 15 | 16 | check_supported() { 17 | true 18 | } 19 | 20 | speed_test_url() { 21 | echo "dists/${target_release}/Release" 22 | } 23 | 24 | list_mirrors() { 25 | echo 'http://deb.devuan.org/merged' 26 | } 27 | 28 | brl_arch_to_distro() { 29 | case "${1}" in 30 | "aarch64") echo "arm64" ;; 31 | "armv7hl") echo "armhf" ;; 32 | "armv7l") echo "armel" ;; 33 | "mips64el") echo "mips64el" ;; 34 | "mipsel") echo "mipsel" ;; 35 | "ppc64le") echo "ppc64el" ;; 36 | "s390x") echo "s390x" ;; 37 | "i686") echo "i686" ;; 38 | "x86_64") echo "amd64" ;; 39 | *) abort "brl does not know how to translate arch \"${1}\" to ${distro} format" ;; 40 | esac 41 | } 42 | 43 | list_architectures() { 44 | cat <>"${target_dir}/etc/apt/sources.list" 123 | fi 124 | set +o pipefail 125 | setup_chroot "${target_dir}" 126 | autopkgs="$(LANG=C chroot "${target_dir}" /usr/bin/apt-mark showmanual)" 127 | # word splitting is desired here 128 | # shellcheck disable=SC2086 129 | yes "" | LANG=C chroot "${target_dir}" /usr/bin/apt-mark auto ${autopkgs} 130 | yes "" | LANG=C chroot "${target_dir}" /usr/bin/apt-get update 131 | yes "" | LANG=C chroot "${target_dir}" /usr/bin/apt-get install locales-all 132 | set -o pipefail 133 | } 134 | -------------------------------------------------------------------------------- /src/slash-bedrock/share/brl-fetch/distros/exherbo: -------------------------------------------------------------------------------- 1 | #!/bedrock/libexec/busybox sh 2 | # 3 | # Exherbo Linux bootstrap support 4 | # Copyright 2019 Wulf C. Krueger 5 | # Distributed under the terms of the GNU General Public License v2 6 | # 7 | # based in part upon "Gentoo Linux bootstrap support" which is: 8 | # This program is free software; you can redistribute it and/or 9 | # modify it under the terms of the GNU General Public License 10 | # version 2 as published by the Free Software Foundation. 11 | # 12 | # Copyright (c) 2016-2019 Daniel Thau 13 | 14 | # shellcheck source=src/slash-bedrock/libexec/brl-fetch 15 | . /bedrock/share/common-code 16 | trap 'fetch_abort "Unexpected error occurred."' EXIT 17 | 18 | check_supported() { 19 | false 20 | } 21 | 22 | speed_test_url() { 23 | echo "/index.html" 24 | } 25 | 26 | list_mirrors() { 27 | echo "https://dev.exherbo.org/" 28 | } 29 | 30 | brl_arch_to_distro() { 31 | case "${1}" in 32 | "aarch64") echo "aarch64" ;; 33 | "armv7hl") echo "armv7" ;; 34 | "x86_64") echo "x86_64" ;; 35 | *) abort "brl does not know how to translate arch \"${1}\" to ${distro} format" ;; 36 | esac 37 | } 38 | 39 | list_architectures() { 40 | cat < 5 | # Distributed under the terms of the GNU General Public License v2 6 | # 7 | # based in part upon "Gentoo Linux bootstrap support" which is: 8 | # This program is free software; you can redistribute it and/or 9 | # modify it under the terms of the GNU General Public License 10 | # version 2 as published by the Free Software Foundation. 11 | # 12 | # Copyright (c) 2016-2019 Daniel Thau 13 | 14 | # shellcheck source=src/slash-bedrock/libexec/brl-fetch 15 | . /bedrock/share/common-code 16 | trap 'fetch_abort "Unexpected error occurred."' EXIT 17 | 18 | check_supported() { 19 | false 20 | } 21 | 22 | speed_test_url() { 23 | echo "/index.html" 24 | } 25 | 26 | list_mirrors() { 27 | echo "https://dev.exherbo.org/" 28 | } 29 | 30 | brl_arch_to_distro() { 31 | case "${1}" in 32 | "x86_64") echo "x86_64" ;; 33 | *) abort "brl does not know how to translate arch \"${1}\" to ${distro} format" ;; 34 | esac 35 | } 36 | 37 | list_architectures() { 38 | cat < 10 | # 11 | 12 | # shellcheck source=src/slash-bedrock/libexec/brl-fetch 13 | . /bedrock/share/common-code 14 | trap 'fetch_abort "Unexpected error occurred."' EXIT 15 | 16 | check_supported() { 17 | true 18 | } 19 | 20 | speed_test_url() { 21 | echo "releases/verify-digests.sh" 22 | } 23 | 24 | list_mirrors() { 25 | mirror_list_url="https://www.gentoo.org/downloads/mirrors/" 26 | download -q "${mirror_list_url}" - | 27 | awk '/Region/,/
/' | 28 | list_links | 29 | grep "^http" 30 | } 31 | 32 | brl_arch_to_distro() { 33 | case "${1}" in 34 | "aarch64") echo "arm64" ;; 35 | "armv7hl") echo "armv7a_hardfp" ;; 36 | "armv7l") echo "armv7a" ;; 37 | "i486") echo "i486" ;; 38 | "i686") echo "i686" ;; 39 | "ppc") echo "ppc" ;; 40 | "ppc64") echo "ppc64" ;; 41 | "ppc64le") echo "ppc64le" ;; 42 | "s390x") echo "s3960x" ;; 43 | "x86_64") echo "amd64" ;; 44 | *) abort "brl does not know how to translate arch \"${1}\" to ${distro} format" ;; 45 | esac 46 | } 47 | 48 | list_architectures() { 49 | cat </dev/null; then 90 | echo "${group}" 91 | echo "${flavor}" 92 | return 93 | fi 94 | done 95 | done)" 96 | echo "group_flavor: ${group_flavor}" 97 | group="$(echo "${group_flavor}" | sed -n 1p)" 98 | flavor="$(echo "${group_flavor}" | sed -n 2p)" 99 | if [ -z "${group}" ] || [ -z "${flavor}" ]; then 100 | abort "Could not find bootstrap software at ${target_mirror} for ${distro_arch}." 101 | fi 102 | 103 | step "Downloading bootstrap software" 104 | bootstrap_url="$(find_link "${target_mirror}/releases/${group}/autobuilds/current-stage3-${distro_arch}-${flavor}/" "^stage3-${distro_arch}-${flavor}-[^.]*[.]tar[.]\(xz\|bz2\)$")" 105 | bootstrap_name="$(echo "${bootstrap_url}" | sed 's,^.*/,,')" 106 | download "${bootstrap_url}.DIGESTS" "${bootstrap_dir}/checksum" 107 | bootstrap_checksum="$(awk -v"name=${bootstrap_name}" '/^# .* HASH$/ {hash=$2;next} hash == "SHA512" && $2 == name {print$1;exit}' "${bootstrap_dir}/checksum")" 108 | cache_name="stage3.tar.$(echo "${bootstrap_name}" | sed 's/^.*[.]//')" 109 | checksum_download "${cache}/${cache_name}" "sha512sum" "${bootstrap_checksum}" "${bootstrap_url}" 110 | 111 | step "Preparing bootstrap software" 112 | tar -xv -f "${cache}/${cache_name}" -C "${bootstrap_dir}" | awk 'NR%100==0' | progress_unknown 113 | 114 | step "Running bootstrap software" 115 | setup_chroot "${bootstrap_dir}" 116 | setup_ssl "${bootstrap_dir}" 117 | share_cache "." "${bootstrap_dir}/tarballs" 118 | chroot "${bootstrap_dir}" sh -c "cd /target-root && tar xpfv /tarballs/stage3.tar.* --xattrs-include='*.*' --numeric-owner" | awk 'NR%100==0' | progress_unknown 119 | 120 | step "Configuring" 121 | setup_chroot "${target_dir}" 122 | echo "GENTOO_MIRRORS=\"${target_mirror}\"" >>"${target_dir}/etc/portage/make.conf" 123 | mkdir -p "${target_dir}/etc/portage/repos.conf" 124 | cp "${target_dir}/usr/share/portage/config/repos.conf" "${target_dir}/etc/portage/repos.conf/gentoo.conf" 125 | LC_ALL=C chroot "${target_dir}" emerge-webrsync 126 | } 127 | -------------------------------------------------------------------------------- /src/slash-bedrock/share/brl-fetch/distros/kiss: -------------------------------------------------------------------------------- 1 | #!/bedrock/libexec/busybox sh 2 | # 3 | # KISS Linux bootstrap support 4 | # 5 | # This program is free software; you can redistribute it and/or 6 | # modify it under the terms of the GNU General Public License 7 | # version 2 as published by the Free Software Foundation. 8 | # 9 | # Copyright (c) 2019-2020 Daniel Thau 10 | # 11 | 12 | # shellcheck source=src/slash-bedrock/libexec/brl-fetch 13 | . /bedrock/share/common-code 14 | trap 'fetch_abort "Unexpected error occurred."' EXIT 15 | 16 | check_supported() { 17 | false 18 | } 19 | 20 | speed_test_url() { 21 | echo "latest" 22 | } 23 | 24 | list_mirrors() { 25 | echo 'https://github.com/kisslinux/repo/releases' 26 | } 27 | 28 | brl_arch_to_distro() { 29 | case "${1}" in 30 | "x86_64") echo "x86_64" ;; 31 | *) abort "brl does not know how to translate arch \"${1}\" to ${distro} format" ;; 32 | esac 33 | } 34 | 35 | list_architectures() { 36 | cat < 10 | # 11 | 12 | # shellcheck source=src/slash-bedrock/libexec/brl-fetch 13 | . /bedrock/share/common-code 14 | trap 'fetch_abort "Unexpected error occurred."' EXIT 15 | 16 | check_supported() { 17 | false 18 | } 19 | 20 | speed_test_url() { 21 | echo "stable/core/${distro_arch}/core.db.tar.gz" 22 | } 23 | 24 | list_mirrors() { 25 | # All mirrors: 26 | # Server-side filtered list of mirrors: 27 | mirror_list_url='https://repo.manjaro.org' 28 | # tail/grep is to remove the header links and only list http/https 29 | download -q "${mirror_list_url}" - | list_links | tail -n +5 | grep '^http' 30 | } 31 | 32 | brl_arch_to_distro() { 33 | case "${1}" in 34 | "x86_64") echo "x86_64" ;; 35 | *) abort "brl does not know how to translate arch \"${1}\" to ${distro} format" ;; 36 | esac 37 | } 38 | 39 | list_architectures() { 40 | echo "x86_64" 41 | } 42 | 43 | default_release() { 44 | echo "rolling" 45 | } 46 | 47 | list_releases() { 48 | echo "rolling" 49 | } 50 | 51 | setup_pacman() { 52 | # Remove auto architecture detection, as it will confuse things like 53 | # i686 on an x86_64 box and armv7hl on a aarch64 box. 54 | # 55 | # Also remove CheckSpace, which sometimes gets confused by Bedrock's 56 | # mount setup. 57 | sed 's/^Architecture[ \t]*=.*$//' "${1}/etc/pacman.conf" | 58 | awk -v"a=${distro_arch}" '{print} $0 == "[options]" {print "Architecture = "a}' | 59 | sed 's/^[ \t]*CheckSpace/# &/' >"${1}/etc/pacman.conf-new" 60 | mv "${1}/etc/pacman.conf-new" "${1}/etc/pacman.conf" 61 | 62 | LC_ALL=C chroot "${1}" /usr/bin/update-ca-trust 63 | LC_ALL=C chroot "${1}" /usr/bin/pacman-key --init 64 | LC_ALL=C chroot "${1}" /usr/bin/pacman-key --populate manjaro archlinux 65 | 66 | if ! grep -q "^Server" "${1}/etc/pacman.d/mirrorlist"; then 67 | echo "### Set by Bedrock Linux when acquiring this stratum" >>"${1}/etc/pacman.d/mirrorlist" 68 | echo "Server = ${target_mirror}/stable\$repo/\$arch" >>"$1/etc/pacman.d/mirrorlist" 69 | fi 70 | } 71 | 72 | fetch() { 73 | bootstrap_deps="manjaro-tools-base pacman pacman-mirrors ca-certificates ca-certificates-utils awk util-linux" 74 | 75 | step "Downloading package information database" 76 | download "${target_mirror}/stable/core/${distro_arch}/core.db.tar.gz" "${bootstrap_dir}/core.db.tar.gz" 77 | download "${target_mirror}/stable/extra/${distro_arch}/extra.db.tar.gz" "${bootstrap_dir}/extra.db.tar.gz" 78 | download "${target_mirror}/stable/community/${distro_arch}/community.db.tar.gz" "${bootstrap_dir}/community.db.tar.gz" 79 | 80 | step "Decompressing package information database" 81 | mkdir -p "${bootstrap_dir}/pacmandb/core" "${bootstrap_dir}/pacmandb/extra" "${bootstrap_dir}/pacmandb/community" 82 | ( 83 | tar -xv -f "${bootstrap_dir}/core.db.tar.gz" -C "${bootstrap_dir}/pacmandb/core/" 84 | tar -xv -f "${bootstrap_dir}/extra.db.tar.gz" -C "${bootstrap_dir}/pacmandb/extra/" 85 | tar -xv -f "${bootstrap_dir}/community.db.tar.gz" -C "${bootstrap_dir}/pacmandb/community/" 86 | ) | awk 'NR%100==0' | progress_unknown 87 | 88 | step "Converting distro package information database to brl format" 89 | pacmandb_to_brldb "${bootstrap_dir}/pacmandb" "${bootstrap_dir}/brldb" 90 | 91 | step "Calculating required bootstrap packages" 92 | brldb_calculate_required_packages "${bootstrap_dir}/brldb" "${bootstrap_dir}/required_packages" "${bootstrap_deps}" 93 | 94 | step "Downloading bootstrap packages" 95 | # brldb contains repo/filename 96 | # files are at mirror/stable/repo/arch/filename 97 | checksum_downloads "${cache}/packages/" "$(awk -v"a=${distro_arch}" -v"m=${target_mirror}" '{sub("/", "/"a"/"); print m"/stable/"$0}' "${bootstrap_dir}/required_packages")" 98 | step "Extracting bootstrap packages" 99 | bootstrap_packages="$(awk -v"d=${cache}/packages/" '{sub(/^.*\//,d);print $1}' "${bootstrap_dir}/required_packages")" 100 | # shellcheck disable=SC2086 101 | extract_pacman_pkgs "${bootstrap_dir}" ${bootstrap_packages} 102 | 103 | step "Running bootstrap software" 104 | # pacstrap mounts devtmpfs (which is shared with the host system) and 105 | # chowns files in it based on /etc/passwd and /etc/group. Ensure 106 | # system copies of files are used to avoid problematic file ownership 107 | # change in /dev. 108 | mkdir -p "${target_dir}/etc" 109 | cp -a "/etc/passwd" "${target_dir}/etc/passwd" 110 | cp -a "/etc/group" "${target_dir}/etc/group" 111 | 112 | setup_chroot "${bootstrap_dir}" 113 | setup_ssl "${bootstrap_dir}" 114 | share_cache "packages" "${bootstrap_dir}/target-root/var/cache/pacman/pkg/" 115 | # -a to use the api, -P all protocols, -t 1 timeout if it takes longer than 1 second 116 | LC_ALL=C chroot "${bootstrap_dir}" pacman-mirrors -S stable -f 1 -a -P all -t 1 117 | setup_pacman "${bootstrap_dir}" 118 | LC_ALL=C chroot "${bootstrap_dir}" basestrap "/target-root" base 119 | 120 | step "Configuring" 121 | setup_chroot "${target_dir}" 122 | setup_pacman "${target_dir}" 123 | cp "${cache}/packages/"* "${target_dir}/var/cache/pacman/" 124 | if LC_ALL=C chroot "${target_dir}" pacman -Q linux >/dev/null 2>&1; then 125 | LC_ALL=C chroot "${target_dir}" pacman --noconfirm -R linux 126 | fi 127 | } 128 | -------------------------------------------------------------------------------- /src/slash-bedrock/share/brl-fetch/distros/openwrt: -------------------------------------------------------------------------------- 1 | #!/bedrock/libexec/busybox sh 2 | # 3 | # OpenWrt bootstrap support 4 | # 5 | # This program is free software; you can redistribute it and/or 6 | # modify it under the terms of the GNU General Public License 7 | # version 2 as published by the Free Software Foundation. 8 | # 9 | # Copyright (c) 2018-2019 Daniel Thau 10 | # 11 | 12 | # shellcheck source=src/slash-bedrock/libexec/brl-fetch 13 | . /bedrock/share/common-code 14 | trap 'fetch_abort "Unexpected error occurred."' EXIT 15 | 16 | check_supported() { 17 | false 18 | } 19 | 20 | speed_test_url() { 21 | echo "releases/${target_release}/targets/x86/64/sha256sums" 22 | } 23 | 24 | list_mirrors() { 25 | # main mirror 26 | echo 'https://downloads.openwrt.org' 27 | 28 | # additional mirrors 29 | mirror_list_url='https://openwrt.org/downloads' 30 | download -q "${mirror_list_url}" - | 31 | awk '/id="mirrors"/,/<\/table>/' | 32 | list_links | 33 | grep "^http" 34 | } 35 | 36 | brl_arch_to_distro() { 37 | case "${1}" in 38 | "aarch64") echo "armvirt-64" ;; 39 | "armv7l") echo "armvirt-32" ;; 40 | "i486") echo "x86-generic" ;; 41 | "x86_64") echo "x86-64" ;; 42 | *) abort "brl does not know how to translate arch \"${1}\" to ${distro} format" ;; 43 | esac 44 | } 45 | 46 | list_architectures() { 47 | cat < 10 | # 11 | 12 | # shellcheck source=src/slash-bedrock/libexec/brl-fetch 13 | . /bedrock/share/common-code 14 | trap 'fetch_abort "Unexpected error occurred."' EXIT 15 | 16 | check_supported() { 17 | true 18 | } 19 | 20 | speed_test_url() { 21 | echo "dists/${target_release}/Release" 22 | } 23 | 24 | list_mirrors() { 25 | mirror_list_url='https://www.raspbian.org/RaspbianMirrors' 26 | download -q "${mirror_list_url}" - | 27 | awk '/Raspbian Repository Mirrors/,/<\/div/' | 28 | sed 's/([a-z|]*http[a-z|]*)/http/' | 29 | grep '>http://.*<' | 30 | sed 's,.*>http://,http://,' | 31 | sed 's,<.*$,,' 32 | } 33 | 34 | brl_arch_to_distro() { 35 | case "${1}" in 36 | "armv7hl") echo "armhf" ;; 37 | *) abort "brl does not know how to translate arch \"${1}\" to ${distro} format" ;; 38 | esac 39 | } 40 | 41 | list_architectures() { 42 | echo "armv7hl" 43 | } 44 | 45 | default_release() { 46 | for mirror in "${flag_mirror}" $(list_mirrors); do 47 | release="$(download -q "${mirror}/dists/stable/Release" - | awk '$1 == "Codename:" {print$2;exit}')" 48 | if [ -n "${release}" ]; then 49 | echo "${release}" 50 | return 51 | fi 52 | done 53 | } 54 | 55 | list_releases() { 56 | for mirror in "${flag_mirror}" $(list_mirrors); do 57 | if download -q "${mirror}/dists" - | 58 | list_links | 59 | grep '/$' | 60 | grep -v -- '-' | 61 | grep -ve '[.]' -ve '^/' -ve 'experimental' | 62 | sed 's,/$,,g'; then 63 | break 64 | fi 65 | done 66 | } 67 | 68 | fetch() { 69 | bootstrap_deps="debootstrap apt dpkg coreutils dash bash grep sed awk perl bzip2 gzip tar gpgv raspbian-archive-keyring" 70 | case "${target_release}" in 71 | stretch | buster) 72 | bootstrap_deps="${bootstrap_deps} libapt-pkg5.0" 73 | ;; 74 | *) 75 | bootstrap_deps="${bootstrap_deps} libapt-pkg6.0" 76 | ;; 77 | esac 78 | 79 | step "Downloading package information database" 80 | download "${target_mirror}/dists/${target_release}/main/binary-${distro_arch}/Packages.gz" "${bootstrap_dir}/Packages.gz" 81 | gunzip "${bootstrap_dir}/Packages.gz" 82 | 83 | step "Converting distro package information database to brl format" 84 | debdb_to_brldb "${bootstrap_dir}/Packages" "${bootstrap_dir}/brldb" 85 | 86 | step "Calculating required bootstrap packages" 87 | brldb_calculate_required_packages "${bootstrap_dir}/brldb" "${bootstrap_dir}/required_packages" "${bootstrap_deps}" 88 | 89 | step "Downloading bootstrap packages" 90 | checksum_downloads "${cache}/packages/" "$(awk -v"m=${target_mirror}" '{print m"/"$0}' "${bootstrap_dir}/required_packages")" 91 | 92 | step "Extracting bootstrap packages" 93 | bootstrap_packages="$(awk -v"d=${cache}/packages/" '{sub(/^.*\//,d);print $1}' "${bootstrap_dir}/required_packages")" 94 | # shellcheck disable=SC2086 95 | extract_debs "${bootstrap_dir}" ${bootstrap_packages} 96 | 97 | step "Running bootstrap software" 98 | setup_chroot "${bootstrap_dir}" 99 | setup_ssl "${bootstrap_dir}" 100 | set +o pipefail 101 | if LANG=C chroot "${bootstrap_dir}" debootstrap --help | grep -q "cache-dir"; then 102 | share_cache "packages" "${bootstrap_dir}/packages" 103 | yes "" | LANG=C chroot "${bootstrap_dir}" debootstrap --variant=minbase --cache-dir="/packages" "${target_release}" "/target-root" "${target_mirror}" 104 | else 105 | yes "" | LANG=C chroot "${bootstrap_dir}" debootstrap --variant=minbase "${target_release}" "/target-root" "${target_mirror}" 106 | fi 107 | set -o pipefail 108 | 109 | step "Configuring" 110 | set +o pipefail 111 | setup_chroot "${target_dir}" 112 | autopkgs="$(LANG=C chroot "${target_dir}" /usr/bin/apt-mark showmanual)" 113 | # word splitting is desired here 114 | # shellcheck disable=SC2086 115 | yes "" | LANG=C chroot "${target_dir}" /usr/bin/apt-mark auto ${autopkgs} 116 | yes "" | LANG=C chroot "${target_dir}" /usr/bin/apt-get update 117 | yes "" | LANG=C chroot "${target_dir}" /usr/bin/apt-get install locales-all 118 | set -o pipefail 119 | } 120 | -------------------------------------------------------------------------------- /src/slash-bedrock/share/brl-fetch/distros/rocky: -------------------------------------------------------------------------------- 1 | #!/bedrock/libexec/busybox sh 2 | # 3 | # Rocky bootstrap support 4 | # 5 | # This program is free software; you can redistribute it and/or 6 | # modify it under the terms of the GNU General Public License 7 | # version 2 as published by the Free Software Foundation. 8 | # 9 | # Copyright (c) 2016-2021 Daniel Thau 10 | # 11 | 12 | # shellcheck source=src/slash-bedrock/libexec/brl-fetch 13 | . /bedrock/share/common-code 14 | trap 'fetch_abort "Unexpected error occurred."' EXIT 15 | 16 | check_supported() { 17 | false 18 | } 19 | 20 | get_mirror_suffix() { 21 | if [ "$(echo "${target_release}" | sed 's/-[a-z]*$//')" -lt 8 ]; then 22 | echo "${target_release}/os/${distro_arch}/" 23 | else 24 | echo "${target_release}/BaseOS/${distro_arch}/os" 25 | fi 26 | } 27 | 28 | speed_test_url() { 29 | echo "$(get_mirror_suffix)/repodata/repomd.xml" 30 | } 31 | 32 | list_mirrors() { 33 | mirror_list_url='https://mirrors.rockylinux.org/mirrormanager/mirrors' 34 | download -q "${mirror_list_url}" - | 35 | awk '/
http' | 37 | list_links | 38 | grep "^http" 39 | } 40 | 41 | brl_arch_to_distro() { 42 | case "${1}" in 43 | "aarch64") echo "aarch64" ;; 44 | "x86_64") echo "x86_64" ;; 45 | *) abort "brl does not know how to translate arch \"${1}\" to ${distro} format" ;; 46 | esac 47 | } 48 | 49 | list_architectures() { 50 | cat <>"${bootstrap_dir}/brldb/provides/u" 101 | fi 102 | 103 | step "Calculating required bootstrap packages" 104 | brldb_calculate_required_packages "${bootstrap_dir}/brldb" "${bootstrap_dir}/required_packages" "$(bootstrap_deps)" 105 | 106 | step "Downloading bootstrap packages" 107 | checksum_downloads "${cache}/packages/" "$(awk -v"m=${target_mirror}/${suffix}" '{print m"/"$0}' "${bootstrap_dir}/required_packages")" 108 | 109 | step "Extracting bootstrap packages" 110 | # This round is just to bootstrap the distro's rpm. 111 | # Next step we'll use the distro's rpm to install everything properly. 112 | # Need to extract filesystem first to ensure symlinks are set up 113 | bootstrap_packages="$(awk -v"d=${cache}/packages/" '{sub(/^.*\//,d);print $1}' "${bootstrap_dir}/required_packages")" 114 | # shellcheck disable=SC2086 115 | extract_rpms "${bootstrap_dir}" "${cache}/packages"/filesystem*.rpm ${bootstrap_packages} 116 | 117 | step "Installing bootstrap packages" 118 | setup_chroot "${bootstrap_dir}" 119 | # setup_ssl "${bootstrap_dir}" # fights with yum/dnf later on, not actually needed 120 | share_cache "packages" "${bootstrap_dir}/packages" 121 | bootstrap_packages="$(awk -v"d=/packages/" '{sub(/^.*\//,d);print $1}' "${bootstrap_dir}/required_packages")" 122 | # shellcheck disable=SC2086 123 | LC_ALL=C chroot "${bootstrap_dir}" sh -c 'rpm --import /etc/pki/rpm-gpg/*' 124 | LC_ALL=C chroot "${bootstrap_dir}" rpm -i ${bootstrap_packages} 125 | 126 | step "Running bootstrap software" 127 | # By default, dnf clears anything in its package cache. 128 | # Configure them to retain them so we can leverage previous cached 129 | # packages. 130 | if [ -e "${bootstrap_dir}/etc/dnf/dnf.conf" ] && grep -q "^keepcache=1$" "${bootstrap_dir}/etc/dnf/dnf.conf"; then 131 | share_cache "dnf-cache" "${bootstrap_dir}/target-root/var/cache/dnf" 132 | elif [ -e "${bootstrap_dir}/etc/dnf/dnf.conf" ] && grep -q "^keepcache=0$" "${bootstrap_dir}/etc/dnf/dnf.conf"; then 133 | sed 's/^keepcache=0$/keepcache=1/' "${bootstrap_dir}/etc/dnf/dnf.conf" >"${bootstrap_dir}/etc/dnf/dnf.conf-new" 134 | mv "${bootstrap_dir}/etc/dnf/dnf.conf-new" "${bootstrap_dir}/etc/dnf/dnf.conf" 135 | share_cache "dnf-cache" "${bootstrap_dir}/target-root/var/cache/dnf" 136 | elif [ -r "${bootstrap_dir}/etc/dnf/dnf.conf" ]; then 137 | echo "keepcache=1" >>"${bootstrap_dir}/etc/dnf/dnf.conf" 138 | share_cache "dnf-cache" "${bootstrap_dir}/target-root/var/cache/dnf" 139 | fi 140 | 141 | LC_ALL=C chroot "${bootstrap_dir}" rpm -i --root=/target-root --nodeps ./packages/centos-release-*.rpm 2>/dev/null || true 142 | if [ "$(echo "${target_release}" | sed 's/-[a-z]*$//')" -lt 8 ]; then 143 | LC_ALL=C chroot "${bootstrap_dir}" dnf --installroot=/target-root install -y rpm-build dnf 144 | else 145 | LC_ALL=C chroot "${bootstrap_dir}" dnf --installroot=/target-root --releasever="${target_release}" install -y rpm-build dnf 146 | fi 147 | # Need to set database timestamps for pmm due to `dnf -C` usage 148 | umount -l "${bootstrap_dir}/var/cache/dnf" >/dev/null 2>&1 || true 149 | setup_chroot "${target_dir}" 150 | LC_ALL=C chroot "${target_dir}" dnf -y update 151 | } 152 | -------------------------------------------------------------------------------- /src/slash-bedrock/share/brl-fetch/distros/slackware: -------------------------------------------------------------------------------- 1 | #!/bedrock/libexec/busybox sh 2 | # 3 | # Slackware bootstrap support 4 | # 5 | # This program is free software; you can redistribute it and/or 6 | # modify it under the terms of the GNU General Public License 7 | # version 2 as published by the Free Software Foundation. 8 | # 9 | # Copyright (c) 2016-2019 Daniel Thau 10 | # 11 | 12 | # shellcheck source=src/slash-bedrock/libexec/brl-fetch 13 | . /bedrock/share/common-code 14 | trap 'fetch_abort "Unexpected error occurred."' EXIT 15 | 16 | check_supported() { 17 | false 18 | } 19 | 20 | speed_test_url() { 21 | echo "/slackware64-current/CHECKSUMS.md5" 22 | } 23 | 24 | list_mirrors() { 25 | mirror_list_url='https://mirrors.slackware.com/mirrorlist/' 26 | download -q "${mirror_list_url}" - | 27 | sed 's/[<> \t\n\r]/\n/g' | 28 | awk -F"[=>]" '/^href=/ || /^HREF=/ {print$2}' | 29 | grep "^http" 30 | } 31 | 32 | brl_arch_to_distro() { 33 | case "${1}" in 34 | "i586") echo "slackware" ;; 35 | "x86_64") echo "slackware64" ;; 36 | *) abort "brl does not know how to translate arch \"${1}\" to ${distro} format" ;; 37 | esac 38 | } 39 | 40 | list_architectures() { 41 | cat </dev/null || true 89 | fi 90 | rm -rf "${bootstrap_dir}/install" 91 | echo "x" 92 | done | progress_bar "${total}" 93 | 94 | step "Running bootstrap software" 95 | setup_chroot "${bootstrap_dir}" 96 | setup_ssl "${bootstrap_dir}" 97 | share_cache "packages" "${bootstrap_dir}/packages" 98 | for pkg in "${cache}/packages/"*; do 99 | pkg="$(echo "${pkg}" | sed 's,^.*/,,')" 100 | LC_ALL=C chroot "${bootstrap_dir}" /sbin/installpkg --root "/target-root" "/packages/${pkg}" >/dev/null 2>&1 101 | echo "x" 102 | done | progress_bar "${total}" 103 | } 104 | -------------------------------------------------------------------------------- /src/slash-bedrock/share/brl-fetch/distros/ubuntu: -------------------------------------------------------------------------------- 1 | #!/bedrock/libexec/busybox sh 2 | # 3 | # Ubuntu bootstrap support 4 | # 5 | # This program is free software; you can redistribute it and/or 6 | # modify it under the terms of the GNU General Public License 7 | # version 2 as published by the Free Software Foundation. 8 | # 9 | # Copyright (c) 2016-2021 Daniel Thau 10 | # 11 | 12 | # shellcheck source=src/slash-bedrock/libexec/brl-fetch 13 | . /bedrock/share/common-code 14 | trap 'fetch_abort "Unexpected error occurred."' EXIT 15 | 16 | check_supported() { 17 | true 18 | } 19 | 20 | speed_test_url() { 21 | echo "dists/${target_release}/Release" 22 | } 23 | 24 | list_mirrors() { 25 | case "${target_arch}" in 26 | "x86_64") 27 | echo 'http://archive.ubuntu.com/ubuntu' 28 | mirror_list_url='https://launchpad.net/ubuntu/+archivemirrors' 29 | download -q "${mirror_list_url}" - | 30 | awk '/mirrors_list/,/<\/div/' | 31 | list_links | 32 | grep "^http" 33 | ;; 34 | *) 35 | echo 'http://ports.ubuntu.com/ubuntu-ports/' 36 | ;; 37 | esac 38 | } 39 | 40 | brl_arch_to_distro() { 41 | case "${1}" in 42 | "aarch64") echo "arm64" ;; 43 | "armv7hl") echo "armhf" ;; 44 | "ppc64le") echo "ppc64el" ;; 45 | "s390x") echo "s390x" ;; 46 | # Cannot find 32-bit x86 in Ubuntu 19.04. Apparently it was dropped. 47 | "x86_64") echo "amd64" ;; 48 | *) abort "brl does not know how to translate arch \"${1}\" to ${distro} format" ;; 49 | esac 50 | } 51 | 52 | list_architectures() { 53 | cat </dev/null | 70 | list_links | 71 | sed 's,/,,g' | 72 | grep '^[0-9]*[.][0-9]*$' | 73 | sort -rn | 74 | head -n1)" 75 | 76 | codenames="$(download -q "http://archive.ubuntu.com/ubuntu/dists" - 2>/dev/null | 77 | list_links | 78 | grep '/$' | 79 | grep -v -- '-' | 80 | grep -v -- '^devel/$' | 81 | grep -ve '[.]' -ve '^/' | 82 | sed 's,/$,,g')" 83 | 84 | for codename in ${codenames}; do 85 | if ! download -q "http://archive.ubuntu.com/ubuntu/dists/${codename}/Release" - | 86 | awk -v"n=${num}" '$1 == "Version:" && $2 == n {exit 1}'; then 87 | echo "${codename}" 88 | set +o pipefail 89 | return 90 | fi 91 | done 92 | set -o pipefail 93 | } 94 | 95 | list_releases() { 96 | for mirror in "${flag_mirror}" $(list_mirrors); do 97 | if download -q "${mirror}/dists" - | 98 | list_links | 99 | grep '/$' | 100 | grep -v -- '-' | 101 | grep -ve '[.]' -ve '^/' | 102 | sed 's,/$,,g' | 103 | grep -v '^devel$'; then 104 | break 105 | fi 106 | done 107 | } 108 | 109 | fetch() { 110 | bootstrap_deps="debootstrap apt dpkg coreutils dash bash grep sed awk perl bzip2 gzip tar gpgv ubuntu-keyring" 111 | # libapt-pkg.so.5.X provider changed from libapt-pkg5.0 in pre-eoan to libapt-pkg-dev in eoan 112 | if [ "$( ( 113 | echo "${target_release:-}" 114 | echo "eoan" 115 | ) | sort | head -n1)" != "eoan" ]; then 116 | bootstrap_deps="${bootstrap_deps} libapt-pkg5.0" 117 | else 118 | bootstrap_deps="${bootstrap_deps} libapt-pkg-dev" 119 | fi 120 | 121 | step "Downloading package information database" 122 | download "${target_mirror}/dists/${target_release}/main/binary-${distro_arch}/Packages.gz" "${bootstrap_dir}/Packages.gz" 123 | gunzip "${bootstrap_dir}/Packages.gz" 124 | 125 | step "Converting distro package information database to brl format" 126 | debdb_to_brldb "${bootstrap_dir}/Packages" "${bootstrap_dir}/brldb" 127 | 128 | step "Calculating required bootstrap packages" 129 | brldb_calculate_required_packages "${bootstrap_dir}/brldb" "${bootstrap_dir}/required_packages" "${bootstrap_deps}" 130 | 131 | step "Downloading bootstrap packages" 132 | checksum_downloads "${cache}/packages/" "$(awk -v"m=${target_mirror}" '{print m"/"$0}' "${bootstrap_dir}/required_packages")" 133 | 134 | step "Extracting bootstrap packages" 135 | bootstrap_packages="$(awk -v"d=${cache}/packages/" '{sub(/^.*\//,d);print $1}' "${bootstrap_dir}/required_packages")" 136 | # shellcheck disable=SC2086 137 | extract_debs "${bootstrap_dir}" ${bootstrap_packages} 138 | 139 | step "Running bootstrap software" 140 | setup_chroot "${bootstrap_dir}" 141 | setup_ssl "${bootstrap_dir}" 142 | set +o pipefail 143 | if LANG=C chroot "${bootstrap_dir}" debootstrap --help | grep -q "cache-dir"; then 144 | share_cache "packages" "${bootstrap_dir}/packages" 145 | yes "" | LANG=C chroot "${bootstrap_dir}" debootstrap --variant=minbase --cache-dir="/packages" "${target_release}" "/target-root" "${target_mirror}" 146 | else 147 | yes "" | LANG=C chroot "${bootstrap_dir}" debootstrap --variant=minbase "${target_release}" "/target-root" "${target_mirror}" 148 | fi 149 | set -o pipefail 150 | 151 | step "Configuring" 152 | if grep -q "\" "${target_dir}/etc/apt/sources.list" && ! grep -q "\" "${target_dir}/etc/apt/sources.list"; then 153 | # universe contains locales-all package needed below 154 | sed 's/\/main universe/' "${target_dir}/etc/apt/sources.list" >"${target_dir}/etc/apt/sources.list-new" 155 | mv "${target_dir}/etc/apt/sources.list-new" "${target_dir}/etc/apt/sources.list" 156 | fi 157 | case "${distro_arch}" in 158 | "amd64") 159 | echo "deb http://archive.ubuntu.com/ubuntu/ ${target_release}-security main universe" >>"${target_dir}/etc/apt/sources.list" 160 | ;; 161 | esac 162 | set +o pipefail 163 | setup_chroot "${target_dir}" 164 | autopkgs="$(LANG=C chroot "${target_dir}" /usr/bin/apt-mark showmanual)" 165 | # word splitting is desired here 166 | # shellcheck disable=SC2086 167 | yes "" | LANG=C chroot "${target_dir}" /usr/bin/apt-mark auto ${autopkgs} 168 | yes "" | LANG=C chroot "${target_dir}" /usr/bin/apt-get update 169 | yes "" | LANG=C chroot "${target_dir}" /usr/bin/apt-get install locales-all 170 | set -o pipefail 171 | } 172 | -------------------------------------------------------------------------------- /src/slash-bedrock/share/brl-fetch/distros/void: -------------------------------------------------------------------------------- 1 | #!/bedrock/libexec/busybox sh 2 | # 3 | # Void Linux bootstrap support 4 | # 5 | # This program is free software; you can redistribute it and/or 6 | # modify it under the terms of the GNU General Public License 7 | # version 2 as published by the Free Software Foundation. 8 | # 9 | # Copyright (c) 2016-2020 Daniel Thau 10 | # 11 | 12 | # shellcheck source=src/slash-bedrock/libexec/brl-fetch 13 | . /bedrock/share/common-code 14 | trap 'fetch_abort "Unexpected error occurred."' EXIT 15 | 16 | check_supported() { 17 | true 18 | } 19 | 20 | speed_test_url() { 21 | echo "static/sha256sums.txt" 22 | } 23 | 24 | list_mirrors() { 25 | # https://docs.voidlinux.org/xbps/repositories/mirrors/index.html 26 | # > A fresh install will default to repo-default.voidlinux.org, which may map to any Tier 1 mirror 27 | echo 'https://repo-default.voidlinux.org/' 28 | } 29 | 30 | brl_arch_to_distro() { 31 | # while static mips/mipsel xbps shows up in the mirrors, the mirrors 32 | # do not provide binary packages for it. 33 | case "${1}" in 34 | "aarch64") echo "aarch64" ;; 35 | "armv7hl") echo "armv7l" ;; 36 | # Void does offer i686, but glibc-only. The fetch strategy below is 37 | # based on leveraging static xbps. Thus, at least for now, brl-fetch 38 | # does not support either flavor of i686 Void. 39 | "x86_64") echo "x86_64" ;; 40 | *) abort "brl does not know how to translate arch \"${1}\" to ${distro} format" ;; 41 | esac 42 | } 43 | 44 | list_architectures() { 45 | cat <]' ' 81 | /^\t/ { 82 | section=$3 83 | } 84 | section == "xbps-static" && /^\t\t/ { 85 | subsection=$3 86 | } 87 | section == "xbps-static" && subsection == "filename-sha256" && /^\t\t/ { 88 | checksum=$3 89 | } 90 | section == "xbps-static" && subsection == "pkgver" && /^\t\t/ { 91 | filename=$3 92 | } 93 | checksum != "" && filename != "" { 94 | print checksum"\t"filename 95 | checksum="" 96 | filename="" 97 | } 98 | ')" 99 | bootstrap_checksum="$(echo "${pair}" | awk '{print$1}')" 100 | bootstrap_name="$(echo "${pair}" | awk '{print$2}')" 101 | bootstrap_url="${target_mirror}/current/${prefix}/${bootstrap_name}.${distro_arch}-musl.xbps" 102 | checksum_download "${cache}/xbps.tar.zstd" "sha256sum" "${bootstrap_checksum}" "${bootstrap_url}" 103 | 104 | step "Preparing bootstrap software" 105 | /bedrock/libexec/zstd -d <"${cache}/xbps.tar.zstd" | tar xf - -C "${bootstrap_dir}" 106 | 107 | step "Running bootstrap software" 108 | set +o pipefail 109 | cp /bedrock/libexec/busybox "${bootstrap_dir}" 110 | for dir in bin sbin usr/bin usr/sbin; do 111 | mkdir -p "${bootstrap_dir}/${dir}" 112 | done 113 | chroot "${bootstrap_dir}" /busybox --install 114 | setup_chroot "${bootstrap_dir}" 115 | setup_ssl "${bootstrap_dir}" 116 | share_cache "packages" "${bootstrap_dir}/target-root/var/cache/xbps" 117 | case "${distro}:${distro_arch}" in 118 | "void:aarch64") prefix="aarch64" ;; 119 | "void:armv7l") prefix="" ;; 120 | "void:x86_64") prefix="" ;; 121 | "void-musl:aarch64") prefix="aarch64" ;; 122 | "void-musl:armv7l") prefix="musl" ;; 123 | "void-musl:x86_64") prefix="musl" ;; 124 | *) abort "unrecognized distro:architecture pair \"${distro}:${distro_arch}\"" ;; 125 | esac 126 | mkdir -p "${target_dir}/var/db/xbps/https___alpha_de_repo_voidlinux_org_current" 127 | yes "" | LC_ALL=C XBPS_ARCH="${distro_arch}" chroot "${bootstrap_dir}" "/usr/bin/xbps-install.static" -S -R "${target_mirror}/current/${prefix}" -r /target-root/ base-minimal 128 | set -o pipefail 129 | 130 | step "Configuring" 131 | mkdir -p "${target_dir}/etc/xbps.d/" 132 | echo "repository=${target_mirror}/current/${prefix}" >"${target_dir}/etc/xbps.d/00-brl-fetch.conf" 133 | # Void's zsh package does not create /etc/zsh/zshenv but it is needed 134 | # for various Bedrock hooks 135 | if ! [ -e "${target_dir}/etc/zsh/zshenv" ]; then 136 | mkdir -p "${target_dir}/etc/zsh/" 137 | echo "# File created by Bedrock Linux during stratum fetch" >"${target_dir}/etc/zsh/zshenv" 138 | fi 139 | } 140 | -------------------------------------------------------------------------------- /src/slash-bedrock/share/brl-fetch/distros/void-musl: -------------------------------------------------------------------------------- 1 | #!/bedrock/libexec/busybox sh 2 | # 3 | # Void Linux (musl) bootstrap support 4 | # 5 | # This program is free software; you can redistribute it and/or 6 | # modify it under the terms of the GNU General Public License 7 | # version 2 as published by the Free Software Foundation. 8 | # 9 | # Copyright (c) 2016-2020 Daniel Thau 10 | # 11 | 12 | # shellcheck source=src/slash-bedrock/libexec/brl-fetch 13 | . /bedrock/share/common-code 14 | trap 'fetch_abort "Unexpected error occurred."' EXIT 15 | 16 | check_supported() { 17 | true 18 | } 19 | 20 | speed_test_url() { 21 | echo "static/sha256sums.txt" 22 | } 23 | 24 | list_mirrors() { 25 | # https://docs.voidlinux.org/xbps/repositories/mirrors/index.html 26 | # > A fresh install will default to repo-default.voidlinux.org, which may map to any Tier 1 mirror 27 | echo 'https://repo-default.voidlinux.org/' 28 | } 29 | 30 | brl_arch_to_distro() { 31 | # while static mips/mipsel xbps shows up in the mirrors, the mirrors 32 | # do not provide binary packages for it. 33 | case "${1}" in 34 | "aarch64") echo "aarch64" ;; 35 | "armv7hl") echo "armv7l" ;; 36 | # Void does offer i686, but glibc-only. The fetch strategy below is 37 | # based on leveraging static xbps. Thus, at least for now, brl-fetch 38 | # does not support either flavor of i686 Void. 39 | "x86_64") echo "x86_64" ;; 40 | *) abort "brl does not know how to translate arch \"${1}\" to ${distro} format" ;; 41 | esac 42 | } 43 | 44 | list_architectures() { 45 | cat <]' ' 81 | /^\t/ { 82 | section=$3 83 | } 84 | section == "xbps-static" && /^\t\t/ { 85 | subsection=$3 86 | } 87 | section == "xbps-static" && subsection == "filename-sha256" && /^\t\t/ { 88 | checksum=$3 89 | } 90 | section == "xbps-static" && subsection == "pkgver" && /^\t\t/ { 91 | filename=$3 92 | } 93 | checksum != "" && filename != "" { 94 | print checksum"\t"filename 95 | checksum="" 96 | filename="" 97 | } 98 | ')" 99 | bootstrap_checksum="$(echo "${pair}" | awk '{print$1}')" 100 | bootstrap_name="$(echo "${pair}" | awk '{print$2}')" 101 | bootstrap_url="${target_mirror}/current/${prefix}/${bootstrap_name}.${distro_arch}-musl.xbps" 102 | checksum_download "${cache}/xbps.tar.zstd" "sha256sum" "${bootstrap_checksum}" "${bootstrap_url}" 103 | 104 | step "Preparing bootstrap software" 105 | /bedrock/libexec/zstd -d <"${cache}/xbps.tar.zstd" | tar xf - -C "${bootstrap_dir}" 106 | 107 | step "Running bootstrap software" 108 | set +o pipefail 109 | cp /bedrock/libexec/busybox "${bootstrap_dir}" 110 | for dir in bin sbin usr/bin usr/sbin; do 111 | mkdir -p "${bootstrap_dir}/${dir}" 112 | done 113 | chroot "${bootstrap_dir}" /busybox --install 114 | setup_chroot "${bootstrap_dir}" 115 | setup_ssl "${bootstrap_dir}" 116 | share_cache "packages" "${bootstrap_dir}/target-root/var/cache/xbps" 117 | case "${distro}:${distro_arch}" in 118 | "void:aarch64") prefix="aarch64" ;; 119 | "void:armv7l") prefix="" ;; 120 | "void:x86_64") prefix="" ;; 121 | "void-musl:aarch64") prefix="aarch64" ;; 122 | "void-musl:armv7l") prefix="musl" ;; 123 | "void-musl:x86_64") prefix="musl" ;; 124 | *) abort "unrecognized distro:architecture pair \"${distro}:${distro_arch}\"" ;; 125 | esac 126 | mkdir -p "${target_dir}/var/db/xbps/https___alpha_de_repo_voidlinux_org_current" 127 | yes "" | LC_ALL=C XBPS_ARCH="${distro_arch}-musl" chroot "${bootstrap_dir}" "/usr/bin/xbps-install.static" -S -R "${target_mirror}/current/${prefix}" -r /target-root/ base-minimal 128 | set -o pipefail 129 | 130 | step "Configuring" 131 | mkdir -p "${target_dir}/etc/xbps.d/" 132 | echo "repository=${target_mirror}/current/${prefix}" >"${target_dir}/etc/xbps.d/00-brl-fetch.conf" 133 | # Void's zsh package does not create /etc/zsh/zshenv but it is needed 134 | # for various Bedrock hooks 135 | if ! [ -e "${target_dir}/etc/zsh/zshenv" ]; then 136 | mkdir -p "${target_dir}/etc/zsh/" 137 | echo "# File created by Bedrock Linux during stratum fetch" >"${target_dir}/etc/zsh/zshenv" 138 | fi 139 | } 140 | -------------------------------------------------------------------------------- /src/slash-bedrock/share/brl-tutorial/common: -------------------------------------------------------------------------------- 1 | #!/bedrock/libexec/busybox sh 2 | # shellcheck disable=SC2154 disable=SC2034 3 | 4 | # shellcheck source=src/slash-bedrock/share/common-code 5 | . /bedrock/share/common-code 6 | 7 | Alpine="${color_distro}Alpine${color_norm}" 8 | apk="${color_cmd}apk${color_norm}" 9 | apt="${color_cmd}apt${color_norm}" 10 | Arch="${color_distro}Arch${color_norm}" 11 | bash="${color_cmd}bash${color_norm}" 12 | Bedrock="${color_bedrock}Bedrock${color_norm}" 13 | bedrock="${color_strat}bedrock${color_norm}" 14 | bedrock_conf="${color_file}bedrock.conf${color_norm}" 15 | bedrock_etc_bedrock_conf="${color_file}/bedrock/etc/bedrock.conf${color_norm}" 16 | Bedrock_Linux="${color_bedrock}Bedrock Linux${color_norm}" 17 | bedrock_strata="${color_file}/bedrock/strata/${color_norm}" 18 | brl="${color_cmd}brl${color_norm}" 19 | brl_apply="${color_cmd}brl apply${color_norm}" 20 | brl_fetch="${color_cmd}brl fetch${color_norm}" 21 | brl_import="${color_cmd}brl import${color_norm}" 22 | brl_remove="${color_cmd}brl remove${color_norm}" 23 | brl_tutorial="${color_cmd}brl tutorial${color_norm}" 24 | brl_which="${color_cmd}brl which${color_norm}" 25 | cross="${color_term}cross${color_norm}" 26 | Debian="${color_distro}Debian${color_norm}" 27 | disable="${color_term}disable${color_norm}" 28 | disabled="${color_term}disabled${color_norm}" 29 | enable="${color_term}enable${color_norm}" 30 | enabled="${color_term}enabled${color_norm}" 31 | etc_apt_sources_list="${color_file}/etc/apt/sources.list${color_norm}" 32 | global="${color_term}global${color_norm}" 33 | hashbang="${color_cmd}#!/bin/sh${color_norm}" 34 | hijack="${color_term}hijack${color_norm}" 35 | hijacked="${color_term}hijacked${color_norm}" 36 | home="${color_file}/home${color_norm}" 37 | init_stratum="${color_strat}$(brl deref init)${color_norm}" 38 | jo="${color_cmd}jo${color_norm}" 39 | jq="${color_cmd}jq${color_norm}" 40 | local="${color_term}local${color_norm}" 41 | locally="${color_term}locally${color_norm}" 42 | ls="${color_cmd}ls${color_norm}" 43 | makepkg="${color_cmd}makepkg${color_norm}" 44 | man="${color_cmd}man${color_norm}" 45 | pinned="${color_term}pinned${color_norm}" 46 | pinning="${color_term}pinning${color_norm}" 47 | pmm="${color_cmd}pmm${color_norm}" 48 | reboot="${color_cmd}reboot${color_norm}" 49 | restrict="${color_term}restrict${color_norm}" 50 | restriction="${color_term}restriction${color_norm}" 51 | run="${color_file}/run${color_norm}" 52 | show="${color_term}show${color_norm}" 53 | sources_list="${color_file}sources.list${color_norm}" 54 | strat="${color_cmd}strat${color_norm}" 55 | Strata="${color_term}Strata${color_norm}" 56 | strata="${color_term}strata${color_norm}" 57 | stratum="${color_term}stratum${color_norm}" 58 | sudo="${color_cmd}sudo${color_norm}" 59 | tmp="${color_file}/tmp${color_norm}" 60 | tut_alpine="${color_strat}tut-alpine${color_norm}" 61 | tut_void="${color_strat}tut-void${color_norm}" 62 | Ubuntu="${color_distro}Ubuntu${color_norm}" 63 | Void="${color_distro}Void${color_norm}" 64 | xbps_install="${color_cmd}xbps-install${color_norm}" 65 | 66 | # Users have complained busybox mktemp output is too difficult to type when 67 | # following tutorial instructions. Attempt to generate a more user friendly 68 | # temporary file names. 69 | n=0 70 | tmpfile="" 71 | while true; do 72 | n=$((n + 1)) 73 | tmpfile="/tmp/tut${n}" 74 | touch "${tmpfile}" || continue 75 | exec 9>"${tmpfile}" || continue 76 | flock -nx 9 && break 77 | done 78 | tmpfile2="" 79 | while true; do 80 | n=$((n + 1)) 81 | tmpfile2="/tmp/tut${n}" 82 | touch "${tmpfile2}" || continue 83 | exec 8>"${tmpfile2}" || continue 84 | flock -nx 8 && break 85 | done 86 | echo "" >"${tmpfile}" 87 | echo "" >"${tmpfile2}" 88 | trap 'rm -f ${tmpfile} ${tmpfile2}' INT TERM EXIT 89 | -------------------------------------------------------------------------------- /src/slash-bedrock/share/dkms/include-bedrock: -------------------------------------------------------------------------------- 1 | 2 | # Automatically added by Bedrock Linux 3 | source_tree="/bedrock/cross/src/" 4 | -------------------------------------------------------------------------------- /src/slash-bedrock/share/fish/completion/strat.fish: -------------------------------------------------------------------------------- 1 | # fish tab completion for strat 2 | # 3 | # This program is free software; you can redistribute it and/or 4 | # modify it under the terms of the GNU General Public License 5 | # version 2 as published by the Free Software Foundation. 6 | # 7 | # Copyright (c) 2018 Daniel Thau 8 | # 9 | function _strat_opts 10 | set args (commandline -opc) 11 | 12 | set saw_help "0" 13 | set saw_restrict "0" 14 | set saw_arg0 "0" 15 | set saw_arg0_arg "0" 16 | set saw_stratum "0" 17 | set saw_command "0" 18 | for i in (seq 2 (count $args)) 19 | switch "$args[$i]" 20 | case "-h" 21 | set saw_help "$i" 22 | case "--help" 23 | set saw_help "$i" 24 | case "-r" 25 | set saw_restrict "$i" 26 | case "--restrict" 27 | set saw_restrict "$i" 28 | case "-a" 29 | set saw_arg0 "$i" 30 | case "--arg0" 31 | set saw_arg0 "$i" 32 | case "*" 33 | if [ "$saw_arg0" -ne 0 ]; and [ "$saw_arg0_arg" -eq 0 ] 34 | set saw_arg0_arg "$i" 35 | else if [ "$saw_stratum" -eq 0 ] 36 | set saw_stratum "$i" 37 | else 38 | set saw_command "$i" 39 | end 40 | end 41 | end 42 | 43 | set opts "" 44 | if [ "$saw_arg0" -ne 0 ]; and [ "$saw_arg0_arg" -eq 0 ] 45 | set opts "$opts newarg" 46 | else if [ "$saw_stratum" -eq 0 ] 47 | set opts "$opts stratum" 48 | if [ "$saw_help" -eq 0 ] 49 | set opts "$opts help" 50 | end 51 | if [ "$saw_restrict" -eq 0 ] 52 | set opts "$opts restrict" 53 | end 54 | if [ "$saw_arg0" -eq 0 ] 55 | set opts "$opts arg0" 56 | end 57 | else if [ "$saw_command" -eq 0 ] 58 | set opts "$opts command" 59 | else 60 | set opts "$opts pass" 61 | end 62 | 63 | if echo "$opts" | grep -q "\<$argv\>" 64 | return 0 65 | else 66 | return 1 67 | end 68 | end 69 | 70 | function _strat_subcommand 71 | set args (commandline -opc) 72 | 73 | set saw_help "0" 74 | set saw_restrict "0" 75 | set saw_arg0 "0" 76 | set saw_arg0_arg "0" 77 | set saw_stratum "0" 78 | set saw_command "0" 79 | for i in (seq 2 (count $args)) 80 | switch "$args[$i]" 81 | case "-h" 82 | set saw_help "$i" 83 | case "--help" 84 | set saw_help "$i" 85 | case "-r" 86 | set saw_restrict "$i" 87 | case "--restrict" 88 | set saw_restrict "$i" 89 | case "-a" 90 | set saw_arg0 "$i" 91 | case "--arg0" 92 | set saw_arg0 "$i" 93 | case "*" 94 | if [ "$saw_arg0" -ne 0 ]; and [ "$saw_arg0_arg" -eq 0 ] 95 | set saw_arg0_arg "$i" 96 | else if [ "$saw_stratum" -eq 0 ] 97 | set saw_stratum "$i" 98 | else 99 | set saw_command "$i" 100 | end 101 | end 102 | end 103 | 104 | __fish_complete_subcommand --fcs-skip=(math $saw_command - 1) 105 | end 106 | 107 | function _strat_command 108 | set args (commandline -opc) 109 | 110 | set saw_help "0" 111 | set saw_restrict "0" 112 | set saw_arg0 "0" 113 | set saw_arg0_arg "0" 114 | set saw_stratum "0" 115 | set saw_command "0" 116 | for i in (seq 2 (count $args)) 117 | switch "$args[$i]" 118 | case "-h" 119 | set saw_help "$i" 120 | case "--help" 121 | set saw_help "$i" 122 | case "-r" 123 | set saw_restrict "$i" 124 | case "--restrict" 125 | set saw_restrict "$i" 126 | case "-a" 127 | set saw_arg0 "$i" 128 | case "--arg0" 129 | set saw_arg0 "$i" 130 | case "*" 131 | if [ "$saw_arg0" -ne 0 ]; and [ "$saw_arg0_arg" -eq 0 ] 132 | set saw_arg0_arg "$i" 133 | else if [ "$saw_stratum" -eq 0 ] 134 | set saw_stratum "$i" 135 | else 136 | set saw_command "$i" 137 | end 138 | end 139 | end 140 | 141 | set prefix "/bedrock/strata/$args[$saw_stratum]" 142 | for dir in $PATH 143 | if not echo "$dir" | grep -q "^/bedrock/cross" 144 | ls -1 $prefix$dir 2>/dev/null 145 | end 146 | end 147 | end 148 | 149 | complete -f -c strat -o 'h' -d 'print help message' -n '_strat_opts help' 150 | complete -f -c strat -l 'help' -d 'print help message' -n '_strat_opts help' 151 | complete -f -c strat -o 'r' -d 'disable cross-stratum hooks' -n '_strat_opts restrict' 152 | complete -f -c strat -l 'restrict' -d 'disable cross-stratum hooks' -n '_strat_opts restrict' 153 | complete -f -c strat -o 'a' -d 'specify arg0' -n '_strat_opts arg0' 154 | complete -f -c strat -l 'arg0' -d 'specify arg0' -n '_strat_opts arg0' 155 | complete -f -c strat -a '(/bedrock/bin/brl list)' -d 'stratum' -n '_strat_opts stratum' 156 | complete -f -c strat -a '(_strat_command)' -n '_strat_opts command' 157 | complete -x -c strat -a '(_strat_subcommand)' -n '_strat_opts pass' 158 | -------------------------------------------------------------------------------- /src/slash-bedrock/share/fonts/fontconf.conf: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | /bedrock/cross/fonts/ 6 | 7 | -------------------------------------------------------------------------------- /src/slash-bedrock/share/info/.keepinfodir: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bedrocklinux/bedrocklinux-userland/eab5b73acd9370994594f56e3a91e89e98d9ad35/src/slash-bedrock/share/info/.keepinfodir -------------------------------------------------------------------------------- /src/slash-bedrock/share/pmm/flags: -------------------------------------------------------------------------------- 1 | #!/bedrock/libexec/busybox awk -f 2 | # 3 | # Package Manager Manager flags 4 | # 5 | # This program is free software; you can redistribute it and/or 6 | # modify it under the terms of the GNU General Public License 7 | # version 2 as published by the Free Software Foundation. 8 | # 9 | # Copyright (c) 2013-2020 Daniel Thau 10 | 11 | # Map pmm internal name for a flag to either "value" or "binary". 12 | # 13 | # "value" indicates it expects a corresponding value. For example, in: 14 | # 15 | # pmm --stratum ubuntu install vim 16 | # 17 | # The flag `--stratum` takes a value, `ubuntu`. 18 | # 19 | # "binary" indicates it is a binary flag. It is either present or it is 20 | # not. For example, in: 21 | # 22 | # pmm --quiet install vim 23 | # 24 | # The flag `--quiet` is present. The alternative was it not being present. It 25 | # does not take a value. 26 | 27 | # 28 | # General, operation independent flags 29 | # 30 | flags["assume-no"] = "binary" 31 | flags["assume-yes"] = "binary" 32 | flags["confirm"] = "binary" 33 | flags["quiet"] = "binary" 34 | flags["verbose"] = "binary" 35 | 36 | # 37 | # pmm specific, operation independent flags 38 | # 39 | flags["strat"] = "value" 40 | flags["package-manager"] = "value" 41 | flags["every"] = "binary" 42 | flags["newest"] = "binary" 43 | flags["oldest"] = "binary" 44 | flags["approx-version"] = "value" 45 | flags["exact-version"] = "value" 46 | flags["newer-or-equal"] = "value" 47 | flags["newer-than"] = "value" 48 | flags["older-or-equal"] = "value" 49 | flags["older-than"] = "value" 50 | -------------------------------------------------------------------------------- /src/slash-bedrock/share/pmm/package_managers/pmm: -------------------------------------------------------------------------------- 1 | #!/bedrock/libexec/busybox awk -f 2 | # 3 | # Package Manager Manager pmm-specific operation support 4 | # 5 | # This program is free software; you can redistribute it and/or 6 | # modify it under the terms of the GNU General Public License 7 | # version 2 as published by the Free Software Foundation. 8 | # 9 | # Copyright (c) 2013-2020 Daniel Thau 10 | 11 | # 12 | # Most of pmm's user interface and operation/flag capabilities mirror those of 13 | # other package managers. However, it offers a number of pmm-specific concepts 14 | # as well. Those are registered here utilizing "*" to effectively register 15 | # them with all other package managers. 16 | # 17 | 18 | # 19 | # pmm specific, operation independent flags 20 | # 21 | # Since these are pmm specific, other package managers will not have flags for 22 | # them. To make them accessible, use "*" to register them for all package 23 | # managers. 24 | # 25 | user_interfaces["*", "strat"] = "--strat/--stratum" 26 | user_interfaces["*", "package-manager"] = "--pm/--package-manager" 27 | user_interfaces["*", "newest"] = "--newest" 28 | user_interfaces["*", "oldest"] = "--oldest" 29 | user_interfaces["*", "approx-version"] = "--approx-version" 30 | user_interfaces["*", "exact-version"] = "--exact-version" 31 | user_interfaces["*", "newer-or-equal"] = "--newer-or-equal" 32 | user_interfaces["*", "newer-than"] = "--newer-than" 33 | user_interfaces["*", "older-or-equal"] = "--older-or-equal" 34 | user_interfaces["*", "older-than"] = "--older-than" 35 | user_interfaces["*", "every"] = "--every" 36 | 37 | # 38 | # Internal pmm operations. 39 | # 40 | # Since these are not user facing, use "*" to register that all package 41 | # managers have empty user interfaces for these items. 42 | # 43 | user_interfaces["*", "is-package-installed"] = "" 44 | user_interfaces["*", "is-package-available"] = "" 45 | user_interfaces["*", "is-file-db-available"] = "" 46 | user_interfaces["*", "print-file-db-install-instructions"] = "" 47 | user_interfaces["*", "print-package-version"] = "" 48 | user_interfaces["*", "cache-package-db"] = "" 49 | 50 | # 51 | # pmm specific operations. 52 | # 53 | # Since these are pmm specific, normal package managers will not have 54 | # corresponding user interfaces or implementations. Use "*" to register that 55 | # all package managers have empty user interfaces for these items. 56 | # 57 | # Corresponding implementations[] is ignored and implemented internally to pmm. 58 | # Include empty items here for completion's sake. 59 | # 60 | user_interfaces["*", "diff-world"] = "pmm --diff-world" 61 | user_interfaces["*", "update-world-installed"] = "pmm --update-world-installed" 62 | user_interfaces["*", "update-world-removed"] = "pmm --update-world-removed" 63 | user_interfaces["*", "update-world"] = "pmm --update-world" 64 | user_interfaces["*", "apply-world-installed"] = "pmm --apply-world-installed" 65 | user_interfaces["*", "apply-world-removed"] = "pmm --apply-world-removed" 66 | user_interfaces["*", "apply-world"] = "pmm --apply-world" 67 | user_interfaces["*", "check-pmm-configuration"] = "pmm --check-pmm-configuration" 68 | user_interfaces["*", "list-pmm-ui-files"] = "pmm --list-pmm-ui-files" 69 | 70 | implementations["*", "diff-world"] = "" 71 | implementations["*", "update-world-installed"] = "" 72 | implementations["*", "update-world-removed"] = "" 73 | implementations["*", "update-world"] = "" 74 | implementations["*", "apply-world-installed"] = "" 75 | implementations["*", "apply-world-removed"] = "" 76 | implementations["*", "apply-world"] = "" 77 | implementations["*", "check-pmm-configuration"] = "" 78 | implementations["*", "list-pmm-ui-files"] = "" 79 | 80 | # 81 | # Errors 82 | # 83 | user_interfaces["*", "no-match-error"] = "" 84 | implementations["*", "no-match-error"] = "" 85 | -------------------------------------------------------------------------------- /src/slash-bedrock/share/resolvconf/00bedrock: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Some distro network stacks become confused if they see a /etc/resolv.conf 4 | # from a different distro's network stack. Consequently, rebooting a Bedrock 5 | # system between distro inits - and network stacks - is prone to breaking if 6 | # /etc/resolv.conf is retained across the reboot. To resolve this, Bedrock 7 | # removes /etc/resolv.conf before handing control off to session init under the 8 | # expectation that the init will create /etc/resolv.conf itself once it sees it 9 | # missing. 10 | # 11 | # However, this introduces difficulties with other distro network stacks which 12 | # will create an resolv.conf file, but not at /etc/resolv.conf, under the 13 | # assumption that something else is responsible for making /etc/resolv.conf a 14 | # symlink. To resolve this, Bedrock configures systems to run this script at 15 | # the appropriate time to create a symlink at /etc/resolv.conf pointing to 16 | # whatever distro networking stack created resolv.conf location. 17 | # 18 | 19 | # Something already created a /etc/resolv.conf 20 | if [ -e /etc/resolv.conf ] || [ -h /etc/resolv.conf ]; then 21 | exit 22 | fi 23 | 24 | # Try known resolv.conf locations from various distros 25 | for f in /etc/resolvconf/run/resolv.conf \ 26 | /run/resolvconf/resolv.conf \ 27 | /run/systemd/resolve/stub-resolv.conf \ 28 | /run/NetworkManager/resolv.conf \ 29 | /run/systemd/resolve/resolv.conf \ 30 | ; do 31 | if [ -e "${f}" ]; then 32 | ln -s "${f}" /etc/resolv.conf 33 | exit 34 | fi 35 | done 36 | -------------------------------------------------------------------------------- /src/slash-bedrock/share/shells/include-bedrock: -------------------------------------------------------------------------------- 1 | 2 | # Automatically added by Bedrock Linux 3 | . /bedrock/run/profile 4 | -------------------------------------------------------------------------------- /src/slash-bedrock/share/sudo/include-bedrock: -------------------------------------------------------------------------------- 1 | 2 | # Automatically added by Bedrock Linux 3 | #include /bedrock/run/sudoers 4 | -------------------------------------------------------------------------------- /src/slash-bedrock/share/systemd/bedrock-fix-mounts.service: -------------------------------------------------------------------------------- 1 | # systemd appears to automatically share all preexisting mount points at boot. 2 | # Moreover, this functionality appears to be hard-coded with no configuration 3 | # option to disable it. 4 | # 5 | # This attempts to re-apply Bedrock's desired mount point settings after 6 | # systemd has finished changing them. 7 | # 8 | # Additonally it fixes LVM devices. 9 | 10 | [Unit] 11 | Description=Bedrock Linux tweak to undo systemd mount changes 12 | DefaultDependencies=false 13 | 14 | [Service] 15 | Type=oneshot 16 | ExecStart=/bedrock/libexec/busybox sh -c '/bedrock/bin/brl repair $(/bedrock/bin/brl list)' 17 | ExecStart=/bin/udevadm trigger --type=devices --action=change 18 | 19 | [Install] 20 | WantedBy=multi-user.target 21 | -------------------------------------------------------------------------------- /src/slash-bedrock/share/systemd/bedrock-fix-resolv.service: -------------------------------------------------------------------------------- 1 | # Some distro network stacks become confused if they see a /etc/resolv.conf 2 | # from a different distro's network stack. Consequently, rebooting a Bedrock 3 | # system between distro inits - and network stacks - is prone to breaking if 4 | # /etc/resolv.conf is retained across the reboot. To resolve this, Bedrock 5 | # removes /etc/resolv.conf before handing control off to session init under the 6 | # expectation that the init will create /etc/resolv.conf itself once it sees it 7 | # missing. 8 | # 9 | # However, this introduces difficulties with other distro network stacks which 10 | # will create an resolv.conf file, but not at /etc/resolv.conf, under the 11 | # assumption that something else is responsible for making /etc/resolv.conf a 12 | # symlink. To resolve this, this unit attempts to create /etc/resolv.conf. 13 | 14 | [Unit] 15 | Description=Bedrock Linux tweak to assist /etc/resolv.conf management 16 | After=NetworkManager.service systemd-resolved.service 17 | 18 | [Service] 19 | Type=oneshot 20 | ExecStart=/bedrock/share/resolvconf/00bedrock 21 | 22 | [Install] 23 | WantedBy=network-online.target 24 | -------------------------------------------------------------------------------- /src/slash-bedrock/share/systemd/bedrock-stop-fuse-filesystems.service: -------------------------------------------------------------------------------- 1 | # systemd appears to have difficulty stopping FUSE filesystems. 2 | # Lets stop our own to remove the responsibility from systemd. 3 | 4 | [Unit] 5 | Description=Shutdown Bedrock Linux FUSE filesystems. 6 | 7 | [Service] 8 | RemainAfterExit=yes 9 | ExecStart=-/bedrock/libexec/busybox true 10 | ExecStop=-/bedrock/libexec/busybox sh /bedrock/share/systemd/stop-fuse-filesystems.sh 11 | 12 | [Install] 13 | WantedBy=multi-user.target 14 | -------------------------------------------------------------------------------- /src/slash-bedrock/share/systemd/stop-fuse-filesystems.sh: -------------------------------------------------------------------------------- 1 | #!/bedrock/libexec/busybox sh 2 | # 3 | # Some systemd version circa systemd 237 in 2018 was found to have difficulty 4 | # unmounting FUSE filesystems which resulted in shutdown delays. Bedrock 5 | # worked around this with a unit file that assists in unmounting Bedrock's FUSE 6 | # filesytems. 7 | # 8 | # Some systemd version circa systemd 245 in 2020 was found to have improved the 9 | # FUSE filesystem handling, but changed something which resulted in Bedrock's 10 | # FUSE assistance causing a shutdown delay. 11 | # 12 | # Thus, we only want to assist unmounting for pre-245 systemd versions. 13 | 14 | if command -v systemctl >/dev/null 2>&1 && [ "$(systemctl --version | awk '{print$2;exit}')" -lt 245 ]; then 15 | umount -l /etc /bedrock/strata/*/etc /bedrock/cross /bedrock/strata/*/bedrock/cross 16 | fi 17 | 18 | # Some systemd version circa systemd 254 in 2023 was found to have difficulty 19 | # unmounting some mount points within the bedrock stratum for some users. 20 | # Specifics were difficult to nail down. Unmount everything in the bedrock 21 | # stratum en mass as a work-around. 22 | for m in $(awk '{print$2}' /proc/mounts | grep '^/bedrock/strata/bedrock/'); do 23 | mount --make-private "${m}" 24 | umount -l "${m}" 25 | done 26 | -------------------------------------------------------------------------------- /src/slash-bedrock/share/zsh/completion/_strat: -------------------------------------------------------------------------------- 1 | #compdef strat 2 | # zsh tab completion for strat 3 | # 4 | # This program is free software; you can redistribute it and/or 5 | # modify it under the terms of the GNU General Public License 6 | # version 2 as published by the Free Software Foundation. 7 | # 8 | # Copyright (c) 2018 Daniel Thau 9 | # 10 | 11 | # List items in the PATH local that aren't in /bedrock/cross. That is, those 12 | # local to the given stratum. 13 | _strat_local_cmds() { 14 | local -a prefix 15 | # zsh-ism: ${words} is auto-populated by the shell 16 | # shellcheck disable=SC2154 17 | prefix="/bedrock/strata/${words[${#words}-1]}" 18 | 19 | # zsh-ism 20 | # shellcheck disable=SC2154 21 | for dir in ${(@s/:/)PATH} 22 | do 23 | if ! [[ "${dir}" =~ "^/bedrock/cross/" ]] 24 | then 25 | _arguments "*:command:_files -W ${prefix}${dir}" 26 | fi 27 | done 28 | } 29 | 30 | # Strip everything preceeding the in-stratum command, then pass to normal zsh 31 | # completion for the rest of the line. 32 | _strat_local_params() { 33 | words[1]=() CURRENT=$((CURRENT - 1)) _normal 34 | } 35 | 36 | # zsh-ism: this file is effectively a function. 37 | # shellcheck disable=SC2168 38 | local -a args 39 | args=( 40 | # Flags 41 | '(-r --restrict)'{-r,--restrict}'[disable cross-stratum hooks]' 42 | "-a[specify arg0]:new arg0:" 43 | "--arg0[specify arg0]:new argv[0]:" 44 | '(-h --help)'{-h,--help}'[print help message]' 45 | # Stratum 46 | "(-)1:stratum:($(/bedrock/bin/brl list -a))" 47 | # Command to run from stratum 48 | '2:command:_strat_local_cmds' 49 | # Parameters for command being run from specified stratum 50 | '*::parameters:_strat_local_params' 51 | ) 52 | 53 | # zsh-ism: we want it to expand here 54 | # shellcheck disable=SC2128,SC2086 55 | _arguments ${args} 56 | -------------------------------------------------------------------------------- /src/slash-bedrock/share/zsh/include-bedrock: -------------------------------------------------------------------------------- 1 | 2 | # Automatically added by Bedrock Linux 3 | . /bedrock/run/zprofile 4 | -------------------------------------------------------------------------------- /src/slash-bedrock/var/lock: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bedrocklinux/bedrocklinux-userland/eab5b73acd9370994594f56e3a91e89e98d9ad35/src/slash-bedrock/var/lock -------------------------------------------------------------------------------- /src/strat/Makefile: -------------------------------------------------------------------------------- 1 | # strat makefile 2 | # 3 | # This program is free software; you can redistribute it and/or 4 | # modify it under the terms of the GNU General Public License 5 | # version 2 as published by the Free Software Foundation. 6 | # 7 | # Copyright (c) 2012-2018 Daniel Thau 8 | 9 | all: strat 10 | 11 | strat: strat.c 12 | $(CC) $(CFLAGS) -std=c99 strat.c -o strat -lcap 13 | 14 | clean: 15 | rm -f strat 16 | 17 | install: 18 | mkdir -p $(prefix)/bin 19 | install -m 755 strat $(prefix)/bin/strat 20 | 21 | uninstall: 22 | rm -f $(prefix)/bin/strat 23 | -------------------------------------------------------------------------------- /src/strat/README.md: -------------------------------------------------------------------------------- 1 | strat 2 | ===== 3 | 4 | strat runs the specified Bedrock Linux stratum's instance of an executable. 5 | 6 | Usage 7 | ----- 8 | 9 | To use, run: 10 | 11 | strat 12 | 13 | Consider, for example, a Bedrock Linux install with both Debian and Ubuntu 14 | strata. If one would like to search for a package that provides vim, one could run: 15 | 16 | apt search vim 17 | 18 | However, which instance of apt - Debian's or Ubuntu's - is in use is 19 | context-dependent, which may not be desired. To explicitly specify which to 20 | use one should use strat. For example, to search Debian's repositories for vim, 21 | one could run: 22 | 23 | strat debian apt search vim 24 | 25 | Or to search Ubuntu's, one could run: 26 | 27 | strat ubuntu apt search vim 28 | 29 | Some commands require a specific argv[0]. To explicitly set this, use `-a` or 30 | `--arg0`. For example: 31 | 32 | strat --arg0 ls gentoo busybox 33 | 34 | It is often useful to restrict a given process to only the executables provided 35 | by its local stratum. For example, this helps avoid mixing dependencies across 36 | strata when compiling. To enforce this for the duration of a given command, 37 | run with `-r` or `--restrict`. For example: 38 | 39 | strat --restrict arch makepkg 40 | 41 | Installation 42 | ------------ 43 | 44 | Bedrock Linux should be distributed with a script which handles installation, 45 | but just in case: 46 | 47 | The dependencies are: 48 | 49 | - libcap (can be found here: https://sites.google.com/site/fullycapable/) 50 | 51 | To compile, run 52 | 53 | make 54 | 55 | To install into installdir, run 56 | 57 | make prefix= install 58 | 59 | Then proceed to use "setcap" to set the "cap_sys_chroot=ep" capability on the 60 | installed brc executable: 61 | 62 | /bedrock/libexec/setcap cap_sys_chroot=ep /path/to/strat 63 | 64 | To clean up, like usual: 65 | 66 | make clean 67 | 68 | And finally, to remove it, run: 69 | 70 | make prefix= uninstall 71 | --------------------------------------------------------------------------------