From f687558b6618733d2ad25663fae9e64df7ed6ea4 Mon Sep 17 00:00:00 2001 From: Liam Waldron Date: Thu, 29 Oct 2026 09:33:38 -0400 Subject: [PATCH] Initial import: build and boot Everest Linux in QEMU everest.sh builds Everest's signed packages in an Alpine container, publishes the base, extra and extra-src repositories, installs the system with glacier-bootstrap into an initramfs and boots it in QEMU. The image carries glacier, a toolchain and the repositories, and builds packages from source inside the VM. Co-Authored-By: Claude Opus 5.5 --- .gitignore | 12 + Dockerfile.build | 14 + LICENSE | 674 ++++++++++++++++++ README.md | 136 ++++ everest.sh | 130 ++++ pkgsrc/everest-bootscripts/etc/doas.conf | 8 + pkgsrc/everest-bootscripts/etc/group | 4 + pkgsrc/everest-bootscripts/etc/hostname | 1 + pkgsrc/everest-bootscripts/etc/init.d/rcK | 4 + pkgsrc/everest-bootscripts/etc/init.d/rcS | 22 + pkgsrc/everest-bootscripts/etc/inittab | 13 + pkgsrc/everest-bootscripts/etc/passwd | 2 + pkgsrc/everest-bootscripts/etc/profile | 14 + pkgsrc/everest-bootscripts/etc/shadow | 2 + pkgsrc/everest-bootscripts/etc/shells | 1 + .../etc/glacier/keys/everest-2026.pub | 2 + pkgsrc/everest-repos/etc/glacier/repos.conf | 10 + pkgsrc/glacier-ng/etc/glacier/glacier.conf | 33 + recipes/README | 16 + recipes/extra-src/bash/recipe | 12 + recipes/extra-src/binutils/build | 23 + recipes/extra-src/binutils/recipe | 12 + recipes/extra-src/gcc/build | 38 + recipes/extra-src/gcc/recipe | 23 + recipes/extra-src/less/recipe | 13 + recipes/extra-src/linux-headers/build | 9 + recipes/extra-src/linux-headers/recipe | 11 + recipes/extra-src/lua/build | 14 + recipes/extra-src/lua/recipe | 11 + recipes/extra-src/make/build | 11 + recipes/extra-src/make/recipe | 12 + recipes/extra-src/ncurses/build | 18 + recipes/extra-src/ncurses/recipe | 19 + recipes/extra-src/vim/recipe | 19 + recipes/extra-src/zstd/build | 4 + recipes/extra-src/zstd/recipe | 13 + scripts/container.sh | 496 +++++++++++++ scripts/live-init.sh | 24 + scripts/toolchain-test.sh | 40 ++ scripts/vm-drive.py | 63 ++ scripts/vm-testnet.sh | 30 + scripts/vmtests/builds.txt | 16 + templates/minimal.template | 29 + 43 files changed, 2058 insertions(+) create mode 100644 .gitignore create mode 100644 Dockerfile.build create mode 100644 LICENSE create mode 100644 README.md create mode 100755 everest.sh create mode 100644 pkgsrc/everest-bootscripts/etc/doas.conf create mode 100644 pkgsrc/everest-bootscripts/etc/group create mode 100644 pkgsrc/everest-bootscripts/etc/hostname create mode 100755 pkgsrc/everest-bootscripts/etc/init.d/rcK create mode 100755 pkgsrc/everest-bootscripts/etc/init.d/rcS create mode 100644 pkgsrc/everest-bootscripts/etc/inittab create mode 100644 pkgsrc/everest-bootscripts/etc/passwd create mode 100644 pkgsrc/everest-bootscripts/etc/profile create mode 100644 pkgsrc/everest-bootscripts/etc/shadow create mode 100644 pkgsrc/everest-bootscripts/etc/shells create mode 100644 pkgsrc/everest-repos/etc/glacier/keys/everest-2026.pub create mode 100644 pkgsrc/everest-repos/etc/glacier/repos.conf create mode 100644 pkgsrc/glacier-ng/etc/glacier/glacier.conf create mode 100644 recipes/README create mode 100644 recipes/extra-src/bash/recipe create mode 100644 recipes/extra-src/binutils/build create mode 100644 recipes/extra-src/binutils/recipe create mode 100644 recipes/extra-src/gcc/build create mode 100644 recipes/extra-src/gcc/recipe create mode 100644 recipes/extra-src/less/recipe create mode 100644 recipes/extra-src/linux-headers/build create mode 100644 recipes/extra-src/linux-headers/recipe create mode 100644 recipes/extra-src/lua/build create mode 100644 recipes/extra-src/lua/recipe create mode 100644 recipes/extra-src/make/build create mode 100644 recipes/extra-src/make/recipe create mode 100644 recipes/extra-src/ncurses/build create mode 100644 recipes/extra-src/ncurses/recipe create mode 100644 recipes/extra-src/vim/recipe create mode 100644 recipes/extra-src/zstd/build create mode 100644 recipes/extra-src/zstd/recipe create mode 100755 scripts/container.sh create mode 100644 scripts/live-init.sh create mode 100644 scripts/toolchain-test.sh create mode 100644 scripts/vm-drive.py create mode 100644 scripts/vm-testnet.sh create mode 100644 scripts/vmtests/builds.txt create mode 100644 templates/minimal.template diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7f01a19 --- /dev/null +++ b/.gitignore @@ -0,0 +1,12 @@ +# Build outputs and downloads (all rebuildable; see README) +/boot/ +/pkgs/ +/repo/ +/sources/ +/disk.img +# Throwaway test CA: holds private keys, never published +/testca/ +# Backups +*.old +*.old[0-9]* +*.pdf diff --git a/Dockerfile.build b/Dockerfile.build new file mode 100644 index 0000000..82457ea --- /dev/null +++ b/Dockerfile.build @@ -0,0 +1,14 @@ +# Build environment for Everest packages: Alpine, so the native compiler +# targets musl. Everything a package build or the initramfs step needs is +# installed once here (curl: tarball sources; openssl: the local test +# repository server, see container.sh); glacier-ng and libglacier-ng are +# mounted at run time (see everest.sh), never copied in, so builds +# always use the current checkouts. +FROM alpine:latest + +RUN apk add --no-cache \ + bash git coreutils findutils diffutils tar cpio xz curl openssl \ + build-base linux-headers \ + autoconf automake libtool cmake pkgconf \ + bc flex bison perl elfutils-dev openssl-dev \ + luajit luajit-dev libarchive-dev libconfig-dev diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..f288702 --- /dev/null +++ b/LICENSE @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. 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 +them 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 prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. 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. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey 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; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If 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 convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU 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 that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + 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. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +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. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + 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 +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + 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 3 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, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program 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, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU 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. But first, please read +. diff --git a/README.md b/README.md new file mode 100644 index 0000000..da15e8c --- /dev/null +++ b/README.md @@ -0,0 +1,136 @@ +# everest-qemu + +Builds a minimal, bootable Everest Linux system from glacier packages and +boots it in QEMU. The system is installed by glacier itself, carries +glacier, a toolchain and Everest's signed repositories, and can build +packages from source inside the VM. + +Needs Docker, QEMU (KVM), `openssl` and `socat`, plus sibling checkouts of +`glacier-ng` and `libglacier-ng` (or set `GLACIER_NG` / `LIBGLACIER_NG`). + +```sh +./everest.sh keygen # once: the signing key, in ~/.config/everest/keys +./everest.sh build all # every package -> pkgs/, signed +./everest.sh publish # signed repositories base, extra, extra-src -> repo/ +./everest.sh initramfs # -> boot/vmlinuz, boot/initramfs.gz +./everest.sh boot # QEMU on this terminal; Enter for a root shell, + # `poweroff -f` (or Ctrl-A X) to leave +``` + +`./everest.sh build PKG` rebuilds a single package (linux and gcc take a +while; most take under a minute). `./everest.sh adopt DIR` takes packages +built from recipes into `pkgs/`. `EVEREST_MEM` (MB, default 6144) and +`EVEREST_CPUS` (default 2) size the VM. + +`pkgs/`, `repo/`, `boot/`, `sources/` and `testca/` are build outputs and +are not tracked. + +## Booting a released image + +Only `vmlinuz` and `initramfs.gz` are needed: + +```sh +qemu-system-x86_64 -enable-kvm -m 6144 -smp 2 -nographic \ + -nic user,model=virtio-net-pci \ + -kernel vmlinuz -initrd initramfs.gz -append "console=ttyS0 rdinit=/init" +``` + +The image carries a copy of the repositories at `/srv/everest`, so +`syspkg -y` and binary installs (`syspkg -f gcc`) work offline. Building +from source downloads the sources, so bring the network up first: + +```sh +ip link set eth0 up +ip addr add 10.0.2.15/24 dev eth0 +ip route add default via 10.0.2.2 +echo "nameserver 10.0.2.3" >> /etc/resolv.conf +``` + +## Signing + +Every package's sidecar is signed (`NAME-VER.gpkg.sha256.sig`): glacier +installs a base package only with a signature by a key its +`/etc/glacier/repos.conf` trusts for base. The secret key, +`everest-2026.sec`, stays outside this tree, in `~/.config/everest/keys` +(or `$EVEREST_KEYS`), mounted read-only into the build container; `build` +refuses without it. The public key and `repos.conf` ship in +`everest-repos` (`pkgsrc/everest-repos/etc/glacier/`). + +## Repositories + +`repos.conf` lists `https://pkg.everestlinux.org/{base,extra,extra-src}`. +Until that server exists, `initramfs` rewrites the image's copy to +`file:///srv/everest/REPO`, and `boot` serves `repo/` locally: + +- over https, as `10.0.2.100:443` in the guest, with a throwaway test CA + (`testca/`, made by `initramfs`; never shipped); +- read-only over 9p (`mount_tag=everest-repo`), so `./everest.sh publish` + reaches a running VM without a new initramfs. + +In the VM, `sh /sys/firmware/qemu_fw_cfg/by_name/opt/everest/testnet/raw` +(`scripts/vm-testnet.sh`) brings up the network, mounts the 9p share over +`/srv/everest` and trusts the test CA. + +## Building from source in the VM + +```sh +syspkg -y +syspkg -f vim # asks which repository: pick extra-src +syspkg -f less zstd lua bash +``` + +Builds run in glacier's sandbox (user namespaces, overlayfs) as the +`_gbuild` user, over the layers `BUILD_ROOT` in `/etc/glacier/glacier.conf` +names (musl, busybox, linux-headers, binutils, gcc, make). `JOBS = N;` in +glacier.conf sets the parallelism. Per-package switches go in +`/etc/glacier/config/NAME.conf` (`TRAITS = [ "-huge" ];`), and `syspkg -u` +rebuilds what they change. + +`scripts/vm-drive.py LOG CMDS` boots the VM on a pty and runs a command +list non-interactively (`scripts/vmtests/builds.txt`). + +## Layout + +| Path | What | +|---|---| +| `everest.sh` | Entry point, runs on the host | +| `Dockerfile.build` | Alpine build image: the native compiler targets musl | +| `scripts/container.sh` | Runs inside that image: the build of each package (sources pinned by SHA256), publish, initramfs assembly | +| `scripts/live-init.sh` | The image's `/init`: copies the system onto a tmpfs and switches root to it | +| `scripts/vm-testnet.sh` | Network, local repositories and test CA inside the VM | +| `templates/minimal.template` | The package list `glacier-bootstrap` installs into the image | +| `pkgsrc/` | Sources of `everest-bootscripts`, `everest-repos` and Everest's `glacier.conf` | +| `recipes/extra-src/` | Source recipes, published as the `extra-src` repository | + +## The system + +| Package | Version | Repo | Provides | +|---|---|---|---| +| musl | 1.2.5 | base | C library and dynamic loader | +| busybox | 1.37.0 | base | init, sh, mount and core utilities | +| linux | 6.12.112 | base | kernel (namespaces, overlayfs) | +| everest-bootscripts | 1.4.0 | base | `/etc`: inittab, rc scripts, accounts (root locked, `_gbuild`), profile, doas.conf | +| everest-repos | 1.1.0 | base | `/etc/glacier`: `repos.conf` and `keys/everest-2026.pub` | +| zlib, libarchive, libconfig, luajit | | base | glacier's dependencies | +| libglacier-ng, glacier-ng | 4.0.0 | base | the package manager | +| libressl, ca-certificates, curl | 4.3.3, 2026.9.25, 8.23.0 | base | https for repositories | +| gcc-libs | 16.2.0 | base | libstdc++, libgcc_s | +| doas | 6.8.2 | extra | privilege escalation | +| linux-headers, binutils, make, gcc | 6.12.112, 2.47.0, 4.4.1, 16.2.0 | extra | the toolchain | + +The image is a system installed by glacier: `scripts/container.sh` runs +`glacier-bootstrap -t -d pkgs templates/minimal.template /target`, which +verifies the packages and has `syspkg -R /target` install them in one +transaction, then packs `/target`. + +## Not yet + +- No bootloader: the kernel is started by QEMU's `-kernel`. +- No installer: installing to disk is manual. +- `pkg.everestlinux.org` is not live. + +## License + +GPLv3 (`LICENSE`). Packages built here contain third-party software under +its own licenses; `scripts/container.sh` pins every upstream source by URL +and SHA256. diff --git a/everest.sh b/everest.sh new file mode 100755 index 0000000..6cc7700 --- /dev/null +++ b/everest.sh @@ -0,0 +1,130 @@ +#!/bin/sh +# everest.sh - build and boot a minimal Everest system. +# +# ./everest.sh keygen make the signing key (once) +# ./everest.sh build PKG build one package into pkgs/, signed +# ./everest.sh build all every package in PACKAGES (below) +# ./everest.sh adopt DIR take packages built from recipes into pkgs/ +# ./everest.sh publish sign the repositories into repo/ +# ./everest.sh initramfs assemble boot/vmlinuz + boot/initramfs.gz +# ./everest.sh boot boot it in QEMU on this terminal +# +# The repositories (repo/{base,extra,extra-src}) are published at +# https://pkg.everestlinux.org/REPO, which everest-repos' repos.conf +# lists. Until that server exists, initramfs and boot serve repo/ under +# that name locally, over https with a throwaway test CA (testca/): +# initramfs inside its container, boot to the VM (guest 10.0.2.100:443, +# relayed with socat). In the VM, run +# sh /sys/firmware/qemu_fw_cfg/by_name/opt/everest/testnet/raw +# to bring up the network and trust the test CA (scripts/vm-testnet.sh; +# neither is shipped). EVEREST_MEM / EVEREST_CPUS size the VM. +# +# Packages are built inside an Alpine container (Dockerfile.build), so +# they target musl. glacier-ng and libglacier-ng default to siblings of +# this directory; override with GLACIER_NG / LIBGLACIER_NG. +# +# Every package's sidecar is signed (REPO_DESIGN.txt section 7: syspkg +# installs a base package only with a signature by a key trusted for +# base). The SECRET key lives outside this tree, in EVEREST_KEYS +# (default ~/.config/everest/keys), and is mounted read-only into the +# build container; the public key ships in everest-repos. +set -eu + +HERE="$(cd "$(dirname "$0")" && pwd)" +GLACIER_NG="${GLACIER_NG:-$HERE/../glacier-ng}" +LIBGLACIER_NG="${LIBGLACIER_NG:-$HERE/../libglacier-ng}" +IMAGE=everest-build +EVEREST_KEYS="${EVEREST_KEYS:-$HOME/.config/everest/keys}" +KEY_NAME=everest-2026 +PACKAGES="musl busybox linux everest-bootscripts everest-repos zlib libarchive libconfig luajit libglacier-ng glacier-ng doas libressl ca-certificates curl linux-headers binutils make gcc" + +# in_container KEYS ARGS...: run container.sh ARGS in the build image. +# KEYS is "ro" or "rw" to mount EVEREST_KEYS at /keys, "-" for none. +# MOUNT=SRC:DST[:ro] adds one more mount. +in_container() { + keys="$1"; shift + docker build -q -t "$IMAGE" -f "$HERE/Dockerfile.build" "$HERE" >/dev/null + if [ "$keys" = - ]; then + set -- "$IMAGE" sh /everest/scripts/container.sh "$@" + else + set -- -v "$EVEREST_KEYS:/keys:$keys" "$IMAGE" sh /everest/scripts/container.sh "$@" + fi + docker run --rm \ + -e HOST_UID="$(id -u)" -e HOST_GID="$(id -g)" -e KEY_NAME="$KEY_NAME" \ + -v "$HERE:/everest" \ + -v "$(cd "$GLACIER_NG" && pwd):/glacier-ng:ro" \ + -v "$(cd "$LIBGLACIER_NG" && pwd):/libglacier-ng:ro" \ + ${MOUNT:+-v "$MOUNT"} \ + "$@" +} + +case "${1:-}" in +keygen) + if [ -e "$EVEREST_KEYS/$KEY_NAME.sec" ] || [ -e "$EVEREST_KEYS/$KEY_NAME.pub" ]; then + echo "[x] $EVEREST_KEYS/$KEY_NAME already exists." >&2 + exit 1 + fi + mkdir -p "$EVEREST_KEYS" && chmod 700 "$EVEREST_KEYS" + in_container rw keygen + ;; +build) + pkg="${2:?usage: $0 build PKG|all}" + if [ ! -r "$EVEREST_KEYS/$KEY_NAME.sec" ]; then + echo "[x] Missing signing key $EVEREST_KEYS/$KEY_NAME.sec." >&2 + exit 1 + fi + if [ "$pkg" = all ]; then + for p in $PACKAGES; do in_container ro build "$p"; done + else + in_container ro build "$pkg" + fi + ;; +adopt) + dir="$(cd "${2:?usage: $0 adopt DIR}" && pwd)" + if [ ! -r "$EVEREST_KEYS/$KEY_NAME.sec" ]; then + echo "[x] Missing signing key $EVEREST_KEYS/$KEY_NAME.sec." >&2 + exit 1 + fi + MOUNT="$dir:/adopt:ro" in_container ro adopt /adopt + ;; +publish) + if [ ! -r "$EVEREST_KEYS/$KEY_NAME.sec" ]; then + echo "[x] Missing signing key $EVEREST_KEYS/$KEY_NAME.sec." >&2 + exit 1 + fi + in_container ro publish + ;; +initramfs) + in_container - initramfs + ;; +boot) + # Press Enter for a root shell. Leave with `poweroff -f`, or Ctrl-A X. + # Drop -enable-kvm if /dev/kvm isn't available. + set -- -enable-kvm -m "${EVEREST_MEM:-6144}" -smp "${EVEREST_CPUS:-2}" -nographic \ + -kernel "$HERE/boot/vmlinuz" -initrd "$HERE/boot/initramfs.gz" \ + -append "console=ttyS0 rdinit=/init" + # The local repo/ as https://pkg.everestlinux.org (see the top). + if [ -f "$HERE/repo/base/repo.idx" ] && [ -f "$HERE/testca/server.pem" ]; then + port="${EVEREST_SERVE_PORT:-8443}" + (cd "$HERE/repo" && exec openssl s_server -quiet -WWW -accept "127.0.0.1:$port" \ + -cert "$HERE/testca/server.pem" -key "$HERE/testca/server.key" >/dev/null 2>&1) & + server=$! + trap 'kill $server 2>/dev/null' EXIT + set -- "$@" -netdev "user,id=net0,guestfwd=tcp:10.0.2.100:443-cmd:socat STDIO TCP:127.0.0.1:$port" \ + -device virtio-net-pci,netdev=net0 \ + -fw_cfg "name=opt/everest/testca,file=$HERE/testca/ca.pem" \ + -fw_cfg "name=opt/everest/testnet,file=$HERE/scripts/vm-testnet.sh" + fi + # repo/ itself, shared read-only: scripts/vm-testnet.sh mounts it + # over the image's copy at /srv/everest, so `everest.sh publish` + # reaches a running VM (syspkg -y) without a new initramfs. + if [ -f "$HERE/repo/base/repo.idx" ]; then + set -- "$@" -virtfs "local,path=$HERE/repo,mount_tag=everest-repo,security_model=none,readonly=on" + fi + qemu-system-x86_64 "$@" + ;; +*) + sed -n '2,30p' "$0" + exit 1 + ;; +esac diff --git a/pkgsrc/everest-bootscripts/etc/doas.conf b/pkgsrc/everest-bootscripts/etc/doas.conf new file mode 100644 index 0000000..68babb0 --- /dev/null +++ b/pkgsrc/everest-bootscripts/etc/doas.conf @@ -0,0 +1,8 @@ +# Members of wheel may run anything as root, with their password. +permit :wheel +# ...and create their own glacier directory (/glacier/usr/) +# without one. gstore -n with no UID acts only for the caller. doas +# matches cmd against what was typed, so both spellings are listed; a +# bare name is looked up on doas's own root-only PATH. +permit nopass :wheel as root cmd gstore args -n +permit nopass :wheel as root cmd /usr/bin/gstore args -n diff --git a/pkgsrc/everest-bootscripts/etc/group b/pkgsrc/everest-bootscripts/etc/group new file mode 100644 index 0000000..2688670 --- /dev/null +++ b/pkgsrc/everest-bootscripts/etc/group @@ -0,0 +1,4 @@ +root:x:0: +tty:x:5: +wheel:x:10:root +_gbuild:x:900: diff --git a/pkgsrc/everest-bootscripts/etc/hostname b/pkgsrc/everest-bootscripts/etc/hostname new file mode 100644 index 0000000..b5cee1d --- /dev/null +++ b/pkgsrc/everest-bootscripts/etc/hostname @@ -0,0 +1 @@ +everest diff --git a/pkgsrc/everest-bootscripts/etc/init.d/rcK b/pkgsrc/everest-bootscripts/etc/init.d/rcK new file mode 100755 index 0000000..5e86302 --- /dev/null +++ b/pkgsrc/everest-bootscripts/etc/init.d/rcK @@ -0,0 +1,4 @@ +#!/bin/sh +# /etc/init.d/rcK - run by init at shutdown (::shutdown in /etc/inittab). +sync +umount -a -r 2>/dev/null diff --git a/pkgsrc/everest-bootscripts/etc/init.d/rcS b/pkgsrc/everest-bootscripts/etc/init.d/rcS new file mode 100755 index 0000000..81dd611 --- /dev/null +++ b/pkgsrc/everest-bootscripts/etc/init.d/rcS @@ -0,0 +1,22 @@ +#!/bin/sh +# /etc/init.d/rcS - run once by init at boot (::sysinit in /etc/inittab). +# Mounts only what isn't mounted yet, so it works the same whether the +# root filesystem is an initramfs or a real disk. + +mnt() { # mnt TYPE DIR [OPTIONS] + mountpoint -q "$2" && return 0 + mkdir -p "$2" + mount -t "$1" ${3:+-o "$3"} "$1" "$2" +} + +mnt proc /proc nosuid,nodev,noexec +mnt sysfs /sys nosuid,nodev,noexec +mnt devtmpfs /dev nosuid,mode=0755 +mnt devpts /dev/pts nosuid,noexec,gid=5,mode=0620 +mnt tmpfs /dev/shm nosuid,nodev,mode=1777 +mnt tmpfs /run nosuid,nodev,mode=0755 + +# A real root filesystem is usually mounted read-only by the kernel. +mount -o remount,rw / 2>/dev/null + +[ -r /etc/hostname ] && hostname -F /etc/hostname diff --git a/pkgsrc/everest-bootscripts/etc/inittab b/pkgsrc/everest-bootscripts/etc/inittab new file mode 100644 index 0000000..d0ce941 --- /dev/null +++ b/pkgsrc/everest-bootscripts/etc/inittab @@ -0,0 +1,13 @@ +# /etc/inittab - busybox init. Format: ::: +# An empty tty field means the console. + +# Early boot: mount the virtual filesystems, set the hostname. +::sysinit:/etc/init.d/rcS + +# A root shell on the console, once Enter is pressed. root's password is +# locked (see /etc/shadow), so this is the only way in until one is set. +::askfirst:-/bin/sh + +::ctrlaltdel:/sbin/reboot +::shutdown:/etc/init.d/rcK +::restart:/sbin/init diff --git a/pkgsrc/everest-bootscripts/etc/passwd b/pkgsrc/everest-bootscripts/etc/passwd new file mode 100644 index 0000000..79ae7eb --- /dev/null +++ b/pkgsrc/everest-bootscripts/etc/passwd @@ -0,0 +1,2 @@ +root:x:0:0:root:/root:/bin/sh +_gbuild:x:900:900:glacier builds:/var/empty:/usr/sbin/nologin diff --git a/pkgsrc/everest-bootscripts/etc/profile b/pkgsrc/everest-bootscripts/etc/profile new file mode 100644 index 0000000..76537ec --- /dev/null +++ b/pkgsrc/everest-bootscripts/etc/profile @@ -0,0 +1,14 @@ +# /etc/profile - login shell setup. +# +# PATH: the user's own glacier packages, then non-base system packages +# (/glacier/sys/links), then the base system (/usr/bin; /bin and /sbin +# are links to it). The glacier dirs are listed whether or not they +# exist yet: they appear after `syspkg -n` / `gstore -n`, and a missing +# PATH entry is harmless. +GLACIER_LINKS="/glacier/usr/$(id -u)/links" +GLACIER_SYS_LINKS="/glacier/sys/links" +export PATH="$GLACIER_LINKS/bin:$GLACIER_SYS_LINKS/bin:/usr/bin" +export LD_LIBRARY_PATH="$GLACIER_LINKS/lib:$GLACIER_SYS_LINKS/lib" +unset GLACIER_LINKS GLACIER_SYS_LINKS +export PS1='\h:\w\$ ' +umask 022 diff --git a/pkgsrc/everest-bootscripts/etc/shadow b/pkgsrc/everest-bootscripts/etc/shadow new file mode 100644 index 0000000..18efb62 --- /dev/null +++ b/pkgsrc/everest-bootscripts/etc/shadow @@ -0,0 +1,2 @@ +root:!:0:::::: +_gbuild:!:0:::::: diff --git a/pkgsrc/everest-bootscripts/etc/shells b/pkgsrc/everest-bootscripts/etc/shells new file mode 100644 index 0000000..c2cdaa0 --- /dev/null +++ b/pkgsrc/everest-bootscripts/etc/shells @@ -0,0 +1 @@ +/bin/sh diff --git a/pkgsrc/everest-repos/etc/glacier/keys/everest-2026.pub b/pkgsrc/everest-repos/etc/glacier/keys/everest-2026.pub new file mode 100644 index 0000000..1f7eb7d --- /dev/null +++ b/pkgsrc/everest-repos/etc/glacier/keys/everest-2026.pub @@ -0,0 +1,2 @@ +untrusted comment: everest-2026 public key +RWTALtzjJuR6Ye62fG3Icws8B+D/g/+fZvh6JaY3MMZWEV6/YGJ804zo diff --git a/pkgsrc/everest-repos/etc/glacier/repos.conf b/pkgsrc/everest-repos/etc/glacier/repos.conf new file mode 100644 index 0000000..dfd2c17 --- /dev/null +++ b/pkgsrc/everest-repos/etc/glacier/repos.conf @@ -0,0 +1,10 @@ +# Everest's repositories and the keys trusted for each +# (REPO_DESIGN.txt section 3). syspkg -y / -f / -u fetch every entry +# with a url; base packages installed with syspkg -l need a signature by +# a key listed for base. extra-src holds the recipes extra's packages +# can also be built from (BUILD_DESIGN.txt). +repos = ( + { name = "base"; url = "https://pkg.everestlinux.org/base"; keys = [ "everest-2026" ]; }, + { name = "extra"; url = "https://pkg.everestlinux.org/extra"; keys = [ "everest-2026" ]; }, + { name = "extra-src"; url = "https://pkg.everestlinux.org/extra-src"; keys = [ "everest-2026" ]; } +); diff --git a/pkgsrc/glacier-ng/etc/glacier/glacier.conf b/pkgsrc/glacier-ng/etc/glacier/glacier.conf new file mode 100644 index 0000000..8e2ff33 --- /dev/null +++ b/pkgsrc/glacier-ng/etc/glacier/glacier.conf @@ -0,0 +1,33 @@ +// /etc/glacier/glacier.conf - glacier configuration (libconfig syntax). +// Everest's copy (pkgsrc/glacier-ng), shipped by the glacier-ng package. +// Read by gpkg and syspkg. Settings have no built-in defaults: if a +// setting an operation needs is missing, that operation refuses to run. + +// How many backups of replaced package versions to keep, per package. +// When `-lO` replaces an installed version, the old one is compressed +// into /backup///-.gpkg (+ .sha256) +// and the oldest backups beyond this count are deleted. 0 = no backups. +KEEP_OLD = 1; + +// Building from source (BUILD_DESIGN.txt). Used only when a package is +// built from a NAME-src repository; a build without what it needs +// refuses. +// +// The packages every build root has (from the binary repositories). +BUILD_ROOT = [ "musl", "busybox", "linux-headers", "binutils", "gcc", "make" ]; +// +// The unprivileged user syspkg builds as (not root; owns +// /glacier/sys/build). gpkg builds as the user running it. +BUILD_USER = "_gbuild"; +// +// Traits for every build, "name" on or "-name" off. A user's own +// /glacier/usr//config/glacier.conf overrides these, and a +// per-package file (/etc/glacier/config/NAME.conf, or the user's +// config/NAME.conf: TRAITS, CFLAGS, CXXFLAGS, LDFLAGS, CONFIGURE) +// overrides both. +// TRAITS = [ "-x11" ]; +// +// CFLAGS = "-O2 -pipe"; +// CXXFLAGS = "-O2 -pipe"; +// LDFLAGS = ""; +// JOBS = 4; diff --git a/recipes/README b/recipes/README new file mode 100644 index 0000000..1e3c02b --- /dev/null +++ b/recipes/README @@ -0,0 +1,16 @@ +Everest's recipes (BUILD_DESIGN.txt in libglacier-ng) + + extra-src/NAME/recipe libconfig, read by the library + extra-src/NAME/build optional shell hooks: prepare, + configure, compile, package + extra-src/NAME/patches/*.patch optional, applied in PATCHES order + +Pack and publish (a NAME-src repo is signed like a binary one): + + glacier-ng/tests/mkgrcp -o OUT extra-src/*/ + grepo -s KEY.sec -r extra-src OUT + +Build them in Docker: see libglacier-ng's DOCKER_BUILDS.txt. + +In hooks, install under $PREFIX (where the package will be linked: +/glacier/sys/links for extra), never a literal /usr. diff --git a/recipes/extra-src/bash/recipe b/recipes/extra-src/bash/recipe new file mode 100644 index 0000000..3bd1180 --- /dev/null +++ b/recipes/extra-src/bash/recipe @@ -0,0 +1,12 @@ +NAME = "bash"; +VER = "5.3.0"; +REPO = "extra"; +DESC = "The GNU Bourne-again shell"; +MAINT = "liamwaldron@everestlinux.org"; +COPYRIGHT = "GNU GPL 3.0"; +SOURCES = ( + { URL = "https://ftp.gnu.org/gnu/bash/bash-5.3.tar.gz"; + SHA256 = "sha256:0d5cd86965f869a26cf64f4b71be7b96f90a3ba8b3d74e27e8e9d9d5550f31ba"; } +); +# bash's bundled gettext doesn't compile on musl; its malloc misbehaves there. +CONFIGURE = [ "--disable-nls", "--without-bash-malloc" ]; diff --git a/recipes/extra-src/binutils/build b/recipes/extra-src/binutils/build new file mode 100644 index 0000000..b0f16a5 --- /dev/null +++ b/recipes/extra-src/binutils/build @@ -0,0 +1,23 @@ +# Toolchain packages are built for /usr, not PREFIX: they are build +# layers, which always sit at /usr (BUILD_DESIGN.txt section 13), and +# on the running system gcc finds its parts relative to itself. +# ld also searches /glacier/sys/links/lib, where extra's libraries are. +T=x86_64-everest-linux-musl + +configure() { + mkdir -p build && cd build + ../configure --prefix=/usr --build=$T --host=$T --target=$T \ + --disable-nls --disable-werror --disable-multilib \ + --enable-deterministic-archives --enable-ld=default \ + --enable-plugins --enable-64-bit-bfd --disable-gprofng \ + --disable-gdb --disable-gdbserver --disable-sim \ + --with-system-zlib --without-zstd \ + --with-lib-path=/usr/lib:/glacier/sys/links/lib +} + +compile() { make; } + +package() { + make DESTDIR="$DESTDIR" install-strip + rm -f "$DESTDIR/usr/share/info/dir" +} diff --git a/recipes/extra-src/binutils/recipe b/recipes/extra-src/binutils/recipe new file mode 100644 index 0000000..d35264c --- /dev/null +++ b/recipes/extra-src/binutils/recipe @@ -0,0 +1,12 @@ +NAME = "binutils"; +VER = "2.47.0"; +REPO = "extra"; +DESC = "Assembler, linker and binary tools"; +MAINT = "liamwaldron@everestlinux.org"; +COPYRIGHT = "GPL-3.0-or-later"; +SOURCES = ( + { URL = "https://ftp.gnu.org/gnu/binutils/binutils-2.47.tar.xz"; + SHA256 = "sha256:154ab23b60070e8f27013c22977f1129425d67d1e8acd6e13010e617811e4cff"; } +); +BUILD = "hooks"; +DEPS = ( { NAME = "musl"; VER = "1.2.5"; }, { NAME = "zlib"; VER = "1.3.2"; } ); diff --git a/recipes/extra-src/gcc/build b/recipes/extra-src/gcc/build new file mode 100644 index 0000000..0246278 --- /dev/null +++ b/recipes/extra-src/gcc/build @@ -0,0 +1,38 @@ +# A toolchain package: built for /usr, not PREFIX (see binutils). The +# same configuration as Everest's binary gcc (scripts/container.sh), +# whose runtime libraries are the separate gcc-libs package (base), so +# they are left out here. --with-local-prefix: headers of extra's +# packages, in /glacier/sys/links/include, are searched too. +T=x86_64-everest-linux-musl + +prepare() { + cd gcc-16.2.0 + for p in gmp-6.3.0 mpfr-4.2.2 mpc-1.3.1 isl-0.24; do + ln -s "../$p" "${p%%-*}" + done + # One libdir: x86_64 would otherwise put its libraries in lib64. + sed -i 's,m64=../lib64,m64=../lib,' gcc/config/i386/t-linux64 +} + +configure() { + mkdir build && cd build + ../configure --prefix=/usr --build=$T --host=$T --target=$T \ + --enable-languages=c,c++ --disable-multilib --disable-bootstrap \ + --disable-nls --disable-libsanitizer --disable-libssp \ + --disable-symvers --enable-default-pie --enable-default-ssp \ + --enable-shared --enable-threads=posix --enable-__cxa_atexit \ + --enable-checking=release --with-system-zlib \ + --with-local-prefix=/glacier/sys/links \ + --with-pkgversion="Everest" +} + +compile() { make; } + +package() { + make DESTDIR="$DESTDIR" install-strip + rm -f "$DESTDIR/usr/share/info/dir" + # POSIX's name for the C compiler: plain Makefiles (zstd's) call cc. + ln -s gcc "$DESTDIR/usr/bin/cc" + # gcc-libs' files (libcc1, GDB's plugin, stays here) + find "$DESTDIR/usr/lib" -maxdepth 1 -name 'lib*.so.*' ! -name '*.py' ! -name 'libcc1.*' -delete +} diff --git a/recipes/extra-src/gcc/recipe b/recipes/extra-src/gcc/recipe new file mode 100644 index 0000000..26b7b2f --- /dev/null +++ b/recipes/extra-src/gcc/recipe @@ -0,0 +1,23 @@ +NAME = "gcc"; +VER = "16.2.0"; +REPO = "extra"; +DESC = "The GNU C and C++ compilers"; +MAINT = "liamwaldron@everestlinux.org"; +COPYRIGHT = "GPL-3.0-or-later"; +# gmp, mpfr, mpc and isl are built into gcc; their hashes match the +# sha512s in gcc's own contrib/prerequisites.sha512. +SOURCES = ( + { URL = "https://ftp.gnu.org/gnu/gcc/gcc-16.2.0/gcc-16.2.0.tar.xz"; + SHA256 = "sha256:e6738e29597f733270731aa90600f37ffdc045079dfc27ec7e8192cc81085c3e"; }, + { URL = "https://gcc.gnu.org/pub/gcc/infrastructure/gmp-6.3.0.tar.bz2"; + SHA256 = "sha256:ac28211a7cfb609bae2e2c8d6058d66c8fe96434f740cf6fe2e47b000d1c20cb"; }, + { URL = "https://gcc.gnu.org/pub/gcc/infrastructure/mpfr-4.2.2.tar.bz2"; + SHA256 = "sha256:9ad62c7dc910303cd384ff8f1f4767a655124980bb6d8650fe62c815a231bb7b"; }, + { URL = "https://gcc.gnu.org/pub/gcc/infrastructure/mpc-1.3.1.tar.gz"; + SHA256 = "sha256:ab642492f5cf882b74aa0cb730cd410a81edcdbec895183ce930e706c1c759b8"; }, + { URL = "https://gcc.gnu.org/pub/gcc/infrastructure/isl-0.24.tar.bz2"; + SHA256 = "sha256:fcf78dd9656c10eb8cf9fbd5f59a0b6b01386205fe1934b3b287a0a1898145c0"; } +); +BUILD = "hooks"; +DEPS = ( { NAME = "musl"; VER = "1.2.5"; }, { NAME = "gcc-libs"; VER = "16.2.0"; }, + { NAME = "binutils"; VER = "2.47.0"; }, { NAME = "zlib"; VER = "1.3.2"; } ); diff --git a/recipes/extra-src/less/recipe b/recipes/extra-src/less/recipe new file mode 100644 index 0000000..89217ba --- /dev/null +++ b/recipes/extra-src/less/recipe @@ -0,0 +1,13 @@ +NAME = "less"; +VER = "710.0.0"; +REPO = "extra"; +DESC = "Terminal pager"; +MAINT = "liamwaldron7009@protonmail.com"; +COPYRIGHT = "GPL-3.0-or-later OR BSD-2-Clause"; +SOURCES = ( + { URL = "https://www.greenwoodsoftware.com/less/less-710.tar.gz"; + SHA256 = "sha256:d1008fb78dcae1323ddab664bcb352a61f022b1b131bd8018548e021d975ec7a"; } +); +BUILD = "autotools"; +CONFIGURE = [ "--with-regex=posix" ]; +DEPS = ( { NAME = "ncurses"; VER = "6.6.0"; } ); diff --git a/recipes/extra-src/linux-headers/build b/recipes/extra-src/linux-headers/build new file mode 100644 index 0000000..f193085 --- /dev/null +++ b/recipes/extra-src/linux-headers/build @@ -0,0 +1,9 @@ +# In /usr/include, where gcc looks (a toolchain package, see binutils). +# make headers_install without its rsync: the .h files of the +# generated usr/include. +package() { + make headers + find usr/include -type f ! -name '*.h' -delete + mkdir -p "$DESTDIR/usr" + cp -R usr/include "$DESTDIR/usr/" +} diff --git a/recipes/extra-src/linux-headers/recipe b/recipes/extra-src/linux-headers/recipe new file mode 100644 index 0000000..edcfa93 --- /dev/null +++ b/recipes/extra-src/linux-headers/recipe @@ -0,0 +1,11 @@ +NAME = "linux-headers"; +VER = "6.12.112"; +REPO = "extra"; +DESC = "Linux kernel headers for userspace"; +MAINT = "liamwaldron@everestlinux.org"; +COPYRIGHT = "GPL-2.0-only"; +SOURCES = ( + { URL = "https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-6.12.112.tar.xz"; + SHA256 = "sha256:164dc9d1f6c93c61a15e1f071c48379b467f2b17c469cce7223471968208ed03"; } +); +BUILD = "hooks"; diff --git a/recipes/extra-src/lua/build b/recipes/extra-src/lua/build new file mode 100644 index 0000000..c0944c3 --- /dev/null +++ b/recipes/extra-src/lua/build @@ -0,0 +1,14 @@ +# Lua has no configure step: its module search path is compiled in +# from LUA_ROOT, so point it at PREFIX. +prepare() { + sed -i "s|^\(#define LUA_ROOT[[:space:]]*\)\"/usr/local/\"|\1\"$PREFIX/\"|" src/luaconf.h + grep -q "^#define LUA_ROOT[[:space:]]*\"$PREFIX/\"" src/luaconf.h +} + +compile() { + make linux MYCFLAGS="$CFLAGS" MYLDFLAGS="$LDFLAGS" +} + +package() { + make install INSTALL_TOP="$DESTDIR$PREFIX" INSTALL_MAN="$DESTDIR$PREFIX/share/man/man1" +} diff --git a/recipes/extra-src/lua/recipe b/recipes/extra-src/lua/recipe new file mode 100644 index 0000000..65a3f85 --- /dev/null +++ b/recipes/extra-src/lua/recipe @@ -0,0 +1,11 @@ +NAME = "lua"; +VER = "5.4.9"; +REPO = "extra"; +DESC = "Lua scripting language"; +MAINT = "liamwaldron7009@protonmail.com"; +COPYRIGHT = "MIT"; +SOURCES = ( + { URL = "https://www.lua.org/ftp/lua-5.4.9.tar.gz"; + SHA256 = "sha256:2335b6c582a52654f94612bf10d2f4672805d05329aa6568b1d8cd9e5c6fb8e6"; } +); +BUILD = "hooks"; diff --git a/recipes/extra-src/make/build b/recipes/extra-src/make/build new file mode 100644 index 0000000..4cd1725 --- /dev/null +++ b/recipes/extra-src/make/build @@ -0,0 +1,11 @@ +# A toolchain package: built for /usr, not PREFIX (see binutils). +# gnu17: make 4.4.1's old-style declarations aren't C23 (gcc's default). +configure() { + ./configure --prefix=/usr --disable-nls --without-guile \ + CFLAGS="${CFLAGS:--O2} -std=gnu17" +} +compile() { make; } +package() { + make DESTDIR="$DESTDIR" install + rm -f "$DESTDIR/usr/share/info/dir" +} diff --git a/recipes/extra-src/make/recipe b/recipes/extra-src/make/recipe new file mode 100644 index 0000000..8c1ff1d --- /dev/null +++ b/recipes/extra-src/make/recipe @@ -0,0 +1,12 @@ +NAME = "make"; +VER = "4.4.1"; +REPO = "extra"; +DESC = "GNU make"; +MAINT = "liamwaldron@everestlinux.org"; +COPYRIGHT = "GPL-3.0-or-later"; +SOURCES = ( + { URL = "https://ftp.gnu.org/gnu/make/make-4.4.1.tar.gz"; + SHA256 = "sha256:dd16fb1d67bfab79a72f5e8390735c49e3e8e70b4945a15ab1f81ddb78658fb3"; } +); +BUILD = "hooks"; +DEPS = ( { NAME = "musl"; VER = "1.2.5"; } ); diff --git a/recipes/extra-src/ncurses/build b/recipes/extra-src/ncurses/build new file mode 100644 index 0000000..cdf4441 --- /dev/null +++ b/recipes/extra-src/ncurses/build @@ -0,0 +1,18 @@ +# The paths below depend on PREFIX, so they can't be static CONFIGURE +# arguments. terminfo is looked up in the package's own copy first. +configure() { + configure_args ./configure --prefix="$PREFIX" --sysconfdir=/etc \ + --mandir="$PREFIX/share/man" \ + --with-pkg-config-libdir="$PREFIX/lib/pkgconfig" \ + --with-terminfo-dirs="$PREFIX/share/terminfo:/etc/terminfo:/usr/share/terminfo" +} + +# Only the wide-character library is built: link the usual names to it. +package() { + make install DESTDIR="$DESTDIR" + cd "$DESTDIR$PREFIX/lib" + for l in ncurses curses tinfo; do + ln -s libncursesw.so lib$l.so + done + ln -s ncursesw.pc pkgconfig/ncurses.pc +} diff --git a/recipes/extra-src/ncurses/recipe b/recipes/extra-src/ncurses/recipe new file mode 100644 index 0000000..4c6856a --- /dev/null +++ b/recipes/extra-src/ncurses/recipe @@ -0,0 +1,19 @@ +NAME = "ncurses"; +VER = "6.6.0"; +REPO = "extra"; +DESC = "Terminal handling library and terminfo database"; +MAINT = "liamwaldron7009@protonmail.com"; +COPYRIGHT = "MIT"; +SOURCES = ( + { URL = "https://ftp.gnu.org/gnu/ncurses/ncurses-6.6.tar.gz"; + SHA256 = "sha256:355b4cbbed880b0381a04c46617b7656e362585d52e9cf84a67e2009b749ff11"; } +); +BUILD = "autotools"; +CONFIGURE = [ "--with-shared", "--without-debug", "--without-normal", + "--without-ada", "--without-tests", "--enable-widec", + "--enable-overwrite", "--enable-pc-files" ]; +TRAITS = ( + { NAME = "cxx"; DEFAULT = false; + ON = [ "--with-cxx-binding", "--with-cxx-shared" ]; + OFF = [ "--without-cxx-binding" ]; } +); diff --git a/recipes/extra-src/vim/recipe b/recipes/extra-src/vim/recipe new file mode 100644 index 0000000..9d2c5f9 --- /dev/null +++ b/recipes/extra-src/vim/recipe @@ -0,0 +1,19 @@ +NAME = "vim"; +VER = "9.2.1209"; +REPO = "extra"; +DESC = "Vi IMproved, a programmer's text editor"; +MAINT = "liamwaldron7009@protonmail.com"; +COPYRIGHT = "Vim"; +SOURCES = ( + { URL = "https://github.com/vim/vim/archive/refs/tags/v9.2.1209.tar.gz"; + SHA256 = "sha256:75b58bd42067312721fd22da5bcb78f735bea5d59ec7d79cdf45ea85f956a53c"; } +); +BUILD = "autotools"; +CONFIGURE = [ "--with-tlib=ncursesw", "--disable-gui", "--without-x", + "--disable-nls", "--disable-canberra", "--disable-libsodium", + "--enable-multibyte" ]; +TRAITS = ( + { NAME = "huge"; DEFAULT = true; + ON = [ "--with-features=huge" ]; OFF = [ "--with-features=normal" ]; } +); +DEPS = ( { NAME = "ncurses"; VER = "6.6.0"; } ); diff --git a/recipes/extra-src/zstd/build b/recipes/extra-src/zstd/build new file mode 100644 index 0000000..8c729c4 --- /dev/null +++ b/recipes/extra-src/zstd/build @@ -0,0 +1,4 @@ +# The same make variables for install, or it rebuilds with autodetection. +package() { + configure_args make install PREFIX="$PREFIX" DESTDIR="$DESTDIR" +} diff --git a/recipes/extra-src/zstd/recipe b/recipes/extra-src/zstd/recipe new file mode 100644 index 0000000..db4dc5b --- /dev/null +++ b/recipes/extra-src/zstd/recipe @@ -0,0 +1,13 @@ +NAME = "zstd"; +VER = "1.5.7"; +REPO = "extra"; +DESC = "Zstandard compression library and tool"; +MAINT = "liamwaldron7009@protonmail.com"; +COPYRIGHT = "BSD-3-Clause OR GPL-2.0-only"; +SOURCES = ( + { URL = "https://github.com/facebook/zstd/releases/download/v1.5.7/zstd-1.5.7.tar.gz"; + SHA256 = "sha256:eb33e51f49a15e023950cd7825ca74a4a2b43db8354825ac24fc1b7ee09e6fa3"; } +); +BUILD = "make"; +# Don't link whatever compression libraries the build root happens to have. +CONFIGURE = [ "HAVE_ZLIB=0", "HAVE_LZMA=0", "HAVE_LZ4=0" ]; diff --git a/scripts/container.sh b/scripts/container.sh new file mode 100755 index 0000000..2377cd9 --- /dev/null +++ b/scripts/container.sh @@ -0,0 +1,496 @@ +#!/bin/sh +# Runs INSIDE the everest-build image (started by everest.sh). +# /everest this project (read-write: pkgs/, boot/) +# /glacier-ng glacier-ng checkout (read-only: gbuild, lib/) +# /libglacier-ng libglacier-ng checkout (read-only, built in /tmp) +# /keys the signing keys (build: read-only; keygen: read-write) +# +# container.sh keygen make /keys/$KEY_NAME.{sec,pub}, and copy the +# public key into everest-repos +# container.sh build PKG build one package into /everest/pkgs, signed +# container.sh adopt DIR take packages built from recipes into pkgs/ +# container.sh publish sign the repositories into /everest/repo +# container.sh testca make /everest/testca (local test server) +# container.sh initramfs assemble /everest/boot/{vmlinuz,initramfs.gz} +set -eu + +OUT=/everest/pkgs +MAINT="liamwaldron@everestlinux.org" + +# libglacier-ng, built for musl: gbuild needs gsha256sum, and the +# initramfs step runs glacier-bootstrap and syspkg with it. +cp -a /libglacier-ng /tmp/lg +make -C /tmp/lg >/tmp/lg-build.log 2>&1 || { tail -30 /tmp/lg-build.log; exit 1; } +export GSHA256SUM_BIN=/tmp/lg/build/bin/gsha256sum +export GSIGN_BIN=/tmp/lg/build/bin/gsign +KEY_NAME="${KEY_NAME:?}" +KEY="/keys/$KEY_NAME.sec" +# The public key and repos.conf everest-repos ships; the build host +# trusts the same (initramfs, below). +TRUST=/everest/pkgsrc/everest-repos/etc/glacier + +# Hand everything we write back to the invoking user. +give_back() { chown -R "${HOST_UID:-0}:${HOST_GID:-0}" "$@"; } + +# Tarball sources are pinned by SHA256 (checked against upstream's +# signatures when the hash was written down) and cached in sources/. +SRC=/everest/sources +# The toolchain's target: native x86_64 musl, under Everest's own name. +TRIPLE=x86_64-everest-linux-musl + +# fetch URL SHA256: download URL into sources/ (unless the cached copy +# has SHA256), refuse it on a mismatch, unpack a tarball into a fresh +# directory and print the tree it made; for any other file, print the +# directory holding a copy. +fetch() { + f="$SRC/${1##*/}" + mkdir -p "$SRC" + if ! echo "$2 $f" | sha256sum -c --status 2>/dev/null; then + curl -sfL --proto =https -o "$f.part" "$1" || { echo "[x] Cannot fetch $1" >&2; exit 1; } + if ! echo "$2 $f.part" | sha256sum -c --status; then + rm -f "$f.part" + echo "[x] $1 does not match its hash." >&2 + exit 1 + fi + mv "$f.part" "$f" + give_back "$SRC" + fi + d=$(mktemp -d /tmp/src.XXXXXX) + case $f in + *.tar.*|*.tgz) tar -xf "$f" -C "$d" && echo "$d"/* ;; + *) cp "$f" "$d/" && echo "$d" ;; + esac +} + +LIBRESSL_URL=https://ftp.openbsd.org/pub/OpenBSD/LibreSSL/libressl-4.3.3.tar.gz +LIBRESSL_SHA=ff97c432457f349e6ba3d416ab903bc7468f1436f0f32efe5fff808de292c7b8 +LIBRESSL_CONF='./configure --prefix=/usr --sysconfdir=/etc --disable-static --disable-tests' +LINUX_URL=https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-6.12.112.tar.xz +LINUX_SHA=164dc9d1f6c93c61a15e1f071c48379b467f2b17c469cce7223471968208ed03 + +# gcc and gcc-libs come from ONE build: gcc-libs (base) is the runtime +# C++/libgcc libraries programs load, gcc (extra) everything else. +# The runtime files: versioned shared objects (lib*.so.N...), not the +# gdb pretty-printer scripts beside them. +# libcc1 is GDB's compiler plugin: gcc's, not a runtime library. +gcc_runtime() { (cd "$1" && find usr/lib -maxdepth 1 -name 'lib*.so.*' ! -name '*.py' ! -name 'libcc1.*'); } + +build_gcc() { + s=$(fetch https://ftp.gnu.org/gnu/gcc/gcc-16.2.0/gcc-16.2.0.tar.xz \ + e6738e29597f733270731aa90600f37ffdc045079dfc27ec7e8192cc81085c3e) + # gmp, mpfr, mpc, isl: built into gcc. The script checks each + # against the sha512s in the (signed) gcc tarball. + (cd "$s" && ./contrib/download_prerequisites) + # One libdir: x86_64 would otherwise put its libraries in lib64. + sed -i 's,m64=../lib64,m64=../lib,' "$s/gcc/config/i386/t-linux64" + mkdir "$s/build" + (cd "$s/build" && ../configure --prefix=/usr \ + --build=$TRIPLE --host=$TRIPLE --target=$TRIPLE \ + --enable-languages=c,c++ --disable-multilib --disable-bootstrap \ + --disable-nls --disable-libsanitizer --disable-libssp \ + --disable-symvers --enable-default-pie --enable-default-ssp \ + --enable-shared --enable-threads=posix --enable-__cxa_atexit \ + --enable-checking=release --with-system-zlib --without-zstd \ + --with-local-prefix=/glacier/sys/links \ + --with-pkgversion="Everest" && make -j"$(nproc)" && \ + make DESTDIR=/tmp/gcc-dest install-strip) + rm -f /tmp/gcc-dest/usr/share/info/dir + # POSIX's name for the C compiler: plain Makefiles (zstd's) call cc. + ln -s gcc /tmp/gcc-dest/usr/bin/cc + gcc_runtime /tmp/gcc-dest > /tmp/gcc-runtime + [ -s /tmp/gcc-runtime ] || { echo "[x] gcc installed no runtime libraries" >&2; exit 1; } + ./gbuild -k "$KEY" -n gcc-libs -V 16.2.0 -g base -c "GPL-3.0-or-later WITH GCC-exception-3.1" -m "$MAINT" \ + -d "GCC's runtime libraries (libgcc_s, libstdc++, ...)" \ + -D musl:1.2.5 \ + -b ':' \ + -i 'mkdir -p "$DESTDIR/usr/lib" && cp -P $(cat /tmp/gcc-runtime) "$DESTDIR/usr/lib/"' \ + -o "$OUT" /tmp/gcc-dest + ./gbuild -k "$KEY" -n gcc -V 16.2.0 -g extra -c "GPL-3.0-or-later" -m "$MAINT" \ + -d "The GNU C and C++ compilers" \ + -D musl:1.2.5 -D gcc-libs:16.2.0 -D binutils:2.47.0 -D zlib:1.3.2 \ + -b ':' \ + -i 'cp -a usr "$DESTDIR/" && (cd "$DESTDIR" && rm -f $(cat /tmp/gcc-runtime))' \ + -o "$OUT" /tmp/gcc-dest +} + +keygen() { + "$GSIGN_BIN" -G -p "/keys/$KEY_NAME.pub" -s "$KEY" -c "$KEY_NAME" + mkdir -p "$TRUST/keys" + install -m 644 "/keys/$KEY_NAME.pub" "$TRUST/keys/$KEY_NAME.pub" + give_back /keys "$TRUST" +} + +build() { + cd /glacier-ng + case "$1" in + musl) + ./gbuild -k "$KEY" -n musl -V 1.2.5 -g base -c MIT -m "$MAINT" \ + -d "The musl C library" \ + -u https://git.musl-libc.org/git/musl -r v1.2.5 \ + -b './configure --prefix=/usr --syslibdir=/lib && make -j"$(nproc)"' \ + -i 'make DESTDIR="$DESTDIR" install' \ + -o "$OUT" + ;; + busybox) + # CONFIG_TC: the tc applet doesn't build against current kernel + # headers. linuxrc would land at /usr/linuxrc; nothing needs it. + ./gbuild -k "$KEY" -n busybox -V 1.37.0 -g base -c GPL-2.0-only -m "$MAINT" \ + -d "Init, shell and core utilities in one binary" \ + -D musl:1.2.5 \ + -u https://git.busybox.net/busybox -r 1_37_0 \ + -b 'make defconfig && sed -i "s/^CONFIG_TC=y/# CONFIG_TC is not set/" .config && make -j"$(nproc)"' \ + -i 'make CONFIG_PREFIX="$DESTDIR" install && rm -f "$DESTDIR/linuxrc"' \ + -o "$OUT" + ;; + linux) + # 6.12 LTS. Plain v6.12 doesn't build with GCC 15. The image goes + # under /usr/lib/modules//: base packages only link under + # /usr, and copying it to the boot partition is the installer's job. + # kvm_guest.config adds virtio for QEMU; drop it for real hardware. + # Namespaces and overlayfs: gsandbox's builds (BUILD_DESIGN.txt). + # FW_CFG_SYSFS: everest.sh boot hands test files to the VM. + ./gbuild -k "$KEY" -n linux -V 6.12.112 -g base -c GPL-2.0-only -m "$MAINT" \ + -d "The Linux kernel" \ + -u https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git -r v6.12.112 \ + -b 'make defconfig && make kvm_guest.config && ./scripts/config -e NAMESPACES -e USER_NS -e PID_NS -e IPC_NS -e UTS_NS -e NET_NS -e OVERLAY_FS -e FW_CFG_SYSFS && make olddefconfig && make -j"$(nproc)" bzImage modules' \ + -i 'rel="$(make -s kernelrelease)" && install -Dm644 arch/x86/boot/bzImage "$DESTDIR/usr/lib/modules/$rel/vmlinuz" && make INSTALL_MOD_PATH="$DESTDIR/usr" INSTALL_MOD_STRIP=1 modules_install && rm -f "$DESTDIR/usr/lib/modules/$rel/build"' \ + -o "$OUT" + ;; + everest-bootscripts) + # No compilation: the package is pkgsrc/everest-bootscripts/etc. + # Modes are kept, ownership isn't (files are packaged as root). + ./gbuild -k "$KEY" -n everest-bootscripts -V 1.4.0 -g base -c MIT -m "$MAINT" \ + -d "Default boot scripts and /etc files for Everest" \ + -D busybox:1.37.0 \ + -b ':' \ + -i 'cp -R --preserve=mode,timestamps etc "$DESTDIR/"' \ + -o "$OUT" /everest/pkgsrc/everest-bootscripts + ;; + everest-repos) + # /etc/glacier/repos.conf and the public keys it lists, so an + # installed system knows its repositories (pkgsrc/everest-repos). + ./gbuild -k "$KEY" -n everest-repos -V 1.1.0 -g base -c MIT -m "$MAINT" \ + -d "Everest's repository list and signing keys" \ + -b ':' \ + -i 'cp -R --preserve=mode,timestamps etc "$DESTDIR/"' \ + -o "$OUT" /everest/pkgsrc/everest-repos + ;; + # --- glacier itself (ROADMAP 1.4): everything base except doas --- + zlib) + ./gbuild -k "$KEY" -n zlib -V 1.3.2 -g base -c Zlib -m "$MAINT" \ + -d "Compression library (deflate, gzip)" \ + -D musl:1.2.5 \ + -u https://github.com/madler/zlib -r v1.3.2 \ + -b './configure --prefix=/usr && make -j"$(nproc)"' \ + -i 'make DESTDIR="$DESTDIR" install' \ + -o "$OUT" + ;; + libarchive) + # gzip'd tar is all glacier needs: every optional codec, crypto + # library and front-end is off, so nothing links outside the + # system (the build image has openssl, xz, ... installed). + ./gbuild -k "$KEY" -n libarchive -V 3.8.9 -g base -c BSD-2-Clause -m "$MAINT" \ + -d "Archive reading and writing library" \ + -D musl:1.2.5 -D zlib:1.3.2 \ + -u https://github.com/libarchive/libarchive -r v3.8.9 \ + -b 'sh build/autogen.sh && ./configure --prefix=/usr --disable-static --disable-bsdtar --disable-bsdcpio --disable-bsdcat --disable-bsdunzip --disable-acl --disable-xattr --without-xml2 --without-expat --without-openssl --without-mbedtls --without-nettle --without-lzma --without-zstd --without-bz2lib --without-lz4 --without-libb2 --without-iconv && make -j"$(nproc)"' \ + -i 'make DESTDIR="$DESTDIR" install' \ + -o "$OUT" + ;; + libconfig) + ./gbuild -k "$KEY" -n libconfig -V 1.8.2 -g base -c LGPL-2.1-or-later -m "$MAINT" \ + -d "Structured configuration file library" \ + -D musl:1.2.5 \ + -u https://github.com/hyperrealm/libconfig -r v1.8.2 \ + -b 'cmake -B b -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_INSTALL_LIBDIR=lib -DBUILD_CXX=OFF -DBUILD_EXAMPLES=OFF -DBUILD_TESTS=OFF && cmake --build b -j"$(nproc)"' \ + -i 'DESTDIR="$DESTDIR" cmake --install b' \ + -o "$OUT" + ;; + luajit) + # LuaJIT has rolling releases: the version is 2.1., + # which is what `luajit -v` reports for this commit. + # -static-libgcc: its unwinder would otherwise need libgcc_s.so.1, + # which Everest doesn't ship (no GCC runtime package). + ./gbuild -k "$KEY" -n luajit -V 2.1.1788856981 -g base -c MIT -m "$MAINT" \ + -d "Just-in-time compiler for Lua" \ + -D musl:1.2.5 \ + -u https://github.com/LuaJIT/LuaJIT -r c6ffc141a8762b41703f9287d63d93622a13dd8f \ + -b 'make -j"$(nproc)" PREFIX=/usr LDFLAGS=-static-libgcc' \ + -i 'make install PREFIX=/usr DESTDIR="$DESTDIR"' \ + -o "$OUT" + ;; + libglacier-ng) + # From the mounted checkout, built above in /tmp/lg. gsha256sum + # belongs to the later glacier-tools package, not here. + ./gbuild -k "$KEY" -n libglacier-ng -V 4.0.0 -g base -c GPL-3.0-only -m "$MAINT" \ + -d "The glacier package manager library" \ + -D musl:1.2.5 -D libarchive:3.8.9 -D libconfig:1.8.2 \ + -b 'make clean && make' \ + -i 'mkdir -p "$DESTDIR/usr/bin" && make install PREFIX="$DESTDIR/usr" && rm -r "$DESTDIR/usr/bin"' \ + -o "$OUT" /tmp/lg + ;; + glacier-ng) + # syspkg, gpkg and gstore find lib/ beside their REAL path, so + # they live in usr/lib/glacier-ng/ and usr/bin/ holds symlinks + # into it. lib/glacier points at libglacier-ng's /usr/lib/glacier. + # glacier.conf is Everest's (pkgsrc/glacier-ng: BUILD_ROOT and + # BUILD_USER set), not glacier-ng's example. + ./gbuild -k "$KEY" -n glacier-ng -V 4.0.0 -g base -c GPL-3.0-only -m "$MAINT" \ + -d "syspkg, gpkg and gstore" \ + -D luajit:2.1.1788856981 -D libglacier-ng:4.0.0 -D busybox:1.37.0 \ + -b ':' \ + -i 'd="$DESTDIR/usr/lib/glacier-ng" && mkdir -p "$d/lib" "$DESTDIR/usr/bin" "$DESTDIR/etc/glacier" && install -m 755 syspkg gpkg gstore "$d/" && install -m 644 lib/cargs.lua lib/color.lua lib/glacier_cdef.lua lib/gpkg_common.lua lib/gpkg_build.lua lib/build-driver.sh "$d/lib/" && ln -s /usr/lib/glacier "$d/lib/glacier" && for t in syspkg gpkg gstore; do ln -s "../lib/glacier-ng/$t" "$DESTDIR/usr/bin/$t"; done && install -m 644 /everest/pkgsrc/glacier-ng/etc/glacier/glacier.conf "$DESTDIR/etc/glacier/"' \ + -o "$OUT" /glacier-ng + ;; + doas) + # extra, not base: replaceable (e.g. by sudo). No PAM: shadow + # passwords. /etc/doas.conf comes from everest-bootscripts. + ./gbuild -k "$KEY" -n doas -V 6.8.2 -g extra -c ISC -m "$MAINT" \ + -d "Run commands as another user (OpenDoas)" \ + -D musl:1.2.5 \ + -u https://github.com/Duncaen/OpenDoas -r v6.8.2 \ + -b './configure --prefix=/usr --without-pam --without-timestamp && make -j"$(nproc)"' \ + -i 'make DESTDIR="$DESTDIR" install' \ + -o "$OUT" + ;; + # --- https for glacier (REPO_DESIGN 10a): LibreSSL, curl, CAs --- + libressl) + # Libraries only: no openssl/ocspcheck programs, and no + # /etc/ssl/cert.pem (ca-certificates ships that). + s=$(fetch $LIBRESSL_URL $LIBRESSL_SHA) + ./gbuild -k "$KEY" -n libressl -V 4.3.3 -g base -c "OpenSSL AND ISC" -m "$MAINT" \ + -d "TLS and crypto libraries (libssl, libcrypto, libtls)" \ + -D musl:1.2.5 \ + -b "$LIBRESSL_CONF"' && make -j"$(nproc)"' \ + -i 'make DESTDIR="$DESTDIR" install && rm -f "$DESTDIR/etc/ssl/cert.pem" "$DESTDIR/usr/bin/openssl" "$DESTDIR/usr/bin/ocspcheck" && rm -rf "$DESTDIR/usr/share/man/man1" "$DESTDIR/usr/share/man/man8/ocspcheck.8" && rmdir "$DESTDIR/usr/bin" 2>/dev/null; true' \ + -o "$OUT" "$s" + ;; + ca-certificates) + s=$(fetch https://curl.se/ca/cacert-2026-09-25.pem \ + a41b5d356aea97a529fe27e0f7316d2f9d946d75927476cf9cf1b90637d00505) + ./gbuild -k "$KEY" -n ca-certificates -V 2026.9.25 -g base -c MPL-2.0 -m "$MAINT" \ + -d "Mozilla's CA certificates (curl's extract), /etc/ssl/cert.pem" \ + -b ':' \ + -i 'install -Dm644 cacert-2026-09-25.pem "$DESTDIR/etc/ssl/cert.pem"' \ + -o "$OUT" "$s" + ;; + curl) + # Against LibreSSL, not the build image's OpenSSL: that is + # removed and the same LibreSSL installed into this (throwaway) + # container first. https only matters to glacier; everything + # optional is off. + apk del -q openssl-dev + l=$(fetch $LIBRESSL_URL $LIBRESSL_SHA) + (cd "$l" && eval "$LIBRESSL_CONF" >/dev/null && make -j"$(nproc)" >/dev/null && make install >/dev/null) + s=$(fetch https://curl.se/download/curl-8.23.0.tar.xz \ + 8dadd7d2536a314f982ad05a651b713f426bf7d02cc2c76cffb9796f2218e6c5) + ./gbuild -k "$KEY" -n curl -V 8.23.0 -g base -c curl -m "$MAINT" \ + -d "URL transfer tool and library (https through LibreSSL)" \ + -D musl:1.2.5 -D zlib:1.3.2 -D libressl:4.3.3 -D ca-certificates:2026.9.25 \ + -b './configure --prefix=/usr --disable-static --with-openssl --with-ca-bundle=/etc/ssl/cert.pem --without-ca-path --with-zlib --without-libpsl --without-brotli --without-zstd --without-nghttp2 --without-nghttp3 --without-ngtcp2 --without-libidn2 --without-librtmp --without-libssh2 --without-libssh --disable-ldap --disable-ldaps --disable-manual && make -j"$(nproc)"' \ + -i 'make DESTDIR="$DESTDIR" install' \ + -o "$OUT" "$s" + ;; + # --- the toolchain (BUILD_DESIGN 1n: extra; its runtime in base) --- + linux-headers) + # make headers_install, without its rsync: the .h files of + # the generated usr/include. + s=$(fetch $LINUX_URL $LINUX_SHA) + ./gbuild -k "$KEY" -n linux-headers -V 6.12.112 -g extra -c GPL-2.0-only -m "$MAINT" \ + -d "Linux kernel headers for userspace" \ + -b ':' \ + -i 'make headers && find usr/include -type f ! -name "*.h" -delete && mkdir -p "$DESTDIR/usr" && cp -R usr/include "$DESTDIR/usr/"' \ + -o "$OUT" "$s" + ;; + binutils) + # ld also searches /glacier/sys/links/lib, where extra's + # libraries are linked (gcc: --with-local-prefix, its headers). + s=$(fetch https://ftp.gnu.org/gnu/binutils/binutils-2.47.tar.xz \ + 154ab23b60070e8f27013c22977f1129425d67d1e8acd6e13010e617811e4cff) + ./gbuild -k "$KEY" -n binutils -V 2.47.0 -g extra -c GPL-3.0-or-later -m "$MAINT" \ + -d "Assembler, linker and binary tools" \ + -D musl:1.2.5 -D zlib:1.3.2 \ + -b "mkdir build && cd build && ../configure --prefix=/usr --build=$TRIPLE --host=$TRIPLE --target=$TRIPLE --disable-nls --disable-werror --disable-multilib --enable-deterministic-archives --enable-ld=default --enable-plugins --enable-64-bit-bfd --disable-gprofng --disable-gdb --disable-gdbserver --disable-sim --with-system-zlib --without-zstd --without-debuginfod --with-lib-path=/usr/lib:/glacier/sys/links/lib"' && make -j"$(nproc)"' \ + -i 'make -C build DESTDIR="$DESTDIR" install-strip && rm -f "$DESTDIR/usr/share/info/dir"' \ + -o "$OUT" "$s" + ;; + make) + # gnu17: make 4.4.1's old-style declarations aren't C23 (GCC 15+'s + # default). + s=$(fetch https://ftp.gnu.org/gnu/make/make-4.4.1.tar.gz \ + dd16fb1d67bfab79a72f5e8390735c49e3e8e70b4945a15ab1f81ddb78658fb3) + ./gbuild -k "$KEY" -n make -V 4.4.1 -g extra -c GPL-3.0-or-later -m "$MAINT" \ + -d "GNU make" \ + -D musl:1.2.5 \ + -b './configure --prefix=/usr --disable-nls --without-guile CFLAGS="-O2 -std=gnu17" && make -j"$(nproc)"' \ + -i 'make DESTDIR="$DESTDIR" install && rm -f "$DESTDIR/usr/share/info/dir"' \ + -o "$OUT" "$s" + ;; + gcc|gcc-libs) + build_gcc + ;; + *) + echo "unknown package: $1" >&2 + exit 1 + ;; + esac + give_back "$OUT" +} + +# adopt DIR: packages built from extra-src recipes (the kept +# REPO@NAME-VER.gpkg files of a builder's /build/packages) become +# pkgs/NAME-VER.gpkg, sidecar written and signed as build does. The +# package each replaces moves to pkgs/stage1/ (kept once: the first +# build, from the build image's toolchain). Nothing is trusted from +# DIR but what the name and the manifest agree on; publish signs the +# indexes afterwards. +adopt() { + mkdir -p "$OUT/stage1" + for f in "$1"/*@*.gpkg; do + [ -f "$f" ] || { echo "[x] No REPO@NAME-VER.gpkg files in $1." >&2; exit 1; } + b=${f##*/}; repo=${b%%@*}; p=${b#*@}; p=${p%.gpkg} + m=$(tar -xzOf "$f" "$p/manifest.gpm.cfg") || { echo "[x] $b has no $p/manifest.gpm.cfg." >&2; exit 1; } + r=$(echo "$m" | sed -n 's/^PKG_REPO *= *"\(.*\)";$/\1/p') + [ "$r" = "$repo" ] || { echo "[x] $b says repository '$r'." >&2; exit 1; } + if [ -f "$OUT/$p.gpkg" ] && [ ! -f "$OUT/stage1/$p.gpkg" ]; then + mv "$OUT/$p.gpkg"* "$OUT/stage1/" + fi + cp "$f" "$OUT/$p.gpkg" + "$GSHA256SUM_BIN" "$OUT/$p.gpkg" > "$OUT/$p.gpkg.sha256" + "$GSIGN_BIN" -S -s "$KEY" -m "$OUT/$p.gpkg.sha256" >/dev/null + echo "Adopted $repo::$p" + done + give_back "$OUT" +} + +# The repositories, signed, in /everest/repo/{base,extra,extra-src}: +# every package templates/minimal.template installs plus EXTRA_PKGS +# (extra packages the image doesn't install; none today: the toolchain +# is in the template), each in the repository its manifest names (so +# base is exactly the template's base packages), and every recipe in +# /everest/recipes/extra-src. Built in repo.new and swapped in, so a +# failure leaves the old tree. +EXTRA_PKGS="" +REPO=/everest/repo +publish() { + rm -rf "$REPO.new" + mkdir -p "$REPO.new/base" "$REPO.new/extra" "$REPO.new/extra-src" + for p in $(sed -n 's/^PKG=\([^ ]*\) \([^ ]*\).*/\1-\2/p' /everest/templates/minimal.template) $EXTRA_PKGS; do + r=$(tar -xzOf "$OUT/$p.gpkg" "$p/manifest.gpm.cfg" | sed -n 's/^PKG_REPO *= *"\(.*\)";$/\1/p') + case $r in + base|extra) cp "$OUT/$p.gpkg" "$OUT/$p.gpkg.sha256" "$REPO.new/$r/" ;; + *) echo "[x] $p.gpkg: repository '$r' is not published." >&2; exit 1 ;; + esac + done + /glacier-ng/tests/mkgrcp -o "$REPO.new/extra-src" /everest/recipes/extra-src/*/ >/dev/null + # grepo's serial continues from the previous index. + for r in base extra extra-src; do + [ -f "$REPO/$r/repo.idx" ] && cp "$REPO/$r/repo.idx" "$REPO.new/$r/" + /tmp/lg/build/bin/grepo -s "$KEY" -r "$r" "$REPO.new/$r" + done + chmod -R a+rX "$REPO.new" + rm -rf "$REPO" && mv "$REPO.new" "$REPO" + give_back "$REPO" +} + +# A throwaway CA and a certificate for pkg.everestlinux.org signed by +# it, so the local repo/ can be served over https for tests (the build +# container here, QEMU through everest.sh serve). Its key is no secret: +# NEVER add ca.pem to anything shipped; tests append it at run time. +TESTCA=/everest/testca +testca() { + [ -f "$TESTCA/server.pem" ] && return 0 + mkdir -p "$TESTCA" + cd "$TESTCA" + openssl req -x509 -newkey ec -pkeyopt ec_paramgen_curve:P-256 -nodes \ + -keyout ca.key -out ca.pem -days 3650 \ + -subj "/CN=Everest TEST CA - never trust outside tests" \ + -addext "basicConstraints=critical,CA:TRUE" \ + -addext "keyUsage=critical,keyCertSign,cRLSign" 2>/dev/null + openssl req -newkey ec -pkeyopt ec_paramgen_curve:P-256 -nodes \ + -keyout server.key -out server.csr -subj "/CN=pkg.everestlinux.org" 2>/dev/null + printf 'subjectAltName=DNS:pkg.everestlinux.org\nextendedKeyUsage=serverAuth\nbasicConstraints=CA:FALSE\nkeyUsage=critical,digitalSignature\n' > ext + openssl x509 -req -in server.csr -CA ca.pem -CAkey ca.key -CAcreateserial \ + -out server.pem -days 3650 -extfile ext 2>/dev/null + rm -f server.csr ext ca.srl + cd / + give_back "$TESTCA" +} + +# Serve /everest/repo as https://pkg.everestlinux.org inside THIS +# container (the test CA trusted, the name pointed at 127.0.0.1). +serve_local() { + [ -f "$REPO/base/repo.idx" ] || { echo "[x] No $REPO: run everest.sh publish first." >&2; exit 1; } + testca + cat "$TESTCA/ca.pem" >> /etc/ssl/certs/ca-certificates.crt + echo "127.0.0.1 pkg.everestlinux.org" >> /etc/hosts + (cd "$REPO" && exec openssl s_server -quiet -WWW -accept 443 \ + -cert "$TESTCA/server.pem" -key "$TESTCA/server.key" >/dev/null 2>&1) & + sleep 1 +} + +# The system is installed by glacier itself: glacier-bootstrap verifies +# and resolves templates/minimal.template against pkgs/, then syspkg -R +# installs it into $T in one transaction (/glacier/sys, merged /usr, +# /etc copied). syspkg refuses to run as root from a tree it doesn't +# trust, so glacier-ng is copied to a root-owned /opt/glacier-ng with +# the musl-built libraries, and $T must be root-owned (not under /tmp). +initramfs() { + G=/opt/glacier-ng + rm -rf "$G" && cp -a /glacier-ng "$G" + mkdir -p "$G/lib/glacier" + cp /tmp/lg/build/lib/shared/libglacier_*.so "$G/lib/glacier/" + chown -R root:root "$G" && chmod -R go-w "$G" + + # syspkg -R checks base packages against THIS host's keyring. + install -D -m 644 "$TRUST/repos.conf" /etc/glacier/repos.conf + install -D -m 644 "$TRUST/keys/$KEY_NAME.pub" "/etc/glacier/keys/$KEY_NAME.pub" + + # T's repos.conf lists pkg.everestlinux.org, which bootstrap syncs + # (syspkg -R T -y): from the local repo/, never the network. + serve_local + + T=/target + rm -rf "$T" && mkdir -m 755 "$T" + echo y | PATH="$G:$PATH" "$G/glacier-bootstrap" -t \ + -d "$OUT" /everest/templates/minimal.template "$T" + + # The test image reads its repositories from a copy of repo/ at + # /srv/everest (file://), so -y/-f/-u work with no network; + # `everest.sh boot` can also share repo/ live at the same place + # (scripts/vm-testnet.sh mounts it). repos.conf is edited in T, so + # it is admin-modified there; the package still ships the https one. + mkdir -p -m 755 "$T/srv" + cp -a "$REPO" "$T/srv/everest" + chown -R root:root "$T/srv/everest" && chmod -R go-w,a+rX "$T/srv/everest" + sed 's|url = "https://pkg.everestlinux.org/|url = "file:///srv/everest/|' \ + "$T/etc/glacier/repos.conf" > /tmp/repos.conf + grep -q 'file:///srv/everest/base' /tmp/repos.conf || + { echo "[x] T's repos.conf has no pkg.everestlinux.org url to replace." >&2; exit 1; } + install -m 644 /tmp/repos.conf "$T/etc/glacier/repos.conf" + + mkdir -p /everest/boot + # T's links name runtime paths (/glacier/sys/store/...), so resolve + # them inside T. + chroot "$T" /bin/sh -c 'cat /usr/lib/modules/*/vmlinuz' > /everest/boot/vmlinuz + (cd "$T" && find . | cpio -o -H newc 2>/dev/null | gzip -9) > /everest/boot/initramfs.gz + # A second archive (the kernel unpacks them in order) holding only + # /init, which moves / to a tmpfs (see scripts/live-init.sh). It is + # not part of T: an installed system boots from its disk. + L=/tmp/live-init + rm -rf "$L" && mkdir -m 755 "$L" + install -m 755 /everest/scripts/live-init.sh "$L/init" + (cd "$L" && echo init | cpio -o -H newc -R 0:0 2>/dev/null | gzip -9) >> /everest/boot/initramfs.gz + give_back /everest/boot + ls -l /everest/boot +} + +case "${1:-}" in +keygen) keygen ;; +build) build "${2:?usage: container.sh build PKG}" ;; +adopt) adopt "${2:?usage: container.sh adopt DIR}" ;; +publish) publish ;; +testca) testca ;; +initramfs) initramfs ;; +*) echo "usage: container.sh keygen | build PKG | adopt DIR | publish | testca | initramfs" >&2; exit 1 ;; +esac diff --git a/scripts/live-init.sh b/scripts/live-init.sh new file mode 100644 index 0000000..c371c80 --- /dev/null +++ b/scripts/live-init.sh @@ -0,0 +1,24 @@ +#!/bin/sh +# /init of the live image (rdinit=/init), packed by `container.sh +# initramfs` as a second cpio after T's: it belongs to no package. +# +# The kernel unpacks the initramfs into rootfs, and pivot_root(2) +# refuses to move rootfs, so builds (gsandbox) could never enter their +# build root. This copies the system into a tmpfs and switch_roots into +# it; switch_root empties rootfs, so the copy costs no RAM after boot. +PATH=/usr/bin:/bin +mkdir -p /.live +if ! mount -t tmpfs -o size=90%,mode=755 live /.live; then + echo "[x] Cannot mount the live tmpfs; booting from the initramfs." >&2 + exec /sbin/init +fi +for e in /* /.[!.]*; do + case "$e" in + /.live|/init|'/.[!.]*') ;; + *) cp -a "$e" /.live/ || { + echo "[x] Cannot copy $e to the live tmpfs; booting from the initramfs." >&2 + umount /.live; exec /sbin/init + } ;; + esac +done +exec switch_root /.live /sbin/init diff --git a/scripts/toolchain-test.sh b/scripts/toolchain-test.sh new file mode 100644 index 0000000..68ed89e --- /dev/null +++ b/scripts/toolchain-test.sh @@ -0,0 +1,40 @@ +# toolchain-test.sh: Phases 2 and 4. NOT RUN YET. +# Runs INSIDE glacier-alpine_root started with the -b options plus +# -v EVEREST/repo:/srv/everest:ro (everest.sh publish; EVEREST = this tree) +# -v EVEREST/pkgsrc/everest-repos/etc/glacier/keys:/everest-keys:ro +# -v OUTDIR:/out (PHASE4=1: the kept packages, for everest.sh adopt) +# Phase 4 needs -fO there (base deps would land in the container's /usr). +set -u +export PATH=/glacier/sys/links/bin:/app:$PATH LD_LIBRARY_PATH=/glacier/sys/links/lib +nc() { sed 's/\x1b\[[0-9;]*m//g'; } +syspkg -n >/dev/null +adduser -S -D -H _gbuild +cp /everest-keys/everest-2026.pub /etc/glacier/keys/ +cat > /etc/glacier/repos.conf <<'EOR' +repos = ( + { name = "base"; url = "file:///srv/everest/base"; keys = [ "everest-2026" ]; }, + { name = "extra"; url = "file:///srv/everest/extra"; keys = [ "everest-2026" ]; }, + { name = "extra-src"; url = "file:///srv/everest/extra-src"; keys = [ "everest-2026" ]; } +); +EOR +chmod 644 /etc/glacier/repos.conf +cat > /etc/glacier/glacier.conf <>> " + c, flush=True) + LOG.write("\n>>> " + c + "\n") + send(c + '; echo "@@RC=$?@@"') + m = wait(r"@@RC=(\d+)@@", 3 * 3600, ans) + print(" rc=" + m.group(1), flush=True) +send("poweroff -f") +time.sleep(5) diff --git a/scripts/vm-testnet.sh b/scripts/vm-testnet.sh new file mode 100644 index 0000000..67c92b6 --- /dev/null +++ b/scripts/vm-testnet.sh @@ -0,0 +1,30 @@ +# vm-testnet.sh: run INSIDE an Everest VM started by `everest.sh boot`, +# which hands it over through QEMU's fw_cfg (never shipped): +# +# sh /sys/firmware/qemu_fw_cfg/by_name/opt/everest/testnet/raw +# +# Brings up QEMU's user network, points pkg.everestlinux.org at the +# host's local repository server (guest 10.0.2.100:443, relayed by +# QEMU) and appends the throwaway test CA to /etc/ssl/cert.pem (which +# makes that file admin-modified: ca-certificates won't update it). +# Also mounts the host's repo/ (shared by everest.sh boot) over the +# image's copy at /srv/everest, the file:// repositories repos.conf +# lists in the test image. +set -e +if [ -d /sys/bus/virtio/drivers/9pnet_virtio ] && ! grep -q ' /srv/everest 9p ' /proc/mounts; then + mount -t 9p -o trans=virtio,version=9p2000.L,ro everest-repo /srv/everest && + echo "/srv/everest is this host's repo/ (live)." +fi +ip link set lo up +ip link set eth0 up +ip addr add 10.0.2.15/24 dev eth0 2>/dev/null || true +ip route add default via 10.0.2.2 2>/dev/null || true +# QEMU's DNS, for builds fetching their sources (syspkg -f from -src). +grep -q '^nameserver' /etc/resolv.conf 2>/dev/null || + echo "nameserver 10.0.2.3" >> /etc/resolv.conf +grep -q pkg.everestlinux.org /etc/hosts 2>/dev/null || + echo "10.0.2.100 pkg.everestlinux.org" >> /etc/hosts +ca=/sys/firmware/qemu_fw_cfg/by_name/opt/everest/testca/raw +grep -q "$(sed -n 2p "$ca")" /etc/ssl/cert.pem 2>/dev/null || + cat "$ca" >> /etc/ssl/cert.pem +echo "Test network up: https://pkg.everestlinux.org is this host's repo/." diff --git a/scripts/vmtests/builds.txt b/scripts/vmtests/builds.txt new file mode 100644 index 0000000..c978a8b --- /dev/null +++ b/scripts/vmtests/builds.txt @@ -0,0 +1,16 @@ +grep -E ' / ' /proc/mounts +sh /sys/firmware/qemu_fw_cfg/by_name/opt/everest/testnet/raw +echo 'JOBS = 8;' >> /etc/glacier/glacier.conf +syspkg -y +syspkg -q -f vim +vim --version | head -1; vim --version | grep -o '[-+]huge\|Huge version' +syspkg -q -f less zstd lua bash +less --version | head -1; zstd --version; lua -v; bash --version | head -1 +echo 'int main(){return 0;}' > /tmp/t.c && cc -o /tmp/t /tmp/t.c && /tmp/t && echo cc-ok +mkdir -p /etc/glacier/config && echo 'TRAITS = [ "-huge" ];' > /etc/glacier/config/vim.conf +syspkg -q -u +vim --version | head -1; vim --version | grep -o 'Huge version\|Normal version\|Small version\|Tiny version' +adduser -D tester && gstore -n $(id -u tester) +su - tester -c 'gpkg -q -f zstd' +su - tester -c 'command -v zstd; zstd --version' +dmesg | grep -ci 'failed to set xattr' diff --git a/templates/minimal.template b/templates/minimal.template new file mode 100644 index 0000000..a464256 --- /dev/null +++ b/templates/minimal.template @@ -0,0 +1,29 @@ +# The minimal bootable Everest system: what `everest.sh initramfs` packs. +# glacier-bootstrap -d pkgs templates/minimal.template TARGET +NAME=minimal +PKG=musl 1.2.5 +PKG=busybox 1.37.0 +PKG=linux 6.12.112 +PKG=everest-bootscripts 1.4.0 +# repos.conf and keys: glacier-bootstrap fetches the indexes it lists +PKG=everest-repos 1.1.0 +# glacier, so the system can manage itself (ROADMAP 1.4) +PKG=zlib 1.3.2 +PKG=libarchive 3.8.9 +PKG=libconfig 1.8.2 +PKG=luajit 2.1.1788856981 +PKG=libglacier-ng 4.0.0 +PKG=glacier-ng 4.0.0 +PKG=doas 6.8.2 +# https for -y/-f/-u (REPO_DESIGN 10a: LibreSSL) +PKG=libressl 4.3.3 +PKG=ca-certificates 2026.9.25 +PKG=curl 8.23.0 +# GCC's runtime (C++ programs, libgcc_s) +PKG=gcc-libs 16.2.0 +# The toolchain (extra): gcc in the shell, and the packages glacier.conf's +# BUILD_ROOT names for building from source (BUILD_DESIGN.txt) +PKG=linux-headers 6.12.112 +PKG=binutils 2.47.0 +PKG=make 4.4.1 +PKG=gcc 16.2.0