commit e69e26f086113f49a2099ab2117d3d5026d456a7
Author: emmett1 <emmett1.2miligrams@protonmail.com>
Date: Sun, 7 Sep 2025 10:54:17 +0800
fix usage message
Diffstat:
A | INSTALL.sh | | | 11 | +++++++++++ |
A | LICENSE | | | 674 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
A | README.md | | | 2 | ++ |
A | apkg | | | 1041 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
A | apkg-bin | | | 232 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
A | apkg-chroot | | | 105 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
A | apkg-clean | | | 85 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
A | apkg-deps | | | 29 | +++++++++++++++++++++++++++++ |
A | apkg-foreign | | | 10 | ++++++++++ |
A | apkg-genabuild | | | 65 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
A | apkg-orphan | | | 18 | ++++++++++++++++++ |
A | apkg-outdated | | | 32 | ++++++++++++++++++++++++++++++++ |
A | apkg-purge | | | 60 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
A | apkg-redundantdeps | | | 47 | +++++++++++++++++++++++++++++++++++++++++++++++ |
A | apkg-reposync | | | 73 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
A | doc/abuild.readme | | | 100 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
A | doc/apkg.conf.readme | | | 56 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
A | doc/defaultbuildopts | | | 87 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
A | doc/postinstall.readme | | | 3 | +++ |
A | doc/preinstall.readme | | | 3 | +++ |
A | doc/readme | | | 34 | ++++++++++++++++++++++++++++++++++ |
A | man/apkg.conf.md | | | 45 | +++++++++++++++++++++++++++++++++++++++++++++ |
A | man/apkg.md | | | 72 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
A | man/make-man.sh | | | 32 | ++++++++++++++++++++++++++++++++ |
A | man/man5/apkg.conf.5 | | | 86 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
A | man/man8/apkg.8 | | | 181 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
A | man/man8/revdep.8 | | | 34 | ++++++++++++++++++++++++++++++++++ |
A | man/revdep.md | | | 29 | +++++++++++++++++++++++++++++ |
A | reposync | | | 98 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
A | revdep | | | 63 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
A | updateconf | | | 64 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
31 files changed, 3471 insertions(+), 0 deletions(-)
diff --git a/INSTALL.sh b/INSTALL.sh
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+BINDIR=${DESTDIR}${BINDIR:-/usr/bin}
+CONFDIR=${DESTDIR}${CONFDIR:-/etc}
+
+mkdir -p ${BINDIR} ${CONFDIR}
+
+install -m755 apkg ${BINDIR}
+install -m755 apkg-* ${BINDIR}
+install -m755 revdep updateconf reposync ${BINDIR}
+install -m644 doc/apkg.conf.readme ${CONFDIR}/apkg.conf
diff --git a/LICENSE b/LICENSE
@@ -0,0 +1,674 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 3, 29 June 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 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.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 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 <https://www.gnu.org/licenses/>.
+
+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:
+
+ <program> Copyright (C) <year> <name of author>
+ 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
+<https://www.gnu.org/licenses/>.
+
+ 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
+<https://www.gnu.org/licenses/why-not-lgpl.html>.
diff --git a/README.md b/README.md
@@ -0,0 +1,2 @@
+# autils
+Alice Linux Utilities
diff --git a/apkg b/apkg
@@ -0,0 +1,1041 @@
+#!/bin/sh
+# ______ ______ __ __ ______
+# /\ __ \ /\ == \/\ \/ / /\ ___\
+# \ \ __ \\ \ _-/\ \ _"-.\ \ \__ \
+# \ \_\ \_\\ \_\ \ \_\ \_\\ \_____\
+# \/_/\/_/ \/_/ \/_/\/_/ \/_____/
+#
+# APKG - Alice Package Manager (C) 2023-2025 Emmett1
+#
+
+fetch_src() {
+ [ "$source" ] || return 0
+ for i in $source; do
+ i=${i%::noextract}
+ case $i in
+ *::*) sn=${i%::*};;
+ *) sn=${i##*/};;
+ esac
+ case ${i#*::} in
+ http://*|https://*|ftp://*)
+ if [ ! -f $APKG_SOURCE_DIR/$sn ]; then
+ [ -f $APKG_SOURCE_DIR/$sn.tmp ] && resume="-C -"
+ msg "fetching ${i#*::}"
+ curl $resume --fail --retry 3 --retry-delay 3 -L -o $APKG_SOURCE_DIR/$sn.tmp ${i#*::} || {
+ msg "Failed downloading source '$sn'."
+ exit 1
+ }
+ mv $APKG_SOURCE_DIR/$sn.tmp $APKG_SOURCE_DIR/$sn
+ fi;;
+ esac
+ done
+}
+
+extract_src() {
+ prepare_workdir
+ [ "$source" ] || return 0
+ checksource
+ for i in $source; do
+ case $i in
+ */*) S=$APKG_SOURCE_DIR;;
+ *) S=$HERE;;
+ esac
+ case ${i%::noextract} in
+ *::*) sn=${i%%::*};;
+ *) sn=${i##*/}; sn=${sn%::noextract};;
+ esac
+ case $i in
+ *::noextract)
+ i=${i%::noextract}
+ cp $S/$sn $SRC || {
+ msg "Failed copy '$S/$sn' to '$SRC'."
+ ret 1
+ };;
+ *.tar.bz2|*.tar.gz|*.tar.lz|*.tar.lzma|*.tar.lzo|*.tar.xz|*.tar.Z|*.tb2|*.tbz|*.tbz2|*.tz2|*.taz|*.tgz|*.tlz|*.txz|*.tZ|*.taZ)
+ msg "Unpacking '$S/$sn'..."
+ tar -p -o -C $SRC -xf $S/$sn || {
+ msg "Failed unpacking source '${i##*/}'."
+ ret 1
+ };;
+ *)
+ i=${i%::noextract}
+ cp $S/$sn $SRC || {
+ msg "Failed copy '$S/$sn' to '$SRC'."
+ ret 1
+ };;
+ esac
+ done
+}
+
+prepare_workdir() {
+ export SRC=$APKG_WORK_DIR/apkg-src-${PWD##*/}
+ export PKG=$APKG_WORK_DIR/apkg-pkg-${PWD##*/}
+
+ remove_workdir
+ mkdir -p "$PKG" "$SRC"
+}
+
+remove_workdir() {
+ rm -rf "$PKG" "$SRC"
+}
+
+ret() {
+ [ "$APKG_KEEP_WORKDIR" ] || remove_workdir
+ exit $1
+}
+
+detect_buildtype() {
+ if [ -f meson.build ]; then
+ build_type=meson_build
+ elif [ -f configure ]; then
+ build_type=configure_build
+ elif [ -f CMakeLists.txt ]; then
+ build_type=cmake_build
+ elif [ -f setup.py ]; then
+ build_type=python_build
+ elif [ -f Makefile.PL ]; then
+ build_type=perlmodule_build
+ elif [ -f Makefile ] || [ -f makefile ] || [ -f GNUmakefile ]; then
+ build_type=makefile_build
+ else
+ msg "failed to detect buildtype"
+ ret 1
+ fi
+}
+
+_makefile_build() {
+ make \
+ PREFIX=/usr \
+ prefix=/usr \
+ SYSCONFDIR=/etc \
+ sysconfdir=/etc \
+ MANDIR=/usr/share/man \
+ mandir=/usr/share/man \
+ LIBDIR=/usr/lib \
+ PKGCONFIGDIR=/usr/lib/pkgconfig
+ make \
+ PREFIX=/usr \
+ prefix=/usr \
+ SYSCONFDIR=/etc \
+ sysconfdir=/etc \
+ MANDIR=/usr/share/man \
+ mandir=/usr/share/man \
+ LIBDIR=/usr/lib \
+ PKGCONFIGDIR=/usr/lib/pkgconfig \
+ DESTDIR=$PKG install
+}
+
+_perlmodule_build() {
+ perl Makefile.PL
+ make
+ make DESTDIR=$PKG install
+}
+
+_cmake_build() {
+ mkdir -p cmakebuild
+ cd cmakebuild
+ cmake \
+ -DCMAKE_INSTALL_PREFIX=/usr \
+ -DCMAKE_INSTALL_SYSCONFDIR=/etc \
+ -DCMAKE_INSTALL_LIBDIR=lib \
+ -DCMAKE_BUILD_TYPE=Release \
+ -DFETCHCONTENT_FULLY_DISCONNECTED=ON \
+ -DCMAKE_C_FLAGS_RELEASE="$CFLAGS" \
+ -DCMAKE_CXX_FLAGS_RELEASE="$CXXFLAGS" \
+ $build_opt \
+ -B build ..
+ if [ -f build.ninja ]; then
+ ninja
+ DESTDIR=$PKG ninja install
+ else
+ cmake --build build
+ DESTDIR=$PKG cmake --install build
+ fi
+}
+
+_python_build() {
+ python3 setup.py build
+ python3 setup.py install --prefix=/usr --root=$PKG --optimize=1 $build_opt
+}
+
+_configure_build() {
+ ./configure \
+ --prefix=/usr \
+ --sysconfdir=/etc \
+ --localstatedir=/var \
+ --libdir=/usr/lib \
+ --infodir=/usr/share/info \
+ --mandir=/usr/share/man \
+ $build_opt
+ make
+ make DESTDIR=$PKG install
+}
+
+_meson_build() {
+ meson setup \
+ -Dprefix=/usr \
+ -Dlibdir=/usr/lib \
+ -Dincludedir=/usr/include \
+ -Ddatadir=/usr/share \
+ -Dmandir=/usr/share/man \
+ -Dinfodir=/usr/share/info \
+ -Dlocaledir=/usr/share/locale \
+ -Dsysconfdir=/etc \
+ -Dlocalstatedir=/var \
+ -Dsharedstatedir=/var/lib \
+ -Dbuildtype=plain \
+ -Dauto_features=auto \
+ -Dwrap_mode=nodownload \
+ -Db_lto=true \
+ -Db_pie=true \
+ $build_opt \
+ build
+ ninja -C build
+ DESTDIR=$PKG meson install -C build
+}
+
+apply_patch() {
+ [ "$skip_patch" ] && {
+ unset skip_patch # allowing manual patch in build() using apply_patch
+ return 0
+ }
+ if [ "$source" ]; then
+ for p in $source; do
+ case ${p%::noextract} in
+ *::*) pn=${p%::*};;
+ *) pn=${p##*/};;
+ esac
+ case $pn in
+ *.patch|*.diff)
+ msg "applying path '$SRC/$pn'."
+ patch ${patch_opt:--p1} -t -i $SRC/$pn || ret 1;;
+ esac
+ done
+ fi
+}
+
+msg() {
+ # Don't bother if we're not in a terminal
+ if [ -t 1 ]; then
+ ttysize=$(stty size 2>/dev/null | awk '{print $2}' || echo "80")
+ fi
+ printf "%s\n" "[${name:-...}] $@" | fold -sw ${ttysize:-80}
+}
+
+buildstatus() {
+ [ "$?" = 0 ] || {
+ msg "build package '$name-$version-$release' failed on '$1'."
+ ret 1
+ }
+}
+
+build_src() {
+ cd $SRC
+
+ if [ "$build_dir" ]; then
+ if [ ! -d "$build_dir" ]; then
+ msg "Source directory '$build_dir' not found."
+ ret 1
+ fi
+ elif [ -d $name-$version ]; then
+ build_dir=$name-$version
+ elif [ -d "$(ls -1 --group-directories-first | head -n1)" ]; then
+ build_dir=$(ls -1 --group-directories-first | head -n1)
+ fi
+
+ # cd into extracted source directory
+ if [ "$build_dir" ]; then
+ cd $build_dir
+ fi
+
+ apply_patch
+
+ export CARGO_HOME=${CARGO_HOME:-$SRC/.cargo}
+ export GOCACHE=${GOCACHE:-$SRC/.go}
+ export DESTDIR=$PKG
+ export DEST_DIR=$PKG # p7zip
+ export INSTALLROOT=$PKG # syslinux
+ export install_root=$PKG # glibc
+ export INSTALL_ROOT=$PKG # qt5
+
+ if [ ! "$source" ]; then
+ # dummy pkg
+ mkdir -p $PKG/usr
+ elif [ "$(command -v build)" ]; then
+ (set -e -x; build)
+ buildstatus build
+ else
+ if [ "$(command -v prebuild)" ]; then
+ (set -e -x; prebuild)
+ buildstatus prebuild
+ fi
+ if [ ! "${build_type}" ]; then
+ detect_buildtype
+ fi
+ (set -e -x; _${build_type})
+ buildstatus ${build_type}
+ if [ "$(command -v postbuild)" ]; then
+ (set -e -x; postbuild)
+ buildstatus postbuild
+ fi
+ fi
+
+ msg "build $name-$version-$release success"
+
+ # compress man pages
+ if [ -d $PKG/usr/share/man ]; then
+ # only keep man[1-8] man pages
+ for m in $PKG/usr/share/man/*; do
+ case ${m##*/} in
+ man[1-8]) continue;;
+ esac
+ rm -rf $m
+ done
+ for i in $(find $PKG/usr/share/man -type f); do
+ [ $i = ${i%%.gz} ] || continue
+ gzip -9 $i
+ done
+ for i in $(find $PKG/usr/share/man -type l) ; do
+ ln -s $(readlink $i).gz ${i%.gz}.gz
+ rm $i
+ done
+ fi
+
+ # compress info pages
+ if [ -d $PKG/usr/share/info ]; then
+ rm -f $PKG/usr/share/info/dir
+ find $PKG/usr/share/info -type f -exec gzip -9 {} \;
+ fi
+
+ # possible conflicts
+ find $PKG -name "fonts.dir" -exec rm {} \;
+ find $PKG -name "fonts.scale" -exec rm {} \;
+ find $PKG -name "perllocal.pod" -exec rm {} \;
+ find $PKG -name "charset.alias" -exec rm {} \;
+
+ if [ ! "$keep_static" ]; then
+ find $PKG -name "*.a" -exec rm {} \;
+ fi
+
+ if [ ! "$keep_libtool" ]; then
+ find $PKG -name "*.la" -exec rm {} \;
+ fi
+
+ if [ ! "$keep_locale" ]; then
+ rm -rf $PKG/usr/share/locale
+ rm -rf $PKG/usr/lib/locale
+ fi
+
+ if [ ! "$keep_doc" ]; then
+ rm -rf $PKG/usr/share/doc
+ rm -rf $PKG/usr/doc
+ fi
+
+ # strip binaries and libraries
+ if [ ! "$no_strip" ]; then
+ find $PKG | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs ${CROSS_COMPILE}strip --strip-all 2>/dev/null
+ find $PKG | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs ${CROSS_COMPILE}strip --strip-unneeded 2>/dev/null
+ find $PKG | xargs file | grep "current ar archive" | cut -f 1 -d : | xargs ${CROSS_COMPILE}strip --strip-debug 2>/dev/null
+ fi
+
+ # usrmerge
+ if [ "$APKG_BINMERGE" ]; then
+ for b in bin sbin usr/sbin; do
+ if [ -d $PKG/$b ]; then
+ mkdir -p $PKG/usr/bin
+ mv $PKG/$b/* $PKG/usr/bin
+ rm -rf $PKG/$b
+ fi
+ done
+ fi
+
+ # runit service
+ for s in $sv; do
+ [ -f $SRC/$s ] || ret 1
+ case $s in
+ run) install -Dm755 $SRC/$s $PKG/etc/sv/$name/run
+ ln -s ../../../run/runit/supervise.$name $PKG/etc/sv/$name/supervise;;
+ finish) install -Dm755 $SRC/$s $PKG/etc/sv/$name/finish;;
+ *.run) install -Dm755 $SRC/$s $PKG/etc/sv/${s%.*}/run
+ ln -s ../../../run/runit/supervise.${s%.*} $PKG/etc/sv/${s%.*}/supervise;;
+ *.finish) install -Dm755 $SRC/$s $PKG/etc/sv/${s%.*}/finish;;
+ *.*) install -Dm644 $SRC/$s $PKG/etc/sv/${s%%.*}/${s#*.};;
+ *) install -Dm644 $SRC/$s $PKG/etc/sv/$name/$s;;
+ esac
+ done
+
+ if [ ! "$(ls -1 $PKG)" ]; then
+ msg "\$PKG is empty"
+ ret 1
+ fi
+
+ # temporary: for backward compatibility
+ if [ "$(grep '#MARKER' /usr/bin/spm)" ]; then
+ cd $PKG
+ spm -b $packagefile || {
+ msg "Failed packaging $packagefile"
+ ret 1
+ }
+ else
+ cd $APKG_PACKAGE_DIR
+ spm -b $PKG && {
+ mv package.spm $packagefile
+ } || {
+ msg "Failed packaging $packagefile"
+ ret 1
+ }
+ fi
+
+ if [ ! -f "$HERE"/.files ] || [ "$HERE"/abuild -nt "$HERE"/.files ]; then
+ pkg_updatefiles
+ fi
+
+ cd $HERE
+ remove_workdir
+}
+
+pkg_updatefiles() {
+ if [ ! -f "$packagefile" ]; then
+ msg "Package '$packagefile' not found."
+ ret 1
+ fi
+ msg "filelist updated."
+ tar -tvf $packagefile | awk '{$3=$4=$5=""; print $0}' | sort -k 3 > "$HERE"/.files
+}
+
+pkg_path() {
+ for p in $@; do
+ for r in $APKG_REPO; do
+ [ -f $r/$p/abuild ] && {
+ printf "%s\n" $r/$p
+ break
+ }
+ done
+ done
+}
+
+die() {
+ [ "$1" ] && printf "%s\n" "error: $1"
+ ret 1
+}
+
+checkdep() {
+ [ "$(pkg_path $1)" ] || return
+ # track processed pkg to avoid cycle deps
+ process="$process $1"
+ for ii in $(pkg_depends $1); do
+ # if already installed, skip
+ if [ "$skip_installed" ]; then
+ [ -s $SPM_PKGDB/$ii ] && continue
+ fi
+ # if deps already in process list, skip, cycle deps detected
+ printf "%s\n" $process | tr ' ' '\n' | grep -qx $ii && continue
+ # skip if itself in depends list
+ [ "$ii" = "$1" ] && continue
+ # skip if pkg already in deps list
+ printf "%s\n" $DEPS | tr ' ' '\n' | grep -x $ii && continue
+ # check deps
+ checkdep $ii
+ done
+ # will go here if no deps anymore to check, add it to list deps
+ DEPS="$DEPS $1"
+}
+
+pkg_deplist() {
+ for i in $@; do
+ # if already have in list deps, dont check again
+ if [ ! $(printf "%s\n" $DEPS | tr ' ' '\n' | grep -x $i) ]; then
+ checkdep $i
+ fi
+ done
+ printf "%s\n" $DEPS | tr ' ' '\n'
+}
+
+pkg_fsearch() {
+ for r in $APKG_REPO; do
+ rr="$rr $r/*/.files"
+ done
+ grep $1 $rr 2>/dev/null | tr ':' ' ' | awk '{print $1,$4}' | sed 's,/.files,,g'
+}
+
+pkg_dependents() {
+ for r in $APKG_REPO; do
+ rr="$rr $r/*/depends"
+ done
+ grep -x $1 $rr 2>/dev/null | rev | cut -d / -f 2 | rev
+}
+
+pkg_depends() {
+ _path=$(pkg_path $1) || return 1
+ [ -s $_path/depends ] || return
+ solve_alias $(grep -Ev ^'(#|$)' $_path/depends | awk '{print $1}')
+}
+
+solve_alias() {
+ [ "$APKG_ALIAS" ] || {
+ printf "%s\n" $@
+ return
+ }
+ while [ "$1" ]; do
+ d=$(printf "%s\n" $APKG_ALIAS | tr ' ' '\n' | grep ^$1:* | head -n1 | awk -F : '{print $2}')
+ printf "%s\n" ${d:-$1}
+ shift
+ done
+}
+
+pkg_outdate() {
+ verbose=1 pkg_allinstalled | while read -r n v; do
+ [ "$APKG_MASK" ] && {
+ printf "%s\n" "$APKG_MASK" | tr ' ' '\n' | grep -xq $n && continue
+ }
+ [ "$(pkg_path $n)" ] || continue
+ nv="$(grep ^version= $(pkg_path $n)/abuild | tail -n1 | awk -F = '{print $2}')-$(grep ^release= $(pkg_path $n)/abuild | awk -F = '{print $2}')"
+ [ "$nv" ] || continue
+ [ "$v" = "$nv" ] || printf "%s\n" "$n $v -> $nv"
+ done
+}
+
+pkg_remove() {
+ needroot
+ for i in $@; do
+ SPM_ROOT=$APKG_ROOT spm -r $i
+ done
+}
+
+pkg_sysup() {
+ needroot
+ msg "Checking for outdated packages..."
+ od=$(pkg_outdate | awk '{print $1}')
+ if [ ! "$od" ]; then
+ msg "No outdated packages."
+ exit 0
+ else
+ msg "Solving dependencies..."
+ for p in $(pkg_deplist $od); do
+ [ -s $SPM_PKGDB/$p ] || ni="$ni $p"
+ printf "%s\n" $od | tr ' ' '\n' | grep -qx $p && pu="$pu $p"
+ done
+ if [ "$ni" ]; then
+ newpkg=$(printf "%s\n" $ni | tr ' ' '\n' | wc -l)
+ msg "Installing $newpkg new package(s): $ni"
+ fi
+ totalpkg=$(printf "%s\n" $pu | tr ' ' '\n' | wc -l)
+ msg "Upgrading $totalpkg package(s): $pu"
+ prompt_user
+ if [ "$ni" ]; then
+ $APKG -i $ni || die
+ fi
+ $APKG -u $pu || die
+ fi
+}
+
+pkg_search() {
+ if [ ! "$APKG_REPO" ]; then
+ msg "No repo configured."
+ exit 1
+ fi
+ if [ "$pkg" ]; then
+ for p in $pkg; do
+ grep="$grep -e $p"
+ done
+ grep="grep $grep"
+ else
+ grep=cat
+ fi
+ [ "$verbose" ] && {
+ find $APKG_REPO -type f -name abuild 2>/dev/null | sed 's|/abuild||' | rev | awk -F / '{print $1}' | rev | $grep | while read line; do printf "$line "; awk -F'=' '/^version/ {print $2}' $($APKG -p $line)/abuild ; done
+ } || {
+ find $APKG_REPO -type f -name abuild 2>/dev/null | sed 's|/abuild||' | rev | awk -F / '{print $1}' | rev | $grep
+ }
+}
+
+pkg_depinstalll() {
+ needroot
+ for p in $@; do
+ if [ -s $SPM_PKGDB/$p ]; then
+ msg "Package '$p' is installed"
+ continue
+ fi
+ if [ ! "$(pkg_path $p)" ]; then
+ msg "Package '$p' not found"
+ continue
+ fi
+ pkg="$pkg $p"
+ done
+ [ "$pkg" ] || exit 0
+ set -- $pkg
+ msg "Solving dependencies..."
+ for p in $(skip_installed=1 pkg_deplist $@); do
+ [ -s $SPM_PKGDB/$p ] && continue
+ installthis="$installthis $p"
+ done
+ if [ ! "$installthis" ]; then
+ msg "Nothing to install. Exiting..."
+ exit 0
+ fi
+ totalpkg=$(printf "%s\n" $installthis | tr ' ' '\n' | wc -l)
+ msg "Installing $totalpkg package(s): $installthis"
+ prompt_user
+ $APKG -i $installthis || die
+}
+
+_trigger_fccache() {
+ command -v fc-cache >/dev/null || return 0
+ spm -l $1 | grep -q ^usr/share/fonts/$ && {
+ msg "Updating fontconfig cache..."
+ fc-cache -sf
+ }
+}
+
+_trigger_gdkpixbufcache() {
+ command -v gdk-pixbuf-query-loaders >/dev/null || return 0
+ spm -l $1 | grep -q ^usr/lib/gdk-pixbuf-2.0/2.10.0/loaders/$ && {
+ msg "Probing GDK-Pixbuf loader modules..."
+ gdk-pixbuf-query-loaders --update-cache
+ }
+}
+
+_trigger_giomodules() {
+ command -v gio-querymodules >/dev/null || return 0
+ spm -l $1 | grep -q ^usr/lib/gio/modules/$ && {
+ msg "Updating GIO module cache..."
+ gio-querymodules /usr/lib/gio/modules
+ }
+}
+
+_trigger_glibschema() {
+ command -v glib-compile-schemas >/dev/null || return 0
+ spm -l $1 | grep -q ^usr/share/glib-2.0/schemas/$ && {
+ msg "Compiling GSettings XML schema files..."
+ glib-compile-schemas /usr/share/glib-2.0/schemas
+ }
+}
+
+_trigger_gtk2immodules() {
+ command -v gtk-query-immodules-2.0 >/dev/null || return 0
+ spm -l $1 | grep -q ^usr/lib/gtk-2.0/2.10.0/immodules/$ && {
+ msg "Probing GTK2 input method modules..."
+ gtk-query-immodules-2.0 --update-cache
+ }
+}
+
+_trigger_gtk3immodules() {
+ command -v gtk-query-immodules-3.0 >/dev/null || return 0
+ spm -l $1 | grep -q ^usr/lib/gtk-3.0/3.0.0/immodules/$ && {
+ msg "Probing GTK3 input method modules..."
+ gtk-query-immodules-3.0 --update-cache
+ }
+}
+
+_trigger_iconcache() {
+ command -v gtk-update-icon-cache >/dev/null || return 0
+ spm -l $1 | grep -q ^usr/share/icons/$ && {
+ msg "Updating icon theme caches..."
+ for dir in /usr/share/icons/* ; do
+ if [ -e $dir/index.theme ]; then
+ gtk-update-icon-cache -q $dir 2>/dev/null
+ else
+ rm -f $dir/icon-theme.cache
+ rmdir --ignore-fail-on-non-empty $dir
+ fi
+ done
+ }
+}
+
+_trigger_udevdb() {
+ command -v udevadm >/dev/null || return 0
+ spm -l $1 | grep -q ^etc/udev/hwdb.d/$ && {
+ msg "Updating hardware database..."
+ udevadm hwdb --update
+ }
+}
+
+_trigger_fontcache() {
+ command -v mkfontdir >/dev/null || return 0
+ command -v mkfontscale >/dev/null || return 0
+ spm -l $1 | grep -q ^usr/share/fonts/$ && {
+ msg "Updating X fontdir indices..."
+ for dir in $(find /usr/share/fonts -maxdepth 1 -type d \( ! -path /usr/share/fonts \)); do
+ rm -f $dir/fonts.scale $dir/fonts.dir $dir/.uuid
+ rmdir --ignore-fail-on-non-empty $dir
+ [ -d "$dir" ] || continue
+ mkfontdir $dir
+ mkfontscale $dir
+ done
+ }
+}
+
+_trigger_desktopdb() {
+ command -v update-desktop-database >/dev/null || return 0
+ spm -l $1 | grep -q ^usr/share/applications/$ && {
+ msg "Updating desktop file MIME type cache..."
+ update-desktop-database --quiet
+ }
+}
+
+_trigger_mimedb() {
+ command -v update-mime-database >/dev/null || return 0
+ spm -l $1 | grep -q ^usr/share/mime/$ && {
+ msg "Updating the MIME type database..."
+ update-mime-database /usr/share/mime
+ }
+}
+
+pkg_trigger() {
+ needroot
+ [ "$@" ] || set -- $($APKG -a)
+ for t in mimedb desktopdb fontcache fccache udevdb iconcache gtk3immodules gtk2immodules glibschema giomodules gdkpixbufcache; do
+ for p in $@; do
+ _trigger_$t $p && break
+ done
+ done
+}
+
+pkg_allinstalled() {
+ if [ "$pkg" ]; then
+ for p in $pkg; do
+ grep="$grep -e $p"
+ done
+ grep="grep $grep"
+ else
+ grep=cat
+ fi
+ [ "$verbose" ] && {
+ ls -1 $SPM_PKGDB | $grep | while read line; do printf "$line "; head -n1 $SPM_PKGDB/$line ; done
+ } || {
+ ls -1 $SPM_PKGDB | $grep
+ }
+}
+
+checksum_src() {
+ if [ ! -s "$checksum_file" ]; then
+ gencsum
+ else
+ b3sumcheck || return 0
+ printcsum > ${checksum_file}.tmp
+ diff -U 0 ${checksum_file} ${checksum_file}.tmp | \
+ sed '/---/d;/+++/d;/@@/d' | \
+ sed 's/^+/ new : /' | \
+ sed 's/^-/ missing: /' > ${checksum_file}.diff
+ [ -s "${checksum_file}.diff" ] && {
+ cat ${checksum_file}.diff
+ msg "Checksum failed."
+ failed=1
+ }
+ rm -f ${checksum_file}.tmp ${checksum_file}.diff
+ [ "$failed" ] && ret 1
+ fi
+}
+
+printsource() {
+ # print out source full path
+ for printsource in $source; do
+ printsource=${printsource%::noextract}
+ case $printsource in
+ *::*) sourcename=${printsource%::*};;
+ *) sourcename=${printsource##*/};;
+ esac
+ case ${printsource#*::} in
+ */*) sourcenamefullpath=${APKG_SOURCE_DIR}/$sourcename;;
+ *) sourcenamefullpath=${HERE}/$sourcename;;
+ esac
+ printf "%s\n" $sourcenamefullpath
+ done
+}
+
+checksource() {
+ # check for source existence, exit non-zero if missing
+ for checksource in $(printsource); do
+ [ -f "$checksource" ] || {
+ msg "Source file '$checksource' not found."
+ failed=1
+ }
+ done
+ [ "$failed" ] && ret 1
+}
+
+b3sumcheck() {
+ command -v b3sum >/dev/null || { msg "'b3sum' not installed."; return 1; }
+}
+
+gencsum() {
+ checksource
+ b3sumcheck || return 0
+ rm -f .checksum
+ printcsum > .checksum
+ msg "Checksum file updated."
+}
+
+printcsum() {
+ for printcsum in $(printsource); do
+ [ -f "$printcsum" ] || continue
+ b3sum $printcsum | sed "s,$APKG_SOURCE_DIR/,,;s,$HERE/,,"
+ done | sort -k 2
+}
+
+prompt_user() {
+ if [ ! "$APKG_NOPROMPT" ]; then
+ msg "Press ENTER to continue operation."
+ msg "Press Ctrl + C to abort."
+ read -r null
+ fi
+}
+
+runscript() {
+ if [ -x ./${1}install ]; then
+ msg "Running ${1}install script..."
+ if [ "$APKG_ROOT" ]; then
+ cat ./${1}install > "$APKG_ROOT"/.runscript
+ chmod +x "$APKG_ROOT"/.runscript
+ chroot "$APKG_ROOT" /.runscript
+ rm -f "$APKG_ROOT"/.runscript
+ else
+ ./${1}install
+ fi
+ fi
+}
+
+needroot() {
+ [ $(id -u) = 0 ] || {
+ msg 'This operation need root access'
+ exit 1
+ }
+}
+
+parsesubopt() {
+ # loop opts until found '-*'
+ shift; while [ "$1" ]; do
+ case $1 in
+ -*) break;;
+ *) printf "%s\n" "$1";;
+ esac
+ shift
+ done
+}
+
+updateopts() {
+ while [ "$1" ]; do
+ case $1 in
+ -*) newopt="$newopt $1";;
+ esac
+ shift
+ done
+ printf "%s\n" "$newopt"
+}
+
+parseopts() {
+ while [ "$1" ]; do
+ case $1 in
+ -I) pkg_depinstalll "$(parsesubopt "$@")"; exit 0;;
+ -D) pkg_deplist "$(parsesubopt "$@")"; exit 0;;
+ -r) pkg_remove "$(parsesubopt "$@")"; exit 0;;
+ -p) pkg_path "$(parsesubopt "$@")"; exit 0;;
+ -t) pkg_trigger "$(parsesubopt "$@")"; exit 0;;
+ -U) pkg_sysup; exit 0;;
+ -d) pkg_depends "$2"; exit 0;;
+ -s) search=1;;
+ -S) pkg_fsearch "$2"; exit 0;;
+ -j) pkg_dependents "$2"; exit 0;;
+ -a) allinstalled=1;;
+ -h) apkg_help; exit 0;;
+ -l) pkg_outdate; exit 0;;
+ -g) updatecsum=1;;
+ -k) updatefiles=1;;
+ -f) forcerebuild=1;;
+ -i) install=1;;
+ -u) upgrade=1;;
+ -o) downloadonly=1;;
+ -v) verbose=1;;
+ -*) msg "invalid option '$1'"; exit 1;;
+ *) pkg="$pkg $1";;
+ esac
+ shift
+ done
+}
+
+apkg_help() {
+ cat << EOF
+usage: ${0##*/} <option> <arg(s)>
+
+options:
+ -i <pkg(s)> install package(s)
+ -I <pkg(s)> install packages(s) with dependencies
+ -d <pkg> list <pkg> dependencies
+ -D <pkg(s)> list all dependencies
+ -j <pkg> list all dependents
+ -u <pkg(s)> upgrade package(s)
+ -r <pkg(s)> remove package(s)
+ -t [pkg(s)] trigger system cache/db updates
+ -U update system
+ -f force rebuild
+ -o <pkg(s)> download source
+ -p <pkg> print package path
+ -g <pkg> update package checksum
+ -k <pkg> update package files
+ -l list outdated packages
+ -s <pattern> search packages
+ -S <pattern> search files
+ -v be verbose
+ -h print this help message
+
+environment variables:
+ APKG_ROOT override default root (${APKG_ROOT:-/}) location
+ APKG_CONF override default $APKG_CONF location
+ APKG_NOPROMPT set the variable for non-interactive use
+ APKG_LOG set the variable for logging the output to a file
+
+EOF
+exit 0
+}
+
+main() {
+ parseopts "$@"
+ set -- $(updateopts "$@")
+
+ if [ "$search" ]; then
+ pkg_search $@
+ exit 0
+ fi
+
+ if [ "$allinstalled" ]; then
+ pkg_allinstalled $@
+ exit 0
+ fi
+
+ for d in $APKG_PACKAGE_DIR $APKG_SOURCE_DIR $APKG_WORK_DIR $APKG_LOG_DIR; do
+ [ -d "$d" ] || { msg "Directory '$d' not exist"; exit 1; }
+ [ -w "$d" ] || { msg "Directory '$d' dont have write access"; exit 1; }
+ done
+
+ if [ "$pkg" ]; then
+ for p in $pkg; do
+ [ "$(pkg_path "$p")" ] || {
+ msg "Package '$p' not found"
+ continue
+ }
+ (cd "$(pkg_path "$p")" && $APKG "$@") || exit 1
+ done
+ exit 0
+ fi
+
+ if [ ! -f ./abuild ]; then
+ msg "'abuild' not found."
+ exit 1
+ fi
+
+ . ./abuild
+ [ "$name" ] || die "name is empty"
+ [ "$version" ] || die "version is empty"
+ [ "$release" ] || die "release is empty"
+ [ "$name" = "${PWD##*/}" ] || {
+ msg "'name' should be same as package directory name (${PWD##*/})."
+ exit 1
+ }
+
+ logfile="$APKG_LOG_DIR"/$name.log
+ packagefile="$APKG_PACKAGE_DIR"/$name#$version-$release.spm
+
+ if [ "$install" ] && [ -s "$SPM_PKGDB/${PWD##*/}" ]; then
+ msg "Package '${PWD##*/}' already installed."
+ exit 0
+ fi
+
+ if [ "$upgrade" ] && [ ! -s "$SPM_PKGDB/${PWD##*/}" ]; then
+ msg "Package '${PWD##*/}' not installed."
+ exit 0
+ fi
+
+ if [ "$updatecsum" ]; then
+ gencsum
+ exit 0
+ fi
+
+ if [ "$downloadonly" ]; then
+ fetch_src
+ exit 0
+ fi
+
+ if [ "$updatefiles" ]; then
+ pkg_updatefiles
+ exit 0
+ fi
+
+ if [ "$(id -u)" != 0 ]; then
+ msg "Packages need to build as root. Aborted."
+ exit 1
+ fi
+
+ if [ -f "$packagefile" ] && [ ! "$forcerebuild" ]; then
+ if [ ! "$install" ] && [ ! "$upgrade" ]; then
+ msg "Package '$packagefile' found."
+ fi
+ else
+ if [ "$install" ] || [ "$upgrade" ]; then
+ # run preinstall script before build
+ runscript pre
+ fi
+ fetch_src
+ checksum_src
+ extract_src
+ [ "$APKG_LOG" ] && {
+ build_src 2>&1 | tee -- "$logfile"
+ } || {
+ build_src
+ }
+ fi
+
+ if [ "$install" ]; then
+ SPM_ROOT=${APKG_ROOT%/} spm -i "$packagefile" || exit $?
+ elif [ "$upgrade" ]; then
+ SPM_ROOT=${APKG_ROOT%/} spm -u "$packagefile" || exit $?
+ fi
+
+ if [ "$install" ] || [ "$upgrade" ]; then
+ # run postinstall script after installed/upgraded
+ runscript post
+ [ "$APKG_ROOT" ] || pkg_trigger "$name"
+ fi
+}
+
+umask 022
+
+export HERE="$PWD"
+
+APKG=$0
+SPM_PKGDB="${APKG_ROOT%/}/var/lib/spm/db"
+
+# for apkg config, either override or default
+APKG_CONF="${APKG_CONF:-/etc/apkg.conf}"
+
+## NEED BETTER WAY TO DO THIS?
+# environment override
+O_APKG_REPO=$APKG_REPO
+O_APKG_PACKAGE_DIR=$APKG_PACKAGE_DIR
+O_APKG_SOURCE_DIR=$APKG_SOURCE_DIR
+O_APKG_WORK_DIR=$APKG_WORK_DIR
+O_APKG_LOG_DIR=$APKG_LOG_DIR
+
+# default value
+APKG_REPO="$PWD"
+APKG_PACKAGE_DIR="$PWD"
+APKG_SOURCE_DIR="$PWD"
+APKG_WORK_DIR="$PWD"
+APKG_LOG_DIR="$PWD"
+
+checksum_file="$HERE/.checksum"
+
+# source config
+if [ -f "$APKG_CONF" ]; then
+ . "$APKG_CONF"
+fi
+
+# reset value, use override first, else either from config or use default
+APKG_REPO=${O_APKG_REPO:-$APKG_REPO}
+APKG_PACKAGE_DIR=${O_APKG_PACKAGE_DIR:-$APKG_PACKAGE_DIR}
+APKG_SOURCE_DIR=${O_APKG_SOURCE_DIR:-$APKG_SOURCE_DIR}
+APKG_WORK_DIR=${O_APKG_WORK_DIR:-$APKG_WORK_DIR}
+APKG_LOG_DIR=${O_APKG_LOG_DIR:-$APKG_LOG_DIR}
+
+main "$@"
+
+exit 0
diff --git a/apkg-bin b/apkg-bin
@@ -0,0 +1,232 @@
+#!/bin/sh
+# apkg-bin - a simple binary package manager helper script
+
+REMOTE="${REMOTE:-https://emmett1.my/files/alice/packages}"
+PKGDIR="${PKGDIR:-/var/cache/apkg-bin}"
+REPODB="${REPODB:-REPO}"
+DBFILE="$PKGDIR/$REPODB"
+
+usage() {
+ echo "Usage: $0 [options]"
+ echo " g <path> Generate database from package dir"
+ echo " S Sync database from remote server"
+ echo " l List packages"
+ echo " s <pattern> Search packages"
+ echo " a <pkg> Show package info"
+ echo " d <pkg...> Download package(s)"
+ echo " i <pkg...> Install package(s)"
+ echo " u <pkg...> Upgrade/reinstall package(s)"
+ echo " c Clean mismatched/unknown packages"
+ exit 0
+}
+
+msg() {
+ m=${pkg%#*}
+ echo "[${m:-...}] $*"
+}
+
+pkg_existence() {
+ need_db
+ [ "$(cut -d '#' -f1 "$DBFILE" | grep -x "$1" | uniq)" ] || return 1
+ return 0
+}
+
+get_pkg() {
+ for p in $@; do
+ pkg_existence $p && pkg="$pkg $p" || msg "No package found matching: $p"
+ done
+}
+
+get_entry() {
+ entry=$(grep ^$1# "$DBFILE" | sort -V -t'#' -k2 | tail -n1)
+}
+
+need_db() {
+ [ -f "$DBFILE" ] || { msg "Run '$0 S' first to sync database."; exit 1; }
+}
+
+need_root() {
+ [ $(id -u) = 0 ] || { msg "This option need root access."; exit 1; }
+}
+
+fetch_pkg() {
+ get_entry $1
+ expected_sha=$(echo "$entry" | cut -d'|' -f4)
+ pkg=$(echo "$entry" | cut -d'|' -f1)
+
+ mkdir -p "$PKGDIR"
+ if [ -f "$PKGDIR/$pkg" ]; then
+ msg "$PKGDIR/$pkg found."
+ else
+ url="$REMOTE/$(echo "$pkg" | sed 's/#/%23/g')"
+ msg "Downloading $url..."
+ curl -fsSLo "$PKGDIR/$pkg" "$url" || { msg "Download failed: $pkg" >&2; return 1; }
+ fi
+
+ actual_sha=$(sha256sum "$PKGDIR/$pkg" | awk '{print $1}')
+ if [ "$expected_sha" = "$actual_sha" ]; then
+ msg "Verification PASSED: $pkg"
+ else
+ msg "Verification FAILED: $pkg" >&2
+ rm -f "$pkg"
+ return 1
+ fi
+
+ if [ "$mode" ]; then
+ spm $mode "$PKGDIR/$pkg"
+ fi
+}
+
+generate_db() {
+ [ -d "$1" ] || { msg "Invalid path: $1"; exit 1; }
+ > "$1/$REPODB"
+ msg "Generating database, please wait..."
+ for f in "$1"/*.spm; do
+ [ -f "$f" ] || continue
+ size=$(stat -c%s "$f")
+ mtime=$(stat -c%Y "$f")
+ sha=$(sha256sum "$f" | awk '{print $1}')
+ name=$(basename "$f")
+ echo "$name|$size|$mtime|$sha" >> "$1/$REPODB"
+ done
+ msg "Database generated at $1/$REPODB"
+}
+
+sync_db() {
+ need_root
+ mkdir -p "${DBFILE%/*}"
+ msg "Downloading database $REMOTE/$REPODB"
+ curl -fsSo "$DBFILE" "$REMOTE/$REPODB" || { msg "Failed to sync $REPODB"; exit 1; }
+ msg "Database synced to $DBFILE"
+}
+
+list_pkg() {
+ need_db
+ cut -d'|' -f1 "$DBFILE" | sed 's/#/ /g;s/.spm//g'
+}
+
+search_pkg() {
+ need_db
+ cut -d '|' -f1 "$DBFILE" | grep -i "$1" | sed 's/#/ /g;s/.spm//g'
+ exit 0
+}
+
+info_pkg() {
+ need_db
+ get_pkg $@
+ for p in $pkg; do
+ get_entry $p
+ name=$p
+ verrel=$(echo "$entry" | cut -d '#' -f2 | sed 's/\.spm.*//')
+ size=$(echo "$entry" | cut -d '|' -f2)
+ mtime=$(echo "$entry" | cut -d '|' -f3)
+ sha=$(echo "$entry" | cut -d '|' -f4)
+
+ # convert size
+ if [ "$size" -lt 1024 ]; then
+ hsize="${size} B"
+ elif [ "$size" -lt 1048576 ]; then
+ hsize="$(awk "BEGIN{printf \"%.1f\", $size/1024}") KB"
+ else
+ hsize="$(awk "BEGIN{printf \"%.1f\", $size/1048576}") MB"
+ fi
+
+ # convert date
+ hdate=$(date -d @"$mtime" '+%Y-%m-%d %H:%M:%S')
+
+ echo "Package: $name"
+ echo "Version: $verrel"
+ echo "Size: $hsize"
+ echo "Date: $hdate"
+ echo "SHA256: $sha"
+ done
+}
+
+download_pkg() {
+ need_db
+ get_pkg $@
+ for p in $pkg; do
+ fetch_pkg $p
+ done
+}
+
+install_pkg() {
+ need_root
+ need_db
+ get_pkg $@
+ for p in $pkg; do
+ [ "$(spm -a | grep -x $p)" ] && {
+ msg "Package '$p' is installed, skipped."
+ } || {
+ pkg2="$pkg2 $p"
+ }
+ done
+ for p in $pkg2; do
+ mode='-i' fetch_pkg $p
+ done
+}
+
+upgrade_pkg() {
+ need_root
+ need_db
+ get_pkg $@
+ for p in $pkg; do
+ [ "$(spm -a | grep -x $p)" ] || {
+ msg "Package '$p' not installed, skipped."
+ } && {
+ pkg2="$pkg2 $p"
+ }
+ done
+ for p in $pkg2; do
+ mode='-u' fetch_pkg $p
+ done
+}
+
+clean_pkg() {
+ need_db
+ need_root
+ msg "Checking local packages in $PKGDIR..."
+ known_pkgs=$(cut -d '|' -f1 "$DBFILE")
+ for f in "$PKGDIR"/*.spm; do
+ [ -f "$f" ] || continue
+ fname=${f##*/}
+ if echo "$known_pkgs" | grep -qx "$fname"; then
+ entry=$(grep "^$fname|" "$DBFILE")
+ expected_size=$(echo "$entry" | cut -d'|' -f2)
+ expected_sha=$(echo "$entry" | cut -d'|' -f4)
+ actual_size=$(stat -c%s "$f")
+ actual_sha=$(sha256sum "$f" | awk '{print $1}')
+ if [ "$expected_size" != "$actual_size" ] || [ "$expected_sha" != "$actual_sha" ]; then
+ msg "Mismatch: $fname (removed)"
+ fi
+ else
+ msg "Unknown package: $fname (removed)"
+ rm -f "$f"
+ fi
+ done
+ msg "Cleanup done."
+}
+
+main() {
+ if [ ! "$1" ]; then
+ usage
+ else
+ case $1 in
+ g) generate_db $2 ;;
+ S) sync_db ;;
+ l) list_pkg ;;
+ s) search_pkg $2 ;;
+ a) shift; info_pkg $@ ;;
+ d) shift; download_pkg $@ ;;
+ i) shift; install_pkg $@ ;;
+ u) shift; upgrade_pkg $@ ;;
+ c) clean_pkg ;;
+ *) usage ;;
+ esac
+ exit 0
+ fi
+}
+
+main $@
+
+exit 0
diff --git a/apkg-chroot b/apkg-chroot
@@ -0,0 +1,105 @@
+#!/bin/sh
+#
+# script to enter chroot
+
+printhelp() {
+ cat << EOF
+
+Usage:
+ $(basename $0) <chroot-dir> [command]
+
+If 'command' is unspecified, ${0##*/} will launch /bin/sh.
+
+EOF
+}
+
+msgerr() {
+ echo "ERROR: $*"
+}
+
+unmount() {
+ while [ "$(mount | awk '{print $3}' | grep -x $1)" ]; do
+ umount $1 2>/dev/null || :
+ done
+}
+
+umountall() {
+ for i in $(mount | awk '{print $3}' | grep $TARGET | tac); do
+ unmount $i
+ done
+}
+
+[ "$(id -u)" = "0" ] || {
+ msgerr "$(basename $0) need root access!"
+ printhelp
+ exit 1
+}
+
+TARGET=$(realpath $1)
+trap umountall 1 2 3 15
+
+[ "$1" ] || {
+ msgerr "Please set directory for chroot!"
+ printhelp
+ exit 1
+}
+
+[ -d "$TARGET" ] || {
+ msgerr "Directory '$TARGET' not exist!"
+ printhelp
+ exit 1
+}
+
+shift
+
+if [ ! "$1" ]; then
+ CMD="/bin/sh"
+else
+ CMD=$*
+fi
+
+if [ -e /sys/firmware/efi/systab ]; then
+ EFI_SYSTEM=1
+fi
+
+mount --bind /dev $TARGET/dev
+mount -t devpts devpts $TARGET/dev/pts -o gid=5,mode=620
+mount -t proc proc $TARGET/proc
+mount -t sysfs sysfs $TARGET/sys
+if [ -n "$EFI_SYSTEM" ]; then
+ mount --bind /sys/firmware/efi/efivars $TARGET/sys/firmware/efi/efivars
+fi
+mount -t tmpfs tmpfs $TARGET/run
+
+if [ -h $TARGET/dev/shm ]; then
+ mkdir -p $TARGET/$(readlink $TARGET/dev/shm)
+fi
+
+[ -f $TARGET/etc/resolv.conf ] && {
+ backupresolvconf=1
+ mv $TARGET/etc/resolv.conf $TARGET/etc/resolv.conf.tmp
+}
+cp -L /etc/resolv.conf $TARGET/etc
+
+chroot "$TARGET" /usr/bin/env -i \
+HOME=/root \
+TERM="$TERM" \
+PS1='\u:\w\$ ' \
+PATH=/bin:/usr/bin:/sbin:/usr/sbin $CMD
+
+retval=$?
+
+[ "$backupresolvconf" = 1 ] && {
+ mv $TARGET/etc/resolv.conf.tmp $TARGET/etc/resolv.conf
+}
+
+unmount $TARGET/dev/pts
+unmount $TARGET/dev
+unmount $TARGET/run
+unmount $TARGET/proc
+if [ -n "$EFI_SYSTEM" ]; then
+ unmount $TARGET/sys/firmware/efi/efivars
+fi
+unmount $TARGET/sys
+
+exit $retval
diff --git a/apkg-clean b/apkg-clean
@@ -0,0 +1,85 @@
+#!/bin/sh
+#
+# this script is for cleanup old packages and sources
+#
+# usage:
+# apkg-clean | xargs rm
+#
+
+[ -f /etc/apkg.conf ] && . /etc/apkg.conf
+
+scan_pkgs() {
+ [ "$APKG_PACKAGE_DIR" ] && allpkg=$(echo $APKG_PACKAGE_DIR/*.spm 2>/dev/null)
+ for i in $(apkg -s); do
+ . $(apkg -p $i)/abuild 2>/dev/null
+ if [ ! "$APKG_PACKAGE_DIR" ]; then
+ for p in $(apkg -p $i)/*.spm; do
+ [ -f $p ] || continue
+ [ "${p##*/}" = "$name#$version-$release.spm" ] && continue
+ echo $p
+ done
+ else
+ allpkg=$(echo $allpkg | sed "s|$APKG_PACKAGE_DIR/$name#$version-$release.spm||")
+ fi
+ done
+ [ "$APKG_PACKAGE_DIR" ] && echo $allpkg | tr ' ' '\n'
+}
+
+scan_srcs() {
+ [ "$APKG_SOURCE_DIR" ] && allsrc=$(echo $APKG_SOURCE_DIR/* 2>/dev/null)
+ for i in $(apkg -s); do
+ . $(apkg -p $i)/abuild 2>/dev/null
+ unset keep
+ for s in $source; do
+ s=${s%::noextract}
+ case $s in
+ *::*) keep="$keep ${s%::*}";;
+ */*) keep="$keep ${s##*/}";;
+ *) [ "$APKG_SOURCE_DIR" ] || keep="$keep $s";;
+ esac
+ done
+ if [ ! "$APKG_SOURCE_DIR" ]; then
+ (cd $(apkg -p $i)
+ for f in *; do
+ case $f in
+ abuild|depends|preinstall|postinstall|*.spm) continue;;
+ esac
+ echo $keep | tr ' ' '\n' | grep -qx $f || echo $PWD/$f
+ done
+ )
+ else
+ for f in $keep; do
+ allsrc=$(echo $allsrc | sed "s|$APKG_SOURCE_DIR/$f||")
+ done
+ fi
+ done
+ [ "$APKG_SOURCE_DIR" ] && echo $allsrc | tr ' ' '\n'
+}
+
+print_help() {
+ cat <<EOF
+usage:
+ $0 [-p] [-s] | xargs rm -v
+
+options:
+ -s print sources only
+ -p print packages only
+
+EOF
+}
+
+if [ "$1" ]; then
+ while [ "$1" ]; do
+ case $1 in
+ -p) scan_pkgs;;
+ -s) scan_srcs;;
+ -h) print_help;;
+ esac
+ shift
+ done
+else
+ scan_pkgs
+ scan_srcs
+fi
+
+exit 0
diff --git a/apkg-deps b/apkg-deps
@@ -0,0 +1,29 @@
+#!/bin/sh
+
+PKGDB=/var/lib/spm/db
+
+if [ ! "$1" ]; then
+ echo "usage: $0 <pkg>"
+ exit 0
+fi
+
+if [ ! -s "$PKGDB/$1" ]; then
+ echo "Package '$1' not installed"
+ exit 0
+fi
+
+f=$(spm -l $1 | awk '/(sbin|bin|lib)\//')
+
+for i in $f; do
+ [ -x /$i ] || continue
+ deps="$deps $(ldd /$i 2>/dev/null | awk '!/(ldd)|(linux-gate)|( dynamic)|(not found)/ {print $3}')"
+done
+
+deps=$(for i in $deps; do realpath $i; done | sort | uniq)
+pkg=$(for i in $deps; do spm -o $i | awk '{print $1}'; done | sort | uniq | grep -Ev "($1|gcc|musl|binutils|glibc)")
+
+if [ "$pkg" ]; then
+ echo $pkg | tr ' ' '\n'
+fi
+
+exit 0
diff --git a/apkg-foreign b/apkg-foreign
@@ -0,0 +1,10 @@
+#!/bin/sh
+#
+# script to print foreign pkg
+# (package installed but not in repos)
+
+for i in $(spm -a | awk '{print $1}'); do
+ [ $(apkg -p $i) ] || echo $i
+done
+
+exit 0
diff --git a/apkg-genabuild b/apkg-genabuild
@@ -0,0 +1,65 @@
+#!/bin/sh
+#
+# script to generate abuild template
+
+print_help() {
+ cat <<EOF
+usage:
+ $0 <url> [name]
+
+EOF
+exit 0
+}
+
+if [ ! "$1" ] || [ "$1" = '-h' ]; then
+ print_help
+fi
+
+url=$1
+
+name=$(echo $1 | rev | cut -d / -f1 | cut -d - -f2- | rev | tr '[:upper:]' '[:lower:]')
+version=$(echo $1 | rev | cut -d / -f1 | cut -d - -f1 | rev | sed 's/\.tar.*//' | sed 's/^v//')
+
+case $url in
+ *.pythonhosted.*) name="python-$name";;
+ */pypi.org/*) name="python-$name";;
+ *.metacpan.*|*.cpan.*) name="perl-$name";;
+ */refs/tags/*) # github tags tarball
+ gh=${1%/archive*} # project url
+ name=${gh##*/} # project name
+ verstar=${1##*/} # version with tar suffix
+ vers=${verstar%.tar.*} # version without tar suffix
+ version=${vers#v} # final version without 'v' prefix
+ url=$gh/archive/$vers/$name-$verstar;;
+ *) name=$name;;
+esac
+
+if [ "$2" ]; then
+ name=$2
+fi
+
+# make name lowercase
+name=$(echo $name | tr '[:upper:]' '[:lower:]')
+
+[ -d $name ] && {
+ grep ^version= $name/abuild
+ echo "port for $name exist"
+ exit 1
+}
+url=$(echo $url | sed "s,$name,\${name},g;s,$version,\${version},g" )
+
+case $version in
+ *.*.*) v=${version%.*}
+ url=$(echo $url | sed "s,$v,\${version%\.\*},g" )
+esac
+
+mkdir -p $name
+
+echo "name=$name
+version=$version
+release=1
+source=\"$url\"" > $name/abuild
+
+cat $name/abuild
+
+exit 0
diff --git a/apkg-orphan b/apkg-orphan
@@ -0,0 +1,18 @@
+#!/bin/sh
+#
+# script to print orphan package
+# (package which no its dependent installed)
+
+for i in $(apkg -a); do
+ [ "$(apkg -p $i)" ] || continue
+ orphan=1
+ for p in $(apkg -j $i); do
+ if [ "$(apkg -a ^$p$)" ]; then
+ unset orphan
+ break
+ fi
+ done
+ [ "$orphan" ] && echo $i
+done
+
+exit 0
diff --git a/apkg-outdated b/apkg-outdated
@@ -0,0 +1,32 @@
+#!/bin/sh
+
+[ "$1" ] || {
+ echo "script to check outdated package from repology"
+ echo " usage: $0 <port path> <port path> ..."
+ echo
+ exit 1
+}
+
+while [ "$1" ]; do
+ unset curver port
+ [ -f $1/abuild ] && port=$(realpath $1)
+ [ "$port" ] || { shift; continue; }
+ repo=${port%/*}; repo=${repo##*/}
+ pname=${1##*/}
+ curver=$(grep ^version= $port/abuild | awk -F = '{print $2}')
+ [ "$curver" ] || { shift; continue; }
+ if [ -s $1/outdated ]; then
+ pname=$(tail -n1 $1/outdated)
+ else
+ case $pname in
+ python-*) pname=python:${pname#python-};;
+ esac
+ fi
+ newver=$(curl -s -H "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36" https://repology.org/badge/latest-versions/$pname.svg | grep middle | sed 's/.*middle">//;s/<.*//;s/,//' | tr ' ' '\n' | tail -n1)
+ if [ "$newver" = "-" ]; then
+ echo "$repo/${1##*/} 404 ($curver)"
+ elif [ "$curver" != "$newver" ]; then
+ echo "$repo/${1##*/} $newver ($curver)"
+ fi
+ shift
+done
diff --git a/apkg-purge b/apkg-purge
@@ -0,0 +1,60 @@
+#!/bin/sh -e
+#
+# script for purge package and its dependencies from system
+
+purge() {
+ for j in $(apkg -j $1); do
+ [ "$(apkg -a ^$j$)" ] && {
+ echo "[$1] dependent package is installed: $j"
+ error=1
+ }
+ done
+ [ "$error" ] && return 1
+
+ for i in $(apkg -d $1); do
+ [ "$(apkg -a ^$i$)" ] || continue
+ for d in $(apkg -j $i); do
+ [ "$d" = "$1" ] && continue
+ [ "$(apkg -a ^$d$)" ] && continue 2
+ done
+ if [ "$purgeit" ]; then
+ spm -r $i
+ else
+ echo $i
+ fi
+ done
+ if [ "$purgeit" ]; then
+ spm -r $1
+ else
+ echo $1
+ fi
+}
+
+help() {
+ cat <<EOF
+usage:
+ $0 [-p] <pkgs>
+
+option:
+ -p remove from system
+
+EOF
+exit 0
+}
+
+while [ "$1" ]; do
+ case $1 in
+ -p) purgeit=1;;
+ -h) help;;
+ *) pkg="$pkg $1";;
+ esac
+ shift
+done
+
+for p in $pkg; do
+ apkg -p $p >/dev/null || continue # skip if package not exist in repo
+ apkg -a | grep -qx $p || continue # skip if package not installed
+ purge $p
+done
+
+exit 0
diff --git a/apkg-redundantdeps b/apkg-redundantdeps
@@ -0,0 +1,47 @@
+#!/bin/sh
+#
+# find redundant dependencies
+
+print_help() {
+ cat <<EOF
+usage:
+ $0 [-f] <pkgs>
+
+options:
+ -f fix (remove) redundant pkg from depends
+
+EOF
+exit 0
+}
+
+if [ "$1" ]; then
+ while [ "$1" ]; do
+ case $1 in
+ -f) fix=1;;
+ -h) print_help;;
+ *) pkg="$pkg $1";;
+ esac
+ shift
+ done
+fi
+
+[ "$pkg" ] || pkg=$(apkg -D $(apkg -s))
+
+for i in $pkg; do
+ [ "$(apkg -d $i )" ] || continue
+ for d in $(apkg -d $i); do
+ for dd in $(apkg -d $i); do
+ [ "$dd" = "$d" ] && continue
+ [ "$(apkg -D $d | grep -x $dd)" ] && {
+ echo "[$i] $dd (already pulled from $d)"
+ if [ "$fix" ]; then
+ sed -i "/^$dd$/d" $(apkg -p $i)/depends
+ echo " $dd is removed from $i depends"
+ [ -s $(apkg -p $i)/depends ] || rm $(apkg -p $i)/depends
+ fi
+ }
+ done
+ done
+done
+
+exit 0
diff --git a/apkg-reposync b/apkg-reposync
@@ -0,0 +1,73 @@
+#!/bin/sh
+
+APKG_CONF="${APKG_CONF:-/etc/apkg.conf}"
+temp_repos_file=$(mktemp)
+write_permission=0
+
+die() {
+ [ "$1" ] && echo "error: $1"
+ rm -f "$temp_repos_file"
+ exit 1
+}
+
+find_default_remote() {
+ cd "${1}" || die "cannot cd to <${1}> the repo"
+ default_remote=$(git branch --list "$(git branch --show-current)" \
+ "--format=%(upstream:remotename)")
+}
+
+find_current_branch() {
+ cd "${1}" || die "cannot cd to the <${1}> repo"
+ current_branch=$(git remote show "${default_remote}" | sed -n '/HEAD branch/s/.*: //p')
+}
+
+check_write_permissions() {
+ random_file=$(find "${1}" -type f -print0 | shuf -z -n 1)
+ test -w "$random_file" || write_permission=$((write_permission+1))
+}
+
+source_and_sanity_checks() {
+[ ! -e "$(realpath "${APKG_CONF}")" ] && die "There is no configuration file in ${APKG_CONF}! Exiting..."
+
+. "${APKG_CONF}"
+
+[ -z "${APKG_REPO}" ] && die "There are no repos configured in $APKG_CONF, exiting..."
+
+for r in ${APKG_REPO}; do
+printf "%s\n" "$r" >> "$temp_repos_file"
+check_write_permissions "$r"; done
+[ "$write_permission" = 0 ] || die "You need to execute the script as root!"
+printf "%s\n" "Configured repos:" && awk ' {print $0} ' "$temp_repos_file"
+grep -q "alicelinux/repos/core" "$temp_repos_file" || die "No official repos configured in $APKG_CONF"
+}
+
+sync_official() {
+ # This assumes the current repo structure.
+ dir_for_official_repo=$(grep alicelinux/repos/core "$temp_repos_file")
+ [ -d "$dir_for_official_repo" ] || die "No $dir_for_official_repo exists, exiting..."
+ dir_for_official_repo=$(echo "$dir_for_official_repo" | sed "s/repos\/core//")
+ printf "%s\n" "[~> Syncing official repos in <$dir_for_official_repo> ...]"
+ find_default_remote "$dir_for_official_repo"
+ find_current_branch "$dir_for_official_repo"
+ git pull "$default_remote" "$current_branch" || die "Cannot pull from $default_remote/$current_branch for the ofixial repos"
+ [ "$?" = 0 ] && printf "%s\n" "[~> Successfully synced the <official> repo!]"
+}
+
+sync_or_skip() {
+ # Remove all official repo lines from the temp_repos_file
+ unofficial_repos=$(grep -v alicelinux/repos "$temp_repos_file" | tr "\n" " ")
+ for r in $unofficial_repos; do
+ if [ -d "$r"/.git ]; then
+ find_default_remote "$r"
+ find_current_branch "$r"
+ git pull "$default_remote" "$current_branch" || die "Cannot pull from $default_remote/$current_branch"
+ else
+ printf "%s\n" "[~>Repo in <$r> is not a git repo, skipping...]"
+ fi
+ done
+}
+
+source_and_sanity_checks
+sync_official
+sync_or_skip
+[ "$?" = 0 ] && echo "[~> Repo(s) succesfully synced!]" && rm -f "temp_repos_file"
diff --git a/doc/abuild.readme b/doc/abuild.readme
@@ -0,0 +1,100 @@
+# This is template file for abuild with explanations
+# you can use this template as base for your package abuild
+# all commented lines can be removed to keep it simple and clean.
+# uncomment necessary optional variables/functions as needed
+
+# 'name', 'version' and 'release' is required as it will be used in package database
+# must be the same as directory name.
+name=mypkg
+
+# should use version number from package upstream as possible
+version=1.2.3
+
+# does not follow any number from package upstream
+# must be increment number from 1
+# must reset to 1 when 'version' is changed
+# must not contain any character other than increment number from 1
+# can be use to bump package when package need rebuild without source changed
+release=1
+
+# if no source defined, empty package will be created, good for making meta packages
+# must use '$name' and '$version' variable so updating packages will be easier
+# 4 format acceptable can be used:
+# * <url> - just regular source tarball url
+# * <tarball name>::<url> - good to use when upstream source tarball name is not in proper format
+# * <url>::noextract - to skip extracting the source tarball
+# * <filename> - when its not a url, the <filename> is expected exist inside package abuild recipe directory
+#source="https://anyurl.com/$name-$version.tar.gz
+ $name-$version.tar.gz::https://anyurl.com/$version.tar.gz
+ https://anyurl.com/$name-$version.tar.gz::noextract
+ file"
+
+# placed runit service with proper name in /etc/sv
+# this is acceptable name for runit service file:
+# * run - /etc/sv/$name/run
+# * <whatevername> - /etc/sv/<whatevername>/run
+# * <whatevername>.run - /etc/sv/<whatevername>/run
+# * finish - /etc/sv/$name/finish
+# * <whatevername>.finish - /etc/sv/<whatevername>/finish
+#sv="run <whatevername>.run <whatevername>
+ finish <whatevername>.finish"
+
+# auto build system already use regular options like --prefix, --sysconfdir, --libdir and etc
+# use this to add the optional opts or to override the one in defaults (see 'defaultbuildopts' file)
+#build_opt=""
+
+# skipping auto apply patch
+#skip_patch=1
+
+# define patch opts to use other than default (-p1)
+#patch_opt="-p1"
+
+# keep static libraries (*.a) in packages
+#keep_static=1
+
+# keep libtool files (*.la) in packages
+#keep_libtool=1
+
+# keep locales in packages (/usr/share/locale and /usr/lib/locale)
+#keep_locale=1
+
+# keep documentations in packages (/usr/share/doc)
+#keep_doc=1
+
+# use this to force which build_type to use (if available)
+# by default build_type will be automatically detected
+# list available build_type (in order when autodetect)
+# * meson_build
+# * configure_build
+# * cmake_build
+# * python_build
+# * perlmodule_build
+# * makefile_build
+#build_type=""
+
+# override auto build system by using 'build()', 'prebuild()', and/or 'postbuild()' function
+# NOTE: when 'build()' is used, 'prebuild()' and 'postbuild()' will be ignored
+# theres 2 variable can be used in these function
+# * $PKG - is fakeroot location where all package files is installed before packaging
+# * $SRC - is where source is extracted
+#prebuild() {
+# # do whatever needed before compiling
+# # eg: fix whatever bug
+# sed -i 's/need to changed/to this/g' src/whateverfile
+#}
+#
+#postbuild() {
+# # do whatever needed after files installed to $PKG, before packaging occur
+# # eg: move binary to correct location
+# mkdir -p $PKG/usr/sbin
+# mv $PKG/usr/bin/binary $PKG/usr/sbin
+#}
+#
+#build() {
+# sed -i 's/need to changed/to this/g' src/whateverfile
+# ./configure --prefix=/usr
+# make
+# make DESTDIR=$PKG install
+# mkdir -p $PKG/usr/sbin
+# mv $PKG/usr/bin/binary $PKG/usr/sbin
+#}
diff --git a/doc/apkg.conf.readme b/doc/apkg.conf.readme
@@ -0,0 +1,56 @@
+# this is configuration file for 'apkg' located at '/etc/apkg.conf'
+# this file will get sourced before reading any package abuild recipe
+#
+# its good to export some compiler flags here
+#export CFLAGS="-O3 -march=x86-64 -pipe"
+#export CXXFLAGS="$CFLAGS"
+#export JOBS=$(nproc)
+#export MAKEFLAGS=-j$JOBS
+#export NINJAJOBS=$JOBS
+
+# repo path that contains package abuild recipe
+# the order is matter, which package found first will take precedence
+#APKG_REPO="<path to repo> <path to next repo> <and so on>"
+
+# path to prebuilt packages
+# if this not use, package will built inside package build recipe directory instead
+#APKG_PACKAGE_DIR=<path to package directory>
+
+# path to source tarball
+# if this not use, source tarball will fetched into package build recipe directory instead
+APKG_SOURCE_DIR=<path to source directory>
+
+# working directory path, where source is extracted and fakeroot location before packaging
+#APKG_WORK_DIR=<path to working directory>
+
+# package build logging directory path (log file is $APKG_WORK_DIR/$name.log)
+#APKG_LOG_DIR=<path to logging directory>
+
+# enable package build logging
+#APKG_LOG=1
+
+# keep source when build failed, good to examine what causing build failed
+#APKG_KEEP_WORKDIR=1
+
+# skip user prompt when using '-I' and '-U' options (disable interactive mode, good to use in scripting)
+#APKG_NOPROMPT=1
+
+# package dependencies alias
+# example: point openssl to libressl, so when installing package that depends on openssl will pull libressl instead
+# format: '<realpkg>:<aliasedpkg>'
+#APKG_ALIAS="openssl:libressl pkg1:pkg2"
+
+# package mask
+# avoid package(s) from get upgraded
+#APKG_MASK="musl gcc linux"
+
+# you can define and export whatever needed variable here as long its safe and not conflicting with other important
+# build variable, example, keep_* can be used here to set globally
+#keep_static=1
+#keep_libtool=1
+#keep_locale=1
+#keep_doc=1
+
+# you can also define ccache variable here to speed up package rebuild (required 'ccache' package installed)
+#export PATH=/usr/lib/ccache:$PATH
+#export CCACHE_DIR=/var/cache/ccache
diff --git a/doc/defaultbuildopts b/doc/defaultbuildopts
@@ -0,0 +1,87 @@
+# this file no needed in package build recipe
+# this file will just show what auto build system use for build options
+
+1 - meson_build:
+ meson setup \
+ -Dprefix=/usr \
+ -Dlibdir=/usr/lib \
+ -Dincludedir=/usr/include \
+ -Ddatadir=/usr/share \
+ -Dmandir=/usr/share/man \
+ -Dinfodir=/usr/share/info \
+ -Dlocaledir=/usr/share/locale \
+ -Dsysconfdir=/etc \
+ -Dlocalstatedir=/var \
+ -Dsharedstatedir=/var/lib \
+ -Dbuildtype=plain \
+ -Dauto_features=auto \
+ -Dwrap_mode=nodownload \
+ -Db_lto=true \
+ -Db_pie=true \
+ $build_opt \
+ build
+ ninja -C build
+ DESTDIR=$PKG meson install -C build
+
+2 - configure_build:
+ ./configure \
+ --prefix=/usr \
+ --sysconfdir=/etc \
+ --localstatedir=/var \
+ --libdir=/usr/lib \
+ --infodir=/usr/share/info \
+ --mandir=/usr/share/man \
+ $build_opt
+ make
+ make DESTDIR=$PKG install
+
+3 - cmake_build:
+ mkdir -p cmakebuild
+ cd cmakebuild
+ cmake \
+ -DCMAKE_INSTALL_PREFIX=/usr \
+ -DCMAKE_INSTALL_SYSCONFDIR=/etc \
+ -DCMAKE_INSTALL_LIBDIR=lib \
+ -DCMAKE_BUILD_TYPE=Release \
+ -DFETCHCONTENT_FULLY_DISCONNECTED=ON \
+ -DCMAKE_C_FLAGS_RELEASE="$CFLAGS" \
+ -DCMAKE_CXX_FLAGS_RELEASE="$CXXFLAGS" \
+ $build_opt \
+ -B build ..
+ if [ -f build.ninja ]; then
+ ninja
+ DESTDIR=$PKG ninja install
+ else
+ cmake --build build
+ DESTDIR=$PKG cmake --install build
+ fi
+
+4 - python_build:
+ python3 setup.py build
+ python3 setup.py install --prefix=/usr --root=$PKG --optimize=1 $build_opt
+
+5 - perlmodule_build:
+ perl Makefile.PL
+ make
+ make DESTDIR=$PKG install
+
+6 - makefile_build:
+ make \
+ PREFIX=/usr \
+ prefix=/usr \
+ SYSCONFDIR=/etc \
+ sysconfdir=/etc \
+ MANDIR=/usr/share/man \
+ mandir=/usr/share/man \
+ LIBDIR=/usr/lib \
+ PKGCONFIGDIR=/usr/lib/pkgconfig
+ make \
+ PREFIX=/usr \
+ prefix=/usr \
+ SYSCONFDIR=/etc \
+ sysconfdir=/etc \
+ MANDIR=/usr/share/man \
+ mandir=/usr/share/man \
+ LIBDIR=/usr/lib \
+ PKGCONFIGDIR=/usr/lib/pkgconfig \
+ DESTDIR=$PKG install
diff --git a/doc/postinstall.readme b/doc/postinstall.readme
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+# whatever command need to after package installed into system
diff --git a/doc/preinstall.readme b/doc/preinstall.readme
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+# whatever command need to run before build/install package
diff --git a/doc/readme b/doc/readme
@@ -0,0 +1,34 @@
+abuild recipe guidance
+======================
+
+- please read all availabe *.readme files
+
+abuild recipe tree
+------------------
+name - directory name, must be same as 'name' variable in abuild
+ |- abuild - package recipe (required)
+ |- preinstall - pre installation script (optional)
+ |- postinstall - post installation script (optional)
+ |- depends - dependencies list, one package per line (optional)
+ |- .checksum - source's b3sum, auto generated if not exist, can be manually generated using 'apkg -g'
+ \- .files - packages file list, will be generated after packaging, can be manually generated using 'apkg -k'
+
+building package
+----------------
+
+- run 'apkg' inside package recipe directory.
+ or
+- run 'apkg <package name>' if package recipe is created inside APKG_REPO directory (you can run 'apkg -p <package name>' to
+ print <package name>'s path if its in APKG_REPO path).
+
+installing package
+------------------
+
+- run 'apkg -i' or 'apkg -i <package name>' (same case as above).
+ or
+- run 'spm -i <path to prebuilt package file>' directly (installing this way will not execute pre/postinstall script and will
+ not trigger system database updates, you recomended to run 'apkg -t' afterwards)
+
+NOTE:
+- 'apkg -t' will update font cache, mime database, desktop database, gtkimodules, glib schema, giomodules and gdkpixbuf cache.
+- this trigger will automatically detected on which packages need to run.
diff --git a/man/apkg.conf.md b/man/apkg.conf.md
@@ -0,0 +1,45 @@
+# NAME
+
+**apkg.conf** - configuration file for apkg
+
+# DESCRIPTION
+
+**apkg.conf** is the configuration file for the **apkg** package manager for the alice linux distribution.
+It resides by default under `/etc` in an alice linux installation.
+The contents are sourced by the **apkg** program and are in the posix shell `key="value"` format.
+
+# CONFIGURATION KEYS
+
+- `APKG_NOPROMPT` If set, it enables non-interactive use by disabling user confirmation prompt.
+- `APKG_PACKAGE_DIR` Directory where the compiled packages will reside.
+- `APKG_SOURCE_DIR` Directory that will hold the downloaded sources.
+- `APKG_WORK_DIR` Directory where the actual building process will take place. This happens in subdirectories which are cleaned after completion.
+- `APKG_LOG` If set, it enables the creation of a log for the program output.
+- `export CFLAGS="<cflags>"` Default <cflags> are *-O3 -march=x86-64 -pipe*
+- `export CXXFLAGS="$CFLAGS"`
+- `export NINJAJOBS="<-x>"` Replace <-x> with the number of jobs the ninja build system with use. Without this it will use the maximum amount of threads the processor suports.
+- `export MAKEFLAGS="-jx"` Replace <x> with the number of jobs the make build system with use.
+
+EXAMPLES
+
+```
+### example of a valid apkg.conf ###
+export CFLAGS="-O3 -march=x86-64 -pipe"
+export CXXFLAGS="$CFLAGS"
+export MAKEFLAGS="-j12"
+export NINJAJOBS="12"
+APKG_REPO="/var/lib/alicelinux/repos/core /var/lib/alicelinux/repos/extra /var/lib/alicelinux/repos/xorg /var/lib/alicelinux/repos/wayland"
+APKG_PACKAGE_DIR=/var/cache/pkg
+APKG_SOURCE_DIR=/var/cache/src
+APKG_WORK_DIR=/var/cache/work
+```
+
+# AUTHORS
+
+emmett1 <emmett1.2miligrams@protonmail.com> Author of the program and creator of alice linux.
+
+mobinmob <mobinmob@disroot.org> Author of the man page.
+
+# REPORTING BUGS
+
+**apkg** is in a working stage but also under heavy development. Please report and bugs/issues in the project issue tracker: https://codeberg.org/emmett1/autils/issues
diff --git a/man/apkg.md b/man/apkg.md
@@ -0,0 +1,72 @@
+# NAME
+
+**apkg** - package building tool and package manager for alice linux
+
+# SYNOPSIS
+
+**apkg** [-i] [-I] [-d] [-D] [-j] [-u] [-r] [-t] [-U ] [-f] [-o] [-p] [-s] [-g] [-h] [*pkg(s)*]
+
+# DESCRIPTION
+
+**apkg** is the package build tool and package installer, along with **spm** for the alice linux distribution.
+It is written in posix shell with the goal to be simple and effective. It can consume package building templates in the abuild format
+and automate the building and installing of packages.
+
+# OPTIONS
+
+Arguments for apkg are as follows:
+
+- **-h** Print help.
+- **-i** *<pkg(s)>* Install package(s) without taking dependencies into account. Building will fail if the dependencies are not present in the system.
+- **-I** *<pkg(s)>* Install package(s) with dependencies.
+- **-d** *<pkg>* List only direct package dependencies
+- **-D** *<pkg(s)>* List all dependencies for package(s)
+- **-j** *<pkg>* List all reverse dependencies for the package (packages that depend on it).
+- **-u** *<pkg(s)>* Upgrade package(s)
+- **-r** *<pkg(s)>* Remove package(s)
+- **-t** *<pkg(s)>* Run scripts for package(s) that update cache or dbs (mime, font cache e.t.c)
+- **-U** Update system
+- **-f** Force rebuild a package.
+- **-o** *<pkg(s)>* Only download source for package(s), do not build and install
+- **-p** *<pkg(s)>* Print full path to the package build template directory
+- **-s** *<pattern>* Search for packages
+- **-g** *<pkg>* Update or generate checksum(s) for the package source files.
+
+# ENVIRONMENT VARIABLES
+
+- `APKG_ROOT` Overrides default root location (/), where sw is installed
+- `APKG_CONF` Overrides default location for the configuration file apkg.conf. The default is under /etc on an installed alice linux system.
+- `APKG_NOPROMPT` If set, it enabled non-interactive use by disabling user confirmation prompt.
+- `APKG_REPO` Double-quoted, space-separated list for the local directories that contain build templates.
+- `APKG_PACKAGE_DIR` Directory where the compiled packages will reside.
+- `APKG_SOURCE_DIR` Directory that will hold the downloaded sources.
+- `APKG_WORK_DIR` Directory where the actual building process will take place. This happens in subdirectories which are cleaned after completion.
+- `APKG_LOG` If set, it enables the creation of a log for the program output.
+
+**Note:** Usually, APKG_REPO, APKG_PACKAGE_DIR, APKG_SOURCE_DIR and APKG_WORK_DIR are declared in the apkg.conf configuration file. For more information, please see apkg.conf(5).
+
+# FILES
+
+- **apkg.conf(5)** is the default configuration file, it resides by default under /etc.
+- **abuild** is the name of the package templates that apkg uses, along with relevant files in order to
+build and installed packages. For example, one can look to the alice linux repos, under https://codeberg.org/emmett1/alicelinux/src/branch/main/repos
+
+# EXAMPLES
+
+`apkg -i linux` - Install the *linux* package
+
+`apkg -f jupp` - Force rebuild the *jupp* package. If someone tries with just `-i`, `apkg` will produce the following message
+if the package is already installed: `[...] Package 'jupp' already installed.`
+
+`apkg -s icon` - Search for packages names that contain "icon", it will produce a list with one
+package per line.
+
+# AUTHORS
+
+emmett1 <emmett1.2miligrams@protonmail.com> Author of the program and creator of alice linux.
+
+mobinmob <mobinmob@disroot.org> Author of the man page.
+
+# REPORTING BUGS
+
+**apkg** is in a working stage but also under heavy development. Please report and bugs/issues in the project issue tracker: https://codeberg.org/emmett1/autils/issues
diff --git a/man/make-man.sh b/man/make-man.sh
@@ -0,0 +1,32 @@
+#!/bin/sh
+
+# This script is derives from the original, written for Obarun Linux distribution by Eric Vidal.
+# The original is released under BSD Zero Clause licence (BSD0), and can be found at https://git.obarun.org/Obarun/66/-/blob/master/doc/make-man.sh?ref_type=heads.
+
+
+man8='apkg revdep'
+man5='apkg.conf'
+
+for i in 5 8;do
+ if [ ! -d man${i} ]; then
+ mkdir -p -m 0755 man"${i}" || exit 1
+ fi
+done
+
+for i in ${man5}; do
+ lowdown -s -Tman "${i}".md -o man5/"${i}".5 || exit 1
+ var=$( sed -n -e '/^.TH/p' < man5/"${i}".5)
+ var=$(printf '%s' "$var" | tr '7' '5')
+ sed -i "s!^.TH.*!${var}!" man5/"${i}".5 || exit 1
+ sed -i '4,8d' man5/"${i}".5 || exit 1
+done
+
+for i in ${man8}; do
+ lowdown -s -Tman "${i}".md -o man8/"${i}".8 || exit 1
+ var=$( sed -n -e '/^.TH/p' < man8/"${i}".8)
+ var=$(printf '%s' "$var" | tr '7' '8')
+ sed -i "s!^.TH.*!${var}!" man8/"${i}".8 || exit 1
+ sed -i '4,8d' man8/"${i}".8 || exit 1
+done
+
+exit 0
diff --git a/man/man5/apkg.conf.5 b/man/man5/apkg.conf.5
@@ -0,0 +1,86 @@
+.\" -*- mode: troff; coding: utf-8 -*-
+.TH "" "5" ""
+.SH NAME
+It resides by default under \f(CR/etc\fR in an alice linux installation.
+The contents are sourced by the \fBapkg\fR program and are in the posix shell \f(CRkey=\(dqvalue\(dq\fR format.
+.SH CONFIGURATION KEYS
+.IP "\(bu" 3
+\f(CRAPKG_NOPROMPT\fR If set, it enables non-interactive use by disabling user confirmation prompt.
+.if n \
+.sp -1
+.if t \
+.sp -0.25v
+.IP "\(bu" 3
+\f(CRAPKG_PACKAGE_DIR\fR Directory where the compiled packages will reside.
+.if n \
+.sp -1
+.if t \
+.sp -0.25v
+.IP "\(bu" 3
+\f(CRAPKG_SOURCE_DIR\fR Directory that will hold the downloaded sources.
+.if n \
+.sp -1
+.if t \
+.sp -0.25v
+.IP "\(bu" 3
+\f(CRAPKG_WORK_DIR\fR Directory where the actual building process will take place. This happens in subdirectories which are cleaned after completion.
+.if n \
+.sp -1
+.if t \
+.sp -0.25v
+.IP "\(bu" 3
+\f(CRAPKG_LOG\fR If set, it enables the creation of a log for the program output.
+.if n \
+.sp -1
+.if t \
+.sp -0.25v
+.IP "\(bu" 3
+\f(CRexport CFLAGS=\(dq<cflags>\(dq\fR Default are \fI-O3 -march=x86-64 -pipe\fR
+.if n \
+.sp -1
+.if t \
+.sp -0.25v
+.IP "\(bu" 3
+\f(CRexport CXXFLAGS=\(dq$CFLAGS\(dq\fR
+.if n \
+.sp -1
+.if t \
+.sp -0.25v
+.IP "\(bu" 3
+\f(CRexport NINJAJOBS=\(dq<-x>\(dq\fR Replace <-x> with the number of jobs the ninja build system with use. Without this it will use the maximum amount of threads the processor suports.
+.if n \
+.sp -1
+.if t \
+.sp -0.25v
+.IP "\(bu" 3
+\f(CRexport MAKEFLAGS=\(dq-jx\(dq\fR Replace with the number of jobs the make build system with use.
+.LP
+EXAMPLES
+.LP
+.EX
+### example of a valid apkg.conf ###
+export CFLAGS=\(dq-O3 -march=x86-64 -pipe\(dq
+export CXXFLAGS=\(dq$CFLAGS\(dq
+export MAKEFLAGS=\(dq-j12\(dq
+export NINJAJOBS=\(dq12\(dq
+APKG_REPO=\(dq/var/lib/alicelinux/repos/core /var/lib/alicelinux/repos/extra /var/lib/alicelinux/repos/xorg /var/lib/alicelinux/repos/wayland\(dq
+APKG_PACKAGE_DIR=/var/cache/pkg
+APKG_SOURCE_DIR=/var/cache/src
+APKG_WORK_DIR=/var/cache/work
+.EE
+.SH AUTHORS
+.LP
+emmett1 \c
+.MT emmett1.2miligrams@protonmail.com
+.ME
+Author of the program and creator of alice linux.
+.PP
+mobinmob \c
+.MT mobinmob@disroot.org
+.ME
+Author of the man page.
+.SH REPORTING BUGS
+.LP
+\fBapkg\fR is in a working stage but also under heavy development. Please report and bugs/issues in the project issue tracker: \c
+.UR https://codeberg.org/emmett1/autils/issues
+.UE
diff --git a/man/man8/apkg.8 b/man/man8/apkg.8
@@ -0,0 +1,181 @@
+.\" -*- mode: troff; coding: utf-8 -*-
+.TH "" "8" ""
+.SH NAME
+.SH DESCRIPTION
+.LP
+\fBapkg\fR is the package build tool and package installer, along with \fBspm\fR for the alice linux distribution.
+It is written in posix shell with the goal to be simple and effective. It can consume package building templates in the abuild format
+and automate the building and installing of packages.
+.SH OPTIONS
+.LP
+Arguments for apkg are as follows:
+.IP "\(bu" 3
+\fB-h\fR Print help.
+.if n \
+.sp -1
+.if t \
+.sp -0.25v
+.IP "\(bu" 3
+\fB-i\fR \fI\fR Install package(s) without taking dependencies into account. Building will fail if the dependencies are not present in the system.
+.if n \
+.sp -1
+.if t \
+.sp -0.25v
+.IP "\(bu" 3
+\fB-I\fR \fI\fR Install package(s) with dependencies.
+.if n \
+.sp -1
+.if t \
+.sp -0.25v
+.IP "\(bu" 3
+\fB-d\fR \fI\fR List only direct package dependencies
+.if n \
+.sp -1
+.if t \
+.sp -0.25v
+.IP "\(bu" 3
+\fB-D\fR \fI\fR List all dependencies for package(s)
+.if n \
+.sp -1
+.if t \
+.sp -0.25v
+.IP "\(bu" 3
+\fB-j\fR \fI\fR List all reverse dependencies for the package (packages that depend on it).
+.if n \
+.sp -1
+.if t \
+.sp -0.25v
+.IP "\(bu" 3
+\fB-u\fR \fI\fR Upgrade package(s)
+.if n \
+.sp -1
+.if t \
+.sp -0.25v
+.IP "\(bu" 3
+\fB-r\fR \fI\fR Remove package(s)
+.if n \
+.sp -1
+.if t \
+.sp -0.25v
+.IP "\(bu" 3
+\fB-t\fR \fI\fR Run scripts for package(s) that update cache or dbs (mime, font cache e.t.c)
+.if n \
+.sp -1
+.if t \
+.sp -0.25v
+.IP "\(bu" 3
+\fB-U\fR Update system
+.if n \
+.sp -1
+.if t \
+.sp -0.25v
+.IP "\(bu" 3
+\fB-f\fR Force rebuild a package.
+.if n \
+.sp -1
+.if t \
+.sp -0.25v
+.IP "\(bu" 3
+\fB-o\fR \fI\fR Only download source for package(s), do not build and install
+.if n \
+.sp -1
+.if t \
+.sp -0.25v
+.IP "\(bu" 3
+\fB-p\fR \fI\fR Print full path to the package build template directory
+.if n \
+.sp -1
+.if t \
+.sp -0.25v
+.IP "\(bu" 3
+\fB-s\fR \fI\fR Search for packages
+.if n \
+.sp -1
+.if t \
+.sp -0.25v
+.IP "\(bu" 3
+\fB-g\fR \fI\fR Update or generate checksum(s) for the package source files.
+.SH ENVIRONMENT VARIABLES
+.IP "\(bu" 3
+\f(CRAPKG_ROOT\fR Overrides default root location (/), where sw is installed
+.if n \
+.sp -1
+.if t \
+.sp -0.25v
+.IP "\(bu" 3
+\f(CRAPKG_CONF\fR Overrides default location for the configuration file apkg.conf. The default is under /etc on an installed alice linux system.
+.if n \
+.sp -1
+.if t \
+.sp -0.25v
+.IP "\(bu" 3
+\f(CRAPKG_NOPROMPT\fR If set, it enabled non-interactive use by disabling user confirmation prompt.
+.if n \
+.sp -1
+.if t \
+.sp -0.25v
+.IP "\(bu" 3
+\f(CRAPKG_REPO\fR Double-quoted, space-separated list for the local directories that contain build templates.
+.if n \
+.sp -1
+.if t \
+.sp -0.25v
+.IP "\(bu" 3
+\f(CRAPKG_PACKAGE_DIR\fR Directory where the compiled packages will reside.
+.if n \
+.sp -1
+.if t \
+.sp -0.25v
+.IP "\(bu" 3
+\f(CRAPKG_SOURCE_DIR\fR Directory that will hold the downloaded sources.
+.if n \
+.sp -1
+.if t \
+.sp -0.25v
+.IP "\(bu" 3
+\f(CRAPKG_WORK_DIR\fR Directory where the actual building process will take place. This happens in subdirectories which are cleaned after completion.
+.if n \
+.sp -1
+.if t \
+.sp -0.25v
+.IP "\(bu" 3
+\f(CRAPKG_LOG\fR If set, it enables the creation of a log for the program output.
+.LP
+\fBNote:\fR Usually, APKG\fIREPO, APKG\fRPACKAGE\fIDIR, APKG\fRSOURCE\fIDIR and APKG\fRWORK_DIR are declared in the apkg.conf configuration file. For more information, please see apkg.conf(5).
+.SH FILES
+.IP "\(bu" 3
+\fBapkg.conf(5)\fR is the default configuration file, it resides by default under /etc.
+.if n \
+.sp -1
+.if t \
+.sp -0.25v
+.IP "\(bu" 3
+\fBabuild\fR is the name of the package templates that apkg uses, along with relevant files in order to
+build and installed packages. For example, one can look to the alice linux repos, under \c
+.UR https://codeberg.org/emmett1/alicelinux/src/branch/main/repos
+.UE
+.SH EXAMPLES
+.LP
+\f(CRapkg -i linux\fR - Install the \fIlinux\fR package
+.PP
+\f(CRapkg -f jupp\fR - Force rebuild the \fIjupp\fR package. If someone tries with just \f(CR-i\fR, \f(CRapkg\fR will produce the following message
+if the package is already installed: \f(CR[...] Package 'jupp' already installed.\fR
+.PP
+\f(CRapkg -s icon\fR - Search for packages names that contain \(lqicon\(rq, it will produce a list with one
+package per line.
+.SH AUTHORS
+.LP
+emmett1 \c
+.MT emmett1.2miligrams@protonmail.com
+.ME
+Author of the program and creator of alice linux.
+.PP
+mobinmob \c
+.MT mobinmob@disroot.org
+.ME
+Author of the man page.
+.SH REPORTING BUGS
+.LP
+\fBapkg\fR is in a working stage but also under heavy development. Please report and bugs/issues in the project issue tracker: \c
+.UR https://codeberg.org/emmett1/autils/issues
+.UE
diff --git a/man/man8/revdep.8 b/man/man8/revdep.8
@@ -0,0 +1,34 @@
+.\" -*- mode: troff; coding: utf-8 -*-
+.TH "" "8" ""
+.SH NAME
+it can discover programs that need to be rebuilt after library upgrades or are missing libraries.
+It should probably run after any big upgrade, especially those that feature lib version bumps.
+.SH OPTIONS
+.IP "\(bu" 3
+\fB-h\fR Show program help.
+.if n \
+.sp -1
+.if t \
+.sp -0.25v
+.IP "\(bu" 3
+\fB-v\fR Verbose output of the operation.
+.SH NOTE
+.LP
+\fBrevdep\fR does not automatically rebuild broken packages or their dependencies. You need to
+use apkg for these operations.
+.SH REPORTING BUGS
+.LP
+\fBapkg\fR is in a working stage but also under heavy development. Please report and bugs/issues in the project issue tracker: \c
+.UR https://codeberg.org/emmett1/autils/issues
+.UE
+.SH AUTHORS
+.LP
+emmett1 \c
+.MT emmett1.2miligrams@protonmail.com
+.ME
+Author of the program and creator of alice linux.
+.PP
+mobinmob \c
+.MT mobinmob@disroot.org
+.ME
+Author of the man page.
diff --git a/man/revdep.md b/man/revdep.md
@@ -0,0 +1,29 @@
+# NAME
+
+**revdep** - utility to discover and rebuild reverse deps
+
+# DESCRIPTION
+
+**revdep** is a utility inspired by the gentoo program revdep-rebuild. It is written in posix shell and
+it can discover programs that need to be rebuilt after library upgrades or are missing libraries.
+It should probably run after any big upgrade, especially those that feature lib version bumps.
+
+# OPTIONS
+
+- **-h** Show program help.
+- **-v** Verbose output of the operation.
+
+# NOTE
+
+**revdep** does not automatically rebuild broken packages or their dependencies. You need to
+use apkg for these operations.
+
+# REPORTING BUGS
+
+**apkg** is in a working stage but also under heavy development. Please report and bugs/issues in the project issue tracker: https://codeberg.org/emmett1/autils/issues
+
+# AUTHORS
+
+emmett1 <emmett1.2miligrams@protonmail.com> Author of the program and creator of alice linux.
+
+mobinmob <mobinmob@disroot.org> Author of the man page.
diff --git a/reposync b/reposync
@@ -0,0 +1,98 @@
+#!/bin/sh -e
+#
+# script to sync repos
+# required /etc/reposync.conf
+#
+# /etc/reposync.conf format:
+# <git url>|<branch>|<local path to sync>
+#
+
+log() {
+ msg="$1"
+ if [ "$LOG" ]; then
+ echo "$(date +'%Y-%m-%d %H:%M:%S') $msg" | tee -a "$LOGFILE"
+ else
+ echo "$msg"
+ fi
+}
+
+run_cmd() {
+ if [ "$DRY_RUN" ]; then
+ log " [dry-run] $*"
+ else
+ log " $*"
+ eval "$@"
+ fi
+}
+
+syncrepo() {
+ url=$1
+ branch=$2
+ path=$3
+
+ # if url is empty, do nothing
+ if [ ! "$url" ]; then
+ exit 0
+ fi
+
+ # if $path empty, your format is wrong
+ if [ ! "$path" ]; then
+ echo "/etc/reposync.conf format: <git url>|<branch>|<local path to sync>"
+ exit
+ fi
+
+ if [ "$FORCE" ]; then
+ if [ -d "$path" ]; then
+ log "=> Force removing repo directory $path..."
+ run_cmd "rm -rf \"$path\""
+ fi
+ fi
+
+ if [ ! -d "$path/.git" ]; then
+ log "=> Sync repo $path..."
+ run_cmd "mkdir -p \"$path\""
+ run_cmd "git clone --branch \"$branch\" --single-branch \"$url\" \"$path\""
+ else
+ log "=> Updating repo $path..."
+ run_cmd "cd \"$path\" && git fetch origin \"$branch\""
+ run_cmd "cd \"$path\" && git reset --hard \"origin/$branch\""
+ run_cmd "cd \"$path\" && git clean -fdx"
+ fi
+}
+
+usage() {
+ echo "Usage: $0 [-n|-l|-f]"
+ echo " -n dry-run"
+ echo " -l logging (/var/log/reposync.log)"
+ echo " -f force sync"
+ exit 1
+}
+
+while [ "$1" ]; do
+ case "$1" in
+ -n) DRY_RUN=1;;
+ -l) LOG=1;;
+ -f) FORCE=1;;
+ -h) usage;;
+ esac
+ shift
+done
+
+command -v git >/dev/null 2>&1 || {
+ echo "error: git is not installed." >&2
+ exit 1
+}
+
+LOGFILE="/var/log/reposync.log"
+CONFFILE="/etc/reposync.conf"
+
+if [ ! -f "$CONFFILE" ]; then
+ echo "error: config file not found: $CONFFILE" >&2
+ exit 1
+fi
+
+grep -Ev '^#|^$' "$CONFFILE" | while IFS='|' read -r url branch path _; do
+ syncrepo "$url" "$branch" "$path"
+done
+
+exit 0
diff --git a/revdep b/revdep
@@ -0,0 +1,63 @@
+#!/bin/sh
+
+SEARCH_DIRS="/bin /usr/bin /sbin /usr/sbin /lib /usr/lib /usr/libexec"
+TMPFILE=$(mktemp)
+
+if [ -d /etc/revdep.d ] && [ "$(ls -1 /etc/revdep.d)" ]; then
+ for line in $(cat /etc/revdep.d/*); do
+ LD_LIBRARY_PATH="$line:$LD_LIBRARY_PATH"
+ done
+ export LD_LIBRARY_PATH
+fi
+
+trap 'rm -f $TMPFILE; printf "\033[0K"; exit 1' 1 2 3 15
+
+while [ "$1" ]; do
+ case $1 in
+ -v) verbose=1;;
+ -h) help=1;;
+ esac
+ shift
+done
+
+find $SEARCH_DIRS -type f \( -perm /+u+x -o -name '*.so' -o -name '*.so.*' \) -print 2> /dev/null | sort -u > $TMPFILE
+total=$(wc -l $TMPFILE | awk '{print $1}')
+count=0
+while read -r line; do
+ count=$(( count + 1 ))
+ libname=${line##*/}
+ if [ "$verbose" ]; then
+ printf " $(( 100*count/total ))%% $libname\033[0K\r"
+ fi
+ case "$(file -bi "$line")" in
+ *application/x-sharedlib* | *application/x-executable* | *application/x-pie-executable*)
+ if [ -e /lib/ld-musl-x86_64.so.1 ] || [ -e /usr/lib/ld-musl-x86_64.so.1 ]; then
+ # musl system
+ missinglib=$(ldd /$line 2>&1 | grep "Error loading shared library" | awk '{print $5}' | sed 's/://' | sort | uniq)
+ else
+ # glibc system
+ missinglib=$(ldd /$line 2>&1 | grep "not found" | awk '{print $1}' | sort | uniq)
+ fi
+ if [ "$missinglib" ]; then
+ for i in $missinglib; do
+ objdump -p $line | grep NEEDED | awk '{print $2}' | grep -qx $i && {
+ ownby=$(spm -o ^${line#/}$ | head -n1 | awk '{print $1}')
+ [ "$ownby" ] || continue
+ if [ "$verbose" ]; then
+ echo " $ownby: $line (requires $i)"
+ else
+ [ "$(echo "$p" | tr ' ' '\n' | grep -x $ownby)" ] || {
+ echo $ownby
+ p="$p $ownby"
+ }
+ fi
+ }
+ done
+ fi;;
+ esac
+done < $TMPFILE
+printf "\033[0K"
+
+rm -f $TMPFILE
+
+exit 0
diff --git a/updateconf b/updateconf
@@ -0,0 +1,64 @@
+#!/bin/sh
+
+EDITOR=${EDITOR:-vi}
+
+command -v $EDITOR >/dev/null || {
+ echo "Editor '$EDITOR' not exist. Append 'EDITOR=<your editor>' to ${0##*/}."
+ exit 2
+}
+
+[ "$(id -u)" = 0 ] || {
+ echo "This operation need root access. Exiting..."
+ exit 1
+}
+
+pkgnew=$(find /etc -type f -name "*.new" 2> /dev/null)
+
+[ "$pkgnew" ] || {
+ echo "Nothing to do. Exiting..."
+ exit 0
+}
+
+for file in $pkgnew; do
+ currentfile=${file%.*}
+ if [ ! -e "$currentfile" ]; then
+ echo "Remove '$file', '$currentfile' not exist."
+ rm -f "$file"
+ sleep 0.5
+ continue
+ fi
+ while true; do
+ clear
+ diff -u $currentfile $file #--color=always
+ if [ $? = 0 ]; then
+ echo "Remove '$file', no diff found."
+ rm -f "$file"
+ sleep 1
+ break
+ fi
+ echo
+ echo "File: $currentfile"
+ echo
+ printf "[U]pdate [D]iscard [E]dit [K]eep ?: "
+ read ACTION
+ echo
+ case $ACTION in
+ U|u) echo "Replace '$currentfile' with '$file'."
+ mv -f "$file" "$currentfile"
+ break;;
+ D|d) echo "Remove '$file'."
+ rm -f "$file"
+ break;;
+ E|e) vim "$currentfile";;
+ K|k) echo "Keeping both."
+ break;;
+ esac
+ done
+ sleep 0.5
+done
+
+clear
+
+echo "Done updating package's configuration files."
+
+exit 0