summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock2
-rw-r--r--Cargo.toml4
-rw-r--r--LICENSE750
-rw-r--r--README.md47
-rw-r--r--src/apply.rs7
-rw-r--r--src/config.rs69
-rw-r--r--src/group.rs1
-rw-r--r--src/install.rs31
-rw-r--r--src/main.rs103
-rw-r--r--src/parallel.rs81
-rw-r--r--src/progress.rs116
-rw-r--r--src/rootfs.rs531
12 files changed, 700 insertions, 1042 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 684122c..4d0144e 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -2333,7 +2333,7 @@ dependencies = [
[[package]]
name = "ror"
-version = "1.0.3"
+version = "1.0.4"
dependencies = [
"ar",
"chrono",
diff --git a/Cargo.toml b/Cargo.toml
index d14472b..54d7a18 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,10 +1,10 @@
[package]
name = "ror"
-version = "1.0.3"
+version = "1.0.4"
edition = "2024"
authors = ["rorka900"]
description = "RorkOS package manager"
-license = "AGPL-3.0"
+license = "MPL-2.0"
[dependencies]
ar = "0.9"
diff --git a/LICENSE b/LICENSE
index 179a1a6..5f9ef49 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,387 +1,363 @@
- GNU AFFERO GENERAL PUBLIC LICENSE
- Version 3, 19 November 2007
-
- Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- Preamble
-
- The GNU Affero General Public License is a free, copyleft license for
-software and other kinds of works, specifically designed to ensure
-cooperation with the community in the case of network server software.
-
- The licenses for most software and other practical works are designed
-to take away your freedom to share and change the works. By contrast,
-our General Public Licenses are 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.
-
- 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.
-
- Developers that use our General Public Licenses protect your rights
-with two steps: (1) assert copyright on the software, and (2) offer
-you this License which gives you legal permission to copy, distribute
-and/or modify the software.
-
- A secondary benefit of defending all users' freedom is that
-improvements made in alternate versions of the program, if they
-receive widespread use, become available for other developers to
-incorporate. Many developers of free software are heartened and
-encouraged by the resulting cooperation. However, in the case of
-software used on network servers, this result may fail to come about.
-The GNU General Public License permits making a modified version and
-letting the public access it on a server without ever releasing its
-source code to the public.
-
- The GNU Affero General Public License is designed specifically to
-ensure that, in such cases, the modified source code becomes available
-to the community. It requires the operator of a network server to
-provide the source code of the modified version running there to the
-users of that server. Therefore, public use of a modified version, on
-a publicly accessible server, gives the public access to the source
-code of the modified version.
-
- An older license, called the Affero General Public License and
-published by Affero, was designed to accomplish similar goals. This is
-a different license, not a version of the Affero GPL, but Affero has
-released a new version of the Affero GPL which permits relicensing under
-this license.
-
- 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 Affero 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 fi \ No newline at end of file
+Mozilla Public License Version 2.0
+==================================
+
+1. Definitions
+--------------
+
+1.1. "Contributor"
+ means each individual or legal entity that creates, contributes to
+ the creation of, or owns Covered Software.
+
+1.2. "Contributor Version"
+ means the combination of the Contributions of others (if any) used
+ by a Contributor and that particular Contributor's Contribution.
+
+1.3. "Contribution"
+ means Covered Software of a particular Contributor.
+
+1.4. "Covered Software"
+ means Source Code Form to which the initial Contributor has attached
+ the notice in Exhibit A, the Executable Form of such Source Code
+ Form, and Modifications of such Source Code Form, in each case
+ including portions thereof.
+
+1.5. "Incompatible With Secondary Licenses"
+ means
+
+ (a) that the initial Contributor has attached the notice described
+ in Exhibit B to the Covered Software; or
+
+ (b) that the Covered Software was made available under the terms of
+ version 1.1 or earlier of the License, but not also under the
+ terms of a Secondary License.
+
+1.6. "Executable Form"
+ means any form of the work other than Source Code Form.
+
+1.7. "Larger Work"
+ means a work that combines Covered Software with other material, in
+ a separate file or files, that is not Covered Software.
+
+1.8. "License"
+ means this document.
+
+1.9. "Licensable"
+ means having the right to grant, to the maximum extent possible,
+ whether at the time of the initial grant or subsequently, any and
+ all of the rights granted herein.
+
+1.10. "Modifications"
+ means any of the following:
+
+ (a) any addition to or deletion from the substance or structure of
+ the file or files containing Covered Software; or
+
+ (b) any new file in Source Code Form that contains any part of the
+ Covered Software.
+
+1.11. "Patent Claims" of a Contributor
+ means any patent claim(s), including without limitation, method,
+ process, and apparatus claims, in any patent Licensable by such
+ Contributor that would be infringed, but for the grant of the License,
+ by the making, using, selling, offering for sale, having made, import,
+ or transfer of either its Contributions or its Contributor Version.
+
+1.12. "Secondary License"
+ means either the GNU General Public License, Version 2.0, the GNU
+ Lesser General Public License, Version 2.1, the GNU Affero General
+ Public License, Version 3.0, or any later versions of those
+ licenses.
+
+1.13. "Source Code Form"
+ means the form of the work preferred for making modifications.
+
+1.14. "You" (or "Your")
+ means an individual or a legal entity exercising rights under this
+ License. For legal entities, "You" includes any entity that
+ controls, is controlled by, or is under common control with You. For
+ purposes of this definition, "control" means (a) the power, direct
+ or indirect, to cause the direction or management of such entity,
+ whether by contract or otherwise, or (b) ownership of more than
+ fifty percent (50%) of the outstanding shares or beneficial
+ ownership of such entity.
+
+2. License Grants and Conditions
+--------------------------------
+
+2.1. Grants
+
+Each Contributor hereby grants You a world-wide, royalty-free,
+non-exclusive license:
+
+(a) under intellectual property rights (other than patent or trademark)
+ Licensable by such Contributor to use, reproduce, make available,
+ modify, display, perform, distribute, and otherwise exploit its
+ Contributions, either on an unmodified basis, with Modifications, or
+ as part of a Larger Work; and
+
+(b) under Patent Claims of such Contributor to make, use, sell, offer
+ for sale, have made, import, and otherwise transfer either its
+ Contributions or its Contributor Version.
+
+2.2. Effective Date
+
+The licenses granted in Section 2.1 with respect to any Contribution
+become effective for each Contribution on the date the Contributor first
+distributes such Contribution.
+
+2.3. Limitations on Grant Scope
+
+The licenses granted in this Section 2 are the only rights granted under
+this License. No additional rights or licenses will be implied from the
+distribution or licensing of Covered Software under this License.
+Notwithstanding Section 2.1(b) above, no patent license is granted by a
+Contributor:
+
+(a) for any code that a Contributor has deleted from the Covered
+ Software; or
+
+(b) for infringements caused by: (i) Your and any other third party's
+ modifications of Covered Software, or (ii) the combination of its
+ Contributions with other software (except as part of its Contributor
+ Version); or
+
+(c) under Patent Claims infringed by Covered Software in the absence of
+ its Contributions.
+
+This License does not grant any rights in the trademarks, service marks,
+or logos of any Contributor (except as may be necessary to comply with
+the notice requirements in Section 3.4).
+
+2.4. Subsequent Licenses
+
+No Contributor makes additional grants as a result of Your choice to
+distribute the Covered Software under a subsequent version of this
+License (see Section 10.2) or under the terms of a Secondary License (if
+permitted under the terms of Section 3.3).
+
+2.5. Representation
+
+Each Contributor represents that the Contributor believes its
+Contributions are its original creation(s) or it has sufficient rights
+to grant the rights to its Contributions conveyed by this License.
+
+2.6. Fair Use
+
+This License is not intended to limit any rights You have under
+applicable copyright doctrines of fair use, fair dealing, or other
+equivalents.
+
+2.7. Conditions
+
+Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted
+in Section 2.1.
+
+3. Responsibilities
+-------------------
+
+3.1. Distribution of Source Form
+
+All distribution of Covered Software in Source Code Form, including any
+Modifications that You create or to which You contribute, must be under
+the terms of this License. You must inform recipients that the Source
+Code Form of the Covered Software is governed by the terms of this
+License, and how they can obtain a copy of this License. You may not
+attempt to alter or restrict the recipients' rights in the Source Code
+Form.
+
+3.2. Distribution of Executable Form
+
+If You distribute Covered Software in Executable Form then:
+
+(a) such Covered Software must also be made available in Source Code
+ Form, as described in Section 3.1, and You must inform recipients of
+ the Executable Form how they can obtain a copy of such Source Code
+ Form by reasonable means in a timely manner, at a charge no more
+ than the cost of distribution to the recipient; and
+
+(b) You may distribute such Executable Form under the terms of this
+ License, or sublicense it under different terms, provided that the
+ license for the Executable Form does not attempt to limit or alter
+ the recipients' rights in the Source Code Form under this License.
+
+3.3. Distribution of a Larger Work
+
+You may create and distribute a Larger Work under terms of Your choice,
+provided that You also comply with the requirements of this License for
+the Covered Software. If the Larger Work is a combination of Covered
+Software with a work governed by one or more Secondary Licenses, and the
+Covered Software is not Incompatible With Secondary Licenses, this
+License permits You to additionally distribute such Covered Software
+under the terms of such Secondary License(s), so that the recipient of
+the Larger Work may, at their option, further distribute the Covered
+Software under the terms of either this License or such Secondary
+License(s).
+
+3.4. Notices
+
+You may not remove or alter the substance of any license notices
+(including copyright notices, patent notices, disclaimers of warranty,
+or limitations of liability) contained within the Source Code Form of
+the Covered Software, except that You may alter any license notices to
+the extent required to remedy known factual inaccuracies.
+
+3.5. Application of Additional Terms
+
+You may choose to offer, and to charge a fee for, warranty, support,
+indemnity or liability obligations to one or more recipients of Covered
+Software. However, You may do so only on Your own behalf, and not on
+behalf of any Contributor. You must make it absolutely clear that any
+such warranty, support, indemnity, or liability obligation is offered by
+You alone, and You hereby agree to indemnify every Contributor for any
+liability incurred by such Contributor as a result of warranty, support,
+indemnity or liability terms You offer. You may include additional
+disclaimers of warranty and limitations of liability specific to any
+jurisdiction.
+
+4. Inability to Comply Due to Statute or Regulation
+---------------------------------------------------
+
+If it is impossible for You to comply with any of the terms of this
+License with respect to some or all of the Covered Software due to
+statute, judicial order, or regulation then You must: (a) comply with
+the terms of this License to the maximum extent possible; and (b)
+describe the limitations and the code they affect. Such description must
+be placed in a text file included with all distributions of the Covered
+Software under this License. Except to the extent prohibited by statute
+or regulation, such description must be sufficiently detailed for a
+recipient of ordinary skill to be able to understand it.
+
+5. Termination
+--------------
+
+5.1. The rights granted under this License will terminate automatically
+if You fail to comply with any of its terms. However, if You become
+compliant, then the rights granted under this License from a particular
+Contributor are reinstated (a) provisionally, unless and until such
+Contributor explicitly and finally terminates Your grants, and (b) on an
+ongoing basis, if such Contributor fails to notify You of the
+non-compliance by some reasonable means prior to 60 days after You have
+come back into compliance. Moreover, Your grants from a particular
+Contributor are reinstated on an ongoing basis if such Contributor
+notifies You of the non-compliance by some reasonable means, this is the
+first time You have received notice of non-compliance with this License
+from such Contributor, and You become compliant prior to 30 days after
+Your receipt of the notice.
+
+5.2. If You initiate litigation against any entity by asserting a patent
+infringement claim (excluding declaratory judgment actions,
+counter-claims, and cross-claims) alleging that a Contributor Version
+directly or indirectly infringes any patent, then the rights granted to
+You by any and all Contributors for the Covered Software under Section
+2.1 of this License shall terminate.
+
+5.3. In the event of termination under Sections 5.1 or 5.2 above, all
+end user license agreements (excluding distributors and resellers) which
+have been validly granted by You or Your distributors under this License
+prior to termination shall survive termination.
+
+6. Disclaimer of Warranty
+-------------------------
+
+Covered Software is provided under this License on an "as is"
+basis, without warranty of any kind, either expressed, implied, or
+statutory, including, without limitation, warranties that the
+Covered Software is free of defects, merchantable, fit for a
+particular purpose or non-infringing. The entire risk as to the
+quality and performance of the Covered Software is with You.
+Should any Covered Software prove defective in any respect, You
+(not any Contributor) assume the cost of any necessary servicing,
+repair, or correction. This disclaimer of warranty constitutes an
+essential part of this License. No use of any Covered Software is
+authorized under this License except under this disclaimer.
+
+7. Limitation of Liability
+--------------------------
+
+Under no circumstances and under no legal theory, whether tort
+(including negligence), contract, or otherwise, shall any
+Contributor, or anyone who distributes Covered Software as
+permitted above, be liable to You for any direct, indirect,
+special, incidental, or consequential damages of any character
+including, without limitation, damages for lost profits, loss of
+goodwill, work stoppage, computer failure or malfunction, or any
+and all other commercial damages or losses, even if such party
+shall have been informed of the possibility of such damages. This
+limitation of liability shall not apply to liability for death or
+personal injury resulting from such party's negligence to the
+extent applicable law prohibits such limitation. Some
+jurisdictions do not allow the exclusion or limitation of
+incidental or consequential damages, so this exclusion and
+limitation may not apply to You.
+
+8. Litigation
+-------------
+
+Any litigation relating to this License may be brought only in the
+courts of a jurisdiction where the defendant maintains its principal
+place of business and such litigation shall be governed by laws of that
+jurisdiction, without reference to its conflict-of-law provisions.
+Nothing in this Section shall prevent a party's ability to bring
+cross-claims or counter-claims.
+
+9. Miscellaneous
+----------------
+
+This License represents the complete agreement concerning the subject
+matter hereof. If any provision of this License is held to be
+unenforceable, such provision shall be reformed only to the extent
+necessary to make it enforceable. Any law or regulation which provides
+that the language of a contract shall be construed against the drafter
+shall not be used to construe this License against a Contributor.
+
+10. Versions of the License
+---------------------------
+
+10.1. New Versions
+
+Mozilla Foundation is the license steward. Except as provided in
+Section 10.3, no one other than the license steward has the right to
+modify or publish new versions of this License. Each version will be
+given a distinguishing version number.
+
+10.2. Effect of New Versions
+
+You may distribute the Covered Software under the terms of the version
+of the License under which You originally received the Covered Software,
+or under the terms of any subsequent version published by the license
+steward.
+
+10.3. Modified Versions
+
+If you create software not governed by this License, and you want to
+create a new license for such software, you may create and use a
+modified version of this License if you rename the license and remove
+any references to the name of the license steward (except to note that
+such modified license differs from this License).
+
+10.4. Distributing Source Code Form that is Incompatible With Secondary
+Licenses
+
+If You choose to distribute Source Code Form that is Incompatible With
+Secondary Licenses under the terms of this version of the License, the
+notice described in Exhibit B of this License must be attached.
+
+Exhibit A - Source Code Form License Notice
+-------------------------------------------
+
+ This Source Code Form is subject to the terms of the Mozilla Public
+ License, v. 2.0. If a copy of the MPL was not distributed with this
+ file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+If it is not possible to put the notice in a particular file, then You
+may include the notice in a location (such as a LICENSE file in a
+relevant directory) where a recipient would be likely to look for such
+a notice.
+
+You may add additional accurate notices of copyright ownership.
+
+Exhibit B - "Incompatible With Secondary Licenses" Notice
+---------------------------------------------------------
+
+ This Source Code Form is "Incompatible With Secondary Licenses", as
+ defined by the Mozilla Public License, v. 2.0.
diff --git a/README.md b/README.md
index ee7a847..01bd1cb 100644
--- a/README.md
+++ b/README.md
@@ -4,27 +4,26 @@ ror is a lightweight, fast package manager designed for RorkOS. It uses YAML-bas
## Configuration
-ror reads `/etc/ror/ror.conf` (INI format):
+ror reads `/etc/ror/ror.conf` (INI format). System architecture and libc variant are automatically detected at runtime:
-```
+```ini
[global]
-ignore_speed = false
-strict_gpg = false
parallel_downloads = 4
-arch = x86_64
-libc = glibc
+strict_gpg = false
[repositories.rorkos]
-url = "https://example.com/repo"
-urlrepo = "https://example.com/repo"
-mirror = "https://example.com/mirror"
-gpg_support = true
-gpg_key = "rorka.pub"
+url = "https://codeberg.org/RorkOS/packages.git"
+urlrepo = "https://rorkos.duckdns.org/pkg/"
+gpg_support = false
```
+- `url`: Git repository URL for package recipes (`.yaml`)
+- `urlrepo`: HTTP(S) URL where binary packages (`.ror`, `.sror`) are hosted
+- `mirror`: optional fallback mirror for binary packages
+
Generate a default config:
-```
+```bash
# ror gen-config
```
@@ -153,13 +152,13 @@ Package names are matched case-insensitively. Any of these work:
## Removing Packages
-```
-# ror remove <package>
+```bash
+# ror delete <package>
```
or using the alias:
-```
+```bash
# ror d <package>
```
@@ -407,10 +406,26 @@ Installed packages are tracked in `/etc/ror/installed.json` (JSON format). This
| Command | Alias |
|----------------------|-------|
| `install` | `i` |
-| `remove` | `d` |
+| `delete` | `d` |
| `sync` | `s` |
| `upgrade` | `u` |
| `list-installed` | `l` |
| `count` | `c` |
| `list-groups` | `lg` |
| `apply` | `a` |
+
+## Version
+
+```bash
+# ror version
+# ror --version
+```
+
+Output:
+```
+ror 1.0.4 MPL 2
+```
+
+## License
+
+MPL-2.0 (Mozilla Public License Version 2.0)
diff --git a/src/apply.rs b/src/apply.rs
index dd5268d..5494773 100644
--- a/src/apply.rs
+++ b/src/apply.rs
@@ -106,12 +106,7 @@ pub fn get_target_packages(sys_config: &SystemConfig, _cfg: &Config) -> Result<V
let group = group::load_group(group_name)
.map_err(|e| format!("Failed to load group '{}': {}", group_name, e))?;
if let Some(ref libc_pkg) = group.libc {
- let libc_name = match libc_pkg.as_str() {
- "musl" => "musl",
- "glibc" => "glibc",
- other => other,
- };
- target.insert(libc_name.to_string());
+ target.insert(libc_pkg.clone());
}
for pkg in group.packages {
target.insert(pkg);
diff --git a/src/config.rs b/src/config.rs
index e4ffdaf..e9d1c95 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -54,8 +54,26 @@ impl Default for GlobalConfig {
fn default_ignore_speed() -> bool { false }
fn default_strict_gpg() -> bool { false }
fn default_parallel_downloads() -> usize { 4 }
-fn default_arch() -> String { std::env::consts::ARCH.to_string() }
-fn default_libc() -> String { "glibc".to_string() }
+
+pub fn detect_arch() -> String {
+ std::env::consts::ARCH.to_string()
+}
+
+pub fn detect_libc() -> String {
+ if cfg!(target_env = "musl") {
+ "musl".to_string()
+ } else {
+ "glibc".to_string()
+ }
+}
+
+fn default_arch() -> String {
+ detect_arch()
+}
+
+fn default_libc() -> String {
+ detect_libc()
+}
#[derive(Debug, Deserialize, Serialize, Clone, Default)]
pub struct SystemProfile {
@@ -167,29 +185,17 @@ impl Config {
pub fn to_ini(&self) -> Result<String, config::ConfigError> {
let mut lines = vec!["[global]".to_string()];
- lines.push(format!("ignore_speed = {}", self.global.ignore_speed));
- lines.push(format!("strict_gpg = {}", self.global.strict_gpg));
lines.push(format!("parallel_downloads = {}", self.global.parallel_downloads));
- lines.push(format!("arch = {}", self.global.arch));
- lines.push(format!("libc = {}", self.global.libc));
- lines.push(String::new());
-
- let p = &self.profile;
- let has_profile = p.init_system.is_some() || p.libc.is_some()
- || p.core_utils.is_some() || !p.sh.is_empty()
- || !p.su.is_empty() || p.udev.is_some() || p.active_group.is_some();
-
- if has_profile {
- lines.push("[profile]".to_string());
- if let Some(v) = &p.active_group { lines.push(format!("active-group = {}", v)); }
- if let Some(v) = &p.init_system { lines.push(format!("init-system = {}", v)); }
- if let Some(v) = &p.libc { lines.push(format!("libc = {}", v)); }
- if let Some(v) = &p.core_utils { lines.push(format!("core-utils = {}", v)); }
- if !p.sh.is_empty() { lines.push(format!("sh = {}", p.sh.join(","))); }
- if !p.su.is_empty() { lines.push(format!("su = {}", p.su.join(","))); }
- if let Some(v) = &p.udev { lines.push(format!("udev = {}", v)); }
- lines.push(String::new());
+ if self.global.strict_gpg {
+ lines.push(format!("strict_gpg = {}", self.global.strict_gpg));
+ }
+ if self.global.allow_external_binaries {
+ lines.push(format!("allow_external_binaries = {}", self.global.allow_external_binaries));
}
+ if self.global.ignore_speed {
+ lines.push(format!("ignore_speed = {}", self.global.ignore_speed));
+ }
+ lines.push(String::new());
for (name, repo) in &self.repositories {
lines.push(format!("[repositories.{}]", name));
@@ -200,7 +206,9 @@ impl Config {
if let Some(m) = &repo.mirror {
lines.push(format!("mirror = \"{}\"", m));
}
- lines.push(format!("gpg_support = {}", repo.gpg_support));
+ if repo.gpg_support {
+ lines.push(format!("gpg_support = {}", repo.gpg_support));
+ }
if let Some(k) = &repo.gpg_key {
lines.push(format!("gpg_key = \"{}\"", k));
}
@@ -219,20 +227,17 @@ impl Config {
pub fn create_default_config(path: &Path) -> std::io::Result<()> {
let ini = concat!(
"[global]\n",
- "ignore_speed = true\n",
- "strict_gpg = false\n",
- "allow_external_binaries = true\n",
"parallel_downloads = 4\n",
- "arch = x86_64\n",
- "libc = glibc\n\n",
+ "strict_gpg = false\n\n",
"[repositories.rorkos]\n",
- "url = \"https://rorkos.duckdns.org/pkg/\"\n",
+ "url = \"https://codeberg.org/RorkOS/packages.git\"\n",
"urlrepo = \"https://rorkos.duckdns.org/pkg/\"\n",
- "mirror = \"https://rorkos.duckdns.org/pkg/\"\n",
"gpg_support = false\n",
);
- fs::create_dir_all(path.parent().unwrap())?;
+ if let Some(parent) = path.parent() {
+ fs::create_dir_all(parent)?;
+ }
let mut tmp = NamedTempFile::new_in(path.parent().unwrap_or(Path::new(".")))?;
tmp.write_all(ini.as_bytes())?;
fs::set_permissions(tmp.path(), std::fs::Permissions::from_mode(0o644))?;
diff --git a/src/group.rs b/src/group.rs
index bc34a68..6623b40 100644
--- a/src/group.rs
+++ b/src/group.rs
@@ -16,6 +16,7 @@ pub struct Group {
pub version: Option<String>,
pub packages: Vec<String>,
#[serde(default)]
+ #[allow(dead_code)]
pub install_steps: String,
#[serde(rename = "init-system")]
diff --git a/src/install.rs b/src/install.rs
index e58735e..fae66fc 100644
--- a/src/install.rs
+++ b/src/install.rs
@@ -11,7 +11,7 @@ use std::collections::HashMap;
use std::os::unix::fs::{symlink, PermissionsExt};
use tempfile::{NamedTempFile, tempdir};
use crate::config;
-use crate::progress::{Spinner, format_bytes};
+use crate::progress::{Spinner, DownloadBar};
use crate::debug;
use tar::Archive as TarArchive;
use zstd::stream::read::Decoder as ZstdDecoder;
@@ -301,6 +301,9 @@ pub fn download_and_verify(url: &str, expected_sha: &str, _cfg: &config::Config)
.and_then(|v| v.to_str().ok())
.and_then(|s| s.parse::<u64>().ok());
+ let filename = url.rsplit('/').next().unwrap_or(url);
+ let mut bar = DownloadBar::new(filename, total_size);
+
let mut tmp_file = NamedTempFile::new()
.map_err(|e| format!("Failed to create temp file: {}", e))?;
let file_path = tmp_file.path().to_path_buf();
@@ -308,7 +311,6 @@ pub fn download_and_verify(url: &str, expected_sha: &str, _cfg: &config::Config)
let mut hasher = Sha256::new();
let mut reader = response;
let mut buf = [0u8; 65536];
- let mut downloaded: u64 = 0;
loop {
let n = reader
@@ -320,31 +322,10 @@ pub fn download_and_verify(url: &str, expected_sha: &str, _cfg: &config::Config)
hasher.update(&buf[..n]);
tmp_file.write_all(&buf[..n])
.map_err(|e| format!("Failed to write to temp file: {}", e))?;
- downloaded += n as u64;
-
- match total_size {
- Some(total) if total > 0 => {
- let pct = downloaded * 40 / total;
- let bar = format!(
- "{}>{}",
- "=".repeat(pct.saturating_sub(1) as usize),
- " ".repeat((40 - pct) as usize)
- );
- eprint!(
- "\r\x1b[K\x1b[36m[{}]\x1b[0m {} / {}",
- bar,
- format_bytes(downloaded),
- format_bytes(total)
- );
- }
- _ => {
- eprint!("\r\x1b[K{} downloaded", format_bytes(downloaded));
- }
- }
- std::io::stderr().flush().ok();
+ bar.update(n as u64);
}
- eprintln!("\r\x1b[K\x1b[32m✓\x1b[0m Downloaded {}", format_bytes(downloaded));
+ bar.finish();
if !expected_sha.is_empty() {
let hash = format!("{:x}", hasher.finalize());
diff --git a/src/main.rs b/src/main.rs
index c2725ee..447c93a 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,4 +1,4 @@
-use clap::{Parser, Subcommand};
+use clap::{CommandFactory, Parser, Subcommand};
use std::sync::Arc;
use colored::Colorize;
use std::path::{Path, PathBuf};
@@ -22,7 +22,12 @@ mod apply;
mod resolver;
#[derive(Parser)]
-#[command(name = "ror", about = "Ror package manager")]
+#[command(
+ name = "ror",
+ about = "ror package manager",
+ version = concat!(env!("CARGO_PKG_VERSION"), " MPL 2"),
+ disable_help_subcommand = true
+)]
struct Cli {
#[command(subcommand)]
command: Commands,
@@ -30,86 +35,127 @@ struct Cli {
#[derive(Subcommand)]
enum Commands {
-
+ /// install one or more packages or groups
#[command(alias = "i")]
Install {
+ /// package names or @group specifications to install
#[arg(required = true)]
packages: Vec<String>,
},
-
+
+ /// list available package groups
#[command(alias = "lg")]
ListGroups,
-
+
+ /// synchronize repository package recipes from remote
#[command(alias = "s")]
Sync,
-
+
+ /// remove an installed package
#[command(alias = "d")]
Delete {
+ /// name of the package to remove
package: String,
},
-
+
+ /// list all installed packages
#[command(alias = "l")]
ListInstalled,
+ /// print the total count of installed packages
#[command(alias = "c")]
Count,
-
+
+ /// display detailed information about a package
Info {
+ /// name of the package
package: String,
},
-
+
+ /// update a specific package to the latest available version
Update {
+ /// name of the package to update
package: String,
+ /// check for update without making modifications
#[arg(long)]
dry_run: bool,
},
-
+
+ /// upgrade all installed packages to their latest versions
#[command(alias = "u")]
Upgrade,
-
+
+ /// search for packages by query in repositories
Search {
+ /// search query string
query: String,
},
-
+
+ /// add a new package repository
RepoAdd {
+ /// repository name
name: String,
+ /// repository recipe git url
url: String,
+ /// optional binary package mirror url
mirror: Option<String>,
},
-
+
+ /// remove a configured package repository
RepoRemove {
+ /// name of the repository to remove
name: String,
},
-
+
+ /// list all configured package repositories
RepoList,
-
+
+ /// build a rootfs environment from a package group
BuildRootfs {
+ /// package group name to build
#[arg(long)]
group: String,
+ /// target directory path for rootfs
#[arg(long)]
target: PathBuf,
+ /// target architecture (default: native)
#[arg(long, default_value = "native")]
arch: String,
},
-
+
+ /// atomically replace one package with another
Di {
+ /// package to delete
delete: String,
+ /// package to install
install: String,
},
-
+
+ /// apply declarative system configuration state
#[command(alias = "a")]
Apply {
+ /// show changes without applying them
#[arg(long)]
dry_run: bool,
+ /// custom system.yaml configuration file path
#[arg(long)]
config: Option<PathBuf>,
},
-
+
+ /// check integrity of installed packages
Check,
-
+
+ /// generate default configuration file at /etc/ror/ror.conf
GenConfig,
-
+
+ /// display ror version information
Version,
+
+ /// print this message or the help of the given subcommand
+ Help {
+ /// name of the subcommand
+ subcommand: Option<String>,
+ },
}
#[tokio::main]
@@ -117,8 +163,22 @@ async fn main() {
let cli = Cli::parse();
match cli.command {
+ Commands::Help { subcommand } => {
+ let mut cmd = Cli::command();
+ if let Some(sub) = subcommand {
+ if let Some(subcmd) = cmd.find_subcommand_mut(&sub) {
+ let _ = subcmd.print_help();
+ } else {
+ let _ = cmd.print_help();
+ }
+ } else {
+ let _ = cmd.print_help();
+ }
+ println!();
+ }
+
Commands::Version => {
- println!("ror {}", env!("CARGO_PKG_VERSION"));
+ println!("ror {} MPL 2", env!("CARGO_PKG_VERSION"));
}
Commands::GenConfig => {
@@ -202,7 +262,6 @@ async fn main() {
&target,
&cfg,
arch,
- true,
) {
eprintln!("{} {}", "[ror]".red().bold(), e);
}
diff --git a/src/parallel.rs b/src/parallel.rs
index aacd9c3..93958e6 100644
--- a/src/parallel.rs
+++ b/src/parallel.rs
@@ -140,18 +140,23 @@ impl AtomicInstaller {
}
}
-async fn download_one(url: &str, expected_sha: &str, _cfg: &Config) -> Result<PathBuf, String> {
+async fn download_one(
+ url: &str,
+ expected_sha: &str,
+ pkg_name: Option<&str>,
+ _cfg: &Config,
+) -> Result<PathBuf, String> {
if url.starts_with("http://") {
return Err(format!("Insecure HTTP URL rejected: {}. Only HTTPS allowed.", url));
}
- let result = timeout(Duration::from_secs(60), async {
+ let result = timeout(Duration::from_secs(120), async {
let client = reqwest::Client::builder()
- .timeout(Duration::from_secs(30))
+ .timeout(Duration::from_secs(60))
.build()
.map_err(|e| format!("HTTP client builder: {}", e))?;
- let res = client
+ let mut res = client
.get(url)
.send()
.await
@@ -161,13 +166,23 @@ async fn download_one(url: &str, expected_sha: &str, _cfg: &Config) -> Result<Pa
return Err(format!("HTTP {} for {}", res.status(), url));
}
+ let total_size = res.content_length();
+ let mut bar = pkg_name.map(|name| crate::progress::DownloadBar::new(name, total_size));
+
let mut tmp_file = NamedTempFile::new().map_err(|e| e.to_string())?;
- let _file_path = tmp_file.path().to_path_buf();
let mut hasher = Sha256::new();
- let body = res.bytes().await.map_err(|e| e.to_string())?;
- hasher.update(&body);
- tmp_file.write_all(&body).map_err(|e| e.to_string())?;
+ while let Some(chunk) = res.chunk().await.map_err(|e| e.to_string())? {
+ hasher.update(&chunk);
+ tmp_file.write_all(&chunk).map_err(|e| e.to_string())?;
+ if let Some(b) = &mut bar {
+ b.update(chunk.len() as u64);
+ }
+ }
+
+ if let Some(b) = &bar {
+ b.finish();
+ }
if !expected_sha.is_empty() {
let hash = format!("{:x}", hasher.finalize());
@@ -191,10 +206,11 @@ async fn download_one(url: &str, expected_sha: &str, _cfg: &Config) -> Result<Pa
async fn race_download(
urls: Vec<String>,
expected_sha: &str,
+ pkg_name: &str,
cfg: Arc<Config>,
) -> Result<(PathBuf, String), String> {
if urls.len() == 1 {
- let p = download_one(&urls[0], expected_sha, &cfg).await?;
+ let p = download_one(&urls[0], expected_sha, Some(pkg_name), &cfg).await?;
return Ok((p, urls[0].clone()));
}
@@ -206,9 +222,10 @@ async fn race_download(
let tx_clone = Arc::clone(&tx);
let cfg_clone = cfg.clone();
let sha = expected_sha.to_string();
+ let name = pkg_name.to_string();
handles.push(task::spawn(async move {
- match download_one(&url, &sha, &cfg_clone).await {
+ match download_one(&url, &sha, Some(&name), &cfg_clone).await {
Ok(path) => {
let mut guard = tx_clone.lock().unwrap();
if let Some(sender) = guard.take() {
@@ -236,7 +253,7 @@ async fn install_single_impl(
variant: Option<&str>,
cfg: Arc<Config>,
) -> Result<InstalledPackage, String> {
- println!("[{}] Resolving {}...", "[ror]".cyan().bold(), pkg_name);
+ println!("{} Resolving {}...", "[ror]".cyan().bold(), pkg_name);
let start_time = std::time::Instant::now();
@@ -279,18 +296,17 @@ async fn install_single_impl(
));
}
- println!("[{}] Downloading {}...", "[ror]".blue(), pkg_name);
let (archive_path, winning_url) =
- race_download(urls, &binary.sha256, cfg.clone()).await?;
+ race_download(urls, &binary.sha256, pkg_name, cfg.clone()).await?;
if repo_cfg.map(|r| r.gpg_support).unwrap_or(false) {
if let Some(key_file) = repo_cfg.and_then(|r| r.gpg_key.as_deref()) {
let asc_url = format!("{}.asc", winning_url);
- println!("[{}] Verifying GPG...", "[ror]".cyan());
+ println!("{} Verifying GPG...", "[ror]".cyan().bold());
let asc_path = match timeout(
Duration::from_secs(30),
- download_one(&asc_url, "", &cfg),
+ download_one(&asc_url, "", None, &cfg),
)
.await
{
@@ -318,7 +334,7 @@ async fn install_single_impl(
}
}
- println!("[{}] Extracting {}...", "[ror]".green(), pkg_name);
+ println!("{} Extracting {}...", "[ror]".green().bold(), pkg_name);
let shadow = tempfile::tempdir().map_err(|e| e.to_string())?;
let work_dir = shadow.path().join("root");
std::fs::create_dir_all(&work_dir).map_err(|e| e.to_string())?;
@@ -336,7 +352,7 @@ async fn install_single_impl(
}
};
- println!("{} Installing {}...", "[ror]".blue().bold(), pkg_name);
+ println!("{} Installing {}...", "[ror]".blue().bold(), pkg_name);
let installer = AtomicInstaller::new(shadow);
let installed_files =
@@ -345,7 +361,7 @@ async fn install_single_impl(
let _ = std::fs::remove_file(&archive_path);
let elapsed = start_time.elapsed().as_millis();
- println!("[>] Installed {} ({:.2}ms)", pkg_name, elapsed as f64);
+ println!("{} Installed {} ({:.2}ms)", "[ror]".green().bold(), pkg_name, elapsed as f64);
install_services(&pkg);
@@ -362,7 +378,7 @@ pub async fn install_packages_parallel(
packages: &[String],
cfg: Arc<Config>,
) -> Result<(), String> {
- println!("[>] Starting package synchronization...");
+ println!("{} Starting package installation...", "[ror]".blue().bold());
let ctrl_c_handle = tokio::spawn(async {
tokio::signal::ctrl_c().await.ok();
@@ -388,7 +404,7 @@ pub async fn install_packages_parallel(
resolver::collect_required_packages(&pure_packages, &installed_db, &mut outdated, libc)?;
if required.is_empty() {
- println!("[>] Nothing to install.");
+ println!("{} Nothing to install.", "[ror]".green().bold());
ctrl_c_handle.abort();
return Ok(());
}
@@ -401,16 +417,19 @@ pub async fn install_packages_parallel(
for (level_idx, level_pkgs) in levels.iter().enumerate() {
if INTERRUPTED.load(Ordering::SeqCst) {
- println!("[!] Interrupted by user.");
+ println!("{} Interrupted by user.", "[ror]".yellow().bold());
ctrl_c_handle.abort();
return Err("Installation aborted".to_string());
}
- println!(
- "[>] Level {} installing {} packages...",
- level_idx,
- level_pkgs.len()
- );
+ if levels.len() > 1 {
+ println!(
+ "{} Level {} installing {} package(s)...",
+ "[ror]".blue().bold(),
+ level_idx + 1,
+ level_pkgs.len()
+ );
+ }
let mut tasks = Vec::new();
for pkg in level_pkgs {
@@ -440,12 +459,12 @@ pub async fn install_packages_parallel(
}
if !level_errors.is_empty() {
- println!("[X] Errors at level {}:", level_idx);
+ println!("{} Errors at level {}:", "[ror]".red().bold(), level_idx + 1);
for (name, err) in &level_errors {
- println!(" [!] {}: {}", name.red(), err);
+ println!(" {} {}: {}", "[ror]".red().bold(), name, err);
}
ctrl_c_handle.abort();
- return Err(format!("Level {} failed", level_idx));
+ return Err(format!("Level {} failed", level_idx + 1));
}
let mut db = InstalledDB::load();
@@ -455,13 +474,13 @@ pub async fn install_packages_parallel(
let path = Path::new(InstalledDB::PATH);
if let Err(e) = db.save_atomic(path) {
- eprintln!("[X] Failed to save database: {}", e);
+ eprintln!("{} Failed to save database: {}", "[ror]".red().bold(), e);
ctrl_c_handle.abort();
return Err(format!("Failed to save DB: {}", e));
}
}
ctrl_c_handle.abort();
- println!("[>] Synchronization completed successfully.");
+ println!("{} All packages installed successfully.", "[ror]".green().bold());
Ok(())
}
diff --git a/src/progress.rs b/src/progress.rs
index ec97b79..eb5ea00 100644
--- a/src/progress.rs
+++ b/src/progress.rs
@@ -91,3 +91,119 @@ pub fn format_bytes(bytes: u64) -> String {
format!("{:.1} MB", bytes as f64 / (1024.0 * 1024.0))
}
}
+
+pub struct DownloadBar {
+ name: String,
+ total: Option<u64>,
+ downloaded: u64,
+ start_time: std::time::Instant,
+ last_render: std::time::Instant,
+ width: usize,
+}
+
+impl DownloadBar {
+ pub fn new(name: &str, total: Option<u64>) -> Self {
+ let bar = Self {
+ name: name.to_string(),
+ total,
+ downloaded: 0,
+ start_time: std::time::Instant::now(),
+ last_render: std::time::Instant::now(),
+ width: 25,
+ };
+ bar.render();
+ bar
+ }
+
+ pub fn update(&mut self, delta: u64) {
+ self.downloaded += delta;
+ if self.last_render.elapsed().as_millis() >= 80 {
+ self.render();
+ self.last_render = std::time::Instant::now();
+ }
+ }
+
+ pub fn render(&self) {
+ let elapsed = self.start_time.elapsed().as_secs_f64();
+ let speed = if elapsed > 0.05 {
+ format!("{}/s", format_bytes((self.downloaded as f64 / elapsed) as u64))
+ } else {
+ "-- B/s".to_string()
+ };
+
+ if let Some(total) = self.total {
+ if total > 0 {
+ let pct = ((self.downloaded as f64 / total as f64) * 100.0).min(100.0);
+ let pos = ((self.downloaded as usize * self.width) / total as usize).min(self.width);
+ let runner = if (self.downloaded / 65536) % 2 == 0 { "R" } else { "r" };
+ let mut bar = String::new();
+ for i in 0..self.width {
+ if i < pos {
+ bar.push('═');
+ } else if i == pos {
+ bar.push_str("\x1b[1;36m");
+ bar.push_str(runner);
+ bar.push_str("\x1b[0m");
+ } else if i % 3 == 0 {
+ bar.push_str("\x1b[1;37mo\x1b[0m");
+ } else {
+ bar.push(' ');
+ }
+ }
+
+ eprint!(
+ "\r\x1b[K\x1b[1;34m[ror]\x1b[0m {} \x1b[36m[{}]\x1b[0m \x1b[32m{:>3.0}%\x1b[0m {:>8} / {:<8} \x1b[90m({})\x1b[0m",
+ self.name,
+ bar,
+ pct,
+ format_bytes(self.downloaded),
+ format_bytes(total),
+ speed
+ );
+ io::stderr().flush().ok();
+ return;
+ }
+ }
+
+ let pos = ((self.start_time.elapsed().as_millis() / 150) as usize) % self.width;
+ let runner = if (pos % 2) == 0 { "R" } else { "r" };
+ let mut bar = String::new();
+ for i in 0..self.width {
+ if i < pos {
+ bar.push('═');
+ } else if i == pos {
+ bar.push_str("\x1b[1;36m");
+ bar.push_str(runner);
+ bar.push_str("\x1b[0m");
+ } else if i % 3 == 0 {
+ bar.push_str("\x1b[1;37mo\x1b[0m");
+ } else {
+ bar.push(' ');
+ }
+ }
+
+ eprint!(
+ "\r\x1b[K\x1b[1;34m[ror]\x1b[0m {} \x1b[36m[{}]\x1b[0m {:>8} downloaded \x1b[90m({})\x1b[0m",
+ self.name,
+ bar,
+ format_bytes(self.downloaded),
+ speed
+ );
+ io::stderr().flush().ok();
+ }
+
+ pub fn finish(&self) {
+ let elapsed = self.start_time.elapsed().as_secs_f64();
+ let speed = if elapsed > 0.05 {
+ format!("{}/s", format_bytes((self.downloaded as f64 / elapsed) as u64))
+ } else {
+ String::new()
+ };
+ eprintln!(
+ "\r\x1b[K\x1b[1;32m[ror] ✓\x1b[0m Downloaded {} ({}{})",
+ self.name,
+ format_bytes(self.downloaded),
+ if speed.is_empty() { String::new() } else { format!(", {}", speed) }
+ );
+ }
+}
diff --git a/src/rootfs.rs b/src/rootfs.rs
index 46025d0..8da1b90 100644
--- a/src/rootfs.rs
+++ b/src/rootfs.rs
@@ -1,28 +1,19 @@
-use std::collections::HashMap;
-use crate::debug;
+use std::collections::{HashMap, HashSet, VecDeque};
use std::fs;
+use std::io::{Read, Write};
use std::path::Path;
-use std::os::unix::fs::symlink;
use std::sync::{Arc, Mutex};
-use std::sync::atomic::{AtomicU64, AtomicBool, Ordering};
+use std::sync::atomic::{AtomicBool, AtomicU64, Ordering};
use std::thread;
use colored::Colorize;
+use chrono::Local;
use crate::config;
use crate::progress::ProgressBar;
-use chrono::Local;
use crate::install::{
Dependency, load_package,
extract_native, extract_ror, extract_sror, extract_deb, install_files_to_root, select_binary_for_arch,
InstalledDB, InstalledPackage, resolve_filename, install_services_to_root,
};
-use nix::mount::{mount, umount2, MntFlags, MsFlags};
-use nix::unistd::{chroot, chdir, fork, ForkResult, execve};
-use nix::sys::wait::{waitpid, WaitStatus};
-use std::io::{Read, Write};
-use std::ffi::CString;
-use std::ffi::CStr;
-use std::collections::HashSet;
-use std::collections::VecDeque;
struct DownloadTask {
pkg_name: String,
@@ -371,424 +362,6 @@ fn install_from_archive(
Ok(installed)
}
-fn setup_usr_merge(target_dir: &Path, target_libc: &str) -> Result<(), String> {
- let is_musl = target_libc == "musl";
-
- let root_dirs: &[&str] = if is_musl {
- &["bin", "lib", "sbin"]
- } else {
- &["bin", "lib", "lib64", "sbin"]
- };
-
- for dir in root_dirs {
- let path = target_dir.join(dir);
- if path.symlink_metadata().is_ok() {
- if path.is_dir() && !path.is_symlink() {
- fs::remove_dir_all(&path)
- .map_err(|e| format!("Failed to remove directory {}: {}", dir, e))?;
- } else {
- fs::remove_file(&path)
- .map_err(|e| format!("Failed to remove {}: {}", dir, e))?;
- }
- }
- }
-
- fs::create_dir_all(target_dir.join("usr/bin"))
- .map_err(|e| format!("Failed to create usr/bin: {}", e))?;
- fs::create_dir_all(target_dir.join("usr/lib"))
- .map_err(|e| format!("Failed to create usr/lib: {}", e))?;
- if !is_musl {
- fs::create_dir_all(target_dir.join("usr/lib64"))
- .map_err(|e| format!("Failed to create usr/lib64: {}", e))?;
- }
-
- let usr_sbin = target_dir.join("usr/sbin");
- if usr_sbin.exists() || usr_sbin.is_symlink() {
- let _ = fs::remove_file(&usr_sbin);
- }
- symlink("bin", &usr_sbin)
- .map_err(|e| format!("Failed to create symlink usr/sbin -> bin: {}", e))?;
-
- if is_musl {
- symlink("usr/bin", target_dir.join("bin"))
- .map_err(|e| format!("Failed to create symlink bin -> usr/bin: {}", e))?;
- symlink("usr/lib", target_dir.join("lib"))
- .map_err(|e| format!("Failed to create symlink lib -> usr/lib: {}", e))?;
- symlink("usr/bin", target_dir.join("sbin"))
- .map_err(|e| format!("Failed to create symlink sbin -> usr/bin: {}", e))?;
- } else {
- symlink("usr/bin", target_dir.join("bin"))
- .map_err(|e| format!("Failed to create symlink bin -> usr/bin: {}", e))?;
- symlink("usr/lib", target_dir.join("lib"))
- .map_err(|e| format!("Failed to create symlink lib -> usr/lib: {}", e))?;
- symlink("usr/lib64", target_dir.join("lib64"))
- .map_err(|e| format!("Failed to create symlink lib64 -> usr/lib64: {}", e))?;
- symlink("usr/bin", target_dir.join("sbin"))
- .map_err(|e| format!("Failed to create symlink sbin -> usr/bin: {}", e))?;
- }
-
- Ok(())
-}
-
-fn fix_usr_merge(target_dir: &Path, target_libc: &str) -> Result<(), String> {
- let is_musl = target_libc == "musl";
-
- let root_links: &[&str] = if is_musl {
- &["bin", "lib", "sbin"]
- } else {
- &["bin", "lib", "lib64", "sbin"]
- };
-
- for link in root_links {
- let path = target_dir.join(link);
- if path.exists() || path.is_symlink() {
- let _ = fs::remove_file(&path);
- }
- }
-
- let usr_sbin = target_dir.join("usr/sbin");
- if usr_sbin.exists() || usr_sbin.is_symlink() {
- let _ = fs::remove_file(&usr_sbin);
- }
-
- let usr_bin = target_dir.join("usr/bin");
- if !usr_bin.exists() {
- fs::create_dir_all(&usr_bin).map_err(|e| e.to_string())?;
- }
-
- symlink("bin", &usr_sbin).map_err(|e| e.to_string())?;
-
- if is_musl {
- symlink("usr/bin", target_dir.join("bin")).map_err(|e| e.to_string())?;
- symlink("usr/lib", target_dir.join("lib")).map_err(|e| e.to_string())?;
- symlink("usr/bin", target_dir.join("sbin")).map_err(|e| e.to_string())?;
- } else {
- symlink("usr/bin", target_dir.join("bin")).map_err(|e| e.to_string())?;
- symlink("usr/lib", target_dir.join("lib")).map_err(|e| e.to_string())?;
- symlink("usr/lib64", target_dir.join("lib64")).map_err(|e| e.to_string())?;
- symlink("usr/bin", target_dir.join("sbin")).map_err(|e| e.to_string())?;
- }
-
- Ok(())
-}
-
-fn create_fhs_skeleton(target_dir: &Path) -> Result<(), String> {
- use std::os::unix::fs::PermissionsExt;
-
- let dirs = &[
- "boot", "dev", "dev/pts", "dev/shm", "etc", "etc/ror",
- "home", "mnt", "opt", "proc", "root", "run", "srv", "sys",
- "tmp", "usr/include", "usr/local/bin", "usr/local/lib",
- "usr/local/share", "usr/share", "usr/share/doc",
- "var", "var/cache", "var/empty", "var/lib", "var/lock",
- "var/log", "var/run", "var/spool", "var/tmp",
- ];
-
- for dir in dirs {
- fs::create_dir_all(target_dir.join(dir))
- .map_err(|e| format!("Failed to create FHS dir {}: {}", dir, e))?;
- }
-
- for dir in &["tmp", "var/tmp"] {
- fs::set_permissions(target_dir.join(dir), fs::Permissions::from_mode(0o1777))
- .map_err(|e| format!("Failed to set sticky bit on {}: {}", dir, e))?;
- }
-
- for dir in &["root", "var/empty"] {
- fs::set_permissions(target_dir.join(dir), fs::Permissions::from_mode(0o700))
- .map_err(|e| format!("Failed to set permissions on {}: {}", dir, e))?;
- }
-
- Ok(())
-}
-
-fn mount_virtual_fs(root_dir: &Path) -> Result<(), String> {
- let mounts: &[(&str, &str, &str, bool)] = &[
- ("/dev", "dev", "devtmpfs", true),
- ("/dev/pts", "dev/pts", "devpts", true),
- ("/dev/shm", "dev/shm", "tmpfs", true),
- ("proc", "proc", "proc", false),
- ("sysfs", "sys", "sysfs", false),
- ];
- for (src, rel, fstype, bind) in mounts {
- let target = root_dir.join(rel);
- fs::create_dir_all(&target)
- .map_err(|e| format!("Failed to create mountpoint {}: {}", rel, e))?;
-
- if *bind {
- mount(
- Some(Path::new(src)),
- &target,
- None::<&str>,
- MsFlags::MS_BIND | MsFlags::MS_REC,
- None::<&Path>,
- )
- .map_err(|e| format!("Failed to bind mount {}: {}", rel, e))?;
-
- let _ = mount(
- None::<&Path>,
- &target,
- None::<&str>,
- MsFlags::MS_PRIVATE | MsFlags::MS_REC,
- None::<&Path>,
- );
- } else {
- mount(
- Some(Path::new(src)),
- &target,
- Some(*fstype),
- MsFlags::empty(),
- None::<&Path>,
- )
- .map_err(|e| format!("Failed to mount {}: {}", rel, e))?;
- }
- }
- Ok(())
-}
-
-fn umount_virtual_fs(root_dir: &Path) {
- for rel in &["dev/pts", "dev/shm", "dev", "proc", "sys"] {
- let target = root_dir.join(rel);
- if target.exists() {
- let _ = umount2(&target, MntFlags::MNT_DETACH);
- }
- }
-}
-
-const SHELL_CANDIDATES: &[(&str, Option<&str>)] = &[
- ("/bin/sh", None),
- ("/usr/bin/sh", None),
- ("/bin/dash", None),
- ("/usr/bin/dash", None),
- ("/bin/bash", None),
- ("/usr/bin/bash", None),
- ("/bin/busybox", Some("sh")),
- ("/usr/bin/busybox", Some("sh")),
- ("/bin/toybox", Some("sh")),
- ("/bin/ash", None),
- ("/usr/bin/ash", None),
-];
-
-fn find_working_shell(root_dir: &Path) -> Option<(&'static str, Option<&'static str>)> {
- for (shell_path, subcmd) in SHELL_CANDIDATES {
- let full = root_dir.join(shell_path.trim_start_matches('/'));
- if !full.exists() {
- continue;
- }
- let test_script = "exit 0";
- let script_path = root_dir.join(".ror-shell-test.sh");
- if fs::write(&script_path, format!("#!/bin/sh\n{}", test_script)).is_err() {
- continue;
- }
- match unsafe { fork() } {
- Ok(ForkResult::Child) => {
- if chroot(root_dir).is_err() { std::process::exit(1); }
- if chdir("/").is_err() { std::process::exit(1); }
- let shell_c = CString::new(*shell_path).unwrap();
- let arg0 = CString::new(*shell_path).unwrap();
- let args = if let Some(sub) = subcmd {
- let sub_c = CString::new(*sub).unwrap();
- let script_c = CString::new(".ror-shell-test.sh").unwrap();
- vec![arg0, sub_c, script_c]
- } else {
- let script_c = CString::new(".ror-shell-test.sh").unwrap();
- vec![arg0, script_c]
- };
- let args_refs: Vec<&CStr> = args.iter().map(|s| s.as_c_str()).collect();
- let env_c = [
- CString::new("PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin").unwrap(),
- CString::new("HOME=/root").unwrap(),
- CString::new("TERM=xterm").unwrap(),
- ];
- let env_refs: Vec<&CStr> = env_c.iter().map(|s| s.as_c_str()).collect();
- let _ = execve::<&CStr, &CStr>(&shell_c, &args_refs, &env_refs);
- std::process::exit(1);
- }
- Ok(ForkResult::Parent { child }) => {
- match waitpid(child, None) {
- Ok(WaitStatus::Exited(_, 0)) => {
- let _ = fs::remove_file(&script_path);
- return Some((*shell_path, *subcmd));
- }
- Ok(_) => {
- let _ = fs::remove_file(&script_path);
- }
- Err(_) => {
- let _ = fs::remove_file(&script_path);
- }
- }
- }
- Err(_) => { let _ = fs::remove_file(&script_path); }
- }
- }
- None
-}
-
-fn run_install_steps_in_chroot(
- _pkg_name: &str,
- steps: &str,
- root_dir: &Path,
- shell: &str,
- subcmd: Option<&str>,
-) -> Result<(), String> {
- let script_rel = "/.ror-install-steps.sh";
- let script_host = root_dir.join(script_rel.trim_start_matches('/'));
- fs::write(&script_host, format!("#!/bin/sh\nset -e\n{}", steps))
- .map_err(|e| format!("Failed to write script: {}", e))?;
-
- match unsafe { fork() } {
- Ok(ForkResult::Child) => {
- if chroot(root_dir).is_err() { std::process::exit(1); }
- if chdir("/").is_err() { std::process::exit(1); }
- let shell_c = CString::new(shell).unwrap();
- let arg0 = CString::new(shell).unwrap();
- let script_c = CString::new(script_rel).unwrap();
- let args = if let Some(sub) = subcmd {
- let sub_c = CString::new(sub).unwrap();
- vec![arg0, sub_c, script_c]
- } else {
- vec![arg0, script_c]
- };
- let args_refs: Vec<&CStr> = args.iter().map(|s| s.as_c_str()).collect();
- let env_c = [
- CString::new("PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin").unwrap(),
- CString::new("HOME=/root").unwrap(),
- CString::new("TERM=xterm").unwrap(),
- CString::new("USER=root").unwrap(),
- ];
- let env_refs: Vec<&CStr> = env_c.iter().map(|s| s.as_c_str()).collect();
- let _ = execve::<&CStr, &CStr>(&shell_c, &args_refs, &env_refs);
- std::process::exit(1);
- }
- Ok(ForkResult::Parent { child }) => {
- match waitpid(child, None) {
- Ok(WaitStatus::Exited(_, code)) => {
- let _ = fs::remove_file(&script_host);
- if code == 0 {
- Ok(())
- } else {
- Err(format!("install_steps failed with exit code {}", code))
- }
- }
- Ok(_) => {
- let _ = fs::remove_file(&script_host);
- Err("install_steps terminated by signal".to_string())
- }
- Err(e) => {
- let _ = fs::remove_file(&script_host);
- Err(format!("waitpid failed: {}", e))
- }
- }
- }
- Err(e) => {
- let _ = fs::remove_file(&script_host);
- Err(format!("Fork failed: {}", e))
- }
- }
-}
-
-fn run_ldconfig_in_root(root_dir: &Path) -> Result<(), String> {
- let status = std::process::Command::new("ldconfig")
- .arg("-r")
- .arg(root_dir)
- .arg("-C")
- .arg("/etc/ld.so.cache")
- .status();
- if let Ok(s) = status {
- if s.success() {
- debug!("Host ldconfig -r generated /etc/ld.so.cache successfully");
- return Ok(());
- }
- }
-
- let ldconfig_path = if root_dir.join("sbin/ldconfig").exists() {
- "/sbin/ldconfig"
- } else if root_dir.join("usr/sbin/ldconfig").exists() {
- "/usr/sbin/ldconfig"
- } else {
- return Err("No ldconfig available".to_string());
- };
-
- match unsafe { fork() } {
- Ok(ForkResult::Child) => {
- if chroot(root_dir).is_err() { std::process::exit(1); }
- if chdir("/").is_err() { std::process::exit(1); }
- let ldconfig = CString::new(ldconfig_path).unwrap();
- let arg0 = CString::new("ldconfig").unwrap();
- let env_c = [
- CString::new("PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin").unwrap(),
- ];
- let env_refs: Vec<&CStr> = env_c.iter().map(|s| s.as_c_str()).collect();
- let _ = execve::<&CStr, &CStr>(&ldconfig, &[&arg0], &env_refs);
- std::process::exit(1);
- }
- Ok(ForkResult::Parent { child }) => {
- match waitpid(child, None) {
- Ok(WaitStatus::Exited(_, 0)) => Ok(()),
- Ok(_) => Err("ldconfig terminated abnormally".to_string()),
- Err(e) => Err(format!("waitpid ldconfig failed: {}", e)),
- }
- }
- Err(e) => Err(format!("Fork for ldconfig failed: {}", e)),
- }
-}
-
-fn run_all_install_steps(
- group_order: &[String],
- all_installed: &HashSet<String>,
- target_dir: &Path,
-) -> Result<(), String> {
- let mut done: HashSet<String> = HashSet::new();
- let mut queue: Vec<&str> = group_order.iter().map(|s| s.as_str()).collect();
-
- let mut extras: Vec<String> = all_installed.iter()
- .filter(|p| !group_order.contains(p))
- .cloned()
- .collect();
- extras.sort();
- for e in &extras {
- queue.push(e.as_str());
- }
-
- let steps_pkgs: Vec<String> = queue.iter()
- .filter(|&&pkg_name| {
- all_installed.contains(pkg_name) &&
- load_package(pkg_name).map(|p| !p.install_steps.trim().is_empty()).unwrap_or(false)
- })
- .map(|s| s.to_string())
- .collect();
-
- if steps_pkgs.is_empty() {
- return Ok(());
- }
-
- let mut pb = ProgressBar::new(steps_pkgs.len().max(1), "Running install steps...");
-
- let (shell, subcmd) = find_working_shell(target_dir)
- .ok_or_else(|| "No working shell found in rootfs. Tried: sh, dash, bash, busybox, ash".to_string())?;
-
- println!("{} Using shell: {}{}", ">>>".cyan(), shell,
- subcmd.map(|s| format!(" {}", s)).unwrap_or_default());
-
- for pkg_name in queue {
- if done.contains(pkg_name) || !all_installed.contains(pkg_name) {
- continue;
- }
- done.insert(pkg_name.to_string());
-
- if let Some(pkg) = load_package(pkg_name) {
- if !pkg.install_steps.trim().is_empty() {
- pb.inc(&format!("install_steps: {}", pkg_name));
- eprintln!();
- run_install_steps_in_chroot(pkg_name, &pkg.install_steps, target_dir, shell, subcmd)?;
- pb.render();
- }
- }
- }
- pb.finish("All install steps done");
- Ok(())
-}
-
fn write_installed_json(
target_dir: &Path,
packages: &[String],
@@ -841,7 +414,7 @@ fn generate_system_yaml(target_dir: &Path, group: &crate::group::Group) -> Resul
let mut role_udev: Option<String> = None;
let mut role_sh: Vec<String> = Vec::new();
let mut role_su: Vec<String> = Vec::new();
- let mut role_pkgs: std::collections::HashSet<String> = std::collections::HashSet::new();
+ let mut role_pkgs: HashSet<String> = HashSet::new();
for spec in &group.packages {
let (pkg_name, _) = crate::install::parse_package_spec(spec);
@@ -874,13 +447,8 @@ fn generate_system_yaml(target_dir: &Path, group: &crate::group::Group) -> Resul
if role_libc.is_none() {
if let Some(libc_name) = &group.libc {
- let libc_pkg = match libc_name.as_str() {
- "musl" => "musl",
- "glibc" => "glibc",
- other => other,
- };
- role_libc = Some(libc_pkg.to_string());
- role_pkgs.insert(libc_pkg.to_string());
+ role_libc = Some(libc_name.clone());
+ role_pkgs.insert(libc_name.clone());
}
}
@@ -950,7 +518,6 @@ pub fn build_rootfs(
target_dir: &Path,
cfg: &config::Config,
target_arch: &str,
- run_ldconfig: bool,
) -> Result<(), String> {
if !target_dir.exists() {
fs::create_dir_all(target_dir)
@@ -964,22 +531,9 @@ pub fn build_rootfs(
}
let group = crate::group::load_group(group_name)?;
- let mut start_packages = group.packages.clone();
-
+ let start_packages = group.packages.clone();
let target_libc: String = group.libc.clone().unwrap_or_else(|| cfg.global.libc.clone());
- if let Some(libc_name) = &group.libc {
- let libc_pkg = match libc_name.as_str() {
- "musl" => "musl",
- "glibc" => "glibc",
- other => other,
- };
- if !start_packages.contains(&libc_pkg.to_string()) {
- start_packages.push(libc_pkg.to_string());
- println!("{} Adding libc package: {}", ">>>".cyan(), libc_pkg);
- }
- }
-
println!(
"{} Building rootfs in {}",
"[ror]".blue().bold(),
@@ -989,19 +543,11 @@ pub fn build_rootfs(
println!("{} {}", "Description:".yellow(), desc);
}
- println!("\n{} Phase 0: UsrMerge...", ">>>".cyan().bold());
- setup_usr_merge(target_dir, &target_libc)?;
- println!("{} bin/lib/lib64/sbin are now symlinks into usr/", ">>>".green());
-
- println!("{} Creating FHS skeleton...", ">>>".cyan());
- create_fhs_skeleton(target_dir)?;
- println!("{} FHS skeleton created.", ">>>".green());
-
- println!("\n{} Phase 1a: Resolving packages...", ">>>".cyan().bold());
+ println!("\n{} Phase 1: Resolving packages...", ">>>".cyan().bold());
let all_packages = collect_install_order(&start_packages, &target_libc)?;
println!("{} {} packages to install (including dependencies)", ">>>".green(), all_packages.len());
- println!("\n{} Phase 1b: Building download queue...", ">>>".cyan().bold());
+ println!("\n{} Phase 2: Building download queue...", ">>>".cyan().bold());
let tasks = build_download_tasks(&all_packages, target_arch, &target_libc, cfg)?;
let n_parallel = cfg.global.parallel_downloads.max(1);
@@ -1009,7 +555,7 @@ pub fn build_rootfs(
let downloaded = download_parallel(tasks, cfg_arc, n_parallel)?;
println!("{} All downloads complete.", ">>>".green().bold());
- println!("\n{} Phase 1c: Installing files...", ">>>".cyan().bold());
+ println!("\n{} Phase 3: Installing files...", ">>>".cyan().bold());
let mut installing: HashSet<String> = HashSet::new();
let mut installed_files_map: HashMap<String, Vec<String>> = HashMap::new();
let mut pb = ProgressBar::new(all_packages.len().max(1), "Installing...");
@@ -1039,8 +585,6 @@ pub fn build_rootfs(
}
pb.finish(&format!("{} packages installed", installing.len()));
- fix_usr_merge(target_dir, &target_libc)?;
-
println!("\n{} Writing installed.json...", ">>>".cyan());
write_installed_json(target_dir, &all_packages, &installed_files_map, &group, &target_libc)?;
println!("{} installed.json written to etc/ror/", ">>>".green());
@@ -1057,59 +601,6 @@ pub fn build_rootfs(
generate_system_yaml(target_dir, &group)?;
println!("{} system.yaml written to etc/ror/", ">>>".green());
- if run_ldconfig && target_libc != "musl" {
- println!("{} Running ldconfig...", ">>>".cyan());
- let ld_conf = target_dir.join("etc/ld.so.conf");
- if !ld_conf.exists() {
- let _ = fs::write(&ld_conf, "/usr/lib\n/usr/lib64\n");
- }
- if let Err(e) = run_ldconfig_in_root(target_dir) {
- eprintln!("{} ldconfig failed: {} (non-fatal)", "[ror]".yellow(), e);
- } else {
- println!("{} ldconfig done.", ">>>".green());
- }
- }
-
- println!("\n{} Phase 2: Running install_steps in chroot...", ">>>".cyan().bold());
- println!("{} Mounting /dev /proc /sys...", ">>>".cyan());
- if let Err(e) = mount_virtual_fs(target_dir) {
- eprintln!("{} Warning: Failed to mount virtual fs: {} (continuing anyway)", "[ror]".yellow(), e);
- }
-
- let result = run_all_install_steps(&group.packages, &installing, target_dir);
-
- if result.is_ok() && !group.install_steps.trim().is_empty() {
- println!("{} Running group install_steps in chroot...", ">>>".cyan());
- let shell_result = find_working_shell(target_dir)
- .ok_or_else(|| "No working shell found for group install_steps".to_string());
- match shell_result {
- Ok((shell, subcmd)) => {
- if let Err(e) = run_install_steps_in_chroot(
- &group.name,
- &group.install_steps,
- target_dir,
- shell,
- subcmd,
- ) {
- println!("{} Unmounting virtual filesystems...", ">>>".cyan());
- umount_virtual_fs(target_dir);
- return Err(e);
- }
- println!("{} Group install_steps done.", ">>>".green());
- }
- Err(e) => {
- println!("{} Unmounting virtual filesystems...", ">>>".cyan());
- umount_virtual_fs(target_dir);
- return Err(e);
- }
- }
- }
-
- println!("{} Unmounting virtual filesystems...", ">>>".cyan());
- umount_virtual_fs(target_dir);
-
- result?;
-
println!(
"\n{} Rootfs built successfully at {} ",
"[ror]".green().bold(),