This commit is contained in:
exkc 2022-07-28 17:31:45 +08:00
parent cc4cfb0e74
commit ab27f6c172
123 changed files with 27183 additions and 60 deletions

339
LICENSE Normal file
View File

@ -0,0 +1,339 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Lesser General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License.

1411
Makefile Normal file

File diff suppressed because it is too large Load Diff

264
README.md
View File

@ -1,92 +1,236 @@
# Loongbedrocklinux Userland
# Attempt To Port Bedrock To Loong64
Trying to port
# Fork from commit 9ba01417713b9bfb11472fe00149014db5e32f28
## Getting started
Bedrock Linux Userland
======================
To make it easy for you to get started with GitLab, here's a list of recommended next steps.
Bedrock Linux is a Linux distribution composed of user-selected components from
various other Linux distributions. For example, with Bedrock one may use the
installation process from one distribution, the init from another, a window
manager from a third, and a web browser from a fourth. Bedrock strives to make
these components work together as transparently as possible such that for
day-to-day operations it is not readily evident that the various components
were originally intended for disparate distributions.
Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
This repository contains all the userland code for a Bedrock Linux system. It
can create a script which may be used to install or update a Bedrock Linux
system.
## Add your files
Building the installer/updater
------------------------------
- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files
- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command:
On a Linux system, install the build dependencies:
```
cd existing_repo
git remote add origin https://gitlab.com/exkc/loongbedrocklinux-userland.git
git branch -M main
git push -uf origin main
```
- Standard UNIX utilities: grep, sed, awk, etc.
- autoconf
- autopoint
- bison
- fakeroot
- gcc 4.9.1 or newer
- git 1.8 or newer
- gpg (optional)
- gzip
- libtool
- make
- meson 0.38 or newer
- ninja-build
- pkg-config
- rsync
- udev (build-time only)
- wget
## Integrate with your tools
Ensure you have internet access (to fetch upstream dependencies), then run:
- [ ] [Set up project integrations](https://gitlab.com/exkc/loongbedrocklinux-userland/-/settings/integrations)
make GPGID=<gpg-id-with-which-to-sign>
## Collaborate with your team
to build a signed install/update script or
- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/)
- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html)
- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically)
- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/)
- [ ] [Automatically merge when pipeline succeeds](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html)
make SKIPSIGN=true
## Test and Deploy
to build an unsigned install/update script.
Use the built-in continuous integration in GitLab.
The build process can be customized in the same fashion as most make and C
projects:
- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html)
- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing(SAST)](https://docs.gitlab.com/ee/user/application_security/sast/)
- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html)
- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/)
- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html)
- You may use `-jN` to tell make to parallelize the build process with `N`
jobs.
- You may set `CFLAGS` to pass flags to the C compiler such as `-Os` and
`-march=native`.
- Bedrock's components *must* be statically compiled. The build system
sets `-static` in various places. Do not set `-dynamic` or otherwise
try to change away from a static build.
***
This will produce a script such as:
# Editing this README
bedrock-linux-0.7-x86_64.sh
When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thank you to [makeareadme.com](https://www.makeareadme.com/) for this template.
which may be used to install or update a Bedrock Linux system.
## Suggestions for a good README
Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
Installation
## Name
Choose a self-explaining name for your project.
- Install another, traditional Linux distribution.
- Select a filesystem which supports extended filesystem attributes.
- Setup users, networking, etc as one would typically do.
- Reboot into the fresh install.
- Get the `bedrock-linux-<version>-<arch>.sh` script onto the system, either by
building it locally or getting a pre-built version from elsewhere.
- Run the script as root with the `--hijack` flag.
- Follow the prompts.
- Reboot. Re-select the new install at any bootloader prompt.
- You're now running Bedrock Linux, but with only the initial install's files.
To leverage Bedrock's features, we need other distribution's files as well.
- Run `brl fetch --list` to see the various distributions which Bedrock knows
how to fetch.
- As root, run `brl fetch <distros>` to acquire upstream distribution files.
- If this fails, you may need to manually look up release and mirror
information for the desired distribution and provide the information
with `--release` and `--mirror` flags.
## Description
Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
Basic usage
-----------
## Badges
On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
A Bedrock Linux system is composed of "strata". These are collections of
interrelated files. These are often, but not always, one-to-one with other,
traditional Linux distributions. Bedrock integrates these strata together,
creating a single, largely cohesive system with desirable features from other
distributions.
## Visuals
Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
To list the currently installed (and enabled) strata, run:
## Installation
Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
$ brl list
## Usage
Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
To list distros which can be easily acquired as strata, run:
## Support
Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
$ brl fetch --list
## Roadmap
If you have ideas for releases in the future, it is a good idea to list them in the README.
To acquire new strata, run (as root):
## Contributing
State if you are open to contributions and what your requirements are for accepting them.
# brl fetch <distros>
For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
Once that has completed, you may run commands from the new strata. For
example, the following series of commands make sense on a Bedrock system:
You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
$ sudo brl fetch arch debian
$ sudo pacman -S mupdf && sudo apt install texlive
$ man pdflatex
$ pdflatex preexisting-file.tex && mupdf preexisting-file.pdf
## Authors and acknowledgment
Show your appreciation to those who have contributed to the project.
Bedrock's integration is not limited to the command line. For example,
graphical application menus or launchers will automatically pick up
applications across strata, and Xorg fonts installed from one stratum will be
picked up in an X11 graphical application from another stratum.
## License
For open source projects, say how it is licensed.
If there are multiple instances of an executable, Bedrock will select one by
default in a given context. If there are hints it can pick up on for which one
to use, it is normally correct. `brl which` can be used to query which Bedrock
will select in a given context. For example:
## Project status
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
$ # arch, debian, and centos are installed.
$ # running debian's init, and thus must use debian's reboot
$ sudo brl which -b reboot
debian
$ # only arch provides pacman, so arch's pacman will be used
$ brl which -b pacman
arch
$ # yum is a python script. Since yum comes from centos, the python
$ # interpreter used to run yum will also come from centos.
$ sudo yum update
^Z
$ brl which $(pidof python | cut -d' ' -f1)
centos
If you would like a specific instance, you may select it with `strat`:
$ # arch, debian, and ubuntu are installed
$ # install vlc from arch
$ sudo pacman -S vlc
$ # install vlc from debian
$ sudo strat debian apt install vlc
$ # install vlc from ubuntu
$ sudo strat ubuntu apt install vlc
$ # run default vlc
$ vlc /path/to/video
$ # run arch's vlc
$ strat arch vlc /path/to/video
$ # run debian's vlc
$ strat debian vlc /path/to/video
$ # run ubuntu's vlc
$ strat ubuntu vlc /path/to/video
To avoid conflicts, processes from one stratum may see its own stratum's
instance of a given file. For example, Debian's `apt` and Ubuntu's `apt` must
both see their own instance of `/etc/apt/sources.list`. Other files must be
shared across strata to ensure they work together, and thus all strata see the
same file. For example, `/home`. Such shared files are referred to as
"global". Which stratum provides a file in a given context can be queried by
`brl which`:
$ # which stratum is my shell from?
$ brl which --pid $$
gentoo
$ # that query is common enough the PID may be dropped
$ brl which
gentoo
$ # which stratum provides ~/.vimrc
$ brl which --filepath ~/.vimrc
global
$ # global indicates all stratum seem the same file; not specific to any
$ # stratum.
$ brl which --filepath /bin/bash
gentoo
$ brl which --bin pacman
arch
If you would like to specify which non-global file to read or write, prefix
`/bedrock/strata/<stratum>/` to its path.
$ brl which --filepath /bedrock/strata/debian/etc/apt/sources.list
debian
$ brl which --filepath /bedrock/strata/ubuntu/etc/apt/sources.list
ubuntu
$ # edit debian's sources.list with ubuntu's vi
$ strat ubuntu vi /bedrock/strata/debian/etc/apt/sources.list
`brl` provides much more functionality which can be read from `brl --help`.
A concrete list of everything Bedrock can integrate, work-arounds for known
limitations, and other useful information may be found at bedrocklinux.org.
Hacking
-------
To sanity check your work (e.g. before upstream changes to Bedrock Linux),
install:
- shellcheck
- cppcheck
- clang
- gcc
- tcc
- scan-build (usually distributed with clang)
- shfmt (https://github.com/mvdan/sh)
- indent (GNU)
- uthash
- libfuse3
- libcap
- libattr
Run
make format
to standardize the formatting of any changes you may have made, then run
make check
to run various sanity checks against the code base.
Where To Get Help
-----------------
- Website: https://bedrocklinux.org
- IRC: `#bedrock` on libera.chat
- Forums: http://www.linuxquestions.org/questions/bedrock-linux-118
- Reddit: http://reddit.com/r/bedrocklinux
- Github: https://github.com/bedrocklinux

302
ReleaseNotes.md Normal file
View File

@ -0,0 +1,302 @@
# 0.7.28beta1
- Improved brl-fetch handling of GPT and multi-partition images
- Removed redundant Ubuntu vt.handoff hack handling
# 0.7.27
- Fixed brl-fetch arch
# 0.7.26
- Fixed GRUB+BTRFS check false-positives.
# 0.7.25
- Fixed brl-fetch centos
- Fixed brl-fetch fedora
- Fixed brl-fetch gentoo
- Improved brl-fetch error message
- Improved systemd 250 shutdown performance
- Increased hijack-time GRUB+BTRFS detection sensitivity
# 0.7.24
- Added pmm zsh completion
- Fixed brl zsh completion
- Fixed brl-fetch centos
- Fixed brl-fetch fedora locale
- Fixed brl-fetch ubuntu
- Fixed resolve.conf handling with some distros/inits
- Improved theoretical robustness of init selection menu
# 0.7.23
- Add support for s6
- Security updates for openssl
# 0.7.22
- Added code to handle errant program clearing modules.dep
- Fixed brl-fetch debian for bullseye
- Fixed hijacked GRUB theme handling
- Fixed resolv.conf on some distros
# 0.7.21
- Added automatic restriction of cmake, dkms
- Added brl-fetch alma
- Added brl-fetch artix-s6
- Added brl-fetch rocky
- Added pmm upgrade-packages*,remove-orphans operations
- Added zstd support to modprobe
- Fixed Gentoo/portage attempting to write to /bedrock/cross/info
- Fixed booting with s6 breaking Bedrock's /run setup
- Fixed brl-fetch artix
- Fixed brl-fetch debian
- Fixed brl-fetch ubuntu
# 0.7.20
- Added brl-import command
- Fixed brl-fetch centos
- Fixed brl-fetch localegen logic issue in some situations
- Fixed brl-fetch solus
- Fixed various pmm issues
- Improved brl SSL handling portability
- Worked around Linux kernel FUSE atomic write bug
# 0.7.18
- Added automatic restriction of CRUX's prt-get, pkgmk
- Added code to load modules on init to help with keyboard detection
- Added crossfs support for wayland-sessions
- Added envvar crossfs settings
- Added more setfattr hijack sanity checks
- Added pmm support for dnf short aliases
- Added retention of BEDROCK_RESTRICTION across sudo call
- Added themes, backgrounds to crossfs defaults
- Fixed /bedrock/cross/bin/X11 self-reference loop
- Fixed brl fetch --list tab completion comment
- Fixed brl priority color handling when brl colors are disabled
- Fixed brl-fetch Alpine
- Fixed brl-fetch Fedora
- Fixed brl-fetch Gentoo
- Fixed brl-fetch KISS
- Fixed brl-fetch centos
- Fixed brl-fetch devuan detection of stable release
- Fixed brl-fetch manjaro
- Fixed brl-strat completion
- Fixed detection of package manager user interface at hijack
- Fixed fish envvar handling
- Fixed overwriting system and user-set PATH entries
- Fixed pmm creation of redundant items when superseding
- Fixed pmm support for pacman,yay search-for-package-by-name
- Fixed pmm support for portage which-packages-provide-file
- Fixed pmm using supersede logic when unneeded
- Fixed portage is-file-db-available noise
- Fixed restriction of XDG_DATA_DIRS
- Fixed zprofile restriction check
- Improved brl-fetch handling of different ssl standards
- Improved brl-fetch locale-gen failure handling
- Improved brl-fetch void to use smaller base-minimal
- Improved crossfs multithread performance if openat2 available (Linux 5.6 and up)
- Improved env-var handling
- Improved etcfs debug output
- Improved plymouth handling
# 0.7.17
- Fixed sudoers injection return value
# 0.7.16
- Added cross-stratum /etc/crypttab support
- Added cross-stratum /etc/profile.d/*.sh support
- Added cross-stratum dkms support
- Fixed brl-fetch fedora, void, void-musl
- Improve brl-fetch error messages
- Improve pmm pacman/yay handling to only supersede identical commands
- Restrict kiss package manager
# 0.7.15
- Added pmm to brl-tutorial
- Fixed brl-tutorial typo
- Fixed pmm apt no-cache package availability check
# 0.7.14
- Added ppc and ppc64 support
- Added Package Manager Manager ("pmm")
- Added code to recover from bad bedrock.conf timezone values
- Added sanity check against GRUB+BTRFS/ZFS issue
- Fixed Path, TryExec handling in crossfs ini filter
- Fixed brl-fetch centos, kiss, void, void-musl, debian sid,
# 0.7.13
- Fixed brl-fetch arch
- Fixed brl-fetch kiss
# 0.7.12
- Fixed brl-fetch artix
- Fixed bash completion for brl-tutorial
# 0.7.11
- Added brl-tutorial command
- Added basics tutorial
- Added brl-fetch tutorial
- Added brl-fetch support for Fedora 31
- Added brl-fetch support for Manjaro
- Fixed brl-fetch debug handling
- Fixed brl-disable handling of invalid stratum
# 0.7.10
- Add brl-fetch centos support for CentOS 8 and 8-stream
- Add brl-fetch support for Artix
- Fix brl-fetch debian, devuan, raspbian and ubuntu libapt-pkg.so warning
- Fix brl-fetch ubuntu default release detection considering "devel" a release
- Improve hijack warning to better explain what it will do
# 0.7.9
- Ensure bouncer updates do not confuse pre-0.7.8 crossfs builds
# 0.7.8
- Added LVM support
- Added brl-fetch Arch Linux 32
- Added brl-fetch Exherbo
- Added caching support
- Added debug subsystem
- Add etcfs debug support
- Add brl-fetch debug support
- Added i386, i486, i586, and i686 support
- Added wait for keyboard initialisation
- This fixed no keyboard in init selection menu issue
- Fixed brl-fetch exherbo
- Fixed crossfs handling of live bouncer changes
- Fixed etcfs file descriptor leak
- This fixed Void init emergence shell issue
- Improved build system performance
- Restrict apt-key by default
- Restrict debuild by default
# 0.7.7
- Added brl-fetch KISS Linux support
- Added brl-report check for environment variables
- Added brl-update support for verifying signature of offline updates
- Added brl-update support scanning multiple configured mirrors
- Added init message about bedrock.conf
- Added installer check for corrupt embedded tarball
- Added installer check for grub2-mkrelpath bug
- Added installer message about bedrock.conf
- Added official installer/update binaries for ppc64le
- Fixed brl-fetch arch
- Fixed brl-fetch fedora
- Fixed brl-fetch mirrors with paths in http indexes
- Fixed brl-fetch non-native void
- Fixed brl-fetch solus
- Fixed installer handling of quotes in distro name
- Fixed login.defs handling bug
- Fixed resolv.conf handling for some distros
- Fixed various shell tab completion issues
- Improved etcfs robustness to power outages
- Removed /var/tmp from share list
- Update expiration date of signing key
- Various minor fixes and improvements.
# 0.7.6
- Added experimental non-native CPU architecture strata support.
- Requires `qemu-user-static`.
- Added experimental non-native CPU capabilities to brl-fetch.
- See new `-a` and `-A` flags in `brl fetch --help`.
- Added official installer/update binaries for additional CPU architectures.
- Fixed Firefox font handling issue. Work-around is no longer needed.
- Various minor fixes and improvements.
# 0.7.5
- Fixed crossfs local alias dereferencing of sandboxed software.
# 0.7.4
- Added `[restriction]` feature, superseding previous `[cross-bin-restrict]` feature.
- Configured restriction is not dropped by `strat` unless explicitly indicated so via `--unrestrict`.
- Local stratum instance of restricted command is used if available.
- Added local alias.
- Fixed Alpine networking issues.
- Fixed `brl fetch -LX` ignoring `-X`
- Fixed determining default Ubuntu release
- Fixed dist-upgrading Ubuntu
- Fixed hijack on bsdtar distros
- Fixed system uid/gid range consistency issues
# 0.7.3
- Added "current" to list of Slackware releases.
- Added code to handle users providing brl-fetch an Arch Linux mirror with
unquoted/escaped shell variables.
- Added cross pixmap support.
- Added resolvconf support.
- Added support for multiple localegen lines.
- Added warning when default init does not exist.
- Fixed `strat -r ... zsh` escaping restriction via sourcing zprofile.
- Fixed fetch handling of Clear Linux.
- Fixed reboot handling after hijacking systems with PID1 provided by SysV init.
- Generalized brl-fetch user/group handling.
- Implemented work-around for Chromium/Electron/et al TZ bug.
- Improved hijack distro name detection to handle MX Linux. (Note other issues
with Bedrock Linux/MX Linux compatibility are known at this time.)
- Various minor UI tweaks.
# 0.7.2
- Made `makepkg` and similar programs restricted by default via new
`[cross-bin-restrict]` configuration.
- Added snap and flatpak items to bedrock.conf
- Added delay between etcfs overrides, which fixes `xbps-install` updating
etcfs-override files such as /etc/environment.
- Added confirmation prompt to installer when hijacking.
- Added sanity checks to installer for WSL and LVM global directories.
- `strat` now sets SHELL=/bin/sh when restricted, as crossfs SHELL entries do
not work when restricted.
- Improved various error messages.
- Added experimental brl-fetch support for Clear Linux, Slackware, and Solus.
- Various minor fixes.
# 0.7.1
- Fixed various issues with init/initrd system for some distros.
- Fixed hidden init-selection menu with Ubuntu
- Fixed systemd freezing with Fedora
- Fixed doubling of output due to lingering plymouthd with Fedora
- Added code to handle various conflicts automatically
- Automatically handle machine-id conflicts
- Automatically clean up dangling /etc/resolv.conf symlinks which confuse some networking software.
- Various and improvements fixes to brl-fetch
- Improved `brl fetch --help` description of -i flag.
- Fixed `brl fetch --releases debian`
- Fixed `brl fetch gentoo` locale configuration.
- Fixed mirror-prefix handling for Fedora.
- Fixed `brl fetch fedora` step count.
- Various reliability improvements for etcfs
- Increased defensiveness of handling of libfuse-provided values.
- Simplified injection logic
- Added new `Exec*` fields to crossfs ini filter
- Fixed brl-repair/enable handling of missing directories
- Fixed brl-which recognition of `/bedrock/strata/*` paths.
- Fixed brl-apply failing to apply new bedrock.conf share/bind fields
- Fixed brl-update unnecessary error message
- Added lsmod to brl-report.
- Fixed bedrock.conf comment typo.
# 0.7.0
- First Poki release. Changes are too numerous from Nyla, starting fresh release notes.

105
detect_arch.sh Executable file
View File

@ -0,0 +1,105 @@
#!/bin/sh
#
# detect_arch.sh
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# version 2 as published by the Free Software Foundation.
#
# Copyright (c) 2019 Daniel Thau <danthau@bedrocklinux.org>
#
# Detects which CPU architecture Bedrock Linux's build system is producing.
# Outputs two lines:
# - First line is Bedrock's name for the architecture. This is used, for
# example, in the output installer/updater file name.
# - Second line is context expected in `file` output on one of the binaries.
# This is used to sanity check the resulting binaries are in fact of the
# expected type.
# - Third line is CPU bit depth.
if ! gcc --version >/dev/null 2>&1; then
echo "ERROR: gcc not found" >&2
exit 1
fi
case "$(gcc -dumpmachine)" in
aarch64-*)
echo "aarch64"
echo "ARM aarch64"
echo "64"
;;
arm-*abi)
echo "armv7l"
echo "EABI5"
echo "32"
;;
arm-*abihf)
echo "armv7hl"
echo "EABI5"
echo "32"
;;
i386-*)
echo "i386"
echo "Intel 80386"
echo "32"
;;
i486-*)
echo "i486"
echo "Intel 80386"
echo "32"
;;
i586-*)
echo "i586"
echo "Intel 80386"
echo "32"
;;
i686-*)
echo "i686"
echo "Intel 80386"
echo "32"
;;
mips-*)
echo "mips"
echo "MIPS32"
echo "32"
;;
mipsel-*)
echo "mipsel"
echo "MIPS32"
echo "32"
;;
mips64el-*)
echo "mips64el"
echo "MIPS64"
echo "64"
;;
powerpc-*)
echo "ppc"
echo "32-bit.*PowerPC"
echo "32"
;;
powerpc64-*)
echo "ppc64"
echo "64-bit PowerPC"
echo "64"
;;
powerpc64le-*)
echo "ppc64le"
echo "64-bit PowerPC"
echo "64"
;;
s390x-*)
echo "s390x"
echo "IBM S/390"
echo "64" # the x in s390x indicates 64 bit
;;
x86_64-*)
echo "x86_64"
echo "x86-64"
echo "64"
;;
*)
echo "Unrecognized CPU architecture" >&2
exit 1
;;
esac

View File

@ -0,0 +1,49 @@
--- ./tools/lvmcmdline.c
+++ ./tools/lvmcmdline.c
@@ -1252,7 +1252,7 @@
int err = is_valid_fd(STDERR_FILENO);
if (!is_valid_fd(STDIN_FILENO) &&
- !(stdin = fopen(_PATH_DEVNULL, "r"))) {
+ !freopen(_PATH_DEVNULL, "r", stdin)) {
if (err)
perror("stdin stream open");
else
@@ -1262,7 +1262,7 @@
}
if (!is_valid_fd(STDOUT_FILENO) &&
- !(stdout = fopen(_PATH_DEVNULL, "w"))) {
+ !freopen(_PATH_DEVNULL, "w", stdout)) {
if (err)
perror("stdout stream open");
/* else no stdout */
@@ -1270,7 +1270,7 @@
}
if (!is_valid_fd(STDERR_FILENO) &&
- !(stderr = fopen(_PATH_DEVNULL, "w"))) {
+ !freopen(_PATH_DEVNULL, "w", stderr)) {
printf("stderr stream open: %s\n",
strerror(errno));
return 0;
--- ./lib/commands/toolcontext.c
+++ ./lib/commands/toolcontext.c
@@ -1869,7 +1869,7 @@
/* FIXME Make this configurable? */
reset_lvm_errno(1);
-#ifndef VALGRIND_POOL
+#if !defined(VALGRIND_POOL) && defined(__GLIBC__)
/* Set in/out stream buffering before glibc */
if (set_buffering
#ifdef SYS_gettid
@@ -2274,7 +2274,7 @@
dm_hash_destroy(cmd->cft_def_hash);
dm_device_list_destroy(&cmd->cache_dm_devs);
-#ifndef VALGRIND_POOL
+#if !defined(VALGRIND_POOL) && defined(__GLIBC__)
if (cmd->linebuffer) {
/* Reset stream buffering to defaults */
if (is_valid_fd(STDIN_FILENO) &&

View File

@ -0,0 +1,11 @@
--- ./lib/mm/memlock.c.orig 2015-03-09 11:18:41.560028850 -0100
+++ ./lib/mm/memlock.c 2015-03-09 11:19:54.504373309 -0100
@@ -137,7 +137,7 @@
static void _allocate_memory(void)
{
-#ifndef VALGRIND_POOL
+#if !defined(VALGRIND_POOL) && defined(__GLIBC__)
void *stack_mem;
struct rlimit limit;
int i, area = 0, missing = _size_malloc_tmp, max_areas = 32, hblks;

376
releases Normal file
View File

@ -0,0 +1,376 @@
# =======================================
# Bedrock Linux 0.7.x installers/updaters
# =======================================
#
# Installation
# ------------
#
# To install a Bedrock Linux 0.7.x system, first install and set up a
# fresh, traditional distro Linux install. Next download the latest of the
# files below corresponding to your CPU architecture and execute it as root
# with a `--hijack` flag, like so:
#
# sh bedrock-linux-<version>-<arch>.sh --hijack
#
# Finally, reboot. Once you are back in the system, explore the `brl` command.
#
# Update with internet
# --------------------
#
# Provided you internet access is available, a Bedrock Linux 0.7.x system may
# be updated by setting this file's URL in as the appropriate mirror value in
# /bedrock/etc/bedrock.conf. Once that is in place, run as root:
#
# brl update
#
# Update without internet
# -----------------------
#
# A Bedrock Linux 0.7.x system may be updated to a newer 0.7.x release by
# downloading a corresponding file below onto the system and executing it as
# root with the `--update` flag, like so:
#
# sh bedrock-linux-<version>-<arch>.sh --update
#
###################
# Current release #
###################
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.28beta1/bedrock-linux-0.7.28beta1-x86_64.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.28beta1/bedrock-linux-0.7.28beta1-s390x.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.28beta1/bedrock-linux-0.7.28beta1-ppc64le.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.28beta1/bedrock-linux-0.7.28beta1-ppc64.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.28beta1/bedrock-linux-0.7.28beta1-ppc.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.28beta1/bedrock-linux-0.7.28beta1-mipsel.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.28beta1/bedrock-linux-0.7.28beta1-mips64el.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.28beta1/bedrock-linux-0.7.28beta1-mips.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.28beta1/bedrock-linux-0.7.28beta1-i686.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.28beta1/bedrock-linux-0.7.28beta1-i586.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.28beta1/bedrock-linux-0.7.28beta1-i486.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.28beta1/bedrock-linux-0.7.28beta1-i386.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.28beta1/bedrock-linux-0.7.28beta1-armv7l.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.28beta1/bedrock-linux-0.7.28beta1-armv7hl.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.28beta1/bedrock-linux-0.7.28beta1-aarch64.sh
#################
# Past releases #
#################
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.27/bedrock-linux-0.7.27-x86_64.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.27/bedrock-linux-0.7.27-s390x.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.27/bedrock-linux-0.7.27-ppc64le.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.27/bedrock-linux-0.7.27-ppc64.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.27/bedrock-linux-0.7.27-ppc.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.27/bedrock-linux-0.7.27-mipsel.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.27/bedrock-linux-0.7.27-mips64el.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.27/bedrock-linux-0.7.27-mips.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.27/bedrock-linux-0.7.27-i686.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.27/bedrock-linux-0.7.27-i586.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.27/bedrock-linux-0.7.27-i486.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.27/bedrock-linux-0.7.27-i386.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.27/bedrock-linux-0.7.27-armv7l.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.27/bedrock-linux-0.7.27-armv7hl.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.27/bedrock-linux-0.7.27-aarch64.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.26/bedrock-linux-0.7.26-x86_64.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.26/bedrock-linux-0.7.26-s390x.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.26/bedrock-linux-0.7.26-ppc64le.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.26/bedrock-linux-0.7.26-ppc64.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.26/bedrock-linux-0.7.26-ppc.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.26/bedrock-linux-0.7.26-mipsel.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.26/bedrock-linux-0.7.26-mips64el.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.26/bedrock-linux-0.7.26-mips.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.26/bedrock-linux-0.7.26-i686.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.26/bedrock-linux-0.7.26-i586.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.26/bedrock-linux-0.7.26-i486.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.26/bedrock-linux-0.7.26-i386.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.26/bedrock-linux-0.7.26-armv7l.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.26/bedrock-linux-0.7.26-armv7hl.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.26/bedrock-linux-0.7.26-aarch64.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.25/bedrock-linux-0.7.25-x86_64.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.25/bedrock-linux-0.7.25-s390x.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.25/bedrock-linux-0.7.25-ppc64le.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.25/bedrock-linux-0.7.25-ppc64.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.25/bedrock-linux-0.7.25-ppc.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.25/bedrock-linux-0.7.25-mipsel.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.25/bedrock-linux-0.7.25-mips64el.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.25/bedrock-linux-0.7.25-mips.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.25/bedrock-linux-0.7.25-i686.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.25/bedrock-linux-0.7.25-i586.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.25/bedrock-linux-0.7.25-i486.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.25/bedrock-linux-0.7.25-i386.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.25/bedrock-linux-0.7.25-armv7l.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.25/bedrock-linux-0.7.25-armv7hl.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.25/bedrock-linux-0.7.25-aarch64.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.24/bedrock-linux-0.7.24-x86_64.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.24/bedrock-linux-0.7.24-s390x.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.24/bedrock-linux-0.7.24-ppc64le.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.24/bedrock-linux-0.7.24-ppc64.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.24/bedrock-linux-0.7.24-ppc.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.24/bedrock-linux-0.7.24-mipsel.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.24/bedrock-linux-0.7.24-mips64el.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.24/bedrock-linux-0.7.24-mips.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.24/bedrock-linux-0.7.24-i686.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.24/bedrock-linux-0.7.24-i586.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.24/bedrock-linux-0.7.24-i486.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.24/bedrock-linux-0.7.24-i386.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.24/bedrock-linux-0.7.24-armv7l.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.24/bedrock-linux-0.7.24-armv7hl.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.24/bedrock-linux-0.7.24-aarch64.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.23/bedrock-linux-0.7.23-x86_64.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.23/bedrock-linux-0.7.23-s390x.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.23/bedrock-linux-0.7.23-ppc64le.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.23/bedrock-linux-0.7.23-ppc64.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.23/bedrock-linux-0.7.23-ppc.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.23/bedrock-linux-0.7.23-mipsel.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.23/bedrock-linux-0.7.23-mips64el.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.23/bedrock-linux-0.7.23-mips.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.23/bedrock-linux-0.7.23-i686.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.23/bedrock-linux-0.7.23-i586.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.23/bedrock-linux-0.7.23-i486.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.23/bedrock-linux-0.7.23-i386.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.23/bedrock-linux-0.7.23-armv7l.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.23/bedrock-linux-0.7.23-armv7hl.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.23/bedrock-linux-0.7.23-aarch64.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.22/bedrock-linux-0.7.22-x86_64.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.22/bedrock-linux-0.7.22-s390x.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.22/bedrock-linux-0.7.22-ppc64le.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.22/bedrock-linux-0.7.22-ppc64.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.22/bedrock-linux-0.7.22-ppc.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.22/bedrock-linux-0.7.22-mipsel.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.22/bedrock-linux-0.7.22-mips64el.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.22/bedrock-linux-0.7.22-mips.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.22/bedrock-linux-0.7.22-i686.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.22/bedrock-linux-0.7.22-i586.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.22/bedrock-linux-0.7.22-i486.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.22/bedrock-linux-0.7.22-i386.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.22/bedrock-linux-0.7.22-armv7l.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.22/bedrock-linux-0.7.22-armv7hl.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.22/bedrock-linux-0.7.22-aarch64.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.21/bedrock-linux-0.7.21-x86_64.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.21/bedrock-linux-0.7.21-s390x.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.21/bedrock-linux-0.7.21-ppc64le.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.21/bedrock-linux-0.7.21-ppc64.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.21/bedrock-linux-0.7.21-ppc.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.21/bedrock-linux-0.7.21-mipsel.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.21/bedrock-linux-0.7.21-mips64el.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.21/bedrock-linux-0.7.21-mips.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.21/bedrock-linux-0.7.21-i686.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.21/bedrock-linux-0.7.21-i586.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.21/bedrock-linux-0.7.21-i486.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.21/bedrock-linux-0.7.21-i386.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.21/bedrock-linux-0.7.21-armv7l.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.21/bedrock-linux-0.7.21-armv7hl.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.21/bedrock-linux-0.7.21-aarch64.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.20/bedrock-linux-0.7.20-x86_64.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.20/bedrock-linux-0.7.20-s390x.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.20/bedrock-linux-0.7.20-ppc64le.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.20/bedrock-linux-0.7.20-ppc64.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.20/bedrock-linux-0.7.20-ppc.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.20/bedrock-linux-0.7.20-mipsel.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.20/bedrock-linux-0.7.20-mips64el.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.20/bedrock-linux-0.7.20-mips.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.20/bedrock-linux-0.7.20-i686.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.20/bedrock-linux-0.7.20-i586.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.20/bedrock-linux-0.7.20-i486.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.20/bedrock-linux-0.7.20-i386.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.20/bedrock-linux-0.7.20-armv7l.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.20/bedrock-linux-0.7.20-armv7hl.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.20/bedrock-linux-0.7.20-aarch64.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.19/bedrock-linux-0.7.19-x86_64.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.19/bedrock-linux-0.7.19-s390x.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.19/bedrock-linux-0.7.19-ppc64le.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.19/bedrock-linux-0.7.19-ppc64.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.19/bedrock-linux-0.7.19-ppc.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.19/bedrock-linux-0.7.19-mipsel.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.19/bedrock-linux-0.7.19-mips64el.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.19/bedrock-linux-0.7.19-mips.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.19/bedrock-linux-0.7.19-i686.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.19/bedrock-linux-0.7.19-i586.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.19/bedrock-linux-0.7.19-i486.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.19/bedrock-linux-0.7.19-i386.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.19/bedrock-linux-0.7.19-armv7l.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.19/bedrock-linux-0.7.19-armv7hl.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.19/bedrock-linux-0.7.19-aarch64.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.18/bedrock-linux-0.7.18-x86_64.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.18/bedrock-linux-0.7.18-s390x.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.18/bedrock-linux-0.7.18-ppc64le.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.18/bedrock-linux-0.7.18-ppc64.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.18/bedrock-linux-0.7.18-ppc.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.18/bedrock-linux-0.7.18-mipsel.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.18/bedrock-linux-0.7.18-mips64el.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.18/bedrock-linux-0.7.18-mips.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.18/bedrock-linux-0.7.18-i686.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.18/bedrock-linux-0.7.18-i586.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.18/bedrock-linux-0.7.18-i486.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.18/bedrock-linux-0.7.18-i386.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.18/bedrock-linux-0.7.18-armv7l.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.18/bedrock-linux-0.7.18-armv7hl.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.18/bedrock-linux-0.7.18-aarch64.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.17/bedrock-linux-0.7.17-x86_64.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.17/bedrock-linux-0.7.17-s390x.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.17/bedrock-linux-0.7.17-ppc64le.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.17/bedrock-linux-0.7.17-ppc64.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.17/bedrock-linux-0.7.17-ppc.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.17/bedrock-linux-0.7.17-mipsel.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.17/bedrock-linux-0.7.17-mips64el.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.17/bedrock-linux-0.7.17-mips.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.17/bedrock-linux-0.7.17-i686.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.17/bedrock-linux-0.7.17-i586.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.17/bedrock-linux-0.7.17-i486.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.17/bedrock-linux-0.7.17-i386.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.17/bedrock-linux-0.7.17-armv7l.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.17/bedrock-linux-0.7.17-armv7hl.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.17/bedrock-linux-0.7.17-aarch64.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.16/bedrock-linux-0.7.16-x86_64.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.16/bedrock-linux-0.7.16-s390x.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.16/bedrock-linux-0.7.16-ppc64le.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.16/bedrock-linux-0.7.16-ppc64.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.16/bedrock-linux-0.7.16-ppc.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.16/bedrock-linux-0.7.16-mipsel.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.16/bedrock-linux-0.7.16-mips64el.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.16/bedrock-linux-0.7.16-mips.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.16/bedrock-linux-0.7.16-i686.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.16/bedrock-linux-0.7.16-i586.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.16/bedrock-linux-0.7.16-i486.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.16/bedrock-linux-0.7.16-i386.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.16/bedrock-linux-0.7.16-armv7l.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.16/bedrock-linux-0.7.16-armv7hl.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.16/bedrock-linux-0.7.16-aarch64.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.15/bedrock-linux-0.7.15-x86_64.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.15/bedrock-linux-0.7.15-s390x.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.15/bedrock-linux-0.7.15-ppc64le.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.15/bedrock-linux-0.7.15-ppc64.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.15/bedrock-linux-0.7.15-ppc.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.15/bedrock-linux-0.7.15-mipsel.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.15/bedrock-linux-0.7.15-mips64el.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.15/bedrock-linux-0.7.15-mips.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.15/bedrock-linux-0.7.15-i686.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.15/bedrock-linux-0.7.15-i586.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.15/bedrock-linux-0.7.15-i486.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.15/bedrock-linux-0.7.15-i386.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.15/bedrock-linux-0.7.15-armv7l.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.15/bedrock-linux-0.7.15-armv7hl.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.15/bedrock-linux-0.7.15-aarch64.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.14/bedrock-linux-0.7.14-x86_64.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.14/bedrock-linux-0.7.14-s390x.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.14/bedrock-linux-0.7.14-ppc64le.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.14/bedrock-linux-0.7.14-ppc64.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.14/bedrock-linux-0.7.14-ppc.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.14/bedrock-linux-0.7.14-mipsel.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.14/bedrock-linux-0.7.14-mips64el.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.14/bedrock-linux-0.7.14-mips.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.14/bedrock-linux-0.7.14-i686.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.14/bedrock-linux-0.7.14-i586.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.14/bedrock-linux-0.7.14-i486.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.14/bedrock-linux-0.7.14-i386.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.14/bedrock-linux-0.7.14-armv7l.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.14/bedrock-linux-0.7.14-armv7hl.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.14/bedrock-linux-0.7.14-aarch64.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.13/bedrock-linux-0.7.13-x86_64.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.13/bedrock-linux-0.7.13-s390x.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.13/bedrock-linux-0.7.13-ppc64le.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.13/bedrock-linux-0.7.13-mipsel.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.13/bedrock-linux-0.7.13-mips64el.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.13/bedrock-linux-0.7.13-mips.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.13/bedrock-linux-0.7.13-i686.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.13/bedrock-linux-0.7.13-i586.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.13/bedrock-linux-0.7.13-i486.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.13/bedrock-linux-0.7.13-i386.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.13/bedrock-linux-0.7.13-armv7l.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.13/bedrock-linux-0.7.13-armv7hl.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.13/bedrock-linux-0.7.13-aarch64.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.12/bedrock-linux-0.7.12-x86_64.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.12/bedrock-linux-0.7.12-s390x.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.12/bedrock-linux-0.7.12-ppc64le.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.12/bedrock-linux-0.7.12-mipsel.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.12/bedrock-linux-0.7.12-mips64el.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.12/bedrock-linux-0.7.12-mips.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.12/bedrock-linux-0.7.12-i686.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.12/bedrock-linux-0.7.12-i586.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.12/bedrock-linux-0.7.12-i486.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.12/bedrock-linux-0.7.12-i386.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.12/bedrock-linux-0.7.12-armv7l.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.12/bedrock-linux-0.7.12-armv7hl.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.12/bedrock-linux-0.7.12-aarch64.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.11/bedrock-linux-0.7.11-x86_64.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.11/bedrock-linux-0.7.11-s390x.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.11/bedrock-linux-0.7.11-ppc64le.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.11/bedrock-linux-0.7.11-mipsel.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.11/bedrock-linux-0.7.11-mips64el.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.11/bedrock-linux-0.7.11-mips.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.11/bedrock-linux-0.7.11-i686.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.11/bedrock-linux-0.7.11-i586.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.11/bedrock-linux-0.7.11-i486.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.11/bedrock-linux-0.7.11-i386.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.11/bedrock-linux-0.7.11-armv7l.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.11/bedrock-linux-0.7.11-armv7hl.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.11/bedrock-linux-0.7.11-aarch64.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.10/bedrock-linux-0.7.10-x86_64.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.10/bedrock-linux-0.7.10-s390x.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.10/bedrock-linux-0.7.10-ppc64le.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.10/bedrock-linux-0.7.10-mipsel.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.10/bedrock-linux-0.7.10-mips64el.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.10/bedrock-linux-0.7.10-mips.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.10/bedrock-linux-0.7.10-i686.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.10/bedrock-linux-0.7.10-i586.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.10/bedrock-linux-0.7.10-i486.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.10/bedrock-linux-0.7.10-i386.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.10/bedrock-linux-0.7.10-armv7l.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.10/bedrock-linux-0.7.10-armv7hl.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.10/bedrock-linux-0.7.10-aarch64.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.9/bedrock-linux-0.7.9-x86_64.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.9/bedrock-linux-0.7.9-s390x.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.9/bedrock-linux-0.7.9-ppc64le.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.9/bedrock-linux-0.7.9-mipsel.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.9/bedrock-linux-0.7.9-mips64el.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.9/bedrock-linux-0.7.9-mips.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.9/bedrock-linux-0.7.9-i686.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.9/bedrock-linux-0.7.9-i586.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.9/bedrock-linux-0.7.9-i486.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.9/bedrock-linux-0.7.9-i386.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.9/bedrock-linux-0.7.9-armv7l.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.9/bedrock-linux-0.7.9-armv7hl.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.9/bedrock-linux-0.7.9-aarch64.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.8/bedrock-linux-0.7.8-x86_64.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.8/bedrock-linux-0.7.8-s390x.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.8/bedrock-linux-0.7.8-ppc64le.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.8/bedrock-linux-0.7.8-mipsel.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.8/bedrock-linux-0.7.8-mips64el.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.8/bedrock-linux-0.7.8-mips.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.8/bedrock-linux-0.7.8-i686.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.8/bedrock-linux-0.7.8-i586.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.8/bedrock-linux-0.7.8-i486.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.8/bedrock-linux-0.7.8-i386.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.8/bedrock-linux-0.7.8-armv7l.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.8/bedrock-linux-0.7.8-armv7hl.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.8/bedrock-linux-0.7.8-aarch64.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.7/bedrock-linux-0.7.7-x86_64.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.7/bedrock-linux-0.7.7-s390x.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.7/bedrock-linux-0.7.7-ppc64le.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.7/bedrock-linux-0.7.7-mipsel.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.7/bedrock-linux-0.7.7-mips64el.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.7/bedrock-linux-0.7.7-mips.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.7/bedrock-linux-0.7.7-armv7l.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.7/bedrock-linux-0.7.7-armv7hl.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.7/bedrock-linux-0.7.7-aarch64.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.6/bedrock-linux-0.7.6-x86_64.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.6/bedrock-linux-0.7.6-s390x.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.6/bedrock-linux-0.7.6-mipsel.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.6/bedrock-linux-0.7.6-mips64el.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.6/bedrock-linux-0.7.6-mips.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.6/bedrock-linux-0.7.6-armv7l.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.6/bedrock-linux-0.7.6-armv7hl.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.6/bedrock-linux-0.7.6-aarch64.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.5/bedrock-linux-0.7.5-x86_64.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.5/bedrock-linux-0.7.5-armv7l.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.4/bedrock-linux-0.7.4-x86_64.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.4/bedrock-linux-0.7.4-armv7l.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.3/bedrock-linux-0.7.3-x86_64.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.3/bedrock-linux-0.7.3-armv7l.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.2/bedrock-linux-0.7.2-x86_64.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.2/bedrock-linux-0.7.2-armv7l.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.1/bedrock-linux-0.7.1-x86_64.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.1/bedrock-linux-0.7.1-armv7l.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.0/bedrock-linux-0.7.0-x86_64.sh
https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.0/bedrock-linux-0.7.0-armv7l.sh

22
src/bouncer/Makefile Normal file
View File

@ -0,0 +1,22 @@
# bouncer makefile
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# version 2 as published by the Free Software Foundation.
#
# Copyright (c) 2017-2018 Daniel Thau <danthau@bedrocklinux.org>
all: bouncer
strat:
$(CC) $(CFLAGS) -std=c99 bouncer.c -o bouncer
clean:
rm -f bouncer
install:
mkdir -p $(prefix)/bin
install -m 755 strat $(prefix)/bin/bouncer
uninstall:
rm -f $(prefix)/bin/bouncer

40
src/bouncer/README.md Normal file
View File

@ -0,0 +1,40 @@
bouncer
=======
bouncer redirects calls to another executable based on the following xattrs as
set on the bouncer executable:
- `user.bedrock.stratum` indicates the stratum which should provide the
executable
- `user.bedrock.localpath` indicates stratum-local path of the desired
executable
bouncer passes its arg0 to the executable it is calling. This is in contrast
to a hashbang file such as:
#!/bin/sh
exec strat <stratum> <local-path>
which would lose its argv[0].
Installation
------------
Bedrock Linux should be distributed with a script which handles installation,
but just in case:
To compile, run
make
To install into installdir, run
make prefix=<installdir> install
To clean up, like usual:
make clean
And finally, to remove it, run:
make prefix=<installdir> uninstall

115
src/bouncer/bouncer.c Normal file
View File

@ -0,0 +1,115 @@
/*
* bouncer.c
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* version 2 as published by the Free Software Foundation.
*
* Copyright (c) 2017-2019 Daniel Thau <danthau@bedrocklinux.org>
*
* This program redirects to the specified executable in the specified stratum
* via strat. The appropriate stratum and executable are determined by the
* 'user.bedrock_stratum' and 'user.bedrock_localpath' xattrs on
* /proc/self/exe.
*
* This is preferable to a script such as
*
* #!/bin/sh
* exec strat <stratum> <local-path> $@
*
* as it can pass its own argv[0] where as a hashbang loses this information.
*/
#include <errno.h>
#include <limits.h>
#include <linux/limits.h>
#include <stdio.h>
#include <sys/xattr.h>
#include <unistd.h>
int main(int argc, char *argv[])
{
/*
* Which stratum do we want to be in?
*/
char target_stratum[PATH_MAX];
ssize_t len = getxattr("/proc/self/exe", "user.bedrock.stratum",
target_stratum, sizeof(target_stratum) - 1);
if (len < 0) {
fprintf(stderr, "bouncer: unable to determine target stratum\n");
return errno;
}
target_stratum[len] = '\0';
/*
* Which executable do we want to run?
*/
char target_path[PATH_MAX];
len = getxattr("/proc/self/exe", "user.bedrock.localpath", target_path, sizeof(target_path) - 1);
if (len < 0) {
fprintf(stderr, "bouncer: unable to determine target path\n");
return errno;
}
target_path[len] = '\0';
/*
* Do we want to restrict the process to its own stratum?
*/
int restrict_flag = 0;
char target_restrict[PATH_MAX];
len = getxattr("/proc/self/exe", "user.bedrock.restrict", target_restrict, sizeof(target_restrict) - 1);
if (len >= 0) {
restrict_flag = 1;
}
char *strat = "/bedrock/bin/strat";
/*
* Example:
*
* incoming: apt install foo bar baz -- (argc does not count NULL)
* \ \ \ \ \___________________________________________________
* \ \ \ \___________________________________________________ \
* \ \ \___________________________________________________ \ \
* \ \__________________________________________________ \ \ \
* \___________________ \ \ \ \
* \ \ \ \ \
* outgoing: /bedrock/bin/strat --arg0 apt --restrict debian /usr/bin/apt install foo bar baz NULL
* /bedrock/bin/strat --arg0 apt --restrict debian /usr/bin/apt install foo bar baz NULL
* \ \ \ \ \ \
* \- 1 \- 2 \- 3 \- 4 \- 5 \- 6
*
* Potentially need 6 more than argc.
*/
char *new_argv[argc + 6];
new_argv[0] = strat;
new_argv[1] = "--arg0";
new_argv[2] = argv[0];
if (restrict_flag) {
new_argv[3] = "--restrict";
}
new_argv[3 + restrict_flag] = target_stratum;
new_argv[4 + restrict_flag] = target_path;
/* start at 1 to skip argv[0] which was already consumed above */
for (int i = 1; i < argc; i++) {
new_argv[i + 4 + restrict_flag] = argv[i];
}
new_argv[argc + 4 + restrict_flag] = NULL;
execv(strat, new_argv);
fprintf(stderr, "bouncer: could not execute\n %s\n", strat);
switch (errno) {
case EACCES:
fprintf(stderr, "due to: permission denied (EACCES).\n");
break;
case ENOENT:
fprintf(stderr, "due to: unable to find file (ENOENT).\n");
break;
default:
perror("due to: execv:\n");
break;
}
return 1;
}

22
src/crossfs/Makefile Normal file
View File

@ -0,0 +1,22 @@
# crossfs makefile
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# version 2 as published by the Free Software Foundation.
#
# Copyright (c) 2014-2018 Daniel Thau <danthau@bedrocklinux.org>
all: crossfs
crossfs: crossfs.c
$(CC) $(CFLAGS) -std=c99 -D_FILE_OFFSET_BITS=64 crossfs.c -o crossfs -lfuse3 -lpthread
clean:
rm -f crossfs
install:
mkdir -p $(prefix)/sbin
install -m 755 crossfs $(prefix)/sbin/crossfs
uninstall:
rm -f $(prefix)/sbin/crossfs

44
src/crossfs/README.md Normal file
View File

@ -0,0 +1,44 @@
crossfs
=======
crossfs is a virtual filesystem which dynamically populates a specified
directory with content from other strata, modified as necessary so the files
are consumable across strata. For example, it wraps binary executables so that
they are implicit run through strat to the appropriate stratum.
crossfs takes the typical libfuse arguments such as `-o allow_other` and `-f`.
See libfuse for details.
Configuration
-------------
crossfs creates a virtual `.bedrock-config-filesystem` file in the root of its
mount point to handle its configuration. `.bedrock-config-filesystem` may be
read to get the current configuration and is written to by `brl reload`.
Installation
------------
Bedrock Linux should be distributed with a script which handles installation,
but just in case:
The dependencies are:
- libfuse
- uthash
To compile, run
make
To install into installdir, run
make prefix=<installdir> install
To clean up, like usual:
make clean
And finally, to remove it, run:
make prefix=<installdir> uninstall

2410
src/crossfs/crossfs.c Normal file

File diff suppressed because it is too large Load Diff

22
src/etcfs/Makefile Normal file
View File

@ -0,0 +1,22 @@
# etcfs makefile
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# version 2 as published by the Free Software Foundation.
#
# Copyright (c) 2013-2018 Daniel Thau <danthau@bedrocklinux.org>
all: etcfs
etcfs: etcfs.c
$(CC) $(CFLAGS) -std=c99 -D_FILE_OFFSET_BITS=64 etcfs.c -o etcfs -lfuse3 -lpthread
clean:
rm -f etcfs
install:
mkdir -p $(prefix)/sbin
install -m 755 etcfs $(prefix)/sbin/etcfs
uninstall:
rm -f $(prefix)/sbin/etcfs

40
src/etcfs/README.md Normal file
View File

@ -0,0 +1,40 @@
etcfs
=====
etcfs is a virtual filesystem which redirects file access to either the global
stratum's instance of a file, or the calling process' local stratum instance of
a file. It may also modify files as needed to enforce specific file content,
such as configuration file values.
Configuration
-------------
etcfs creates a virtual `.bedrock-config-filesystem` file in the root of its
mount point to handle its configuration. `.bedrock-config-filesystem` may be
read to get the current configuration and is written to by `brl reload`.
Installation
------------
Bedrock Linux should be distributed with a script which handles installation,
but just in case:
The dependencies are:
- libfuse
To compile, run
make
To install into installdir, run
make prefix=<installdir> install
To clean up, like usual:
make clean
And finally, to remove it, run:
make prefix=<installdir> uninstall

2220
src/etcfs/etcfs.c Normal file

File diff suppressed because it is too large Load Diff

475
src/init/init Executable file
View File

@ -0,0 +1,475 @@
#!/bedrock/libexec/busybox sh
#
# init
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# version 2 as published by the Free Software Foundation.
#
# Copyright (c) 2014-2019 Daniel Thau <danthau@bedrocklinux.org>
#
# Bedrock Linux meta-init system
. /bedrock/share/common-code
# Remove typical runtime sanity checks, as crashing during init is going to
# just cause difficult to debug headaches for most users.
set +eu
trap '' EXIT
fatal_error() {
echo ""
printf "${color_alert}${*}${color_norm}\\n"
echo ""
echo "Starting emergency shell"
echo "Good luck"
echo ""
exec sh
}
setup_term() {
# Ensure plymouth is not running, as it will fight with us over control
# of the terminal.
/bedrock/libexec/plymouth-quit
# Plymouth will lock the terminal settings. This causes the following
# commands to fail if not unlocked.
/bedrock/libexec/manage_tty_lock unlock
# Ensure sane terminal settings. This is probably overkill.
reset
stty sane
stty cooked
reset
}
ensure_essential_environment() {
if ! [ -r /proc/mounts ] || ! grep -q "^\\w* /proc proc" /proc/mounts 2>&1 | head -n0; then
mkdir -p /proc
mount -t proc proc /proc
fi
mount -o remount,rw / 2>&1 | head -n0
if ! grep -q "^\\w* /sys sysfs" /proc/mounts; then
mkdir -p /sys
mount -t sysfs sysfs /sys
fi
if ! grep -q "^\\w* /dev devtmpfs" /proc/mounts; then
mkdir -p /dev
mount -t devtmpfs devtmpfs /dev
mdev -s
fi
if ! grep -q "^\\w* /dev/pts devpts" /proc/mounts; then
mkdir -p /dev/pts
mount -t devpts devpts /dev/pts
fi
if ! grep -q "^\\w* /run tmpfs" /proc/mounts; then
mkdir -p /run
mount -t tmpfs tmpfs /run
fi
# If the user runs a non-zstd-aware depmod with a zstd-based module
# set, it may clear modules.dep. If so, fix modules.dep.
if [ -e /lib/modules/$(uname -r)/modules.dep ] && \
[ "$(stat -c%s "/lib/modules/$(uname -r)/modules.dep")" -eq 0 ]; then
printf "Regenerating modules.dep... "
/sbin/depmod
echo "done"
fi
if ! grep -q "\\<fuse\\>" /proc/filesystems; then
/sbin/modprobe fuse
fi
if ! [ -e /dev/fuse ]; then
mkdir -p /dev
mknod -m 660 /dev/fuse c 10 229
fi
if ! grep -q "\\<binfmt_misc\\>" /proc/filesystems; then
/sbin/modprobe binfmt_misc >/dev/null 2>&1 || true
fi
# Systemd seems confused when an initrd-systemd launches Bedrock's init
# which launches userland-systemd. Kill /run/systemd to break the
# relationship so systemd thinks it is starting fresh.
if [ -d /run/systemd ]; then
rm -r /run/systemd
fi
# Some networking software make /etc/resolv.conf into a symlink. Other
# networking software seems confused by this. This can cause problems
# when switching init-providing strata (and thus their networking
# stacks) during a reboot. To avoid this, remove /etc/resolv.conf
# symlinks here. Network software should re-recreate this file as
# needed.
if [ -h /etc/resolv.conf ]; then
rm /etc/resolv.conf
fi
}
complete_hijack() {
step_init "6"
notice "Completing ${color_term}hijack install${color_norm}"
hijacked="$(deref hijacked)"
step "Moving ${color_strat}${hijacked}${color_norm} files to ${color_file}/bedrock/strata/${hijacked}${color_norm}"
mkdir -p "/bedrock/strata/${hijacked}"
set_attr "/bedrock/strata/${hijacked}" "stratum" "${hijacked}"
cd /
for item in *; do
case "${item}" in
"proc" | "sys" | "dev" | "run" | "boot" | bedrock*)
continue
;;
esac
mv "${item}" "/bedrock/strata/${hijacked}/${item}"
done
step "Moving ${color_strat}global${color_norm} items to ${color_file}/${color_norm}"
set_attr "/" "stratum" "bedrock"
for global in $(cfg_values "global" "share") $(cfg_values "global" "bind"); do
case "${global}" in
"/proc" | "/sys" | "/dev" | "/run" | "/boot" | /bedrock*)
continue
;;
esac
if [ -e "/bedrock/strata/${hijacked}${global}" ] ||
[ -h "/bedrock/strata/${hijacked}${global}" ]; then
mkdir -p "$(dirname "${global}")"
mv "/bedrock/strata/${hijacked}${global}" "${global}"
mkdir -p "/bedrock/strata/${hijacked}${global}"
else
mkdir -p "${global}"
fi
done
for global in $(cfg_values "global" "etc"); do
mkdir -p "$(dirname "/etc/${global}")"
if [ -e "/bedrock/strata/${hijacked}/etc/${global}" ] ||
[ -h "/bedrock/strata/${hijacked}/etc/${global}" ]; then
mv "/bedrock/strata/${hijacked}/etc/${global}" "/etc/${global}"
fi
done
step "Creating root files and directories"
for dir in /bin /dev /etc /lib/systemd /mnt /proc /root /run /sbin /sys /tmp /usr/bin /usr/sbin /usr/share/info /var; do
mkdir -p "${dir}"
done
ln -s ../bedrock/etc/bedrock-release /etc/bedrock-release
ln -s ../bedrock/etc/os-release /etc/os-release
ln -s /bedrock/libexec/kmod /sbin/depmod
ln -s /bedrock/libexec/kmod /sbin/insmod
ln -s /bedrock/libexec/kmod /sbin/lsmod
ln -s /bedrock/libexec/kmod /sbin/modinfo
ln -s /bedrock/libexec/kmod /sbin/modprobe
ln -s /bedrock/libexec/kmod /sbin/rmmod
ln -s /bedrock/strata/hijacked/usr/share/grub /usr/share/grub
/bedrock/libexec/busybox --install -s
touch /usr/share/info/.keepinfodir
mv "/bedrock/strata/${hijacked}/sbin/init" "/sbin/init"
step "Restoring ${color_term}hijacked${color_norm} init systems"
prefix="/bedrock/strata/${hijacked}"
for init in /bin/init /sbin/init /usr/bin/init /usr/sbin/init /lib/systemd/systemd /usr/lib/systemd/systemd; do
if [ -h "${prefix}${init}-bedrock-backup" ] || [ -e "${prefix}${init}-bedrock-backup" ]; then
mv "${prefix}${init}-bedrock-backup" "${prefix}${init}"
fi
done
step "Granting ${color_cmd}strat${color_norm} necessary capabilities"
/bedrock/libexec/setcap cap_sys_chroot=ep /bedrock/bin/strat
step "Completing ${color_term}hijack install${color_norm}"
rm /bedrock/complete-hijack-install
echo ""
}
complete_upgrade() {
# All crossfs builds prior to 0.7.8 became confused if bouncer changed
# out from under them. If upgrading such a version, bouncer was not
# upgraded in-place. Complete the upgrade now while crossfs is not
# running.
if [ -e /bedrock/libexec/bouncer-0.7.9 ]; then
mv /bedrock/libexec/bouncer-0.7.9 /bedrock/libexec/bouncer
fi
}
wait_for_keyboard() {
# Users with keyboards that take a while to initialize have reported
# surprise at the inability to type in the init selection menu.
# Vocally wait for a keyboard to be available to assuage these
# concerns.
for module in $(cfg_values "init" "modules"); do
/sbin/modprobe "${module}" 2>/dev/null
done
if /bedrock/libexec/keyboard_is_present; then
return
fi
printf "Waiting up to %s seconds for keyboard initialization..." "${init_timeout}"
start="$(date +%s)"
end="$((init_timeout + start))"
while [ "$(date +%s)" -lt "${end}" ] && ! /bedrock/libexec/keyboard_is_present; do
usleep 250000 # quarter second
done
printf "\r"
printf "Waiting up to %s seconds for keyboard initialization..." "${init_timeout}" | sed 's/./ /g'
printf "\r"
if ! /bedrock/libexec/keyboard_is_present; then
notice "${color_warn}WARNING: unable to detect keyboard${color_norm}"
fi
}
list_init_options() {
for stratum in $(list_strata); do
if [ "${stratum}" = "bedrock" ]; then
continue
fi
if ! has_attr "/bedrock/strata/${stratum}" "show_init"; then
continue
fi
for cmd in $(cfg_values "init" "paths"); do
sproc="/bedrock/strata/${stratum}/proc"
mkdir -p "${sproc}" 2>/dev/null || true
mount -t proc proc "${sproc}"
link="$(chroot "/bedrock/strata/${stratum}" "/proc/1/root/bedrock/libexec/busybox" realpath "${cmd}" 2>/dev/null)" || true
path="/bedrock/strata/${stratum}${link}"
if [ -n "${link:-}" ] && [ -x "${path}" ]; then
echo "${stratum} ${path} ${cmd} ${link}"
fi
umount "${sproc}"
done
done | awk '
{
if (!($2 in cmds)) {
cmds[$2] = $0
next
}
split($0, a)
if (a[3] == a[4] && $3 != $4) {
cmds[$2] = $0
}
}
END {
for (i in cmds) {
print cmds[i]
}
}
' | sort | uniq
}
pretty_print_options() {
i=0
IFS="
"
for option in $(list_init_options); do
i=$((i + 1))
stratum="$(echo "${option}" | cut -d" " -f1)"
path="$(echo "${option}" | cut -d" " -f2)"
cmd="$(echo "${option}" | cut -d" " -f3)"
link="$(echo "${option}" | cut -d" " -f4)"
if [ "${path}" = "${def_path}" ]; then
star="${color_glue}*${color_norm}"
else
star=" "
fi
if [ "${cmd}" != "${link}" ]; then
res="${color_glue} -> ${color_cmd}${link}"
else
res=""
fi
printf "${star}${color_sub}%2s${color_norm}. ${color_strat}${stratum}${color_glue}:${color_cmd}${cmd}${res}${color_norm}\\n" "${i}"
done
}
get_init_choice() {
echo "Select init number to use for this session" >&2
echo "See /bedrock/etc/bedrock.conf [init] to change default init and timeout" >&2
echo "" >&2
max="$(list_init_options | wc -l)"
wait_for_keyboard >&2
while true; do
pretty_print_options >&2
printf "\\nInit number: " >&2
if [ "${init_timeout}" -eq 0 ] && [ -n "${def_path}" ] && [ -x "${def_path}" ]; then
selected_num=0
elif [ "${init_timeout}" -gt 0 ] && [ -n "${def_path}" ] && [ -x "${def_path}" ]; then
printf "(${color_sub}${init_timeout}s${color_norm}): " >&2
read -r -t "${init_timeout}" selected_num
else
read -r selected_num
fi
if [ -z "${selected_num}" ]; then
selected_num=0
fi
if [ -n "${def_path}" ] && [ -x "${def_path}" ] && [ "${selected_num}" -eq 0 ]; then
echo "${def_stratum}:${def_cmd}"
return
elif echo "${selected_num}" | grep -q "[^0-9]"; then
true
elif [ "${selected_num}" -gt "${max}" ]; then
true
elif [ "${selected_num}" -gt 0 ]; then
list_init_options | awk -v"n=${selected_num}" 'NR==n {print $1":"$3}'
return
fi
printf "${color_alert}Unrecognized choice, try again.${color_norm}\\n" >&2
done
}
pivot() {
# Can only pivot_root with mount points. Ensure init_stratum root is a mount point.
mount --bind "/bedrock/strata/${init_stratum}" "/bedrock/strata/${init_stratum}"
# Ensure /bedrock is in the stratum so we can continue to utilize it post pivot
mkdir -p "/bedrock/strata/${init_stratum}/bedrock"
mount --bind "/bedrock" "/bedrock/strata/${init_stratum}/bedrock"
# Pivot
cd "/bedrock/strata/${init_stratum}"
pivot_root "." "bedrock/strata/${init_stratum}"
cd /
mount --move "/bedrock/strata/${init_stratum}" "/bedrock/strata/bedrock"
# `man 8 pivot_root` says to `chroot .` here, but in practice this was
# found to make mount points inaccessible, and no problems were found when
# skipping this step.
}
preenable() {
# Preemptively share key directories that are needed to enable
mkdir -p "/bedrock/strata/bedrock/proc"
mount --make-shared "/bedrock/strata/bedrock/proc"
mkdir -p "/proc"
mount --rbind "/bedrock/strata/bedrock/proc" "/proc"
mkdir -p "/bedrock/strata/bedrock/dev"
mount --make-shared "/bedrock/strata/bedrock/dev"
mkdir -p "/dev"
mount --rbind "/bedrock/strata/bedrock/dev" "/dev"
mkdir -p "/bedrock/strata/bedrock/sys"
mount --make-shared "/bedrock/strata/bedrock/sys"
mkdir -p "/sys"
mount --rbind "/bedrock/strata/bedrock/sys" "/sys"
mkdir -p "/bedrock/strata/bedrock/bedrock/run"
mount -t tmpfs bedrock_run "/bedrock/strata/bedrock/bedrock/run"
chmod go-w "/bedrock/strata/bedrock/bedrock"
chmod go-w "/bedrock/strata/bedrock/bedrock/run"
mkdir -p "/bedrock/run"
mount --rbind "/bedrock/strata/bedrock/bedrock/run" "/bedrock/run"
ensure_essential_environment
}
if [ "${$}" -ne 1 ]; then
exec "/sbin/init-bedrock-backup" "${@}"
fi
ensure_essential_environment
setup_term
clear
print_logo "$(cat /bedrock/etc/bedrock-release)"
if [ -e "/bedrock/complete-hijack-install" ]; then
complete_hijack
fi
complete_upgrade
init_timeout="$(cfg_values "init" "timeout")"
def_tuple="$(cfg_values "init" "default")"
def_stratum="$(deref "$(echo "${def_tuple}" | cut -d: -f1)")"
def_cmd="$(echo "${def_tuple}" | cut -d: -f2-)"
def_path=""
if [ -n "${def_tuple}" ] && [ -d "/bedrock/strata/${def_stratum}" ]; then
sproc="/bedrock/strata/${def_stratum}/proc"
mkdir -p "${sproc}" 2>/dev/null || true
mount -t proc proc "${sproc}"
if def_link="$(chroot "/bedrock/strata/${def_stratum}" "/proc/1/root/bedrock/libexec/busybox" realpath "${def_cmd}" 2>/dev/null)"; then
def_path="/bedrock/strata/${def_stratum}${def_link}"
fi
umount "${sproc}"
fi
if [ -n "${def_tuple}" ] && [ -z "${def_path:-}" ]; then
notice "${color_warn}WARNING: ${color_file}/bedrock/etc/bedrock.conf [init]/default ${color_warn}value does not describe a valid stratum:init pair.${color_norm}"
fi
if [ -z "${def_path:-}" ]; then
init_timeout="-1"
def_stratum=""
def_cmd=""
def_link=""
def_path=""
fi
if ! init_tuple="$(grep -q '\<bedrock_init=' /proc/cmdline && sed -e 's/^.*bedrock_init=//' -e 's/[ \t].*$//' /proc/cmdline)"; then
init_tuple="$(get_init_choice)"
fi
init_stratum="$(echo "${init_tuple}" | cut -d: -f1)"
init_cmd="$(echo "${init_tuple}" | cut -d: -f2-)"
echo ""
step_init "6"
step "Mounting ${color_file}fstab${color_norm}"
/bedrock/libexec/dmsetup mknodes
/bedrock/libexec/lvm vgscan --ignorelockingfailure
/bedrock/libexec/lvm vgchange -ay --ignorelockingfailure
mount -a
step "Pivoting to ${color_strat}${init_stratum}${color_norm}"
pivot
step "Preparing to enable"
preenable
step "Enabling ${color_term}strata${color_norm}"
notice "Enabling ${color_strat}bedrock${color_norm}"
# Cannot brl-enable bedrock or init stratum, and cannot brl-repair disabled
# strata. Thus, manually set up minimum required to mark strata as enabled
# then run brl-repair on bedrock and init strata.
mkdir -p /bedrock/strata/bedrock/bedrock/run/enabled_strata
touch /bedrock/strata/bedrock/bedrock/run/enabled_strata/bedrock
ln -s "/bedrock/strata/${init_stratum}" "/bedrock/strata/bedrock/bedrock/run/init-alias"
touch "/bedrock/strata/bedrock/bedrock/run/enabled_strata/${init_stratum}"
/bedrock/libexec/brl-repair --skip-crossfs "bedrock"
notice "Enabling ${color_strat}${init_stratum}${color_norm}"
/bedrock/libexec/brl-repair --skip-crossfs "${init_stratum}"
for stratum in $(list_strata); do
if is_bedrock "${stratum}" ||
is_init "${stratum}" ||
! has_attr "/bedrock/strata/${stratum}" "show_boot"; then
continue
fi
notice "Enabling ${color_strat}${stratum}${color_norm}"
/bedrock/libexec/brl-enable --skip-crossfs "${stratum}"
done
step "Applying configuration"
/bedrock/libexec/brl-apply --skip-repair
step "Handing control off to ${color_strat}${init_stratum}${color_glue}:${color_cmd}${init_cmd}${color_norm}"
if ! [ -x "${init_cmd}" ]; then
fatal_error "Specified (${init_cmd}) is not executable"
fi
# Shellcheck warns about `exec` usage. It is explicitly desired here.
#
# shellcheck disable=SC2093
exec "${init_cmd}" "${@}"
# We should never get here.
# If exec above succeeds, that takes over.
# If exec above fails, we get a kernel panic.
fatal_error "Unable to execute ${init_stratum}:${init_cmd}"

580
src/installer/installer.sh Normal file
View File

@ -0,0 +1,580 @@
#!/bin/sh
#
# installer.sh
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# version 2 as published by the Free Software Foundation.
#
# Copyright (c) 2018-2022 Daniel Thau <danthau@bedrocklinux.org>
#
# Installs or updates a Bedrock Linux system.
. /bedrock/share/common-code # replace with file content during build process
ARCHITECTURE= # replace with build target CPU architecture during build process
TARBALL_SHA1SUM= # replace with tarball sha1sum during build process
print_help() {
printf "Usage: ${color_cmd}${0} ${color_sub}<operations>${color_norm}
Install or update a Bedrock Linux system.
Operations:
${color_cmd}--hijack ${color_sub}[name] ${color_norm}convert current installation to Bedrock Linux.
${color_priority}this operation is not intended to be reversible!${color_norm}
${color_norm}optionally specify initial ${color_term}stratum${color_norm} name.
${color_cmd}--update ${color_norm}update current Bedrock Linux system.
${color_cmd}--force-update ${color_norm}update current system, ignoring warnings.
${color_cmd}-h${color_norm}, ${color_cmd}--help ${color_norm}print this message
${color_norm}"
}
extract_tarball() {
# Many implementations of common UNIX utilities fail to properly handle
# null characters, severely restricting our options. The solution here
# assumes only one embedded file with nulls - here, the tarball - and
# will not scale to additional null-containing embedded files.
# Utilities that completely work with null across tested implementations:
#
# - cat
# - wc
#
# Utilities that work with caveats:
#
# - head, tail: only with direct `-n N`, no `-n +N`
# - sed: does not print lines with nulls correctly, but prints line
# count correctly.
lines_total="$(wc -l <"${0}")"
lines_before="$(sed -n "1,/^-----BEGIN TARBALL-----\$/p" "${0}" | wc -l)"
lines_after="$(sed -n "/^-----END TARBALL-----\$/,\$p" "${0}" | wc -l)"
lines_tarball="$((lines_total - lines_before - lines_after))"
# Since the tarball is a binary, it can end in a non-newline character.
# To ensure the END marker is on its own line, a newline is appended to
# the tarball. The `head -c -1` here strips it.
tail -n "$((lines_tarball + lines_after))" "${0}" | head -n "${lines_tarball}" | head -c -1 | gzip -d
}
sanity_check_grub_mkrelpath() {
if grub2-mkrelpath --help 2>&1 | grep -q "relative"; then
orig="$(grub2-mkrelpath --relative /boot)"
mount --bind /boot /boot
new="$(grub2-mkrelpath --relative /boot)"
umount -l /boot
[ "${orig}" = "${new}" ]
elif grub-mkrelpath --help 2>&1 | grep -q "relative"; then
orig="$(grub-mkrelpath --relative /boot)"
mount --bind /boot /boot
new="$(grub-mkrelpath --relative /boot)"
umount -l /boot
[ "${orig}" = "${new}" ]
fi
}
hijack() {
printf "\
${color_priority}* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *${color_norm}
${color_priority}*${color_alert} ${color_priority}*${color_norm}
${color_priority}*${color_alert} Continuing will: ${color_priority}*${color_norm}
${color_priority}*${color_alert} - Move the existing install to a temporary location ${color_priority}*${color_norm}
${color_priority}*${color_alert} - Install Bedrock Linux on the root of the filesystem ${color_priority}*${color_norm}
${color_priority}*${color_alert} - Add the previous install as a new Bedrock Linux stratum ${color_priority}*${color_norm}
${color_priority}*${color_alert} ${color_priority}*${color_norm}
${color_priority}*${color_alert} YOU ARE ABOUT TO REPLACE YOUR EXISTING LINUX INSTALL WITH A ${color_priority}*${color_norm}
${color_priority}*${color_alert} BEDROCK LINUX INSTALL! THIS IS NOT INTENDED TO BE REVERSIBLE! ${color_priority}*${color_norm}
${color_priority}*${color_alert} ${color_priority}*${color_norm}
${color_priority}* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *${color_norm}
Please type \"Not reversible!\" without quotes at the prompt to continue:
> "
read -r line
echo ""
if [ "${line}" != "Not reversible!" ]; then
abort "Warning not copied exactly."
fi
release="$(extract_tarball | tar xOf - bedrock/etc/bedrock-release 2>/dev/null || true)"
print_logo "${release}"
step_init 6
step "Performing sanity checks"
modprobe fuse 2>/dev/null || true
if [ "$(id -u)" != "0" ]; then
abort "root required"
elif [ -r /proc/sys/kernel/osrelease ] && grep -qi 'microsoft' /proc/sys/kernel/osrelease; then
abort "Windows Subsystem for Linux does not support the required features for Bedrock Linux."
elif ! grep -q "\\<fuse\\>" /proc/filesystems; then
abort "/proc/filesystems does not contain \"fuse\". FUSE is required for Bedrock Linux to operate. Install the module fuse kernel module and try again."
elif ! [ -e /dev/fuse ]; then
abort "/dev/fuse not found. FUSE is required for Bedrock Linux to operate. Install the module fuse kernel module and try again."
elif ! type sha1sum >/dev/null 2>&1; then
abort "Could not find sha1sum executable. Install it then try again."
elif ! extract_tarball >/dev/null 2>&1 || [ "${TARBALL_SHA1SUM}" != "$(extract_tarball | sha1sum - | cut -d' ' -f1)" ]; then
abort "Embedded tarball is corrupt. Did you edit this script with software that does not support null characters?"
elif ! sanity_check_grub_mkrelpath; then
abort "grub-mkrelpath/grub2-mkrelpath --relative does not support bind-mounts on /boot. Continuing may break the bootloader on a kernel update. This is a known Bedrock issue with OpenSUSE+btrfs/GRUB."
elif [ -r /boot/grub/grub.cfg ] && { grep -q 'subvol=' /boot/grub/grub.cfg || grep -q 'ZFS=' /boot/grub/grub.cfg; }; then
abort '`subvol=` or `ZFS=` detected in `/boot/grub/grub.cfg` indicating GRUB usage on either BTRFS or ZFS. GRUB can get confused when updating this content on Bedrock which results in a non-booting system. Either use another filesystem or another bootloader.'
elif grep -qi 'btrfs' '/proc/mounts' && find /boot -iname "*grub*" 2>/dev/null | grep -q '.'; then
# Some users have reported getting past above two checks. This additional check is prone to false-positive, but it's better to be conservative here.
abort 'Detected BTRFS mount and GRUB reference in /boot. GRUB can get confused when updating its configuration in this scenario. Either use another filesystem or another bootloader.'
elif [ -e /bedrock/ ]; then
# Prefer this check at end of sanity check list so other sanity
# checks can be tested directly on a Bedrock system.
abort "/bedrock found. Cannot hijack Bedrock Linux."
fi
bb="/true"
if ! extract_tarball | tar xOf - bedrock/libexec/busybox >"${bb}"; then
rm -f "${bb}"
abort "Unable to write to root filesystem. Read-only root filesystems are not supported."
fi
chmod +x "${bb}"
if ! "${bb}"; then
rm -f "${bb}"
abort "Unable to execute reference binary. Perhaps this installer is intended for a different CPU architecture."
fi
rm -f "${bb}"
setf="/bedrock-linux-installer-$$-setfattr"
getf="/bedrock-linux-installer-$$-getfattr"
extract_tarball | tar xOf - bedrock/libexec/setfattr >"${setf}"
extract_tarball | tar xOf - bedrock/libexec/getfattr >"${getf}"
chmod +x "${setf}"
chmod +x "${getf}"
if ! "${setf}" --help >/dev/null; then
rm "${setf}"
rm "${getf}"
abort "Unable to run setfattr."
fi
if ! "${setf}" -n 'user.bedrock.test' -v 'x' "${getf}"; then
rm "${setf}"
rm "${getf}"
abort "Unable to set xattr. Bedrock Linux only works with filesystems which support extended filesystem attributes (\"xattrs\")."
fi
if [ "$("${getf}" --only-values --absolute-names -n "user.bedrock.test" "${getf}")" != "x" ]; then
rm "${setf}"
rm "${getf}"
abort "Unable to get xattr. Bedrock Linux only works with filesystems which support extended filesystem attributes (\"xattrs\")."
fi
rm "${setf}"
rm "${getf}"
setc="/bedrock-linux-installer-$$-setcap"
extract_tarball | tar xOf - bedrock/libexec/setcap >"${setc}"
chmod +x "${setc}"
if ! "${setc}" cap_sys_chroot=ep "${setc}" 2>/dev/null; then
rm "${setc}"
abort "Unable to set Linux capabilities. Does your kernel support them, e.g. CONFIG_EXT4_FS_SECURITY?"
fi
rm "${setc}"
step "Gathering information"
name=""
if [ -n "${1:-}" ]; then
name="${1}"
elif grep -q '^DISTRIB_ID=' /etc/lsb-release 2>/dev/null; then
name="$(awk -F= '$1 == "DISTRIB_ID" {print tolower($2)}' /etc/lsb-release | strip_illegal_stratum_name_characters)"
elif grep -q '^ID=' /etc/os-release 2>/dev/null; then
name="$(. /etc/os-release && echo "${ID}" | strip_illegal_stratum_name_characters)"
else
for file in /etc/*; do
if [ "${file}" = "os-release" ]; then
continue
elif [ "${file}" = "lsb-release" ]; then
continue
elif echo "${file}" | grep -q -- "-release$" 2>/dev/null; then
name="$(awk '{print tolower($1);exit}' "${file}" | strip_illegal_stratum_name_characters)"
break
fi
done
fi
if [ -z "${name}" ]; then
name="hijacked"
fi
ensure_legal_stratum_name "${name}"
notice "Using ${color_strat}${name}${color_norm} for initial stratum"
if ! [ -r "/sbin/init" ]; then
abort "No file detected at /sbin/init. Unable to hijack init system."
fi
notice "Using ${color_strat}${name}${color_glue}:${color_cmd}/sbin/init${color_norm} as default init selection"
pmm_cfgs="$(extract_tarball | tar tf - | grep 'bedrock/share/pmm/package_managers/.')"
initialize_awk_variables="$(extract_tarball | tar xOf - ${pmm_cfgs} | grep "^package_manager_canary_executables.\"")"
pmm_ui="$(awk 'BEGIN {
'"${initialize_awk_variables}"'
for (pm in package_manager_canary_executables) {
if (system("type "package_manager_canary_executables[pm]" >/dev/null 2>&1") == 0) {
print pm
exit
}
}
}')"
if [ -n "${pmm_ui:-}" ]; then
notice "Using ${color_cmd}${pmm_ui}${color_norm} as pmm user interface"
else
notice "No recognized system package managers discovered. Leaving pmm user interface unset."
fi
localegen=""
if [ -r "/etc/locale.gen" ]; then
localegen="$(awk '/^[^#]/{printf "%s, ", $0}' /etc/locale.gen | sed 's/, $//')"
fi
if [ -n "${localegen:-}" ] && echo "${localegen}" | grep -q ","; then
notice "Discovered multiple locale.gen lines"
elif [ -n "${localegen:-}" ]; then
notice "Using ${color_file}${localegen}${color_norm} for ${color_file}locale.gen${color_norm} language"
else
notice "Unable to determine locale.gen language, continuing without it"
fi
if [ -n "${LANG:-}" ]; then
notice "Using ${color_cmd}${LANG}${color_norm} for ${color_cmd}\$LANG${color_norm}"
fi
timezone=""
if [ -r /etc/timezone ] && [ -r "/usr/share/zoneinfo/$(cat /etc/timezone)" ]; then
timezone="$(cat /etc/timezone)"
elif [ -h /etc/localtime ] && readlink /etc/localtime | grep -q '^/usr/share/zoneinfo/' && [ -r /etc/localtime ]; then
timezone="$(readlink /etc/localtime | sed 's,^/usr/share/zoneinfo/,,')"
elif [ -r /etc/rc.conf ] && grep -q '^TIMEZONE=.' /etc/rc.conf; then
timezone="$(awk -F[=] '$1 == "TIMEZONE" {print$NF}' /etc/rc.conf)"
elif [ -r /etc/localtime ]; then
timezone="$(find /usr/share/zoneinfo -type f -exec sha1sum {} \; 2>/dev/null | awk -v"l=$(sha1sum /etc/localtime | cut -d' ' -f1)" '$1 == l {print$NF;exit}' | sed 's,/usr/share/zoneinfo/,,')"
fi
if [ -n "${timezone:-}" ]; then
notice "Using ${color_file}${timezone}${color_norm} for timezone"
else
notice "Unable to automatically determine timezone, continuing without it"
fi
step "Hijacking init system"
# Bedrock wants to take control of /sbin/init. Back up that so we can
# put our own file there.
#
# Some initrds assume init is systemd if they find systemd on disk and
# do not respect the Bedrock meta-init at /sbin/init. Thus we need to
# hide the systemd executables.
for init in /sbin/init /usr/bin/init /usr/sbin/init /lib/systemd/systemd /usr/lib/systemd/systemd; do
if [ -h "${init}" ] || [ -e "${init}" ]; then
mv "${init}" "${init}-bedrock-backup"
fi
done
step "Extracting ${color_file}/bedrock${color_norm}"
extract_tarball | (
cd /
tar xf -
)
extract_tarball | tar tf - | grep -v bedrock.conf | sort >/bedrock/var/bedrock-files
step "Configuring"
notice "Configuring ${color_strat}bedrock${color_norm} stratum"
set_attr "/" "stratum" "bedrock"
set_attr "/" "arch" "${ARCHITECTURE}"
set_attr "/bedrock/strata/bedrock" "stratum" "bedrock"
notice "Configuring ${color_strat}${name}${color_norm} stratum"
mkdir -p "/bedrock/strata/${name}"
if [ "${name}" != "hijacked" ]; then
ln -s "${name}" /bedrock/strata/hijacked
fi
for dir in / /bedrock/strata/bedrock /bedrock/strata/${name}; do
set_attr "${dir}" "show_boot" ""
set_attr "${dir}" "show_cross" ""
set_attr "${dir}" "show_init" ""
set_attr "${dir}" "show_list" ""
set_attr "${dir}" "show_pmm" ""
done
notice "Configuring ${color_file}bedrock.conf${color_norm}"
mv /bedrock/etc/bedrock.conf-* /bedrock/etc/bedrock.conf
sha1sum </bedrock/etc/bedrock.conf >/bedrock/var/conf-sha1sum
mv /bedrock/etc/.fresh-world /bedrock/etc/world
awk -v"value=${name}:/sbin/init" '!/^default =/{print} /^default =/{print "default = "value}' /bedrock/etc/bedrock.conf >/bedrock/etc/bedrock.conf-new
mv /bedrock/etc/bedrock.conf-new /bedrock/etc/bedrock.conf
if [ -n "${timezone:-}" ]; then
awk -v"value=${timezone}" '!/^timezone =/{print} /^timezone =/{print "timezone = "value}' /bedrock/etc/bedrock.conf >/bedrock/etc/bedrock.conf-new
mv /bedrock/etc/bedrock.conf-new /bedrock/etc/bedrock.conf
fi
if [ -n "${localegen:-}" ]; then
awk -v"values=${localegen}" '!/^localegen =/{print} /^localegen =/{print "localegen = "values}' /bedrock/etc/bedrock.conf >/bedrock/etc/bedrock.conf-new
mv /bedrock/etc/bedrock.conf-new /bedrock/etc/bedrock.conf
fi
if [ -n "${LANG:-}" ]; then
awk -v"value=${LANG}" '!/^LANG =/{print} /^LANG =/{print "LANG = "value}' /bedrock/etc/bedrock.conf >/bedrock/etc/bedrock.conf-new
mv /bedrock/etc/bedrock.conf-new /bedrock/etc/bedrock.conf
fi
if [ -n "${pmm_ui:-}" ]; then
awk -v"value=${pmm_ui}" '!/^user-interface =/{print} /^user-interface =/{print "user-interface = "value}' /bedrock/etc/bedrock.conf >/bedrock/etc/bedrock.conf-new
mv /bedrock/etc/bedrock.conf-new /bedrock/etc/bedrock.conf
fi
notice "Configuring ${color_file}/etc/fstab${color_norm}"
if [ -r /etc/fstab ]; then
awk '$1 !~ /^#/ && NF >= 6 {$6 = "0"} 1' /etc/fstab >/etc/fstab-new
mv /etc/fstab-new /etc/fstab
fi
step "Finalizing"
touch "/bedrock/complete-hijack-install"
notice "Reboot to complete installation"
notice "After reboot consider trying the Bedrock Linux basics tutorial command: ${color_cmd}brl tutorial basics${color_norm}"
}
update() {
if [ -n "${1:-}" ]; then
force=true
else
force=false
fi
step_init 7
step "Performing sanity checks"
require_root
if ! [ -r /bedrock/etc/bedrock-release ]; then
abort "No /bedrock/etc/bedrock-release file. Are you running Bedrock Linux 0.7.0 or higher?"
elif ! [ -e /dev/fuse ]; then
abort "/dev/fuse not found. FUSE is required for Bedrock Linux to operate. Install the module fuse kernel module and try again."
elif ! type sha1sum >/dev/null 2>&1; then
abort "Could not find sha1sum executable. Install it then try again."
elif ! extract_tarball >/dev/null 2>&1 || [ "${TARBALL_SHA1SUM}" != "$(extract_tarball | sha1sum - | cut -d' ' -f1)" ]; then
abort "Embedded tarball is corrupt. Did you edit this script with software that does not support null characters?"
fi
bb="/true"
if ! extract_tarball | tar xOf - bedrock/libexec/busybox >"${bb}"; then
rm -f "${bb}"
abort "Unable to write to root filesystem. Read-only root filesystems are not supported."
fi
chmod +x "${bb}"
if ! "${bb}"; then
rm -f "${bb}"
abort "Unable to execute reference binary. Perhaps this update file is intended for a different CPU architecture."
fi
rm -f "${bb}"
step "Determining version change"
current_version="$(awk '{print$3}' </bedrock/etc/bedrock-release)"
new_release="$(extract_tarball | tar xOf - bedrock/etc/bedrock-release)"
new_version="$(echo "${new_release}" | awk '{print$3}')"
if ! ${force} && ! ver_cmp_first_newer "${new_version}" "${current_version}"; then
abort "${new_version} is not newer than ${current_version}, aborting."
fi
if ver_cmp_first_newer "${new_version}" "${current_version}"; then
notice "Updating from ${current_version} to ${new_version}"
elif [ "${new_version}" = "${current_version}" ]; then
notice "Re-installing ${current_version} over same version"
else
notice "Downgrading from ${current_version} to ${new_version}"
fi
step "Running pre-install steps"
# Early Bedrock versions used a symlink at /sbin/init, which was found
# to be problematic. Ensure the userland extraction places a real file
# at /sbin/init.
if ver_cmp_first_newer "0.7.9" "${current_version}" && [ -h /bedrock/strata/bedrock/sbin/init ]; then
rm -f /bedrock/strata/bedrock/sbin/init
fi
# All crossfs builds prior to 0.7.8 became confused if bouncer changed
# out from under them. If upgrading such a version, do not upgrade
# bouncer in place until reboot.
#
# Back up original bouncer so we can restore it after extracting over
# it.
if ver_cmp_first_newer "0.7.9" "${current_version}"; then
cp /bedrock/libexec/bouncer /bedrock/libexec/bouncer-pre-0.7.9
fi
step "Installing new files and updating existing ones"
extract_tarball | (
cd /
/bedrock/bin/strat bedrock /bedrock/libexec/busybox tar xf -
)
/bedrock/libexec/setcap cap_sys_chroot=ep /bedrock/bin/strat
new_crossfs_sha1sum="$(sha1sum <"/bedrock/libexec/crossfs")"
new_etcfs_sha1sum="$(sha1sum <"/bedrock/libexec/etcfs")"
step "Removing unneeded files"
# Remove previously installed files not part of this release
extract_tarball | tar tf - | grep -v bedrock.conf | sort >/bedrock/var/bedrock-files-new
diff -d /bedrock/var/bedrock-files-new /bedrock/var/bedrock-files | grep '^>' | cut -d' ' -f2- | tac | while read -r file; do
if echo "${file}" | grep '/$'; then
/bedrock/bin/strat bedrock /bedrock/libexec/busybox rmdir "/${file}" 2>/dev/null || true
else
/bedrock/bin/strat bedrock /bedrock/libexec/busybox rm -f "/${file}" 2>/dev/null || true
fi
done
mv /bedrock/var/bedrock-files-new /bedrock/var/bedrock-files
# Handle world file
if [ -e /bedrock/etc/world ]; then
rm /bedrock/etc/.fresh-world
else
mv /bedrock/etc/.fresh-world /bedrock/etc/world
fi
step "Handling possible bedrock.conf update"
# If bedrock.conf did not change since last update, remove new instance
new_conf=true
new_sha1sum="$(sha1sum <"/bedrock/etc/bedrock.conf-${new_version}")"
if [ "${new_sha1sum}" = "$(cat /bedrock/var/conf-sha1sum)" ]; then
rm "/bedrock/etc/bedrock.conf-${new_version}"
new_conf=false
fi
echo "${new_sha1sum}" >/bedrock/var/conf-sha1sum
step "Running post-install steps"
if ver_cmp_first_newer "0.7.0beta4" "${current_version}"; then
# Busybox utility list was updated in 0.7.0beta3, but their symlinks were not changed.
# Ensure new utilities have their symlinks.
/bedrock/libexec/busybox --list-full | while read -r applet; do
strat bedrock /bedrock/libexec/busybox rm -f "/${applet}"
done
strat bedrock /bedrock/libexec/busybox --install -s
fi
if ver_cmp_first_newer "0.7.6" "${current_version}"; then
set_attr "/bedrock/strata/bedrock" "arch" "${ARCHITECTURE}"
fi
if ver_cmp_first_newer "0.7.7beta1" "${current_version}" && [ -r /etc/login.defs ]; then
# A typo in /bedrock/share/common-code's enforce_id_ranges()
# resulted in spam at the bottom of /etc/login.defs files. The
# typo was fixed in this release such that we won't generate
# new spam, but we still need to remove any existing spam.
#
# /etc/login.defs is global such that we only have to update
# one file.
#
# Remove all SYS_UID_MIN and SYS_GID_MIN lines after the first
# of each.
awk '
/^[ \t]*SYS_UID_MIN[ \t]/ {
if (uid == 0) {
print
uid++
}
next
}
/^[ \t]*SYS_GID_MIN[ \t]/ {
if (gid == 0) {
print
gid++
}
next
}
1
' "/etc/login.defs" > "/etc/login.defs-new"
mv "/etc/login.defs-new" "/etc/login.defs"
# Run working enforce_id_ranges to fix add potentially missing
# lines
enforce_id_ranges
fi
# All crossfs builds prior to 0.7.8 became confused if bouncer changed
# out from under them. If upgrading such a version, do not upgrade
# bouncer in place until reboot.
#
# Back up new bouncer and restore previous one.
if ver_cmp_first_newer "0.7.9" "${current_version}" && [ -e /bedrock/libexec/bouncer-pre-0.7.9 ]; then
cp /bedrock/libexec/bouncer /bedrock/libexec/bouncer-0.7.9
cp /bedrock/libexec/bouncer-pre-0.7.9 /bedrock/libexec/bouncer
rm /bedrock/libexec/bouncer-pre-0.7.9
fi
# Ensure preexisting non-hidden strata are visible to pmm
if ver_cmp_first_newer "0.7.14beta1" "${current_version}"; then
brl show --pmm $(brl list -ed)
fi
notice "Successfully updated to ${new_version}"
if ver_cmp_first_newer "0.7.0beta3" "${current_version}"; then
notice "Added brl-fetch-mirrors section to bedrock.conf. This can be used to specify preferred mirrors to use with brl-fetch."
fi
if ver_cmp_first_newer "0.7.0beta4" "${current_version}"; then
notice "Added ${color_cmd}brl copy${color_norm}."
notice "${color_alert}New, required section added to bedrock.conf. Merge new config with existing and reboot.${color_norm}"
fi
if ver_cmp_first_newer "0.7.0beta6" "${current_version}"; then
notice "Reworked ${color_cmd}brl retain${color_norm} options."
notice "Made ${color_cmd}brl status${color_norm} more robust. Many strata may now report as broken. Reboot to remedy."
fi
if ver_cmp_first_newer "0.7.14beta1" "${current_version}"; then
notice "Added new pmm subsystem"
notice "Populate new [pmm] section of bedrock.conf \`user_interface\` field then run \`brl apply\` as root to create pmm front-end."
fi
if ver_cmp_first_newer "0.7.16beta1" "${current_version}" && ! [ -e "/bedrock/strata/bedrock/etc/crypttab" ]; then
for s in $(/bedrock/bin/brl list -i); do
if [ "$(/bedrock/bin/brl deref "${s}")" = "bedrock" ]; then
continue
fi
if [ -e "/bedrock/strata/${s}/etc/crypttab" ]; then
cp "/bedrock/strata/${s}/etc/crypttab" "/bedrock/strata/bedrock/etc/crypttab"
fi
done
fi
if ver_cmp_first_newer "0.7.21beta1" "${current_version}"; then
# Keeps Gentoo/portage from trying to write to /bedrock/cross/info/
mkdir -p /bedrock/strata/bedrock/usr/share/info/
touch /bedrock/strata/bedrock/usr/share/info/.keepinfodir
fi
if ver_cmp_first_newer "0.7.21beta5" "${current_version}"; then
ln -fns /bedrock/libexec/kmod /bedrock/strata/bedrock/sbin/depmod
ln -fns /bedrock/libexec/kmod /bedrock/strata/bedrock/sbin/insmod
ln -fns /bedrock/libexec/kmod /bedrock/strata/bedrock/sbin/lsmod
ln -fns /bedrock/libexec/kmod /bedrock/strata/bedrock/sbin/modinfo
ln -fns /bedrock/libexec/kmod /bedrock/strata/bedrock/sbin/modprobe
ln -fns /bedrock/libexec/kmod /bedrock/strata/bedrock/sbin/rmmod
fi
if ver_cmp_first_newer "0.7.22beta2" "${current_version}" && \
! [ -e /bedrock/strata/bedrock/usr/share/grub ] && \
! [ -h /bedrock/strata/bedrock/usr/share/grub ]; then
ln -s /bedrock/strata/hijacked/usr/share/grub /bedrock/strata/bedrock/usr/share/grub
fi
if ver_cmp_first_newer "0.7.23beta2" "${current_version}"; then
notice "Updated etcfs. Cannot restart Bedrock FUSE filesystems live. Reboot to complete change."
fi
if ver_cmp_first_newer "0.7.23beta1" "${current_version}"; then
notice "Updated crossfs. Cannot restart Bedrock FUSE filesystems live. Reboot to complete change."
fi
if "${new_conf}"; then
notice "New reference configuration created at ${color_file}/bedrock/etc/bedrock.conf-${new_version}${color_norm}."
notice "Compare against ${color_file}/bedrock/etc/bedrock.conf${color_norm} and consider merging changes."
notice "Remove ${color_file}/bedrock/etc/bedrock.conf-${new_version}${color_norm} at your convenience."
fi
}
case "${1:-}" in
"--hijack")
shift
hijack "$@"
;;
"--update")
update
;;
"--force-update")
update "force"
;;
*)
print_help
;;
esac
trap '' EXIT
exit 0

View File

@ -0,0 +1,22 @@
# keyboard_is_present makefile
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# version 2 as published by the Free Software Foundation.
#
# Copyright (c) 2019 Daniel Thau <danthau@bedrocklinux.org>
all: keyboard_is_present
keyboard_is_present: keyboard_is_present.c
$(CC) $(CFLAGS) -std=c99 keyboard_is_present.c -o keyboard_is_present
clean:
rm -f keyboard_is_present
install:
mkdir -p $(prefix)/sbin
install -m 755 keyboard_is_present $(prefix)/sbin/keyboard_is_present
uninstall:
rm -f $(prefix)/sbin/keyboard_is_present

View File

@ -0,0 +1,32 @@
keyboard_is_present
===================
Detects if Linux system has an initialized keyboard
Usage
-----
Simply run the executable. It will return zero if a keyboard is detected and
non-zero otherwise.
Installation
------------
Bedrock Linux should be distributed with a script which handles installation,
but just in case:
To compile, run
make
To install into installdir, run
make prefix=<installdir> install
To clean up, like usual:
make clean
And finally, to remove it, run:
make prefix=<installdir> uninstall

View File

@ -0,0 +1,124 @@
/*
* keyboard_is_present.c
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* version 2 as published by the Free Software Foundation.
*
* Copyright (c) 2019 Daniel Thau <danthau@bedrocklinux.org>
*
* Based on the keyboard detection system described here:
* https://www.mattfischer.com/blog/archives/182
*
* Returns zero if a keyboard is detected and non-zero otherwise.
*/
#include <dirent.h>
#include <linux/input.h>
#include <linux/limits.h>
#include <stdio.h>
#include <sys/stat.h>
/*
* Input device directory
*/
#define INPUT_DIR "/sys/class/input"
/*
* Escape key, the number row, and Q through D
*/
#define KEYBOARD_MASK 0xFFFFFFFE
int main(int argc, char *argv[])
{
(void)argc;
(void)argv;
DIR *dir;
if ((dir = opendir(INPUT_DIR)) == NULL) {
fprintf(stderr, "Unable to open \"%s\"\n", INPUT_DIR);
return 2;
}
struct dirent *entry;
while ((entry = readdir(dir)) != NULL) {
/*
* Skip `.` and `..`. Also dotfiles if they some how end up
* here.
*/
if (entry->d_name[0] == '.') {
continue;
}
/*
* Find capabilities directory
*/
char *cap = "capabilities";
char path[PATH_MAX];
int s = snprintf(path, sizeof(path),
INPUT_DIR "/%s/%s", entry->d_name, cap);
if (s < 0 || s >= (int)sizeof(path)) {
fprintf(stderr, "Unable to build capabilities path string\n");
return 2;
}
struct stat stbuf;
if (stat(path, &stbuf) != 0 || !S_ISDIR(stbuf.st_mode)) {
cap = "device/capabilities";
s = snprintf(path, sizeof(path), INPUT_DIR "/%s/%s", entry->d_name, cap);
if (s < 0 || s >= (int)sizeof(path)) {
fprintf(stderr, "Unable to build capabilities path string\n");
return 2;
}
}
if (stat(path, &stbuf) != 0 || !S_ISDIR(stbuf.st_mode)) {
continue;
}
/*
* Check if device has keyboard event code support
*/
s = snprintf(path, sizeof(path), INPUT_DIR "/%s/%s/ev", entry->d_name, cap);
if (s < 0 || s >= (int)sizeof(path)) {
fprintf(stderr, "Unable to build ev path string\n");
return 2;
}
FILE *f;
if ((f = fopen(path, "r")) == NULL) {
continue;
}
unsigned int bits = 0;
while (fscanf(f, "%x", &bits) == 1) {
;
}
fclose(f);
if ((bits & EV_KEY) != EV_KEY) {
continue;
}
/*
* Check if device supports expected keyboard keys such as escape, the number row, and Q through D
*/
s = snprintf(path, sizeof(path), INPUT_DIR "/%s/%s/key", entry->d_name, cap);
if (s < 0 || s >= (int)sizeof(path)) {
fprintf(stderr, "Unable to build key path string\n");
return 2;
}
if ((f = fopen(path, "r")) == NULL) {
continue;
}
bits = 0;
while (fscanf(f, "%x", &bits) == 1) {
;
}
fclose(f);
if ((bits & KEYBOARD_MASK) != KEYBOARD_MASK) {
continue;
}
/*
* Found keyboard
*/
return 0;
}
return 1;
}

View File

@ -0,0 +1,22 @@
# manage_tty_lock makefile
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# version 2 as published by the Free Software Foundation.
#
# Copyright (c) 2015-2018 Daniel Thau <danthau@bedrocklinux.org>
all: manage_tty_lock
manage_tty_lock:
$(CC) $(CFLAGS) -std=c99 manage_tty_lock.c -o manage_tty_lock
clean:
rm -f manage_tty_lock
install:
mkdir -p $(prefix)/sbin
install -m 755 manage_tty_lock $(prefix)/sbin/manage_tty_lock
uninstall:
rm -f $(prefix)/sbin/manage_tty_lock

View File

@ -0,0 +1,42 @@
manage_tty_lock
===============
Set/unset the locks on a given terminal.
Usage
-----
To lock a terminal, use `lock` as the first argument. To unlock one, use
`unlock` as the first argument. The second argument can be utilized to specify
which terminal to lock/unlock; if it is left unset, the current terminal is
utilized.
Example, locking /dev/pts/1:
manage_stty_lock lock /dev/pts/1
Example, unlocking the current terminal:
Example: manage_stty_lock unlock
Installation
------------
Bedrock Linux should be distributed with a script which handles installation,
but just in case:
To compile, run
make
To install into installdir, run
make prefix=<installdir> install
To clean up, like usual:
make uninstall
And finally, to remove it, run:
make prefix=<installdir> uninstall

View File

@ -0,0 +1,106 @@
/*
* manage_stty_lock.c
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* version 2 as published by the Free Software Foundation.
*
* Copyright (c) 2015-2018 Daniel Thau <danthau@bedrocklinux.org>
*
* This program sets/unsets the locks on a given terminal. See tty_ioctl(4).
*/
#include <errno.h>
#include <fcntl.h>
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <termios.h>
#include <unistd.h>
void print_help()
{
printf(""
"Usage: manage_stty_lock [lock|unlock] [tty]\n"
"Requires root.\n"
"\n"
"To lock a terminal, use `lock` as the first argument. To unlock one, use\n"
"`unlock` as the first argument. The second argument can be utilized to specify\n"
"which terminal to lock/unlock; if it is left unset, the current terminal is\n"
"utilized.\n"
"\n"
"Example, locking /dev/pts/1:\n"
"\n"
" manage_stty_lock lock /dev/pts/1\n"
"\n" "Example, unlocking the current terminal:\n" "\n Example: manage_stty_lock unlock\n");
}
int lock_tty(int fd)
{
/*
* Non-zero bits indicate a field to lock. Since we're locking
* everything, set everything to non-zero.
*/
struct termios term;
memset(&term, 0xff, sizeof(term));
errno = 0;
if (ioctl(fd, TIOCSLCKTRMIOS, &term) < 0) {
perror("ioctl error");
}
return errno;
}
int unlock_tty(int fd)
{
/*
* Non-zero bits indicate a field to lock. Since we're unlocking
* everything, set everything to zero.
*/
struct termios term;
memset(&term, 0, sizeof(term));
errno = 0;
if (ioctl(fd, TIOCSLCKTRMIOS, &term) < 0) {
perror("ioctl error");
}
return errno;
}
int main(int argc, char *argv[])
{
if (argc < 2) {
fprintf(stderr, "Insufficient arguments\n");
return EINVAL;
}
if (!strcmp(argv[1], "-h") || !strcmp(argv[1], "--help")) {
print_help();
return 0;
}
int fd = 0;
if (argc >= 3) {
fd = open(argv[2], O_RDONLY);
if (fd < 0) {
fprintf(stderr, "Unable to open specified tty \"%s\"\n", argv[2]);
return EBADF;
}
}
if (!strcmp(argv[1], "lock")) {
return lock_tty(fd);
} else if (!strcmp(argv[1], "unlock")) {
return unlock_tty(fd);
} else {
printf("Unrecognized argument \"%s\"\n", argv[1]);
return EINVAL;
}
}

View File

@ -0,0 +1,55 @@
From 98f49ddcfbbeeda32de65aefeeb529a8e2aa5281 Mon Sep 17 00:00:00 2001
From: Daniel Thau <danthau@bedrocklinux.org>
Date: Sun, 9 May 2021 10:37:58 -0400
Subject: [PATCH] mount: support "X-" and "x-" options
util-linux supports userspace application-specific capital "X-" mount
options which serve as /etc/fstab comments. They should be ignored by
mount and should not be passed to mount(2).
util-linux also supports userspace application-specific lowercase "x-"
mount options which serve as comments both in /etc/fstab and
/run/mount/utab. Similar to "X-", they should not be passed to
mount(2). Had busybox support for /run/mount/utab, they should be
stored there; since busybox does not, they are simply ignored
completely.
This is commonly used by systemd, e.g. "x-systemd.device-timeout=0".
---
util-linux/mount.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/util-linux/mount.c b/util-linux/mount.c
index 831dab9e2..e26db33ed 100644
--- a/util-linux/mount.c
+++ b/util-linux/mount.c
@@ -347,6 +347,8 @@ static const int32_t mount_options[] ALIGN4 = {
IF_DESKTOP(/* "nofail" */ MOUNT_NOFAIL,)
/* "_netdev" */ 0,
IF_DESKTOP(/* "comment=" */ 0,) /* systemd uses this in fstab */
+ IF_DESKTOP(/* "X-" */ 0,) /* fstab comment */
+ IF_DESKTOP(/* "x-" */ 0,) /* fstab and utab comment */
)
IF_FEATURE_MOUNT_FLAGS(
@@ -410,6 +412,8 @@ static const char mount_option_str[] ALIGN1 =
IF_DESKTOP("nofail\0")
"_netdev\0"
IF_DESKTOP("comment=\0") /* systemd uses this in fstab */
+ IF_DESKTOP("X-\0") /* fstab comment */
+ IF_DESKTOP("x-\0") /* fstab and utab comment */
)
IF_FEATURE_MOUNT_FLAGS(
// vfs flags
@@ -610,6 +614,8 @@ static unsigned long parse_mount_options(char *options, char **unrecognized)
&& (options[opt_len] == '\0'
/* or is it "comment=" thingy in fstab? */
IF_FEATURE_MOUNT_FSTAB(IF_DESKTOP( || option_str[opt_len-1] == '=' ))
+ /* or is it a "X-" or "x-" fstab comment? */
+ IF_FEATURE_MOUNT_FSTAB(IF_DESKTOP( || strcasecmp(option_str, "x-") == 0))
)
) {
unsigned long fl = mount_options[i];
--
2.20.1

View File

@ -0,0 +1,22 @@
# plymouth-quit makefile
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# version 2 as published by the Free Software Foundation.
#
# Copyright (c) 2020 Daniel Thau <danthau@bedrocklinux.org>
all: plymouth-quit
plymouth-quit: plymouth-quit.c
$(CC) $(CFLAGS) -std=c99 plymouth-quit.c -o plymouth-quit
clean:
rm -f plymouth-quit
install:
mkdir -p $(prefix)/sbin
install -m 755 plymouth-quit $(prefix)/sbin/plymouth-quit
uninstall:
rm -f $(prefix)/sbin/plymouth-quit

View File

@ -0,0 +1,31 @@
plymouth-quit
=============
Tells plymouth to quit
Usage
-----
Simply run the executable.
Installation
------------
Bedrock Linux should be distributed with a script which handles installation,
but just in case:
To compile, run
make
To install into installdir, run
make prefix=<installdir> install
To clean up, like usual:
make clean
And finally, to remove it, run:
make prefix=<installdir> uninstall

View File

@ -0,0 +1,60 @@
/*
* plymouth-quit.c
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* version 2 as published by the Free Software Foundation.
*
* Copyright (c) 2020 Daniel Thau <danthau@bedrocklinux.org>
*
* Tells plymouth to quit.
*/
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <unistd.h>
#define PLYMOUTH_ABSTRACT_SOCKET_PATH "/org/freedesktop/plymouthd"
#define PLYMOUTH_QUIT_CHAR 'Q'
int main(int argc, char *argv[])
{
(void)argc;
(void)argv;
int fd = socket(AF_UNIX, SOCK_STREAM, 0);
if (fd < 0) {
perror("socket");
return -1;
}
struct sockaddr_un addr;
memset(&addr, 0, sizeof(addr));
addr.sun_family = AF_UNIX;
addr.sun_path[0] = '\0';
strncpy(addr.sun_path + 1, PLYMOUTH_ABSTRACT_SOCKET_PATH, strlen(PLYMOUTH_ABSTRACT_SOCKET_PATH) + 1);
if (connect(fd, (struct sockaddr *)&addr, sizeof(addr) - 81) < 0) {
switch (errno) {
case ECONNREFUSED:
/*
* Plymouth isn't running
*/
return 0;
default:
perror("connect");
return -1;
}
}
char buf[4];
buf[0] = PLYMOUTH_QUIT_CHAR;
buf[1] = '\2';
buf[2] = '\1';
buf[3] = '\0';
write(fd, buf, sizeof(buf));
return 0;
}

75
src/slash-bedrock/bin/brl Executable file
View File

@ -0,0 +1,75 @@
#!/bedrock/libexec/busybox sh
#
# brl
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# version 2 as published by the Free Software Foundation.
#
# Copyright (c) 2012-2019 Daniel Thau <danthau@bedrocklinux.org>
#
# This program manages and provides information about a Bedrock Linux install
# and its subsystems.
. /bedrock/share/common-code
print_help() {
printf "Usage: ${color_cmd}brl ${color_sub}<command> [arguments]${color_norm}
${color_bedrock}Bedrock Linux${color_norm} system management and introspection.
Common commands:
${color_cmd}strat ${color_norm}Run specified ${color_term}stratum${color_norm}'s executable
${color_cmd} ${color_norm}Note: ${color_cmd}\`strat\`${color_norm} is available without the ${color_cmd}\`brl\`${color_norm} prefix
${color_cmd}list ${color_norm}List ${color_term}strata${color_norm}
${color_cmd}which ${color_norm}Query which ${color_term}stratum${color_norm} provides object
${color_term}Strata${color_norm} management commands:
${color_cmd}fetch ${color_term}Fetch${color_norm} new ${color_term}strata${color_norm}
${color_cmd}import ${color_term}Import${color_norm} new ${color_term}strata${color_norm}
${color_cmd}remove ${color_norm}Remove ${color_term}strata${color_norm} (or ${color_term}aliases${color_norm})
${color_cmd}rename ${color_norm}Rename a ${color_term}stratum${color_norm}
${color_cmd}copy ${color_norm}Copy a ${color_term}stratum${color_norm}
${color_term}Strata${color_norm} status management commands:
${color_cmd}status ${color_norm}Query ${color_term}stratum${color_norm} status
${color_cmd}enable ${color_norm}${color_term}Enable${color_norm} ${color_term}strata${color_norm}
${color_cmd}disable ${color_norm}${color_term}Disable${color_norm} ${color_term}strata${color_norm}
${color_cmd}repair ${color_norm}Repairs ${color_term}broken${color_norm} ${color_term}strata${color_norm}
${color_term}Strata${color_norm} visibility management commands:
${color_cmd}hide ${color_norm}${color_term}Hide${color_norm} ${color_term}strata${color_norm}
${color_cmd}show ${color_norm}${color_term}Show${color_norm} ${color_term}strata${color_norm}
${color_term}Alias${color_norm} management commands:
${color_cmd}alias ${color_norm}Create a ${color_term}stratum${color_norm} ${color_term}alias${color_norm}
${color_cmd}deref ${color_norm}Dereference ${color_term}stratum${color_norm} ${color_term}aliases${color_norm}
Miscellaneous commands:
${color_cmd}apply ${color_norm}Apply configuration changes
${color_cmd}update ${color_norm}Update ${color_bedrock}Bedrock Linux${color_norm} system
${color_cmd}version ${color_norm}Query ${color_bedrock}Bedrock Linux${color_norm} version
${color_cmd}report ${color_norm}Generate report
${color_cmd}tutorial ${color_norm}Run interactive ${color_bedrock}Bedrock Linux${color_norm} tutorial
See ${color_cmd}\`brl ${color_sub}<command>${color_cmd} --help\`${color_norm} for further details per command.
"
}
case "${1:-}" in
"-h" | "--help" | "help" | "")
print_help
exit_success
;;
"strat" | "list" | "which" | "fetch" | "import" | "remove" | "rename" | "copy" | "status" | "enable" | "disable" | "repair" | "hide" | "show" | "alias" | "deref" | "apply" | "update" | "version" | "report" | "tutorial")
backend="/bedrock/libexec/brl-${1}"
shift
exec "${backend}" "${@}"
abort "Unable to execute \`${backend}\`"
;;
*)
abort "Unrecognized brl subcommand. See \`${0} --help\`"
;;
esac
exit_success

View File

@ -0,0 +1,711 @@
#
# Bedrock Linux main configuration file
#
# After making changes here, run `brl apply` (as root) to apply them.
#
[locale]
#
# The Olson timezone. For example:
#
# timezone = America/New_York
#
# At least one stratum should provide an Olson database file at
#
# /usr/share/zoneinfo/<timezone>
#
# For example, for America/New_York there should be a file at
#
# /usr/share/zoneinfo/America/New_York
#
timezone =
#
# The /etc/locale.gen language lines. For example:
#
# localegen = en_US.UTF-8 UTF-8
#
localegen = en_US.UTF-8 UTF-8
#
# The POSIX $LANG variable
#
LANG =
[init]
#
# Bedrock Linux provides its own init which sets up Bedrock subsystems then
# hands control over to a user-selected init provided by some stratum.
#
#
# Number of seconds to wait for an init to be input before automatically
# selecting the default value (if a valid default value is set).
#
timeout = 30
#
# Init to utilize by default if timeout expires. Format is
#
# default = <stratum>:<path>
#
# For example, to use void's /sbin/init, use:
#
# default = void:/sbin/init
#
default =
#
# A comma separated list of local file paths which may provide an init. The
# Bedrock init menu will list every available one from every (unignored)
# stratum.
#
paths = /sbin/init, /sbin/fallback-init, /sbin/myinit, /sbin/ninit, /sbin/openrc-init, /sbin/runit-init, /sbin/simpleinit, /sbin/upstart, /lib/sysvinit/init, /lib/systemd/systemd, /usr/lib/systemd/systemd, /usr/bin/intra-desktop
#
# Kernel modules to load before assuming keyboard is available.
#
modules = usbhid, hid, hid_generic, hid_microsoft
[global]
#
# Bedrock Linux categorizes every file path on the system as either:
#
# - Local to a given stratum. Multiple instances of such files are needed to
# avoid conflicts between the strata.
# - Global across all strata. There is only one instance of such a file
# irrelevant of the number of strata.
#
# For example: both Debian and Ubuntu have package managers that read
# /etc/apt/sources.list, and each needs to see something different there.
# Thus, the /etc/apt/sources.list file path should be local to each stratum.
# However, all processes should see the same contents in /home, and thus /home
# is global.
#
# By default, all files are local. The following settings are used to indicate
# which files should be global. Different contexts require different systems
# for marking a file path as global.
#
#
# A list of directories which should be global. If something is
# mounted into one of these directories, that new mount point
# is also global.
#
share = /boot, /dev, /home, /lib/modules, /media, /mnt, /proc, /root, /run, /sys, /tmp
#
# Another list of directories which should be global. Anything mounted in them
# is local by default. These are primarily used to avoid recursion in nested
# cases. Given that nesting is expected, be careful with order.
#
bind = /bedrock, /bedrock/cross, /bedrock/run, /bedrock/strata/bedrock
#
# A list of files and directories within /etc which should be global. /etc
# must be treated specially, as the techniques used for share and bind do not
# work for files in it.
#
etc = adjtime, crypttab, default/grub, fstab, group, group+, group-, group.OLD, group.org, gshadow, gshadow+, gshadow-, gshadow.OLD, gshadow.org, hostname, hosts, login.defs, machine-id, modprobe.d/blacklist.conf, passwd, passwd+, passwd-, passwd.OLD, passwd.org, rc.local, resolv.conf, resolvconf/run, shadow, shadow+, shadow-, shadow.OLD, shadow.org, sudoers
[symlinks]
#
# Enforce various symlinks are in place at local paths. This is applied at
# stratum enable/repair time.
#
# Keys are local paths, values are symlink contents.
#
# The symlink contents must be absolute paths.
#
#
# Some package managers attempt to update this. They become upset if it is
# created between an unlink() and symlink(), making it unsuitable for
# [etc-symlinks] below.
#
# Different distros use slightly different values here that are all effectively
# the same. Rather than attempt to fight distros in this regard, Bedrock has
# hard-coded internal support for multiple valid values here and may not
# respect changes to this field.
/etc/mtab = /proc/self/mounts
#
# Some distros may expect a file at one path while others expect it at another.
# Standardize the location of global files.
#
/var/lib/dbus/machine-id = /etc/machine-id
/var/run = /run
#
# Various programs need to be configured to properly interact with Bedrock
# subsystems. Point them to Bedrock configuration.
#
/etc/systemd/system/bedrock-fix-mounts.service = /bedrock/share/systemd/bedrock-fix-mounts.service
/etc/systemd/system/bedrock-fix-resolv.service = /bedrock/share/systemd/bedrock-fix-resolv.service
/etc/systemd/system/bedrock-stop-fuse-filesystems.service = /bedrock/share/systemd/bedrock-stop-fuse-filesystems.service
/etc/systemd/system/multi-user.target.wants/bedrock-fix-mounts.service = /bedrock/share/systemd/bedrock-fix-mounts.service
/etc/systemd/system/multi-user.target.wants/bedrock-stop-fuse-filesystems.service = /bedrock/share/systemd/bedrock-stop-fuse-filesystems.service
/etc/systemd/system/network-online.target.wants/bedrock-fix-resolv.service = /bedrock/share/systemd/bedrock-fix-resolv.service
/etc/X11/xorg.conf.d/99-bedrock-fonts.conf = /bedrock/run/xorg-fonts
/etc/fonts/conf.d/99-bedrock-fonts.conf = /bedrock/share/fonts/fontconf.conf
/etc/X11/Xsession.d/99bedrock_env = /bedrock/run/profile
/etc/X11/xinit/xinitrc.d/99bedrock_env = /bedrock/run/profile
/etc/bash_completion.d/brl = /bedrock/share/bash/completion/brl
/etc/bash_completion.d/strat = /bedrock/share/bash/completion/strat
/etc/fish/conf.d/99bedrock.fish = /bedrock/run/fprofile
/etc/fish/completions/brl.fish = /bedrock/share/fish/completion/brl.fish
/etc/fish/completions/strat.fish = /bedrock/share/fish/completion/strat.fish
/etc/resolvconf/update.d/00bedrock = /bedrock/share/resolvconf/00bedrock
#
# In general, system software such as Bedrock should not manipulate /usr/local.
# Bedrock should favor configuring /etc files instead.
#
# However, dbus's dbus-daemon-launch-helper seems to ignore /etc/dbus-1/
# configuration extending the search path. See
# https://bugs.freedesktop.org/show_bug.cgi?id=92458 for a discussion on the
# matter. For example:
#
# > Note that d-d-l-h only reads .service files from standard hard-coded paths,
# > not from any additional paths that you might have configured
#
# Since /usr/local/share/dbus is included in the hard-coded paths, is not used
# by most package managers, and is rarely used by end-users, it's the cleanest
# option available to teach dbus about /bedrock/cross.
#
/usr/local/share/dbus-1/system-services = /bedrock/cross/dbus-system
/usr/local/share/dbus-1/services = /bedrock/cross/dbus-session
#
# Some distros use a swap file and include reference to it in their fstab.
# This must be global so that it is valid when using an init from another
# stratum. However, it is not clear if it would work well with any of the
# established techniques in [global]. Instead, symlink it into a known global
# directory.
#
/swapfile = /bedrock/swapfile
[etc-symlinks]
#
# Dynamically enforce various symlinks are in place at local paths. Any change
# away from specified configuration is immediately undone.
#
# Keys are local paths relative to /etc, values are symlink contents.
#
# The symlink contents must be absolute paths.
#
#
# Some init systems attempt to change these values at boot time, just after
# being enabled. Thus, symlinks-general will not suffice.
#
localtime = /bedrock/run/localtime
environment = /bedrock/run/environment
[etc-inject]
#
# Not all programs can be adequately/reliably configured by creating new,
# cleanly isolated configuration files. Instead, a configuration file must be
# extended to include desired configuration without clobbering its stratum
# local configuration. Typically these configuration files are in /etc.
#
# Bedrock ensures that, should certain files exist in /etc, they will include
# content specified at another file path. If the desired content is not found
# in the file it is automatically appended to the end.
#
# The keys are file paths relative to /etc, and the values are paths to files
# whose content must be included if the key's file exists in /etc.
#
# If you alter either the key/values in this section, or the actual content of
# the values, run `brl apply` to apply the change. Do this before rebooting
# to ensure any old content is removed.
#
sudoers = /bedrock/share/sudo/include-bedrock
profile = /bedrock/share/shells/include-bedrock
# Received mix fixed back on cross-stratum dkms. It's disabled by default.
#
# To enable it, uncomment dkms/framework.conf line below and run `brl apply`.
#
# To re-disable it, comment out dkms/framework.conf line, `brl apply`, then
# remove corresponding line from /bedrock/strata/*/etc/dkms/framework.conf
#
#dkms/framework.conf = /bedrock/share/dkms/include-bedrock
#
# etc-inject only injects existing files and does create make files in order to
# avoid creating a file a package manager does not expect. Different distro
# zsh packages provide different files, requiring multiple zsh file injections.
#
zprofile = /bedrock/share/zsh/include-bedrock
zshenv = /bedrock/share/zsh/include-bedrock
zsh/zprofile = /bedrock/share/zsh/include-bedrock
zsh/zshenv = /bedrock/share/zsh/include-bedrock
[env-vars]
#
# Many programs search environment variables consisting of a (usually colon
# separated) list of directories. We can use these to teach these programs
# about cross-stratum content.
#
# These variables are typically searched in listed order. To manage this
# order, the configuration below is broken up into three sections for each
# variable:
#
# - PREFIX:<envvar> entries. Bedrock ensures these are at the front of the
# environment variable. These are used to ensure a given resource is provided
# by a specific stratum. For example, this ensures `reboot` is provided by the
# init stratum.
#
# - INFIX:<envvar> entries. These are used to ensure a given entry comes from
# the local stratum. For example, some software may request to be launched by
# sh via `#!/usr/bin/env sh` but utilize bash-isms which are valid on some
# distros which symlink `sh` to `bash`, but not others which don't. Such
# software must use the local stratum's `sh` to ensure the `bash` shell they
# expect is utilized.
#
# - SUFFIX:<envvar> entries. Bedrock ensures these are at the end of the
# environment variable. Given the PREFIX:<envvar> (specific stratum) and
# INFIX:<envvar> (local stratum) do not contain the item, it likely does not
# matter which stratum provides it, and so this contains resources from any
# strata which provide the resource.
#
#
# A list of directories searched by various programs to find executables.
#
PREFIX:PATH = /bedrock/cross/pin/bin:/bedrock/bin
INFIX:PATH = /usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin:/usr/local/games:/usr/games
SUFFIX:PATH = /bedrock/cross/bin
#
# A list of directories searched by the man executable to find documentation.
#
PREFIX:MANPATH = /bedrock/cross/pin/man:/bedrock/share/man
INFIX:MANPATH = /usr/local/share/man:/usr/share/man:/bedrock/cross/man
SUFFIX:MANPATH = /bedrock/cross/man
#
# A list of directories searched by the info executable to find documentation.
#
PREFIX:INFOPATH = /bedrock/cross/pin/info:/bedrock/share/info
INFIX:INFOPATH = /usr/local/share/info:/usr/share/info
SUFFIX:INFOPATH = /bedrock/cross/info
#
# A list of directories used by the freedesktop.org standard containing things
# such as icons and application descriptions.
#
PREFIX:XDG_DATA_DIRS = /bedrock/cross/pin
INFIX:XDG_DATA_DIRS = /usr/local/share:/usr/share
SUFFIX:XDG_DATA_DIRS = /bedrock/cross
#
# Terminfo file locations
#
PREFIX:TERMINFO_DIRS = /bedrock/cross/pin/terminfo
INFIX:TERMINFO_DIRS = /usr/local/share/terminfo:/usr/share/terminfo
SUFFIX:TERMINFO_DIRS = /bedrock/cross/terminfo
#
# zsh tab completion information
#
# No INFIX here; just pick up from zsh initialization.
#
PREFIX:fpath = /bedrock/share/zsh/completion
SUFFIX:fpath = /bedrock/cross/zsh-completion
[restriction]
#
# Some programs become confused upon discovering software from other distros.
# To avoid this, Bedrock can restrict such software to its own stratum (and
# global paths) by removing cross paths from various environment variables.
#
# This is primarily needed for software which discovers dependencies in
# preparation for compiling, such as Arch Linux's makepkg. However, it may be
# useful for other programs as well.
#
# This only affects processes which are run through `strat` or /bedrock/cross.
# To ensure unwrapped calls are run through cross, configure pin entries under
# [cross-bin].
#
# List any commands you would like restricted here.
#
restrict = apt-key, cave, cmake, debuild, dkms, dpkg-buildpackage, firecfg, firejail, firetools, gdb, git, kiss, makepkg, pkgmk, prt-get, rpmbuild
[cross]
#
# Bedrock Linux mounts a virtual filesystem at
#
# /bedrock/cross
#
# which provides an alternative view of various files from the enabled strata.
# This view is used for cross-stratum coordination.
#
# For the [cross-*] sections below, the keys represent file paths appended to
# /bedrock/cross, and the values are a list of files or directories to be
# searched for contents for the given file path. For example,
#
# man = /usr/local/share/man, /usr/share/man
#
# indicates that /bedrock/cross/man should be populated with the contents of
# the /usr/local/share/man and /usr/share/man directories of all of the enabled
# strata.
#
# The paths used for values may be prefixed by "<stratum>:" indicating the
# given file/directory should only be considered from a specific stratum. For
# example,
#
# pin/bin/firefox = arch:/usr/bin/firefox, void:/usr/bin/firefox
#
# Indicates a file at /bedrock/cross/pin/bin/firefox should be provided by
# arch if available, or if not then void; otherwise, the file should not exist.
#
# The following environment variables are also valid values:
#
# $PATH, $MANPATH, $INFOPATH, $XDG_DATA_DIRS, $TERMINFO_DIRS, $fpath
#
# These are parsed from per-stratum /etc/profile.d and expanded appropriately.
# For example,
#
# man = $MANPATH
#
# acts similarly to the above man example, but will detect new $MANPATH entries
# described by /etc/profile.d drop-in configuration.
#
# Environment variable entries may optionally have a "<stratum>:" prefix and/or
# a "/additional/path" suffix. For example:
#
# pin/bin/reboot = init:$PATH/reboot
#
# will expand to "init:<path>/reboot" for all $PATH entries.
#
#
# If a value does not have a stratum prefixed, it may be provided by any
# stratum that has the file. If multiple do, the values in "priority" below
# indicate which should be given priority. Any enabled strata left unspecified
# are implicitly appended at the end in an unspecified order. For example,
#
# priority = gentoo, debian
#
# indicates that for the `man` example above, if gentoo provides the given man
# page, gentoo's version should be provided. Otherwise, if debian does, then
# debian's should be provided. Otherwise, any stratum that provides the man
# page may provide it.
#
priority =
[cross-pass]
#
# Files accessed here are passed through from the stratum's version unaltered.
#
man = $MANPATH
info = $INFOPATH
icons = $XDG_DATA_DIRS/icons
pixmaps = $XDG_DATA_DIRS/pixmaps
themes = $XDG_DATA_DIRS/themes
backgrounds = $XDG_DATA_DIRS/backgrounds
zoneinfo = /usr/share/zoneinfo
terminfo = $TERMINFO_DIRS
src = /usr/local/src, /usr/src
bash-completion = /usr/share/bash-completion
zsh-completion = $fpath
firmware = /lib/firmware/updates/UTS_RELEASE, /lib/firmware/updates, /lib/firmware/UTS_RELEASE, /lib/firmware
[cross-bin]
#
# Files are executables. Executing these files should implicitly redirect
# through `strat <stratum>`.
#
bin = $PATH
#
# These programs are strongly related to the init system. If the stratum
# providing init provides these commands, that version should take priority.
# Typical Bedrock systems have /bedrock/pin/bin/ at the front of the $PATH.
#
pin/bin/service = init:$PATH/service
pin/bin/systemctl = init:$PATH/systemctl
pin/bin/rc-service = init:$PATH/rc-service
pin/bin/rc-status = init:$PATH/rc-status
pin/bin/rc-update = init:$PATH/rc-update
pin/bin/rc-udevadm = init:$PATH/rc-udevadm
pin/bin/sv = init:$PATH/sv
pin/bin/poweroff = init:$PATH/poweroff
pin/bin/reboot = init:$PATH/reboot
pin/bin/shutdown = init:$PATH/shutdown
pin/bin/halt = init:$PATH/halt
# [restriction]/restrict items are only restricted if run through strat or
# cross. List any such items here to ensure they are run through cross to be
# restricted.
#
# If a local instance is available, that is preferred over crossing strata
# boundaries, just in case there is some dependency on its specific quirks.
# Ensure all items here use the local alias. If the item is not available
# locally, the call will fall through to un-pinned `bin` above.
pin/bin/apt-key = local:$PATH/apt-key
pin/bin/cave = local:$PATH/cave
pin/bin/cmake = local:$PATH/cmake
pin/bin/debuild = local:$PATH/debuild
pin/bin/dkms = local:$PATH/dkms
pin/bin/dpkg-buildpackage = local:$PATH/dpkg-buildpackage
pin/bin/firecfg = local:$PATH/firecfg
pin/bin/firejail = local:$PATH/firejail
pin/bin/firetools = local:$PATH/firetools
pin/bin/gdb = local:$PATH/gdb
pin/bin/git = local:$PATH/git
pin/bin/kiss = local:$PATH/kiss
pin/bin/makepkg = local:$PATH/makepkg
pin/bin/pkgmk = local:$PATH/pkgmk
pin/bin/prt-get = local:$PATH/prt-get
pin/bin/rpmbuild = local:$PATH/rpmbuild
[cross-ini]
#
# Files are in ini format. These files are modified so that their contents
# should work across stratum boundaries. For example, `Exec` keys may have
# their values prefixed with `strat <stratum>` to ensure they work across
# stratum boundaries.
#
applications = $XDG_DATA_DIRS/applications
xsessions = init:$XDG_DATA_DIRS/xsessions, $XDG_DATA_DIRS/xsessions
wayland-sessions = init:$XDG_DATA_DIRS/wayland-sessions, $XDG_DATA_DIRS/wayland-sessions
dbus-system = /usr/share/dbus-1/system-services
dbus-session = /usr/share/dbus-1/services
[cross-font]
#
# Values are font directories. Fonts are passed through, and font databases
# are merged to list all fonts.
#
fonts = /usr/share/fonts
[pmm]
#
# Package Manager Manager
#
# A typical Bedrock Linux system has multiple package managers. Bedrock's
# Package Manager Manager, or pmm, acts as a front-end for these and provides
# multi-package-manager and cross-package-manager operations.
#
#
# The command line user interface pmm should utilize.
#
# See file names in /bedrock/share/pmm/package_managers/ for available options.
#
# For example, to mimic Debian/Ubuntu/etc's apt user interface, set:
#
# user-interface = apt
#
# Or to mimic Arch's pacman user interface, set:
#
# user-interface = pacman
#
user-interface =
#
# List indicating the order package managers should be considered by pmm. Any
# available package manager not included will be considered after this list in
# an undefined order.
#
# List entries may have any of the following patterns:
#
# - `<stratum>:<package-manager>`, indicating a specific stratum's specific
# package manager.
# - `<stratum>:`, indicating any/all package managers in the
# given stratum.
# - `:<package-manager>`, indicating a specific package manager from any
# stratum.
#
# For example:
#
# priority = alpine:, debian:apt, arch:pacman, centos:, :pip
#
priority =
#
# If true, only system package managers such as `apt` or `pacman` will be
# considered by pmm.
#
# If false, non-system-package managers such as `pip` or `yay` will be
# considered as well.
#
# `priority` overrides this setting and may be used to white list specific
# non-system package managers while others remain ignored.
#
ignore-non-system-package-managers = true
#
# To black list specific strata from pmm, `brl hide --pmm <stratum>` the
# stratum. See `brl hide --help` and `brl show --help`.
#
#
# Some package managers such as yay recommend against running as root. If pmm
# is called as root, pmm will call such package managers with this user via
# `sudo`.
#
# sudo sets $SUDO_USER accordingly and is thus a good general default if pmm is
# called via sudo. If you do not use this, consider setting it either your
# primary user or a dedicated unprivileged user.
#
unprivileged-user = $SUDO_USER
#
# Most package managers support only a subset of available operations. If a
# given package manager is unable to fulfill an operation, it is skipped.
#
# If true, print a warning when skipping package manager because it does not
# support the requested operation.
#
# If false, skip package managers silently.
#
warn-about-skipping-package-managers = true
#
# pmm cache settings
#
# Many pmm operations query multiple package managers, the sum of which may be
# undesirably slow. When run as root, pmm can cache pre-calculate and cache
# data to speed up future queries. However, this caching operation takes time
# and its utilization risks missing cache invalidation cues.
#
# See `[miscellaneous]` `cache-life` to control how long cached values remain
# on disk.
#
#
# If true, pmm will cache the list of package managers to consider.
#
# If false, pmm will build list of available package managers every operation.
#
# This cache is updated on changes to bedrock.conf or the list of
# non-pmm-hidden, enabled strata. It will miss the addition of new package
# managers within a preexisting stratum, such as would occur if one ran `apt
# install python-pip`.
#
# This cache size varies depending on the number of package managers available
# on the system. It may use tens of kilobytes of disk space in total.
#
cache-package-manager-list = true
#
# If true, pmm will cache the list of available packages and some of their
# metadata. This speeds up internal look-ups about available packages.
#
# If false, pmm will query underlying package managers every time it needs to
# learn about possible available packages.
#
# This cache is updated after pmm is instructed to update package manager
# databases (e.g. `pmm update`, `pmm -Syu`, etc). It may become outdated if
# package managers update their databases outside of pmm.
#
# This cache size and caching time varies heavily depending on the number of
# packages a given package manager has available. It may use tens of megabytes
# of disk space per package manager.
#
cache-package-database = true
[brl-fetch-mirrors]
#
# `brl fetch` fetches files from distros for use as Bedrock Linux strata.
#
# If a mirror is provided to the `brl fetch` command, it is used to fetch the
# given distro. Otherwise, this configuration is checked to see if it
# specifies a given mirror should be tried. If no working mirror is found
# here, `brl fetch` will attempt to select a mirror from those it finds for the
# given distribution.
#
#
# Some mirrors support multiple Linux distributions and use the same prefix
# path for all of them. For example, at the time of writing, there is an Arch
# mirror at
#
# http://mirrors.edge.kernel.org/archlinux
#
# and a CentOS mirror at
#
# http://mirrors.edge.kernel.org/centos
#
# and a Debian mirror at:
#
# http://mirrors.edge.kernel.org/debian
#
# and a Fedora mirror at
#
# http://mirrors.edge.kernel.org/fedora
#
# Rather than configuring each of these separately, the base URL can be added
# to mirror-prefix to tell `brl fetch` to check it as a possible mirror. For
# the above kernel.org example, one may set:
#
# mirror-prefix = http://mirrors.edge.kernel.org
#
# This is a comma separated list which is checked in order.
#
mirror-prefix =
#
# You may set mirrors per distro by setting the distro name as spelled by
#
# brl fetch --list
#
# as the key and the mirror as the value. For example, to indicate that Ubuntu
# should be fetched with the mirror
#
# http://us.archive.ubuntu.com/ubuntu
#
# One may set
#
# ubuntu = http://us.archive.ubuntu.com/ubuntu
#
[brl-update]
#
# Set mirrors to one or more Bedrock Linux releases file URLs.
#
# Most users are recommend to stick with the stable release channel here:
#
# mirrors = https://raw.githubusercontent.com/bedrocklinux/bedrocklinux-userland/0.7/releases
#
# However, if you would like to help test upcoming Bedrock updates and are
# willing to take the associated risks, a beta channel is available as well.
# It should be added in addition to the stable channel so that you're always on
# whichever is newer between the two:
#
# mirrors = https://raw.githubusercontent.com/bedrocklinux/bedrocklinux-userland/0.7/releases, https://raw.githubusercontent.com/bedrocklinux/bedrocklinux-userland/0.7beta/releases
#
mirrors = https://raw.githubusercontent.com/bedrocklinux/bedrocklinux-userland/0.7/releases
[miscellaneous]
#
# Time to retain Bedrock cached data (such as from brl-fetch) in days.
#
cache-life = 30
#
# Set to false to disable color in brl output
#
color = true
#
# Enable debugging for specified subsystems.
#
# Possible values include:
# - etcfs
# - brl-fetch
#
debug =

View File

@ -0,0 +1,7 @@
NAME="Bedrock Linux"
ID=bedrock
ID_LIKE=bedrocklinux
VERSION=
VERSION_ID=
PRETTY_NAME=
HOME_URL="https://bedrocklinux.org"

View File

@ -0,0 +1,25 @@
#
# Package Manager Manager world file
#
# This file is expected to contain a list of
#
# <stratum>:<package-manager><whitespace><package-name>
#
# entries which `pmm` can utilize synchronize against the system's list of
# explicitly installed packages. A given line may contain multiple white space
# separated package names. For example:
#
# ### Bedrock Linux `make check` dependencies
# # compilers
# arch:pacman gcc clang
# # static check tools
# arch:pacman cppcheck shellcheck
# # formatting tools
# arch:pacman indent shfmt
# # libraries
# arch:pacman fuse3 uthash
#
# See `pmm --help | grep world` for a list of world file
# operations.
#

View File

@ -0,0 +1,52 @@
-----BEGIN PGP PUBLIC KEY BLOCK-----
mQINBFM8nLkBEADmFjFEW2HUC1Z4YF8ij4hI/3/QI8Qbecax8bwfQcxQDjMmSNrN
V51lon4Ww2B2dGVBtBtpqcGtS8fyTWP1MvOnJ0QyEO0wygv1GmUAkAzo2BMKm20k
DPQEU1hk5R3QRpSC27WXQHklfr8OXb7YyKalV8gcpeIwX0rJll4to247fhmUDZ1H
zrMZ1xd2WLHsmMhsUfcr2Ivg+olR+bSBYXa4sV8kWGTRE4DGXDt39oEClFhyoKif
KrAwCueQlyW9h+PKbzVvh4hDRm+Ql8UUOXUn7f18+KMAcck1f9gEI1NKYR5Bho02
yYdMrA2ohiEmFqJRPGxruSChHY1hv9PyD8e2dAjg7amdqIu9tP1Yue7i2iDzDIyV
3yc59dbec7gFaKuCNEuyg/uycyFiNO24Luof0Icb8LKBePqGiJr+U08T7Gkgqmms
YksGAi99vhafd6KGHIH8kGcI/ugVdmn2stqPTG0Tu3BpPrB0dR1Zor/ILE4Iv4M4
TmNdnWrWRA/Y4ueuqFEsM+p8zwv+QBLXqx7a/Xni6OSvMA4z/pN8bc+Z2pwB5r8V
phedtxVZ5EslwjZOgAfOLEu4nZiGnSWazrmEOIwpD0aEwklFkLEcX9Bi+pTyOCPe
3RNtHHp2kUlz4oQdTR9I+4be9qCKh8DicOLhFB19icnoN0sXt+q9UTxt+QARAQAB
tDFEYW5pZWwgVGhhdSAocGFyYWRpZ20pIDxkYW50aGF1QGJlZHJvY2tsaW51eC5v
cmc+iQJVBBMBAgA/AhsDBgsJCAcDAgYVCAIJCgsEFgIDAQIeAQIXgBYhBLebcnTR
OrCfZoPlWA8lNQyY97IHBQJdWHaKBQkRoKfRAAoJEA8lNQyY97IHbkIQANU+Bf6F
KPeyBZKdOBzpdpPVKIhoeV8G7ahjkGo2Cnm3GsWRXMW0uQKBWiT+GhirfVzR05w+
QZ69y84InKG7sGAF0AOkPbZJFAEEVGSWGpmgjpFsOGW1v0VsA+s77LnYokFu2U6S
0iOQIqAq0ly24+hrBymyEl1LuGHjKphcfI+x5BcE0HbUb16rE196Gqcr+uHBCXy0
5I1GbR9qtYd7LKHyKbqQg340wVu4RBKfutEvcaarPDwm/kLVGXaOlqYzOqxMtVDp
WB9NmPzIdpf1EQWiyg91Jn3cZibe+RjjxS1kqjx03xl/zHjq7vwRJDshD8tMHCYS
m222I1JfLKejpiOyqOPcCNFENOCsI9g4dVclb+EHlYQ2XbErhMSvsjWe1P8eWka1
O3U5k2P31mXQkvN3VBVxAb7d/ad4rIj5AFMbTiAWjH9GYdiL5HAissXiCevOATyC
ARmsGU5vJ+jqQ/L3dgX3hRkvqV84pSl3Sut3LQISbh9KI/HS5NJ4d7sDOtxOZIxz
tYrBzw1gIK4QHiTdWmGU41vPyN+YlfOeYwhaN6z9lWEa7oQcoLVApMsmBMYzzS+f
sbDo22IgtsU5LGR4wd9w+2pSby3e6i62NIhvEPwgDKOUSplGdUZByCYniv9VFlSw
0xUYpYCNMFi38cxl5cdfa9byy6SIAXKZpiAuuQINBFM8nLkBEADi3uIVcHvvovA7
AEskKU5HeqJYv/tFeN8Z8VeYrh4o3VyvhjW+yVAYwjWvVAYLiW9LyX/tQfLXVC25
Hzyghf7OU9Fjvil84OmfatAdYQssQeGIDb+QWUzQx7GTGRpO/JMOxUXoLVjCAuAm
GlfTjbjqgmnS57tYRvkZjwVI47Q2R1d70da2fKPlwE8bCesRd0GyaCvSMdztCmgR
LCa6zTZGWPTic6ej54kxA388BE7zUlp6trSe5QkQNv9gmBBsm8uMEZw54EMjnUmq
JR855yPM2M9HQ0CCjtde4XmdqIn2ykAu25XnmPEly1Xadux+2LTauPrfeBvBQRrm
yK8A4/xcJ0Z2IT5ShQ1POZbzeMdqTEP2zBt/vwho0RaguSUctCv8WeEHA9gkgfI4
gP2mSpGonsHj8Tv0S1UnsAJbO7+1orui2uCA/yFVzzwK4w9e+QJRK3Ovy7m1ds/C
4v4yxmZRrX7DuYuQdtvhLFEDALGXBV/aCM5NQGo9HA8+OyhY7FLr8cflHbOWgTMp
p/B71ZUkyKv4qyYxv1keJlf5Dny67FHCBGr+iNw7c7qRkI/PQyzYPk87HjBvSPYo
WILuky9UWs4anefJss6h9so1Ns99oAbgxJjlRtCg+9gmTg01+NCTB2HD4dpIuo8r
3oimkANOJF9qEwjqNimi81a0uJmBGQARAQABiQI8BBgBAgAmAhsMFiEEt5tydNE6
sJ9mg+VYDyU1DJj3sgcFAl1YdscFCRGgqA4ACgkQDyU1DJj3sgcGcRAAmpmgmqlX
Mt0T62chqUGdP3TrwzIq0Xl6zc7lxAGu3WJerGAPnSCnRiq3PdkRSs0Oz0XQCK42
LnmPoZeRoHJCWdtG3v0JCy6TlV/13vG56Fi/CFJ7LX/fectgXxdRXfOZjPyxBccj
cUuVnbF2NUoAhDWCn+P7Cc2Gu2ZbAR+usP91cgooH38vlHx97eP5Z/wdjY4ltznG
oZz9hC6de/6Gi9VZYSzqUjeWSK4s/Ah5oo3v4j3/oOv6Q3Tv0jAfRlv0dYDHGZiS
5BcN6zu69waI1H1SMCkfYncUOEiafNdsKwKlwxHfgh0FKISS+ot4D/5b9XYJ5YNJ
7mMm9zIv2IDLQPMAh5KFmISP+6KlIXFL6to7X0xFuBpzdlBJETLgMKD2xM/yPYnj
Z294Dx54tzp91UDaDtUCSNgzmZ36F97aWCWdgJPPVfsQY0l4wMIpGHN0de26CyH8
/OL3tjqPTfkWskgYBjb1uibd+fL41MQwRHjLwFVotlGGM9SPAkz1rbm58re5Hq3c
7aBskBLvheJd/s4WAqaApxs4iaQ8BB0IuIuzq3zDDtVrvAM3j1DyoKiKLeS40lTw
9r2XlOa2IJBXmaA3i8UENGJbvXR1nsJBwWXlkwjjMxJ/U/X0rFbdyMtd+zY8B03T
pDFSUaW25oAiCPhToTk5q2F5nl/VzMhgXd8=
=vp73
-----END PGP PUBLIC KEY BLOCK-----

View File

@ -0,0 +1,62 @@
#!/bedrock/libexec/busybox sh
#
# brl alias
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# version 2 as published by the Free Software Foundation.
#
# Copyright (c) 2018 Daniel Thau <danthau@bedrocklinux.org>
#
# Create stratum aliases.
. /bedrock/share/common-code
print_help() {
printf "Usage: ${color_cmd}brl alias ${color_sub}[options] <stratum> <alias>${color_norm}
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}
name in most contexts. Requires root.
Options:
${color_cmd}-h${color_norm}, ${color_cmd}--help${color_norm} print this message
Example:
${color_rcmd}# brl fetch fedora --release 27 --name fedora27
${color_cmd}$ brl list | grep fedora
${color_strat}fedora27
${color_rcmd}# brl alias fedora27 fedora
${color_cmd}$ brl deref fedora
${color_strat}fedora27
${color_cmd}$ brl status fedora
${color_strat}fedora27${color_norm}: ${color_okay}enabled
${color_cmd}$ cat /bedrock/strata/fedora27/etc/fedora-release
${color_norm}Fedora release 27 (Twenty Seven)
${color_cmd}$ cat /bedrock/strata/fedora/etc/fedora-release
${color_norm}Fedora release 27 (Twenty Seven)
${color_cmd}$ strat fedora27 cat /etc/fedora-release
${color_norm}Fedora release 27 (Twenty Seven)
${color_cmd}$ strat fedora cat /etc/fedora-release
${color_norm}Fedora release 27 (Twenty Seven)
${color_norm}"
}
handle_help "${@:-}"
min_args "${#}" "2"
stratum="${1}"
alias="${2}"
require_root
lock
ensure_legal_stratum_name "${alias}"
if ! is_stratum "${stratum}"; then
abort "No (non-alias) stratum found called \"${stratum}\". Refusing to make broken alias."
elif is_stratum_or_alias "${alias}"; then
abort "Pre-existing stratum or alias found called \"${alias}\". Remove with \`brl remove ${alias}\` first if you wish to change it."
fi
ln -s "${stratum}" "/bedrock/strata/${alias}"
exit_success

View File

@ -0,0 +1,448 @@
#!/bedrock/libexec/busybox sh
#
# brl apply
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# version 2 as published by the Free Software Foundation.
#
# Copyright (c) 2018-2020 Daniel Thau <danthau@bedrocklinux.org>
#
# (re)loads configuration
. /bedrock/share/common-code
# Remove typical runtime sanity checks, as leaving a system half-configured is
# worse than aborting mid-configure.
set +eu
trap '' EXIT
print_help() {
printf "Usage: ${color_cmd}brl apply ${color_sub}[options]${color_norm}
Apply ${color_file}/bedrock/etc/bedrock.conf${color_norm} configuration changes. Requires root.
Options:
${color_cmd}-h${color_norm}, ${color_cmd}--help${color_norm} print this message
Example:
${color_cmd}$ brl which startx
${color_strat}debian
${color_rcmd}# vim /bedrock/etc/bedrock.conf
${color_sub}<pin startx to arch>
${color_cmd}$ brl which startx
${color_strat}debian
${color_rcmd}# brl apply
${color_cmd}$ brl which startx
${color_strat}arch
${color_norm}"
}
handle_help "${@:-}"
require_root
if [ "${1:-}" != "--skip-repair" ]; then
# Repair strata to apply stratum-status changing configuration
/bedrock/libexec/brl-repair --skip-crossfs "bedrock"
/bedrock/libexec/brl-repair --skip-crossfs "init"
for stratum in $(list_strata); do
is_bedrock "${stratum}" && continue
is_init "${stratum}" && continue
is_enabled "${stratum}" || continue
/bedrock/libexec/brl-repair --skip-crossfs "${stratum}"
done
fi
# lock after brl-repair above, as it locks
lock
# Various fields below manage the timezone. Timezone information should not be
# read from /usr/share/zoneinfo because:
# - It is a local file and different strata could have differing values, which
# would result in subtle time issues which would be difficult for users to
# detect or debug. Using /bedrock/cross ensures a consistent timezone value
# across all strata.
# - Some strata may not have a locale zoneinfo database, which means they must
# look into /bedrock/cross.
#
# We cannot use TZ=:/etc/localtime or TZ=:/bedrock/cross/zoneinfo/<timezone>
# because of a bug in chromium and the many programs which build off of
# chromium:
# https://bugs.chromium.org/p/chromium/issues/detail?id=811403
# https://github.com/signalapp/Signal-Desktop/issues/3085
# https://github.com/ValveSoftware/steam-for-linux/issues/5612
# https://chromium-review.googlesource.com/c/chromium/deps/icu/+/1006219/
#
# By ensuring TZ is unset, all tested software including chromium, glibc, and
# musl, fall back to /etc/localtime, which is symlinked (eventually) to
# /bedrock/cross.
# Set up /etc/localtime
ln -fns "/bedrock/cross/zoneinfo/$(cfg_value "locale" "timezone")" /bedrock/run/localtime
# special case fpath
envvars="$(cfg_keys "env-vars" | sed 's/^[^:]*://g' | grep -v "^fpath$" | sort | uniq)"
cfg_envvar() {
# Retain backwards compatibility with non-prefix/infix/suffix config
# system.
whole="$(cfg_value "env-vars" "${1}")"
if [ -n "${whole}" ]; then
echo "${whole}"
return
fi
prefix="$(cfg_value "env-vars" "PREFIX:${1}")"
infix="$(cfg_value "env-vars" "INFIX:${1}")"
suffix="$(cfg_value "env-vars" "SUFFIX:${1}")"
echo "${prefix}:${infix}:${suffix}"
}
# Setup /etc/environment
cat <<EOF >/bedrock/run/environment
LANG=$(cfg_value "locale" "LANG")
$(
for envvar in ${envvars}; do
echo "${envvar}=$(cfg_envvar "${envvar}")"
done
)
EOF
# Setup /etc/profile
cat <<EOF >/bedrock/run/profile
#!/bin/sh
[ -n "\${BEDROCK_RESTRICT:-}" ] && return
br_dedup_envvar() {
envvar=""
prefix="\${1}"
suffix="\${2}"
IFS=":"
[ -n "\${ZSH_VERSION:-}" ] && setopt sh_word_split
for i in \${prefix}; do
case ":\${envvar}:\${suffix}:" in
*":\${i}:"*) ;;
*) envvar="\${envvar}:\${i}" ;;
esac
done
for i in \${suffix}; do
case ":\${envvar}:" in
*":\${i}:"*) ;;
*) envvar="\${envvar}:\${i}" ;;
esac
done
echo "\${envvar}" | sed -e 's/::*/:/g' -e 's/^://' -e 's/:$//'
}
for line in \$(
cd /
for s in \$(/bedrock/bin/brl list); do
[ -r "/bedrock/strata/\${s}/etc/profile" ] || continue
/bedrock/bin/strat -r "\${s}" /bin/sh -c '
. /etc/profile;
$(
for envvar in ${envvars}; do
printf "\t\techo \"%s=\${%s}\";\n" "${envvar}" "${envvar}"
done
) ' &
done
wait
); do
case "\${line}" in
$(
for envvar in ${envvars}; do
printf "\t\"%s=\"*) %s=\"\${%s}:\${line#*=}\";;\n" "${envvar}" "${envvar}" "${envvar}"
done
)
esac
done
unset line
unset TZ
export LANG="$(cfg_value "locale" LANG)"
$(
# shellcheck disable=SC2030
for envvar in ${envvars}; do
printf "export %s=\"\$(br_dedup_envvar \"%s:\${%s}\" \"%s\")\"\n" \
"${envvar}" \
"$(cfg_value "env-vars" "PREFIX:${envvar}"):$(cfg_value "env-vars" "${envvar}"):$(cfg_value "env-vars" "INFIX:${envvar}")" \
"${envvar}" \
"$(cfg_value "env-vars" "SUFFIX:${envvar}")"
done
)
unset -f br_dedup_envvar
EOF
# Setup /etc/zsh/zprofile, /etc/zprofile
cat <<EOF >/bedrock/run/zprofile
#!/usr/bin/env zsh
[ -n "\${BEDROCK_RESTRICT:-}" ] && return
# zsh does not read /etc/profile by default. Some distros configure it to,
# some do not.
. /bedrock/run/profile
br_dedup_envvar() {
envvar=""
prefix="\${1}"
suffix="\${2}"
IFS=":"
for i in \${prefix}; do
case ":\${envvar}:\${suffix}:" in
*":\${i}:"*) ;;
*) envvar="\${envvar}:\${i}" ;;
esac
done
for i in \${suffix}; do
case ":\${envvar}:" in
*":\${i}:"*) ;;
*) envvar="\${envvar}:\${i}" ;;
esac
done
echo "\${envvar}" | sed -e 's/::*/:/g' -e 's/^://' -e 's/:$//'
}
$(
printf "export fpath=(\$(br_dedup_envvar \"%s:\${fpath}\" \"%s\" | sed 's/:/ /g'))\n" \
"$(cfg_value "env-vars" "PREFIX:fpath"):$(cfg_value "env-vars" "fpath"):$(cfg_value "env-vars" "INFIX:fpath")" \
"$(cfg_value "env-vars" "SUFFIX:fpath")"
)
EOF
# Setup /etc/fish/conf.d/ configuration
cat <<EOF >/bedrock/run/fprofile
[ -n "\$BEDROCK_RESTRICT" ]; and exit 0
function br_dedup_envvar
set -l envvar
set -l prefix \$argv[1]
set -l suffix \$argv[2]
for i in (string split ":" \$prefix)
if not contains \$i \$envvar; and not contains \$i \$suffix; and [ -n "\$i" ]
set -a envvar \$i
end
end
for i in (string split ":" \$suffix)
if not contains \$i \$envvar; and [ -n "\$i" ]
set -a envvar \$i
end
end
echo -s :\$envvar | sed -e 's/::*/:/g' -e 's/^://' -e 's/:$//'
end
set -e TZ
set -x LANG $(cfg_value "locale" "LANG")
$(
for envvar in ${envvars}; do
printf "set -x %s (br_dedup_envvar \"%s:\$%s\" \"%s\")\n" \
"${envvar}" \
"$(cfg_value "env-vars" "PREFIX:${envvar}"):$(cfg_value "env-vars" "${envvar}"):$(cfg_value "env-vars" "INFIX:${envvar}")" \
"${envvar}" \
"$(cfg_value "env-vars" "SUFFIX:${envvar}")"
done
)
functions -e br_dedup_envvar
EOF
# Setup /etc/sudoers configuration
cat <<EOF >/bedrock/run/sudoers
Defaults secure_path="$(cfg_envvar "PATH")"
Defaults env_keep+="BEDROCK_RESTRICT"
EOF
# Configure crossfs. Items below reference crossfs, and so this should be done
# early. However, not too early; it requires /bedrock/run/profile.
cfg_crossfs "/proc/1/root/bedrock/strata/bedrock/bedrock/cross"
# configure etcfs
for stratum in $(/bedrock/bin/brl list -ei); do
root="$(stratum_root "${stratum}")"
cfg_etcfs "/proc/1/root${root}/etc"
done
# Configure cross firmware.
if [ -w /sys/module/firmware_class/parameters/path ] && [ -d /bedrock/cross/firmware ]; then
printf "/bedrock/cross/firmware" >/sys/module/firmware_class/parameters/path
fi
# Specify commands which should automatically be restricted in an easily parsed
# format for strat.
mkdir -p /bedrock/run/restricted_cmds/
for cmd in $(cfg_values "restriction" "restrict"); do
touch "/bedrock/run/restricted_cmds/${cmd}"
done
if echo /bedrock/run/restricted_cmds/* >/dev/null 2>&1; then
for file in /bedrock/run/restricted_cmds/*; do
found=false
for cmd in $(cfg_values "restriction" "restrict"); do
if [ "$(basename "${file}")" = "${cmd}" ]; then
found=true
break
fi
done
if ! "${found}"; then
rm "${file}"
fi
done
fi
# Setup xorg.conf configuration
if [ -d /bedrock/cross/fonts ]; then
(
echo "Section \"Files\""
find /bedrock/cross/fonts -mindepth 1 -type d -exec echo " FontPath \"{}\"" \;
echo "EndSection"
) >/bedrock/run/xorg-fonts
fi
# Configure /etc/login.defs
if [ -r /etc/login.defs ] && awk -F'=' -v"path=$(cfg_value "env-vars" "PATH")" '
# Ensure login.defs uses Bedrock $PATH.
#
/^[ \t]*ENV_SUPATH[ \t][ \t]*/ && $2 == path {s=1}
/^[ \t]*ENV_PATH[ \t][ \t]*/ && $2 == path {n=1}
END {exit (s+n==2)}' /etc/login.defs; then
awk -F'=' -v"path=$(cfg_envvar "PATH")" '
/^[ \t]*ENV_SUPATH[ \t][ \t]*/ {
print "ENV_SUPATH\t"path
s=1
next
}
/^[ \t]*ENV_PATH[ \t][ \t]*/ {
print "ENV_PATH\t"path
n=1
next
}
1
END {
if(s == 0) {
print "ENV_SUPATH\t"path
}
if(n == 0) {
print "ENV_PATH\t"path
}
}
' /etc/login.defs >/etc/login.defs-new
mv /etc/login.defs-new /etc/login.defs
fi
# Configure /etc/fstab
if [ -r /etc/fstab ] && awk '$1$2$3$4$5$6 !~ "#" && $6 != "" && $6 != 0 {x=1} END {exit !x}' /etc/fstab; then
# Bedrock creates bind mounts referencing the root directory which
# confuse various init systems attempts to fsck the root directory.
# Thus, disable configuration indicating the root directory should be
# fscked.
awk '
$1$2$3$4$5$6 !~ "#" && $6 != "" && $6 != 0 {
$6 = "0"
}
{
print
}
' /etc/fstab >/etc/fstab-new && mv /etc/fstab-new /etc/fstab
fi
# Disable SELinux
for stratum in $(/bedrock/bin/brl list -ei); do
root="$(stratum_root --empty "${stratum}")"
seconfig="/proc/1/root${root}/etc/selinux/config"
if grep -q '^SELINUX=enforcing' "${seconfig}" 2>/dev/null || grep -q '^SELINUX=permissive' "${seconfig}" 2>/dev/null; then
sed 's/^SELINUX=/SELINUX=disabled/' "${seconfig}" >"${seconfig}-"
mv "${seconfig}-" "${seconfig}"
fi
done
# Force login shells to use cross path to ensure they are available to all
# programs which may call them. This is particularly important to allow users
# to login when the login software comes from a stratum which does not directly
# provide the user's configured shell.
need_shell_change=false
while read -r line; do
shell="$(echo "${line}" | awk -F":" '{print$7}')"
subline="$(echo "${line}" | awk -F":" -vOFS=":" '{$7="";print}')"
name="$(basename "${shell}")"
crosspath="/bedrock/cross/bin/$(basename "${shell}")"
if echo "${shell}" | grep -q '^/bedrock/cross/'; then
true
elif ! [ -x "${crosspath}" ]; then
true
else
need_shell_change=true
break
fi
done </etc/passwd
if "${need_shell_change}"; then
cp -a /etc/passwd /etc/passwd-
while read -r line; do
shell="$(echo "${line}" | awk -F":" '{print$7}')"
subline="$(echo "${line}" | awk -F":" -vOFS=":" '{$7="";print}')"
name="$(basename "${shell}")"
crosspath="/bedrock/cross/bin/$(basename "${shell}")"
if echo "${shell}" | grep -q '^/bedrock/cross/'; then
echo "${line}"
elif ! [ -x "${crosspath}" ]; then
echo "${line}"
else
echo "${subline}/bedrock/cross/bin/${name}"
fi
done </etc/passwd >/etc/passwd-
if [ "$(cat /etc/passwd)" != "$(cat /etc/passwd-)" ] &&
[ "$(wc -l /etc/passwd | cut -d' ' -f1)" = "$(wc -l /etc/passwd- | cut -d' ' -f1)" ]; then
mv /etc/passwd- /etc/passwd
enforce_shells
else
rm /etc/passwd-
fi
fi
# Setup pmm front-end.
pmm_ui="$(cfg_value pmm user-interface)"
if [ "${pmm_ui}" = "" ]; then
notice "Set [pmm]/user-interface in bedrock.conf and run \`brl apply\` to update pmm front-end(s)"
else
pmm_ui_files="$(/bedrock/libexec/pmm "${pmm_ui}" pmm --list-pmm-ui-files 2>/dev/null)"
# Create front-end files
for file in ${pmm_ui_files}; do
tgt_contents="#!/bedrock/libexec/busybox sh
exec /bedrock/libexec/pmm ${pmm_ui} ${file} \"\${@}\""
tgt_path="/bedrock/bin/${file}"
if ! echo "${file}" | grep -q "^pmm"; then
echo "ERROR: pmm requests non-pmm front-end \"${file}\""
continue
elif [ -x "${tgt_path}" ] && [ "$(cat "${tgt_path}")" = "${tgt}" ]; then
continue
else
echo "${tgt_contents}" >"${tgt_path}"
chmod a+rx "${tgt_path}"
fi
done
# Remove outdated front-end files
cd /bedrock/bin/
if ls pmm* >/dev/null 2>&1; then
for file in pmm*; do
if echo "${pmm_ui_files}" | awk -vf="${file}" '$1 == f {exit 1}'; then
rm "${file}"
fi
done
fi
fi
# Patch s6 init to skip unmounting /run, as this breaks Bedrock's pre-init setup of /run
for stratum in $(/bedrock/bin/brl list -ei); do
init="$(realpath "/bedrock/strata/${stratum}/sbin/init")"
if ! grep -q "^s6-linux-init" "${init}" 2>/dev/null; then
continue
fi
if grep -q "^s6-linux-init -N " "${init}" 2>/dev/null; then
continue
fi
cp "${init}" "${init}-bedrock-patch"
sed 's/s6-linux-init /s6-linux-init -N /' "${init}" > "${init}-bedrock-patch"
mv "${init}-bedrock-patch" "${init}"
done
exit_success

View File

@ -0,0 +1,67 @@
#!/bedrock/libexec/busybox sh
#
# brl copy
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# version 2 as published by the Free Software Foundation.
#
# Copyright (c) 2018-2019 Daniel Thau <danthau@bedrocklinux.org>
#
# Copies strata.
. /bedrock/share/common-code
print_help() {
printf "Usage: ${color_cmd}brl copy ${color_sub}[options] <stratum> <new-stratum>${color_norm}
Copies a disabled ${color_term}stratum${color_norm}. Requires root.
Options:
${color_cmd}-h${color_norm}, ${color_cmd}--help${color_norm} print this message
Examples:
${color_rcmd}# brl fetch ubuntu
${color_cmd}$ brl list | grep ubu
${color_strat}ubuntu
${color_rcmd}# brl disable ubuntu
${color_rcmd}# brl copy ubuntu ubu-lts
${color_cmd}$ brl list -a | grep ubu
${color_strat}ubuntu
${color_strat}ubu-lts
${color_rcmd}# strat ubuntu apt dist-upgrade
${color_norm}"
}
handle_help "${@:-}"
min_args "${#}" "2"
alias="${1}"
new_stratum="${2}"
require_root
lock
ensure_legal_stratum_name "${new_stratum}"
if ! is_stratum_or_alias "${alias}"; then
abort "No stratum or alias found called \"${alias}\"."
elif ! stratum="$(deref "${alias}")"; then
abort "Unable to dereference \"${alias}\"."
elif is_enabled "${stratum}"; then
abort "Cannot copy enabled stratum. Disable first."
elif is_stratum_or_alias "${new_stratum}"; then
abort "Pre-existing stratum or alias found called \"${new_stratum}\". Remove with \`brl remove ${new_stratum}\` first if you wish to change it."
fi
if is_stratum "${stratum}"; then
disable_stratum "${stratum}"
fi
cp -a "/bedrock/strata/${stratum}" "/bedrock/strata/${new_stratum}"
for xattr in "show_boot" "show_cross" "show_init" "show_list"; do
if has_attr "/bedrock/strata/${stratum}" "${xattr}"; then
set_attr "/bedrock/strata/${new_stratum}" "${xattr}" ""
fi
done
exit_success

View File

@ -0,0 +1,52 @@
#!/bedrock/libexec/busybox sh
#
# brl deref
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# version 2 as published by the Free Software Foundation.
#
# Copyright (c) 2018 Daniel Thau <danthau@bedrocklinux.org>
#
# Dereference stratum aliases.
. /bedrock/share/common-code
print_help() {
printf "Usage: ${color_cmd}brl deref ${color_sub}[options] <strata>${color_norm}
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}.
Options:
${color_cmd}-h${color_norm}, ${color_cmd}--help${color_norm} print this message
Example:
${color_rcmd}# brl fetch fedora --release 27 --name fedora27
${color_rcmd}# brl fetch debian --release unstable --name sid
${color_rcmd}# brl alias fedora27 fedora
${color_rcmd}# brl alias sid unstable
${color_cmd}$ brl deref fedora
${color_strat}fedora27
${color_cmd}$ brl deref fedora27
${color_strat}fedora27
${color_cmd}$ brl deref unstable
${color_strat}sid
${color_cmd}$ brl deref sid
${color_strat}sid
${color_norm}"
}
handle_help "${@:-}"
min_args "${#}" "1"
for alias in "${@}"; do
if ! is_stratum_or_alias "${alias}"; then
abort "No stratum or alias called \"${alias}\"."
elif ! stratum="$(deref "${alias}")"; then
abort "Unable to dereference \"${alias}\"."
else
printf "${color_strat}%s${color_norm}\\n" "${stratum}"
fi
done
exit_success

View File

@ -0,0 +1,57 @@
#!/bedrock/libexec/busybox sh
#
# brl disable
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# version 2 as published by the Free Software Foundation.
#
# Copyright (c) 2012-2018 Daniel Thau <danthau@bedrocklinux.org>
#
# De-integrates strata from the system.
. /bedrock/share/common-code
print_help() {
printf "Usage: ${color_cmd}brl disable ${color_sub}[options] <strata>${color_norm}
De-integrates ${color_term}strata${color_norm} from the system.
Options:
${color_cmd}-h${color_norm}, ${color_cmd}--help${color_norm} print this message
Examples:
${color_cmd}$ brl status solus
${color_strat}solus${color_norm}: ${color_okay}enabled
${color_rcmd}# brl disable solus
${color_cmd}$ brl status solus
${color_norm}disabled
${color_rcmd}# brl disable alpine arch centos
${color_cmd}$ brl status alpine arch centos
${color_strat}alpine${color_norm}: ${color_norm}disabled
${color_strat}arch${color_norm}: ${color_norm}disabled
${color_strat}centos${color_norm}: ${color_norm}disabled
${color_norm}"
}
handle_help "${@:-}"
min_args "${#}" "1"
require_root
lock
for alias in "${@}"; do
if ! is_stratum_or_alias "${alias}"; then
abort "No stratum or alias called \"${alias}\"."
elif ! stratum="$(deref "${alias}")"; then
abort "Unable to dereference \"${alias}\"."
elif is_init "${stratum}"; then
abort "Cannot disable init-providing stratum."
elif is_bedrock "${stratum}"; then
abort "Cannot disable bedrock stratum."
else
disable_stratum "${stratum}"
fi
done
exit_success

View File

@ -0,0 +1,126 @@
#!/bedrock/libexec/busybox sh
#
# brl enable
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# version 2 as published by the Free Software Foundation.
#
# Copyright (c) 2012-2019 Daniel Thau <danthau@bedrocklinux.org>
#
# Integrates strata into the system.
. /bedrock/share/common-code
print_help() {
printf "Usage: ${color_cmd}brl enable ${color_sub}[options] <strata>${color_norm}
Integrates ${color_term}disabled${color_norm} ${color_term}strata${color_norm} into the system. Requires root.
Options:
${color_cmd}-h${color_norm}, ${color_cmd}--help${color_norm} print this message
Examples:
${color_cmd}$ brl status solus
${color_strat}solus${color_norm}: disabled
${color_rcmd}# brl enable solus
${color_cmd}$ brl status solus
${color_strat}solus${color_norm}: ${color_okay}enabled
${color_rcmd}# brl enable solus
${color_alert}ERROR: \"solus\" is already enabled. Consider \`brl repair\` to fix a broken stratum.
${color_rcmd}# brl enable alpine arch centos
${color_cmd}$ brl status alpine arch centos
${color_strat}alpine${color_norm}: ${color_okay}enabled
${color_strat}arch${color_norm}: ${color_okay}enabled
${color_strat}centos${color_norm}: ${color_okay}enabled
${color_norm}"
}
handle_help "${@:-}"
min_args "${#}" "1"
require_root
lock
enable_stratum() {
stratum="${1}"
root="$(stratum_root "${stratum}")"
br_root="/bedrock/strata/bedrock"
# Set an attribute on the stratum's root indicating to which stratum it
# belongs. This allows processes to look up their stratum by reading
# the attribute off of their root directory.
if ! cur_attr="$(get_attr "/proc/1/root/${root}" "stratum" 2>/dev/null)" || [ "${cur_attr}" != "${stratum}" ]; then
set_attr "/proc/1/root/${root}" "stratum" "${stratum}"
fi
# Ensure the stratum's root directory is a mount point.
stinit busybox mount --bind "${root}" "${root}"
for mnt in $(cfg_values "global" "share"); do
stinit busybox mkdir -p "${br_root}${mnt}" "${root}${mnt}"
stinit busybox mount --make-rshared "${br_root}${mnt}" 2>/dev/null || true
stinit busybox mount --rbind "${br_root}${mnt}" "${root}${mnt}"
stinit busybox mount --make-rshared "${root}${mnt}"
done
for mnt in $(cfg_values "global" "bind"); do
stinit busybox mkdir -p "${br_root}${mnt}" "${root}${mnt}"
stinit busybox mount --make-private "${br_root}${mnt}" 2>/dev/null || true
stinit busybox mount --bind "${br_root}${mnt}" "${root}${mnt}"
stinit busybox mount --make-private "${root}${mnt}"
done
(
drop_lock
mkdir -p "/proc/1/root${root}/etc"
if cfg_value "miscellaneous" "debug" | grep -q etcfs; then
cache="/bedrock/var/cache/etcfs-${stratum}"
lock --nonblock "${cache}" || true
rm -f "${cache}/log"
touch "${cache}/log"
chmod go-rwx "${cache}/log"
chroot "/proc/1/root${root}" /bedrock/libexec/etcfs -d -o allow_other "/etc" >>"${cache}/log" 2>&1 &
sleep 1
else
chroot "/proc/1/root${root}" /bedrock/libexec/etcfs -o allow_other "/etc"
fi
cfg_etcfs "/proc/1/root${root}/etc"
)
setup_binfmt_misc "${stratum}"
enforce_symlinks "${stratum}"
stinit busybox touch "/bedrock/strata/bedrock/bedrock/run/enabled_strata/${1}"
enforce_shells
enforce_id_ranges
if ! "${skip_crossfs}"; then
cfg_crossfs "/proc/1/root/bedrock/strata/bedrock/bedrock/cross"
fi
}
skip_crossfs="false"
if [ "${1:-}" = "--skip-crossfs" ]; then
skip_crossfs="true"
shift
fi
for alias in "${@}"; do
if ! is_stratum_or_alias "${alias}"; then
abort "No stratum or alias called \"${alias}\"."
elif ! stratum="$(deref "${alias}")"; then
abort "Unable to dereference \"${alias}\"."
elif is_enabled "${stratum}"; then
abort "\"${stratum}\" is already enabled. Consider \`brl repair\` to fix a broken stratum."
elif is_bedrock "${stratum}" || is_init "${stratum}"; then
abort "Cannot enable bedrock or init-providing stratum, as neither should ever be disabled."
else
disable_stratum "${stratum}"
enable_stratum "${stratum}"
fi
done
exit_success

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,138 @@
#!/bedrock/libexec/busybox sh
#
# brl hide
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# version 2 as published by the Free Software Foundation.
#
# Copyright (c) 2016-2020 Daniel Thau <danthau@bedrocklinux.org>
#
# Marks strata to be hidden.
. /bedrock/share/common-code
print_help() {
printf "Usage: ${color_cmd}brl hide ${color_sub}[options] <strata>${color_norm}
${color_term}Hides${color_norm} ${color_term}strata${color_norm} from various ${color_bedrock}Bedrock Linux${color_norm} subsystems. Requires root.
Options:
${color_sub}<none>${color_norm} defaults to ${color_cmd}--all${color_norm}
${color_cmd}-a${color_norm},${color_cmd} --all ${color_norm}${color_term}hide${color_norm} ${color_term}stratum${color_norm} in all available subsystems
${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
${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}
${color_cmd}-i${color_norm},${color_cmd} --init ${color_norm}do not list ${color_term}stratum${color_norm}'s init options during boot
${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.
${color_cmd}-p${color_norm},${color_cmd} --pmm ${color_norm}do not consider for ${color_cmd}\`pmm\`${color_norm} operations
${color_cmd}-h${color_norm},${color_cmd} --help ${color_norm}print this message
Examples:
${color_cmd}$ brl list | grep centos
${color_strat}centos
${color_rcmd}# brl hide centos
${color_cmd}$ brl list | grep centos
${color_norm}"
}
handle_help "${@:-}"
min_args "${#}" "1"
hide_boot=false
hide_cross=false
hide_init=false
hide_list=false
hide_pmm=false
strata=""
OPTL="all,boot,cross,init,list,pmm,help"
OPTO="abcilp"
eval set -- "$(getopt -q -l "${OPTL}" -- "${OPTO}" "${@}")" || true
saw_non_positional=false
while [ -n "${1:-}" ]; do
case "${1}" in
-a | --all)
hide_boot=true
hide_cross=true
hide_init=true
hide_list=true
hide_pmm=true
shift
;;
-b | --boot)
hide_boot=true
shift
;;
-c | --cross)
hide_cross=true
shift
;;
-i | --init)
hide_init=true
shift
;;
-l | --list)
hide_list=true
shift
;;
-p | --pmm)
hide_pmm=true
shift
;;
--)
shift
;;
-*)
if "${saw_non_positional}"; then
eval set -- "$(getopt -q -l "${OPTL}" -- "${OPTO}" "${@}")" || true
saw_non_positional=false
else
abort "Unrecognized argument: ${1}"
fi
;;
*)
saw_non_positional=true
strata="${strata} ${1}"
shift
;;
esac
done
if [ -z "${strata}" ]; then
abort "No stratum or alias specified."
fi
# Default to --all if none are specified
if ! "${hide_boot}" &&
! "${hide_cross}" &&
! "${hide_init}" &&
! "${hide_list}" &&
! "${hide_pmm}"; then
hide_boot=true
hide_cross=true
hide_init=true
hide_list=true
hide_pmm=true
fi
lock
for stratum in ${strata}; do
if ! is_stratum_or_alias "${stratum}"; then
abort "No stratum or alias named \"${stratum}\"."
elif "${hide_boot}" && is_bedrock "${stratum}"; then
abort "Cannot hide bedrock stratum from boot-time enabling. You may hide it from everything else, however. See --help for other options."
fi
"${hide_boot}" && rm_attr "/bedrock/strata/${stratum}" "show_boot"
"${hide_cross}" && rm_attr "/bedrock/strata/${stratum}" "show_cross"
"${hide_init}" && rm_attr "/bedrock/strata/${stratum}" "show_init"
"${hide_list}" && rm_attr "/bedrock/strata/${stratum}" "show_list"
"${hide_pmm}" && rm_attr "/bedrock/strata/${stratum}" "show_pmm"
done
if "${hide_cross}"; then
cfg_crossfs "/proc/1/root/bedrock/strata/bedrock/bedrock/cross"
fi
exit_success

View File

@ -0,0 +1,246 @@
#!/bedrock/libexec/busybox sh
#
# brl import
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# version 2 as published by the Free Software Foundation.
#
# Copyright (c) 2020-2022 Daniel Thau <danthau@bedrocklinux.org>
#
# Creates strata from specified file(s)
. /bedrock/share/common-code
print_help() {
printf "Usage: ${color_cmd}brl import ${color_sub}<name> <source>${color_norm}
Creates a new ${color_term}stratum${color_norm} named ${color_sub}<name>${color_norm} from specified a ${color_sub}<source>${color_norm}.
Requires root. Some sources may require external tooling (e.g. ${color_cmd}qemu-img${color_norm})
If using a VM image with multiple partitions, ${color_cmd}brl import${color_norm} will attempt to guess
the root partition. ${color_warn}This is error-prone.${color_norm} For best results, prefer using one
large partition; avoid things like separate ${color_file}/boot${color_norm} and ${color_file}/home${color_norm} partitions.
Sources:
Directory (such as an unpacked tarball, ${color_cmd}docker${color_norm}/${color_cmd}podman${color_norm} image, etc)
Tarball (${color_file}.tar${color_norm})
Qemu qcow/qcow2/qcow3 image (${color_file}.qcow${color_norm}, ${color_file}.qcow2${color_norm}, ${color_file}.qcow3${color_norm})
VirtualBox image (${color_file}.vdi${color_norm})
VMware image (${color_file}.vmdk${color_norm})
Example:
${color_cmd}$ wget http://example.com/arch-root.tar
${color_rcmd}# brl import arch arch-root.tar
${color_cmd}$ qemu-image create -f qcow3 disk.qcow3 10G
${color_cmd}$ qemu-system-x86_64 ./disk.qcow3 -drive ubuntu.iso # install in VM
${color_rcmd}# brl import ubuntu disk.qcow3
${color_cmd}$ # Also works with podman
${color_rcmd}# docker pull hello-world
${color_rcmd}# image=\"/bedrock/strata/\$(brl which docker)\$(docker inspect hello-world | jq -r '.[0].GraphDriver.Data.UpperDir')\"
${color_rcmd}# brl import hello-world \"\${image}\"
${color_norm}"
}
require_cmd() {
cmd="${1}"
if ! which "${cmd}" >/dev/null 2>&1; then
abort "Specified source type requires \"${cmd}\" in \`\$PATH\`. Install it and try again."
fi
}
copy_dir_contents() {
src="${1}"
dst="${2}"
mkdir -p "${dst}"
count=0
for f in "${src}"/*; do
case "$(basename "${f}")" in
"*" | "brl-import") continue ;;
esac
count=$((count + 1))
done
for f in "${src}"/*; do
case "$(basename "${f}")" in
"*" | "brl-import") continue ;;
esac
cp -a "${f}" "${tgt}"
echo "x"
done | progress_bar "${count}"
}
list_partitions() {
fdisk -lu "${1}" | awk '
/Found valid GPT/ {
gpt=1
}
# Busybox fdisk MBR mode sector size
/Units: sectors of/ {
sector_size = $(NF-1)
}
# Busybox fdisk GPT mode sector size
/Logical sector size:/ {
sector_size = $(NF)
}
# Busybox fdisk MBR mode partition list
# e.g.
# Device Boot StartCHS EndCHS StartLBA EndLBA Sectors Size Id Type
# /dev/shm/test.img1 * 0,32,33 12,223,19 2048 206847 204800 100M 83 Linux
!gpt && /^\// && $(NF) == "Linux" {
if ($2 == "*") {
print $5 * sector_size
} else {
print $4 * sector_size
}
}
# Busybox fdisk GPT mode partition list
# No type indicator, have to check things like swap.
# GPT first detected partition at 2048 is BIOS boot partition, not Linux partition.
# e.g.
# Number Start (sector) End (sector) Size Name
# 1 2048 18431 8192K
gpt && /^ *[0-9]/ && $2 > 2048 {
print $2 * sector_size
}
'
}
mount_partition() {
partition_start="${1}"
image="${2}"
mount_point="${3}"
if mount -o loop,offset="${partition_start}" "${image}" "${mount_point}" 2>/dev/null; then
good=true
else
# Rapid mount -oloop calls can result in an undocumented EEXIST errors
# https://unix.stackexchange.com/questions/537029/error-for-mount-system-call-failed-file-exists
sleep 1
good=false
fi
"${good}"
}
# Some virtual machines hide everything in an `@` directory
# Some directories/tarballs/etc contain an undesired parent directory
remove_root_dir() {
if [ -d "${tgt}/@" ] && ls "${tgt}/@/"* >/dev/null 2>&1; then
dir="${tgt}/@"
elif [ "$(find "${tgt}" -mindepth 1 -maxdepth 1 | wc -l)" -ne 1 ]; then
return
elif ! [ -d "$(find "${tgt}" -mindepth 1 -maxdepth 1)" ]; then
return
else
dir="$(find "${tgt}" -mindepth 1 -maxdepth 1)"
fi
notice "Moving files"
mv "${dir}/"* "${tgt}"
less_lethal_rm_rf "${dir}"
}
import_abort() {
printf "${color_alert}ERROR: %s\\n${color_norm}" "${@}" >&2
notice "Cleaning up"
less_lethal_rm_rf "${tgt}"
exit 1
}
handle_help "${@:-}"
min_args "${#}" "2"
name="${1}"
src="${2}"
tgt="/bedrock/strata/${name}/"
tmp="${tgt}/brl-import/"
mnt="${tgt}/brl-import/mnt"
image="${tmp}/disk.img"
require_root
lock
ensure_legal_stratum_name "${name}"
if is_stratum_or_alias "${name}"; then
abort "Something already exists at \"/bedrock/strata/${name}\". Either choose another name or remove preexisting stratum/alias with \`brl remove ${name}\` and try again."
fi
trap 'import_abort "Unexpected error occurred."' EXIT
mkdir -p "${tgt}" "${tmp}" "${mnt}"
case "${src}" in
*.qcow | *.qcow2 | *.qcow3 | *.vmdk | *.vdi)
require_cmd qemu-img
step_init 8
step "Converting image format"
# -p makes its own progress bar
qemu-img convert -p -Oraw "${src}" "${image}"
step "Detecting target partition"
partitions="$(list_partitions "${image}")"
partition_count="$(echo "${partitions}" | wc -l)"
for partition in ${partitions}; do
if mount_partition "${partition}" "${image}" "${mnt}"; then
if [ -e "${mnt}/etc/os-release" ] || [ -h "${mnt}/etc/os-release" ]; then
echo "${partition}" >> "${tmp}/likely-root-partition"
fi
umount "${mnt}"
echo "${partition}" >> "${tmp}/linux-partitions"
fi
echo "${partition}"
done | progress_bar "${partition_count}"
if [ -e "${tmp}/linux-partitions" ] && [ "$(cat "${tmp}/linux-partitions" | wc -l)" -eq 1 ]; then
target_partition="$(cat "${tmp}/linux-partitions")"
elif [ -e "${tmp}/likely-root-partition" ] && [ "$(cat "${tmp}/likely-root-partition" | wc -l)" -eq 1 ]; then
printf "${color_warn}WARNING: Multiple Linux partitions found. Guessing root partition. This may fail to detect correct partition or miss information needed on other partitions.${color_norm}\n"
target_partition="$(cat "${tmp}/likely-root-partition")"
else
abort "Unable to detect target partition. If ${src} contained multiple partitions, consider trying again with one large partition rather than multiple."
fi
step "Mounting partition"
mount_partition "${target_partition}" "${image}" "${mnt}"
step "Copying files"
copy_dir_contents "${mnt}" "${tgt}"
;;
*.tar | *.tar.gz | *.tar.bz2 | *.tar.xz)
step_init 6
step "Extracting tarball"
mkdir -p "${tgt}"
tar -xv -f "${src}" -C "${tgt}" | awk 'NR%100==0' | progress_unknown
;;
*)
if [ -d "${src}" ]; then
step_init 6
step "Copying files"
copy_dir_contents "${src}" "${tgt}"
else
import_abort "Could not determine source type. See --help."
fi
;;
esac
remove_root_dir
step "Cleaning up"
less_lethal_rm_rf "${tmp}"
step "Importing users and groups"
import_users_and_groups "${tgt}/etc/passwd" "${tgt}/etc/group"
drop_lock
step "${color_term}Showing${color_norm}"
/bedrock/libexec/brl-show "${name}"
step "${color_term}Enabling${color_norm}"
/bedrock/libexec/brl-enable "${name}"
notice "Successfully ${color_term}imported${color_norm} ${color_strat}${name}${color_norm}"
exit_success

View File

@ -0,0 +1,157 @@
#!/bedrock/libexec/busybox sh
#
# brl list
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# version 2 as published by the Free Software Foundation.
#
# Copyright (c) 2012-2018 Daniel Thau <danthau@bedrocklinux.org>
#
# List strata and aliases.
. /bedrock/share/common-code
print_help() {
printf "Usage: ${color_cmd}brl list ${color_sub}[options]${color_norm}
Lists ${color_term}strata${color_norm}.
Options:
${color_sub}<none>${color_norm} defaults to ${color_cmd}--enabled${color_norm}
${color_cmd}-e${color_norm},${color_cmd} --enabled-strata ${color_norm}${color_term}enabled${color_norm} ${color_term}stratum${color_norm}
${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}
${color_cmd}-d${color_norm},${color_cmd} --disabled-strata ${color_norm}${color_term}disabled${color_norm} ${color_term}stratum${color_norm}
${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}
${color_cmd}-a${color_norm},${color_cmd} --all-strata ${color_norm}all ${color_term}strata${color_norm}
${color_cmd}-A${color_norm},${color_cmd} --all-aliases ${color_norm}all ${color_term}aliases${color_norm}
${color_cmd}-r${color_norm},${color_cmd} --deref ${color_norm}dereference ${color_term}aliases${color_norm}
${color_cmd}-i${color_norm},${color_cmd} --include-hidden ${color_norm}include ${color_term}hidden strata${color_norm} in list
may require pairing with ${color_cmd}-E${color_norm} or ${color_cmd}-a${color_norm}
${color_cmd}-v${color_norm},${color_cmd} --everything ${color_norm}equivalent to ${color_cmd}-aAir
${color_cmd}-h${color_norm},${color_cmd} --help ${color_norm}print this message
Examples:
${color_cmd}$ brl list
${color_strat}arch
${color_strat}bedrock
${color_strat}gentoo
${color_strat}void
${color_cmd}$ brl list -Dr
${color_alias}unstable -> sid
${color_norm}"
}
handle_help "${@:-}"
list_enabled_strata=false
list_enabled_aliases=false
list_disabled_strata=false
list_disabled_aliases=false
include_hidden=false
deref_aliases=false
OPTL="enabled-strata,enabled-aliases,disabled-strata,disabled-aliases,all-strata,all-aliases,deref,include-hidden,everything"
OPTO="eEdDaAriv"
eval set -- "$(getopt -q -l "${OPTL}" -- "${OPTO}" "${@}")" || true
saw_non_positional=false
while [ -n "${1:-}" ]; do
case "${1}" in
-e | --enabled-strata)
list_enabled_strata=true
shift
;;
-E | --enabled-aliases)
list_enabled_aliases=true
shift
;;
-d | --disabled-strata)
list_disabled_strata=true
shift
;;
-D | --disabled-aliases)
list_disabled_aliases=true
shift
;;
-a | --all-strata)
list_enabled_strata=true
list_disabled_strata=true
shift
;;
-A | --all-aliases)
list_enabled_aliases=true
list_disabled_aliases=true
shift
;;
-r | --deref)
deref_aliases=true
shift
;;
-i | --include-hidden)
include_hidden=true
shift
;;
-v | --everything)
list_enabled_strata=true
list_disabled_strata=true
list_enabled_aliases=true
list_disabled_aliases=true
deref_aliases=true
include_hidden=true
shift
;;
--)
shift
;;
-*)
if "${saw_non_positional}"; then
eval set -- "$(getopt -q -l "${OPTL}" -- "${OPTO}" "${@}")" || true
saw_non_positional=false
else
abort "Unrecognized argument: ${1}"
fi
;;
*)
abort "Unrecognized argument: ${1}"
;;
esac
done
if ! "${list_enabled_strata}" &&
! "${list_enabled_aliases}" &&
! "${list_disabled_strata}" &&
! "${list_disabled_aliases}"; then
list_enabled_strata=true
fi
(
if "${list_enabled_strata}" || "${list_disabled_strata}"; then
list_strata
fi
if "${list_enabled_aliases}" || "${list_disabled_aliases}"; then
list_aliases
fi
) | sort | while read -r stratum; do
if ! "${include_hidden}" && ! has_attr "/bedrock/strata/$stratum" show_list; then
continue
elif "${list_enabled_strata}" && is_stratum "${stratum}" && is_enabled "${stratum}"; then
printf "${color_strat}%s${color_norm}\\n" "$stratum"
elif "${list_disabled_strata}" && is_stratum "${stratum}" && ! is_enabled "${stratum}"; then
printf "${color_disabled_strat}%s${color_norm}\\n" "$stratum"
elif "${list_enabled_aliases}" && is_alias "${stratum}" && is_enabled "${stratum}"; then
if "${deref_aliases}"; then
printf "${color_alias}%s${color_glue} -> ${color_strat}%s${color_norm}\\n" "$stratum" "$(deref "$stratum")"
else
printf "${color_alias}%s${color_norm}\\n" "$stratum"
fi
elif "${list_disabled_aliases}" && is_alias "${stratum}" && ! is_enabled "${stratum}"; then
if "${deref_aliases}"; then
printf "${color_alias}%s${color_glue} -> ${color_strat}%s${color_norm}\\n" "$stratum" "$(deref "$stratum")"
else
printf "${color_alias}%s${color_norm}\\n" "$stratum"
fi
fi
done
exit_success

View File

@ -0,0 +1,103 @@
#!/bedrock/libexec/busybox sh
#
# brl remove
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# version 2 as published by the Free Software Foundation.
#
# Copyright (c) 2016-2019 Daniel Thau <danthau@bedrocklinux.org>
#
# Removes strata and aliases.
. /bedrock/share/common-code
print_help() {
printf "Usage: ${color_cmd}brl remove ${color_sub}[options] <strata>${color_norm}
Removes specified ${color_term}strata${color_norm} and ${color_term}aliases${color_norm}. Requires root.
Options:
${color_cmd}-d${color_norm}, ${color_cmd}--disable${color_norm} disable then remove enabled strata rather than abort
${color_cmd}-h${color_norm}, ${color_cmd}--help${color_norm} print this message
Examples:
${color_cmd}$ brl list -d | grep '^a'
${color_strat}alpine
${color_strat}arch
${color_rcmd}# brl remove alpine arch
${color_cmd}$ brl list -d | grep '^a'
${color_cmd}$ brl list -e | grep '^c'
${color_strat}crux
${color_rcmd}# brl remove crux
${color_alert}ERROR: \"crux\" is enabled, refusing to remove. To disable and remove use \`-d\`.
${color_rcmd}# brl remove -d crux
${color_cmd}$ brl list -e | grep '^c'
${color_norm}"
}
handle_help "${@:-}"
min_args "${#}" "1"
require_root
lock
force_disable=false
strata=""
OPTL="enabled-strata,enabled-aliases,disabled-strata,disabled-aliases,all-strata,all-aliases,deref,include-hidden"
OPTO="eEdDaAri"
eval set -- "$(getopt -q -l "${OPTL}" -- "${OPTO}" "${@}")" || true
saw_non_positional=false
while [ -n "${1:-}" ]; do
case "${1}" in
-d | --disable)
force_disable=true
shift
;;
--)
shift
;;
-*)
if "${saw_non_positional}"; then
eval set -- "$(getopt -q -l "${OPTL}" -- "${OPTO}" "${@}")" || true
saw_non_positional=false
else
abort "Unrecognized argument: ${1}"
fi
;;
*)
saw_non_positional=true
strata="${strata} ${1}"
shift
;;
esac
done
for stratum in ${strata}; do
if ! is_stratum_or_alias "${stratum}"; then
abort "No \"${stratum}\" stratum or alias."
elif [ "${stratum}" = "init" ]; then
abort "Removing init alias is disallowed."
elif is_alias "${stratum}"; then
rm "/bedrock/strata/${stratum}"
elif is_init "${stratum}"; then
abort "Cannot remove or disable init stratum while in use. Reboot and select another stratum to provide init first."
elif is_bedrock "${stratum}"; then
abort "Removing bedrock stratum is disallowed."
elif is_enabled "${stratum}" && ! "${force_disable}"; then
abort "\"${stratum}\" is enabled, refusing to remove. To disable and remove use \`-d\`."
else
for alias in $(list_aliases); do
if [ "$(deref "${alias}")" = "${stratum}" ]; then
rm "/bedrock/strata/${alias}"
fi
done
disable_stratum "${stratum}"
less_lethal_rm_rf "/bedrock/strata/${stratum}"
fi
done
exit_success

View File

@ -0,0 +1,63 @@
#!/bedrock/libexec/busybox sh
#
# brl rename
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# version 2 as published by the Free Software Foundation.
#
# Copyright (c) 2016-2018 Daniel Thau <danthau@bedrocklinux.org>
#
# Renames strata and aliases.
. /bedrock/share/common-code
print_help() {
printf "
Usage: ${color_cmd}brl rename ${color_sub}[options] <stratum> <new-name>${color_norm}
Renames ${color_term}strata${color_norm} and ${color_term}aliases${color_norm}. Requires root. Can only be applied to ${color_term}disabled${color_norm}
${color_term}strata${color_norm}.
Options:
${color_cmd}-h${color_norm}, ${color_cmd}--help${color_norm} print this message
Examples:
${color_cmd}$ brl list unignored | grep -e debian -e stretch
${color_strat}debian
${color_rcmd}# brl rename debian stretch
${color_cmd}$ brl list unignored | grep -e debian -e stretch
${color_strat}stretch
${color_norm}"
}
handle_help "${@:-}"
min_args "${#}" "2"
stratum="${1}"
new_name="${2}"
require_root
lock
if ! is_stratum_or_alias "${stratum}"; then
abort "No stratum or alias found called \"${stratum}\"."
elif is_stratum_or_alias "${new_name}"; then
abort "Pre-existing stratum or alias found called \"${new_name}\". Remove with \`brl remove ${stratum}\` first."
elif [ "${stratum}" = "init" ]; then
abort "Renaming init alias is disallowed."
elif is_bedrock "${stratum}"; then
abort "Renaming bedrock stratum is disallowed."
elif is_init "${stratum}"; then
abort "Renaming init-providing stratum is disallowed."
elif is_stratum "${stratum}" && is_enabled "${stratum}"; then
abort "\"${stratum}\" is enabled. Disable with \`brl disable ${stratum}\` first."
fi
ensure_legal_stratum_name "${new_name}"
if is_stratum "${stratum}"; then
disable_stratum "${stratum}"
fi
mv "/bedrock/strata/${stratum}" "/bedrock/strata/${new_name}"
exit_success

View File

@ -0,0 +1,330 @@
#!/bedrock/libexec/busybox sh
#
# brl repair
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# version 2 as published by the Free Software Foundation.
#
# Copyright (c) 2018-2019 Daniel Thau <danthau@bedrocklinux.org>
# Repairs broken strata
. /bedrock/share/common-code
print_help() {
printf "Usage: ${color_cmd}brl repair ${color_sub}[options] <strata>${color_norm}
Repairs broken ${color_term}strata${color_norm}. Requires root.
Options:
${color_sub}<none>${color_norm} defaults to ${color_cmd}--retain${color_norm}
${color_cmd}-n${color_norm},${color_cmd} --new ${color_norm}only add new mounts, do not remove anything
${color_norm}only fixes trivially broken ${color_term}strata
${color_cmd}-r${color_norm},${color_cmd} --retain ${color_norm}try to retain as much as possible except problematic mount points
${color_norm}fixes most ${color_term}strata${color_norm} but risks losing some state
${color_cmd}-c${color_norm},${color_cmd} --clear ${color_norm}clears ${color_term}strata${color_norm} processes and mount points
${color_norm}should fix almost all ${color_term}strata${color_norm} but loses all state
${color_cmd}-h${color_norm}, ${color_cmd}--help${color_norm} print this message
Examples:
${color_cmd}$ brl status ubuntu
${color_strat}ubuntu${color_norm}: ${color_okay}enabled
${color_rcmd}# strat ubuntu umount /proc
${color_cmd}$ brl status ubuntu
${color_strat}ubuntu${color_norm}: ${color_alert}broken
${color_rcmd}# brl repair --new ubuntu
${color_cmd}$ brl status ubuntu
${color_strat}ubuntu${color_norm}: ${color_okay}enabled
${color_rcmd}# strat ubuntu sshfs 192.168.1.199:/home/ /etc
${color_cmd}$ brl status ubuntu
${color_strat}ubuntu${color_norm}: ${color_alert}broken
${color_rcmd}# brl repair --new ubuntu
${color_alert}ERROR: Cannot repair \"ubuntu\" with --new strategy due to problematic mount at \"/etc\".
${color_rcmd}# brl repair --retain ubuntu
${color_cmd}$ brl status ubuntu
${color_strat}ubuntu${color_norm}: ${color_okay}enabled
${color_norm}"
}
ensure_mnt() {
stratum="${1}"
root="$(stratum_root --empty "${stratum}")"
br_root="/bedrock/strata/bedrock"
mnt="${2}"
tgt_type="${3}"
tgt_share="${4}"
tgt_cmd="${5}"
details="$(mount_details "${stratum}" "${mnt}")"
type="$(echo "${details}" | cut -d: -f1)"
global="$(echo "${details}" | cut -d: -f2)"
shared="$(echo "${details}" | cut -d: -f3)"
# If a non-global mount exists, unmount it.
if [ "${type}" != "missing" ] && ! "${global}"; then
if [ "${strategy}" = "new" ]; then
abort "Cannot repair \"$stratum\" with --new strategy due to problematic mount at \"${mnt}\""
fi
umount_r --init "${root}${mnt}"
type="missing"
shared=false
fi
# If a mount exists but it is the incorrect filesystem type, unmount it.
if [ "${type}" != "missing" ] && [ -n "$tgt_type" ] && [ "${type}" != "${tgt_type}" ]; then
if [ "${strategy}" = "new" ]; then
abort "Cannot repair \"$stratum\" with --new strategy due to problematic mount at \"${mnt}\""
fi
umount_r --init "${root}${mnt}"
type="missing"
shared=false
fi
# If a mount point is private but needs to be shared, we need to
# re-mount it with shared set on the source.
if ! is_bedrock "${stratum}" && ! "${shared}" && "${tgt_share}"; then
if [ "${strategy}" = "new" ]; then
abort "Cannot repair \"$stratum\" with --new strategy due to problematic mount at \"${mnt}\""
fi
umount_r --init "${root}${mnt}"
type="missing"
shared=false
fi
# If the stratum is not Bedrock, ensure Bedrock's equivalent is set up
# to share the subtree. This ensures that when we create the new mount
# we share the subtree with Bedrock's mount.
if ! is_bedrock "${stratum}" && "${tgt_share}"; then
if ! stinit busybox mount --make-rshared "${br_root}${mnt}" 2>/dev/null; then
stinit busybox mkdir -p "${br_root}${mnt}"
stinit busybox mount --bind "${br_root}${mnt}" "${br_root}${mnt}"
stinit busybox mount --make-rshared "${br_root}${mnt}"
fi
fi
# If no mount exists at the target location (possibly because we
# removed it above), create it.
if [ "${type}" = "missing" ]; then
stinit busybox mkdir -p "${br_root}${mnt}" "${root}${mnt}"
eval "${tgt_cmd}"
fi
# If the stratum is Bedrock, ensure the new mount is shared such any
# new bind mounts to it share its subtree.
if is_bedrock "${stratum}" && "${shared}"; then
stinit busybox mount --make-rshared "${br_root}${mnt}" 2>/dev/null
fi
# If the mount point is shared but we want it private, make it private.
if "${shared}" && ! "${tgt_share}"; then
stinit busybox mount --make-private "${br_root}${mnt}" 2>/dev/null || true
stinit busybox mount --make-private "${root}${mnt}"
fi
setup_binfmt_misc "${stratum}"
}
repair_bedrock() {
stratum="${1}"
root="$(stratum_root --empty "${stratum}")"
# Set an attribute on the stratum's root indicating to which stratum it
# belongs. This allows processes to look up their stratum by reading
# the attribute off of their root directory.
if ! cur_attr="$(get_attr "/proc/1/root/${root}" "stratum" 2>/dev/null)" || [ "${cur_attr}" != "${stratum}" ]; then
set_attr "/proc/1/root/${root}" "stratum" "${stratum}"
fi
mnt="/proc"
ensure_mnt "${stratum}" "${mnt}" "proc" "true" "
stinit busybox mount -t proc proc \"${root}${mnt}\"
"
mnt="/etc"
ensure_mnt "${stratum}" "${mnt}" "fuse.etcfs" "false" "
(
drop_lock;
mkdir -p \"/proc/1/root${root}${mnt}\";
if cfg_value \"miscellaneous\" \"debug\" | grep -q etcfs; then
cache=\"/bedrock/var/cache/etcfs-${stratum}\";
lock --nonblock \"\${cache}\" || true;
rm -f \"\${cache}/log\";
touch \"\${cache}/log\";
chmod go-rwx \"\${cache}/log\";
chroot \"/proc/1/root${root}\" /bedrock/libexec/etcfs -d -o allow_other \"${mnt}\" >>\"\${cache}/log\" 2>&1 &
sleep 1;
else
chroot \"/proc/1/root${root}\" /bedrock/libexec/etcfs -o allow_other \"${mnt}\";
fi
cfg_etcfs \"/proc/1/root${root}${mnt}\";
)
"
mnt="/bedrock/run"
ensure_mnt "${stratum}" "${mnt}" "tmpfs" "false" "
stinit busybox mount -t tmpfs bedrock_run \"${root}${mnt}\";
stinit busybox chmod go-w \"${root}\";
stinit busybox chmod go-w \"${root}/bedrock\";
stinit busybox chmod go-w \"${root}/bedrock/run\";
"
mnt="/bedrock/strata/bedrock"
ensure_mnt "${stratum}" "${mnt}" "" "false" "
stinit busybox mount --bind \"${root}\" \"${root}${root}\"
"
# crossfs below depends on init stratum having stratum xattr set
init="$(/bedrock/bin/brl deref init)"
if ! init_attr="$(get_attr "/proc/1/root" "stratum" 2>/dev/null)" || [ "${init_attr}" != "${init}" ]; then
set_attr "/proc/1/root" "stratum" "${init}"
fi
mnt="/bedrock/cross"
ensure_mnt "${stratum}" "${mnt}" "fuse.crossfs" "false" "
(
drop_lock;
mkdir -p \"/proc/1/root${root}${mnt}\";
chroot \"/proc/1/root${root}\" /bedrock/libexec/crossfs -o allow_other \"${mnt}\";
)
"
enforce_symlinks "${stratum}"
enforce_shells
enforce_id_ranges
if ! "${skip_crossfs}"; then
cfg_crossfs "/proc/1/root/bedrock/strata/bedrock/bedrock/cross"
fi
}
repair_stratum() {
stratum="${1}"
root="$(stratum_root --empty "${stratum}")"
br_root="/bedrock/strata/bedrock"
# Set an attribute on the stratum's root indicating to which stratum it
# belongs. This allows processes to look up their stratum by reading
# the attribute off of their root directory.
if ! cur_attr="$(get_attr "/proc/1/root/${root}" "stratum" 2>/dev/null)" || [ "${cur_attr}" != "${stratum}" ]; then
set_attr "/proc/1/root/${root}" "stratum" "${stratum}"
fi
for mnt in $(cfg_values "global" "share"); do
ensure_mnt "${stratum}" "${mnt}" "" "true" "
stinit busybox mount --rbind \"${br_root}${mnt}\" \"${root}${mnt}\"
"
done
for mnt in $(cfg_values "global" "bind"); do
ensure_mnt "${stratum}" "${mnt}" "" "false" "
stinit busybox mount --bind \"${br_root}${mnt}\" \"${root}${mnt}\"
"
done
mnt="/etc"
ensure_mnt "${stratum}" "${mnt}" "fuse.etcfs" "false" "
(
drop_lock;
mkdir -p \"/proc/1/root${root}${mnt}\";
if cfg_value \"miscellaneous\" \"debug\" | grep -q etcfs; then
cache=\"/bedrock/var/cache/etcfs-${stratum}\";
lock --nonblock \"\${cache}\" || true;
rm -f \"\${cache}/log\";
touch \"\${cache}/log\";
chmod go-rwx \"\${cache}/log\";
chroot \"/proc/1/root${root}\" /bedrock/libexec/etcfs -d -o allow_other \"${mnt}\" >>\"\${cache}/log\" 2>&1 &
sleep 1;
else
chroot \"/proc/1/root${root}\" /bedrock/libexec/etcfs -o allow_other \"${mnt}\";
fi
cfg_etcfs \"/proc/1/root${root}${mnt}\";
)
"
enforce_symlinks "${stratum}"
enforce_shells
if ! "${skip_crossfs}"; then
cfg_crossfs "/proc/1/root/bedrock/strata/bedrock/bedrock/cross"
fi
}
handle_help "${@:-}"
min_args "${#}" "1"
require_root
lock
strategy="retain"
strata=""
skip_crossfs="false"
OPTL="new,retain,clear,skip-crossfs"
OPTO="nrc"
eval set -- "$(getopt -q -l "${OPTL}" -- "${OPTO}" "${@}")" || true
saw_non_positional=false
while [ -n "${1:-}" ]; do
case "${1}" in
-n | --new)
strategy="new"
shift
;;
-r | --retain)
strategy="retain"
shift
;;
-c | --clear)
strategy="clear"
shift
;;
--skip-crossfs)
skip_crossfs="true"
shift
;;
--)
shift
;;
-*)
if "${saw_non_positional}"; then
eval set -- "$(getopt -q -l "${OPTL}" -- "${OPTO}" "${@}")" || true
saw_non_positional=false
else
abort "Unrecognized argument: ${1}"
fi
;;
*)
saw_non_positional=true
strata="${strata} ${1}"
shift
;;
esac
done
for alias in ${strata}; do
if ! is_stratum_or_alias "${alias}"; then
abort "No stratum or alias called \"${alias}\"."
elif ! stratum="$(deref "${alias}")"; then
abort "Unable to dereference \"${alias}\"."
elif ! is_enabled "${stratum}"; then
abort "\`brl repair\` is intended for enabled strata. Enable disabled strata with \`brl enable\`."
elif is_bedrock "${stratum}" && [ "${strategy}" = "clear" ]; then
abort "Unable to --clear bedrock stratum"
elif is_init "${stratum}" && [ "${strategy}" = "clear" ]; then
abort "Unable to --clear init-providing stratum"
elif is_bedrock "${stratum}"; then
repair_bedrock "${stratum}"
else
if [ "${strategy}" = "clear" ]; then
disable_stratum "${stratum}"
drop_lock
/bedrock/libexec/brl-enable "${stratum}"
lock
else
repair_stratum "${stratum}"
fi
fi
done
exit_success

View File

@ -0,0 +1,102 @@
#!/bedrock/libexec/busybox sh
#
# brl report
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# version 2 as published by the Free Software Foundation.
#
# Copyright (c) 2015-2019 Daniel Thau <danthau@bedrocklinux.org>
#
# Generates report about system status
. /bedrock/share/common-code
# Continue if there are errors
set +eu
trap '' EXIT
print_help() {
printf "
Usage: ${color_cmd}brl report ${color_sub}[options] <output>${color_norm}
Generates a report about the current ${color_bedrock}Bedrock Linux${color_norm} system for use in debugging
issues. Output must be a file path to store the resulting report.
Options:
${color_cmd}-h${color_norm}, ${color_cmd}--help ${color_norm}print this message
${color_cmd}-o${color_norm}, ${color_cmd}--overwrite ${color_norm}overwrite file at report path
Example:
${color_cmd}$ brl report /tmp/log
${color_cmd}$ cat /tmp/log | xclip
${color_norm}"
}
handle_help "${@:-}"
min_args "${#}" "1"
overwrite="false"
if [ "${1:-}" = "-o" ] || [ "${1:-}" = "--overwrite" ]; then
overwrite="true"
shift
fi
report="${1}"
shift
if [ "${1:-}" = "-o" ] || [ "${1:-}" = "--overwrite" ]; then
overwrite="true"
shift
fi
if [ -e "${report}" ]; then
if "${overwrite}"; then
rm -f "${report}"
else
abort "file exists at \"${report}\" and --overwrite was not specified."
fi
fi
run() {
notice "Running ${color_cmd}\`${*}\`${color_norm}"
(
echo '$ '"${*}"
eval "${@}" | sed 's/^/ /'
echo ""
) >>"${report}" 2>&1 || true
}
notice "Creating report at ${color_file}\`$report\`${color_norm}."
echo "Bedrock Linux system report" >>"${report}"
echo "" >>"${report}"
run "cat /bedrock/etc/bedrock-release"
run "cat /bedrock/etc/bedrock.conf"
run "/bedrock/bin/brl list -v"
run "/bedrock/bin/brl status \$(/bedrock/bin/brl list -aA)"
run "echo \$PATH"
run "echo \$MANPATH"
run "echo \$INFOPATH"
run "echo \$XDG_DATA_DIRS"
run "echo \$SHELL"
run "ls -la /bedrock/strata/"
run "ls -Rl /bedrock/run/"
run "grep secure_path /etc/sudoers"
run "grep \"^\$(whoami):\" /etc/passwd"
run "grep \"^root:\" /etc/passwd"
run "cat /etc/hostname"
run "cat /etc/os-release"
run "cat /etc/lsb-release"
run "cat /etc/fstab"
run "cat /proc/1/mountinfo"
run "lsmod"
run "ps"
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"
run "cat /bedrock/cross/.bedrock-config-filesystem"
run "cat /proc/1/root/etc/.bedrock-config-filesystem"
run "uname -m"
run "uname -a"
run "env"
run "/bedrock/libexec/getfattr -d /bedrock/strata/bedrock"
notice "Completed creating report at ${color_file}\`$report\`${color_norm}."
exit_success

View File

@ -0,0 +1,139 @@
#!/bedrock/libexec/busybox sh
#
# brl show
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# version 2 as published by the Free Software Foundation.
#
# Copyright (c) 2016-2020 Daniel Thau <danthau@bedrocklinux.org>
#
# Marks strata to be visible
. /bedrock/share/common-code
print_help() {
printf "Usage: ${color_cmd}brl show ${color_sub}[options] <strata>${color_norm}
${color_term}Shows${color_norm} ${color_term}strata${color_norm} from various ${color_bedrock}Bedrock Linux${color_norm} subsystems. Requires root.
Options:
${color_sub}<none>${color_norm} defaults to ${color_cmd}--all${color_norm}
${color_cmd}-a${color_norm},${color_cmd} --all ${color_norm}${color_term}show${color_norm} ${color_term}stratum${color_norm} in all available subsystems
${color_cmd}-b${color_norm},${color_cmd} --boot ${color_norm}automatically ${color_term}enable${color_norm} ${color_term}stratum${color_norm} during boot
${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}
${color_cmd}-i${color_norm},${color_cmd} --init ${color_norm}list ${color_term}stratum${color_norm}'s init options during boot
${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
${color_cmd}-p${color_norm},${color_cmd} --pmm ${color_norm}consider for ${color_cmd}\`pmm\`${color_norm} operations
${color_cmd}-h${color_norm},${color_cmd} --help ${color_norm}print this message
Examples:
${color_cmd}$ brl list | grep centos
${color_strat}centos
${color_rcmd}# brl hide centos
${color_cmd}$ brl list | grep centos
${color_rcmd}# brl show centos
${color_cmd}$ brl list | grep centos
${color_strat}centos
${color_norm}"
}
handle_help "${@:-}"
min_args "${#}" "1"
show_boot=false
show_cross=false
show_init=false
show_list=false
show_pmm=false
strata=""
OPTL="all,boot,cross,init,list,pmm,help"
OPTO="abcilp"
eval set -- "$(getopt -q -l "${OPTL}" -- "${OPTO}" "${@}")" || true
saw_non_positional=false
while [ -n "${1:-}" ]; do
case "${1}" in
-a | --all)
show_boot=true
show_cross=true
show_init=true
show_list=true
show_pmm=true
shift
;;
-b | --boot)
show_boot=true
shift
;;
-c | --cross)
show_cross=true
shift
;;
-i | --init)
show_init=true
shift
;;
-l | --list)
show_list=true
shift
;;
-p | --pmm)
show_pmm=true
shift
;;
--)
shift
;;
-*)
if "${saw_non_positional}"; then
eval set -- "$(getopt -q -l "${OPTL}" -- "${OPTO}" "${@}")" || true
saw_non_positional=false
else
abort "Unrecognized argument: ${1}"
fi
;;
*)
saw_non_positional=true
strata="${strata} ${1}"
shift
;;
esac
done
if [ -z "${strata}" ]; then
abort "No stratum or alias specified."
fi
# Default to --all if none are specified
if ! "${show_boot}" &&
! "${show_cross}" &&
! "${show_init}" &&
! "${show_list}" &&
! "${show_pmm}"; then
show_boot=true
show_cross=true
show_init=true
show_list=true
show_pmm=true
fi
lock
for stratum in ${strata}; do
if ! is_stratum_or_alias "${stratum}"; then
abort "no stratum or alias named \"${stratum}\""
fi
"${show_boot}" && set_attr "/bedrock/strata/${stratum}" "show_boot" ""
"${show_cross}" && set_attr "/bedrock/strata/${stratum}" "show_cross" ""
"${show_init}" && set_attr "/bedrock/strata/${stratum}" "show_init" ""
"${show_list}" && set_attr "/bedrock/strata/${stratum}" "show_list" ""
"${show_pmm}" && set_attr "/bedrock/strata/${stratum}" "show_pmm" ""
done
if "${show_cross}"; then
cfg_crossfs "/proc/1/root/bedrock/strata/bedrock/bedrock/cross"
fi
exit_success

View File

@ -0,0 +1,166 @@
#!/bedrock/libexec/busybox sh
#
# brl status
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# version 2 as published by the Free Software Foundation.
#
# Copyright (c) 2012-2018 Daniel Thau <danthau@bedrocklinux.org>
#
# Prints specified stratum's status.
. /bedrock/share/common-code
print_help() {
printf "Usage: ${color_cmd}brl status ${color_sub}[options] <strata>${color_norm}
Prints specified ${color_term}stratum${color_norm}'s status. The status may be one of the following:
${color_term}enabled${color_norm}, ${color_term}disabled${color_norm}, ${color_term}hidden${color_norm}, or ${color_term}broken${color_norm}. If no ${color_term}strata${color_norm} are specified, defaults to
all ${color_term}strata${color_norm}.
Options:
${color_cmd}-h${color_norm}, ${color_cmd}--help ${color_norm}print this message
Examples:
${color_cmd}$ brl status
${color_strat}alpine${color_glue}: ${color_okay}enabled
${color_strat}arch${color_glue}: ${color_okay}enabled
${color_strat}centos${color_glue}: ${color_okay}enabled
${color_strat}debian${color_glue}: ${color_okay}enabled
${color_strat}devuan${color_glue}: ${color_okay}enabled
${color_rcmd}# strat devuan umount /sys
${color_cmd}$ brl status devuan
${color_strat}devuan${color_glue}: ${color_alert}broken
${color_cmd}/sys${color_norm} mount point is ${color_alert}missing${color_norm}
${color_rcmd}# brl disable devuan
${color_cmd}$ brl status devuan
${color_strat}devuan${color_glue}: ${color_norm}disabled
${color_rcmd}# brl hide devuan
${color_cmd}$ brl status devuan
${color_strat}devuan${color_glue}: ${color_norm}hidden
${color_cmd}$ brl status alpine arch
${color_strat}alpine${color_glue}: ${color_okay}enabled
${color_strat}arch${color_glue}: ${color_okay}enabled
${color_norm}"
}
check_mnt() {
stratum="${1}"
root="$(stratum_root --empty "${stratum}")"
mnt="${2}"
tgt_type="${3}"
tgt_share="${4}"
details="$(mount_details "${stratum}" "${mnt}")"
type="$(echo "${details}" | cut -d: -f1)"
global="$(echo "${details}" | cut -d: -f2)"
shared="$(echo "${details}" | cut -d: -f3)"
if [ "${type}" = "missing" ]; then
problem="${problem} ${color_cmd}${mnt}${color_norm} mount point is ${color_alert}missing${color_norm}\\n"
elif [ -n "${tgt_type}" ] && [ "${type}" != "${tgt_type}" ]; then
problem="${problem} ${color_cmd}${mnt}${color_norm} is ${type} ${color_alert}rather than${color_norm} ${tgt_type}\\n"
elif ! "${global}"; then
problem="${problem} ${color_cmd}${mnt}${color_norm} is ${color_alert}local${color_norm}\\n"
elif ! "${shared}" && "${tgt_share}"; then
problem="${problem} ${color_cmd}${mnt}${color_norm} is ${color_alert}bound${color_norm}\\n"
elif "${shared}" && ! "${tgt_share}"; then
problem="${problem} ${color_cmd}${mnt}${color_norm} is ${color_alert}shared${color_norm}\\n"
fi
}
check_links() {
root="${1}"
for link in $(cfg_keys "symlinks"); do
target="$(cfg_values "symlinks" "${link}")"
actual="$(stinit busybox readlink "${root}${link}")" || true
# hard code /etc/mtab to support effectively equivalent variations of /proc/mounts
if [ "${link}" = "/etc/mtab" ] && [ "${actual}" = "/proc/mounts" ]; then
continue
fi
if [ "${link}" = "/etc/mtab" ] && [ "${actual}" = "../proc/mounts" ]; then
continue
fi
if [ "${link}" = "/etc/mtab" ] && [ "${actual}" = "/proc/self/mounts" ]; then
continue
fi
if [ "${link}" = "/etc/mtab" ] && [ "${actual}" = "../proc/self/mounts" ]; then
continue
fi
if [ "${target}" != "${actual}" ]; then
problem="${problem} ${color_file}${link}${color_norm} is ${color_alert}not a symlink${color_norm} to ${color_file}${target}${color_norm}\\n"
fi
done
}
check_bedrock() {
stratum="${1}"
root="$(stratum_root --empty "${stratum}")"
problem=""
check_links "${root}"
check_mnt "${stratum}" "/proc" "proc" "true"
check_mnt "${stratum}" "/etc" "fuse.etcfs" "false"
check_mnt "${stratum}" "/bedrock/run" "tmpfs" "false"
check_mnt "${stratum}" "/bedrock/strata/bedrock" "" "false"
check_mnt "${stratum}" "/bedrock/cross" "fuse.crossfs" "false"
[ -z "${problem}" ]
}
check_stratum() {
stratum="${1}"
root="$(stratum_root --empty "${stratum}")"
problem=""
check_links "${root}"
for mnt in $(cfg_values "global" "share"); do
check_mnt "${stratum}" "${mnt}" "" "true"
done
for mnt in $(cfg_values "global" "bind"); do
check_mnt "${stratum}" "${mnt}" "" "false"
done
check_mnt "${stratum}" "/etc" "fuse.etcfs" "false"
[ -z "${problem}" ]
}
handle_help "${@:-}"
if [ -n "${1:-}" ]; then
strata="$*"
else
strata="$(/bedrock/libexec/brl-list)"
fi
for stratum in ${strata}; do
problem=""
if ! is_stratum_or_alias "${stratum}"; then
abort "No stratum or alias called \"${stratum}\"."
elif ! has_attr "/bedrock/strata/${stratum}" "show_list"; then
printf "${color_strat}${stratum}${color_glue}: ${color_norm}hidden\\n"
elif ! is_enabled "${stratum}"; then
printf "${color_strat}${stratum}${color_glue}: ${color_norm}disabled\\n"
elif is_bedrock "${stratum}"; then
if check_bedrock "${stratum}"; then
printf "${color_strat}${stratum}${color_glue}: ${color_okay}enabled${color_norm}\\n"
else
printf "${color_strat}${stratum}${color_glue}: ${color_alert}broken${color_norm}\\n"
printf "${problem}"
fi
else
if check_stratum "${stratum}"; then
printf "${color_strat}${stratum}${color_glue}: ${color_okay}enabled${color_norm}\\n"
else
printf "${color_strat}${stratum}${color_glue}: ${color_alert}broken${color_norm}\\n"
printf "${problem}"
fi
fi
done
exit_success

View File

@ -0,0 +1,127 @@
#!/bedrock/libexec/busybox sh
#
# brl tutorial
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# version 2 as published by the Free Software Foundation.
#
# Copyright (c) 2019-2020 Daniel Thau <danthau@bedrocklinux.org>
#
# Interactive tutorial front-end
# shellcheck source=src/slash-bedrock/share/brl-tutorial/common
. /bedrock/share/brl-tutorial/common
lesson_directory="/bedrock/share/brl-tutorial/lessons/"
print_help() {
printf "Usage: ${color_cmd}brl tutorial${color_norm} ${color_sub}<lesson>${color_norm}
Provides an interactive tutorial of various Bedrock Linux features.
Lessons:
$(
cd "${lesson_directory}"
for file in *; do
name="$(echo "${file}" | sed 's/^[0-9]*_//')"
printf " ${color_cmd}%-15s${color_norm}%s\n" "${name}" "$(sh "${file}" help)"
done
)
${color_sub}(more lessons may be added in the future)${color_norm}
Options:
${color_cmd}-h${color_norm}, ${color_cmd}--help${color_norm} print this message
Examples:
${color_cmd}$ brl tutorial basics
${color_norm}<tutorial interface>
${color_norm}"
}
cmd() {
printf "\t${color_cmd}\$ $*${color_norm}"
}
rcmd() {
printf "\t${color_alert}# $*${color_norm}"
}
flag() {
printf "${color_cmd}$1${color_norm}"
}
section() {
title="${1}"
text="${2}"
condition="${3:-}"
spinner="|/-\\"
cursor="1"
clear
step "Lesson: ${lesson}, section: ${title}"
printf "${text}"
echo ""
if [ -n "${condition:-}" ]; then
while ! sh -c "${condition}" >/dev/null 2>&1; do
cursor="$((cursor + 1))"
if [ "${cursor}" -gt 4 ]; then
cursor=1
fi
c="$(echo "${spinner}" | head -c "${cursor}" | tail -c1)"
printf "\r[Run specified commands in another terminal to continue ${c}]"
sleep 1
done
else
printf "[Press ${color_cmd}<ENTER>${color_norm} to continue]"
# Prompt is just used to block. We're purposefully not using
# populated variable.
# shellcheck disable=SC2034
read -r PAUSE
fi
printf "\n"
}
standard_intro() {
printf "This tutorial assumes familiarity with common Linux environment concepts such
as a bourne shell-like command line as well as a working internet connection
and a couple gigabytes of free disk space.
Open another terminal with a bourne-like shell along side this one to follow
along with the tutorial.
If you see a \`${color_cmd}\$${color_norm}\` prompt:
$(cmd "ls")
run the command as your normal, non-root user. If you see a \`${color_alert}#${color_norm}\` prompt:
$(rcmd "whoami")
run the command as root (e.g. ${color_alert}sudo${color_norm}, ${color_cmd}su${color_norm}, etc).
You may press ${color_cmd}<ctrl-c>${color_norm} to exit the tutorial at any point.
"
}
handle_help "${@:-}"
# Find user specified lesson implementation
lesson="${*}"
if [ -z "${lesson}" ]; then
abort "No lesson specified, see --help"
elif ! file="$(echo "${lesson_directory}"*"_${lesson}")"; then
abort "No such lesson \"${lesson}\""
fi
# Run lesson
step_init "$(grep -c "^section " "${file}")"
. "${file}"
clear
printf "This completes the lesson: ${lesson}
Thank you for taking the time to learn about ${Bedrock_Linux}.
"
exit_success

View File

@ -0,0 +1,245 @@
#!/bedrock/libexec/busybox sh
#
# brl update
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# version 2 as published by the Free Software Foundation.
#
# Copyright (c) 2019 Daniel Thau <danthau@bedrocklinux.org>
#
# Updates Bedrock Linux system
. /bedrock/share/common-code
print_help() {
printf "Usage: ${color_cmd}brl update ${color_sub}[options]${color_norm} ${color_sub}[file]${color_norm}
Applies updates to the ${color_term}bedrock stratum${color_norm}.
If a ${color_sub}file${color_norm} is specified, it is applied to the ${color_term}bedrock stratum${color_norm}. Otherwise,
${color_cmd}brl update${color_norm} will attempt to fetch an update from a mirror then apply it.
Options:
${color_cmd}-f, --force${color_norm} ignore warnings when applying update
${color_cmd}-m, --mirror ${color_sub}[mirror]${color_norm} use ${color_sub}mirror${color_norm} when fetching update
${color_cmd}-s, --skip-check ${color_norm}skip cryptographic signature check
${color_cmd}-h${color_norm}, ${color_cmd}--help${color_norm} print this message
Example:
${color_cmd}$ brl version
${color_norm}Bedrock Linux 0.7.7 Poki
${color_rcmd}# brl update ./bedrocklinux-0.7.8-x86_64.sh
${color_sub}<update progress>
${color_cmd}$ brl version
${color_norm}Bedrock Linux 0.7.8 Poki
${color_rcmd}# brl update
${color_sub}<update progress>
${color_cmd}$ brl version
${color_norm}Bedrock Linux 0.7.9 Poki
${color_norm}"
}
download_update() {
notice "Checking for updates"
current_version="$(awk '{print$3}' </bedrock/etc/bedrock-release)"
newest_version="${current_version}"
newest_update_url=""
found_valid_mirror="false"
system_arch="$(get_system_arch)"
for mirror in ${mirrors}; do
# Get releases file. These are lists of Bedrock updates and
# their corresponding URLs.
printf "Checking %s... " "${mirror}"
if ! download "${mirror}" "${releases}" 2>/bedrock/run/tmp; then
echo "ERROR!"
sed 's/^/ /g' /bedrock/run/tmp
continue
fi
found_valid_mirror="true"
echo "done"
# Find the latest update in the update list corresponding to
# the system CPU architecture.
IFS="
"
while read -r update_url; do
if ! echo "${update_url}" | grep -q "^http"; then
continue
fi
arch="$(echo "${update_url}" | awk -F'[-.]' '{print $(NF-1)}')"
if [ "${arch}" != "${system_arch}" ]; then
continue
fi
version="$(echo "${update_url}" | awk -F'-' '{print $(NF-1)}')"
if ver_cmp_first_newer "${version}" "${newest_version}"; then
newest_version="${version}"
newest_update_url="${update_url}"
fi
done <"${releases}"
done
if ! "${found_valid_mirror}"; then
abort "No working mirrors found"
fi
if [ -z "${newest_update_url}" ]; then
notice "No updates"
trap '' EXIT
return
fi
notice "Found update at ${color_link}${newest_update_url}${color_norm}"
notice "Downloading update"
if ! download "${newest_update_url}" "${update}" 2>/bedrock/run/tmp; then
cat /bedrock/run/tmp
abort "Unable to download update."
fi
}
verify_update() {
notice "Preparing gpg"
#
# A gnupg homedir is not intended portable across gnupg versions or
# builds. An exported key file is the intended method of passing keys
# between gnupg builds.
#
# Since we're using a gnupg build from another distro which could
# change between brl-update calls , we have to rebuild a homedir from
# an exported key every time.
#
mkdir -p "${homedir}"
chmod go-rwx "${homedir}"
if ! gpg --homedir "${homedir}" --import /bedrock/gnupg-keys/* 2>/bedrock/run/tmp; then
cat /bedrock/run/tmp
abort "Unable to prepare gpg."
fi
notice "Verifying update"
#
# Bedrock update files are scripts with PGP/GPG signatures appended at
# the end. This is preferred over clearsign because clearsign
# disallows the #!/bin/sh hashbang needed to also make the update work
# as a stand-alone script. The downside is we have to manually extract
# the signature to verify it.
#
# Stand-alone signature extracted from update.
sed -n '/^-----BEGIN PGP SIGNATURE-----$/,/^-----END PGP_SIGNATURE-----$/p' "${update}" >"${update_sig}"
# Update file without embedded signature.
#
# This can - and usually does - contain null characters, which is a
# problem because many UNIX utilities choke on them. busybox `wc -l`
# and `head -n` both seem null safe, as they're focused on newlines.
#
# Given the extracted (ASCII armored, null-free) signature above and
# the entire file we can calculate the number of lines in the raw
# update to extract it.
#
lines_sig="$(wc -l <"${update_sig}")"
lines="$(wc -l <"${update}")"
lines_raw="$((lines - lines_sig))"
head -n "${lines_raw}" "${update}" >"${update_raw}"
if ! gpg --homedir "${homedir}" --verify "${update_sig}" "${update_raw}" 2>/bedrock/run/tmp; then
cat /bedrock/run/tmp
abort "Signature verification failed."
fi
}
handle_help "${@:-}"
require_root
lock
file=""
force="false"
mirror=""
skip_check="false"
OPTL="force,mirror:,skip-check"
OPTO="fm:s"
eval set -- "$(getopt -q -l "${OPTL}" -- "${OPTO}" "${@}")" || true
saw_non_positional="false"
while [ -n "${1:-}" ]; do
case "${1}" in
-f | --force)
force="true"
shift
;;
-m | --mirror)
mirror="${2}"
shift
shift
;;
-s | --skip-check)
skip_check="true"
shift
;;
--)
shift
;;
-*)
if "${saw_non_positional}"; then
eval set -- "$(getopt -q -l "${OPTL}" -- "${OPTO}" "${@}")" || true
saw_non_positional="false"
else
abort "Unrecognized argument: ${1}"
fi
;;
*)
if [ -z "${file}" ]; then
file="${1}"
shift
else
abort "Unrecognized argument: ${1}"
fi
;;
esac
done
releases="/bedrock/var/brl-update/releases"
update="/bedrock/var/brl-update/update.sh"
update_sig="${update}-sig"
update_raw="${update}-raw"
homedir="/bedrock/var/brl-update/gnupg"
# Clean up any files from a previous aborted run
rm -rf "/bedrock/var/brl-update"
mkdir -p "/bedrock/var/brl-update"
if ! "${skip_check}" && ! type gpg >/dev/null 2>&1; then
abort "\`gpg\` required for cryptographic signature verification. Either install it (often in \`gnupg\` package) or use \`--skip-check\` flag to disable check."
fi
if [ -n "${mirror}" ]; then
mirrors="${mirror}"
else
mirrors="$(cfg_values miscellaneous mirrors) $(cfg_values brl-update mirrors)"
fi
if [ -n "${file}" ]; then
cp "${file}" "${update}"
else
download_update
fi
if ! [ -f "${update}" ]; then
exit 0
fi
if "${skip_check}"; then
notice "Skipping update signature verification"
else
verify_update
fi
notice "Applying update"
if "${force}"; then
/bedrock/libexec/busybox sh "${update}" --force-update
else
/bedrock/libexec/busybox sh "${update}" --update
fi
exit_success

View File

@ -0,0 +1,33 @@
#!/bedrock/libexec/busybox sh
#
# brl version
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# version 2 as published by the Free Software Foundation.
#
# Copyright (c) 2016-2018 Daniel Thau <danthau@bedrocklinux.org>
#
# Prints current install's Bedrock Linux version
. /bedrock/share/common-code
print_help() {
printf "Usage: ${color_cmd}brl version ${color_sub}[options]${color_norm}
Prints ${color_bedrock}Bedrock Linux${color_norm} install's version.
Options:
${color_cmd}-h${color_norm}, ${color_cmd}--help${color_norm} print this message
Examples:
${color_cmd}$ brl version
${color_norm}Bedrock Linux 0.7.0 Poki
${color_norm}"
}
handle_help "${@:-}"
cat /bedrock/etc/bedrock-release
exit_success

View File

@ -0,0 +1,175 @@
#!/bedrock/libexec/busybox sh
#
# brl which
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# version 2 as published by the Free Software Foundation.
#
# Copyright (c) 2012-2018 Daniel Thau <danthau@bedrocklinux.org>
#
# Indicates which stratum provides a given object
. /bedrock/share/common-code
print_help() {
printf "Usage: ${color_cmd}brl which ${color_sub}[option] [identifier]${color_norm}
Indicates which ${color_term}stratum${color_norm} provides a given object.
Options:
${color_sub}<none> ${color_norm}guess type from identifier
${color_cmd}-c${color_norm}, ${color_cmd}--current ${color_norm}which ${color_term}stratum${color_norm} provides current process
${color_cmd}-b${color_norm}, ${color_cmd}--bin ${color_norm}which ${color_term}stratum${color_norm} provides a given binary in \$PATH
${color_cmd}-f${color_norm}, ${color_cmd}--file ${color_norm}which ${color_term}stratum${color_norm} provides a given file path
${color_cmd}-p${color_norm}, ${color_cmd}--pid ${color_norm}which ${color_term}stratum${color_norm} provides a given process ID
${color_cmd}-x${color_norm}, ${color_cmd}--xwindow ${color_norm}which ${color_term}stratum${color_norm} provides a given X11 window (requires xprop)
${color_cmd}-h${color_norm}, ${color_cmd}--help ${color_norm}print this message
Guessing reasoning for ${color_sub}<blank>${color_norm} based on identifier:
blank current process (${color_cmd}-c${color_norm})
all digits a process' PID (${color_cmd}-p${color_norm})
contains no slash a binary in the ${color_cmd}\$PATH${color_norm} (${color_cmd}-b${color_norm})
contains a slash a relative or absolute file path (${color_cmd}-f${color_norm})
Examples:
${color_cmd}$ brl which ${color_norm}# which ${color_term}stratum${color_norm} provides the current shell?
${color_strat}void
${color_cmd}$ brl which vim ${color_norm}# which ${color_term}stratum${color_norm} provides the ${color_cmd}vim${color_norm} command?
${color_strat}gentoo
${color_cmd}$ brl which ~/.vimrc ${color_norm}# which ${color_term}stratum${color_norm} provides ${color_cmd}~/.vimrc${color_norm}?
${color_strat}global
${color_cmd}$ brl which /etc/os-release ${color_norm}# which ${color_term}stratum${color_norm} provides ${color_file}/etc/os-release${color_file}?
${color_strat}void
${color_cmd}$ brl which /etc/passwd ${color_norm}# which ${color_term}stratum${color_norm} provides ${color_file}/etc/passwd${color_file}?
${color_strat}global
${color_cmd}$ brl which 1 ${color_norm}# which ${color_term}stratum${color_norm} provides PID1/init?
${color_strat}alpine
${color_cmd}$ brl which -x ${color_norm}# click mouse on X11 window to query provider
${color_strat}arch
${color_norm}"
}
which_current() {
printf "${color_strat}"
get_attr "/" "stratum"
printf "${color_norm}"
}
which_bin() {
while [ -n "${1:-}" ]; do
if busybox which "${1}" >/dev/null 2>&1; then
which_file "$(busybox which "${1}")"
else
abort "\`${1}\` not found in \$PATH"
fi
shift
done
}
which_file() {
while [ -n "${1:-}" ]; do
if ! [ -e "${1}" ]; then
abort "no file at \`${1}\`"
elif has_attr "${1}" "stratum"; then
printf "${color_strat}"
get_attr "${1}" "stratum"
printf "${color_norm}"
elif realpath "${1}" | grep -q '^/bedrock/strata/.'; then
printf "${color_strat}"
realpath "${1}" | cut -d/ -f4
printf "${color_norm}"
elif [ "$(stat "${1}" 2>/dev/null | awk 'NR>1')" = "$(/bedrock/bin/strat bedrock /bedrock/libexec/busybox stat "${1}" 2>/dev/null | awk 'NR>1')" ]; then
printf "${color_strat}"
echo "global"
printf "${color_norm}"
else
which_current
fi
shift
done
}
which_pid() {
while [ -n "${1:-}" ]; do
# Pick a mount point visible to the process.
mount_number="$(head -n1 "/proc/${1}/mountinfo" | cut -d" " -f1)"
# Find where init sees it mounted.
init_view="$(grep "^${mount_number} " /proc/1/mountinfo | cut -d' ' -f5 | head -n1)"
# Find where the process sees it mounted.
stratum_view="$(grep "^${mount_number} " "/proc/${1}/mountinfo" | cut -d' ' -f5 | head -n1)"
# If the process sees it mounted the same place as init does, then the
# process is in the init stratum.
if [ "${init_view}" = "${stratum_view}" ]; then
# Report the name of the init stratum
printf "${color_strat}"
deref init
printf "${color_norm}"
else
# Must be in a stratum other than init
#
# Init will see it mounted at
# <empty>/bedrock/stratum/<stratum-name>/something
# | | | | \- from here on out don't care
# | | | \- stratum name
# | | \- third field
# | \- second field
# \- first (empty) field
#
# Thus, the fourth field will be the stratum. Forward slashes
# are not allowed in Linux file names.
printf "${color_strat}"
echo "${init_view}" | cut -d'/' -f4
printf "${color_norm}"
fi
shift
done
}
which_xwindow() {
if busybox which "xprop" >/dev/null 2>&1; then
which_pid "$(xprop | awk '/PID/{print$NF;exit}')"
else
abort "\`xprop\` not found in \$PATH. Install \`xprop\` to utilize this feature."
fi
}
handle_help "${@:-}"
case "${1:-}" in
"-c" | "--current" | "")
[ -n "${1:-}" ] && shift
which_current "${@}"
;;
"-b" | "--bin")
shift
which_bin "${@}"
;;
"-f" | "--file")
shift
which_file "${@}"
;;
"-p" | "--pid")
shift
which_pid "${@}"
;;
"-x" | "--xwindow")
shift
which_xwindow
;;
*)
while [ -n "${1:-}" ]; do
if echo "${1}" | grep -q '^[0-9][0-9]*$'; then
which_pid "${1}"
elif echo "${1}" | grep -q '/'; then
which_file "${1}"
else
which_bin "${1}"
fi
shift
done
;;
esac
exit_success

1734
src/slash-bedrock/libexec/pmm Executable file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,252 @@
#!/bin/bash
#
# bash tab completion for brl
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# version 2 as published by the Free Software Foundation.
#
# Copyright (c) 2018-2020 Daniel Thau <danthau@bedrocklinux.org>
#
# If none of the $1 have been used, include all of them as possibilities
_brl_unused_all() {
tgts="$1"
shift
used=("$@")
for i in "${used[@]}"; do
for j in ${tgts}; do
if [ "${i}" = "${j}" ]; then
return
fi
done
done
echo "${tgts}"
}
# If any of the $1 have been not been used, include it as a possibility
_brl_unused_any() {
tgts="$1"
shift
used=("$@")
for i in ${tgts}; do
saw=false
for j in "${used[@]}"; do
if [ "${i}" = "${j}" ]; then
saw=true
break
fi
done
if ! "${saw}"; then
echo "${i}"
fi
done
}
_brl() {
cur=${COMP_WORDS[COMP_CWORD]}
prev=${COMP_WORDS[COMP_CWORD - 1]}
opts=""
# Every subcommand has -h/--help.
if [ "${COMP_CWORD}" -lt 3 ]; then
opts="-h --help"
fi
if [ "${COMP_CWORD}" -eq 1 ]; then
opts="${opts} help strat list which fetch"
opts="${opts} remove rename status enable"
opts="${opts} disable reename copy hide show"
opts="${opts} alias deref update reload"
opts="${opts} version report tutorial"
fi
case "${COMP_WORDS[1]}" in
"strat")
_command_offset 1
return
;;
"list")
opts="${opts} $(_brl_unused_all "-e --enabled-strata" "${COMP_WORDS[@]}")"
opts="${opts} $(_brl_unused_all "-E --enabled-aliases" "${COMP_WORDS[@]}")"
opts="${opts} $(_brl_unused_all "-d --disabled-strata" "${COMP_WORDS[@]}")"
opts="${opts} $(_brl_unused_all "-D --disabled-aliases" "${COMP_WORDS[@]}")"
opts="${opts} $(_brl_unused_all "-a --all-strata" "${COMP_WORDS[@]}")"
opts="${opts} $(_brl_unused_all "-A --all-aliases" "${COMP_WORDS[@]}")"
opts="${opts} $(_brl_unused_all "-r --deref" "${COMP_WORDS[@]}")"
opts="${opts} $(_brl_unused_all "-h --help" "${COMP_WORDS[@]}")"
opts="${opts} $(_brl_unused_all "-i --include-hidden" "${COMP_WORDS[@]}")"
;;
"which")
if [ "${COMP_CWORD}" -eq 2 ]; then
opts="${opts} $(_brl_unused_all "-c --current" "${COMP_WORDS[@]}")"
opts="${opts} $(_brl_unused_all "-b --bin" "${COMP_WORDS[@]}")"
opts="${opts} $(_brl_unused_all "-f --file" "${COMP_WORDS[@]}")"
opts="${opts} $(_brl_unused_all "-p --pid" "${COMP_WORDS[@]}")"
opts="${opts} $(_brl_unused_all "-x --xwindow" "${COMP_WORDS[@]}")"
fi
case "${COMP_WORDS[2]}" in
"-c" | "--current") ;;
"-b" | "--bin")
opts="${opts} $(compgen -c -- "${cur}")"
;;
"-f" | "--file")
compopt -o filenames
opts="${opts} $(compgen -d -f -- "${cur}")"
;;
"-p" | "--pid")
opts="${opts} $(/bedrock/libexec/busybox ps -opid)"
;;
"-x" | "--xwindow") ;;
"-h" | "--help") ;;
*)
opts="${opts} $(compgen -c -- "${cur}")"
opts="${opts} $(/bedrock/libexec/busybox ps -opid)"
compopt -o filenames
opts="${opts} $(compgen -d -f -- "${cur}")"
;;
esac
;;
"fetch")
# no completion for these flags
case "${prev}" in
"-n" | "--name")
return
;;
"-r" | "--release")
return
;;
"-a" | "--arch")
return
;;
"-m" | "--mirror")
return
;;
"-l" | "--list")
return
;;
"-x" | "--experimental")
return
;;
*) ;;
esac
if [ "${COMP_CWORD}" -eq 2 ]; then
opts="${opts} $(_brl_unused_all "-l --list" "${COMP_WORDS[@]}")"
opts="${opts} $(_brl_unused_all "-x --experimental" "${COMP_WORDS[@]}")"
fi
opts="${opts} $(_brl_unused_all "-R --releases" "${COMP_WORDS[@]}")"
opts="${opts} $(_brl_unused_all "-A --archs" "${COMP_WORDS[@]}")"
opts="${opts} $(_brl_unused_all "-n --name" "${COMP_WORDS[@]}")"
opts="${opts} $(_brl_unused_all "-r --release" "${COMP_WORDS[@]}")"
opts="${opts} $(_brl_unused_all "-a --arch" "${COMP_WORDS[@]}")"
opts="${opts} $(_brl_unused_all "-m --mirror" "${COMP_WORDS[@]}")"
opts="${opts} $(_brl_unused_all "-e --dont-enable" "${COMP_WORDS[@]}")"
opts="${opts} $(_brl_unused_all "-s --dont-show" "${COMP_WORDS[@]}")"
opts="${opts} $(/bedrock/bin/brl fetch --list)"
;;
"import")
if [ "${COMP_CWORD}" -eq 3 ]; then
compopt -o filenames
opts="${opts} $(compgen -d -f -- "${cur}")"
fi
;;
"remove")
opts="${opts} $(_brl_unused_all "-d --disable" "${COMP_WORDS[@]}")"
saw_disable_flag=false
for word in "${@}"; do
if [ "${word}" = "-d" ] || [ "${word}" = "--disable" ]; then
saw_disable_flag=true
fi
done
if "${saw_disable_flag}"; then
opts="${opts} $(/bedrock/bin/brl list -aAi | grep -ve "^bedrock\$" -ve "^init\$")"
else
opts="${opts} $(/bedrock/bin/brl list -dDi | grep -ve "^bedrock\$" -ve "^init\$")"
fi
;;
"rename")
if [ "${COMP_CWORD}" -eq 2 ]; then
opts="${opts} $(/bedrock/bin/brl list -dD | grep -ve "^bedrock$" -ve "^init$")"
fi
;;
"copy")
if [ "${COMP_CWORD}" -eq 2 ]; then
opts="${opts} $(/bedrock/bin/brl list -dD)"
fi
;;
"status")
opts="${opts} $(/bedrock/bin/brl list -aA)"
;;
"enable")
opts="${opts} $(/bedrock/bin/brl list -dD)"
;;
"disable")
for stratum in $(brl list -eE); do
if [ "$(/bedrock/bin/brl deref "${stratum}")" = "bedrock" ]; then
continue
elif [ "$(/bedrock/bin/brl deref "${stratum}")" = "$(/bedrock/bin/brl deref init)" ]; then
continue
fi
opts="${opts} ${stratum}"
done
;;
"repair")
opts="${opts} $(/bedrock/bin/brl list -aA)"
;;
"hide")
opts="${opts} $(_brl_unused_all "-a --all" "${COMP_WORDS[@]}")"
opts="${opts} $(_brl_unused_all "-b --boot" "${COMP_WORDS[@]}")"
opts="${opts} $(_brl_unused_all "-c --cross" "${COMP_WORDS[@]}")"
opts="${opts} $(_brl_unused_all "-i --init" "${COMP_WORDS[@]}")"
opts="${opts} $(/bedrock/bin/brl list -aA)"
;;
"show")
opts="${opts} $(_brl_unused_all "-a --all" "${COMP_WORDS[@]}")"
opts="${opts} $(_brl_unused_all "-b --boot" "${COMP_WORDS[@]}")"
opts="${opts} $(_brl_unused_all "-c --cross" "${COMP_WORDS[@]}")"
opts="${opts} $(_brl_unused_all "-i --init" "${COMP_WORDS[@]}")"
opts="${opts} $(/bedrock/bin/brl list -aAi)"
;;
"alias")
if [ "${COMP_CWORD}" -eq 2 ]; then
opts="${opts} $(/bedrock/bin/brl list -a)"
fi
;;
"deref")
if [ "${COMP_CWORD}" -eq 2 ]; then
opts="${opts} $(/bedrock/bin/brl list -A)"
fi
;;
"update")
opts="${opts} $(_brl_unused_all "-m --mirror" "${COMP_WORDS[@]}")"
opts="${opts} $(_brl_unused_all "-s --skip-check" "${COMP_WORDS[@]}")"
opts="${opts} $(_brl_unused_all "-f --force" "${COMP_WORDS[@]}")"
compopt -o filenames
opts="${opts} $(compgen -d -f -- "${cur}")"
;;
"apply") ;;
# no parameters other than -h/--help
"version") ;;
# no parameters other than -h/--help
"report")
opts="${opts} $(_brl_unused_all "-o --overwrite" "${COMP_WORDS[@]}")"
compopt -o filenames
opts="${opts} $(compgen -d -f -- "${cur}")"
;;
"tutorial")
opts="${opts} $(find /bedrock/share/brl-tutorial/lessons/ -mindepth 1 | sed 's/^.*[0-9][0-9]*_//')"
;;
esac
# Explicitly desire splitting here.
# shellcheck disable=SC2207
COMPREPLY=($(compgen -W "${opts}" -- "${cur}"))
}
complete -F _brl brl

View File

@ -0,0 +1,81 @@
#!/bin/bash
#
# bash tab completion for strat
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# version 2 as published by the Free Software Foundation.
#
# Copyright (c) 2018-2019 Daniel Thau <danthau@bedrocklinux.org>
#
_strat() {
cur=${COMP_WORDS[COMP_CWORD]}
# stages:
# - parsing flags
# - arg0's arg
# - stratum
# - command
saw_help=0
saw_local=0
saw_restrict=0
saw_arg0=0
saw_arg0_arg=0
saw_stratum=0
saw_command=0
for ((i = 1; i < COMP_CWORD; i++)); do
case "${COMP_WORDS[i]}" in
"-h" | "--help")
saw_help=${i}
;;
"-l" | "--local")
saw_local=${i}
;;
"-r" | "--restrict")
saw_restrict=${i}
;;
"-a" | "--arg0")
saw_arg0=${i}
[[ "${COMP_CWORD}" -gt $((i + 1)) ]] && saw_arg0_arg=$((++i))
;;
*)
if [[ "${saw_stratum}" -eq 0 ]]; then
saw_stratum=${i}
else
saw_command=${i}
break
fi
;;
esac
done
opts=""
if [[ "${saw_arg0}" -gt 0 ]] && [[ "${saw_arg0_arg}" -eq 0 ]]; then
# no completion for arg0
return
elif [[ "${saw_stratum}" -eq 0 ]]; then
opts="${opts} $(/bedrock/bin/brl list)"
[ "${saw_help}" -eq 0 ] && opts="${opts} -h --help"
[ "${saw_local}" -eq 0 ] && opts="${opts} -l --local"
[ "${saw_restrict}" -eq 0 ] && opts="${opts} -r --restrict"
[ "${saw_arg0}" -eq 0 ] && opts="${opts} -a --arg0"
elif [[ "${saw_command}" -eq 0 ]]; then
prefix="/bedrock/strata/${COMP_WORDS[saw_stratum]}"
for dir in ${PATH//:/ }; do
if ! echo "${dir}" | grep -q "^/bedrock/cross/"; then
opts="${opts} $(/bedrock/libexec/busybox ls -1 "${prefix}${dir}" 2>/dev/null)"
fi
done
else
_command_offset "${saw_command}"
return
fi
# Explicitly desire splitting here.
# shellcheck disable=SC2207
COMPREPLY=($(compgen -W "${opts}" -- "${cur}"))
}
complete -F _strat strat

View File

@ -0,0 +1,117 @@
#!/bedrock/libexec/busybox sh
#
# openSUSE bootstrap support
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# version 2 as published by the Free Software Foundation.
#
# Copyright (c) 2016-2019 Daniel Thau <danthau@bedrocklinux.org>
#
#
# Some package has a dependency on "this-is-only-for-build-envs" but a
# corresponding provider does not appear in the repository. Given this, the
# fetch fails. Thus, this is disabled.
#
. /bedrock/share/common-code
trap 'fetch_abort "Unexpected error occurred."' EXIT
check_supported() {
false
}
speed_test_url() {
echo "distribution/leap/${target_release:-}/repo/oss/suse/repodata/appdata-screenshots.tar"
}
list_mirrors() {
# from https://mirrors.opensuse.org/
#
# The master download server, download.opensuse.org, automatically redirects you to a server near you
#
echo "https://download.opensuse.org"
}
# Could not find adequate evidence of support for non-x86_64 architectures. For example, the repo here:
#
# https://download.opensuse.org/distribution/leap/15.1/repo/oss/
#
# only lists the x86_64 architecture.
brl_arch_to_distro() {
case "${1}" in
"x86_64") echo "x86_64" ;;
*) abort "brl does not know how to translate arch \"${1}\" to ${distro:-} format" ;;
esac
}
list_architectures() {
echo "x86_64"
}
#
# OpenSUSE 14 was named 42. However, the following version went back 15. For
# sorting purposes, place 42 where 14 would normally go.
#
default_release() {
list_releases |
sed 's/^42\>/14/' |
sort -n |
sed 's/^14\>/42/' |
tail -n1
}
list_releases() {
wget -O- 'https://download.opensuse.org/distribution/leap/' 2>/dev/null |
awk '/folder/,/<\/table>/' |
list_links |
grep '^[0-9][0-9.]*/$' |
sed 's,/$,,' |
sed 's/^42\>/14/' |
sort -n |
sed 's/^14\>/42/' |
uniq
}
fetch() {
step "Downloading package information database"
url="$(find_link "${target_mirror:-}/distribution/leap/${target_release:-}/repo/oss/repodata/" "primary.xml.gz")"
wget -O "${bootstrap_dir:-}/primary.xml.gz" "${url}"
step "Converting distro package information database to brl format"
gunzip "${bootstrap_dir:-}/primary.xml.gz"
rpmdb_to_brldb "${bootstrap_dir:-}/primary.xml" "${bootstrap_dir:-}/brldb"
step "Calculating required bootstrap packages"
brldb_calculate_paths_with_deps "${bootstrap_dir:-}/brldb" "${bootstrap_dir:-}/package_paths" "zypper rpm openSUSE-release filesystem ca-certificates ca-certificates-cacert"
step "Downloading bootstrap packages"
download_files "${bootstrap_dir:-}" "$(awk -v"m=${target_mirror:-}/distribution/leap/${target_release:-}/repo/oss/" '{print m"/"$0}' "${bootstrap_dir:-}/package_paths")"
step "Extracting bootstrap packages"
# This round is just to bootstrap the distro's rpm.
# Next step we'll use the distro's rpm to install everything properly.
# Need to extract filesystem first to ensure symlinks are set up
extract_rpms "${bootstrap_dir:-}" "${bootstrap_dir:-}"/filesystem*.rpm "${bootstrap_dir:-}"/*.rpm
step "Installing bootstrap packages"
setup_chroot "${bootstrap_dir:-}"
LC_ALL=C chroot "${bootstrap_dir:-}" rpm -i ./*.rpm
step "Running bootstrap software"
chroot "${bootstrap_dir:-}" rpm -i --root=/target-root --nodeps openSUSE-release-*.rpm
chroot "${bootstrap_dir:-}" zypper --non-interactive --root=/target-root ar -f "http://download.opensuse.org/distribution/leap/${target_release:-}/repo/oss/" repo-oss
chroot "${bootstrap_dir:-}" zypper --non-interactive --root=/target-root ar -f "http://download.opensuse.org/update/leap/${target_release:-}/oss/" update-oss
chroot "${bootstrap_dir:-}" zypper --non-interactive --gpg-auto-import-keys --root=/target-root refresh
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
step "Configuring"
# Some pre/post install hooks do not seem to take from the bootstrap environment. Need to be installed in the environment proper.
setup_chroot "${target_dir:-}"
chroot "${target_dir:-}" zypper --non-interactive ar -f "http://download.opensuse.org/distribution/leap/${target_release:-}/repo/oss/" repo-oss || true
chroot "${target_dir:-}" zypper --non-interactive ar -f "http://download.opensuse.org/update/leap/${target_release:-}/oss/" update-oss || true
chroot "${target_dir:-}" zypper --non-interactive --gpg-auto-import-keys refresh
chroot "${target_dir:-}" zypper --non-interactive --gpg-auto-import-keys install -f zypper rpm openSUSE-release filesystem ca-certificates ca-certificates-cacert
}

View File

@ -0,0 +1,133 @@
#!/bedrock/libexec/busybox sh
#
# Parabola GNU/Linux-libre bootstrap support
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# version 2 as published by the Free Software Foundation.
#
# Copyright (c) 2016-2020 Daniel Thau <danthau@bedrocklinux.org>
#
# shellcheck source=src/slash-bedrock/libexec/brl-fetch
. /bedrock/share/common-code
trap 'fetch_abort "Unexpected error occurred."' EXIT
check_supported() {
false
}
speed_test_url() {
echo "core/os/${distro_arch}/core.db.tar.gz"
}
list_mirrors() {
mirror_list_url='https://www.parabola.nu/mirrorlist/all/'
wget -O- "${mirror_list_url}" 2>/dev/null |
awk -F "[ $]" ' /^#Server/ {print$3} '
}
brl_arch_to_distro() {
case "${1}" in
"armv7hl") echo "armv7h" ;;
"i686") echo "i686" ;;
"ppc64le") echo "ppc64le" ;;
"x86_64") echo "x86_64" ;;
*) abort "brl does not know how to translate arch \"${1}\" to ${distro} format" ;;
esac
}
list_architectures() {
cat <<EOF
armv7hl
i686
ppc64le
x86_64
EOF
}
default_release() {
echo "rolling"
}
list_releases() {
echo "rolling"
}
setup_pacman() {
# Remove auto architecture detection, as it will confuse things like
# i686 on an x86_64 box and armv7hl on a aarch64 box.
#
# Also remove CheckSpace, which sometimes gets confused by Bedrock's
# mount setup.
sed 's/^Architecture[ \t]*=.*$//' "${1}/etc/pacman.conf" |
awk -v"a=${distro_arch}" '{print} $0 == "[options]" {print "Architecture = "a}' |
sed 's/^[ \t]*CheckSpace/# &/' \
>"${1}/etc/pacman.conf-new"
mv "${1}/etc/pacman.conf-new" "${1}/etc/pacman.conf"
LC_ALL=C chroot "${1}" /usr/bin/update-ca-trust
LC_ALL=C chroot "${1}" /usr/bin/pacman-key --init
LC_ALL=C chroot "${1}" /usr/bin/pacman-key --populate archlinux archlinux32 archlinuxarm parabola
LC_ALL=C chroot "${1}" /usr/bin/pacman-key --refresh-keys
if ! grep -q "^Server" "${1}/etc/pacman.d/mirrorlist"; then
echo "### Set by Bedrock Linux when acquiring this stratum" >>"${1}/etc/pacman.d/mirrorlist"
echo "Server = ${target_mirror}/\$repo/os/\$arch" >>"$1/etc/pacman.d/mirrorlist"
fi
}
fetch() {
bootstrap_deps="arch-install-scripts"
step "Downloading package information database"
wget -O "${bootstrap_dir}/core.db.tar.gz" "${target_mirror}/core/os/${distro_arch}/core.db.tar.gz"
wget -O "${bootstrap_dir}/extra.db.tar.gz" "${target_mirror}/extra/os/${distro_arch}/extra.db.tar.gz"
wget -O "${bootstrap_dir}/libre.db.tar.gz" "${target_mirror}/libre/os/${distro_arch}/libre.db.tar.gz"
step "Decompressing package information database"
mkdir -p "${bootstrap_dir}/pacmandb/core" "${bootstrap_dir}/pacmandb/extra" "${bootstrap_dir}/pacmandb/libre"
(
tar -xv -f "${bootstrap_dir}/core.db.tar.gz" -C "${bootstrap_dir}/pacmandb/core/"
tar -xv -f "${bootstrap_dir}/extra.db.tar.gz" -C "${bootstrap_dir}/pacmandb/extra/"
tar -xv -f "${bootstrap_dir}/libre.db.tar.gz" -C "${bootstrap_dir}/pacmandb/libre/"
) | awk 'NR%100==0' | progress_unknown
step "Converting distro package information database to brl format"
pacmandb_to_brldb "${bootstrap_dir}/pacmandb" "${bootstrap_dir}/brldb"
step "Calculating required bootstrap packages"
brldb_calculate_required_packages "${bootstrap_dir}/brldb" "${bootstrap_dir}/required_packages" "${bootstrap_deps}"
step "Downloading bootstrap packages"
# brldb contains repo/filename
# files are at mirror/repo/os/arch/filename
checksum_downloads "${cache}/packages/" "$(awk -v"a=${distro_arch}" -v"m=${target_mirror}" '{sub("/", "/os/"a"/"); print m"/"$0}' "${bootstrap_dir}/required_packages")"
step "Extracting bootstrap packages"
bootstrap_packages="$(awk -v"d=${cache}/packages/" '{sub(/^.*\//,d);print $1}' "${bootstrap_dir}/required_packages")"
# shellcheck disable=SC2086
extract_pacman_pkgs "${bootstrap_dir}" ${bootstrap_packages}
step "Running bootstrap software"
# pacstrap mounts devtmpfs (which is shared with the host system) and
# chowns files in it based on /etc/passwd and /etc/group. Ensure
# system copies of files are used to avoid problematic file ownership
# change in /dev.
mkdir -p "${target_dir}/etc"
cp -a "/etc/passwd" "${target_dir}/etc/passwd"
cp -a "/etc/group" "${target_dir}/etc/group"
setup_chroot "${bootstrap_dir}"
setup_pacman "${bootstrap_dir}"
share_cache "packages" "${bootstrap_dir}/target-root/var/cache/pacman/pkg/"
LC_ALL=C chroot "${bootstrap_dir}" pacstrap "/target-root" base
step "Configuring"
setup_chroot "${target_dir}"
setup_pacman "${target_dir}"
cp "${cache}/packages/"* "${target_dir}/var/cache/pacman/"
if LC_ALL=C chroot "${target_dir}" pacman -Q linux >/dev/null 2>&1; then
LC_ALL=C chroot "${target_dir}" pacman --noconfirm -R linux
fi
}

View File

@ -0,0 +1,117 @@
#!/bedrock/libexec/busybox sh
#
# Trisquel bootstrap support
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# version 2 as published by the Free Software Foundation.
#
# Copyright (c) 2016-2020 Daniel Thau <danthau@bedrocklinux.org>
#
# shellcheck source=src/slash-bedrock/libexec/brl-fetch
. /bedrock/share/common-code
trap 'fetch_abort "Unexpected error occurred."' EXIT
check_supported() {
false
}
speed_test_url() {
echo "dists/${target_release}/Release"
}
list_mirrors() {
echo 'http://archive.trisquel.info/trisquel'
mirror_list_url='https://trisquel.info/mirmon/index.html'
wget -O- "${mirror_list_url}" 2>/dev/null |
awk '/<H2>report<.H2>/,/<.TABLE>/' |
list_links |
grep "^http"
}
brl_arch_to_distro() {
case "${1}" in
"i686") echo "i386" ;;
"x86_64") echo "amd64" ;;
*) abort "brl does not know how to translate arch \"${1}\" to ${distro} format" ;;
esac
}
list_architectures() {
cat <<EOF
i686
x86_64
EOF
}
default_release() {
wget -O- 'http://mirror.fsf.org/trisquel/meta-release' 2>/dev/null | awk '
$1 == "Name:" {
name = tolower($2)
}
$1 == "Version:" {
version = $2
gsub(/[^0-9.]/, "", version)
}
name != "" && version != "" {
if (version > best_version) {
best_name = name
best_version = version
}
}
END {
print best_name
}
'
}
list_releases() {
wget -O- 'http://mirror.fsf.org/trisquel/meta-release' 2>/dev/null | awk '$1=="Name:" {print $2}'
}
fetch() {
# trisquel 8.0 flidas does not have debootstrap?
bootstrap_deps="debootstrap apt dpkg coreutils dash bash grep sed awk perl bzip2 gzip tar gpgv trisquel-keyring"
step "Downloading package information database"
wget -O "${bootstrap_dir}/Packages.gz" "${target_mirror}/dists/${target_release}/main/binary-${distro_arch}/Packages.gz"
gunzip "${bootstrap_dir}/Packages.gz"
step "Converting distro package information database to brl format"
debdb_to_brldb "${bootstrap_dir}/Packages" "${bootstrap_dir}/brldb"
step "Calculating required bootstrap packages"
brldb_calculate_required_packages "${bootstrap_dir}/brldb" "${bootstrap_dir}/required_packages" "${bootstrap_deps}"
step "Downloading bootstrap packages"
checksum_downloads "${cache}/packages/" "$(awk -v"m=${target_mirror}" '{print m"/"$0}' "${bootstrap_dir}/required_packages")"
step "Extracting bootstrap packages"
bootstrap_packages="$(awk -v"d=${cache}/packages/" '{sub(/^.*\//,d);print $1}' "${bootstrap_dir}/required_packages")"
# shellcheck disable=SC2086
extract_debs "${bootstrap_dir}" ${bootstrap_packages}
step "Running bootstrap software"
setup_chroot "${bootstrap_dir}"
set +o pipefail
if LANG=C chroot "${bootstrap_dir}" debootstrap --help | grep -q "cache-dir"; then
share_cache "packages" "${bootstrap_dir}/packages"
yes "" | LANG=C chroot "${bootstrap_dir}" debootstrap --variant=minbase --cache-dir="/packages" "${target_release}" "/target-root" "${target_mirror}"
else
yes "" | LANG=C chroot "${bootstrap_dir}" debootstrap --variant=minbase "${target_release}" "/target-root" "${target_mirror}"
fi
set -o pipefail
step "Configuring"
echo "deb ${target_mirror} ${target_release}-security main" >>"${target_dir}/etc/apt/sources.list"
echo "deb ${target_mirror} ${target_release}-updates main" >>"${target_dir}/etc/apt/sources.list"
setup_chroot "${target_dir}"
autopkgs="$(LANG=C chroot "${target_dir}" /usr/bin/apt-mark showmanual)"
set +o pipefail
# word splitting is desired here
# shellcheck disable=SC2086
yes "" | LANG=C chroot "${target_dir}" /usr/bin/apt-mark auto ${autopkgs}
yes "" | LANG=C chroot "${target_dir}" /usr/bin/apt-get update
set -o pipefail
}

View File

@ -0,0 +1,151 @@
#!/bedrock/libexec/busybox sh
#
# Alma bootstrap support
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# version 2 as published by the Free Software Foundation.
#
# Copyright (c) 2016-2021 Daniel Thau <danthau@bedrocklinux.org>
#
# shellcheck source=src/slash-bedrock/libexec/brl-fetch
. /bedrock/share/common-code
trap 'fetch_abort "Unexpected error occurred."' EXIT
check_supported() {
false
}
get_mirror_suffix() {
if [ "$(echo "${target_release}" | sed 's/-[a-z]*$//')" -lt 8 ]; then
echo "${target_release}/os/${distro_arch}/"
else
echo "${target_release}/BaseOS/${distro_arch}/os"
fi
}
speed_test_url() {
echo "$(get_mirror_suffix)/repodata/repomd.xml"
}
list_mirrors() {
mirror_list_url='https://mirrors.almalinux.org/'
download -q "${mirror_list_url}" - |
awk '/<table/,/<\/table/' |
sed 's/[<>]/\n/g' |
grep 'a href="http' |
list_links
}
brl_arch_to_distro() {
case "${1}" in
"x86_64") echo "x86_64" ;;
"aarch64") echo "aarch64" ;;
*) abort "brl does not know how to translate arch \"${1}\" to ${distro} format" ;;
esac
}
list_architectures() {
cat <<EOF
aarch64
x86_64
EOF
}
default_release() {
list_releases |
grep -ve "[a-z-]" | # do not default stream releases, only fixed ones
sort -n |
tail -n1
}
list_releases() {
for mirror in "${flag_mirror}" "https://rsync.repo.almalinux.org/almalinux/"; do
if download -q "${mirror}" - |
list_links |
grep '^[0-9][0-9a-z-]*/$' |
sed 's,/$,,'; then
break
fi
done
}
bootstrap_deps() {
echo "dnf rpm almalinux-release filesystem"
}
fetch() {
suffix="$(get_mirror_suffix)"
step "Downloading package information database"
url="$(find_link "${target_mirror}/${suffix}/repodata/" "primary.xml.gz")"
download "${url}" "${bootstrap_dir}/primary.xml.gz"
step "Extracting package information database"
gunzip "${bootstrap_dir}/primary.xml.gz"
step "Converting distro package information database to brl format"
if [ "${target_arch}" = i686 ]; then
# CentOS arch name is i386 in mirrors but i686 in package manager
distro_arch="i686" rpmdb_to_brldb "${bootstrap_dir}/primary.xml" "${bootstrap_dir}/brldb"
else
rpmdb_to_brldb "${bootstrap_dir}/primary.xml" "${bootstrap_dir}/brldb"
fi
# At the time of writing, the CentOS 8/8-stream primary.xml.gz
# incorrectly indicates platform-python requires
# /usr/libexec/platform-python rather than provides it. Hack in a fix.
if [ "$(echo "${target_release}" | sed 's/-[a-z]*$//')" -ge 8 ]; then
echo "/usr/libexec/platform-python platform-python" >>"${bootstrap_dir}/brldb/provides/u"
fi
step "Calculating required bootstrap packages"
brldb_calculate_required_packages "${bootstrap_dir}/brldb" "${bootstrap_dir}/required_packages" "$(bootstrap_deps)"
step "Downloading bootstrap packages"
checksum_downloads "${cache}/packages/" "$(awk -v"m=${target_mirror}/${suffix}" '{print m"/"$0}' "${bootstrap_dir}/required_packages")"
step "Extracting bootstrap packages"
# This round is just to bootstrap the distro's rpm.
# Next step we'll use the distro's rpm to install everything properly.
# Need to extract filesystem first to ensure symlinks are set up
bootstrap_packages="$(awk -v"d=${cache}/packages/" '{sub(/^.*\//,d);print $1}' "${bootstrap_dir}/required_packages")"
# shellcheck disable=SC2086
extract_rpms "${bootstrap_dir}" "${cache}/packages"/filesystem*.rpm ${bootstrap_packages}
step "Installing bootstrap packages"
setup_chroot "${bootstrap_dir}"
# setup_ssl "${bootstrap_dir}" # fights with yum/dnf later on, not actually needed
share_cache "packages" "${bootstrap_dir}/packages"
bootstrap_packages="$(awk -v"d=/packages/" '{sub(/^.*\//,d);print $1}' "${bootstrap_dir}/required_packages")"
# shellcheck disable=SC2086
LC_ALL=C chroot "${bootstrap_dir}" sh -c 'rpm --import /etc/pki/rpm-gpg/*'
LC_ALL=C chroot "${bootstrap_dir}" rpm -i ${bootstrap_packages}
step "Running bootstrap software"
# By default, dnf clears anything in its package cache.
# Configure them to retain them so we can leverage previous cached
# packages.
if [ -e "${bootstrap_dir}/etc/dnf/dnf.conf" ] && grep -q "^keepcache=1$" "${bootstrap_dir}/etc/dnf/dnf.conf"; then
share_cache "dnf-cache" "${bootstrap_dir}/target-root/var/cache/dnf"
elif [ -e "${bootstrap_dir}/etc/dnf/dnf.conf" ] && grep -q "^keepcache=0$" "${bootstrap_dir}/etc/dnf/dnf.conf"; then
sed 's/^keepcache=0$/keepcache=1/' "${bootstrap_dir}/etc/dnf/dnf.conf" >"${bootstrap_dir}/etc/dnf/dnf.conf-new"
mv "${bootstrap_dir}/etc/dnf/dnf.conf-new" "${bootstrap_dir}/etc/dnf/dnf.conf"
share_cache "dnf-cache" "${bootstrap_dir}/target-root/var/cache/dnf"
elif [ -r "${bootstrap_dir}/etc/dnf/dnf.conf" ]; then
echo "keepcache=1" >>"${bootstrap_dir}/etc/dnf/dnf.conf"
share_cache "dnf-cache" "${bootstrap_dir}/target-root/var/cache/dnf"
fi
LC_ALL=C chroot "${bootstrap_dir}" rpm -i --root=/target-root --nodeps ./packages/centos-release-*.rpm 2>/dev/null || true
if [ "$(echo "${target_release}" | sed 's/-[a-z]*$//')" -lt 8 ]; then
LC_ALL=C chroot "${bootstrap_dir}" dnf --installroot=/target-root install -y rpm-build dnf
else
LC_ALL=C chroot "${bootstrap_dir}" dnf --installroot=/target-root --releasever="${target_release}" install -y rpm-build dnf
fi
# Need to set database timestamps for pmm due to `dnf -C` usage
umount -l "${bootstrap_dir}/var/cache/dnf" >/dev/null 2>&1 || true
setup_chroot "${target_dir}"
LC_ALL=C chroot "${target_dir}" dnf -y update
}

View File

@ -0,0 +1,126 @@
#!/bedrock/libexec/busybox sh
#
# Alpine Linux bootstrap support
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# version 2 as published by the Free Software Foundation.
#
# Copyright (c) 2016-2019 Daniel Thau <danthau@bedrocklinux.org>
#
# shellcheck source=src/slash-bedrock/libexec/brl-fetch
. /bedrock/share/common-code
trap 'fetch_abort "Unexpected error occurred."' EXIT
check_supported() {
true
}
speed_test_url() {
echo "latest-stable/main/${distro_arch}/APKINDEX.tar.gz"
}
list_mirrors() {
mirror_list_url='http://nl.alpinelinux.org/alpine/MIRRORS.txt'
download -q "${mirror_list_url}" -
}
brl_arch_to_distro() {
case "${1}" in
"aarch64") echo "aarch64" ;;
"armv7hl") echo "armhf" ;;
"armv7l") echo "armv7" ;;
"ppc64le") echo "ppc64le" ;;
"s390x") echo "s3960x" ;;
"i586") echo "x86" ;;
"x86_64") echo "x86_64" ;;
*) abort "brl does not know how to translate arch \"${1}\" to ${distro} format" ;;
esac
}
list_architectures() {
cat <<EOF
aarch64
armv7hl
armv7l
ppc64le
s390x
i586
x86_64
EOF
}
default_release() {
echo "latest-stable"
}
list_releases() {
for mirror in "${flag_mirror}" $(list_mirrors); do
# get list of all releases, irrelevant of architecture
if ! release_pages="$(download -q "${mirror}" - |
list_links |
grep '/$')"; then
continue
fi
for page in ${release_pages}; do
# find architectures supported by given release
page_archs="$(download -q "${mirror}/${page}/main/" - |
list_links | sed -e 's,/$,,')"
# print release if it supports architecture
for arch in ${page_archs}; do
if [ "${arch}" = "${distro_arch}" ]; then
echo "${page}" | sed -e 's/^v//' -e 's,/$,,'
break
fi
done
done
break
done
}
fetch() {
if echo "${target_release}" | grep -q "^[0-9.]*$"; then
mirror_release="v${target_release}"
else
mirror_release="${target_release}"
fi
step "Downloading bootstrap software"
# The mirror does provide a checksum in APKINDEX.tar.gz we could use to
# verify against a cache, but it is not trivial to extract into a
# useable format.
url="$(find_link "${target_mirror}/${mirror_release}/main/${distro_arch}/" "^apk-tools-static.*.apk")"
download "${url}" "${bootstrap_dir}/apk-tools-static.apk"
step "Preparing bootstrap software"
tar xf "${bootstrap_dir}/apk-tools-static.apk" -O sbin/apk.static >"${bootstrap_dir}/apk"
chmod a+rx "${bootstrap_dir}/apk"
mkdir -p "${target_dir}/etc/apk/"
step "Running bootstrap software"
setup_chroot "${bootstrap_dir}"
setup_ssl "${bootstrap_dir}"
# apk does not appear to cache downloaded packages anywhere we forward
# from a previous fetch.
set +o pipefail
yes "" | LC_ALL=C chroot "${bootstrap_dir}" /apk -X "${target_mirror}/${mirror_release}/main" -U --allow-untrusted --root "/target-root" --initdb add alpine-base
set -o pipefail
step "Configuring"
setup_chroot "${target_dir}"
echo "${target_mirror}/${mirror_release}/main" >"${target_dir}/etc/apk/repositories"
LC_ALL=C chroot "${target_dir}" /sbin/rc-update add devfs sysinit
LC_ALL=C chroot "${target_dir}" /sbin/rc-update add dmesg sysinit
LC_ALL=C chroot "${target_dir}" /sbin/rc-update add mdev sysinit
LC_ALL=C chroot "${target_dir}" /sbin/rc-update add networking sysinit
LC_ALL=C chroot "${target_dir}" /sbin/rc-update add hwclock boot
LC_ALL=C chroot "${target_dir}" /sbin/rc-update add modules boot
LC_ALL=C chroot "${target_dir}" /sbin/rc-update add sysctl boot
LC_ALL=C chroot "${target_dir}" /sbin/rc-update add hostname boot
LC_ALL=C chroot "${target_dir}" /sbin/rc-update add bootmisc boot
LC_ALL=C chroot "${target_dir}" /sbin/rc-update add syslog boot
LC_ALL=C chroot "${target_dir}" /sbin/rc-update add mount-ro shutdown
LC_ALL=C chroot "${target_dir}" /sbin/rc-update add killprocs shutdown
LC_ALL=C chroot "${target_dir}" /sbin/rc-update add savecache shutdown
}

View File

@ -0,0 +1,128 @@
#!/bedrock/libexec/busybox sh
#
# Arch Linux bootstrap support
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# version 2 as published by the Free Software Foundation.
#
# Copyright (c) 2016-2019 Daniel Thau <danthau@bedrocklinux.org>
#
# shellcheck source=src/slash-bedrock/libexec/brl-fetch
. /bedrock/share/common-code
trap 'fetch_abort "Unexpected error occurred."' EXIT
check_supported() {
true
}
speed_test_url() {
echo "core/os/${distro_arch}/core.db.tar.gz"
}
list_mirrors() {
# All mirrors:
# mirror_list_url='https://www.archlinux.org/mirrorlist/all/'
# Server-side filtered list of mirrors:
mirror_list_url='https://www.archlinux.org/mirrorlist/?country=all&protocol=https&ip_version=4&ip_version=6&use_mirror_status=on'
download -q "${mirror_list_url}" - |
awk -F "[ $]" ' /^#Server/ {print$3} '
}
brl_arch_to_distro() {
case "${1}" in
"x86_64") echo "x86_64" ;;
*) abort "brl does not know how to translate arch \"${1}\" to ${distro} format" ;;
esac
}
list_architectures() {
echo "x86_64"
}
default_release() {
echo "rolling"
}
list_releases() {
echo "rolling"
}
setup_pacman() {
# Remove auto architecture detection, as it will confuse things like
# i686 on an x86_64 box and armv7hl on a aarch64 box.
#
# Also remove CheckSpace, which sometimes gets confused by Bedrock's
# mount setup.
sed 's/^Architecture[ \t]*=.*$//' "${1}/etc/pacman.conf" |
awk -v"a=${distro_arch}" '{print} $0 == "[options]" {print "Architecture = "a}' |
sed 's/^[ \t]*CheckSpace/# &/' \
>"${1}/etc/pacman.conf-new"
mv "${1}/etc/pacman.conf-new" "${1}/etc/pacman.conf"
LC_ALL=C chroot "${1}" /usr/bin/update-ca-trust
LC_ALL=C chroot "${1}" /usr/bin/pacman-key --init
LC_ALL=C chroot "${1}" /usr/bin/pacman-key --populate archlinux
if ! grep -q "^Server" "${1}/etc/pacman.d/mirrorlist"; then
echo "### Set by Bedrock Linux when acquiring this stratum" >>"${1}/etc/pacman.d/mirrorlist"
echo "Server = ${target_mirror}/\$repo/os/\$arch" >>"$1/etc/pacman.d/mirrorlist"
fi
}
fetch() {
bootstrap_deps="arch-install-scripts"
step "Downloading package information database"
download "${target_mirror}/core/os/${distro_arch}/core.db.tar.gz" "${bootstrap_dir}/core.db.tar.gz"
download "${target_mirror}/extra/os/${distro_arch}/extra.db.tar.gz" "${bootstrap_dir}/extra.db.tar.gz"
download "${target_mirror}/community/os/${distro_arch}/community.db.tar.gz" "${bootstrap_dir}/community.db.tar.gz"
step "Decompressing package information database"
mkdir -p "${bootstrap_dir}/pacmandb/core" "${bootstrap_dir}/pacmandb/extra" "${bootstrap_dir}/pacmandb/community"
(
tar -xv -f "${bootstrap_dir}/core.db.tar.gz" -C "${bootstrap_dir}/pacmandb/core/"
tar -xv -f "${bootstrap_dir}/extra.db.tar.gz" -C "${bootstrap_dir}/pacmandb/extra/"
tar -xv -f "${bootstrap_dir}/community.db.tar.gz" -C "${bootstrap_dir}/pacmandb/community/"
) | awk 'NR%100==0' | progress_unknown
step "Converting distro package information database to brl format"
pacmandb_to_brldb "${bootstrap_dir}/pacmandb" "${bootstrap_dir}/brldb"
step "Calculating required bootstrap packages"
brldb_calculate_required_packages "${bootstrap_dir}/brldb" "${bootstrap_dir}/required_packages" "${bootstrap_deps}"
step "Downloading bootstrap packages"
# brldb contains repo/filename
# files are at mirror/repo/os/arch/filename
checksum_downloads "${cache}/packages/" "$(awk -v"a=${distro_arch}" -v"m=${target_mirror}" '{sub("/", "/os/"a"/"); print m"/"$0}' "${bootstrap_dir}/required_packages")"
step "Extracting bootstrap packages"
bootstrap_packages="$(awk -v"d=${cache}/packages/" '{sub(/^.*\//,d);print $1}' "${bootstrap_dir}/required_packages")"
# shellcheck disable=SC2086
extract_pacman_pkgs "${bootstrap_dir}" ${bootstrap_packages}
step "Running bootstrap software"
# pacstrap mounts devtmpfs (which is shared with the host system) and
# chowns files in it based on /etc/passwd and /etc/group. Ensure
# system copies of files are used to avoid problematic file ownership
# change in /dev.
mkdir -p "${target_dir}/etc"
cp -a "/etc/passwd" "${target_dir}/etc/passwd"
cp -a "/etc/group" "${target_dir}/etc/group"
setup_chroot "${bootstrap_dir}"
setup_ssl "${bootstrap_dir}"
setup_pacman "${bootstrap_dir}"
share_cache "packages" "${bootstrap_dir}/target-root/var/cache/pacman/pkg/"
LC_ALL=C chroot "${bootstrap_dir}" pacstrap "/target-root" base
step "Configuring"
setup_chroot "${target_dir}"
setup_pacman "${target_dir}"
cp "${cache}/packages/"* "${target_dir}/var/cache/pacman/"
if LC_ALL=C chroot "${target_dir}" pacman -Q linux >/dev/null 2>&1; then
LC_ALL=C chroot "${target_dir}" pacman --noconfirm -R linux
fi
}

View File

@ -0,0 +1,129 @@
#!/bedrock/libexec/busybox sh
#
# Arch Linux 32 bootstrap support
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# version 2 as published by the Free Software Foundation.
#
# Copyright (c) 2016-2019 Daniel Thau <danthau@bedrocklinux.org>
#
# shellcheck source=src/slash-bedrock/libexec/brl-fetch
. /bedrock/share/common-code
trap 'fetch_abort "Unexpected error occurred."' EXIT
check_supported() {
true
}
speed_test_url() {
echo "${distro_arch}/core/core.db.tar.gz"
}
list_mirrors() {
mirror_list_url='https://www.archlinux32.org/mirrorlist/?country=all'
download -q "${mirror_list_url}" - |
sed 's/^# *//' |
awk -F "[ $]" '/^Server/{print$3}'
}
brl_arch_to_distro() {
# Arch Linux 32 also supports Pentium 4 / Netburst / i786. However,
# they are the only distro to do so, and at the time of writing it is
# not deemed worthwhile to support an architecture only utilized by one
# distro, especially since it is compatible with i686.
case "${1}" in
"i486") echo "i486" ;;
"i686") echo "i686" ;;
*) abort "brl does not know how to translate arch \"${1}\" to ${distro} format" ;;
esac
}
list_architectures() {
cat <<EOF
i486
i686
EOF
}
default_release() {
echo "rolling"
}
list_releases() {
echo "rolling"
}
setup_pacman() {
sed 's/^Architecture[ \t]*=.*$//' "${1}/etc/pacman.conf" |
awk -v"a=${distro_arch}" '{print} $0 == "[options]" {print "Architecture = "a}' |
sed 's/^[ \t]*CheckSpace/# &/' \
>"${1}/etc/pacman.conf-new"
mv "${1}/etc/pacman.conf-new" "${1}/etc/pacman.conf"
LC_ALL=C chroot "${1}" /usr/bin/update-ca-trust
LC_ALL=C chroot "${1}" /usr/bin/pacman-key --init
LC_ALL=C chroot "${1}" /usr/bin/pacman-key --populate archlinux32
if ! grep -q "^Server" "${1}/etc/pacman.d/mirrorlist"; then
echo "### Set by Bedrock Linux when acquiring this stratum" >>"${1}/etc/pacman.d/mirrorlist"
echo "Server = ${target_mirror}/\$arch/\$repo" >>"$1/etc/pacman.d/mirrorlist"
fi
}
fetch() {
bootstrap_deps="arch-install-scripts"
step "Downloading package information database"
download "${target_mirror}/${distro_arch}/core/core.db.tar.gz" "${bootstrap_dir}/core.db.tar.gz"
download "${target_mirror}/${distro_arch}/extra/extra.db.tar.gz" "${bootstrap_dir}/extra.db.tar.gz"
download "${target_mirror}/${distro_arch}/community/community.db.tar.gz" "${bootstrap_dir}/community.db.tar.gz"
step "Decompressing package information database"
mkdir -p "${bootstrap_dir}/pacmandb/core" "${bootstrap_dir}/pacmandb/extra" "${bootstrap_dir}/pacmandb/community"
(
tar -xv -f "${bootstrap_dir}/core.db.tar.gz" -C "${bootstrap_dir}/pacmandb/core/"
tar -xv -f "${bootstrap_dir}/extra.db.tar.gz" -C "${bootstrap_dir}/pacmandb/extra/"
tar -xv -f "${bootstrap_dir}/community.db.tar.gz" -C "${bootstrap_dir}/pacmandb/community/"
) | awk 'NR%100==0' | progress_unknown
step "Converting distro package information database to brl format"
pacmandb_to_brldb "${bootstrap_dir}/pacmandb" "${bootstrap_dir}/brldb"
step "Calculating required bootstrap packages"
brldb_calculate_required_packages "${bootstrap_dir}/brldb" "${bootstrap_dir}/required_packages" "${bootstrap_deps}"
step "Downloading bootstrap packages"
# brldb contains repo/filename
# files are at mirror/arch/repo/filename
checksum_downloads "${cache}/packages/" "$(awk -v"a=${distro_arch}" -v"m=${target_mirror}" '{print m"/"a"/"$0}' "${bootstrap_dir}/required_packages")"
step "Extracting bootstrap packages"
bootstrap_packages="$(awk -v"d=${cache}/packages/" '{sub(/^.*\//,d);print $1}' "${bootstrap_dir}/required_packages")"
# shellcheck disable=SC2086
extract_pacman_pkgs "${bootstrap_dir}" ${bootstrap_packages}
step "Running bootstrap software"
# pacstrap mounts devtmpfs (which is shared with the host system) and
# chowns files in it based on /etc/passwd and /etc/group. Ensure
# system copies of files are used to avoid problematic file ownership
# change in /dev.
mkdir -p "${target_dir}/etc"
cp -a "/etc/passwd" "${target_dir}/etc/passwd"
cp -a "/etc/group" "${target_dir}/etc/group"
setup_chroot "${bootstrap_dir}"
setup_ssl "${bootstrap_dir}"
setup_pacman "${bootstrap_dir}"
share_cache "packages" "${bootstrap_dir}/target-root/var/cache/pacman/pkg/"
LC_ALL=C chroot "${bootstrap_dir}" pacstrap "/target-root" base
step "Configuring"
setup_chroot "${target_dir}"
setup_pacman "${target_dir}"
cp "${cache}/packages/"* "${target_dir}/var/cache/pacman/"
if LC_ALL=C chroot "${target_dir}" pacman -Q linux >/dev/null 2>&1; then
LC_ALL=C chroot "${target_dir}" pacman --noconfirm -R linux
fi
}

View File

@ -0,0 +1,138 @@
#!/bedrock/libexec/busybox sh
#
# Arch Linux ARM bootstrap support
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# version 2 as published by the Free Software Foundation.
#
# Copyright (c) 2016-2019 Daniel Thau <danthau@bedrocklinux.org>
#
# shellcheck source=src/slash-bedrock/libexec/brl-fetch
. /bedrock/share/common-code
trap 'fetch_abort "Unexpected error occurred."' EXIT
check_supported() {
true
}
speed_test_url() {
echo "${distro_arch}/core/core.db.tar.gz"
}
list_mirrors() {
mirror_list_url='https://archlinuxarm.org/packages/any/pacman-mirrorlist/files/mirrorlist'
download -q "${mirror_list_url}" - |
awk '/\<code\>/,/<\/code>/' |
sed 's/^# *//' |
awk -F "[ $]" '/^Server/{print$3}'
}
brl_arch_to_distro() {
case "${1}" in
"aarch64") echo "aarch64" ;;
"armv7hl") echo "armv7h" ;;
*) abort "brl does not know how to translate arch \"${1}\" to ${distro} format. Manually specify another architecture with the \`-a\` flag." ;;
esac
}
brl_arch_to_image_name() {
case "${1}" in
"aarch64") echo "ArchLinuxARM-aarch64-latest.tar.gz" ;;
"armv7hl") echo "ArchLinuxARM-armv7-latest.tar.gz" ;;
*) abort "brl does not know how to translate arch \"${1}\" to ${distro} bootstrap file name. Manually specify another architecture with the \`-a\` flag." ;;
esac
}
# Current strategy uses pre-made image to bootstrap system. Could not find an
# image for armv7l, and thus it is removed for the time being. In the future
# we could refactor to actually parse the repos ourselves to build a bootstrap
# environment, which could then use the armv7l repos.
list_architectures() {
cat <<EOF
aarch64
armv7hl
EOF
}
default_release() {
echo "rolling"
}
list_releases() {
echo "rolling"
}
setup_pacman() {
sed 's/^Architecture[ \t]*=.*$//' "${1}/etc/pacman.conf" |
awk -v"a=${distro_arch}" '{print} $0 == "[options]" {print "Architecture = "a}' |
sed 's/^[ \t]*CheckSpace/# &/' \
>"${1}/etc/pacman.conf-new"
mv "${1}/etc/pacman.conf-new" "${1}/etc/pacman.conf"
LC_ALL=C chroot "${1}" /usr/bin/update-ca-trust
LC_ALL=C chroot "${1}" /usr/bin/pacman-key --init
LC_ALL=C chroot "${1}" /usr/bin/pacman-key --populate archlinuxarm
if ! grep -q "^Server" "${1}/etc/pacman.d/mirrorlist"; then
echo "### Set by Bedrock Linux when acquiring this stratum" >>"${1}/etc/pacman.d/mirrorlist"
echo "Server = ${target_mirror}/\$arch/\$repo" >>"$1/etc/pacman.d/mirrorlist"
fi
}
fetch() {
bootstrap_deps="arch-install-scripts"
step "Downloading package information database"
download "${target_mirror}/${distro_arch}/core/core.db.tar.gz" "${bootstrap_dir}/core.db.tar.gz"
download "${target_mirror}/${distro_arch}/extra/extra.db.tar.gz" "${bootstrap_dir}/extra.db.tar.gz"
download "${target_mirror}/${distro_arch}/community/community.db.tar.gz" "${bootstrap_dir}/community.db.tar.gz"
step "Decompressing package information database"
mkdir -p "${bootstrap_dir}/pacmandb/core" "${bootstrap_dir}/pacmandb/extra" "${bootstrap_dir}/pacmandb/community"
(
tar -xv -f "${bootstrap_dir}/core.db.tar.gz" -C "${bootstrap_dir}/pacmandb/core/"
tar -xv -f "${bootstrap_dir}/extra.db.tar.gz" -C "${bootstrap_dir}/pacmandb/extra/"
tar -xv -f "${bootstrap_dir}/community.db.tar.gz" -C "${bootstrap_dir}/pacmandb/community/"
) | awk 'NR%100==0' | progress_unknown
step "Converting distro package information database to brl format"
pacmandb_to_brldb "${bootstrap_dir}/pacmandb" "${bootstrap_dir}/brldb"
step "Calculating required bootstrap packages"
brldb_calculate_required_packages "${bootstrap_dir}/brldb" "${bootstrap_dir}/required_packages" "${bootstrap_deps}"
step "Downloading bootstrap packages"
# brldb contains repo/filename
# files are at mirror/arch/repo/filename
checksum_downloads "${cache}/packages/" "$(awk -v"a=${distro_arch}" -v"m=${target_mirror}" '{print m"/"a"/"$0}' "${bootstrap_dir}/required_packages")"
step "Extracting bootstrap packages"
bootstrap_packages="$(awk -v"d=${cache}/packages/" '{sub(/^.*\//,d);print $1}' "${bootstrap_dir}/required_packages")"
# shellcheck disable=SC2086
extract_pacman_pkgs "${bootstrap_dir}" ${bootstrap_packages}
step "Running bootstrap software"
# pacstrap mounts devtmpfs (which is shared with the host system) and
# chowns files in it based on /etc/passwd and /etc/group. Ensure
# system copies of files are used to avoid problematic file ownership
# change in /dev.
mkdir -p "${target_dir}/etc"
cp -a "/etc/passwd" "${target_dir}/etc/passwd"
cp -a "/etc/group" "${target_dir}/etc/group"
setup_chroot "${bootstrap_dir}"
setup_ssl "${bootstrap_dir}"
setup_pacman "${bootstrap_dir}"
share_cache "packages" "${bootstrap_dir}/target-root/var/cache/pacman/pkg/"
LC_ALL=C chroot "${bootstrap_dir}" pacstrap "/target-root" base
step "Configuring"
setup_chroot "${target_dir}"
setup_pacman "${target_dir}"
cp "${cache}/packages/"* "${target_dir}/var/cache/pacman/"
if LC_ALL=C chroot "${target_dir}" pacman -Q linux >/dev/null 2>&1; then
LC_ALL=C chroot "${target_dir}" pacman --noconfirm -R linux
fi
}

View File

@ -0,0 +1,128 @@
#!/bedrock/libexec/busybox sh
#
# Artix Linux bootstrap support
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# version 2 as published by the Free Software Foundation.
#
# Copyright (c) 2016-2019 Daniel Thau <danthau@bedrocklinux.org>
#
# shellcheck source=src/slash-bedrock/libexec/brl-fetch
. /bedrock/share/common-code
trap 'fetch_abort "Unexpected error occurred."' EXIT
check_supported() {
false
}
speed_test_url() {
echo "system/os/${distro_arch}/system.db.tar.gz"
}
list_mirrors() {
# All mirrors:
# Server-side filtered list of mirrors:
mirror_list_url="https://raw.githubusercontent.com/artix-linux/packages/master/artix-mirrorlist/repos/core-any/mirrorlist"
download -q "${mirror_list_url}" - |
awk -F "[ $]" ' /^Server/ {print$3} '
}
brl_arch_to_distro() {
case "${1}" in
"x86_64") echo "x86_64" ;;
*) abort "brl does not know how to translate arch \"${1}\" to ${distro} format" ;;
esac
}
list_architectures() {
echo "x86_64"
}
default_release() {
echo "rolling"
}
list_releases() {
echo "rolling"
}
setup_pacman() {
# Remove auto architecture detection, as it will confuse things like
# i686 on an x86_64 box and armv7hl on a aarch64 box.
#
# Also remove CheckSpace, which sometimes gets confused by Bedrock's
# mount setup.
sed 's/^Architecture[ \t]*=.*$//' "${1}/etc/pacman.conf" |
awk -v"a=${distro_arch}" '{print} $0 == "[options]" {print "Architecture = "a}' |
sed 's/^[ \t]*CheckSpace/# &/' \
>"${1}/etc/pacman.conf-new"
mv "${1}/etc/pacman.conf-new" "${1}/etc/pacman.conf"
LC_ALL=C chroot "${1}" /usr/bin/update-ca-trust
LC_ALL=C chroot "${1}" /usr/bin/pacman-key --init
LC_ALL=C chroot "${1}" /usr/bin/pacman-key --populate artix
if ! grep -q "^Server" "${1}/etc/pacman.d/mirrorlist"; then
echo "### Set by Bedrock Linux when acquiring this stratum" >>"${1}/etc/pacman.d/mirrorlist"
echo "Server = ${target_mirror}/\$repo/os/\$arch" >>"$1/etc/pacman.d/mirrorlist"
fi
}
fetch() {
bootstrap_deps="artools-base util-linux gettext pacman"
step "Downloading package information database"
download "${target_mirror}/system/os/${distro_arch}/system.db.tar.gz" "${bootstrap_dir}/system.db.tar.gz"
download "${target_mirror}/world/os/${distro_arch}/world.db.tar.gz" "${bootstrap_dir}/world.db.tar.gz"
download "${target_mirror}/galaxy/os/${distro_arch}/galaxy.db.tar.gz" "${bootstrap_dir}/galaxy.db.tar.gz"
step "Decompressing package information database"
mkdir -p "${bootstrap_dir}/pacmandb/system" "${bootstrap_dir}/pacmandb/world" "${bootstrap_dir}/pacmandb/galaxy"
(
tar -xv -f "${bootstrap_dir}/system.db.tar.gz" -C "${bootstrap_dir}/pacmandb/system/"
tar -xv -f "${bootstrap_dir}/world.db.tar.gz" -C "${bootstrap_dir}/pacmandb/world/"
tar -xv -f "${bootstrap_dir}/galaxy.db.tar.gz" -C "${bootstrap_dir}/pacmandb/galaxy/"
) | awk 'NR%100==0' | progress_unknown
step "Converting distro package information database to brl format"
pacmandb_to_brldb "${bootstrap_dir}/pacmandb" "${bootstrap_dir}/brldb"
step "Calculating required bootstrap packages"
brldb_calculate_required_packages "${bootstrap_dir}/brldb" "${bootstrap_dir}/required_packages" "${bootstrap_deps}"
step "Downloading bootstrap packages"
# brldb contains repo/filename
# files are at mirror/repo/os/arch/filename
checksum_downloads "${cache}/packages/" "$(awk -v"a=${distro_arch}" -v"m=${target_mirror}" '{sub("/", "/os/"a"/"); print m"/"$0}' "${bootstrap_dir}/required_packages")"
step "Extracting bootstrap packages"
bootstrap_packages="$(awk -v"d=${cache}/packages/" '{sub(/^.*\//,d);print $1}' "${bootstrap_dir}/required_packages")"
# shellcheck disable=SC2086
extract_pacman_pkgs "${bootstrap_dir}" ${bootstrap_packages}
step "Running bootstrap software"
# pacstrap mounts devtmpfs (which is shared with the host system) and
# chowns files in it based on /etc/passwd and /etc/group. Ensure
# system copies of files are used to avoid problematic file ownership
# change in /dev.
mkdir -p "${target_dir}/etc"
cp -a "/etc/passwd" "${target_dir}/etc/passwd"
cp -a "/etc/group" "${target_dir}/etc/group"
setup_chroot "${bootstrap_dir}"
setup_ssl "${bootstrap_dir}"
setup_pacman "${bootstrap_dir}"
share_cache "packages" "${bootstrap_dir}/target-root/var/cache/pacman/pkg/"
# sed is not included in base, but is needed to basestrap.
LC_ALL=C chroot "${bootstrap_dir}" basestrap "/target-root" base sed
step "Configuring"
setup_chroot "${target_dir}"
setup_pacman "${target_dir}"
cp "${cache}/packages/"* "${target_dir}/var/cache/pacman/"
if LC_ALL=C chroot "${target_dir}" pacman -Q linux >/dev/null 2>&1; then
LC_ALL=C chroot "${target_dir}" pacman --noconfirm -R linux
fi
}

View File

@ -0,0 +1,128 @@
#!/bedrock/libexec/busybox sh
#
# Artix Linux with s6 init bootstrap support
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# version 2 as published by the Free Software Foundation.
#
# Copyright (c) 2016-2021 Daniel Thau <danthau@bedrocklinux.org>
#
# shellcheck source=src/slash-bedrock/libexec/brl-fetch
. /bedrock/share/common-code
trap 'fetch_abort "Unexpected error occurred."' EXIT
check_supported() {
false
}
speed_test_url() {
echo "system/os/${distro_arch}/system.db.tar.gz"
}
list_mirrors() {
# All mirrors:
# Server-side filtered list of mirrors:
mirror_list_url="https://raw.githubusercontent.com/artix-linux/packages/master/artix-mirrorlist/repos/core-any/mirrorlist"
download -q "${mirror_list_url}" - |
awk -F "[ $]" ' /^Server/ {print$3} '
}
brl_arch_to_distro() {
case "${1}" in
"x86_64") echo "x86_64" ;;
*) abort "brl does not know how to translate arch \"${1}\" to ${distro} format" ;;
esac
}
list_architectures() {
echo "x86_64"
}
default_release() {
echo "rolling"
}
list_releases() {
echo "rolling"
}
setup_pacman() {
# Remove auto architecture detection, as it will confuse things like
# i686 on an x86_64 box and armv7hl on a aarch64 box.
#
# Also remove CheckSpace, which sometimes gets confused by Bedrock's
# mount setup.
sed 's/^Architecture[ \t]*=.*$//' "${1}/etc/pacman.conf" |
awk -v"a=${distro_arch}" '{print} $0 == "[options]" {print "Architecture = "a}' |
sed 's/^[ \t]*CheckSpace/# &/' \
>"${1}/etc/pacman.conf-new"
mv "${1}/etc/pacman.conf-new" "${1}/etc/pacman.conf"
LC_ALL=C chroot "${1}" /usr/bin/update-ca-trust
LC_ALL=C chroot "${1}" /usr/bin/pacman-key --init
LC_ALL=C chroot "${1}" /usr/bin/pacman-key --populate artix
if ! grep -q "^Server" "${1}/etc/pacman.d/mirrorlist"; then
echo "### Set by Bedrock Linux when acquiring this stratum" >>"${1}/etc/pacman.d/mirrorlist"
echo "Server = ${target_mirror}/\$repo/os/\$arch" >>"$1/etc/pacman.d/mirrorlist"
fi
}
fetch() {
bootstrap_deps="artools-base util-linux gettext pacman"
step "Downloading package information database"
download "${target_mirror}/system/os/${distro_arch}/system.db.tar.gz" "${bootstrap_dir}/system.db.tar.gz"
download "${target_mirror}/world/os/${distro_arch}/world.db.tar.gz" "${bootstrap_dir}/world.db.tar.gz"
download "${target_mirror}/galaxy/os/${distro_arch}/galaxy.db.tar.gz" "${bootstrap_dir}/galaxy.db.tar.gz"
step "Decompressing package information database"
mkdir -p "${bootstrap_dir}/pacmandb/system" "${bootstrap_dir}/pacmandb/world" "${bootstrap_dir}/pacmandb/galaxy"
(
tar -xv -f "${bootstrap_dir}/system.db.tar.gz" -C "${bootstrap_dir}/pacmandb/system/"
tar -xv -f "${bootstrap_dir}/world.db.tar.gz" -C "${bootstrap_dir}/pacmandb/world/"
tar -xv -f "${bootstrap_dir}/galaxy.db.tar.gz" -C "${bootstrap_dir}/pacmandb/galaxy/"
) | awk 'NR%100==0' | progress_unknown
step "Converting distro package information database to brl format"
pacmandb_to_brldb "${bootstrap_dir}/pacmandb" "${bootstrap_dir}/brldb"
step "Calculating required bootstrap packages"
brldb_calculate_required_packages "${bootstrap_dir}/brldb" "${bootstrap_dir}/required_packages" "${bootstrap_deps}"
step "Downloading bootstrap packages"
# brldb contains repo/filename
# files are at mirror/repo/os/arch/filename
checksum_downloads "${cache}/packages/" "$(awk -v"a=${distro_arch}" -v"m=${target_mirror}" '{sub("/", "/os/"a"/"); print m"/"$0}' "${bootstrap_dir}/required_packages")"
step "Extracting bootstrap packages"
bootstrap_packages="$(awk -v"d=${cache}/packages/" '{sub(/^.*\//,d);print $1}' "${bootstrap_dir}/required_packages")"
# shellcheck disable=SC2086
extract_pacman_pkgs "${bootstrap_dir}" ${bootstrap_packages}
step "Running bootstrap software"
# pacstrap mounts devtmpfs (which is shared with the host system) and
# chowns files in it based on /etc/passwd and /etc/group. Ensure
# system copies of files are used to avoid problematic file ownership
# change in /dev.
mkdir -p "${target_dir}/etc"
cp -a "/etc/passwd" "${target_dir}/etc/passwd"
cp -a "/etc/group" "${target_dir}/etc/group"
setup_chroot "${bootstrap_dir}"
setup_ssl "${bootstrap_dir}"
setup_pacman "${bootstrap_dir}"
share_cache "packages" "${bootstrap_dir}/target-root/var/cache/pacman/pkg/"
# sed is not included in base, but is needed to basestrap.
LC_ALL=C chroot "${bootstrap_dir}" basestrap "/target-root" base sed s6-base dbus-s6 elogind-s6 eudev-s6
step "Configuring"
setup_chroot "${target_dir}"
setup_pacman "${target_dir}"
cp "${cache}/packages/"* "${target_dir}/var/cache/pacman/"
if LC_ALL=C chroot "${target_dir}" pacman -Q linux >/dev/null 2>&1; then
LC_ALL=C chroot "${target_dir}" pacman --noconfirm -R linux
fi
}

View File

@ -0,0 +1,204 @@
#!/bedrock/libexec/busybox sh
#
# CentOS bootstrap support
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# version 2 as published by the Free Software Foundation.
#
# Copyright (c) 2016-2021 Daniel Thau <danthau@bedrocklinux.org>
#
# shellcheck source=src/slash-bedrock/libexec/brl-fetch
. /bedrock/share/common-code
trap 'fetch_abort "Unexpected error occurred."' EXIT
check_supported() {
true
}
get_mirror_suffix() {
if [ "$(echo "${target_release}" | sed 's/-[a-z]*$//')" -lt 8 ]; then
echo "${target_release}/os/${distro_arch}/"
else
echo "${target_release}/BaseOS/${distro_arch}/os/"
fi
}
speed_test_url() {
echo "$(get_mirror_suffix)/repodata/repomd.xml"
}
list_mirrors() {
if [ "$(echo "${target_release}" | sed 's/-[a-z]*$//')" -lt 8 ]; then
repo="os"
else
repo="BaseOS"
fi
#
# The API hit below will return mirrors with a repository suffix.
# However, user-provided mirrors will most likely not include such a
# suffix. To enforce uniformity, strip the repository suffix.
#
download -q "http://mirrorlist.centos.org/?release=${target_release}&arch=${distro_arch}&repo=${repo}" - |
awk -vsuffix="$(get_mirror_suffix)" '{
sl=length(suffix)
ml=length($0)
$0=substr($0, 0, ml-sl)
sub(/[0-9.]*$/,"")
print
}'
}
brl_arch_to_distro() {
case "${1}" in
"aarch64") echo "aarch64" ;;
"armv7hl") echo "armhfp" ;;
"ppc64le") echo "ppc64le" ;;
# Mirrors call it i386, but repo calls it i686.
"i686") echo "i386" ;;
"x86_64") echo "x86_64" ;;
*) abort "brl does not know how to translate arch \"${1}\" to ${distro} format" ;;
esac
}
list_architectures() {
cat <<EOF
aarch64
armv7hl
ppc64le
i686
x86_64
EOF
}
default_release() {
list_releases |
sort -n |
tail -n1
}
list_releases() {
for mirror in "${flag_mirror}" "http://mirror.centos.org/centos/"; do
if download -q "${mirror}" - |
list_links |
grep '^[0-9][0-9a-z-]*/$' |
sed 's,/$,,'; then
break
fi
done
}
determine_package_manager() {
if [ -e "${bootstrap_dir}/brldb/depends/dn" ] && grep -q '^dnf\>' "${bootstrap_dir}/brldb/depends/dn"; then
echo "dnf"
else
echo "yum"
fi
}
bootstrap_deps() {
echo "${package_manager} rpm centos-release filesystem shadow-utils"
# At the time of writing, CentOS 8-stream no longer includes repos as a dependency of the package manager
if echo "${target_release}" | grep -q stream; then
echo "centos-stream-repos centos-gpg-keys"
fi
}
fetch() {
suffix="$(get_mirror_suffix)"
step "Downloading package information database"
url="$(find_link "${target_mirror}/${suffix}/repodata/" "primary.xml.gz")"
download "${url}" "${bootstrap_dir}/primary.xml.gz"
step "Extracting package information database"
gunzip "${bootstrap_dir}/primary.xml.gz"
step "Converting distro package information database to brl format"
if [ "${target_arch}" = i686 ]; then
# CentOS arch name is i386 in mirrors but i686 in package manager
distro_arch="i686" rpmdb_to_brldb "${bootstrap_dir}/primary.xml" "${bootstrap_dir}/brldb"
else
rpmdb_to_brldb "${bootstrap_dir}/primary.xml" "${bootstrap_dir}/brldb"
fi
# At the time of writing, the CentOS 8/8-stream primary.xml.gz
# incorrectly indicates platform-python requires
# /usr/libexec/platform-python rather than provides it. Hack in a fix.
if [ "$(echo "${target_release}" | sed 's/-[a-z]*$//')" -ge 8 ]; then
echo "/usr/libexec/platform-python platform-python" >>"${bootstrap_dir}/brldb/provides/u"
fi
step "Calculating required bootstrap packages"
package_manager="$(determine_package_manager)"
brldb_calculate_required_packages "${bootstrap_dir}/brldb" "${bootstrap_dir}/required_packages" "$(bootstrap_deps)"
step "Downloading bootstrap packages"
checksum_downloads "${cache}/packages/" "$(awk -v"m=${target_mirror}/${suffix}" '{print m"/"$0}' "${bootstrap_dir}/required_packages")"
step "Extracting bootstrap packages"
# This round is just to bootstrap the distro's rpm.
# Next step we'll use the distro's rpm to install everything properly.
# Need to extract filesystem first to ensure symlinks are set up
bootstrap_packages="$(awk -v"d=${cache}/packages/" '{sub(/^.*\//,d);print $1}' "${bootstrap_dir}/required_packages")"
# shellcheck disable=SC2086
extract_rpms "${bootstrap_dir}" "${cache}/packages"/filesystem*.rpm ${bootstrap_packages}
step "Installing bootstrap packages"
setup_chroot "${bootstrap_dir}"
# setup_ssl "${bootstrap_dir}" # fights with yum/dnf later on, not actually needed
share_cache "packages" "${bootstrap_dir}/packages"
bootstrap_packages="$(awk -v"d=/packages/" '{sub(/^.*\//,d);print $1}' "${bootstrap_dir}/required_packages")"
# shellcheck disable=SC2086
LC_ALL=C chroot "${bootstrap_dir}" sh -c 'rpm --import /etc/pki/rpm-gpg/*'
LC_ALL=C chroot "${bootstrap_dir}" rpm -i ${bootstrap_packages}
step "Running bootstrap software"
# By default, yum and dnf clear anything in their package cache.
# Configure them to retain them so we can leverage previous cached
# packages.
if [ -e "${bootstrap_dir}/etc/dnf/dnf.conf" ] && grep -q "^keepcache=1$" "${bootstrap_dir}/etc/dnf/dnf.conf"; then
share_cache "dnf-cache" "${bootstrap_dir}/target-root/var/cache/dnf"
elif [ -e "${bootstrap_dir}/etc/dnf/dnf.conf" ] && grep -q "^keepcache=0$" "${bootstrap_dir}/etc/dnf/dnf.conf"; then
sed 's/^keepcache=0$/keepcache=1/' "${bootstrap_dir}/etc/dnf/dnf.conf" >"${bootstrap_dir}/etc/dnf/dnf.conf-new"
mv "${bootstrap_dir}/etc/dnf/dnf.conf-new" "${bootstrap_dir}/etc/dnf/dnf.conf"
share_cache "dnf-cache" "${bootstrap_dir}/target-root/var/cache/dnf"
elif [ -r "${bootstrap_dir}/etc/dnf/dnf.conf" ]; then
echo "keepcache=1" >>"${bootstrap_dir}/etc/dnf/dnf.conf"
share_cache "dnf-cache" "${bootstrap_dir}/target-root/var/cache/dnf"
elif [ -e "${bootstrap_dir}/etc/yum.conf" ] && grep -q "^keepcache=1$" "${bootstrap_dir}/etc/yum.conf"; then
share_cache "yum-cache" "${bootstrap_dir}/target-root/var/cache/yum"
elif [ -e "${bootstrap_dir}/etc/yum.conf" ] && grep -q "^keepcache=0$" "${bootstrap_dir}/etc/yum.conf"; then
sed 's/^keepcache=0$/keepcache=1/' "${bootstrap_dir}/etc/yum.conf" >"${bootstrap_dir}/etc/yum.conf-new"
mv "${bootstrap_dir}/etc/yum.conf-new" "${bootstrap_dir}/etc/yum.conf"
share_cache "yum-cache" "${bootstrap_dir}/target-root/var/cache/yum"
elif [ -r "${bootstrap_dir}/etc/yum.conf" ]; then
echo "keepcache=1" >>"${bootstrap_dir}/etc/yum.conf"
share_cache "yum-cache" "${bootstrap_dir}/target-root/var/cache/yum"
fi
# Configure the package manager to utilize the desired architecture
if [ "${target_arch}" = "i686" ]; then
mkdir -p "${bootstrap_dir}/etc/${package_manager}/vars/"
echo 'i686' >"${bootstrap_dir}/etc/${package_manager}/vars/arch"
echo 'i386' >"${bootstrap_dir}/etc/${package_manager}/vars/basearch"
mkdir -p "${target_dir}/etc/${package_manager}/vars/"
echo 'i686' >"${target_dir}/etc/${package_manager}/vars/arch"
echo 'i386' >"${target_dir}/etc/${package_manager}/vars/basearch"
fi
LC_ALL=C chroot "${bootstrap_dir}" rpm -i --root=/target-root --nodeps ./packages/centos-release-*.rpm 2>/dev/null || true
if [ "$(echo "${target_release}" | sed 's/-[a-z]*$//')" -lt 8 ]; then
LC_ALL=C chroot "${bootstrap_dir}" "${package_manager}" --installroot=/target-root install -y rpm-build "${package_manager}"
else
LC_ALL=C chroot "${bootstrap_dir}" "${package_manager}" --installroot=/target-root --releasever="${target_release}" install -y rpm-build "${package_manager}"
fi
# Need to set database timestamps for pmm due to `dnf -C` usage
umount -l "${bootstrap_dir}/var/cache/dnf" >/dev/null 2>&1 || true
umount -l "${bootstrap_dir}/var/cache/yum" >/dev/null 2>&1 || true
setup_chroot "${target_dir}"
LC_ALL=C chroot "${target_dir}" "${package_manager}" -y update
}

View File

@ -0,0 +1,126 @@
#!/bedrock/libexec/busybox sh
#
# Clear Linux bootstrap support
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# version 2 as published by the Free Software Foundation.
#
# Copyright (c) 2019 Daniel Thau <danthau@bedrocklinux.org>
#
# shellcheck source=src/slash-bedrock/libexec/brl-fetch
. /bedrock/share/common-code
trap 'fetch_abort "Unexpected error occurred."' EXIT
check_supported() {
false
}
speed_test_url() {
echo "1/Manifest.MoM.tar"
}
list_mirrors() {
echo "https://cdn.download.clearlinux.org/"
}
brl_arch_to_distro() {
case "${1}" in
"x86_64") echo "x86_64" ;;
*) abort "brl does not know how to translate arch \"${1}\" to ${distro} format" ;;
esac
}
list_architectures() {
echo "x86_64"
}
default_release() {
echo "rolling"
}
list_releases() {
echo "rolling"
}
fetch() {
step "Calculating required bootstrap packages"
clear_update="$(download "${target_mirror}/current/latest" -)"
notice "Using update ${clear_update}"
download -q "${target_mirror}/update/${clear_update}/Manifest.MoM" "${bootstrap_dir}/Manifest.MoM"
loop=true
NL="
"
required_bundles="os-core-update"
while "${loop}"; do
loop=false
for bundle in ${required_bundles}; do
if [ -e "${bootstrap_dir}/Manifest.${bundle}" ]; then
continue
fi
loop=true
update="$(awk -v"bundle=${bundle}" '$0 ~ /^M/ && $4 == bundle {print $3; exit}' "${bootstrap_dir}/Manifest.MoM")"
download -q "${target_mirror}/update/${update}/Manifest.${bundle}" "${bootstrap_dir}/Manifest.${bundle}"
required_bundles="${required_bundles}${NL}$(awk '$1 == "includes:" {print $2}' "${bootstrap_dir}/Manifest.${bundle}")"
echo "${required_bundles}" | sort | uniq | grep "." >"${bootstrap_dir}/required_bundles"
echo "x"
done
done | progress_unknown
required_bundles="$(cat "${bootstrap_dir}/required_bundles")"
notice "Bundles required to bootstrap swupd: $(echo "${required_bundles}" | tr '\n' ' ')"
# Packs themselves aren't checksumed; their contents are. There isn't
# a clean way to invalidate cached packs here, so just download them
# every time.
step "Downloading bootstrap software"
total="$(echo "${required_bundles}" | wc -w)"
for bundle in ${required_bundles}; do
update="$(awk -v"bundle=${bundle}" '$0 ~ /^M/ && $4 == bundle {print $3; exit}' "${bootstrap_dir}/Manifest.MoM")"
download -q "${target_mirror}/update/${update}/pack-${bundle}-from-0.tar" "${bootstrap_dir}/pack-${bundle}-from-0.tar"
echo "x"
done | progress_bar "${total}"
step "Extracting bootstrap packages (1/2)"
for tarball in "${bootstrap_dir}/pack"*.tar; do
tar xf "${tarball}" -C "${bootstrap_dir}"
echo "x"
done | progress_bar "${total}"
step "Extracting bootstrap packages (2/2)"
rm "${bootstrap_dir}/Manifest.MoM"
total="$(awk 'NF==4' "${bootstrap_dir}/Manifest."* | wc -l)"
awk 'NF==4' "${bootstrap_dir}/Manifest."* | while read -r line; do
type="$(echo "${line}" | cut -d" " -f1)"
if echo "${type}" | grep -q '^[DFL]'; then
hash="$(echo "${line}" | cut -d" " -f2)"
path="$(echo "${line}" | cut -d" " -f4-)"
dest="${bootstrap_dir}/${path}"
mkdir -p "$(dirname "${dest}")"
cp -a "${bootstrap_dir}/staged/${hash}" "${dest}"
fi
echo "x"
done | progress_bar "${total}"
step "Running bootstrap software"
setup_chroot "${bootstrap_dir}"
setup_ssl "${bootstrap_dir}"
# system passwd/group confuses os-install's hash check
rm -f "${bootstrap_dir}/etc/passwd" "${bootstrap_dir}/etc/group"
# swupd appears to remove packs after use such that we can't cache them between runs.
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
step "Configuring"
# Setup certs
LC_ALL=C chroot "${target_dir}" clrtrust generate
mkdir -p "${target_dir}/etc/ssl"
ln -s /var/cache/ca-certs/anchors "${target_dir}/etc/ssl/certs"
# Clear Linux does not populate various /etc files on which Bedrock
# depends, even if their corresponding package is installed. Create
# them.
echo "# File created by Bedrock Linux during stratum fetch" >"${target_dir}/etc/profile"
if ! [ -e "${target_dir}/etc/zshenv" ]; then
mkdir -p "${target_dir}/etc/zsh/"
echo "# File created by Bedrock Linux during stratum fetch" >"${target_dir}/etc/zshenv"
fi
}

View File

@ -0,0 +1,97 @@
#!/bedrock/libexec/busybox sh
#
# CRUX bootstrap support
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# version 2 as published by the Free Software Foundation.
#
# Copyright (c) 2016-2019 Daniel Thau <danthau@bedrocklinux.org>
#
# shellcheck source=src/slash-bedrock/libexec/brl-fetch
. /bedrock/share/common-code
trap 'fetch_abort "Unexpected error occurred."' EXIT
check_supported() {
false
}
speed_test_url() {
echo "loop/crux/handbook.txt"
}
list_mirrors() {
mirror_list_url='https://crux.nu/Main/Download'
download -q "${mirror_list_url}" - |
awk '/<table/,/<\/table/' |
list_links |
grep "^http"
}
brl_arch_to_distro() {
case "${1}" in
"x86_64") echo "x86_64" ;;
*) abort "brl does not know how to translate arch \"${1}\" to ${distro} format" ;;
esac
}
list_architectures() {
echo "x86_64"
}
list_releases() {
for mirror in "${flag_mirror}" $(list_mirrors); do
if download -q "${mirror}" - |
list_links |
grep -e '^crux-[0-9]' -e 'latest' |
sed -e 's/^crux-//' -e 's,/$,,'; then
break
fi
done
}
default_release() {
download -q 'https://crux.nu/Main/Download' - |
grep 'CRUX [0-9][0-9]*[.]' |
sed 's/^.*CRUX \([0-9][0-9]*[.][0-9]*\).*$/\1/' |
head -n1
}
fetch() {
step "Downloading bootstrap software"
download "${target_mirror}/crux-${target_release}/iso/crux-${target_release}.md5" "${bootstrap_dir}/checksum"
bootstrap_checksum="$(awk '{print$1}' "${bootstrap_dir}/checksum")"
bootstrap_url="${target_mirror}/crux-${target_release}/iso/crux-${target_release}.iso"
checksum_download "${cache}/crux.iso" "md5sum" "${bootstrap_checksum}" "${bootstrap_url}"
step "Preparing bootstrap software"
modprobe iso9660 >/dev/null 2>&1 || true
mount -t iso9660 -o loop,ro "${cache}/crux.iso" "${bootstrap_dir}"
cat "${bootstrap_dir}"/crux/core/pkgutils*.tar.xz | xz -d | tar xf - -O usr/bin/pkgadd >"${target_dir}/pkgadd"
chmod a+rx "${target_dir}/pkgadd"
mkdir -p "${target_dir}/var/lib/pkg"
touch "${target_dir}/var/lib/pkg/db"
step "Running bootstrap software"
total="$(find "${bootstrap_dir}/crux/core/" -mindepth 1 -maxdepth 1 | wc -l)"
for pkg in "${bootstrap_dir}"/crux/core/*; do
echo "${pkg}"
# hiding stderr to ignore noise about .py files not being ELF files
"${target_dir}/pkgadd" -r "${target_dir}" "${pkg}" 2>/dev/null
done | progress_bar "${total}"
step "Configuring"
sed \
-e "s/^HOSTNAME=.*/HOSTNAME=$(hostname)/" \
-e "s/^TIMEZONE=.*/TIMEZONE=/" \
"${target_dir}/etc/rc.conf" >"${target_dir}/etc/rc.conf-new"
mv "${target_dir}/etc/rc.conf-new" "${target_dir}/etc/rc.conf"
# Hack to fix concern around shutdown script running off of bedrock
# fuse filesystem.
# TODO: get this to work properly
mv "${target_dir}/etc/rc.shutdown" "${target_dir}/rc.shutdown"
ln -s "../rc.shutdown" "${target_dir}/etc/rc.shutdown"
}

View File

@ -0,0 +1,147 @@
#!/bedrock/libexec/busybox sh
#
# Debian bootstrap support
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# version 2 as published by the Free Software Foundation.
#
# Copyright (c) 2016-2021 Daniel Thau <danthau@bedrocklinux.org>
#
# shellcheck source=src/slash-bedrock/libexec/brl-fetch
. /bedrock/share/common-code
trap 'fetch_abort "Unexpected error occurred."' EXIT
check_supported() {
true
}
speed_test_url() {
echo "dists/${target_release}/Release"
}
list_mirrors() {
mirror_list_url='https://www.debian.org/mirror/list'
download -q "${mirror_list_url}" - |
awk '/<table/,/<\/table/' |
grep -B1 "\<${distro_arch}\>" |
list_links |
grep "^http"
}
brl_arch_to_distro() {
case "${1}" in
"aarch64") echo "arm64" ;;
"armv7hl") echo "armhf" ;;
"armv7l") echo "armel" ;;
"mips") echo "mips" ;;
"mips64el") echo "mips64el" ;;
"mipsel") echo "mipsel" ;;
"ppc64le") echo "ppc64el" ;;
"s390x") echo "s390x" ;;
"i686") echo "i386" ;;
"x86_64") echo "amd64" ;;
*) abort "brl does not know how to translate arch \"${1}\" to ${distro} format" ;;
esac
}
list_architectures() {
cat <<EOF
aarch64
armv7hl
armv7l
mips
mips64el
mipsel
ppc64le
s390x
i686
x86_64
EOF
}
default_release() {
for mirror in "${flag_mirror}" "http://ftp.debian.org/debian" $(list_mirrors); do
release="$(download -q "${mirror}/dists/stable/Release" - | awk '$1 == "Codename:" {print$2;exit}')"
if [ -n "${release}" ]; then
echo "${release}"
return
fi
done
}
list_releases() {
for mirror in "${flag_mirror}" "http://ftp.debian.org/debian" $(list_mirrors); do
if download -q "${mirror}/dists" - |
list_links |
grep '/$' |
grep -v -- '-' |
grep -ve '[.]' -ve '^/' -ve 'experimental' |
sed 's,/$,,g'; then
break
fi
done
}
fetch() {
bootstrap_deps="debootstrap apt dpkg coreutils dash bash grep sed awk perl bzip2 gzip tar gpgv debian-archive-keyring"
case "${target_release}" in
stretch | buster)
bootstrap_deps="${bootstrap_deps} libapt-pkg5.0"
;;
*)
bootstrap_deps="${bootstrap_deps} libapt-pkg6.0"
;;
esac
step "Downloading package information database"
download "${target_mirror}/dists/${target_release}/main/binary-${distro_arch}/Packages.gz" "${bootstrap_dir}/Packages.gz"
gunzip "${bootstrap_dir}/Packages.gz"
step "Converting distro package information database to brl format"
debdb_to_brldb "${bootstrap_dir}/Packages" "${bootstrap_dir}/brldb"
step "Calculating required bootstrap packages"
brldb_calculate_required_packages "${bootstrap_dir}/brldb" "${bootstrap_dir}/required_packages" "${bootstrap_deps}"
step "Downloading bootstrap packages"
checksum_downloads "${cache}/packages/" "$(awk -v"m=${target_mirror}" '{print m"/"$0}' "${bootstrap_dir}/required_packages")"
step "Extracting bootstrap packages"
bootstrap_packages="$(awk -v"d=${cache}/packages/" '{sub(/^.*\//,d);print $1}' "${bootstrap_dir}/required_packages")"
# shellcheck disable=SC2086
extract_debs "${bootstrap_dir}" ${bootstrap_packages}
step "Running bootstrap software"
setup_chroot "${bootstrap_dir}"
setup_ssl "${bootstrap_dir}"
set +o pipefail
if LANG=C chroot "${bootstrap_dir}" debootstrap --help | grep -q "cache-dir"; then
share_cache "packages" "${bootstrap_dir}/packages"
yes "" | LANG=C chroot "${bootstrap_dir}" debootstrap --variant=minbase --cache-dir="/packages" "${target_release}" "/target-root" "${target_mirror}"
else
yes "" | LANG=C chroot "${bootstrap_dir}" debootstrap --variant=minbase "${target_release}" "/target-root" "${target_mirror}"
fi
set -o pipefail
step "Configuring"
if echo "${target_release}" | grep -q "^\(sid\|unstable\)$"; then
true # no security maintainers for these releases
elif echo "${target_release}" | grep -q "^\(buzz\|rex\|bo\|hamm\|slink\|potato\|woody\|sarge\|etch\|lenny\|squeeze\|wheezy\|jessie\|stretch\|buster\)$"; then
# old security format
echo "deb http://security.debian.org/ ${target_release}/updates main" >>"${target_dir}/etc/apt/sources.list"
else
# new security format
echo "deb http://security.debian.org/debian-security ${target_release}-security main" >>"${target_dir}/etc/apt/sources.list"
fi
set +o pipefail
setup_chroot "${target_dir}"
autopkgs="$(LANG=C chroot "${target_dir}" /usr/bin/apt-mark showmanual)"
# word splitting is desired here
# shellcheck disable=SC2086
yes "" | LANG=C chroot "${target_dir}" /usr/bin/apt-mark auto ${autopkgs}
yes "" | LANG=C chroot "${target_dir}" /usr/bin/apt-get update
yes "" | LANG=C chroot "${target_dir}" /usr/bin/apt-get install locales-all
set -o pipefail
}

View File

@ -0,0 +1,135 @@
#!/bedrock/libexec/busybox sh
#
# Devuan bootstrap support
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# version 2 as published by the Free Software Foundation.
#
# Copyright (c) 2016-2020 Daniel Thau <danthau@bedrocklinux.org>
#
# shellcheck source=src/slash-bedrock/libexec/brl-fetch
. /bedrock/share/common-code
trap 'fetch_abort "Unexpected error occurred."' EXIT
check_supported() {
true
}
speed_test_url() {
echo "dists/${target_release}/Release"
}
list_mirrors() {
echo 'http://deb.devuan.org/merged'
}
brl_arch_to_distro() {
case "${1}" in
"aarch64") echo "arm64" ;;
"armv7hl") echo "armhf" ;;
"armv7l") echo "armel" ;;
"mips") echo "mips" ;;
"mips64el") echo "mips64el" ;;
"mipsel") echo "mipsel" ;;
"ppc64le") echo "ppc64el" ;;
"s390x") echo "s390x" ;;
"i686") echo "i686" ;;
"x86_64") echo "amd64" ;;
*) abort "brl does not know how to translate arch \"${1}\" to ${distro} format" ;;
esac
}
list_architectures() {
cat <<EOF
aarch64
armv7hl
armv7l
mips
mips64el
mipsel
ppc64le
s390x
i686
x86_64
EOF
}
default_release() {
for mirror in "${flag_mirror}" $(list_mirrors); do
release="$(download -q "${mirror}/dists/stable/Release" - | awk '$1 == "Codename:" {print$2;exit}')"
if [ -n "${release}" ]; then
echo "${release}"
return
fi
done
}
list_releases() {
for mirror in "${flag_mirror}" $(list_mirrors); do
if download -q "${mirror}/dists" - |
list_links | grep '/$' |
grep -v -- '-' |
grep -ve '[.]' -ve '^/' |
sed 's,/$,,g'; then
break
fi
done
}
fetch() {
bootstrap_deps="debootstrap apt dpkg coreutils dash bash grep sed awk perl bzip2 gzip tar gpgv devuan-keyring"
case "${target_release}" in
jessie | ascii | beowulf)
bootstrap_deps="${bootstrap_deps} libapt-pkg5.0"
;;
*)
bootstrap_deps="${bootstrap_deps} libapt-pkg6.0"
;;
esac
step "Downloading package information database"
download "${target_mirror}/dists/${target_release}/main/binary-${distro_arch}/Packages.gz" "${bootstrap_dir}/Packages.gz"
gunzip "${bootstrap_dir}/Packages.gz"
step "Converting distro package information database to brl format"
debdb_to_brldb "${bootstrap_dir}/Packages" "${bootstrap_dir}/brldb"
step "Calculating required bootstrap packages"
brldb_calculate_required_packages "${bootstrap_dir}/brldb" "${bootstrap_dir}/required_packages" "${bootstrap_deps}"
step "Downloading bootstrap packages"
checksum_downloads "${cache}/packages/" "$(awk -v"m=${target_mirror}" '{print m"/"$0}' "${bootstrap_dir}/required_packages")"
step "Extracting bootstrap packages"
bootstrap_packages="$(awk -v"d=${cache}/packages/" '{sub(/^.*\//,d);print $1}' "${bootstrap_dir}/required_packages")"
# shellcheck disable=SC2086
extract_debs "${bootstrap_dir}" ${bootstrap_packages}
step "Running bootstrap software"
setup_chroot "${bootstrap_dir}"
setup_ssl "${bootstrap_dir}"
set +o pipefail
if LANG=C chroot "${bootstrap_dir}" debootstrap --help | grep -q "cache-dir"; then
share_cache "packages" "${bootstrap_dir}/packages"
yes "" | LANG=C chroot "${bootstrap_dir}" debootstrap --variant=minbase --cache-dir="/packages" "${target_release}" "/target-root" "${target_mirror}"
else
yes "" | LANG=C chroot "${bootstrap_dir}" debootstrap --variant=minbase "${target_release}" "/target-root" "${target_mirror}"
fi
set -o pipefail
step "Configuring"
if [ "${target_release}" != "ceres" ] && [ "${target_release}" != "unstable" ]; then
echo "deb http://deb.devuan.org/merged ${target_release}-security main" >>"${target_dir}/etc/apt/sources.list"
fi
set +o pipefail
setup_chroot "${target_dir}"
autopkgs="$(LANG=C chroot "${target_dir}" /usr/bin/apt-mark showmanual)"
# word splitting is desired here
# shellcheck disable=SC2086
yes "" | LANG=C chroot "${target_dir}" /usr/bin/apt-mark auto ${autopkgs}
yes "" | LANG=C chroot "${target_dir}" /usr/bin/apt-get update
yes "" | LANG=C chroot "${target_dir}" /usr/bin/apt-get install locales-all
set -o pipefail
}

View File

@ -0,0 +1,91 @@
#!/bedrock/libexec/busybox sh
#
# Exherbo Linux bootstrap support
# Copyright 2019 Wulf C. Krueger <philantrop@exherbo.org>
# Distributed under the terms of the GNU General Public License v2
#
# based in part upon "Gentoo Linux bootstrap support" which is:
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# version 2 as published by the Free Software Foundation.
#
# Copyright (c) 2016-2019 Daniel Thau <danthau@bedrocklinux.org>
# shellcheck source=src/slash-bedrock/libexec/brl-fetch
. /bedrock/share/common-code
trap 'fetch_abort "Unexpected error occurred."' EXIT
check_supported() {
true
}
speed_test_url() {
echo "/index.html"
}
list_mirrors() {
echo "https://dev.exherbo.org/"
}
brl_arch_to_distro() {
case "${1}" in
"aarch64") echo "aarch64" ;;
"armv7hl") echo "armv7" ;;
"x86_64") echo "x86_64" ;;
*) abort "brl does not know how to translate arch \"${1}\" to ${distro} format" ;;
esac
}
list_architectures() {
cat <<EOF
aarch64
armv7hl
x86_64
EOF
}
default_release() {
echo "rolling"
}
list_releases() {
echo "rolling"
}
fetch() {
paludis_builddir=/var/tmp/paludis/build
paludis_user=paludisbuild
paludis_group=paludisbuild
case "${target_arch}" in
"aarch64") ex_stage="exherbo-aarch64-unknown-linux-gnueabi-current.tar.xz" ;;
"armv7hl") ex_stage="exherbo-armv7-unknown-linux-gnueabihf-current.tar.xz" ;;
"x86_64") ex_stage="exherbo-x86_64-pc-linux-gnu-current.tar.xz" ;;
esac
ex_checksum_fn=sha256sum
step "Downloading & verifying bootstrap software"
download "${target_mirror}"/stages/"${ex_stage}.${ex_checksum_fn}" "${bootstrap_dir}/${ex_stage}.${ex_checksum_fn}"
ex_sha256sum="$(awk -v"name=exherbo" '/^# .* HASH$/ {hash=$1;next} index($2, name) {print$1;exit}' "${bootstrap_dir}/${ex_stage}.${ex_checksum_fn}")"
checksum_download "${cache}/${ex_stage}" "sha256sum" "${ex_sha256sum}" "${target_mirror}"/stages/"${ex_stage}"
step "Preparing bootstrap software"
tar xvJp -C "${bootstrap_dir}" -f "${cache}"/"${ex_stage}" | awk 'NR%100==0' | progress_unknown
step "Running bootstrap software"
setup_chroot "${bootstrap_dir}"
setup_ssl "${bootstrap_dir}"
share_cache "." "${bootstrap_dir}/tarballs"
chroot "${bootstrap_dir}" sh -c "cd /target-root && tar xvJpf /tarballs/${ex_stage}" | awk 'NR%100==0' | progress_unknown
step "Configuring"
setup_chroot "${target_dir}"
step "Creating Paludis' build-dir & fixing permissions"
mkdir -p "${target_dir}/${paludis_builddir}/"
chroot "${target_dir}" chown -R "${paludis_user}":"${paludis_group}" "${paludis_builddir}"
chroot "${target_dir}" chmod -R g+rwx "${paludis_builddir}"
step "Modifying ${paludis_user}"
chroot "${target_dir}" usermod -a -G "$(stat -c %G /dev/tty)" ${paludis_user}
}

View File

@ -0,0 +1,83 @@
#!/bedrock/libexec/busybox sh
#
# Exherbo Linux bootstrap support
# Copyright 2019 Wulf C. Krueger <philantrop@exherbo.org>
# Distributed under the terms of the GNU General Public License v2
#
# based in part upon "Gentoo Linux bootstrap support" which is:
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# version 2 as published by the Free Software Foundation.
#
# Copyright (c) 2016-2019 Daniel Thau <danthau@bedrocklinux.org>
# shellcheck source=src/slash-bedrock/libexec/brl-fetch
. /bedrock/share/common-code
trap 'fetch_abort "Unexpected error occurred."' EXIT
check_supported() {
true
}
speed_test_url() {
echo "/index.html"
}
list_mirrors() {
echo "https://dev.exherbo.org/"
}
brl_arch_to_distro() {
case "${1}" in
"x86_64") echo "x86_64" ;;
*) abort "brl does not know how to translate arch \"${1}\" to ${distro} format" ;;
esac
}
list_architectures() {
cat <<EOF
x86_64
EOF
}
default_release() {
echo "rolling"
}
list_releases() {
echo "rolling"
}
fetch() {
paludis_builddir=/var/tmp/paludis/build
paludis_user=paludisbuild
paludis_group=paludisbuild
ex_stage="exherbo-x86_64-pc-linux-musl-current.tar.xz"
ex_checksum_fn=sha256sum
step "Downloading & verifying bootstrap software"
download "${target_mirror}"/stages/${ex_stage}."${ex_checksum_fn}" "${bootstrap_dir}/${ex_stage}.${ex_checksum_fn}"
ex_sha256sum="$(awk -v"name=exherbo" '/^# .* HASH$/ {hash=$1;next} index($2, name) {print$1;exit}' "${bootstrap_dir}/${ex_stage}.${ex_checksum_fn}")"
checksum_download "${cache}/${ex_stage}" "sha256sum" "${ex_sha256sum}" "${target_mirror}"/stages/"${ex_stage}"
step "Preparing bootstrap software"
tar xvJp -C "${bootstrap_dir}" -f "${cache}"/"${ex_stage}" | awk 'NR%100==0' | progress_unknown
step "Running bootstrap software"
setup_chroot "${bootstrap_dir}"
setup_ssl "${bootstrap_dir}"
share_cache "." "${bootstrap_dir}/tarballs"
chroot "${bootstrap_dir}" sh -c "cd /target-root && tar xvJpf /tarballs/${ex_stage}" | awk 'NR%100==0' | progress_unknown
step "Configuring"
setup_chroot "${target_dir}"
step "Creating Paludis' build-dir & fixing permissions"
mkdir -p "${target_dir}/${paludis_builddir}/"
chroot "${target_dir}" chown -R "${paludis_user}":"${paludis_group}" "${paludis_builddir}"
chroot "${target_dir}" chmod -R g+rwx "${paludis_builddir}"
step "Modifying ${paludis_user}"
chroot "${target_dir}" usermod -a -G "$(stat -c %G /dev/tty)" ${paludis_user}
}

View File

@ -0,0 +1,191 @@
#!/bedrock/libexec/busybox sh
#
# Fedora bootstrap support
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# version 2 as published by the Free Software Foundation.
#
# Copyright (c) 2016-2021 Daniel Thau <danthau@bedrocklinux.org>
#
# shellcheck source=src/slash-bedrock/libexec/brl-fetch
. /bedrock/share/common-code
trap 'fetch_abort "Unexpected error occurred."' EXIT
check_supported() {
true
}
speed_test_url() {
echo "releases/${target_release}/Everything/${distro_arch}/os/repodata/repomd.xml"
}
list_mirrors() {
download -q "https://mirrors.fedoraproject.org/mirrorlist?repo=fedora-${target_release}&arch=${distro_arch}" - |
grep -ve '^[ \t]*#' |
sed -e 's,/$,,' |
sed 's,/[^/]*/[^/]*/[^/]*/[^/]*/[^/]*$,,'
}
brl_arch_to_distro() {
case "${1}" in
"aarch64") echo "aarch64" ;;
"armv7hl") echo "armhfp" ;;
"ppc64le") echo "ppc64le" ;;
"s390x") echo "s390x" ;;
# Mirrors call it i386, but repo calls it i686.
"i686") echo "i386" ;;
"x86_64") echo "x86_64" ;;
*) abort "brl does not know how to translate arch \"${1}\" to ${distro} format" ;;
esac
}
list_architectures() {
cat <<EOF
aarch64
armv7hl
ppc64le
s390x
i686
x86_64
EOF
}
default_release() {
list_releases |
sort -n |
tail -n1
}
list_releases() {
download -q 'https://dl.fedoraproject.org/pub/fedora/linux/releases/' - |
list_links |
grep '^[0-9][0-9]*/$' |
sed 's,/$,,' |
sort -n
}
determine_package_manager() {
if [ -e "${bootstrap_dir}/brldb/depends/dn" ] && grep -q '^dnf\>' "${bootstrap_dir}/brldb/depends/dn"; then
echo "dnf"
else
echo "yum"
fi
}
bootstrap_deps() {
echo "${package_manager} rpm fedora-release filesystem fedora-gpg-keys"
}
fetch() {
suffix="releases/${target_release}/Everything/${distro_arch}/os"
step "Downloading package information database"
url="$(find_link "${target_mirror}/${suffix}/repodata/" "primary.xml.gz")"
download "${url}" "${bootstrap_dir}/primary.xml.gz"
step "Extracting package information database"
gunzip "${bootstrap_dir}/primary.xml.gz"
step "Converting distro package information database to brl format"
if [ "${target_arch}" = i686 ]; then
# CentOS arch name is i386 in mirrors but i686 in package manager
distro_arch="i686" rpmdb_to_brldb "${bootstrap_dir}/primary.xml" "${bootstrap_dir}/brldb"
else
rpmdb_to_brldb "${bootstrap_dir}/primary.xml" "${bootstrap_dir}/brldb"
fi
step "Calculating required bootstrap packages"
package_manager="$(determine_package_manager)"
brldb_calculate_required_packages "${bootstrap_dir}/brldb" "${bootstrap_dir}/required_packages" "$(bootstrap_deps)"
step "Downloading bootstrap packages"
checksum_downloads "${cache}/packages/" "$(awk -v"m=${target_mirror}/${suffix}" '{print m"/"$0}' "${bootstrap_dir}/required_packages")"
step "Extracting bootstrap packages"
# This round is just to bootstrap the distro's rpm.
# Next step we'll use the distro's rpm to install everything properly.
# Need to extract filesystem first to ensure symlinks are set up
bootstrap_packages="$(awk -v"d=${cache}/packages/" '{sub(/^.*\//,d);print $1}' "${bootstrap_dir}/required_packages")"
# shellcheck disable=SC2086
extract_rpms "${bootstrap_dir}" "${cache}/packages"/filesystem*.rpm ${bootstrap_packages}
step "Installing bootstrap packages"
setup_chroot "${bootstrap_dir}"
# setup_ssl "${bootstrap_dir}" # fights with yum/dnf later on, not actually needed
share_cache "packages" "${bootstrap_dir}/packages"
bootstrap_packages="$(awk -v"d=/packages/" '{sub(/^.*\//,d);print $1}' "${bootstrap_dir}/required_packages")"
# shellcheck disable=SC2086
LC_ALL=C chroot "${bootstrap_dir}" sh -c 'rpm --import /etc/pki/rpm-gpg/*'
LC_ALL=C chroot "${bootstrap_dir}" rpm -i ${bootstrap_packages}
step "Running bootstrap software"
# By default, yum clears anything in its package cache. Configure it
# to retain them so we can leverage previous cached packages.
if [ -e "${bootstrap_dir}/etc/dnf/dnf.conf" ] && grep -q "^keepcache=1$" "${bootstrap_dir}/etc/dnf/dnf.conf"; then
share_cache "dnf-cache" "${bootstrap_dir}/target-root/var/cache/dnf"
elif [ -e "${bootstrap_dir}/etc/dnf/dnf.conf" ] && grep -q "^keepcache=0$" "${bootstrap_dir}/etc/dnf/dnf.conf"; then
sed 's/^keepcache=0$/keepcache=1/' "${bootstrap_dir}/etc/dnf/dnf.conf" >"${bootstrap_dir}/etc/dnf/dnf.conf-new"
mv "${bootstrap_dir}/etc/dnf/dnf.conf-new" "${bootstrap_dir}/etc/dnf/dnf.conf"
share_cache "dnf-cache" "${bootstrap_dir}/target-root/var/cache/dnf"
elif [ -r "${bootstrap_dir}/etc/dnf/dnf.conf" ]; then
echo "keepcache=1" >>"${bootstrap_dir}/etc/dnf/dnf.conf"
share_cache "dnf-cache" "${bootstrap_dir}/target-root/var/cache/dnf"
elif [ -e "${bootstrap_dir}/etc/yum.conf" ] && grep -q "^keepcache=1$" "${bootstrap_dir}/etc/yum.conf"; then
share_cache "yum-cache" "${bootstrap_dir}/target-root/var/cache/yum"
elif [ -e "${bootstrap_dir}/etc/yum.conf" ] && grep -q "^keepcache=0$" "${bootstrap_dir}/etc/yum.conf"; then
sed 's/^keepcache=0$/keepcache=1/' "${bootstrap_dir}/etc/yum.conf" >"${bootstrap_dir}/etc/yum.conf-new"
mv "${bootstrap_dir}/etc/yum.conf-new" "${bootstrap_dir}/etc/yum.conf"
share_cache "yum-cache" "${bootstrap_dir}/target-root/var/cache/yum"
elif [ -r "${bootstrap_dir}/etc/yum.conf" ]; then
echo "keepcache=1" >>"${bootstrap_dir}/etc/yum.conf"
share_cache "yum-cache" "${bootstrap_dir}/target-root/var/cache/yum"
fi
# Configure the package manager to utilize the desired architecture
if [ "${target_arch}" = "i686" ]; then
mkdir -p "${bootstrap_dir}/etc/${package_manager}/vars/"
echo 'i686' >"${bootstrap_dir}/etc/${package_manager}/vars/arch"
echo 'i386' >"${bootstrap_dir}/etc/${package_manager}/vars/basearch"
mkdir -p "${target_dir}/etc/${package_manager}/vars/"
echo 'i686' >"${target_dir}/etc/${package_manager}/vars/arch"
echo 'i386' >"${target_dir}/etc/${package_manager}/vars/basearch"
fi
LC_ALL=C chroot "${bootstrap_dir}" rpm -i --root=/target-root --nodeps ./packages/fedora-release-*.rpm 2>/dev/null || true
LC_ALL=C chroot "${bootstrap_dir}" "${package_manager}" --installroot=/target-root install -y rpm-build "${package_manager}" fedora-repos
# Need to set database timestamps for pmm due to `dnf -C` usage
umount -l "${bootstrap_dir}/var/cache/dnf" >/dev/null 2>&1 || true
umount -l "${bootstrap_dir}/var/cache/yum" >/dev/null 2>&1 || true
step "Configuring"
setup_chroot "${target_dir}"
LC_ALL=C chroot "${target_dir}" "${package_manager}" -y update
# Fedora does not use localegen; need to special case locale handling.
LC_ALL=C chroot "${target_dir}" "${package_manager}" -y install glibc-locale-source
localegen="$(cfg_values "locale" "localegen")"
if [ -n "${localegen}" ]; then
unset IFS
echo "${localegen}" | while read -r line; do
name="$(echo "${line}" | cut -d'.' -f1)"
locale="$(echo "${line}" | cut -d' ' -f1)"
charset="$(echo "${line}" | cut -d' ' -f2)"
if [ -e "${target_dir}/usr/share/locale/${name}" ]; then
input="${name}"
else
notice "${color_warn}Could not set \"${locale} ${charset}\" locale, skipping.${color_norm}"
continue
fi
if [ -e "${target_dir}/usr/share/locale/locale.alias" ]; then
alias="-A /usr/share/locale/locale.alias"
else
unset alias
fi
if ! LC_ALL=C chroot "${target_dir}" localedef -i "${input:-}" -c -f "${charset}" ${alias:-} "${locale}"; then
notice "${color_warn}Could not set \"${locale} ${charset}\" locale, skipping.${color_norm}"
fi
done
fi
}

View File

@ -0,0 +1,126 @@
#!/bedrock/libexec/busybox sh
#
# Gentoo Linux bootstrap support
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# version 2 as published by the Free Software Foundation.
#
# Copyright (c) 2016-2021 Daniel Thau <danthau@bedrocklinux.org>
#
# shellcheck source=src/slash-bedrock/libexec/brl-fetch
. /bedrock/share/common-code
trap 'fetch_abort "Unexpected error occurred."' EXIT
check_supported() {
true
}
speed_test_url() {
echo "releases/verify-digests.sh"
}
list_mirrors() {
mirror_list_url="https://www.gentoo.org/downloads/mirrors/"
download -q "${mirror_list_url}" - |
awk '/Region/,/<footer>/' |
list_links |
grep "^http"
}
brl_arch_to_distro() {
case "${1}" in
"aarch64") echo "arm64" ;;
"armv7hl") echo "armv7a_hardfp" ;;
"armv7l") echo "armv7a" ;;
"i486") echo "i486" ;;
"i686") echo "i686" ;;
"ppc") echo "ppc" ;;
"ppc64") echo "ppc64" ;;
"ppc64le") echo "ppc64le" ;;
"s390x") echo "s3960x" ;;
"x86_64") echo "amd64" ;;
*) abort "brl does not know how to translate arch \"${1}\" to ${distro} format" ;;
esac
}
list_architectures() {
cat <<EOF
armv7hl
armv7l
ppc
ppc64
ppc64le
s390x
i486
i686
x86_64
EOF
}
default_release() {
echo "rolling"
}
list_releases() {
echo "rolling"
}
fetch() {
# Which flavors are available for a given stage 3 appears to be
# variable depending on time and mirror. Iterate through possibilities
# in minimal-to-maximal order and go with the first found.
#
# TODO: In Bedrock 0.8.0 when `brl fetch --flavor` is available make desktop
# vs hardened vs musl, openrc vs systemd, etc flavors.
flavors="minimal openrc desktop-openrc"
step "Finding bootstrap software"
# stage3 balls are not necessarily in the obvious directory; need to
# search multiple to find where the tarball we are interested in is.
groups="$(download -q "${target_mirror}/releases/" - |
list_links |
grep '/$' |
sed -e 's,/$,,')"
group_flavor="$(for group in ${groups}; do
page="$(download -q "${target_mirror}/releases/${group}/autobuilds/" -)"
for flavor in ${flavors}; do
if echo "${page}" | list_links | grep "^current-stage3-${distro_arch}-${flavor}/$" >/dev/null; then
echo "${group}"
echo "${flavor}"
return
fi
done
done)"
echo "group_flavor: ${group_flavor}"
group="$(echo "${group_flavor}" | sed -n 1p)"
flavor="$(echo "${group_flavor}" | sed -n 2p)"
if [ -z "${group}" ] || [ -z "${flavor}" ]; then
abort "Could not find bootstrap software at ${target_mirror} for ${distro_arch}."
fi
step "Downloading bootstrap software"
bootstrap_url="$(find_link "${target_mirror}/releases/${group}/autobuilds/current-stage3-${distro_arch}-${flavor}/" "^stage3-${distro_arch}-${flavor}-[^.]*[.]tar[.]\(xz\|bz2\)$")"
bootstrap_name="$(echo "${bootstrap_url}" | sed 's,^.*/,,')"
download "${bootstrap_url}.DIGESTS" "${bootstrap_dir}/checksum"
bootstrap_checksum="$(awk -v"name=${bootstrap_name}" '/^# .* HASH$/ {hash=$2;next} hash == "SHA512" && $2 == name {print$1;exit}' "${bootstrap_dir}/checksum")"
cache_name="stage3.tar.$(echo "${bootstrap_name}" | sed 's/^.*[.]//')"
checksum_download "${cache}/${cache_name}" "sha512sum" "${bootstrap_checksum}" "${bootstrap_url}"
step "Preparing bootstrap software"
tar -xv -f "${cache}/${cache_name}" -C "${bootstrap_dir}" | awk 'NR%100==0' | progress_unknown
step "Running bootstrap software"
setup_chroot "${bootstrap_dir}"
setup_ssl "${bootstrap_dir}"
share_cache "." "${bootstrap_dir}/tarballs"
chroot "${bootstrap_dir}" sh -c "cd /target-root && tar xpfv /tarballs/stage3.tar.* --xattrs-include='*.*' --numeric-owner" | awk 'NR%100==0' | progress_unknown
step "Configuring"
setup_chroot "${target_dir}"
echo "GENTOO_MIRRORS=\"${target_mirror}\"" >>"${target_dir}/etc/portage/make.conf"
mkdir -p "${target_dir}/etc/portage/repos.conf"
cp "${target_dir}/usr/share/portage/config/repos.conf" "${target_dir}/etc/portage/repos.conf/gentoo.conf"
LC_ALL=C chroot "${target_dir}" emerge-webrsync
}

View File

@ -0,0 +1,76 @@
#!/bedrock/libexec/busybox sh
#
# KISS Linux bootstrap support
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# version 2 as published by the Free Software Foundation.
#
# Copyright (c) 2019-2020 Daniel Thau <danthau@bedrocklinux.org>
#
# shellcheck source=src/slash-bedrock/libexec/brl-fetch
. /bedrock/share/common-code
trap 'fetch_abort "Unexpected error occurred."' EXIT
check_supported() {
false
}
speed_test_url() {
echo "latest"
}
list_mirrors() {
echo 'https://github.com/kisslinux/repo/releases'
}
brl_arch_to_distro() {
case "${1}" in
"x86_64") echo "x86_64" ;;
*) abort "brl does not know how to translate arch \"${1}\" to ${distro} format" ;;
esac
}
list_architectures() {
cat <<EOF
x86_64
EOF
}
default_release() {
download -q https://api.github.com/repos/kisslinux/repo/releases/latest - | awk -F'"' '
$2 == "assets" {
in_assets = 1
}
/],/ && in_assets {
in_assets = 0
}
$2 == "name" && !in_assets && $4 != "" {
print$4
}'
}
list_releases() {
download -q https://api.github.com/repos/kisslinux/repo/releases - | awk -F'"' '
$2 == "assets" {
in_assets = 1
}
/],/ && in_assets {
in_assets = 0
}
$2 == "name" && !in_assets && $4 != "" {
print$4
}'
}
fetch() {
prefix="https://github.com/kisslinux/repo/releases/download/"
step "Downloading bootstrap software"
download "${prefix}/${target_release}/kiss-chroot-${target_release}.tar.xz.sha256" "${bootstrap_dir}/checksum"
bootstrap_checksum="$(awk '{print$1}' "${bootstrap_dir}/checksum")"
checksum_download "${cache}/bootstrap.tar.xz" "sha256sum" "${bootstrap_checksum}" "${prefix}/${target_release}/kiss-chroot-${target_release}.tar.xz"
step "Extracting bootstrap software"
tar -xv -f "${cache}/bootstrap.tar.xz" -C "${target_dir}" | awk 'NR%100==0' | progress_unknown
}

View File

@ -0,0 +1,127 @@
#!/bedrock/libexec/busybox sh
#
# Manjaro Linux bootstrap support
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# version 2 as published by the Free Software Foundation.
#
# Copyright (c) 2016-2020 Daniel Thau <danthau@bedrocklinux.org>
#
# shellcheck source=src/slash-bedrock/libexec/brl-fetch
. /bedrock/share/common-code
trap 'fetch_abort "Unexpected error occurred."' EXIT
check_supported() {
false
}
speed_test_url() {
echo "stable/core/${distro_arch}/core.db.tar.gz"
}
list_mirrors() {
# All mirrors:
# Server-side filtered list of mirrors:
mirror_list_url='https://repo.manjaro.org'
# tail/grep is to remove the header links and only list http/https
download -q "${mirror_list_url}" - | list_links | tail -n +5 | grep '^http'
}
brl_arch_to_distro() {
case "${1}" in
"x86_64") echo "x86_64" ;;
*) abort "brl does not know how to translate arch \"${1}\" to ${distro} format" ;;
esac
}
list_architectures() {
echo "x86_64"
}
default_release() {
echo "rolling"
}
list_releases() {
echo "rolling"
}
setup_pacman() {
# Remove auto architecture detection, as it will confuse things like
# i686 on an x86_64 box and armv7hl on a aarch64 box.
#
# Also remove CheckSpace, which sometimes gets confused by Bedrock's
# mount setup.
sed 's/^Architecture[ \t]*=.*$//' "${1}/etc/pacman.conf" |
awk -v"a=${distro_arch}" '{print} $0 == "[options]" {print "Architecture = "a}' |
sed 's/^[ \t]*CheckSpace/# &/' >"${1}/etc/pacman.conf-new"
mv "${1}/etc/pacman.conf-new" "${1}/etc/pacman.conf"
LC_ALL=C chroot "${1}" /usr/bin/update-ca-trust
LC_ALL=C chroot "${1}" /usr/bin/pacman-key --init
LC_ALL=C chroot "${1}" /usr/bin/pacman-key --populate manjaro archlinux
if ! grep -q "^Server" "${1}/etc/pacman.d/mirrorlist"; then
echo "### Set by Bedrock Linux when acquiring this stratum" >>"${1}/etc/pacman.d/mirrorlist"
echo "Server = ${target_mirror}/stable\$repo/\$arch" >>"$1/etc/pacman.d/mirrorlist"
fi
}
fetch() {
bootstrap_deps="manjaro-tools-base pacman pacman-mirrors ca-certificates ca-certificates-utils awk util-linux"
step "Downloading package information database"
download "${target_mirror}/stable/core/${distro_arch}/core.db.tar.gz" "${bootstrap_dir}/core.db.tar.gz"
download "${target_mirror}/stable/extra/${distro_arch}/extra.db.tar.gz" "${bootstrap_dir}/extra.db.tar.gz"
download "${target_mirror}/stable/community/${distro_arch}/community.db.tar.gz" "${bootstrap_dir}/community.db.tar.gz"
step "Decompressing package information database"
mkdir -p "${bootstrap_dir}/pacmandb/core" "${bootstrap_dir}/pacmandb/extra" "${bootstrap_dir}/pacmandb/community"
(
tar -xv -f "${bootstrap_dir}/core.db.tar.gz" -C "${bootstrap_dir}/pacmandb/core/"
tar -xv -f "${bootstrap_dir}/extra.db.tar.gz" -C "${bootstrap_dir}/pacmandb/extra/"
tar -xv -f "${bootstrap_dir}/community.db.tar.gz" -C "${bootstrap_dir}/pacmandb/community/"
) | awk 'NR%100==0' | progress_unknown
step "Converting distro package information database to brl format"
pacmandb_to_brldb "${bootstrap_dir}/pacmandb" "${bootstrap_dir}/brldb"
step "Calculating required bootstrap packages"
brldb_calculate_required_packages "${bootstrap_dir}/brldb" "${bootstrap_dir}/required_packages" "${bootstrap_deps}"
step "Downloading bootstrap packages"
# brldb contains repo/filename
# files are at mirror/stable/repo/arch/filename
checksum_downloads "${cache}/packages/" "$(awk -v"a=${distro_arch}" -v"m=${target_mirror}" '{sub("/", "/"a"/"); print m"/stable/"$0}' "${bootstrap_dir}/required_packages")"
step "Extracting bootstrap packages"
bootstrap_packages="$(awk -v"d=${cache}/packages/" '{sub(/^.*\//,d);print $1}' "${bootstrap_dir}/required_packages")"
# shellcheck disable=SC2086
extract_pacman_pkgs "${bootstrap_dir}" ${bootstrap_packages}
step "Running bootstrap software"
# pacstrap mounts devtmpfs (which is shared with the host system) and
# chowns files in it based on /etc/passwd and /etc/group. Ensure
# system copies of files are used to avoid problematic file ownership
# change in /dev.
mkdir -p "${target_dir}/etc"
cp -a "/etc/passwd" "${target_dir}/etc/passwd"
cp -a "/etc/group" "${target_dir}/etc/group"
setup_chroot "${bootstrap_dir}"
setup_ssl "${bootstrap_dir}"
share_cache "packages" "${bootstrap_dir}/target-root/var/cache/pacman/pkg/"
# -a to use the api, -P all protocols, -t 1 timeout if it takes longer than 1 second
LC_ALL=C chroot "${bootstrap_dir}" pacman-mirrors -S stable -f 1 -a -P all -t 1
setup_pacman "${bootstrap_dir}"
LC_ALL=C chroot "${bootstrap_dir}" basestrap "/target-root" base
step "Configuring"
setup_chroot "${target_dir}"
setup_pacman "${target_dir}"
cp "${cache}/packages/"* "${target_dir}/var/cache/pacman/"
if LC_ALL=C chroot "${target_dir}" pacman -Q linux >/dev/null 2>&1; then
LC_ALL=C chroot "${target_dir}" pacman --noconfirm -R linux
fi
}

View File

@ -0,0 +1,98 @@
#!/bedrock/libexec/busybox sh
#
# OpenWrt bootstrap support
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# version 2 as published by the Free Software Foundation.
#
# Copyright (c) 2018-2019 Daniel Thau <danthau@bedrocklinux.org>
#
# shellcheck source=src/slash-bedrock/libexec/brl-fetch
. /bedrock/share/common-code
trap 'fetch_abort "Unexpected error occurred."' EXIT
check_supported() {
false
}
speed_test_url() {
echo "releases/${target_release}/targets/x86/64/sha256sums"
}
list_mirrors() {
# main mirror
echo 'https://downloads.openwrt.org'
# additional mirrors
mirror_list_url='https://openwrt.org/downloads'
download -q "${mirror_list_url}" - |
awk '/id="mirrors"/,/<\/table>/' |
list_links |
grep "^http"
}
brl_arch_to_distro() {
case "${1}" in
"aarch64") echo "armvirt-64" ;;
"armv7l") echo "armvirt-32" ;;
"i486") echo "x86-generic" ;;
"x86_64") echo "x86-64" ;;
*) abort "brl does not know how to translate arch \"${1}\" to ${distro} format" ;;
esac
}
list_architectures() {
cat <<EOF
aarch64
armv7l
i486
x86_64
EOF
}
default_release() {
list_releases |
sort -n |
tail -n1
}
list_releases() {
for mirror in "${flag_mirror}" $(list_mirrors); do
if download -q "${mirror}/releases/" - |
list_links |
grep '^[0-9][0-9.]*/$' |
sed 's,/$,,'; then
break
fi
done
}
fetch() {
step "Downloading bootstrap software"
case "${target_arch}" in
"aarch64") bootstrap_url="$(find_link "${target_mirror}/releases/${target_release}/targets/armvirt/64/" "^openwrt-${target_release}-${distro_arch}-default-rootfs.tar.gz$")" ;;
"armv7l") bootstrap_url="$(find_link "${target_mirror}/releases/${target_release}/targets/armvirt/32/" "^openwrt-${target_release}-${distro_arch}-default-rootfs.tar.gz$")" ;;
"i486") bootstrap_url="$(find_link "${target_mirror}/releases/${target_release}/targets/x86/generic/" "^openwrt-${target_release}-${distro_arch}-generic-rootfs.tar.gz$")" ;;
"x86_64") bootstrap_url="$(find_link "${target_mirror}/releases/${target_release}/targets/x86/64/" "^openwrt-${target_release}-${distro_arch}-generic-rootfs.tar.gz$")" ;;
esac
bootstrap_name="$(echo "${bootstrap_url}" | sed 's,^.*/,,')"
download "$(echo "${bootstrap_url}" | sed 's,/[^/]*$,sha256sums,')" "${bootstrap_dir}/checksum"
bootstrap_checksum="$(awk -vname="${bootstrap_name}" '$2 == "*"name {print$1}' "${bootstrap_dir}/checksum")"
checksum_download "${cache}/bootstrap.tar.gz" "sha256sum" "${bootstrap_checksum}" "${bootstrap_url}"
step "Extracting bootstrap software"
tar -xv -f "${cache}/bootstrap.tar.gz" -C "${target_dir}" | awk 'NR%100==0' | progress_unknown
step "Configuring"
# OpenWrt defaults to /var being a symlink to /tmp. This makes /var
# shared on Bedrock when it should be private. Disconnect /tmp from /var.
if [ -h "${target_dir}/var" ]; then
rm "${target_dir}/var"
fi
mkdir -p "${target_dir}/var/lock"
}

View File

@ -0,0 +1,119 @@
#!/bedrock/libexec/busybox sh
#
# Raspbian bootstrap support
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# version 2 as published by the Free Software Foundation.
#
# Copyright (c) 2016-2020 Daniel Thau <danthau@bedrocklinux.org>
#
# shellcheck source=src/slash-bedrock/libexec/brl-fetch
. /bedrock/share/common-code
trap 'fetch_abort "Unexpected error occurred."' EXIT
check_supported() {
true
}
speed_test_url() {
echo "dists/${target_release}/Release"
}
list_mirrors() {
mirror_list_url='https://www.raspbian.org/RaspbianMirrors'
download -q "${mirror_list_url}" - |
awk '/Raspbian Repository Mirrors/,/<\/div/' |
sed 's/([a-z|]*http[a-z|]*)/http/' |
grep '>http://.*<' |
sed 's,.*>http://,http://,' |
sed 's,<.*$,,'
}
brl_arch_to_distro() {
case "${1}" in
"armv7hl") echo "armhf" ;;
*) abort "brl does not know how to translate arch \"${1}\" to ${distro} format" ;;
esac
}
list_architectures() {
echo "armv7hl"
}
default_release() {
for mirror in "${flag_mirror}" $(list_mirrors); do
release="$(download -q "${mirror}/dists/stable/Release" - | awk '$1 == "Codename:" {print$2;exit}')"
if [ -n "${release}" ]; then
echo "${release}"
return
fi
done
}
list_releases() {
for mirror in "${flag_mirror}" $(list_mirrors); do
if download -q "${mirror}/dists" - |
list_links |
grep '/$' |
grep -v -- '-' |
grep -ve '[.]' -ve '^/' -ve 'experimental' |
sed 's,/$,,g'; then
break
fi
done
}
fetch() {
bootstrap_deps="debootstrap apt dpkg coreutils dash bash grep sed awk perl bzip2 gzip tar gpgv raspbian-archive-keyring"
case "${target_release}" in
stretch | buster)
bootstrap_deps="${bootstrap_deps} libapt-pkg5.0"
;;
*)
bootstrap_deps="${bootstrap_deps} libapt-pkg6.0"
;;
esac
step "Downloading package information database"
download "${target_mirror}/dists/${target_release}/main/binary-${distro_arch}/Packages.gz" "${bootstrap_dir}/Packages.gz"
gunzip "${bootstrap_dir}/Packages.gz"
step "Converting distro package information database to brl format"
debdb_to_brldb "${bootstrap_dir}/Packages" "${bootstrap_dir}/brldb"
step "Calculating required bootstrap packages"
brldb_calculate_required_packages "${bootstrap_dir}/brldb" "${bootstrap_dir}/required_packages" "${bootstrap_deps}"
step "Downloading bootstrap packages"
checksum_downloads "${cache}/packages/" "$(awk -v"m=${target_mirror}" '{print m"/"$0}' "${bootstrap_dir}/required_packages")"
step "Extracting bootstrap packages"
bootstrap_packages="$(awk -v"d=${cache}/packages/" '{sub(/^.*\//,d);print $1}' "${bootstrap_dir}/required_packages")"
# shellcheck disable=SC2086
extract_debs "${bootstrap_dir}" ${bootstrap_packages}
step "Running bootstrap software"
setup_chroot "${bootstrap_dir}"
setup_ssl "${bootstrap_dir}"
set +o pipefail
if LANG=C chroot "${bootstrap_dir}" debootstrap --help | grep -q "cache-dir"; then
share_cache "packages" "${bootstrap_dir}/packages"
yes "" | LANG=C chroot "${bootstrap_dir}" debootstrap --variant=minbase --cache-dir="/packages" "${target_release}" "/target-root" "${target_mirror}"
else
yes "" | LANG=C chroot "${bootstrap_dir}" debootstrap --variant=minbase "${target_release}" "/target-root" "${target_mirror}"
fi
set -o pipefail
step "Configuring"
set +o pipefail
setup_chroot "${target_dir}"
autopkgs="$(LANG=C chroot "${target_dir}" /usr/bin/apt-mark showmanual)"
# word splitting is desired here
# shellcheck disable=SC2086
yes "" | LANG=C chroot "${target_dir}" /usr/bin/apt-mark auto ${autopkgs}
yes "" | LANG=C chroot "${target_dir}" /usr/bin/apt-get update
yes "" | LANG=C chroot "${target_dir}" /usr/bin/apt-get install locales-all
set -o pipefail
}

View File

@ -0,0 +1,151 @@
#!/bedrock/libexec/busybox sh
#
# Rocky bootstrap support
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# version 2 as published by the Free Software Foundation.
#
# Copyright (c) 2016-2021 Daniel Thau <danthau@bedrocklinux.org>
#
# shellcheck source=src/slash-bedrock/libexec/brl-fetch
. /bedrock/share/common-code
trap 'fetch_abort "Unexpected error occurred."' EXIT
check_supported() {
false
}
get_mirror_suffix() {
if [ "$(echo "${target_release}" | sed 's/-[a-z]*$//')" -lt 8 ]; then
echo "${target_release}/os/${distro_arch}/"
else
echo "${target_release}/BaseOS/${distro_arch}/os"
fi
}
speed_test_url() {
echo "$(get_mirror_suffix)/repodata/repomd.xml"
}
list_mirrors() {
mirror_list_url='https://mirrors.rockylinux.org/mirrormanager/mirrors'
download -q "${mirror_list_url}" - |
awk '/<table/,/<\/table/' |
grep '<a class.*">http' |
list_links |
grep "^http"
}
brl_arch_to_distro() {
case "${1}" in
"aarch64") echo "aarch64" ;;
"x86_64") echo "x86_64" ;;
*) abort "brl does not know how to translate arch \"${1}\" to ${distro} format" ;;
esac
}
list_architectures() {
cat <<EOF
aarch64
x86_64
EOF
}
default_release() {
list_releases |
grep -ve "[a-z-]" | # do not default stream releases, only fixed ones
sort -n |
tail -n1
}
list_releases() {
for mirror in "${flag_mirror}" "https://download.rockylinux.org/pub/rocky/"; do
if download -q "${mirror}" - |
list_links |
grep '^[0-9][0-9a-z-]*/$' |
sed 's,/$,,'; then
break
fi
done
}
bootstrap_deps() {
echo "dnf rpm rocky-release filesystem shadow-utils rocky-gpg-keys"
}
fetch() {
suffix="$(get_mirror_suffix)"
step "Downloading package information database"
url="$(find_link "${target_mirror}/${suffix}/repodata/" "primary.xml.gz")"
download "${url}" "${bootstrap_dir}/primary.xml.gz"
step "Extracting package information database"
gunzip "${bootstrap_dir}/primary.xml.gz"
step "Converting distro package information database to brl format"
if [ "${target_arch}" = i686 ]; then
# CentOS arch name is i386 in mirrors but i686 in package manager
distro_arch="i686" rpmdb_to_brldb "${bootstrap_dir}/primary.xml" "${bootstrap_dir}/brldb"
else
rpmdb_to_brldb "${bootstrap_dir}/primary.xml" "${bootstrap_dir}/brldb"
fi
# At the time of writing, the CentOS 8/8-stream primary.xml.gz
# incorrectly indicates platform-python requires
# /usr/libexec/platform-python rather than provides it. Hack in a fix.
if [ "$(echo "${target_release}" | sed 's/-[a-z]*$//')" -ge 8 ]; then
echo "/usr/libexec/platform-python platform-python" >>"${bootstrap_dir}/brldb/provides/u"
fi
step "Calculating required bootstrap packages"
brldb_calculate_required_packages "${bootstrap_dir}/brldb" "${bootstrap_dir}/required_packages" "$(bootstrap_deps)"
step "Downloading bootstrap packages"
checksum_downloads "${cache}/packages/" "$(awk -v"m=${target_mirror}/${suffix}" '{print m"/"$0}' "${bootstrap_dir}/required_packages")"
step "Extracting bootstrap packages"
# This round is just to bootstrap the distro's rpm.
# Next step we'll use the distro's rpm to install everything properly.
# Need to extract filesystem first to ensure symlinks are set up
bootstrap_packages="$(awk -v"d=${cache}/packages/" '{sub(/^.*\//,d);print $1}' "${bootstrap_dir}/required_packages")"
# shellcheck disable=SC2086
extract_rpms "${bootstrap_dir}" "${cache}/packages"/filesystem*.rpm ${bootstrap_packages}
step "Installing bootstrap packages"
setup_chroot "${bootstrap_dir}"
# setup_ssl "${bootstrap_dir}" # fights with yum/dnf later on, not actually needed
share_cache "packages" "${bootstrap_dir}/packages"
bootstrap_packages="$(awk -v"d=/packages/" '{sub(/^.*\//,d);print $1}' "${bootstrap_dir}/required_packages")"
# shellcheck disable=SC2086
LC_ALL=C chroot "${bootstrap_dir}" sh -c 'rpm --import /etc/pki/rpm-gpg/*'
LC_ALL=C chroot "${bootstrap_dir}" rpm -i ${bootstrap_packages}
step "Running bootstrap software"
# By default, dnf clears anything in its package cache.
# Configure them to retain them so we can leverage previous cached
# packages.
if [ -e "${bootstrap_dir}/etc/dnf/dnf.conf" ] && grep -q "^keepcache=1$" "${bootstrap_dir}/etc/dnf/dnf.conf"; then
share_cache "dnf-cache" "${bootstrap_dir}/target-root/var/cache/dnf"
elif [ -e "${bootstrap_dir}/etc/dnf/dnf.conf" ] && grep -q "^keepcache=0$" "${bootstrap_dir}/etc/dnf/dnf.conf"; then
sed 's/^keepcache=0$/keepcache=1/' "${bootstrap_dir}/etc/dnf/dnf.conf" >"${bootstrap_dir}/etc/dnf/dnf.conf-new"
mv "${bootstrap_dir}/etc/dnf/dnf.conf-new" "${bootstrap_dir}/etc/dnf/dnf.conf"
share_cache "dnf-cache" "${bootstrap_dir}/target-root/var/cache/dnf"
elif [ -r "${bootstrap_dir}/etc/dnf/dnf.conf" ]; then
echo "keepcache=1" >>"${bootstrap_dir}/etc/dnf/dnf.conf"
share_cache "dnf-cache" "${bootstrap_dir}/target-root/var/cache/dnf"
fi
LC_ALL=C chroot "${bootstrap_dir}" rpm -i --root=/target-root --nodeps ./packages/centos-release-*.rpm 2>/dev/null || true
if [ "$(echo "${target_release}" | sed 's/-[a-z]*$//')" -lt 8 ]; then
LC_ALL=C chroot "${bootstrap_dir}" dnf --installroot=/target-root install -y rpm-build dnf
else
LC_ALL=C chroot "${bootstrap_dir}" dnf --installroot=/target-root --releasever="${target_release}" install -y rpm-build dnf
fi
# Need to set database timestamps for pmm due to `dnf -C` usage
umount -l "${bootstrap_dir}/var/cache/dnf" >/dev/null 2>&1 || true
setup_chroot "${target_dir}"
LC_ALL=C chroot "${target_dir}" dnf -y update
}

View File

@ -0,0 +1,103 @@
#!/bedrock/libexec/busybox sh
#
# Slackware bootstrap support
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# version 2 as published by the Free Software Foundation.
#
# Copyright (c) 2016-2019 Daniel Thau <danthau@bedrocklinux.org>
#
# shellcheck source=src/slash-bedrock/libexec/brl-fetch
. /bedrock/share/common-code
trap 'fetch_abort "Unexpected error occurred."' EXIT
check_supported() {
false
}
speed_test_url() {
echo "/slackware64-current/CHECKSUMS.md5"
}
list_mirrors() {
mirror_list_url='https://mirrors.slackware.com/mirrorlist/'
download -q "${mirror_list_url}" - |
sed 's/[<> \t\n\r]/\n/g' |
awk -F"[=>]" '/^href=/ || /^HREF=/ {print$2}' |
grep "^http"
}
brl_arch_to_distro() {
case "${1}" in
"i586") echo "slackware" ;;
"x86_64") echo "slackware64" ;;
*) abort "brl does not know how to translate arch \"${1}\" to ${distro} format" ;;
esac
}
list_architectures() {
cat <<EOF
i586
x86_64
EOF
}
default_release() {
list_releases | grep -ve "current" | sort -nr | head -n1
}
list_releases() {
for mirror in "${flag_mirror}" $(list_mirrors); do
if download -q "${mirror}" - |
list_links |
grep -e '^slackware64-[0-9]' |
sed -e 's/^slackware64-//' -e 's,/$,,'; then
echo "current"
break
fi
done
}
fetch() {
prefix="${target_mirror}/${distro_arch}-${target_release}/${distro_arch}/"
step "Downloading bootstrap packages"
download "${prefix}/CHECKSUMS.md5" "${bootstrap_dir}/checksum"
checksum_downloads "${cache}/packages/" "$(
awk -vm="${prefix}" '
x && $2 ~ /^[.]\/[al]\/.*[.]txz$/ {
printf "%s%s\tmd5sum\t%s\n", m, $2, $1
}
/^MD5 message digest.*Filename/{
x=1
}
' "${bootstrap_dir}/checksum"
)"
step "Extracting bootstrap packages"
total="$(find "${cache}/packages/" -mindepth 1 | wc -l)"
cp /bedrock/libexec/busybox "${bootstrap_dir}/busybox"
for pkg in "${cache}/packages/"*; do
# unxz can refuse to operate if it does not recognize the file extension. Using cat to work around this.
# shellcheck disable=SC2002
cat "${pkg}" | unxz | tar x -C "${bootstrap_dir}"
if [ -s "${bootstrap_dir}/install/doinst.sh" ]; then
chroot "${bootstrap_dir}" /busybox sh install/doinst.sh 2>/dev/null || true
fi
rm -rf "${bootstrap_dir}/install"
echo "x"
done | progress_bar "${total}"
step "Running bootstrap software"
setup_chroot "${bootstrap_dir}"
setup_ssl "${bootstrap_dir}"
share_cache "packages" "${bootstrap_dir}/packages"
for pkg in "${cache}/packages/"*; do
pkg="$(echo "${pkg}" | sed 's,^.*/,,')"
LC_ALL=C chroot "${bootstrap_dir}" /sbin/installpkg --root "/target-root" "/packages/${pkg}" >/dev/null 2>&1
echo "x"
done | progress_bar "${total}"
}

View File

@ -0,0 +1,210 @@
#!/bedrock/libexec/busybox sh
#
# Solus bootstrap support
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# version 2 as published by the Free Software Foundation.
#
# Copyright (c) 2018-2019 Daniel Thau <danthau@bedrocklinux.org>
#
# shellcheck source=src/slash-bedrock/libexec/brl-fetch
. /bedrock/share/common-code
trap 'fetch_abort "Unexpected error occurred."' EXIT
check_supported() {
false
}
speed_test_url() {
echo "packages/shannon/eopkg-index.xml.xz"
}
list_mirrors() {
# Could not find list of mirrors. This was the default mirror found on
# a fresh install.
echo "https://mirrors.rit.edu/solus/"
}
brl_arch_to_distro() {
case "${1}" in
"x86_64") echo "x86_64" ;;
*) abort "brl does not know how to translate arch \"${1}\" to ${distro} format" ;;
esac
}
list_architectures() {
echo "x86_64"
}
default_release() {
echo "rolling"
}
list_releases() {
echo "rolling"
}
fetch() {
step "Downloading package information database"
download "${target_mirror}/packages/shannon/eopkg-index.xml.xz" "${bootstrap_dir}/eopkg-index.xml.xz"
unxz "${bootstrap_dir}/eopkg-index.xml.xz"
step "Converting distro package information database to brl format"
eopkgdb_to_brldb "${bootstrap_dir}/eopkg-index.xml" "${bootstrap_dir}/brldb"
step "Calculating required bootstrap packages"
bootstrap_deps="perl $(cat "${bootstrap_dir}/brldb/required")"
brldb_calculate_required_packages "${bootstrap_dir}/brldb" "${bootstrap_dir}/required_packages" "${bootstrap_deps}"
step "Downloading bootstrap packages"
checksum_downloads "${cache}/packages/" "$(awk -v"m=${target_mirror}" '{print m"/packages/shannon/"$0}' "${bootstrap_dir}/required_packages")"
step "Extracting bootstrap packages"
bootstrap_packages="$(awk -v"d=${cache}/packages/" '{sub(/^.*\//,d);print $1}' "${bootstrap_dir}/required_packages")"
total="$(echo "${cache}/packages/baselayout-"*.eopkg "${bootstrap_packages}" | wc -w)"
for pkg in "${cache}/packages/baselayout-"*.eopkg ${bootstrap_packages}; do
unzip -d "${bootstrap_dir}" -qo "${pkg}"
tar xf "${bootstrap_dir}/install.tar.xz" -C "${bootstrap_dir}"
echo "x"
done | progress_bar "${total}"
step "Running bootstrap software"
setup_chroot "${bootstrap_dir}"
setup_ssl "${bootstrap_dir}"
share_cache "packages" "${bootstrap_dir}/target-root/var/cache/eopkg/packages"
# eopkg errors when installing baselayout, presumably due to
# missing assumed files. Extract it rather than install.
unzip -d "${bootstrap_dir}" -qo "${cache}/packages/baselayout-"*.eopkg
tar xf "${bootstrap_dir}/install.tar.xz" -C "${target_dir}"
# Solus' package manager depends on dbus at runtime.
mkdir -p "${bootstrap_dir}/run/dbus"
cp /bedrock/libexec/busybox "${bootstrap_dir}"
chroot "${bootstrap_dir}" /busybox addgroup -S messagebus >/dev/null 2>&1 || true
chroot "${bootstrap_dir}" /busybox adduser -h "/run/dbus" -g "D-Bus Message Daemon" -s "/bin/false" -G "messagebus" -S -D -H "messagebus" >/dev/null 2>&1 || true
chroot "${bootstrap_dir}" dbus-daemon --system
chroot "${bootstrap_dir}" eopkg --debug -y -D/target-root rdb
chroot "${bootstrap_dir}" eopkg -y -D/target-root ar Solus "${target_mirror}/packages/shannon/eopkg-index.xml.xz"
# Fix certs
# https://discuss.getsol.us/d/4996-help-with-ssl-certificate-error
chroot "${bootstrap_dir}" usysconf run -f ssl-certs
# system.base contains util-linux which depends on python3. However,
# installing system.base does not pull in python3, but rather just
# errors about a missing dependency. To resolve this, explicitly
# install python3 first with --ignore-deps.
chroot "${bootstrap_dir}" eopkg -y -D/target-root install python3 --ignore-dep
# Explicitly install system.base just in case python3 didn't pull
# something from system.base in as a dependency.
chroot "${bootstrap_dir}" eopkg -y -D/target-root install -c system.base
# perl is an unlisted required package.
chroot "${bootstrap_dir}" eopkg -y -D/target-root install perl
# There are various compatibility issues between Bedrock and Solus'
# fontcache setup. Install fontcache now in case a user wants it,
# applying fixes as we go.
#
# Installing fontcache rename()s from /etc to /usr, which EXDEVs.
if [ -e "${target_dir}/etc/fonts" ]; then
mv "${target_dir}/etc/fonts" "${target_dir}/usr/share/fonts"
fi
ln -s "../usr/share/fonts" "${target_dir}/etc/fonts"
chroot "${bootstrap_dir}" eopkg -y -D/target-root install fontconfig
# The post-fontcache /etc/fonts symlink is absolute, which confuses
# `brl status`. `brl status` should probably be updated to handle
# this, but for now we can hack around it by making /etc/fonts
# relative.
rm "${target_dir}/etc/fonts"
ln -s "../usr/share/fonts" "${target_dir}/etc/fonts"
# Fix certs
# https://discuss.getsol.us/d/4996-help-with-ssl-certificate-error
setup_chroot "${target_dir}"
chroot "${target_dir}" usysconf run -f ssl-certs
}
eopkgdb_to_brldb() {
mkdir -p "${2}/depends/" "${2}/provides" "${2}/paths"
tr -d '\n' <"${1}" |
sed -e 's,<,\n<,g' -e 's,>\(.\),>\n\1,g' |
grep '[^ ]' >"${2}/flattened"
awk -F"[<> ]" -v"dir=${2}" -v"total=$(wc -l <"${2}/flattened")" -v"arch=${distro_arch}" '
function brldbpath(type, name) {
if (substr(name,1,3) == "lib") {
return dir "/" type "/" substr(name, 4, 2)
} else {
return dir "/" type "/" substr(name, 1, 2)
}
}
/<!\[CDATA\[/ {
skip=1
}
/\]\]>/ {
skip=0
next
}
skip {
next
}
name && uri {
file = brldbpath("depends", name)
printf "%s", name >> file
for (i in depends) {
printf " %s", depends[i] >> file
delete depends[i]
}
printf "\n" >> file
close(file)
file = brldbpath("provides", name)
print name "\t" name >> file
close(file)
file = brldbpath("paths", name)
print name "\t" uri "\tsha1sum\t" hash >> file
close(file)
name = ""
uri = ""
hash = ""
}
/^<[^\/]/ && !/\/>$/ {
path = path ">" $2
next
}
/^<\// {
sub(">[^>]*$","",path)
next
}
path == ">PISI>Package>Name" {
name = $0
next
}
path == ">PISI>Package>RuntimeDependencies>Dependency" {
depends[$0] = $0
next
}
path == ">PISI>Package>PackageURI" {
uri = $0
next
}
path == ">PISI>Package>PackageHash" {
hash = $0
next
}
path == ">PISI>Package>PartOf" && name && $0 == "system.base" {
print name >> dir "/required"
}
int(NR * 100 / total) > percent {
percent = int(NR * 100 / total)
print "x"
}
' "${2}/flattened" | progress_bar 100
}

View File

@ -0,0 +1,171 @@
#!/bedrock/libexec/busybox sh
#
# Ubuntu bootstrap support
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# version 2 as published by the Free Software Foundation.
#
# Copyright (c) 2016-2021 Daniel Thau <danthau@bedrocklinux.org>
#
# shellcheck source=src/slash-bedrock/libexec/brl-fetch
. /bedrock/share/common-code
trap 'fetch_abort "Unexpected error occurred."' EXIT
check_supported() {
true
}
speed_test_url() {
echo "dists/${target_release}/Release"
}
list_mirrors() {
case "${target_arch}" in
"x86_64")
echo 'http://archive.ubuntu.com/ubuntu'
mirror_list_url='https://launchpad.net/ubuntu/+archivemirrors'
download -q "${mirror_list_url}" - |
awk '/mirrors_list/,/<\/div/' |
list_links |
grep "^http"
;;
*)
echo 'http://ports.ubuntu.com/ubuntu-ports/'
;;
esac
}
brl_arch_to_distro() {
case "${1}" in
"aarch64") echo "arm64" ;;
"armv7hl") echo "armhf" ;;
"ppc64le") echo "ppc64el" ;;
"s390x") echo "s390x" ;;
# Cannot find 32-bit x86 in Ubuntu 19.04. Apparently it was dropped.
"x86_64") echo "amd64" ;;
*) abort "brl does not know how to translate arch \"${1}\" to ${distro} format" ;;
esac
}
list_architectures() {
cat <<EOF
aarch64
armv7hl
ppc64le
s390x
x86_64
EOF
}
default_release() {
# cdimage is (1) updated to include the latest stable release, (2) does
# not include any unstable releases, and (3) has a relatively stable
# format that is relatively unlikely to update in a way that breaks
# parsing.
release_list_url='http://cdimage.ubuntu.com/releases/'
set +o pipefail
num="$(download -q "${release_list_url}" - 2>/dev/null |
list_links |
sed 's,/,,g' |
grep '^[0-9]*[.][0-9]*$' |
sort -rn |
head -n1)"
codenames="$(download -q "http://archive.ubuntu.com/ubuntu/dists" - 2>/dev/null |
list_links |
grep '/$' |
grep -v -- '-' |
grep -v -- '^devel/$' |
grep -ve '[.]' -ve '^/' |
sed 's,/$,,g')"
for codename in ${codenames}; do
if ! download -q "http://archive.ubuntu.com/ubuntu/dists/${codename}/Release" - |
awk -v"n=${num}" '$1 == "Version:" && $2 == n {exit 1}'; then
echo "${codename}"
set +o pipefail
return
fi
done
set -o pipefail
}
list_releases() {
for mirror in "${flag_mirror}" $(list_mirrors); do
if download -q "${mirror}/dists" - |
list_links |
grep '/$' |
grep -v -- '-' |
grep -ve '[.]' -ve '^/' |
sed 's,/$,,g' |
grep -v '^devel$'; then
break
fi
done
}
fetch() {
bootstrap_deps="debootstrap apt dpkg coreutils dash bash grep sed awk perl bzip2 gzip tar gpgv ubuntu-keyring"
# libapt-pkg.so.5.X provider changed from libapt-pkg5.0 in pre-eoan to libapt-pkg-dev in eoan
if [ "$( (
echo "${target_release:-}"
echo "eoan"
) | sort | head -n1)" != "eoan" ]; then
bootstrap_deps="${bootstrap_deps} libapt-pkg5.0"
else
bootstrap_deps="${bootstrap_deps} libapt-pkg-dev"
fi
step "Downloading package information database"
download "${target_mirror}/dists/${target_release}/main/binary-${distro_arch}/Packages.gz" "${bootstrap_dir}/Packages.gz"
gunzip "${bootstrap_dir}/Packages.gz"
step "Converting distro package information database to brl format"
debdb_to_brldb "${bootstrap_dir}/Packages" "${bootstrap_dir}/brldb"
step "Calculating required bootstrap packages"
brldb_calculate_required_packages "${bootstrap_dir}/brldb" "${bootstrap_dir}/required_packages" "${bootstrap_deps}"
step "Downloading bootstrap packages"
checksum_downloads "${cache}/packages/" "$(awk -v"m=${target_mirror}" '{print m"/"$0}' "${bootstrap_dir}/required_packages")"
step "Extracting bootstrap packages"
bootstrap_packages="$(awk -v"d=${cache}/packages/" '{sub(/^.*\//,d);print $1}' "${bootstrap_dir}/required_packages")"
# shellcheck disable=SC2086
extract_debs "${bootstrap_dir}" ${bootstrap_packages}
step "Running bootstrap software"
setup_chroot "${bootstrap_dir}"
setup_ssl "${bootstrap_dir}"
set +o pipefail
if LANG=C chroot "${bootstrap_dir}" debootstrap --help | grep -q "cache-dir"; then
share_cache "packages" "${bootstrap_dir}/packages"
yes "" | LANG=C chroot "${bootstrap_dir}" debootstrap --variant=minbase --cache-dir="/packages" "${target_release}" "/target-root" "${target_mirror}"
else
yes "" | LANG=C chroot "${bootstrap_dir}" debootstrap --variant=minbase "${target_release}" "/target-root" "${target_mirror}"
fi
set -o pipefail
step "Configuring"
if grep -q "\<main\>" "${target_dir}/etc/apt/sources.list" && ! grep -q "\<universe\>" "${target_dir}/etc/apt/sources.list"; then
# universe contains locales-all package needed below
sed 's/\<main\>/main universe/' "${target_dir}/etc/apt/sources.list" >"${target_dir}/etc/apt/sources.list-new"
mv "${target_dir}/etc/apt/sources.list-new" "${target_dir}/etc/apt/sources.list"
fi
case "${distro_arch}" in
"amd64")
echo "deb http://archive.ubuntu.com/ubuntu/ ${target_release}-security main universe" >>"${target_dir}/etc/apt/sources.list"
;;
esac
set +o pipefail
setup_chroot "${target_dir}"
autopkgs="$(LANG=C chroot "${target_dir}" /usr/bin/apt-mark showmanual)"
# word splitting is desired here
# shellcheck disable=SC2086
yes "" | LANG=C chroot "${target_dir}" /usr/bin/apt-mark auto ${autopkgs}
yes "" | LANG=C chroot "${target_dir}" /usr/bin/apt-get update
yes "" | LANG=C chroot "${target_dir}" /usr/bin/apt-get install locales-all
set -o pipefail
}

View File

@ -0,0 +1,140 @@
#!/bedrock/libexec/busybox sh
#
# Void Linux bootstrap support
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# version 2 as published by the Free Software Foundation.
#
# Copyright (c) 2016-2020 Daniel Thau <danthau@bedrocklinux.org>
#
# shellcheck source=src/slash-bedrock/libexec/brl-fetch
. /bedrock/share/common-code
trap 'fetch_abort "Unexpected error occurred."' EXIT
check_supported() {
true
}
speed_test_url() {
echo "static/sha256sums.txt"
}
list_mirrors() {
mirror_list_url='https://docs.voidlinux.org/xbps/repositories/mirrors/index.html'
download -q "${mirror_list_url}" - |
awk '/Tier 1 mirrors are/,/<\/table>/' |
list_links
}
brl_arch_to_distro() {
# while static mips/mipsel xbps shows up in the mirrors, the mirrors
# do not provide binary packages for it.
case "${1}" in
"aarch64") echo "aarch64" ;;
"armv7hl") echo "armv7l" ;;
# Void does offer i686, but glibc-only. The fetch strategy below is
# based on leveraging static xbps. Thus, at least for now, brl-fetch
# does not support either flavor of i686 Void.
"x86_64") echo "x86_64" ;;
*) abort "brl does not know how to translate arch \"${1}\" to ${distro} format" ;;
esac
}
list_architectures() {
cat <<EOF
aarch64
armv7hl
x86_64
EOF
}
default_release() {
echo "rolling"
}
list_releases() {
echo "rolling"
}
fetch() {
# void repo data found at:
# ${mirror}/current/aarch64/aarch64-repodata
# ${mirror}/current/armv7l-repodata
# ${mirror}/current/x86_64-repodata
# void-musl repo data found at:
# ${mirror}/current/aarch64/aarch64-musl-repodata
# ${mirror}/current/musl/armv7l-musl-repodata
# ${mirror}/current/musl/x86_64-musl-repodata
step "Downloading package information database"
# Using musl version of tools for both void flavors due to static
# linking.
case "${distro_arch}" in
"aarch64") prefix="aarch64" ;;
*) prefix="musl" ;;
esac
download "${target_mirror}/current/${prefix}/${distro_arch}-musl-repodata" "${bootstrap_dir}/repodata.tar.zstd"
step "Downloading bootstrap software"
pair="$(/bedrock/libexec/zstd -d <"${bootstrap_dir}/repodata.tar.zstd" | tar xf - -O "index.plist" | awk -F'[<>]' '
/^\t<key>/ {
section=$3
}
section == "xbps-static" && /^\t\t<key>/ {
subsection=$3
}
section == "xbps-static" && subsection == "filename-sha256" && /^\t\t<string>/ {
checksum=$3
}
section == "xbps-static" && subsection == "pkgver" && /^\t\t<string>/ {
filename=$3
}
checksum != "" && filename != "" {
print checksum"\t"filename
checksum=""
filename=""
}
')"
bootstrap_checksum="$(echo "${pair}" | awk '{print$1}')"
bootstrap_name="$(echo "${pair}" | awk '{print$2}')"
bootstrap_url="${target_mirror}/current/${prefix}/${bootstrap_name}.${distro_arch}-musl.xbps"
checksum_download "${cache}/xbps.tar.zstd" "sha256sum" "${bootstrap_checksum}" "${bootstrap_url}"
step "Preparing bootstrap software"
/bedrock/libexec/zstd -d <"${cache}/xbps.tar.zstd" | tar xf - -C "${bootstrap_dir}"
step "Running bootstrap software"
set +o pipefail
cp /bedrock/libexec/busybox "${bootstrap_dir}"
for dir in bin sbin usr/bin usr/sbin; do
mkdir -p "${bootstrap_dir}/${dir}"
done
chroot "${bootstrap_dir}" /busybox --install
setup_chroot "${bootstrap_dir}"
setup_ssl "${bootstrap_dir}"
share_cache "packages" "${bootstrap_dir}/target-root/var/cache/xbps"
case "${distro}:${distro_arch}" in
"void:aarch64") prefix="aarch64" ;;
"void:armv7l") prefix="" ;;
"void:x86_64") prefix="" ;;
"void-musl:aarch64") prefix="aarch64" ;;
"void-musl:armv7l") prefix="musl" ;;
"void-musl:x86_64") prefix="musl" ;;
*) abort "unrecognized distro:architecture pair \"${distro}:${distro_arch}\"" ;;
esac
mkdir -p "${target_dir}/var/db/xbps/https___alpha_de_repo_voidlinux_org_current"
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
set -o pipefail
step "Configuring"
mkdir -p "${target_dir}/etc/xbps.d/"
echo "repository=${target_mirror}/current/${prefix}" >"${target_dir}/etc/xbps.d/00-brl-fetch.conf"
# Void's zsh package does not create /etc/zsh/zshenv but it is needed
# for various Bedrock hooks
if ! [ -e "${target_dir}/etc/zsh/zshenv" ]; then
mkdir -p "${target_dir}/etc/zsh/"
echo "# File created by Bedrock Linux during stratum fetch" >"${target_dir}/etc/zsh/zshenv"
fi
}

View File

@ -0,0 +1,140 @@
#!/bedrock/libexec/busybox sh
#
# Void Linux (musl) bootstrap support
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# version 2 as published by the Free Software Foundation.
#
# Copyright (c) 2016-2020 Daniel Thau <danthau@bedrocklinux.org>
#
# shellcheck source=src/slash-bedrock/libexec/brl-fetch
. /bedrock/share/common-code
trap 'fetch_abort "Unexpected error occurred."' EXIT
check_supported() {
true
}
speed_test_url() {
echo "static/sha256sums.txt"
}
list_mirrors() {
mirror_list_url='https://docs.voidlinux.org/xbps/repositories/mirrors/index.html'
download -q "${mirror_list_url}" - |
awk '/Tier 1 mirrors are/,/<\/table>/' |
list_links
}
brl_arch_to_distro() {
# while static mips/mipsel xbps shows up in the mirrors, the mirrors
# do not provide binary packages for it.
case "${1}" in
"aarch64") echo "aarch64" ;;
"armv7hl") echo "armv7l" ;;
# Void does offer i686, but glibc-only. The fetch strategy below is
# based on leveraging static xbps. Thus, at least for now, brl-fetch
# does not support either flavor of i686 Void.
"x86_64") echo "x86_64" ;;
*) abort "brl does not know how to translate arch \"${1}\" to ${distro} format" ;;
esac
}
list_architectures() {
cat <<EOF
aarch64
armv7hl
x86_64
EOF
}
default_release() {
echo "rolling"
}
list_releases() {
echo "rolling"
}
fetch() {
# void repo data found at:
# ${mirror}/current/aarch64/aarch64-repodata
# ${mirror}/current/armv7l-repodata
# ${mirror}/current/x86_64-repodata
# void-musl repo data found at:
# ${mirror}/current/aarch64/aarch64-musl-repodata
# ${mirror}/current/musl/armv7l-musl-repodata
# ${mirror}/current/musl/x86_64-musl-repodata
step "Downloading package information database"
# Using musl version of tools for both void flavors due to static
# linking.
case "${distro_arch}" in
"aarch64") prefix="aarch64" ;;
*) prefix="musl" ;;
esac
download "${target_mirror}/current/${prefix}/${distro_arch}-musl-repodata" "${bootstrap_dir}/repodata.tar.zstd"
step "Downloading bootstrap software"
pair="$(/bedrock/libexec/zstd -d <"${bootstrap_dir}/repodata.tar.zstd" | tar xf - -O "index.plist" | awk -F'[<>]' '
/^\t<key>/ {
section=$3
}
section == "xbps-static" && /^\t\t<key>/ {
subsection=$3
}
section == "xbps-static" && subsection == "filename-sha256" && /^\t\t<string>/ {
checksum=$3
}
section == "xbps-static" && subsection == "pkgver" && /^\t\t<string>/ {
filename=$3
}
checksum != "" && filename != "" {
print checksum"\t"filename
checksum=""
filename=""
}
')"
bootstrap_checksum="$(echo "${pair}" | awk '{print$1}')"
bootstrap_name="$(echo "${pair}" | awk '{print$2}')"
bootstrap_url="${target_mirror}/current/${prefix}/${bootstrap_name}.${distro_arch}-musl.xbps"
checksum_download "${cache}/xbps.tar.zstd" "sha256sum" "${bootstrap_checksum}" "${bootstrap_url}"
step "Preparing bootstrap software"
/bedrock/libexec/zstd -d <"${cache}/xbps.tar.zstd" | tar xf - -C "${bootstrap_dir}"
step "Running bootstrap software"
set +o pipefail
cp /bedrock/libexec/busybox "${bootstrap_dir}"
for dir in bin sbin usr/bin usr/sbin; do
mkdir -p "${bootstrap_dir}/${dir}"
done
chroot "${bootstrap_dir}" /busybox --install
setup_chroot "${bootstrap_dir}"
setup_ssl "${bootstrap_dir}"
share_cache "packages" "${bootstrap_dir}/target-root/var/cache/xbps"
case "${distro}:${distro_arch}" in
"void:aarch64") prefix="aarch64" ;;
"void:armv7l") prefix="" ;;
"void:x86_64") prefix="" ;;
"void-musl:aarch64") prefix="aarch64" ;;
"void-musl:armv7l") prefix="musl" ;;
"void-musl:x86_64") prefix="musl" ;;
*) abort "unrecognized distro:architecture pair \"${distro}:${distro_arch}\"" ;;
esac
mkdir -p "${target_dir}/var/db/xbps/https___alpha_de_repo_voidlinux_org_current"
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
set -o pipefail
step "Configuring"
mkdir -p "${target_dir}/etc/xbps.d/"
echo "repository=${target_mirror}/current/${prefix}" >"${target_dir}/etc/xbps.d/00-brl-fetch.conf"
# Void's zsh package does not create /etc/zsh/zshenv but it is needed
# for various Bedrock hooks
if ! [ -e "${target_dir}/etc/zsh/zshenv" ]; then
mkdir -p "${target_dir}/etc/zsh/"
echo "# File created by Bedrock Linux during stratum fetch" >"${target_dir}/etc/zsh/zshenv"
fi
}

View File

@ -0,0 +1,88 @@
#!/bedrock/libexec/busybox sh
# shellcheck disable=SC2154 disable=SC2034
# shellcheck source=src/slash-bedrock/share/common-code
. /bedrock/share/common-code
Alpine="${color_distro}Alpine${color_norm}"
apk="${color_cmd}apk${color_norm}"
apt="${color_cmd}apt${color_norm}"
Arch="${color_distro}Arch${color_norm}"
bash="${color_cmd}bash${color_norm}"
Bedrock="${color_bedrock}Bedrock${color_norm}"
bedrock="${color_strat}bedrock${color_norm}"
bedrock_conf="${color_file}bedrock.conf${color_norm}"
bedrock_etc_bedrock_conf="${color_file}/bedrock/etc/bedrock.conf${color_norm}"
Bedrock_Linux="${color_bedrock}Bedrock Linux${color_norm}"
bedrock_strata="${color_file}/bedrock/strata/${color_norm}"
brl="${color_cmd}brl${color_norm}"
brl_apply="${color_cmd}brl apply${color_norm}"
brl_fetch="${color_cmd}brl fetch${color_norm}"
brl_import="${color_cmd}brl import${color_norm}"
brl_remove="${color_cmd}brl remove${color_norm}"
brl_tutorial="${color_cmd}brl tutorial${color_norm}"
brl_which="${color_cmd}brl which${color_norm}"
cross="${color_term}cross${color_norm}"
Debian="${color_distro}Debian${color_norm}"
disable="${color_term}disable${color_norm}"
disabled="${color_term}disabled${color_norm}"
enable="${color_term}enable${color_norm}"
enabled="${color_term}enabled${color_norm}"
etc_apt_sources_list="${color_file}/etc/apt/sources.list${color_norm}"
global="${color_term}global${color_norm}"
hashbang="${color_cmd}#!/bin/sh${color_norm}"
hijack="${color_term}hijack${color_norm}"
hijacked="${color_term}hijacked${color_norm}"
home="${color_file}/home${color_norm}"
init_stratum="${color_strat}$(brl deref init)${color_norm}"
jo="${color_cmd}jo${color_norm}"
jq="${color_cmd}jq${color_norm}"
local="${color_term}local${color_norm}"
locally="${color_term}locally${color_norm}"
ls="${color_cmd}ls${color_norm}"
makepkg="${color_cmd}makepkg${color_norm}"
man="${color_cmd}man${color_norm}"
pinned="${color_term}pinned${color_norm}"
pinning="${color_term}pinning${color_norm}"
pmm="${color_cmd}pmm${color_norm}"
reboot="${color_cmd}reboot${color_norm}"
restrict="${color_term}restrict${color_norm}"
restriction="${color_term}restriction${color_norm}"
run="${color_file}/run${color_norm}"
show="${color_term}show${color_norm}"
sources_list="${color_file}sources.list${color_norm}"
strat="${color_cmd}strat${color_norm}"
Strata="${color_term}Strata${color_norm}"
strata="${color_term}strata${color_norm}"
stratum="${color_term}stratum${color_norm}"
sudo="${color_cmd}sudo${color_norm}"
tmp="${color_file}/tmp${color_norm}"
tut_alpine="${color_strat}tut-alpine${color_norm}"
tut_void="${color_strat}tut-void${color_norm}"
Ubuntu="${color_distro}Ubuntu${color_norm}"
Void="${color_distro}Void${color_norm}"
xbps_install="${color_cmd}xbps-install${color_norm}"
# Users have complained busybox mktemp output is too difficult to type when
# following tutorial instructions. Attempt to generate a more user friendly
# temporary file names.
n=0
tmpfile=""
while true; do
n=$((n + 1))
tmpfile="/tmp/tut${n}"
touch "${tmpfile}" || continue
exec 9>"${tmpfile}" || continue
flock -nx 9 && break
done
tmpfile2=""
while true; do
n=$((n + 1))
tmpfile2="/tmp/tut${n}"
touch "${tmpfile2}" || continue
exec 8>"${tmpfile2}" || continue
flock -nx 8 && break
done
echo "" >"${tmpfile}"
echo "" >"${tmpfile2}"
trap 'rm -f ${tmpfile} ${tmpfile2}' INT TERM EXIT

View File

@ -0,0 +1,488 @@
#!/bedrock/libexec/busybox sh
#
# brl tutorial basic
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# version 2 as published by the Free Software Foundation.
#
# Copyright (c) 2019-2020 Daniel Thau <danthau@bedrocklinux.org>
#
# Bedrock Linux basics tutorial
# shellcheck source=src/slash-bedrock/share/brl-tutorial/common
. /bedrock/share/brl-tutorial/common
if [ "${*}" = "help" ]; then
echo "Bare minimum users are expected to know about Bedrock Linux"
return
fi
section "${brl_tutorial}" "
Welcome to the ${Bedrock_Linux} basics tutorial.
This tutorial will introduce you to the minimum ${Bedrock_Linux}-specific
background required to utilize and manage a ${Bedrock} system.
$(standard_intro)
"
section "${Strata}" "
A ${Bedrock} system is composed of ${strata}, which are collections of
interrelated files and processes. These typically correspond to Linux distro
installs: one may have a ${Debian} ${stratum}, an ${Arch} ${stratum}, etc.
${Bedrock} integrates these into a single, largely cohesive system. Run
$(cmd "brl list")
to see a list of ${strata} currently being integrated together.
$(
if [ "$(brl list | wc -l)" -le 2 ]; then
printf "This appears to be a fresh Bedrock Linux install with two ${strata}:
- ${bedrock}, which is the ${stratum} providing ${Bedrock}-specific functionality.
- ${init_stratum} which currently provides everything else.
This isn't much more interesting than ${init_stratum} would have been by itself.
"
else
printf "This system appears to already have a number of ${strata}, including:
- ${bedrock}, which is the ${stratum} providing ${Bedrock}-specific functionality.
- ${init_stratum}, which is currently providing your init system.
amongst others.
"
fi
)
The ${brl_fetch} command can be used to acquire new ${strata}. To see distros
${brl_fetch} knows how to acquire, run
$(cmd "brl fetch --list")
Let's get a couple more ${strata} to experiment with in this tutorial:
$(rcmd "brl fetch -n tut-alpine alpine")
$(rcmd "brl fetch -n tut-void void")
" "brl list | grep \"^tut-alpine\$\" && brl list | grep \"^tut-void\$\""
section "Cross-${stratum} commands" "
Many features from the ${strata} we just acquired should work just as they
would in their normal environments. For example, since we now have an
${Alpine} ${stratum}, we can run ${Alpine}'s ${apk} package manager directly on
the command line:
$(cmd "apk --help")
We also have a ${Void} ${stratum} providing ${xbps_install}:
$(cmd "xbps-install --help")
We can install ${Alpine}'s ${jq} and ${Void}'s ${jo}:
$(rcmd "apk add jq")
$(rcmd "xbps-install -y jo")
Importantly, the commands can interact just as they would were they from the
same distro:
$(cmd "jo \"distro=bedrock\" | jq \".distro\" | tee ${tmpfile}")
" "grep bedrock ${tmpfile}"
section "Other cross-${stratum} features" "
${Bedrock} integrates more than just terminal commands. It strives to make as
much as it can work transparently and cohesively across ${strata}, including:
- Graphical application menu contents
- Shell tab completion
- Kernel firmware detection
- Xorg fonts
- Some themes
Lets try another example: ${man} pages. We can get ${Alpine}'s ${jq} ${man}
page and ${Void}'s ${man} executable:
$(rcmd "apk add jq-doc")
$(rcmd "xbps-install -y man")
Then have ${Void}'s ${man} read ${Alpine}'s ${jq} documentation:
$(cmd "man jq | head | tee ${tmpfile}")
" "grep jq ${tmpfile}"
section "${brl_which}" "
On a ${Bedrock} system, every file and every process is associated with some
${stratum}. The ${brl_which} command can be used to query ${Bedrock} for this
association. Lets try it:
Which ${strata} provide the ${apk} and ${xbps_install} commands?
$(cmd "brl which apk")
$(cmd "brl which xbps-install")
What about commands that multiple ${strata} - ${bedrock}, ${tut_alpine}, ${tut_void},
$(
if strat -r init /bedrock/libexec/busybox which ls >/dev/null 2>&1; then
printf "${init_stratum}, "
fi
)etc - all provide, such as ${ls}?
$(cmd "brl which ls")
Makes sense it has to pick a ${stratum} here, but why that one? Keep this
question in mind, as it will be answered later in the tutorial.
Which ${strata} provide PID 1 (the init system) and PID $$ (this tutorial)?
$(cmd "brl which 1")
$(cmd "brl which $$")
Which stratum provides ${color_file}/${color_norm}, the root directory?
$(cmd "brl which /")
Again, sure it has to pick one, but why that specific ${stratum} for the root
directory that multiple ${strata} provide? Like the ${ls} situation, this will
be answered soon enough.
Which ${stratum} provides ${bedrock_etc_bedrock_conf}, the ${Bedrock} configuration
file?
$(cmd "brl which /bedrock/etc/bedrock.conf")
Wait - that last command output ${global}, but ${color_alert}we do not have a such a ${stratum}:${color_norm}
$(cmd "brl list | grep global")
What's going on here?
"
section "File path types: ${local}" "
To avoid conflicts, processes from one ${stratum} may see their own
${stratum}'s instance of a given file (or lack of file) at a given file path.
This is why the ${stratum} providing your shell:
$(cmd "brl which")
Sees its own root directory instead of another ${stratum}'s:
$(cmd "brl which /")
If your shell ${stratum} has a ${color_file}/etc/os-release${color_norm}, it
will probably correspond to your shell ${stratum} distro:
$(cmd "cat /etc/os-release")
This is needed to avoid conflicts. For example, ${Debian}'s ${apt} needs to
see ${Debian} mirrors at ${etc_apt_sources_list} and ${Ubuntu}'s ${apt} needs
to see ${Ubuntu}'s mirrors at the same path. If they saw the same contents in
${sources_list} these two programs would conflict with each other.
In ${Bedrock} terminology, these file paths are described as ${local}.
"
section "File path types: ${global}" "
If all paths were ${local}, ${strata} would be unable to interact with each
other. For ${strata} to interact, there are also ${global} paths: file paths
where every ${stratum} sees the same content. Under-the-hood, these are
${bedrock} files which are being shared with other ${strata}.
For example, all ${strata} see the same contents in ${run} to communicate over
common sockets:
$(cmd "brl which /run")
Directories like ${home} and ${tmp} are also ${global}. You can have software
from one ${stratum}, like ${Alpine}'s ${jq}, read files created by another
${stratum}, like ${Void}'s ${jo}, provided the file is in a ${global} location:
$(cmd "brl which /tmp")
$(cmd "jo \"path=global\" > ${tmpfile}")
$(cmd "jq \".path\" < ${tmpfile} | tee ${tmpfile2}")
" "grep global ${tmpfile2}"
section "File path types: ${cross}" "
Sometimes processes from one ${stratum} need to access ${local} files from
another. This is achieved via ${cross} file paths.
If you want to read or write to a ${local} file specific to a given ${stratum},
prefix ${bedrock_strata}${color_sub}<stratum>${color_norm} to the file path to ${cross} to that
${stratum}:
$(cmd "brl which /bedrock/strata/bedrock/etc/os-release")
$(cmd "cat /bedrock/strata/bedrock/etc/os-release")
$(cmd "brl which /bedrock/strata/tut-alpine/etc/os-release")
$(cmd "cat /bedrock/strata/tut-alpine/etc/os-release")
"
section "${strat}" "
${bedrock_strata} is only suitable for reading and writing ${cross} files. To
execute a program from a specific ${stratum}, prefix \`${strat} ${color_sub}<stratum>${color_norm}\`.
For example, if you care about which ${ls} you want to run:
$(cmd "strat tut-alpine ls --help 2>&1 | head -n1")
$(cmd "strat tut-void ls --help 2>&1 | head -n1 ")
If you do not specify the desired ${stratum} with ${strat}, ${Bedrock} will try
to figure one out from context:
- If ${Bedrock} is configured to ensure one ${stratum} always provides the
given command, it will do so. For example, init related commands should always
correspond to the ${stratum} providing PID 1. This is called ${pinning}.
- If the command is not ${pinned} to a given ${stratum} but is available
${locally}, ${Bedrock} will utilize the ${local} one. This is to ensure
distro-specific dependency quirks are met.
- If the command is not ${pinned} and not available ${locally}, ${Bedrock}
assumes the specific build of the command does not matter. In these cases
${Bedrock} will search other ${strata} and supply the first instance of the
command it finds.
The first bullet point above is why ${reboot} comes from the init stratum:
$(cmd "brl which reboot")
$(cmd "brl which 1")
The second bullet point above is why the ${ls} you get if you do not specify
one with ${strat}:
$(cmd "brl which ls")
is probably from the same ${stratum} providing your shell:
$(cmd "brl which")
and the third rule above is why ${apk} and ${xbps_install} work despite being
from different ${strata}:
$(cmd "brl which apk")
$(cmd "brl which xbps-install")
"
section "${restriction}" "
Occasionally, software may become confused by ${Bedrock}'s environment. Most
notably this occurs when build tools scan the environment for dependencies and
find them from different distributions. To handle this situation, ${strat}'s
$(flag -r) flag may be used to ${restrict} the command from seeing ${cross}-${stratum} hooks.
For example, normally ${tut_void}'s shell can see ${tut_alpine}'s ${apk}:
$(cmd "strat tut-void sh -c 'apk --help'")
But if you ${restrict} it, it cannot, and this command will fail:
$(cmd "strat -r tut-void sh -c 'apk --help'")
${Bedrock} will automatically ${restrict} some commands that it knows are
related to compiling, such as ${Arch}'s ${makepkg}. If this is a problem for
any reason, you can un-${restrict} with ${strat} $(flag -u).
In general, if something acts oddly under ${Bedrock}, the first thing you
should try is to ${restrict} it. This is especially true when it comes to
compiling software.
"
section "${stratum} states" "
It is sometimes useful to have a ${stratum}'s files on disk without them being
integrated into the rest of the system. To do this, ${disable} the ${stratum}:
$(rcmd "brl disable tut-void")
This will stop all of the ${stratum}'s running processes and block the ability
to launch new ones. This command will now fail:
$(cmd "strat tut-void xbps-install --help")
The ${stratum} may be re-enabled:
$(rcmd "brl enable tut-void")
after which this command will now work:
$(cmd "strat tut-void xbps-install --help")
"
section "Updating" "
Strata are each responsible for updating themselves. To update ${tut_alpine}
we can tell its package manager to update:
$(rcmd "apk update && apk upgrade")
and to update ${tut_void} we can similarly instruct its package manager:
$(rcmd "xbps-install -Syu")
${bedrock} can be updated via ${brl}:
$(rcmd "brl update")
"
section "pmm" "
Manually updating all package managers as shown in the previous section may be a
bit tedious. Other multi-package-manager workflows, such as searching multiple
package managers to see which provides a package, that can also be tedious to
do by hand.
To resolve this, Bedrock provides a utility called ${pmm} which abstracts
multi-package-manager and cross-package-manager workflows.
pmm mimics the user interface of other package managers. Open
${bedrock_etc_bedrock_conf}
as root and find the user-interface field under the [pmm] section. Populate it
according to the surrounding comments if it is empty then run
$(rcmd "brl apply")
to set ${pmm}s user interface. Now explore
$(cmd "pmm --help")
or potentially
$(cmd "pmm-install --help")
depending on your configuration.
"
section "Removing ${strata}" "
As a protective measure, ${strata} may not be removed while ${enabled}. If you
wish to remove a ${stratum}, first ${disable} it.
$(rcmd "brl disable tut-alpine")
$(rcmd "brl remove tut-alpine")
If you know the target ${stratum} is ${enabled}, ${brl_remove} takes a
${color_cmd}-d${color_norm} flag to ${disable} prior to removing:
$(rcmd "brl remove -d tut-void")
" "! brl list -v | grep -e \"^tut-alpine$\" -e \"^tut-void$\""
section "Special ${strata}" "
The ${stratum} currently providing PID 1 (the init) may not be ${disabled}, as the
Linux kernel does not respond well to PID 1 dying. Given
$(cmd "brl which 1")
this command will fail:
$(rcmd "brl disable $(brl deref init)")
If you wish to remove the init-providing ${stratum}, first reboot and select
another ${stratum} to provide your init for the given session.
The ${bedrock} ${stratum} glues the entire system together. It is the only
${stratum} which may not be removed.
$(
if hijacked_stratum="$(brl deref hijacked 2>&1)"; then
hijacked_stratum="${color_strat}${hijacked_stratum}${color_norm}"
printf "
When ${Bedrock} ${hijacked} this computer, it:
- Moved the previous install files elsewhere.
- Installed itself to the root of the system.
- Added the previous install as a new ${stratum} called ${hijacked_stratum}.
Now that the ${hijack} operation has completed, there is nothing particularly
special about the ${hijacked_stratum} ${stratum}. You are free to remove it,
should you wish to do so. Just make sure to install anything essential that
${hijacked_stratum} is providing, such as the bootloader or kernel or ${sudo},
in another ${stratum}.
"
fi
)
"
section "brl import" "
If you would like to make a ${stratum} from some distro that ${brl_fetch} does
not support, you may use the ${brl_import} command to do so.
Get the desired files in some format such as:
- directory containing desired files
- tarball containing desired files
- Virtual Machine image (e.g. .qcow, .vdi, .vmdk)
then run
$(rcmd "brl import <name> </path/to/source>")
"
section "${bedrock_conf}" "
All ${Bedrock} configuration is placed in a single file,
${bedrock_etc_bedrock_conf}. If it seems like something ${Bedrock} does should
be configurable, look in there. After making changes to ${bedrock_conf} run
${brl_apply} to ensure they take effect.
For example, run
$(cmd "brl --help")
$(
if [ "$(cfg_value "miscellaneous" "color")" = "true" ]; then
printf "and notice how pretty and colorful the output is.
Now open ${bedrock_etc_bedrock_conf} and find
${color_file}color = true${color_norm}
towards the bottom and change it to
${color_file}color = false${color_norm}
and apply that change:
$(rcmd "brl apply")
Now run
$(cmd "brl --help")
and notice how boring and monotone the output is.
"
else
printf "and notice how boring and monotone the output is.
Now open ${bedrock_etc_bedrock_conf} and find
${color_file}color = [...]${color_norm}
towards the bottom and change it to
${color_file}color = true${color_norm}
and apply that change:
$(rcmd "brl apply")
Now run
$(cmd "brl --help")
and notice how pretty and colorful the output is.
"
fi
)
Finally, change the ${bedrock_conf} setting back and
$(rcmd "brl apply")
again to reset everything to how it was before.
"
section "${brl}" "
Most operations used to manage ${Bedrock} can be found in the ${brl} command.
This includes both those discussed earlier in the tutorial as well as some
which were skipped for brevity.
After this tutorial, consider exploring ${brl}:
$(cmd "brl --help")
going through other tutorials:
$(cmd "brl tutorial --help")
or reading through ${bedrock_etc_bedrock_conf}.
"

View File

@ -0,0 +1,201 @@
#!/bedrock/libexec/busybox sh
#
# brl tutorial brl-fetch
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# version 2 as published by the Free Software Foundation.
#
# Copyright (c) 2019-2020 Daniel Thau <danthau@bedrocklinux.org>
#
# brl-fetch tutorial
# shellcheck source=src/slash-bedrock/share/brl-tutorial/common
. /bedrock/share/brl-tutorial/common
if [ "${*}" = "help" ]; then
echo "The brl fetch command"
return
fi
section "${brl_fetch}" "
Welcome to the ${Bedrock_Linux} ${brl_fetch} tutorial.
${Bedrock_Linux} allows one to mix and match features from other distros. To
leverage this said features need to be available on disk. ${Bedrock} provides
a ${brl_fetch} command to facilitate getting files from other distros into a
${Bedrock} system. This tutorial covers ${brl_fetch} usage.
$(standard_intro)
"
section "Listing distro options" "
To see the of supported distros ${brl_fetch} can acquire, run it with the
$(flag -L) or $(flag --list) flag:
$(cmd "brl fetch -L")
Should these distro change something and break ${brl_fetch}'s logic to acquire
them, the associated ${Bedrock} maintainer will attempt to remedy it when time
permits.
${brl_fetch} also has code to fetch other distros which lack a ${Bedrock}
maintainer. These worked at one point but may no longer. To see a list of
such distros, run ${brl_fetch} with the $(flag -X) or $(flag --experimental) flag:
$(cmd "brl fetch -X")
These flags can be combined to see all possibly available distros:
$(cmd "brl fetch -LX | tee ${tmpfile}")
" "grep alpine ${tmpfile}"
section "Specifying a stratum name" "
By default, ${brl_fetch} will name the ${strata} it creates after the
corresponding distro. This is not always desirable. For example:
- Some may wish to have multiple ${strata} corresponding to the same distro,
such as for different releases.
- Some may prefer to name their ${strata} after the release of the distro, such
as \"buster\" for a ${Debian} 10, codenamed \"buster,\" ${stratum}.
- Some may prefer to name strata after the functionality they provide, such as
a \"xorg\" ${stratum} which provides X.org functionality
$(
found=""
for cur in $(brl list); do
for avail in $(brl fetch --list); do
if [ "${cur}" = "${avail}" ]; then
found="${cur}"
break
fi
done
if [ -n "${found}" ]; then
break
fi
done
if [ -n "${found}" ]; then
printf "Since you already have a(n) ${color_strat}${found}${color_norm} ${stratum},
${brl_fetch} will be unable to fetch another one without specifying a new name
and this command will fail:
${color_alert}# brl fetch ${found}${color_norm}
"
fi
)
Lets grab an ${Alpine} stratum and prefix \"tut-\" to the name to clarify it is
associated with this tutorial:
$(rcmd "brl fetch -n tut-alpine alpine")
" "brl list | grep \"^tut-alpine\$\""
section "Specifying release" "
If no release is specified, ${brl_fetch} will attempt to fetch the latest
stable release of a given distro.
To see potential releases for a given distro, specify the distro and the
$(flag -R) or $(flag --releases) flag:
$(cmd "brl fetch -R ubuntu")
This could be used, for example, if you wish to select between the latest
${Ubuntu} release and the latest ${Ubuntu} LTS release, or between ${Debian}
Stable, ${Debian} Testing, and ${Debian} Unstable.
To instruct ${brl_fetch} to acquire a given release of a distro, specify the
$(flag -r) or $(flag --release) flag:
$(rcmd "brl fetch -n tut-edge -r edge alpine")
We now have both latest-stable and edge releases of Alpine, which usually have
different versions:
$(cmd "cat /bedrock/strata/tut-alpine/etc/alpine-release | tee ${tmpfile}")
$(cmd "cat /bedrock/strata/tut-edge/etc/alpine-release | tee ${tmpfile2}")
" "grep [.] ${tmpfile} && grep [.] ${tmpfile2}"
alpine_mirror="$(sed 's,/edge/main,,' /bedrock/strata/tut-edge/etc/apk/repositories)"
section "Specifying mirror" "
If no mirror is specified or configured, ${brl_fetch} will attempt to determine
one automatically. This may take some time. Moreover, it may not always find
a valid mirror, let alone the optimal one.
If you know which package mirror you would like ${brl_fetch} to use for a given
distro, it may be configured in ${bedrock_etc_bedrock_conf}'s
${color_cmd}[brl-fetch-mirrors]${color_norm} section. For example, if you add:
${color_file}alpine = ${alpine_mirror}${color_norm}
future calls to ${color_cmd}brl fetch alpine${color_norm} will automatically utilize that mirror.
If you know a mirror which supports multiple distros, you can configure it as a
mirror prefix by configuring the root of the per-distro directories. For
example, if you configure:
${color_file}mirror-prefix = http://mirrors.edge.kernel.org${color_norm}
${brl_fetch} will check ${color_link}http://mirrors.edge.kernel.org/${color_sub}<distro>${color_norm} as a possible
mirror for every distro.
One may override ${bedrock_conf}'s ${brl_fetch} mirror configuration by
providing ${brl_fetch} the $(flag --mirror) flag:
$(rcmd "brl fetch -n tut-alpine2 -m ${alpine_mirror} alpine")
" "brl list | grep \"^tut-alpine2\$\""
section "Non-native ISAs preparation" "
${Bedrock} has experimental support for ${strata} with non-native instruction
set architectures via ${color_cmd}qemu${color_norm}. For example, it allows you to run arm binaries
on x86_64.
To provide this, it requires ${color_cmd}qemu-${color_sub}<arch>${color_cmd}-static${color_norm} executables. Lets acquire
those now:
$(rcmd "brl fetch -n tut-debian debian")
$(rcmd "strat tut-debian apt install -y qemu-user-static")
" "brl list | grep \"^tut-debian\$\" && strat -r tut-debian /bedrock/libexec/busybox which qemu-aarch64-static && strat -r tut-debian /bedrock/libexec/busybox which qemu-x86_64-static"
if [ "$(uname -m)" = "x86_64" ]; then
non_native_isa="aarch64"
else
non_native_isa="x86_64"
fi
section "Non-native ISAs" "
To list architectures ${brl_fetch} supports for a given distro, query it with
$(flag -A) or $(flag --archs):
$(cmd "brl fetch -A alpine")
To list distros ${brl_fetch} supports for a given architecture, specify the
architecture with $(flag -a) or $(flag --arch) and query with
$(flag -L)/$(flag --list)/$(flag -X)/$(flag --experimental):
$(cmd "brl fetch -a aarch64 -L")
Finally, to fetch a given ISA of a given distro, use $(flag -a) to specify the ISA:
$(rcmd "brl fetch -n tut-${non_native_isa} -a ${non_native_isa} alpine")
Note executables from this new ${stratum} think they're running with another ISA:
$(cmd "strat tut-alpine uname -m | tee ${tmpfile}")
$(cmd "strat tut-${non_native_isa} uname -m | tee ${tmpfile2}")
" "grep ${non_native_isa} ${tmpfile2}"
section "Skipping post-fetch setup" "
By default, ${brl_fetch} will ${enable} and ${show} newly fetched ${strata} so
that they are immediately available for use. If this is not always desired and
may be skipped by providing $(flag --dont-enable) and/or $(flag --dont-show) as
is appropriate.
"
section "Clean up" "
This tutorial created a number of ${strata} which you are no longer need after
the tutorial. Clean those up to complete the tutorial:
$(rcmd brl disable tut-alpine tut-alpine2 tut-edge tut-debian tut-${non_native_isa})
$(rcmd brl remove tut-alpine tut-alpine2 tut-edge tut-debian tut-${non_native_isa})
" "! brl list -v | grep -e \"^tut-alpine$\" -e \"^tut-alpine2$\" -e \"^tut-edge$\" -e \"^tut-debian$\" -e \"^tut-${non_native_isa}$\""

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,3 @@
# Automatically added by Bedrock Linux
source_tree="/bedrock/cross/src/"

View File

@ -0,0 +1,168 @@
# fish tab completion for brl
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# version 2 as published by the Free Software Foundation.
#
# Copyright (c) 2018-2020 Daniel Thau <danthau@bedrocklinux.org>
#
function _brl_argnum
if [ (count (commandline -opc)) -eq "$argv" ]
return 0
else
return 1
end
end
function _brl_arg_is
set args (commandline -opc)
if [ (count $args) -lt $argv[1] ]
return 1
else if [ "$args[$argv[1]]" != "$argv[2]" ]
return 1
else
return 0
end
end
function _brl_which_bin
for dir in $PATH
ls -1 $dir 2>/dev/null
end
end
function _brl_which_any
if _brl_arg_is 3 -c
return 1
else if _brl_arg_is 3 --current
return 1
else if _brl_arg_is 3 -b
return 1
else if _brl_arg_is 3 --bin
return 1
else if _brl_arg_is 3 -f
return 1
else if _brl_arg_is 3 --file
return 1
else if _brl_arg_is 3 --p
return 1
else if _brl_arg_is 3 --pid
return 1
else if _brl_arg_is 3 -x
return 1
else if _brl_arg_is 3 --xwindow
return 1
end
return 0
end
complete -f -c brl -a 'help strat list which fetch import remove rename copy status enable disable repair hide show alias deref update reload version report tutorial' -d 'brl subcommand' -n "_brl_argnum 1"
complete -f -c brl -o 'h' -d 'print help message' -n "_brl_argnum 1"
complete -f -c brl -o 'h' -d 'print help message' -n "_brl_argnum 2"
complete -f -c brl -l 'help' -d 'print help message' -n "_brl_argnum 1"
complete -f -c brl -l 'help' -d 'print help message' -n "_brl_argnum 2"
complete -f -c brl -n '_brl_arg_is 2 list; and _brl_argnum 2' -o 'e' -d 'list enabled strata'
complete -f -c brl -n '_brl_arg_is 2 list; and _brl_argnum 2' -o 'E' -d 'list aliases to enabled strata'
complete -f -c brl -n '_brl_arg_is 2 list; and _brl_argnum 2' -o 'd' -d 'list disabled strata'
complete -f -c brl -n '_brl_arg_is 2 list; and _brl_argnum 2' -o 'D' -d 'list aliases to disabled strata'
complete -f -c brl -n '_brl_arg_is 2 list; and _brl_argnum 2' -o 'a' -d 'list all strata'
complete -f -c brl -n '_brl_arg_is 2 list; and _brl_argnum 2' -o 'A' -d 'list all aliases'
complete -f -c brl -n '_brl_arg_is 2 list; and _brl_argnum 2' -o 'r' -d 'dereference aliases'
complete -f -c brl -n '_brl_arg_is 2 list; and _brl_argnum 2' -o 'i' -d 'include hidden strata'
complete -f -c brl -n '_brl_arg_is 2 which; and _brl_argnum 2' -o 'c' -d 'which stratum provides current process'
complete -f -c brl -n '_brl_arg_is 2 which; and _brl_argnum 2' -l 'current' -d 'which stratum provides current process'
complete -f -c brl -n '_brl_arg_is 2 which; and _brl_argnum 2' -o 'b' -d 'which stratum provides binary in $PATH'
complete -f -c brl -n '_brl_arg_is 2 which; and _brl_argnum 2' -l 'bin' -d 'which stratum provides binary in $PATH'
complete -f -c brl -n '_brl_arg_is 2 which; and _brl_argnum 2' -o 'f' -d 'which stratum provides a given file path'
complete -f -c brl -n '_brl_arg_is 2 which; and _brl_argnum 2' -l 'file' -d 'which stratum provides a given file path'
complete -f -c brl -n '_brl_arg_is 2 which; and _brl_argnum 2' -o 'p' -d 'which stratum provides a given process ID'
complete -f -c brl -n '_brl_arg_is 2 which; and _brl_argnum 2' -l 'pid' -d 'which stratum provides a given process ID'
complete -f -c brl -n '_brl_arg_is 2 which; and _brl_argnum 2' -o 'x' -d 'which stratum provides a given process ID'
complete -f -c brl -n '_brl_arg_is 2 which; and _brl_argnum 2' -l 'xwindow' -d 'which stratum provides a given X11 window'
complete -f -c brl -n '_brl_arg_is 2 which; and _brl_arg_is 3 -b' -a '(_brl_which_bin)' -d 'binary'
complete -f -c brl -n '_brl_arg_is 2 which; and _brl_arg_is 3 --bin' -a '(_brl_which_bin)' -d 'binary'
complete -f -c brl -n '_brl_arg_is 2 which; and _brl_arg_is 3 -f' -a '(__fish_complete_path)' -d 'file'
complete -f -c brl -n '_brl_arg_is 2 which; and _brl_arg_is 3 --file' -a '(__fish_complete_path)' -d 'file'
complete -f -c brl -n '_brl_arg_is 2 which; and _brl_arg_is 3 -p' -a '(__fish_complete_pids)' -d 'pid'
complete -f -c brl -n '_brl_arg_is 2 which; and _brl_arg_is 3 --pid' -a '(__fish_complete_pids)' -d 'pid'
complete -f -c brl -n '_brl_arg_is 2 which; and _brl_which_any' -a '(_brl_which_bin)' -d 'binary'
complete -f -c brl -n '_brl_arg_is 2 which; and _brl_which_any' -a '(__fish_complete_path)' -d 'file'
complete -f -c brl -n '_brl_arg_is 2 which; and _brl_which_any' -a '(__fish_complete_pids)' -d 'pid'
complete -f -c brl -n '_brl_arg_is 2 fetch; and _brl_argnum 3' -o 'l' -d 'list supported distros'
complete -f -c brl -n '_brl_arg_is 2 fetch; and _brl_argnum 3' -l 'list' -d 'list supported distros'
complete -f -c brl -n '_brl_arg_is 2 fetch; and _brl_argnum 3' -o 'x' -d 'list experimental distros'
complete -f -c brl -n '_brl_arg_is 2 fetch; and _brl_argnum 3' -l 'experimental' -d 'list experimental distros'
complete -f -c brl -n '_brl_arg_is 2 fetch' -o 'R' -d 'list releases provided by distros'
complete -f -c brl -n '_brl_arg_is 2 fetch' -l 'releases' -d 'list releases provided by distros'
complete -f -c brl -n '_brl_arg_is 2 fetch' -o 'A' -d 'list CPU architectures supported by distros'
complete -f -c brl -n '_brl_arg_is 2 fetch' -l 'archs' -d 'list CPU architectures supported by distros'
complete -f -c brl -n '_brl_arg_is 2 fetch' -o 'n' -d 'specify new stratum name'
complete -f -c brl -n '_brl_arg_is 2 fetch' -l 'name' -d 'specify new stratum name'
complete -f -c brl -n '_brl_arg_is 2 fetch' -o 'r' -d 'specify release'
complete -f -c brl -n '_brl_arg_is 2 fetch' -l 'release' -d 'specify release'
complete -f -c brl -n '_brl_arg_is 2 fetch' -o 'a' -d 'specify CPU architecture'
complete -f -c brl -n '_brl_arg_is 2 fetch' -l 'arch' -d 'specify CPU architecture'
complete -f -c brl -n '_brl_arg_is 2 fetch' -o 'm' -d 'specify mirror'
complete -f -c brl -n '_brl_arg_is 2 fetch' -l 'mirror' -d 'specify mirror'
complete -f -c brl -n '_brl_arg_is 2 fetch' -o 'e' -d 'skip enabling newly fetched strata'
complete -f -c brl -n '_brl_arg_is 2 fetch' -l 'dont-enable' -d 'skip enabling newly fetched strata'
complete -f -c brl -n '_brl_arg_is 2 fetch' -o 's' -d 'skip showing newly fetched strata'
complete -f -c brl -n '_brl_arg_is 2 fetch' -l 'dont-show' -d 'skip showing newly fetched strata'
complete -f -c brl -n '_brl_arg_is 2 fetch' -a '(/bedrock/bin/brl fetch --list)' -d 'distro'
complete -f -c brl -n '_brl_arg_is 3 import' -a '(__fish_complete_path)' -d 'source'
complete -f -c brl -n '_brl_arg_is 2 remove' -a '(/bedrock/bin/brl list -aAi)' -d 'aliases and strata'
complete -f -c brl -n '_brl_arg_is 2 rename; and _brl_argnum 2' -a '(/bedrock/bin/brl list -dD)' -d 'aliases and disabled strata'
complete -f -c brl -n '_brl_arg_is 2 copy; and _brl_argnum 2' -a '(/bedrock/bin/brl list -dD)' -d 'stratum'
complete -f -c brl -n '_brl_arg_is 2 status' -a '(/bedrock/bin/brl list -aA)' -d 'strata or aliases'
complete -f -c brl -n '_brl_arg_is 2 enable' -a '(/bedrock/bin/brl list -dD)' -d 'strata or aliases'
complete -f -c brl -n '_brl_arg_is 2 disable' -a '(/bedrock/bin/brl list -eE)' -d 'enabled strata or aliases'
complete -f -c brl -n '_brl_arg_is 2 repair' -a '(/bedrock/bin/brl list -aA)' -d 'strata or aliases'
complete -f -c brl -n '_brl_arg_is 2 hide; and _brl_argnum 2' -o 'a' -d 'hide from all subsystems'
complete -f -c brl -n '_brl_arg_is 2 hide; and _brl_argnum 2' -l 'all' -d 'hide from all subsystems'
complete -f -c brl -n '_brl_arg_is 2 hide; and _brl_argnum 2' -o 'b' -d 'do not automatically enable stratum during boot'
complete -f -c brl -n '_brl_arg_is 2 hide; and _brl_argnum 2' -l 'boot' -d 'do not automatically enable stratum during boot'
complete -f -c brl -n '_brl_arg_is 2 hide; and _brl_argnum 2' -o 'c' -d 'do not include stratum files in /bedrock/cross'
complete -f -c brl -n '_brl_arg_is 2 hide; and _brl_argnum 2' -l 'cross' -d 'do not include stratum files in /bedrock/cross'
complete -f -c brl -n '_brl_arg_is 2 hide; and _brl_argnum 2' -o 'i' -d 'do not include stratum init option during boot'
complete -f -c brl -n '_brl_arg_is 2 hide; and _brl_argnum 2' -l 'init' -d 'do not include stratum init option during boot'
complete -f -c brl -n '_brl_arg_is 2 hide' -a '(/bedrock/bin/brl list -aA)' -d 'strata or aliases'
complete -f -c brl -n '_brl_arg_is 2 show; and _brl_argnum 2' -o 'a' -d 'show in all subsystems'
complete -f -c brl -n '_brl_arg_is 2 show; and _brl_argnum 2' -l 'all' -d 'show in all subsystems'
complete -f -c brl -n '_brl_arg_is 2 show; and _brl_argnum 2' -o 'b' -d 'automatically enable stratum during boot'
complete -f -c brl -n '_brl_arg_is 2 show; and _brl_argnum 2' -l 'boot' -d 'automatically enable stratum during boot'
complete -f -c brl -n '_brl_arg_is 2 show; and _brl_argnum 2' -o 'c' -d 'include stratum files in /bedrock/cross'
complete -f -c brl -n '_brl_arg_is 2 show; and _brl_argnum 2' -l 'cross' -d 'include stratum files in /bedrock/cross'
complete -f -c brl -n '_brl_arg_is 2 show; and _brl_argnum 2' -o 'i' -d 'include stratum init option during boot'
complete -f -c brl -n '_brl_arg_is 2 show; and _brl_argnum 2' -l 'init' -d 'include stratum init option during boot'
complete -f -c brl -n '_brl_arg_is 2 show' -a '(/bedrock/bin/brl list -aAi)' -d 'strata or aliases'
complete -f -c brl -n '_brl_arg_is 2 alias; and _brl_argnum 2' -a '(/bedrock/bin/brl list -a)' -d 'stratum'
complete -f -c brl -n '_brl_arg_is 2 deref' -a '(/bedrock/bin/brl list -A)' -d 'aliases'
complete -f -c brl -n '_brl_arg_is 2 update' -o 'm' -d 'specify mirror'
complete -f -c brl -n '_brl_arg_is 2 update' -l 'mirror' -d 'specify mirror'
complete -f -c brl -n '_brl_arg_is 2 fetch' -o 's' -d 'skip cryptographic signature check'
complete -f -c brl -n '_brl_arg_is 2 fetch' -l 'skip-check' -d 'skip cryptographic signature check'
complete -f -c brl -n '_brl_arg_is 2 fetch' -o 'f' -d 'skip warnings when applying update'
complete -f -c brl -n '_brl_arg_is 2 fetch' -l 'force-check' -d 'skip warnings when applying update'
complete -f -c brl -n '_brl_arg_is 2 report; and _brl_argnum 2' -o 'o' -d 'overwrite file at report path'
complete -f -c brl -n '_brl_arg_is 2 report; and _brl_argnum 2' -l 'overwrite' -d 'overwrite file at report path'
complete -f -c brl -n '_brl_arg_is 2 tutorial' -a '(find /bedrock/share/brl-tutorial/lessons/ -mindepth 1 | sed "s/^.*[0-9][0-9]*_//")' -d 'strata or aliases'

View File

@ -0,0 +1,157 @@
# fish tab completion for strat
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# version 2 as published by the Free Software Foundation.
#
# Copyright (c) 2018 Daniel Thau <danthau@bedrocklinux.org>
#
function _strat_opts
set args (commandline -opc)
set saw_help "0"
set saw_restrict "0"
set saw_arg0 "0"
set saw_arg0_arg "0"
set saw_stratum "0"
set saw_command "0"
for i in (seq 2 (count $args))
switch "$args[$i]"
case "-h"
set saw_help "$i"
case "--help"
set saw_help "$i"
case "-r"
set saw_restrict "$i"
case "--restrict"
set saw_restrict "$i"
case "-a"
set saw_arg0 "$i"
case "--arg0"
set saw_arg0 "$i"
case "*"
if [ "$saw_arg0" -ne 0 ]; and [ "$saw_arg0_arg" -eq 0 ]
set saw_arg0_arg "$i"
else if [ "$saw_stratum" -eq 0 ]
set saw_stratum "$i"
else
set saw_command "$i"
end
end
end
set opts ""
if [ "$saw_arg0" -ne 0 ]; and [ "$saw_arg0_arg" -eq 0 ]
set opts "$opts newarg"
else if [ "$saw_stratum" -eq 0 ]
set opts "$opts stratum"
if [ "$saw_help" -eq 0 ]
set opts "$opts help"
end
if [ "$saw_restrict" -eq 0 ]
set opts "$opts restrict"
end
if [ "$saw_arg0" -eq 0 ]
set opts "$opts arg0"
end
else if [ "$saw_command" -eq 0 ]
set opts "$opts command"
else
set opts "$opts pass"
end
if echo "$opts" | grep -q "\<$argv\>"
return 0
else
return 1
end
end
function _strat_subcommand
set args (commandline -opc)
set saw_help "0"
set saw_restrict "0"
set saw_arg0 "0"
set saw_arg0_arg "0"
set saw_stratum "0"
set saw_command "0"
for i in (seq 2 (count $args))
switch "$args[$i]"
case "-h"
set saw_help "$i"
case "--help"
set saw_help "$i"
case "-r"
set saw_restrict "$i"
case "--restrict"
set saw_restrict "$i"
case "-a"
set saw_arg0 "$i"
case "--arg0"
set saw_arg0 "$i"
case "*"
if [ "$saw_arg0" -ne 0 ]; and [ "$saw_arg0_arg" -eq 0 ]
set saw_arg0_arg "$i"
else if [ "$saw_stratum" -eq 0 ]
set saw_stratum "$i"
else
set saw_command "$i"
end
end
end
__fish_complete_subcommand --fcs-skip=(math $saw_command - 1)
end
function _strat_command
set args (commandline -opc)
set saw_help "0"
set saw_restrict "0"
set saw_arg0 "0"
set saw_arg0_arg "0"
set saw_stratum "0"
set saw_command "0"
for i in (seq 2 (count $args))
switch "$args[$i]"
case "-h"
set saw_help "$i"
case "--help"
set saw_help "$i"
case "-r"
set saw_restrict "$i"
case "--restrict"
set saw_restrict "$i"
case "-a"
set saw_arg0 "$i"
case "--arg0"
set saw_arg0 "$i"
case "*"
if [ "$saw_arg0" -ne 0 ]; and [ "$saw_arg0_arg" -eq 0 ]
set saw_arg0_arg "$i"
else if [ "$saw_stratum" -eq 0 ]
set saw_stratum "$i"
else
set saw_command "$i"
end
end
end
set prefix "/bedrock/strata/$args[$saw_stratum]"
for dir in $PATH
if not echo "$dir" | grep -q "^/bedrock/cross"
ls -1 $prefix$dir 2>/dev/null
end
end
end
complete -f -c strat -o 'h' -d 'print help message' -n '_strat_opts help'
complete -f -c strat -l 'help' -d 'print help message' -n '_strat_opts help'
complete -f -c strat -o 'r' -d 'disable cross-stratum hooks' -n '_strat_opts restrict'
complete -f -c strat -l 'restrict' -d 'disable cross-stratum hooks' -n '_strat_opts restrict'
complete -f -c strat -o 'a' -d 'specify arg0' -n '_strat_opts arg0'
complete -f -c strat -l 'arg0' -d 'specify arg0' -n '_strat_opts arg0'
complete -f -c strat -a '(/bedrock/bin/brl list)' -d 'stratum' -n '_strat_opts stratum'
complete -f -c strat -a '(_strat_command)' -n '_strat_opts command'
complete -x -c strat -a '(_strat_subcommand)' -n '_strat_opts pass'

View File

@ -0,0 +1,6 @@
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
<!-- Bedrock Linux cross-stratum fonts -->
<dir>/bedrock/cross/fonts/</dir>
</fontconfig>

View File

@ -0,0 +1,49 @@
#!/bedrock/libexec/busybox awk -f
#
# Package Manager Manager flags
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# version 2 as published by the Free Software Foundation.
#
# Copyright (c) 2013-2020 Daniel Thau <danthau@bedrocklinux.org>
# Map pmm internal name for a flag to either "value" or "binary".
#
# "value" indicates it expects a corresponding value. For example, in:
#
# pmm --stratum ubuntu install vim
#
# The flag `--stratum` takes a value, `ubuntu`.
#
# "binary" indicates it is a binary flag. It is either present or it is
# not. For example, in:
#
# pmm --quiet install vim
#
# The flag `--quiet` is present. The alternative was it not being present. It
# does not take a value.
#
# General, operation independent flags
#
flags["assume-no"] = "binary"
flags["assume-yes"] = "binary"
flags["confirm"] = "binary"
flags["quiet"] = "binary"
flags["verbose"] = "binary"
#
# pmm specific, operation independent flags
#
flags["strat"] = "value"
flags["package-manager"] = "value"
flags["every"] = "binary"
flags["newest"] = "binary"
flags["oldest"] = "binary"
flags["approx-version"] = "value"
flags["exact-version"] = "value"
flags["newer-or-equal"] = "value"
flags["newer-than"] = "value"
flags["older-or-equal"] = "value"
flags["older-than"] = "value"

View File

@ -0,0 +1,186 @@
#!/bedrock/libexec/busybox awk -f
#
# Package Manager Manager --help documentation
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# version 2 as published by the Free Software Foundation.
#
# Copyright (c) 2012-2020 Daniel Thau <danthau@bedrocklinux.org>
#
# Contents here populate help[], a map from operations and flags to their
# --help output. This is also used as internal documentation for new pmm
# developers, and so every operation and flag must have a help entry irrelevant
# of whether or not there is a user interface which would surface it.
#
#
# General, operation independent flags.
#
# Unlike operations, flags should not have implementations[].
#
help["assume-no"] = "assume no at prompts"
help["assume-yes"] = "assume yes at prompts"
help["confirm"] = "utilize additional confirmation prompts"
help["quiet"] = "lessen output verbosity"
help["verbose"] = "increase output verbosity"
#
# Operations which directly forward the underlying command output.
#
# The underlying format is forwarded rather than standardized because:
# - It may prompt the user, and we do not want to obscure the prompt.
# - Output contents vary too much across package managers to meaningfully
# standardize beyond trivial things such as "operation completed successfully."
#
help["install-packages"] = "install <pkgs>"
help["reinstall-packages"] = "reinstall <pkgs>"
help["remove-packages-limited"] = "uninstall <pkgs>"
help["remove-packages-full"] = "fully uninstall <pkgs> (e.g. also remove modified config files)"
help["verify-packages"] = "verify <pkgs> are installed correctly"
help["verify-all-packages"] = "verify all packages are installed correctly"
help["mark-packages-explicit"] = "mark <pkgs> as explicitly installed, not (only) to satisfy dependency needs"
help["mark-packages-implicit"] = "mark <pkgs> as installed only to satisfy a dependency need"
help["show-package-information"] = "show information about <pkgs>"
help["clear-cache"] = "clear cache files"
help["remove-orphans"] = "remove orphans, i.e. packages installed only to fulfill now unneeded dependencies"
help["update-package-database"] = "update package database"
help["update-file-database"] = "update file database"
help["upgrade-packages-limited"] = "upgrade installed packages"
help["upgrade-packages-full"] = "fully upgrade installed packages (e.g. also remove packages to handle conflicts)"
#
# Combine operations.
#
# Only populate if package manager supports all entries directly in a single
# operation. Do not populate by combining components with `&&`. pmm will
# automatically check subsets and call individual entries as appropriate.
#
# Take care to use `,` to separate operation names _within_ the quoted strings,
# rather than separating quoted strings themselves. The latter concept is used
# to pair package managers with operations and must remain distinct.
#
help["clear-cache,remove-orphans"] = "clear cache files and uninstall orphan packages"
help["mark-packages-implicit,remove-orphans"] = "mark <pkgs> as installed only to satisfy dependency then remove orphans"
help["remove-packages-limited,remove-orphans"] = "uninstall <pkgs> then uninstall orphans"
help["remove-packages-full,remove-orphans"] = "fully uninstall <pkgs> then uninstall orphans"
help["update-package-database,update-file-database"] = "update all databases"
help["update-package-database,upgrade-packages-partial"] = "update package database then upgrade installed packages"
help["update-package-database,upgrade-packages-full"] = "update package database then fully upgrade installed packages"
help["update-package-database,update-file-database,upgrade-packages-partial"] = "update all databases then upgrade installed packages"
help["update-package-database,update-file-database,upgrade-packages-full"] = "update all databases then fully upgrade installed packages"
help["update-package-database,install-packages"] = "update package database then install packages"
help["update-package-database,update-file-database,install-packages"] = "update all databases then install packages"
help["upgrade-packages-limited,install-packages"] = "upgrade installed packages then install <pkgs>"
help["upgrade-packages-limited,remove-orphans"] = "upgrade installed packages then uninstall orphans"
help["upgrade-packages-full,install-packages"] = "fully upgrade installed packages then install <pkgs>"
help["upgrade-packages-full,remove-orphans"] = "fully upgrade installed packages then uninstall orphans"
help["update-package-database,upgrade-packages-partial,install-packages"] = "update package database, upgrade packages, install <pkgs>"
help["update-package-database,upgrade-packages-full,install-packages"] = "update package database, fully upgrade packages, install <pkgs>"
help["update-package-database,update-file-database,upgrade-packages-partial,install-packages"] = "update all databases, upgrade packages, install <pkgs>"
help["update-package-database,update-file-database,upgrade-packages-full,install-packages"] = "update all databases, fully upgrade packages, install <pkgs>"
#
# Operations which have a standardized output format.
#
# Output is standardized for these commands because:
# - The *expected* output content is similar enough across package managers;
# usually just lists of package names or file names.
# - The underlying concept being expressed may be cleanly filtered through
# Bedrock specific concepts such as strata or `/bedrock/strata/.../` paths.
# - The operation may be used internally within pmm, and thus the underlying
# command output may be consumed by pmm, and thus it must be standardized.
#
# implementation: print full local path, one file per line
# pmm: print full /bedrock/strata/... path, one file per line
help["list-installed-package-files"] = "list files owned by installed <pkgs>"
# implementation: print <package>, one per line.
# pmm: print "<stratum>:<pm><tab><package>"
help["list-installed-explicit"] = "list packages installed explicitly, not (only) to satisfy dependency needs"
help["list-installed-implicit"] = "list packages installed only to satisfy dependency needs"
help["list-installed-packages"] = "list all installed packages"
help["list-available-packages"] = "list all available packages"
help["search-for-package-by-name"] = "search for packages with names matching <text>"
help["search-for-package-by-all"] = "search for packages matching <text> in name, description, etc"
help["which-package-owns-file"] = "query which installed packages own <file>"
# implementation: print <package><tab><file-path>
# pmm: print "<stratum>:<pm><tab><package><tab><file-path>"
help["which-packages-provide-file"] = "query which available packages provide <file>"
#
# Internal pmm operations.
#
# These operations are used internally within pmm and are not exposed directly
# via the user interface. They must have a standardized output to be consumed
# by pmm. If support for a package manager which directly exposes these
# concepts is added, graduate the operation from this category to "Operations
# which have a standardized output format."
#
# Package manager configuration should describe their implementations[] to
# coordinate with pmm, but since these are not user-facing they should not
# populate non-empty-string user_interfaces[] values.
#
# return 0 if package is installed, non-zero otherwise. Do not print
# stdout/stderr.
help["is-package-installed"] = "query if <pkg> is installed"
# return 0 if package is available, non-zero otherwise. Do not print
# stdout/stderr.
help["is-package-available"] = "query if <pkg> is available"
# return 0 if package file database operations are available, non-zero
# otherwise. Do not print stdout/stderr.
help["is-file-db-available"] = "check if file database operations are available"
# If it is possible to make file-db available such as by installing a package,
# print instructions to do so to stdout.
help["print-file-db-install-instructions"] = "instruct user how to make file-db available"
# print available package version. Should only be called if package is
# available. Strip distro/package-manager specific version information from
# version such as preceding `2:` or trailing `-5ubuntu2`. Only `[0-9.]`
# characters are expected.
help["print-package-version"] = "print <pkg> version"
# Print a list of `<package-name><tab><package-version>` pairs, one per line.
# Strip distro/package-manager specific version information from version such
# as preceding `2:` or trailing `-5ubuntu2`. Only `[0-9.]` characters are
# expected.
help["cache-package-db"] = "print information needed to cache package database"
#
# pmm specific, operation independent flags
#
# Typical package manager configurations should not describe the
# user_interfaces[] for these, as they do not correspond to typical package
# managers. Since they are flags - not operations - there is no
# implementations[] to define.
#
help["strat"] = "restrict to <stratum>"
help["package-manager"] = "restrict to <pm>"
help["every"] = "operate on every available instance of items (e.g. uninstall all copies)"
help["newest"] = "select newest corresponding versions of items"
help["oldest"] = "select oldest corresponding versions of items"
help["approx-version"] = "only consider items with a version prefixed by <version>"
help["exact-version"] = "only consider items that are exactly <version>"
help["newer-or-equal"] = "only consider items that are newer than or equal to <version>"
help["newer-than"] = "only consider items that are newer than <version>"
help["older-or-equal"] = "only consider items that are older than or equal to <version>"
help["older-than"] = "only consider items that are older than <version>"
#
# pmm specific operations.
#
# Typical package manager configurations should not describe either the
# user_interfaces[] or implementations[] for these.
#
help["diff-world"] = "print differences between /bedrock/etc/world and system's explicitly installed packages"
help["update-world-installed"] = "populate /bedrock/etc/world with missing explicitly installed packages"
help["update-world-removed"] = "remove /bedrock/etc/world items that do not correspond to explicitly installed packages"
help["update-world"] = "sync /bedrock/etc/world to system's explicitly installed package list"
help["apply-world-installed"] = "explicitly install /bedrock/etc/world items"
help["apply-world-removed"] = "remove packages not in /bedrock/etc/world and resulting orphan packages"
help["apply-world"] = "sync system's explicitly installed package list to /bedrock/etc/world and remove orphans"
help["check-pmm-configuration"] = "sanity check pmm configuration"
help["list-pmm-ui-files"] = "list expected front-end files with current user interface"
#
# Errors
#
help["no-match-error"] = "unable to match a requested item"

View File

@ -0,0 +1,144 @@
#!/bedrock/libexec/busybox awk -f
#
# Package Manager Manager apk support script
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# version 2 as published by the Free Software Foundation.
#
# Copyright (c) 2013-2020 Daniel Thau <danthau@bedrocklinux.org>
#
# Map pmm internal names for operations to a comma-separated list describing
# how they should be handled. The fields of the tuple should be, in order:
#
# - Applicability-type: This indicates which package manager(s) the given
# operation should apply to. It may be overridden by pmm flags such as
# --every and --newest. Valid values are:
# - "first": Use first package manager which passes applicability-check.
# - "every": Use every package manager which which passes
# applicability-check
# - "none": No package managers are applicable; used for pmm specific
# operations which do not correlate to individual package managers.
#
# - Applicability-check: A check to see if a given package manager is
# applicable for the given operation. May be extended by pmm flags such as
# --exact-version. Valid values are:
# - "is-package-installed": Only consider package managers which have
# package installed.
# - "is-package-available": Only consider package managers which have
# package available.
# - "is-file-db-available": Only consider package managers which have file
# db capabilities.
# - "brl-which": Only consider package managers from stratum which owns
# file.
# - "-": No applicability check, allow all.
#
# - Argument-count: This indicates the expected number of arguments an
# operation may take. Valid values are:
# - "zero": No arguments expected.
# - "one": One argument expected.
# - "many": One or more arguments are expected.
#
# - Pre-process: Action pmm must take before processing. Valid values include:
# - "localize": Strip "/bedrock/strata/[^/]*" from input.
# - "-": No pre-processing.
#
# - Post-process: some action to take after process. Valid values are:
# - "prepend-full-path": prepend "/bedrock/strata/<stratum>" to stdout.
# - "prepend-pair": prepend "<stratum>:<package-manager>" to stdout.
# - "update-package-cache": If the package cache is enabled and running as
# root, updated the package cache.
# - "-": No post-processing.
#
#
# Operations which directly forward the underlying command output.
#
operations["install-packages"] = "first, is-package-available, many, -, -"
operations["reinstall-packages"] = "first, is-package-installed, many, -, -"
operations["remove-packages-limited"] = "first, is-package-installed, many, -, -"
operations["remove-packages-full"] = "first, is-package-installed, many, -, -"
operations["verify-packages"] = "first, is-package-installed, many, -, -"
operations["verify-all-packages"] = "every, -, zero, -, -"
operations["mark-packages-explicit"] = "first, is-package-installed, many, -, -"
operations["mark-packages-implicit"] = "first, is-package-installed, many, -, -"
operations["show-package-information"] = "first, is-package-available, many, -, -"
operations["clear-cache"] = "every, -, zero, -, -"
operations["remove-orphans"] = "every, -, zero, -, -"
operations["update-package-database"] = "every, -, zero, -, update-package-cache"
operations["update-file-database"] = "every, is-file-db-available, zero, -, -"
operations["upgrade-packages-limited"] = "every, -, zero, -, -"
operations["upgrade-packages-full"] = "every, -, zero, -, -"
#
# Combine operations.
#
# Applicability fields are ignored here, as they're determined from the
# individual component availability. They're filled out to make sanity check
# code happy.
#
operations["clear-cache,remove-orphans"] = "every, -, zero, -, -"
operations["mark-packages-implicit,remove-orphans"] = "first, is-package-installed, many, -, -"
operations["remove-packages-limited,remove-orphans"] = "first, is-package-installed, many, -, -"
operations["remove-packages-full,remove-orphans"] = "first, is-package-installed, many, -, -"
operations["update-package-database,update-file-database"] = "every, -, zero, -, update-package-cache"
operations["update-package-database,upgrade-packages-partial"] = "every, -, zero, -, update-package-cache"
operations["update-package-database,upgrade-packages-full"] = "every, -, zero, -, update-package-cache"
operations["update-package-database,update-file-database,upgrade-packages-partial"] = "every, -, zero, -, update-package-cache"
operations["update-package-database,update-file-database,upgrade-packages-full"] = "every, -, zero, -, update-package-cache"
operations["update-package-database,install-packages"] = "first, is-package-installed, many, -, update-package-cache"
operations["update-package-database,update-file-database,install-packages"] = "first, is-package-installed, many, -, update-package-cache"
operations["upgrade-packages-limited,install-packages"] = "first, is-package-installed, many, -, -"
operations["upgrade-packages-limited,remove-orphans"] = "every, -, zero, -, -"
operations["upgrade-packages-full,install-packages"] = "first, is-package-installed, many, -, -"
operations["upgrade-packages-full,remove-orphans"] = "every, -, zero, -, -"
operations["update-package-database,upgrade-packages-partial,install-packages"] = "first, is-package-installed, many, -, update-package-cache"
operations["update-package-database,upgrade-packages-full,install-packages"] = "first, is-package-installed, many, -, update-package-cache"
operations["update-package-database,update-file-database,upgrade-packages-partial,install-packages"] = "first, is-package-installed, many, -, update-package-cache"
operations["update-package-database,update-file-database,upgrade-packages-full,install-packages"] = "first, is-package-installed, many, -, update-package-cache"
#
# Operations which have a standardized output format.
#
operations["list-installed-package-files"] = "every, is-package-installed, one, -, prepend-full-path"
operations["list-installed-explicit"] = "every, -, zero, -, prepend-pair"
operations["list-installed-implicit"] = "every, -, zero, -, prepend-pair"
operations["list-installed-packages"] = "every, -, zero, -, prepend-pair"
operations["list-available-packages"] = "every, -, zero, -, prepend-pair"
operations["search-for-package-by-name"] = "every, -, one, -, prepend-pair"
operations["search-for-package-by-all"] = "every, -, one, -, prepend-pair"
operations["which-package-owns-file"] = "every, brl-which, one, localize, prepend-pair"
operations["which-packages-provide-file"] = "every, is-file-db-available, one, -, prepend-pair"
#
# Internal pmm operations.
#
# All fields are ignored here, as these operations are only used internally.
# They're filled out to make sanity check code happy.
#
operations["is-package-installed"] = "every, -, one, -, -"
operations["is-package-available"] = "every, -, one, -, -"
operations["is-file-db-available"] = "every, -, one, -, -"
operations["print-file-db-install-instructions"] = "every, -, one, -, -"
operations["print-package-version"] = "every, -, one, -, -"
operations["cache-package-db"] = "every, -, one, -, -"
#
# pmm specific operations.
#
operations["diff-world"] = "none, -, zero, -, -"
operations["update-world-installed"] = "none, -, zero, -, -"
operations["update-world-removed"] = "none, -, zero, -, -"
operations["update-world"] = "none, -, zero, -, -"
operations["apply-world-installed"] = "none, -, zero, -, -"
operations["apply-world-removed"] = "none, -, zero, -, -"
operations["apply-world"] = "none, -, zero, -, -"
operations["check-pmm-configuration"] = "none, -, zero, -, -"
operations["list-pmm-ui-files"] = "none, -, zero, -, -"
#
# Errors
#
operations["no-match-error"] = "none, -, zero, -, -"

View File

@ -0,0 +1,153 @@
#!/bedrock/libexec/busybox awk -f
#
# Package Manager Manager apk support script
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# version 2 as published by the Free Software Foundation.
#
# Copyright (c) 2018-2020 Daniel Thau <danthau@bedrocklinux.org>
system_package_managers["apk"]
package_manager_canary_executables["apk"] = "apk"
#
# General, operation independent flags.
#
# Unlike operations, flags should not have implementations[].
#
user_interfaces["apk", "assume-no"] = ""
user_interfaces["apk", "assume-yes"] = ""
user_interfaces["apk", "confirm"] = "-i/--interactive"
user_interfaces["apk", "quiet"] = "-q/--quiet"
user_interfaces["apk", "verbose"] = "-v/--verbose"
#
# Operations which directly forward the underlying command output.
#
user_interfaces["apk", "install-packages"] = "pmm add <pkgs>"
user_interfaces["apk", "reinstall-packages"] = "pmm fix -r/--reinstall <pkgs>"
user_interfaces["apk", "remove-packages-limited"] = "" # uses combine remove-packages,remove-orphans
user_interfaces["apk", "remove-packages-full"] = "" # uses combine remove-packages,remove-orphans
user_interfaces["apk", "verify-packages"] = "" # could not find operation in package manager documentation
user_interfaces["apk", "verify-all-packages"] = "pmm audit"
user_interfaces["apk", "mark-packages-explicit"] = "" # implicit with apk add
user_interfaces["apk", "mark-packages-implicit"] = "" # implicit with apk del
user_interfaces["apk", "show-package-information"] = "pmm info <pkgs>"
user_interfaces["apk", "clear-cache"] = "" # could not find operation in package manager documentation
user_interfaces["apk", "remove-orphans"] = "" # implicit with apk del
user_interfaces["apk", "update-package-database"] = "" # no separate file database concept, using combine
user_interfaces["apk", "update-file-database"] = "" # file search command does online query, no local database
user_interfaces["apk", "upgrade-packages-limited"] = "" # no limited upgrade concept
user_interfaces["apk", "upgrade-packages-full"] = "pmm upgrade"
implementations["apk", "install-packages"] = "strat -r ${stratum} apk ${flags} add ${items}"
implementations["apk", "reinstall-packages"] = "strat -r ${stratum} apk ${flags} fix -r ${items}"
implementations["apk", "remove-packages-limited"] = "strat -r ${stratum} apk ${flags} del ${items}"
implementations["apk", "remove-packages-full"] = "strat -r ${stratum} apk ${flags} del --purge ${items}"
implementations["apk", "verify-packages"] = "" # could not find operation in package manager documentation
implementations["apk", "verify-all-packages"] = "strat -r ${stratum} apk ${flags} audit --system --check-permissions"
implementations["apk", "mark-packages-explicit"] = "strat -r ${stratum} apk ${flags} add ${items}"
implementations["apk", "mark-packages-implicit"] = "strat -r ${stratum} apk ${flags} del ${items}"
implementations["apk", "show-package-information"] = "strat -r ${stratum} apk ${flags} info ${items}"
implementations["apk", "clear-cache"] = "" # could not find operation in package manager documentation
implementations["apk", "remove-orphans"] = "" # implicit with apk del
implementations["apk", "update-package-database"] = "strat -r ${stratum} apk ${flags} update"
implementations["apk", "update-file-database"] = "" # no file database concept
implementations["apk", "upgrade-packages-limited"] = "strat -r ${stratum} apk ${flags} upgrade"
implementations["apk", "upgrade-packages-full"] = "strat -r ${stratum} apk ${flags} upgrade"
#
# Combine operations.
#
user_interfaces["apk", "clear-cache,remove-orphans"] = ""
user_interfaces["apk", "mark-packages-implicit,remove-orphans"] = "pmm del <pkgs>"
user_interfaces["apk", "remove-packages-limited,remove-orphans"] = ""
user_interfaces["apk", "remove-packages-full,remove-orphans"] = "pmm del --purge <pkgs>"
user_interfaces["apk", "update-package-database,update-file-database"] = "pmm update"
user_interfaces["apk", "update-package-database,upgrade-packages-partial"] = ""
user_interfaces["apk", "update-package-database,upgrade-packages-full"] = ""
user_interfaces["apk", "update-package-database,update-file-database,upgrade-packages-partial"] = ""
user_interfaces["apk", "update-package-database,update-file-database,upgrade-packages-full"] = ""
user_interfaces["apk", "update-package-database,install-packages"] = ""
user_interfaces["apk", "update-package-database,update-file-database,install-packages"] = ""
user_interfaces["apk", "upgrade-packages-limited,install-packages"] = ""
user_interfaces["apk", "upgrade-packages-limited,remove-orphans"] = ""
user_interfaces["apk", "upgrade-packages-full,install-packages"] = ""
user_interfaces["apk", "upgrade-packages-full,remove-orphans"] = ""
user_interfaces["apk", "update-package-database,upgrade-packages-partial,install-packages"] = ""
user_interfaces["apk", "update-package-database,upgrade-packages-full,install-packages"] = ""
user_interfaces["apk", "update-package-database,update-file-database,upgrade-packages-partial,install-packages"] = ""
user_interfaces["apk", "update-package-database,update-file-database,upgrade-packages-full,install-packages"] = ""
implementations["apk", "clear-cache,remove-orphans"] = ""
implementations["apk", "mark-packages-implicit,remove-orphans"] = "strat -r ${stratum} apk ${flags} del ${items}"
implementations["apk", "remove-packages-limited,remove-orphans"] = "strat -r ${stratum} apk ${flags} del ${items}"
implementations["apk", "remove-packages-full,remove-orphans"] = "strat -r ${stratum} apk ${flags} del --purge ${items}"
implementations["apk", "update-package-database,update-file-database"] = "strat -r ${stratum} apk ${flags} update"
implementations["apk", "update-package-database,upgrade-packages-partial"] = ""
implementations["apk", "update-package-database,upgrade-packages-full"] = ""
implementations["apk", "update-package-database,update-file-database,upgrade-packages-partial"] = ""
implementations["apk", "update-package-database,update-file-database,upgrade-packages-full"] = ""
implementations["apk", "update-package-database,install-packages"] = ""
implementations["apk", "update-package-database,update-file-database,install-packages"] = ""
implementations["apk", "upgrade-packages-limited,install-packages"] = ""
implementations["apk", "upgrade-packages-limited,remove-orphans"] = ""
implementations["apk", "upgrade-packages-full,install-packages"] = ""
implementations["apk", "upgrade-packages-full,remove-orphans"] = ""
implementations["apk", "update-package-database,upgrade-packages-partial,install-packages"] = ""
implementations["apk", "update-package-database,upgrade-packages-full,install-packages"] = ""
implementations["apk", "update-package-database,update-file-database,upgrade-packages-partial,install-packages"] = ""
implementations["apk", "update-package-database,update-file-database,upgrade-packages-full,install-packages"] = ""
#
# Operations which have a standardized output format.
#
user_interfaces["apk", "list-installed-package-files"] = "pmm info -L/--contents <pkgs>"
user_interfaces["apk", "list-installed-explicit"] = "" # not explicitly raised via user interface
user_interfaces["apk", "list-installed-implicit"] = "" # not explicitly raised via user interface
user_interfaces["apk", "list-installed-packages"] = "pmm list -I/--installed"
user_interfaces["apk", "list-available-packages"] = "pmm list"
user_interfaces["apk", "search-for-package-by-name"] = ""
user_interfaces["apk", "search-for-package-by-all"] = "pmm search <text>"
user_interfaces["apk", "which-package-owns-file"] = "pmm info -W/--who-owns <file>"
user_interfaces["apk", "which-packages-provide-file"] = "pmm-file <file>"
implementations["apk", "list-installed-package-files"] = "strat -r ${stratum} apk info -L ${items} | grep -v ' contains:$'"
implementations["apk", "list-installed-explicit"] = "cat /bedrock/strata/${stratum}/etc/apk/world"
implementations["apk", "list-installed-implicit"] = "strat -r ${stratum} apk info |\
awk 'BEGIN {\
world=\"/bedrock/strata/\"ENVIRON[\"stratum\"]\"/etc/apk/world\";\
while ((getline < world) > 0) {\
x[$0]\
}\
}\
(!($0 in x)) {\
print\
}'"
implementations["apk", "list-installed-packages"] = "strat -r ${stratum} apk info"
implementations["apk", "list-available-packages"] = "strat -r ${stratum} apk list | awk '{sub(/-[^-]*-[^-]*$/, \"\", $1); print $1}'"
implementations["apk", "search-for-package-by-name"] = "strat -r ${stratum} apk search | sed 's/-[^-]*-[^-]*$//' | grep ${items}"
implementations["apk", "search-for-package-by-all"] = "strat -r ${stratum} apk search ${items} | sed 's/-[^-]*-[^-]*$//'"
implementations["apk", "which-package-owns-file"] = "strat -r ${stratum} apk info -W ${items} 2>/dev/null | awk '{sub(/-[^-]*-[^-]*$/, \"\"); print $NF}'"
implementations["apk", "which-packages-provide-file"] = "strat -r ${stratum} apk-file ${items} |\
# dedup repeats\
awk '\
/^[\\/]/ {\
x[$1] = $2\
}\
END{\
for (f in x) {\
print x[f]\"\t\"f\
}\
}'"
#
# Internal pmm operations.
#
implementations["apk", "is-package-installed"] = "strat -r ${stratum} apk info -e ${items} >/dev/null 2>&1"
implementations["apk", "is-package-available"] = "strat -r ${stratum} apk info ${items} >/dev/null 2>&1"
implementations["apk", "is-file-db-available"] = "strat -r ${stratum} apk info -e apk-file >/dev/null 2>&1"
implementations["apk", "print-file-db-install-instructions"] = "echo \"Install apk-file from apk community repo in ${stratum}:apk to perform file-db operations\""
implementations["apk", "print-package-version"] = "strat -r ${stratum} apk info ${items} | awk -F'[ -]' '{print$(NF-2);exit}'"
implementations["apk", "cache-package-db"] = "strat -r ${stratum} apk list | sed 's/-\\([^-]*\\)-[^-]* .*$/\t\\1/'"

View File

@ -0,0 +1,145 @@
#!/bedrock/libexec/busybox awk -f
#
# Package Manager Manager apt support script
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# version 2 as published by the Free Software Foundation.
#
# Copyright (c) 2013-2020 Daniel Thau <danthau@bedrocklinux.org>
system_package_managers["apt"]
package_manager_canary_executables["apt"] = "apt"
#
# General, operation independent flags.
#
# Unlike operations, flags should not have implementations[].
#
user_interfaces["apt", "assume-no"] = "--assume-no"
user_interfaces["apt", "assume-yes"] = "-y/--yes/--assume-yes"
user_interfaces["apt", "confirm"] = ""
user_interfaces["apt", "quiet"] = "-q/--quiet"
user_interfaces["apt", "verbose"] = ""
#
# Operations which directly forward the underlying command output.
#
user_interfaces["apt", "install-packages"] = "pmm install <pkgs>"
user_interfaces["apt", "reinstall-packages"] = "pmm reinstall <pkgs>"
user_interfaces["apt", "remove-packages-limited"] = "pmm remove <pkgs>"
user_interfaces["apt", "remove-packages-full"] = "pmm purge <pkgs>"
user_interfaces["apt", "verify-packages"] = "pmm-dpkg -V <pkgs>"
user_interfaces["apt", "verify-all-packages"] = "pmm-dpkg -V"
user_interfaces["apt", "mark-packages-explicit"] = "pmm-mark manual <pkgs>"
user_interfaces["apt", "mark-packages-implicit"] = "pmm-mark auto <pkgs>"
user_interfaces["apt", "show-package-information"] = "pmm show <pkgs>"
user_interfaces["apt", "clear-cache"] = "pmm clear/autoclean/auto-clean"
user_interfaces["apt", "remove-orphans"] = "pmm autoremove"
user_interfaces["apt", "update-package-database"] = "pmm update"
user_interfaces["apt", "update-file-database"] = "pmm-file update"
user_interfaces["apt", "upgrade-packages-limited"] = "pmm upgrade"
user_interfaces["apt", "upgrade-packages-full"] = "pmm dist-upgrade/full-upgrade"
implementations["apt", "install-packages"] = "strat -r ${stratum} apt ${flags} install ${items}"
implementations["apt", "reinstall-packages"] = "strat -r ${stratum} apt ${flags} reinstall ${items}"
implementations["apt", "remove-packages-limited"] = "strat -r ${stratum} apt ${flags} remove ${items}"
implementations["apt", "remove-packages-full"] = "strat -r ${stratum} apt ${flags} purge ${items}"
implementations["apt", "verify-packages"] = "strat -r ${stratum} dpkg -V ${items}"
implementations["apt", "verify-all-packages"] = "strat -r ${stratum} dpkg -V"
implementations["apt", "mark-packages-explicit"] = "strat -r ${stratum} apt-mark manual ${items}"
implementations["apt", "mark-packages-implicit"] = "strat -r ${stratum} apt-mark auto ${items}"
implementations["apt", "show-package-information"] = "strat -r ${stratum} apt ${flags} show ${items}"
implementations["apt", "clear-cache"] = "strat -r ${stratum} apt ${flags} clean"
implementations["apt", "remove-orphans"] = "strat -r ${stratum} apt ${flags} autoremove"
implementations["apt", "update-package-database"] = "strat -r ${stratum} apt ${flags} update"
implementations["apt", "update-file-database"] = "strat -r ${stratum} apt-file update"
implementations["apt", "upgrade-packages-limited"] = "strat -r ${stratum} apt ${flags} upgrade"
implementations["apt", "upgrade-packages-full"] = "strat -r ${stratum} apt ${flags} full-upgrade"
#
# Combine operations.
#
user_interfaces["apt", "clear-cache,remove-orphans"] = ""
user_interfaces["apt", "mark-packages-implicit,remove-orphans"] = ""
user_interfaces["apt", "remove-packages-limited,remove-orphans"] = "pmm remove --auto-remove/--autoremove <pkgs>"
user_interfaces["apt", "remove-packages-full,remove-orphans"] = "pmm purge --auto-remove/--autoremove <pkgs>"
user_interfaces["apt", "update-package-database,update-file-database"] = ""
user_interfaces["apt", "update-package-database,upgrade-packages-partial"] = ""
user_interfaces["apt", "update-package-database,upgrade-packages-full"] = ""
user_interfaces["apt", "update-package-database,update-file-database,upgrade-packages-partial"] = ""
user_interfaces["apt", "update-package-database,update-file-database,upgrade-packages-full"] = ""
user_interfaces["apt", "update-package-database,install-packages"] = ""
user_interfaces["apt", "update-package-database,update-file-database,install-packages"] = ""
user_interfaces["apt", "upgrade-packages-limited,install-packages"] = ""
user_interfaces["apt", "upgrade-packages-limited,remove-orphans"] = "pmm upgrade --auto-remove/--autoremove"
user_interfaces["apt", "upgrade-packages-full,install-packages"] = ""
user_interfaces["apt", "upgrade-packages-full,remove-orphans"] = "pmm full-upgrade --auto-remove/--autoremove"
user_interfaces["apt", "update-package-database,upgrade-packages-partial,install-packages"] = ""
user_interfaces["apt", "update-package-database,upgrade-packages-full,install-packages"] = ""
user_interfaces["apt", "update-package-database,update-file-database,upgrade-packages-partial,install-packages"] = ""
user_interfaces["apt", "update-package-database,update-file-database,upgrade-packages-full,install-packages"] = ""
implementations["apt", "clear-cache,remove-orphans"] = ""
implementations["apt", "mark-packages-implicit,remove-orphans"] = ""
implementations["apt", "remove-packages-limited,remove-orphans"] = "strat -r ${stratum} apt ${flags} remove --autoremove ${items}"
implementations["apt", "remove-packages-full,remove-orphans"] = "strat -r ${stratum} apt ${flags} purge --autoremove ${items}"
implementations["apt", "update-package-database,update-file-database"] = ""
implementations["apt", "update-package-database,upgrade-packages-partial"] = ""
implementations["apt", "update-package-database,upgrade-packages-full"] = ""
implementations["apt", "update-package-database,update-file-database,upgrade-packages-partial"] = ""
implementations["apt", "update-package-database,update-file-database,upgrade-packages-full"] = ""
implementations["apt", "update-package-database,install-packages"] = ""
implementations["apt", "update-package-database,update-file-database,install-packages"] = ""
implementations["apt", "upgrade-packages-limited,install-packages"] = ""
implementations["apt", "upgrade-packages-limited,remove-orphans"] = "strat -r ${stratum} apt ${flags} upgrade --autoremove"
implementations["apt", "upgrade-packages-full,install-packages"] = ""
implementations["apt", "upgrade-packages-full,remove-orphans"] = "strat -r ${stratum} apt ${flags} full-upgrade --autoremove"
implementations["apt", "update-package-database,upgrade-packages-partial,install-packages"] = ""
implementations["apt", "update-package-database,upgrade-packages-full,install-packages"] = ""
implementations["apt", "update-package-database,update-file-database,upgrade-packages-partial,install-packages"] = ""
implementations["apt", "update-package-database,update-file-database,upgrade-packages-full,install-packages"] = ""
#
# Operations which have a standardized output format.
#
user_interfaces["apt", "list-installed-package-files"] = "pmm-dpkg -L/--listfiles <pkgs>"
user_interfaces["apt", "list-installed-explicit"] = "pmm-mark showmanual"
user_interfaces["apt", "list-installed-implicit"] = "pmm-mark showauto"
user_interfaces["apt", "list-installed-packages"] = "pmm list --installed"
user_interfaces["apt", "list-available-packages"] = "pmm list"
user_interfaces["apt", "search-for-package-by-name"] = "pmm search -n/--names-only <text>"
user_interfaces["apt", "search-for-package-by-all"] = "pmm search <text>"
user_interfaces["apt", "which-package-owns-file"] = "pmm-dpkg -S/--search <file>"
user_interfaces["apt", "which-packages-provide-file"] = "pmm-file search <file>"
implementations["apt", "list-installed-package-files"] = "strat -r ${stratum} dpkg -L ${items}"
implementations["apt", "list-installed-explicit"] = "strat -r ${stratum} apt-mark showmanual"
implementations["apt", "list-installed-implicit"] = "strat -r ${stratum} apt-mark showauto"
implementations["apt", "list-installed-packages"] = "strat -r ${stratum} dpkg -l | awk '$1 == \"ii\" {sub(/:[0-9]+$/,\"\",$2); print $2}'"
implementations["apt", "list-available-packages"] = "strat -r ${stratum} apt-cache pkgnames"
implementations["apt", "search-for-package-by-name"] = "strat -r ${stratum} apt-cache search -n ${items} | cut -d' ' -f1"
implementations["apt", "search-for-package-by-all"] = "strat -r ${stratum} apt-cache search ${items} | cut -d' ' -f1"
implementations["apt", "which-package-owns-file"] = "strat -r ${stratum} dpkg -S ${items} | cut -d: -f1 | sed 's/, /\\n/g'"
implementations["apt", "which-packages-provide-file"] = "strat -r ${stratum} apt-file search ${items} | sed 's/: /\t/'"
#
# Internal pmm operations.
#
implementations["apt", "is-package-installed"] = "strat -r ${stratum} dpkg -l ${items} 2>/dev/null | grep -q '^ii'"
implementations["apt", "is-package-available"] = "strat -r ${stratum} apt-cache show ${items} 2>/dev/null | grep -q '^Package:'"
implementations["apt", "is-file-db-available"] = "strat -r ${stratum} dpkg -l apt-file 2>/dev/null | grep -q '^ii'"
implementations["apt", "print-file-db-install-instructions"] = "echo \"Install apt-file in ${stratum}:apt to perform file-db operations\""
implementations["apt", "print-package-version"] = "strat -r ${stratum} apt-cache show ${items} |\
awk '$1 == \"Version:\" {sub(/^[0-9]*:/, \"\"); sub(/[~+-].*$/, \"\"); print $2}'"
implementations["apt", "cache-package-db"] = "strat -r ${stratum} apt-cache show '*' |\
awk '\
$1 == \"Package:\" {\
name = $2\
}\
$1 == \"Version:\" {\
sub(/^[0-9]*:/, \"\");\
sub(/[~+-].*$/, \"\");\
print name\"\t\"$2\
}\
'"

Some files were not shown because too many files have changed in this diff Show More