mirror of
https://gitee.com/amber-ce/amber-pm
synced 2026-06-22 22:23:56 +08:00
Compare commits
58 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 737e7d4979 | |||
| 379cd37fac | |||
| a2f0af2ca7 | |||
| 5c811840fa | |||
| a615cf0b72 | |||
| 8736cf13b8 | |||
| 9702df0410 | |||
| 9708cd7034 | |||
| efa5204b53 | |||
| 8c6ed8b965 | |||
| 8d49cec009 | |||
| 4aaef32ba9 | |||
| e088cca383 | |||
| 03ae4e6129 | |||
| e8c3ab67dd | |||
| 87342fdabd | |||
| c842ff767f | |||
| ee9908ed16 | |||
| 0485303c1b | |||
| 985c23a3f9 | |||
| 616a305739 | |||
| fdf96c7fab | |||
| 993b220ef4 | |||
| 340811523c | |||
| 9b3f8acc58 | |||
| b2dd1d2bd3 | |||
| d85a84fed1 | |||
| d9548f9f39 | |||
| 41aede9bbe | |||
| 7f1851b5cc | |||
| ba292e3870 | |||
| f22f0c95fa | |||
| 8988e94ad1 | |||
| 8c780d8c80 | |||
| ea0c263bf9 | |||
| f8e0667b1b | |||
| 785b83b15b | |||
| f999da97c8 | |||
| a27df804f2 | |||
| ff73778e4b | |||
| 365e31677b | |||
| 486d1d6d5f | |||
| 45250753db | |||
| e754932ba3 | |||
| 091176d017 | |||
| dfae67271b | |||
| 7900e8af3b | |||
| bb7ee02aec | |||
| e771446966 | |||
| bb5bae062d | |||
| f0ccb2f7ed | |||
| 092fb41740 | |||
| c1b464be04 | |||
| a34e9264a9 | |||
| f696793572 | |||
| be5954c95e | |||
| 90553f6737 | |||
| af20707f71 |
@@ -0,0 +1,661 @@
|
||||
GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
Version 3, 19 November 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU Affero General Public License is a free, copyleft license for
|
||||
software and other kinds of works, specifically designed to ensure
|
||||
cooperation with the community in the case of network server software.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
our General Public Licenses are intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
Developers that use our General Public Licenses protect your rights
|
||||
with two steps: (1) assert copyright on the software, and (2) offer
|
||||
you this License which gives you legal permission to copy, distribute
|
||||
and/or modify the software.
|
||||
|
||||
A secondary benefit of defending all users' freedom is that
|
||||
improvements made in alternate versions of the program, if they
|
||||
receive widespread use, become available for other developers to
|
||||
incorporate. Many developers of free software are heartened and
|
||||
encouraged by the resulting cooperation. However, in the case of
|
||||
software used on network servers, this result may fail to come about.
|
||||
The GNU General Public License permits making a modified version and
|
||||
letting the public access it on a server without ever releasing its
|
||||
source code to the public.
|
||||
|
||||
The GNU Affero General Public License is designed specifically to
|
||||
ensure that, in such cases, the modified source code becomes available
|
||||
to the community. It requires the operator of a network server to
|
||||
provide the source code of the modified version running there to the
|
||||
users of that server. Therefore, public use of a modified version, on
|
||||
a publicly accessible server, gives the public access to the source
|
||||
code of the modified version.
|
||||
|
||||
An older license, called the Affero General Public License and
|
||||
published by Affero, was designed to accomplish similar goals. This is
|
||||
a different license, not a version of the Affero GPL, but Affero has
|
||||
released a new version of the Affero GPL which permits relicensing under
|
||||
this license.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU Affero General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source 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. Remote Network Interaction; Use with the GNU General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, if you modify the
|
||||
Program, your modified version must prominently offer all users
|
||||
interacting with it remotely through a computer network (if your version
|
||||
supports such interaction) an opportunity to receive the Corresponding
|
||||
Source of your version by providing access to the Corresponding Source
|
||||
from a network server at no charge, through some standard or customary
|
||||
means of facilitating copying of software. This Corresponding Source
|
||||
shall include the Corresponding Source for any work covered by version 3
|
||||
of the GNU General Public License that is incorporated pursuant to the
|
||||
following paragraph.
|
||||
|
||||
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 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 work with which it is combined will remain governed by version
|
||||
3 of the GNU General Public License.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU Affero 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 Affero 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 Affero 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 Affero 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 Affero 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 Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero 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 your software can interact with users remotely through a computer
|
||||
network, you should also make sure that it provides a way for users to
|
||||
get its source. For example, if your program is a web application, its
|
||||
interface could display a "Source" link that leads users to an archive
|
||||
of the code. There are many ways you could offer source, and different
|
||||
solutions will be better for different programs; see section 13 for the
|
||||
specific requirements.
|
||||
|
||||
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 AGPL, see
|
||||
<https://www.gnu.org/licenses/>.
|
||||
@@ -1,10 +1,24 @@
|
||||
# APM 原理和软件包制作流程
|
||||
# APM
|
||||
|
||||
|
||||
|
||||
APM 是一款基于 fuse-overlayfs , dpkg , ACE 的容器软件包管理系统
|
||||
|
||||
源码在 src
|
||||
|
||||
原理:https://www.cnblogs.com/arnoldlu/p/13055501.html
|
||||
|
||||
## 体验demo: 查看 https://gitee.com/amber-ce/amber-pm/releases
|
||||
|
||||
|
||||
|
||||
制作apm包upperdir的流程
|
||||
|
||||
先安装base包(从release)
|
||||
先安装 apm (从release)
|
||||
|
||||
sudo mount -t overlay overlay -o lowerdir='/var/lib/apm/amber-pm-trixie-host/files/ace-env',upperdir=core/,workdir=work/ ./ace-env
|
||||
sudo apm install base包后,在
|
||||
|
||||
sudo mount -t overlay overlay -o lowerdir='/var/lib/apm/apm/files/ace-env/var/lib/apm/amber-pm-trixie/files/ace-env',upperdir=core/,workdir=work/ ./ace-env
|
||||
|
||||
随后chroot进入进行安装操作,直接进行 apt install 或者其他都可以,完成后
|
||||
|
||||
@@ -13,15 +27,19 @@ work: 保存变更信息
|
||||
需把这两个目录重新拥有并权限换成755
|
||||
|
||||
|
||||
fuse-overlayfs -o lowerdir='/var/lib/apm/amber-pm-trixie-host/files/ace-env',upperdir=core/,workdir=work/ ./ace-env
|
||||
fuse-overlayfs -o lowerdir='/var/lib/apm/apm/files/ace-env/var/lib/apm/amber-pm-trixie/files/ace-env',upperdir=core/,workdir=work/ ./ace-env
|
||||
|
||||
即可只读挂载并进行ace操作
|
||||
即可只读挂载。这一步 apm run 包名 会帮你做好。
|
||||
|
||||
spec:
|
||||
对于lowerdir
|
||||
> apm run 包名: 寻找 /var/lib/apm/包名/是否存在。若存在,根据info文件合成 fuser-overlayfs 参数进行挂载,随后用ACE工具chroot进入进行启动
|
||||
|
||||
./ace-run 即可进入,可以尝试启动一下刚刚安装的应用
|
||||
|
||||
spec(对于APM内的包):
|
||||
对于base
|
||||
/var/lib/apm/包名/files/ace-env 是 lowerdir
|
||||
|
||||
对于upperdir
|
||||
对于core
|
||||
/var/lib/apm/包名/files/core是upperdir
|
||||
/var/lib/apm/包名/files/work是upperdir的work
|
||||
/var/lib/apm/包名/files/ace-env是chroot进的目录(需要在打包好的包内加上允许读写这个目录——或者后续换成tmp的挂载点)
|
||||
@@ -29,5 +47,4 @@ spec:
|
||||
/var/lib/apm/包名/entries是desktop位置,后续会加到自动展示中
|
||||
|
||||
|
||||
|
||||
apm run 包名: 寻找 /var/lib/apm/包名/是否存在。若存在,根据info文件合成 fuser-overlayfs 参数进行挂载,随后用ACE工具chroot进入进行启动
|
||||
core的依赖需要写base
|
||||
|
||||
Executable
+9
@@ -0,0 +1,9 @@
|
||||
Package: apm
|
||||
Version: 1.1
|
||||
Maintainer: shenmo <jifengshenmo@outlook.com>
|
||||
Priority: optional
|
||||
Section: utils
|
||||
Installed-Size: 36
|
||||
Description: A empty package to satisfy depends
|
||||
Architecture: all
|
||||
Homepage: https://shenmo7192.gitee.io/
|
||||
Executable
+15
@@ -0,0 +1,15 @@
|
||||
#!/bin/bash
|
||||
export PACKAGE_NAME="$DPKG_MAINTSCRIPT_PACKAGE"
|
||||
|
||||
|
||||
case "$1" in
|
||||
triggered)
|
||||
amber-pm-dstore-patch
|
||||
|
||||
;;
|
||||
esac
|
||||
|
||||
|
||||
|
||||
|
||||
true
|
||||
Executable
+1
@@ -0,0 +1 @@
|
||||
interest-noawait /var/lib/apm
|
||||
Executable
+174
@@ -0,0 +1,174 @@
|
||||
#!/bin/bash
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
enumAppInfoList() {
|
||||
appInfoList=()
|
||||
apps="/var/lib/apm"
|
||||
list=$(ls $apps 2>/dev/null)
|
||||
for appID in $list; do
|
||||
appInfoList+=("$appID")
|
||||
done
|
||||
echo "${appInfoList[@]}"
|
||||
}
|
||||
linkDir() {
|
||||
ensureTargetDir() {
|
||||
targetFile=$1
|
||||
t=$(dirname "$targetFile")
|
||||
mkdir -p "$t"
|
||||
}
|
||||
|
||||
source=$1
|
||||
target=$2
|
||||
sourceDir=$(dirname "$source")
|
||||
targetDir=$(dirname "$target")
|
||||
find "$source" -type f | while read sourceFile; do
|
||||
targetFile="$targetDir/${sourceFile#$sourceDir/}"
|
||||
|
||||
|
||||
ensureTargetDir "$targetFile"
|
||||
sourceFile=$(realpath --relative-to="$(dirname $targetFile)" "$sourceFile" )
|
||||
if [ ! -e ${targetFile} ];then
|
||||
ln -sv "$sourceFile" "$targetFile"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
linkApp() {
|
||||
appID=$1
|
||||
appEntriesDir="/var/lib/apm/$appID/entries"
|
||||
appLibsDir="/var/lib/apm/$appID/files/lib"
|
||||
autoStartDir="$appEntriesDir/autostart"
|
||||
|
||||
if [ -d "$autoStartDir" ]; then
|
||||
linkDir "$autoStartDir" "/etc/xdg/autostart"
|
||||
fi
|
||||
|
||||
# link application
|
||||
sysShareDir="/usr/share"
|
||||
for folder in "$appEntriesDir/applications" "$appEntriesDir/icons" "$appEntriesDir/mime" "$appEntriesDir/glib-2.0" "$appEntriesDir/services" "$appEntriesDir/GConf" "$appEntriesDir/help" "$appEntriesDir/locale" "$appEntriesDir/fcitx"; do
|
||||
if [ ! -d "$folder" ]; then
|
||||
continue
|
||||
fi
|
||||
if [ "$folder" = "$appEntriesDir/polkit" ]; then
|
||||
linkDir "$folder" "/usr/share/polkit-1"
|
||||
elif [ "$folder" = "$appEntriesDir/fonts/conf" ]; then
|
||||
linkDir "$folder" "/etc/fonts/conf.d"
|
||||
else
|
||||
linkDir "$folder" "$sysShareDir/${folder##*/}"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
function exec_uos_package_link(){
|
||||
|
||||
for app in $(enumAppInfoList); do
|
||||
linkApp "$app" &
|
||||
|
||||
done
|
||||
wait
|
||||
}
|
||||
|
||||
function exec_v23_icon_link(){
|
||||
# Fix v23 broken icon
|
||||
if [ ! -d "/usr/share/icons/hicolor/scalable/apps" ];then
|
||||
mkdir -p /usr/share/icons/hicolor/scalable/apps
|
||||
fi
|
||||
|
||||
for icon_root_icon_path in $(ls /usr/share/icons/*.png /usr/share/icons/*.svg 2>/dev/null)
|
||||
do
|
||||
target_icon_path=/usr/share/icons/hicolor/scalable/apps/$(basename ${icon_root_icon_path})
|
||||
if [ ! -e ${target_icon_path} ];then
|
||||
ln -sv $(realpath --relative-to=/usr/share/icons/hicolor/scalable/apps ${icon_root_icon_path}) /usr/share/icons/hicolor/scalable/apps
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
function exec_link_clean(){
|
||||
# remove broken links in /usr/share
|
||||
|
||||
find /usr/share/applications -xtype l -exec echo '{} is invalid now and going to be cleaned' \; -exec unlink {} \; 2>/dev/null &
|
||||
find /usr/share/icons -xtype l -exec echo '{} is invalid now and going to be cleaned' \; -exec unlink {} \; 2>/dev/null &
|
||||
find /usr/share/mime/packages -xtype l -exec echo '{} is invalid now and going to be cleaned' \; -exec unlink {} \; 2>/dev/null &
|
||||
find /usr/share/glib-2.0 -xtype l -exec echo '{} is invalid now and going to be cleaned' \; -exec unlink {} \; 2>/dev/null &
|
||||
find /usr/share/dbus-1/services -xtype l -exec echo '{} is invalid now and going to be cleaned' \; -exec unlink {} \; 2>/dev/null &
|
||||
find /usr/share/fcitx -xtype l -exec echo '{} is invalid now and going to be cleaned' \; -exec unlink {} \; 2>/dev/null &
|
||||
find /usr/share/help -xtype l -exec echo '{} is invalid now and going to be cleaned' \; -exec unlink {} \; 2>/dev/null &
|
||||
find /usr/share/locale -xtype l -exec echo '{} is invalid now and going to be cleaned' \; -exec unlink {} \; 2>/dev/null &
|
||||
find /usr/lib/$(gcc -dumpmachine)/fcitx -xtype l -exec echo '{} is invalid now and going to be cleaned' \; -exec unlink {} \; 2>/dev/null &
|
||||
find /usr/lib/mozilla/plugins -xtype l -exec echo '{} is invalid now and going to be cleaned' \; -exec unlink {} \; 2>/dev/null &
|
||||
find /usr/share/polkit-1/actions -xtype l -exec echo '{} is invalid now and going to be cleaned' \; -exec unlink {} \; 2>/dev/null &
|
||||
find /usr/share/fonts -xtype l -exec echo '{} is invalid now and going to be cleaned' \; -exec unlink {} \; 2>/dev/null &
|
||||
find /etc/fonts/conf.d -xtype l -exec echo '{} is invalid now and going to be cleaned' \; -exec unlink {} \; 2>/dev/null &
|
||||
|
||||
|
||||
}
|
||||
function exec_uos_package_update(){
|
||||
update-icon-caches /usr/share/icons/* > /dev/null 2>&1 &
|
||||
update-desktop-database -q > /dev/null 2>&1 &
|
||||
update-mime-database -V /usr/share/mime > /dev/null 2>&1 &
|
||||
glib-compile-schemas /usr/share/glib-2.0/schemas/ > /dev/null 2>&1 &
|
||||
|
||||
}
|
||||
|
||||
function exec_debian_compatibile_links(){
|
||||
# 源目录和目标目录定义
|
||||
local SOURCE_DIR="/var/lib/apm"
|
||||
local TARGET_DIR="/var/lib/apm/apm/files/ace-env/var/lib/apm"
|
||||
|
||||
# 检查目标目录是否存在
|
||||
if [[ ! -d "$TARGET_DIR" ]]; then
|
||||
mkdir -p $TARGET_DIR
|
||||
fi
|
||||
|
||||
# 第一部分:为缺失的目录创建软链接
|
||||
echo "检查并创建缺失的软链接..."
|
||||
for dir in "$SOURCE_DIR"/*/; do
|
||||
# 获取目录名(去掉路径和尾部斜杠)
|
||||
dirname=$(basename "$dir")
|
||||
|
||||
# 跳过 apm 目录
|
||||
if [[ "$dirname" == "apm" ]]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
# 检查目标目录中是否已存在对应的软链接或目录
|
||||
target_link="$TARGET_DIR/$dirname"
|
||||
if [[ ! -e "$target_link" ]]; then
|
||||
echo "创建软链接: $target_link -> $dir"
|
||||
ln -sv "$dir" "$target_link"
|
||||
fi
|
||||
done
|
||||
|
||||
# 第二部分:清理无效的软链接
|
||||
echo "清理无效的软链接..."
|
||||
for link in "$TARGET_DIR"/*; do
|
||||
# 检查是否为软链接
|
||||
if [[ -L "$link" ]]; then
|
||||
# 检查软链接是否有效(指向的目标是否存在)
|
||||
if [[ ! -e "$link" ]]; then
|
||||
echo "删除无效软链接: $link"
|
||||
rm "$link"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
}
|
||||
#########################################################################################
|
||||
echo "----------------Running APM Dstore Patch----------------"
|
||||
|
||||
# execute linkApp function for each app and print output
|
||||
exec_uos_package_link
|
||||
|
||||
|
||||
#exec_v23_icon_link
|
||||
exec_link_clean
|
||||
wait
|
||||
exec_uos_package_update
|
||||
if [[ "${IS_APM_ENV}" = "" ]];then
|
||||
exec_debian_compatibile_links
|
||||
fi
|
||||
|
||||
echo "----------------Finished----------------"
|
||||
Executable
+13
@@ -0,0 +1,13 @@
|
||||
Package: apm
|
||||
Source: amber-ce
|
||||
Version: 1.0.9
|
||||
Architecture: amd64
|
||||
Maintainer: shenmo <shenmo@spark-app.store>
|
||||
Installed-Size: 48716
|
||||
Depends: bubblewrap, flatpak, policykit-1 | pkexec | polkit-1 | polkit, systemd, procps,coreutils,fuse-overlayfs,xz-utils
|
||||
Section: misc
|
||||
Conflicts: ace-host-integration
|
||||
Priority: optional
|
||||
Multi-Arch: foreign
|
||||
Homepage: https://gitee.com/amber-ce/amber-pm/
|
||||
Description: bwrap wrapper for install and running debs inside a Amber-PM container
|
||||
Executable
+29
@@ -0,0 +1,29 @@
|
||||
#!/bin/bash
|
||||
export PACKAGE_NAME="$DPKG_MAINTSCRIPT_PACKAGE"
|
||||
|
||||
|
||||
case "$1" in
|
||||
configure)
|
||||
/var/lib/apm/$PACKAGE_NAME/files/bin/ace-init
|
||||
systemctl daemon-reload
|
||||
systemctl enable apm-daily-update
|
||||
systemctl start apm-daily-update
|
||||
systemctl restart apparmor.service || true
|
||||
|
||||
if [ -f /usr/lib/sysctl.d/apm.conf ];then
|
||||
sysctl -p /usr/lib/sysctl.d/apm.conf
|
||||
fi
|
||||
|
||||
|
||||
;;
|
||||
triggered)
|
||||
amber-pm-configure-nvidia-host
|
||||
amber-pm-dstore-patch
|
||||
|
||||
;;
|
||||
esac
|
||||
|
||||
|
||||
|
||||
|
||||
true
|
||||
Executable
+18
@@ -0,0 +1,18 @@
|
||||
#!/bin/bash
|
||||
PACKAGE_NAME="$DPKG_MAINTSCRIPT_PACKAGE"
|
||||
systemctl stop apm-daily-update
|
||||
systemctl disable apm-daily-update
|
||||
|
||||
|
||||
|
||||
if [ "$1" = "remove" ] || [ "$1" = "purge" ];then
|
||||
|
||||
echo "清理卸载残留"
|
||||
|
||||
rm -rf /var/lib/apm/
|
||||
else
|
||||
echo "非卸载,跳过清理"
|
||||
fi
|
||||
|
||||
|
||||
|
||||
Executable
+1
@@ -0,0 +1 @@
|
||||
interest-noawait /var/lib/apm
|
||||
Executable
+17
@@ -0,0 +1,17 @@
|
||||
|
||||
|
||||
|
||||
|
||||
# Ensure base distro defaults xdg path are set if nothing filed up some
|
||||
# defaults yet.
|
||||
if [ -z "$XDG_DATA_DIRS" ]; then
|
||||
export XDG_DATA_DIRS="/usr/local/share:/usr/share"
|
||||
fi
|
||||
|
||||
# Desktop files (used by desktop environments within both X11 and Wayland) are
|
||||
# looked for in XDG_DATA_DIRS; make sure it includes the relevant directory for ACE
|
||||
ACE_path="/var/lib/apm/apm/files/ace-env/amber-ce-tools/data-dir/"
|
||||
if [ -n "${XDG_DATA_DIRS##*${ACE_path}}" ] && [ -n "${XDG_DATA_DIRS##*${ACE_path}:*}" ]; then
|
||||
export XDG_DATA_DIRS="${XDG_DATA_DIRS}:${ACE_path}"
|
||||
fi
|
||||
|
||||
Executable
+9
@@ -0,0 +1,9 @@
|
||||
abi <abi/4.0>,
|
||||
include <tunables/global>
|
||||
|
||||
profile bwrap /usr/bin/bwrap flags=(unconfined) {
|
||||
userns,
|
||||
|
||||
# Site-specific additions and overrides. See local/README for details.
|
||||
include if exists <local/bwrap>
|
||||
}
|
||||
Executable
+16
@@ -0,0 +1,16 @@
|
||||
|
||||
|
||||
|
||||
# Ensure base distro defaults xdg path are set if nothing filed up some
|
||||
# defaults yet.
|
||||
if [ -z "$XDG_DATA_DIRS" ]; then
|
||||
export XDG_DATA_DIRS="/usr/local/share:/usr/share"
|
||||
fi
|
||||
|
||||
# Desktop files (used by desktop environments within both X11 and Wayland) are
|
||||
# looked for in XDG_DATA_DIRS; make sure it includes the relevant directory for ACE
|
||||
ACE_path="/var/lib/apm/apm/files/ace-env/amber-ce-tools/data-dir/"
|
||||
if [ -n "${XDG_DATA_DIRS##*${ACE_path}}" ] && [ -n "${XDG_DATA_DIRS##*${ACE_path}:*}" ]; then
|
||||
export XDG_DATA_DIRS="${XDG_DATA_DIRS}:${ACE_path}"
|
||||
fi
|
||||
|
||||
+1
@@ -0,0 +1 @@
|
||||
../../var/lib/apm/apm/files/bin/amber-ce-configure-nvidia
|
||||
Executable
+21
@@ -0,0 +1,21 @@
|
||||
#!/bin/bash
|
||||
|
||||
APM_BASE="/var/lib/apm"
|
||||
|
||||
# 遍历 /var/lib/apm 下的所有目录
|
||||
for dir in "$APM_BASE"/*/; do
|
||||
# 移除末尾的斜杠获取目录名
|
||||
dirname=$(basename "$dir")
|
||||
|
||||
# 跳过名为 "apm" 的目录
|
||||
if [[ "$dirname" == "apm" ]]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
# 检查是否存在 /var/lib/apm/目录名/files/ace-env
|
||||
if [[ -f "$dir/files/ace-env" ]]; then
|
||||
echo "执行 apm-configure-nvidia: $dir"
|
||||
amber-pm-configure-nvidia "$dir/files/ace-env"
|
||||
fi
|
||||
|
||||
done
|
||||
Executable
+365
@@ -0,0 +1,365 @@
|
||||
#!/bin/bash
|
||||
|
||||
# APM软件包转换器 - 将DEB包转换为APM格式
|
||||
log.warn() { echo -e "[\e[33mWARN\e[0m]: \e[1m$*\e[0m"; }
|
||||
log.error() { echo -e "[\e[31mERROR\e[0m]: \e[1m$*\e[0m"; }
|
||||
log.info() { echo -e "[\e[96mINFO\e[0m]: \e[1m$*\e[0m"; }
|
||||
log.debug() { echo -e "[\e[32mDEBUG\e[0m]: \e[1m$*\e[0m"; }
|
||||
SCRIPT_NAME=$(basename "$0")
|
||||
|
||||
# 显示用法信息
|
||||
usage() {
|
||||
echo "用法: $SCRIPT_NAME --base <basename> [--base <basename> ...] <deb文件路径> [--pkgname <包名>] [--version <版本号>]"
|
||||
echo ""
|
||||
echo "参数说明:"
|
||||
echo " --basename 必填参数,指定基础环境名称,可多次使用指定多个基础环境"
|
||||
echo " deb文件路径 必填参数,要转换的DEB文件路径"
|
||||
echo " --pkgname 可选参数,指定新包的包名(默认使用原DEB包名)"
|
||||
echo " --version 可选参数,指定新包的版本号(默认在原版本后追加'-apm')"
|
||||
echo ""
|
||||
echo "示例:"
|
||||
echo " $SCRIPT_NAME --base amber-pm-trixie /path/to/package.deb"
|
||||
echo " $SCRIPT_NAME --base base上 --base base中 --base base下 /path/to/package.deb --pkgname new-pkg --version 1.0.0"
|
||||
echo "最下层的base在最后面,从上到下写base"
|
||||
}
|
||||
|
||||
# 检查参数数量
|
||||
if [ $# -lt 3 ]; then
|
||||
log.error "错误:参数不足"
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 解析参数
|
||||
BASENAMES=() # 改为数组存储多个base
|
||||
DEB_PATH=""
|
||||
PKGNAME=""
|
||||
VERSION=""
|
||||
|
||||
# 参数解析
|
||||
while [ $# -gt 0 ]; do
|
||||
case $1 in
|
||||
--base)
|
||||
BASENAMES+=("$2")
|
||||
shift 2
|
||||
;;
|
||||
--pkgname)
|
||||
PKGNAME="$2"
|
||||
shift 2
|
||||
;;
|
||||
--version)
|
||||
VERSION="$2"
|
||||
shift 2
|
||||
;;
|
||||
*)
|
||||
if [ -z "$DEB_PATH" ] && [ -f "$1" ]; then
|
||||
DEB_PATH="$1"
|
||||
shift
|
||||
else
|
||||
log.error "错误:未知参数或无效的DEB文件路径: $1"
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# 检查必填参数
|
||||
if [ ${#BASENAMES[@]} -eq 0 ] || [ -z "$DEB_PATH" ]; then
|
||||
log.error "错误:至少需要一个--basename参数,且DEB文件路径为必填"
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 检查DEB文件是否存在
|
||||
if [ ! -f "$DEB_PATH" ]; then
|
||||
log.error "错误:DEB文件不存在: $DEB_PATH"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
log.info "开始转换DEB包: $DEB_PATH"
|
||||
log.info "基础环境数量: ${#BASENAMES[@]}"
|
||||
for i in "${!BASENAMES[@]}"; do
|
||||
log.info " 基础环境 $((i+1)): ${BASENAMES[$i]}"
|
||||
done
|
||||
|
||||
# 1. 创建临时工作目录
|
||||
CRAFT_DIR="$HOME/apm-craft-$$"
|
||||
log.info "创建临时工作目录: $CRAFT_DIR"
|
||||
mkdir -p "$CRAFT_DIR"/{core,work,mergedir,modified_deb}
|
||||
|
||||
# 设置环境变量
|
||||
export CRAFT_DIR
|
||||
|
||||
# 检查是否已挂载,避免重复挂载
|
||||
cleanup_mount() {
|
||||
if mountpoint -q "$CRAFT_DIR/mergedir"; then
|
||||
log.info "解除挂载: $CRAFT_DIR/mergedir"
|
||||
sudo umount "$CRAFT_DIR/mergedir" || true
|
||||
fi
|
||||
}
|
||||
|
||||
# 清理函数
|
||||
cleanup() {
|
||||
log.info "开始清理..."
|
||||
cleanup_mount
|
||||
if [ -d "$CRAFT_DIR" ]; then
|
||||
log.info "删除临时目录: $CRAFT_DIR"
|
||||
sudo rm -rf "$CRAFT_DIR"
|
||||
fi
|
||||
}
|
||||
|
||||
# 设置退出时清理
|
||||
trap cleanup EXIT
|
||||
|
||||
# 2. 检查原DEB包信息
|
||||
log.info "检查原DEB包信息..."
|
||||
ORIG_PKGNAME=$(dpkg -f "$DEB_PATH" Package)
|
||||
ORIG_VERSION=$(dpkg -f "$DEB_PATH" Version)
|
||||
ORIG_ARCH=$(dpkg -f "$DEB_PATH" Architecture)
|
||||
|
||||
log.info "原包名: $ORIG_PKGNAME"
|
||||
log.info "原版本: $ORIG_VERSION"
|
||||
log.info "原架构: $ORIG_ARCH"
|
||||
|
||||
# 设置新包名和版本
|
||||
NEW_PKGNAME="${PKGNAME:-$ORIG_PKGNAME}"
|
||||
NEW_VERSION="${VERSION:-${ORIG_VERSION}-apm}"
|
||||
|
||||
log.info "新包名: $NEW_PKGNAME"
|
||||
log.info "新版本: $NEW_VERSION"
|
||||
log.info "新架构: $ORIG_ARCH"
|
||||
|
||||
# 3. 构建lowerdir路径(多个base按顺序叠放)
|
||||
log.info "构建overlay lowerdir路径..."
|
||||
LOWERDIRS=()
|
||||
|
||||
# 按顺序处理每个base(从第一个到最后一个,最后一个在最底层)
|
||||
for BASENAME in "${BASENAMES[@]}"; do
|
||||
ACE_ENV_PATH="/var/lib/apm/apm/files/ace-env/var/lib/apm/${BASENAME}/files/ace-env"
|
||||
CORE_PATH="/var/lib/apm/apm/files/ace-env/var/lib/apm/${BASENAME}/files/core"
|
||||
|
||||
if [ -d "$ACE_ENV_PATH" ]; then
|
||||
log.info "使用ace-env路径: $ACE_ENV_PATH"
|
||||
LOWERDIRS+=("$ACE_ENV_PATH")
|
||||
elif [ -d "$CORE_PATH" ]; then
|
||||
log.info "使用core路径: $CORE_PATH"
|
||||
LOWERDIRS+=("$CORE_PATH")
|
||||
else
|
||||
log.error "错误:基础环境路径不存在: $BASENAME"
|
||||
log.error " 检查的路径: $ACE_ENV_PATH"
|
||||
log.error " 检查的路径: $CORE_PATH"
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
# 将lowerdirs数组用冒号连接
|
||||
LOWERDIR=$(IFS=:; echo "${LOWERDIRS[*]}")
|
||||
log.debug "最终lowerdir: $LOWERDIR"
|
||||
|
||||
# 4. 进行融合挂载
|
||||
log.info "正在进行融合挂载..."
|
||||
|
||||
sudo mount -t overlay overlay \
|
||||
-o "lowerdir=$LOWERDIR,upperdir=$CRAFT_DIR/core/,workdir=$CRAFT_DIR/work/" \
|
||||
"$CRAFT_DIR/mergedir"
|
||||
|
||||
log.info "挂载完成"
|
||||
|
||||
# 5. 在融合环境中安装修改后的DEB包
|
||||
log.info "在融合环境中测试安装DEB包..."
|
||||
|
||||
# 更新包列表
|
||||
export chrootEnvPath="$CRAFT_DIR/mergedir"
|
||||
sudo -E /var/lib/apm/apm/files/ace-run-pkg aptss update
|
||||
|
||||
# 首先进行dry-run检查
|
||||
log.info "进行安装前检查..."
|
||||
if ! sudo -E /var/lib/apm/apm/files/ace-run-pkg aptss install "$DEB_PATH" --dry-run; then
|
||||
log.error "错误:安装前检查失败,DEB包可能无法在基础环境中安装"
|
||||
log.error "请检查依赖关系或基础环境是否兼容"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
log.info "安装前检查通过,准备实际安装..."
|
||||
|
||||
# 6. 提取并修改DEB包
|
||||
log.info "提取并修改原DEB包..."
|
||||
EXTRACT_DIR="$CRAFT_DIR/extract"
|
||||
MODIFIED_DEB_DIR="$CRAFT_DIR/modified_deb"
|
||||
mkdir -p "$EXTRACT_DIR"
|
||||
mkdir -p "$MODIFIED_DEB_DIR/DEBIAN"
|
||||
|
||||
# 解压DEB包
|
||||
dpkg -x "$DEB_PATH" "$EXTRACT_DIR"
|
||||
dpkg -e "$DEB_PATH" "$MODIFIED_DEB_DIR/DEBIAN"
|
||||
|
||||
# 处理.desktop文件
|
||||
DESKTOP_MODIFIED=false
|
||||
find "$EXTRACT_DIR" -name "*.desktop" | while read -r desktop_file; do
|
||||
log.info "处理桌面文件: $desktop_file"
|
||||
DESKTOP_MODIFIED=true
|
||||
|
||||
# 在Exec和TryExec行前追加 "apm run $NEW_PKGNAME"
|
||||
# 处理Exec行
|
||||
if grep -q '^Exec=' "$desktop_file"; then
|
||||
sed -i 's/^Exec=\(.*\)$/Exec=apm run '"$NEW_PKGNAME"' \1/' "$desktop_file"
|
||||
fi
|
||||
|
||||
# 处理TryExec行
|
||||
if grep -q '^TryExec=' "$desktop_file"; then
|
||||
sed -i 's/^TryExec=\(.*\)$/TryExec=apm run '"$NEW_PKGNAME"' \1/' "$desktop_file"
|
||||
fi
|
||||
|
||||
# 处理Icon路径
|
||||
icon_line=$(grep "^Icon=" "$desktop_file")
|
||||
if [[ "$icon_line" == "Icon=/"* ]]; then
|
||||
sed -i 's|^Icon=/|Icon=/var/lib/apm/apm/files/ace-env/var/lib/apm/'"$NEW_PKGNAME"'/files/core/|' "$desktop_file"
|
||||
fi
|
||||
|
||||
# 添加X-APM-APPID
|
||||
if ! grep -q "X-APM-APPID" "$desktop_file"; then
|
||||
echo "X-APM-APPID=$NEW_PKGNAME" >> "$desktop_file"
|
||||
fi
|
||||
|
||||
# 检查修改结果
|
||||
if grep -q "apm run $NEW_PKGNAME" "$desktop_file"; then
|
||||
log.info "桌面文件修改成功"
|
||||
log.debug "修改后的Exec行: $(grep '^Exec=' "$desktop_file" || echo "未找到")"
|
||||
log.debug "修改后的TryExec行: $(grep '^TryExec=' "$desktop_file" || echo "未找到")"
|
||||
else
|
||||
log.warn "桌面文件可能未正确修改: $desktop_file"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ "$DESKTOP_MODIFIED" = false ]; then
|
||||
log.info "未找到需要修改的.desktop文件"
|
||||
fi
|
||||
|
||||
# 重新打包修改后的DEB
|
||||
MODIFIED_DEB_PATH="$CRAFT_DIR/modified_${ORIG_PKGNAME}.deb"
|
||||
log.info "重新打包修改后的DEB: $MODIFIED_DEB_PATH"
|
||||
|
||||
# 复制修改后的文件结构到打包目录
|
||||
mkdir -p "$MODIFIED_DEB_DIR/data"
|
||||
cp -r "$EXTRACT_DIR"/* "$MODIFIED_DEB_DIR/" 2>/dev/null || true
|
||||
|
||||
# 使用fakeroot重新打包
|
||||
cd "$MODIFIED_DEB_DIR" && fakeroot dpkg-deb --build -Z none . "$MODIFIED_DEB_PATH"
|
||||
cd - > /dev/null
|
||||
|
||||
if [ ! -f "$MODIFIED_DEB_PATH" ]; then
|
||||
log.error "错误:重新打包DEB失败"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
log.info "DEB包修改完成,新包路径: $MODIFIED_DEB_PATH"
|
||||
|
||||
# 实际安装修改后的DEB包
|
||||
if ! sudo -E /var/lib/apm/apm/files/ace-run-pkg ssaudit "$MODIFIED_DEB_PATH" --native --no-create-desktop-entry; then
|
||||
log.error "错误:修改后的DEB包安装失败"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
log.info "修改后的DEB包安装完成"
|
||||
|
||||
# 清理一些垃圾
|
||||
sudo -E /var/lib/apm/apm/files/ace-run-pkg aptss clean
|
||||
sudo -E /var/lib/apm/apm/files/ace-run-pkg rm -vfr /var/lib/apt/lists
|
||||
sudo -E /var/lib/apm/apm/files/ace-run-pkg rm -vfr /var/lib/aptss/lists
|
||||
|
||||
# 7. 创建新的APM包结构
|
||||
log.info "创建新的APM包结构..."
|
||||
PKG_BUILD_DIR="$CRAFT_DIR/new-pkg"
|
||||
mkdir -p "$PKG_BUILD_DIR/DEBIAN"
|
||||
mkdir -p "$PKG_BUILD_DIR/var/lib/apm/$NEW_PKGNAME"/{entries,files}
|
||||
|
||||
# 创建info文件 - 写入所有base,每行一个
|
||||
log.info "创建info文件,包含所有基础环境:"
|
||||
for BASENAME in "${BASENAMES[@]}"; do
|
||||
echo "$BASENAME" >> "$PKG_BUILD_DIR/var/lib/apm/$NEW_PKGNAME/info"
|
||||
log.info " 写入: $BASENAME"
|
||||
done
|
||||
|
||||
# 创建postinst脚本
|
||||
cat > "$PKG_BUILD_DIR/DEBIAN/postinst" << 'EOF'
|
||||
#!/bin/bash
|
||||
PACKAGE_NAME="$DPKG_MAINTSCRIPT_PACKAGE"
|
||||
|
||||
if [ "$1" = "remove" ] || [ "$1" = "purge" ]; then
|
||||
echo "清理卸载残留"
|
||||
rm -rf "/var/lib/apm/$PACKAGE_NAME"
|
||||
else
|
||||
echo "非卸载,跳过清理"
|
||||
fi
|
||||
EOF
|
||||
|
||||
chmod +x "$PKG_BUILD_DIR/DEBIAN/postinst"
|
||||
|
||||
# 8. 复制文件到新的APM包
|
||||
log.info "复制文件到新的APM包..."
|
||||
|
||||
# 复制/usr/share/内容到entries
|
||||
if [ -d "$EXTRACT_DIR/usr/share" ]; then
|
||||
log.info "复制/usr/share/内容..."
|
||||
cp -r "$EXTRACT_DIR/usr/share/"* "$PKG_BUILD_DIR/var/lib/apm/$NEW_PKGNAME/entries/"
|
||||
fi
|
||||
|
||||
# 复制/opt/apps/内容(如果存在)
|
||||
if [ -d "$EXTRACT_DIR/opt/apps/$ORIG_PKGNAME/entries" ]; then
|
||||
log.info "复制/opt/apps/$ORIG_PKGNAME/entries内容..."
|
||||
cp -r "$EXTRACT_DIR/opt/apps/$ORIG_PKGNAME/entries/"* "$PKG_BUILD_DIR/var/lib/apm/$NEW_PKGNAME/entries/"
|
||||
fi
|
||||
|
||||
# 复制融合环境文件
|
||||
log.info "复制融合环境文件..."
|
||||
sudo cp -r "$CRAFT_DIR"/{core,work} "$PKG_BUILD_DIR/var/lib/apm/$NEW_PKGNAME/files/"
|
||||
|
||||
# 设置文件权限
|
||||
sudo chmod -R 755 "$PKG_BUILD_DIR/var/lib/apm/$NEW_PKGNAME/files/"
|
||||
|
||||
# 9. 解除挂载
|
||||
log.info "解除挂载..."
|
||||
cleanup_mount
|
||||
|
||||
# 10. 打包新的APM包
|
||||
log.info "打包新的APM包..."
|
||||
calculate_directory_size() {
|
||||
local dir="$1"
|
||||
if [ -d "$dir" ]; then
|
||||
du -sk "$dir" | cut -f1
|
||||
else
|
||||
echo "0"
|
||||
fi
|
||||
}
|
||||
|
||||
# 构建依赖字符串 - 包含所有base
|
||||
DEPENDS_STR=$(IFS=,; echo "${BASENAMES[*]}")
|
||||
|
||||
# 创建control文件
|
||||
cat > "${PKG_BUILD_DIR}/DEBIAN/control" << EOF
|
||||
Package: $NEW_PKGNAME
|
||||
Version: $NEW_VERSION
|
||||
Architecture: $ORIG_ARCH
|
||||
Maintainer: APM Converter <apm@localhost>
|
||||
Depends: $DEPENDS_STR
|
||||
Installed-Size: $(calculate_directory_size $PKG_BUILD_DIR)
|
||||
Description: APM converted package from $DEB_PATH
|
||||
This package was automatically converted from the original deb package.
|
||||
Based on: ${BASENAMES[*]}
|
||||
EOF
|
||||
|
||||
# 生成输出文件名
|
||||
OUTPUT_DEB="${NEW_PKGNAME}_${NEW_VERSION}_${ORIG_ARCH}.deb"
|
||||
|
||||
# 打包
|
||||
fakeroot dpkg-deb --build "$PKG_BUILD_DIR" "$OUTPUT_DEB"
|
||||
|
||||
log.info "转换完成!"
|
||||
log.info "生成的APM包: $OUTPUT_DEB"
|
||||
log.info "包名: $NEW_PKGNAME"
|
||||
log.info "版本: $NEW_VERSION"
|
||||
log.info "架构: $ORIG_ARCH"
|
||||
log.info "依赖: $DEPENDS_STR"
|
||||
log.info "基础环境: ${BASENAMES[*]}"
|
||||
log.info "注意:桌面文件已修改,添加了APM运行前缀和APPID"
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
../../var/lib/apm/apm/files/bin/ace-run
|
||||
Executable
+174
@@ -0,0 +1,174 @@
|
||||
#!/bin/bash
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
enumAppInfoList() {
|
||||
appInfoList=()
|
||||
apps="/var/lib/apm"
|
||||
list=$(ls $apps 2>/dev/null)
|
||||
for appID in $list; do
|
||||
appInfoList+=("$appID")
|
||||
done
|
||||
echo "${appInfoList[@]}"
|
||||
}
|
||||
linkDir() {
|
||||
ensureTargetDir() {
|
||||
targetFile=$1
|
||||
t=$(dirname "$targetFile")
|
||||
mkdir -p "$t"
|
||||
}
|
||||
|
||||
source=$1
|
||||
target=$2
|
||||
sourceDir=$(dirname "$source")
|
||||
targetDir=$(dirname "$target")
|
||||
find "$source" -type f | while read sourceFile; do
|
||||
targetFile="$targetDir/${sourceFile#$sourceDir/}"
|
||||
|
||||
|
||||
ensureTargetDir "$targetFile"
|
||||
sourceFile=$(realpath --relative-to="$(dirname $targetFile)" "$sourceFile" )
|
||||
if [ ! -e ${targetFile} ];then
|
||||
ln -sv "$sourceFile" "$targetFile"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
linkApp() {
|
||||
appID=$1
|
||||
appEntriesDir="/var/lib/apm/$appID/entries"
|
||||
appLibsDir="/var/lib/apm/$appID/files/lib"
|
||||
autoStartDir="$appEntriesDir/autostart"
|
||||
|
||||
if [ -d "$autoStartDir" ]; then
|
||||
linkDir "$autoStartDir" "/etc/xdg/autostart"
|
||||
fi
|
||||
|
||||
# link application
|
||||
sysShareDir="/usr/share"
|
||||
for folder in "$appEntriesDir/applications" "$appEntriesDir/icons" "$appEntriesDir/mime" "$appEntriesDir/glib-2.0" "$appEntriesDir/services" "$appEntriesDir/GConf" "$appEntriesDir/help" "$appEntriesDir/locale" "$appEntriesDir/fcitx"; do
|
||||
if [ ! -d "$folder" ]; then
|
||||
continue
|
||||
fi
|
||||
if [ "$folder" = "$appEntriesDir/polkit" ]; then
|
||||
linkDir "$folder" "/usr/share/polkit-1"
|
||||
elif [ "$folder" = "$appEntriesDir/fonts/conf" ]; then
|
||||
linkDir "$folder" "/etc/fonts/conf.d"
|
||||
else
|
||||
linkDir "$folder" "$sysShareDir/${folder##*/}"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
function exec_uos_package_link(){
|
||||
|
||||
for app in $(enumAppInfoList); do
|
||||
linkApp "$app" &
|
||||
|
||||
done
|
||||
wait
|
||||
}
|
||||
|
||||
function exec_v23_icon_link(){
|
||||
# Fix v23 broken icon
|
||||
if [ ! -d "/usr/share/icons/hicolor/scalable/apps" ];then
|
||||
mkdir -p /usr/share/icons/hicolor/scalable/apps
|
||||
fi
|
||||
|
||||
for icon_root_icon_path in $(ls /usr/share/icons/*.png /usr/share/icons/*.svg 2>/dev/null)
|
||||
do
|
||||
target_icon_path=/usr/share/icons/hicolor/scalable/apps/$(basename ${icon_root_icon_path})
|
||||
if [ ! -e ${target_icon_path} ];then
|
||||
ln -sv $(realpath --relative-to=/usr/share/icons/hicolor/scalable/apps ${icon_root_icon_path}) /usr/share/icons/hicolor/scalable/apps
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
function exec_link_clean(){
|
||||
# remove broken links in /usr/share
|
||||
|
||||
find /usr/share/applications -xtype l -exec echo '{} is invalid now and going to be cleaned' \; -exec unlink {} \; 2>/dev/null &
|
||||
find /usr/share/icons -xtype l -exec echo '{} is invalid now and going to be cleaned' \; -exec unlink {} \; 2>/dev/null &
|
||||
find /usr/share/mime/packages -xtype l -exec echo '{} is invalid now and going to be cleaned' \; -exec unlink {} \; 2>/dev/null &
|
||||
find /usr/share/glib-2.0 -xtype l -exec echo '{} is invalid now and going to be cleaned' \; -exec unlink {} \; 2>/dev/null &
|
||||
find /usr/share/dbus-1/services -xtype l -exec echo '{} is invalid now and going to be cleaned' \; -exec unlink {} \; 2>/dev/null &
|
||||
find /usr/share/fcitx -xtype l -exec echo '{} is invalid now and going to be cleaned' \; -exec unlink {} \; 2>/dev/null &
|
||||
find /usr/share/help -xtype l -exec echo '{} is invalid now and going to be cleaned' \; -exec unlink {} \; 2>/dev/null &
|
||||
find /usr/share/locale -xtype l -exec echo '{} is invalid now and going to be cleaned' \; -exec unlink {} \; 2>/dev/null &
|
||||
find /usr/lib/`dpkg-architecture -qDEB_HOST_MULTIARCH`/fcitx -xtype l -exec echo '{} is invalid now and going to be cleaned' \; -exec unlink {} \; 2>/dev/null &
|
||||
find /usr/lib/mozilla/plugins -xtype l -exec echo '{} is invalid now and going to be cleaned' \; -exec unlink {} \; 2>/dev/null &
|
||||
find /usr/share/polkit-1/actions -xtype l -exec echo '{} is invalid now and going to be cleaned' \; -exec unlink {} \; 2>/dev/null &
|
||||
find /usr/share/fonts -xtype l -exec echo '{} is invalid now and going to be cleaned' \; -exec unlink {} \; 2>/dev/null &
|
||||
find /etc/fonts/conf.d -xtype l -exec echo '{} is invalid now and going to be cleaned' \; -exec unlink {} \; 2>/dev/null &
|
||||
|
||||
|
||||
}
|
||||
function exec_uos_package_update(){
|
||||
update-icon-caches /usr/share/icons/* > /dev/null 2>&1 &
|
||||
update-desktop-database -q > /dev/null 2>&1 &
|
||||
update-mime-database -V /usr/share/mime > /dev/null 2>&1 &
|
||||
glib-compile-schemas /usr/share/glib-2.0/schemas/ > /dev/null 2>&1 &
|
||||
|
||||
}
|
||||
|
||||
function exec_debian_compatibile_links(){
|
||||
# 源目录和目标目录定义
|
||||
local SOURCE_DIR="/var/lib/apm"
|
||||
local TARGET_DIR="/var/lib/apm/apm/files/ace-env/var/lib/apm"
|
||||
|
||||
# 检查目标目录是否存在
|
||||
if [[ ! -d "$TARGET_DIR" ]]; then
|
||||
mkdir -p $TARGET_DIR
|
||||
fi
|
||||
|
||||
# 第一部分:为缺失的目录创建软链接
|
||||
echo "检查并创建缺失的软链接..."
|
||||
for dir in "$SOURCE_DIR"/*/; do
|
||||
# 获取目录名(去掉路径和尾部斜杠)
|
||||
dirname=$(basename "$dir")
|
||||
|
||||
# 跳过 apm 目录
|
||||
if [[ "$dirname" == "apm" ]]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
# 检查目标目录中是否已存在对应的软链接或目录
|
||||
target_link="$TARGET_DIR/$dirname"
|
||||
if [[ ! -e "$target_link" ]]; then
|
||||
echo "创建软链接: $target_link -> $dir"
|
||||
ln -sv "$dir" "$target_link"
|
||||
fi
|
||||
done
|
||||
|
||||
# 第二部分:清理无效的软链接
|
||||
echo "清理无效的软链接..."
|
||||
for link in "$TARGET_DIR"/*; do
|
||||
# 检查是否为软链接
|
||||
if [[ -L "$link" ]]; then
|
||||
# 检查软链接是否有效(指向的目标是否存在)
|
||||
if [[ ! -e "$link" ]]; then
|
||||
echo "删除无效软链接: $link"
|
||||
rm "$link"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
}
|
||||
#########################################################################################
|
||||
echo "----------------Running APM Dstore Patch----------------"
|
||||
|
||||
# execute linkApp function for each app and print output
|
||||
exec_uos_package_link
|
||||
|
||||
|
||||
#exec_v23_icon_link
|
||||
exec_link_clean
|
||||
wait
|
||||
exec_uos_package_update
|
||||
if [[ "${IS_APM_ENV}" = "" ]];then
|
||||
exec_debian_compatibile_links
|
||||
fi
|
||||
|
||||
echo "----------------Finished----------------"
|
||||
Executable
+30
@@ -0,0 +1,30 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [[ ! -e "/usr/share/gxde-api" ]] && ! grep -q "Kylin" /etc/os-release; then
|
||||
exit 0 # No needed
|
||||
fi
|
||||
|
||||
# 函数:检查目录并创建符号链接
|
||||
process_directory() {
|
||||
local source_dir="$1"
|
||||
local target_dir="$2"
|
||||
local name="$3"
|
||||
|
||||
if [ -d "$source_dir" ] && [ -n "$(ls -A "$source_dir")" ]; then
|
||||
ln -sv $source_dir/* "$target_dir" 2>/dev/null
|
||||
find "$target_dir" -xtype l -exec echo '{} is invalid now and going to be cleaned' \; -exec unlink {} \; 2>/dev/null &
|
||||
else
|
||||
echo "$name directory is empty or does not exist, skipping..."
|
||||
fi
|
||||
}
|
||||
|
||||
# 处理 applications 目录
|
||||
process_directory "/var/lib/apm/apm/files/ace-env/amber-ce-tools/data-dir/applications/" \
|
||||
"/usr/local/share/applications/" "Applications"
|
||||
|
||||
# 处理 icons 目录
|
||||
process_directory "/var/lib/apm/apm/files/ace-env/amber-ce-tools/data-dir/icons/" \
|
||||
"/usr/local/share/icons/" "Icons"
|
||||
|
||||
# 等待所有后台任务完成
|
||||
wait
|
||||
Executable
+301
@@ -0,0 +1,301 @@
|
||||
#!/bin/bash
|
||||
VERSION=1.0.9
|
||||
# 获取脚本名称用于帮助信息
|
||||
SCRIPT_NAME=$(basename "$0")
|
||||
PATH_PREFIX=/var/lib/apm/apm/files/ace-env/
|
||||
|
||||
log.warn() { echo -e "[\e[33mWARN\e[0m]: \e[1m$*\e[0m"; }
|
||||
log.error() { echo -e "[\e[31mERROR\e[0m]: \e[1m$*\e[0m"; }
|
||||
log.info() { echo -e "[\e[96mINFO\e[0m]: \e[1m$*\e[0m"; }
|
||||
log.debug() { echo -e "[\e[32mDEBUG\e[0m]: \e[1m$*\e[0m"; }
|
||||
|
||||
# 帮助信息函数
|
||||
show_help() {
|
||||
cat <<EOF
|
||||
APM - Amber Package Manager ${VERSION}
|
||||
|
||||
Usage:
|
||||
$SCRIPT_NAME [COMMAND] [OPTIONS] [PACKAGES...]
|
||||
|
||||
Commands:
|
||||
install 安装软件包
|
||||
remove 卸载软件包
|
||||
update 更新软件包信息
|
||||
download 下载包
|
||||
clean 清除缓存软件包
|
||||
autoremove 自动移除不需要的包
|
||||
full-upgrade 完全升级软件包
|
||||
run <package> 运行指定软件包的可执行文件
|
||||
ssaudit <path> 使用 ssaudit 进行软件安装,详情见 spark-store
|
||||
debug 显示调试系统信息并进入调试环境
|
||||
amber 彩蛋功能
|
||||
xmp360 彩蛋功能
|
||||
bronya 彩蛋功能
|
||||
|
||||
-h, --help 显示此帮助信息
|
||||
|
||||
|
||||
EOF
|
||||
}
|
||||
|
||||
|
||||
apm_exec(){
|
||||
# 读取info文件中的所有行,按从下到上的顺序构建lowerdir
|
||||
local lowerdirs=()
|
||||
|
||||
# 检查info文件是否存在
|
||||
if [[ ! -f "${PATH_PREFIX}/var/lib/apm/${coredir}/info" ]]; then
|
||||
log.error "Info file not found for package: $coredir"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# 读取info文件的每一行
|
||||
while IFS= read -r basedir; do
|
||||
[[ -z "$basedir" ]] && continue # 跳过空行
|
||||
|
||||
# 检查ace-env目录是否存在
|
||||
if [[ -d "${PATH_PREFIX}/var/lib/apm/${basedir}/files/ace-env" ]]; then
|
||||
lowerdirs+=("${PATH_PREFIX}/var/lib/apm/${basedir}/files/ace-env")
|
||||
# 如果ace-env不存在,检查core目录
|
||||
elif [[ -d "${PATH_PREFIX}/var/lib/apm/${basedir}/files/core" ]]; then
|
||||
lowerdirs+=("${PATH_PREFIX}/var/lib/apm/${basedir}/files/core")
|
||||
else
|
||||
log.warn "Neither ace-env nor core directory found for base: $basedir"
|
||||
fi
|
||||
done < "${PATH_PREFIX}/var/lib/apm/${coredir}/info"
|
||||
|
||||
# 检查是否找到了有效的lowerdir
|
||||
if [[ ${#lowerdirs[@]} -eq 0 ]]; then
|
||||
log.error "No valid lower directories found for package: $coredir"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# 将lowerdirs数组用冒号连接起来
|
||||
local lowerdir=$(IFS=:; echo "${lowerdirs[*]}")
|
||||
|
||||
# 创建挂载点目录
|
||||
mkdir -p "/tmp/apm/${coredir}"
|
||||
|
||||
# 使用fuse-overlayfs挂载
|
||||
log.debug "Mounting with lowerdir: $lowerdir"
|
||||
fuse-overlayfs -o lowerdir="$lowerdir",upperdir="${PATH_PREFIX}/var/lib/apm/${coredir}/files/core/",workdir="${PATH_PREFIX}/var/lib/apm/${coredir}/files/work/" "/tmp/apm/${coredir}"
|
||||
|
||||
# 执行命令
|
||||
chrootEnvPath="/tmp/apm/${coredir}" /var/lib/apm/apm/files/ace-run "$@"
|
||||
|
||||
# 卸载
|
||||
umount "/tmp/apm/${coredir}"
|
||||
}
|
||||
|
||||
|
||||
|
||||
# 调试信息函数
|
||||
debug_info() {
|
||||
log.debug "======= APM Debug Information ======="
|
||||
log.debug "User: $(whoami)"
|
||||
log.debug "Hostname: $(hostname)"
|
||||
log.debug "OS: $(lsb_release -ds 2>/dev/null || uname -om)"
|
||||
log.debug "Kernel: $(uname -sr)"
|
||||
log.debug "Bash Version: ${BASH_VERSION}"
|
||||
log.debug "APT Version: $(apt --version | head -n1)"
|
||||
log.debug "APM APT Version: $(amber-pm-debug apt --version | head -n1)"
|
||||
log.debug "====================================="
|
||||
|
||||
amber-pm-debug "$@"
|
||||
|
||||
}
|
||||
|
||||
# 彩蛋函数
|
||||
amber_egg() {
|
||||
cat <<'EOF'
|
||||
|
||||
____ ____
|
||||
/ __ )____ __________ ____ / __ )__ ______ ____ __ __
|
||||
/ __ / __ `/ ___/ __ \/ __ \ / __ / / / / __ \/ __ \/ / / /
|
||||
/ /_/ / /_/ / / / /_/ / / / / / /_/ / /_/ / / / / / / / /_/ /
|
||||
/_____/\__,_/_/ \____/_/ /_/ /_____/\__,_/_/ /_/_/ /_/\__, /
|
||||
/____/
|
||||
|
||||
Amber Package Manager - Sparkling with magic! 安柏包管理器 - blingbling~
|
||||
💎 Another target tracked down by Outrider Amber! 侦察骑士,发现目标!
|
||||
EOF
|
||||
}
|
||||
|
||||
bronya_egg() {
|
||||
cat <<'EOF'
|
||||
_ __ ____ _ ____ __
|
||||
| | / /__ _/ / /____ ______(_)__ / __/_ _____ / /____ __ _
|
||||
| |/ / _ `/ / '_/ // / __/ / -_) _\ \/ // (_-</ __/ -_) ' \
|
||||
|___/\_,_/_/_/\_\\_, /_/ /_/\__/ /___/\_, /___/\__/\__/_/_/_/
|
||||
/ / ___ ___ __/___/____/ / /___/
|
||||
/ /__/ _ `/ // / _ \/ __/ _ \
|
||||
/____/\_,_/\_,_/_//_/\__/_//_/
|
||||
|
||||
Valkyrie 系统启动 - 重装小兔,Fire!
|
||||
💎 感谢 Anysets 为 AmberCE 和 AmberPM 的 Arch 架构支持提供帮助~
|
||||
EOF
|
||||
}
|
||||
|
||||
xmp360_egg() {
|
||||
cat <<'EOF'
|
||||
################################################################################
|
||||
################################################################################
|
||||
################################################################################
|
||||
##################### ####################
|
||||
####################. %###################
|
||||
##########= ####################
|
||||
############################ #=========*#########
|
||||
############# .% .*****= :######
|
||||
############################### =+ =#######* -#####
|
||||
##### %: *######## :#####
|
||||
######################% # ########* +#####
|
||||
########: # %#####
|
||||
########################## .# ######
|
||||
##################* -* ######
|
||||
##################= =###%: +- *###* ######
|
||||
##################. # %: :* # -######
|
||||
##################. % *###= % -- #### % %######
|
||||
########################- ####+ ########################### .####. #########
|
||||
######################### ############################% ##########
|
||||
###########################=::+################################%-:-*############
|
||||
################################################################################
|
||||
|
||||
哇——————袄 - 撞大运咯!
|
||||
💎 感谢 潇湘·秀 为 APM 的 RPM 架构支持提供帮助~
|
||||
EOF
|
||||
}
|
||||
|
||||
apm-nvidia-toggle(){
|
||||
|
||||
# APM 基础路径
|
||||
APM_BASE="${PATH_PREFIX}/var/lib/apm"
|
||||
|
||||
# 检查基础目录是否存在
|
||||
if [[ ! -d "$APM_BASE" ]]; then
|
||||
echo "错误: 目录 $APM_BASE 不存在"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 遍历 /var/lib/apm 下的所有目录
|
||||
for dir in "$APM_BASE"/*/; do
|
||||
# 移除末尾的斜杠得到纯目录名
|
||||
dir="${dir%/}"
|
||||
|
||||
# 提取目录名(不包括完整路径)
|
||||
dirname=$(basename "$dir")
|
||||
# 检查目标文件是否存在
|
||||
target_file="${APM_BASE}/${dirname}/files/ace-env"
|
||||
if [[ -e "$target_file" ]]; then
|
||||
|
||||
# 将目录传递给 amber-pm-configure-nvidia
|
||||
amber-pm-configure-nvidia "$target_file"
|
||||
|
||||
|
||||
fi
|
||||
done
|
||||
}
|
||||
# 主命令处理
|
||||
case "$1" in
|
||||
install|full-upgrade|upgrade|reinstall)
|
||||
command=$1
|
||||
shift
|
||||
amber-pm-debug aptss "$command" "$@"
|
||||
exit_code=$?
|
||||
if [ $exit_code -eq 0 ]; then
|
||||
log.info "Operation successful"
|
||||
else
|
||||
log.error "Error: Operation failed"
|
||||
exit $exit_code
|
||||
fi
|
||||
amber-pm-debug amber-pm-dstore-patch
|
||||
apm-nvidia-toggle
|
||||
amber-pm-gxde-desktop-fix
|
||||
;;
|
||||
download|search|policy|list|update|clean)
|
||||
command=$1
|
||||
shift
|
||||
amber-pm-debug aptss "$command" "$@"
|
||||
exit_code=$?
|
||||
if [ $exit_code -eq 0 ]; then
|
||||
log.info "Operation successful"
|
||||
else
|
||||
log.error "Error: Operation failed"
|
||||
exit $exit_code
|
||||
fi
|
||||
;;
|
||||
|
||||
remove|autoremove|purge|autopurge)
|
||||
# 特殊APT命令:移除第一个参数后传递其余参数
|
||||
command=$1
|
||||
shift
|
||||
amber-pm-debug aptss "$command" "$@"
|
||||
exit_code=$?
|
||||
if [ $exit_code -eq 0 ]; then
|
||||
log.info "Operation successful"
|
||||
else
|
||||
log.error "Error: Operation failed"
|
||||
exit $exit_code
|
||||
fi
|
||||
amber-pm-debug amber-pm-dstore-patch
|
||||
amber-pm-gxde-desktop-fix
|
||||
;;
|
||||
run)
|
||||
# 运行包命令:第二个参数必须是包名
|
||||
if [ -z "$2" ]; then
|
||||
log.error "Package name required for 'run' command"
|
||||
show_help
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 检查包是否已安装
|
||||
pkg="$2"
|
||||
shift 2 # 移除 'run' 和包名
|
||||
|
||||
if ! ls "${PATH_PREFIX}/var/lib/apm/$pkg" >/dev/null 2>&1; then
|
||||
# 如果带前缀的目录不存在,尝试不带前缀的目录
|
||||
if ls "/var/lib/apm/$pkg" >/dev/null 2>&1; then
|
||||
# 如果不带前缀的目录存在,清空 PATH_PREFIX
|
||||
PATH_PREFIX=""
|
||||
else
|
||||
# 如果两个目录都不存在,报错退出
|
||||
log.error "Package not installed: $pkg"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
coredir=$pkg
|
||||
|
||||
|
||||
# 检测是否有额外命令参数
|
||||
if [ $# -gt 0 ]; then
|
||||
# 有额外参数:执行用户提供的命令
|
||||
log.info "Running user command: $*"
|
||||
apm_exec "$@"
|
||||
else
|
||||
# 没有额外参数:提示
|
||||
log.info "Usage: $SCRIPT_NAME run $pkg [EXEC_PATH]"
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
debug)
|
||||
debug_info
|
||||
;;
|
||||
ssaudit)
|
||||
amber-pm-debug ssaudit "$@" --native
|
||||
;;
|
||||
-h|--help)
|
||||
show_help
|
||||
;;
|
||||
amber)
|
||||
amber_egg
|
||||
;;
|
||||
xmp360)
|
||||
xmp360_egg
|
||||
;;
|
||||
bronya)
|
||||
bronya_egg
|
||||
;;
|
||||
*)
|
||||
show_help
|
||||
;;
|
||||
esac
|
||||
Executable
+6
@@ -0,0 +1,6 @@
|
||||
# ACE app runs in a container, need privileges within user namespace, so we need to set it
|
||||
kernel.unprivileged_userns_clone=1
|
||||
# Ubuntu 24.04 has more limitation on unprivileged user namespace,so we have to disable them.
|
||||
# refer to https://ubuntu.com/blog/ubuntu-23-10-restricted-unprivileged-user-namespaces
|
||||
kernel.apparmor_restrict_unprivileged_unconfined=0
|
||||
kernel.apparmor_restrict_unprivileged_userns=0
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
[Unit]
|
||||
Description=APM Daily Update
|
||||
After=apt-daily.service network.target network-online.target systemd-networkd.service NetworkManager.service connman.service
|
||||
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
RemainAfterExit=yes
|
||||
ExecStart=bash -c "apm clean && apm update"
|
||||
Restart=on-failure
|
||||
RestartSec=10
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
[Unit]
|
||||
Description=APM GXDE Fixer
|
||||
After=apt-daily.service network.target network-online.target systemd-networkd.service NetworkManager.service connman.service
|
||||
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
RemainAfterExit=yes
|
||||
ExecStart=/var/lib/apm/apm/files/bin/ace-gxde-fixer
|
||||
Restart=on-failure
|
||||
RestartSec=10
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
#!/bin/bash
|
||||
|
||||
|
||||
|
||||
# Ensure base distro defaults xdg path are set if nothing filed up some
|
||||
# defaults yet.
|
||||
if [ -z "$XDG_DATA_DIRS" ]; then
|
||||
export XDG_DATA_DIRS="/usr/local/share:/usr/share"
|
||||
fi
|
||||
|
||||
# Desktop files (used by desktop environments within both X11 and Wayland) are
|
||||
# looked for in XDG_DATA_DIRS; make sure it includes the relevant directory for ACE
|
||||
ACE_path="/var/lib/apm/apm/files/ace-env/amber-ce-tools/data-dir/"
|
||||
if [ -n "${XDG_DATA_DIRS##*${ACE_path}}" ] && [ -n "${XDG_DATA_DIRS##*${ACE_path}:*}" ]; then
|
||||
export XDG_DATA_DIRS="${XDG_DATA_DIRS}:${ACE_path}"
|
||||
fi
|
||||
|
||||
+255
@@ -0,0 +1,255 @@
|
||||
# Debian apt(8) completion -*- shell-script -*-
|
||||
|
||||
_apm()
|
||||
{
|
||||
local sourcesdir="/etc/apt/sources.list.d"
|
||||
local cur prev words cword
|
||||
_init_completion || return
|
||||
|
||||
local GENERIC_APT_GET_OPTIONS='
|
||||
-d --download-only
|
||||
-y --assume-yes
|
||||
--assume-no
|
||||
-u --show-upgraded
|
||||
-m --ignore-missing
|
||||
-t --target-release
|
||||
--download
|
||||
--fix-missing
|
||||
--ignore-hold
|
||||
--upgrade
|
||||
--only-upgrade
|
||||
--allow-change-held-packages
|
||||
--allow-remove-essential
|
||||
--allow-downgrades
|
||||
--print-uris
|
||||
--trivial-only
|
||||
--remove
|
||||
--arch-only
|
||||
--allow-unauthenticated
|
||||
--allow-insecure-repositories
|
||||
--install-recommends
|
||||
--install-suggests
|
||||
--no-install-recommends
|
||||
--no-install-suggests
|
||||
--fix-policy
|
||||
'
|
||||
|
||||
# see if the user selected a command already
|
||||
local COMMANDS=(
|
||||
"ssaudit"
|
||||
"list"
|
||||
"search"
|
||||
"show" "showsrc"
|
||||
"install" "remove" "purge" "autoremove" "autopurge"
|
||||
"update"
|
||||
"upgrade" "full-upgrade" "dist-upgrade"
|
||||
"run"
|
||||
"help"
|
||||
"source" "build-dep"
|
||||
"clean" "autoclean"
|
||||
"download" "changelog"
|
||||
"amber"
|
||||
"debug"
|
||||
"depends" "rdepends"
|
||||
"policy")
|
||||
|
||||
local command i
|
||||
for (( i=0; i < ${#words[@]}-1; i++ )); do
|
||||
if [[ ${COMMANDS[@]} =~ ${words[i]} ]]; then
|
||||
command=${words[i]}
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
|
||||
# supported options per command
|
||||
if [[ "$cur" == -* ]]; then
|
||||
case $command in
|
||||
install|remove|purge|upgrade|dist-upgrade|full-upgrade|autoremove)
|
||||
COMPREPLY=( $( compgen -W '--show-progress
|
||||
--fix-broken --purge --verbose-versions --auto-remove
|
||||
-s --simulate --dry-run
|
||||
--download
|
||||
--fix-missing
|
||||
--fix-policy
|
||||
--ignore-hold
|
||||
--force-yes
|
||||
--trivial-only
|
||||
--reinstall --solver
|
||||
-t --target-release'"$GENERIC_APT_GET_OPTIONS" -- "$cur" ) )
|
||||
return 0
|
||||
;;
|
||||
update)
|
||||
COMPREPLY=( $( compgen -W '--list-cleanup
|
||||
--print-uris
|
||||
--allow-insecure-repositories
|
||||
' -- "$cur" ) )
|
||||
return 0
|
||||
;;
|
||||
list)
|
||||
COMPREPLY=( $( compgen -W '--installed --upgradable
|
||||
--manual-installed
|
||||
-v --verbose
|
||||
-a --all-versions
|
||||
-t --target-release
|
||||
' -- "$cur" ) )
|
||||
return 0
|
||||
;;
|
||||
show)
|
||||
COMPREPLY=( $( compgen -W '-a --all-versions
|
||||
' -- "$cur" ) )
|
||||
return 0
|
||||
;;
|
||||
depends|rdepends)
|
||||
COMPREPLY=( $( compgen -W '-i
|
||||
--important
|
||||
--installed
|
||||
--pre-depends
|
||||
--depends
|
||||
--recommends
|
||||
--suggests
|
||||
--replaces
|
||||
--breaks
|
||||
--conflicts
|
||||
--enhances
|
||||
--recurse
|
||||
--implicit' -- "$cur" ) )
|
||||
return 0
|
||||
;;
|
||||
search)
|
||||
COMPREPLY=( $( compgen -W '
|
||||
-n --names-only
|
||||
-f --full' -- "$cur" ) )
|
||||
return 0
|
||||
;;
|
||||
showsrc)
|
||||
COMPREPLY=( $( compgen -W '
|
||||
--only-source' -- "$cur" ) )
|
||||
return 0
|
||||
;;
|
||||
source)
|
||||
COMPREPLY=( $( compgen -W '
|
||||
-s --simulate --dry-run
|
||||
-b --compile --build
|
||||
-P --build-profiles
|
||||
--diff-only --debian-only
|
||||
--tar-only
|
||||
--dsc-only
|
||||
-t --target-release
|
||||
'"$GENERIC_APT_GET_OPTIONS" -- "$cur" ) )
|
||||
return 0
|
||||
;;
|
||||
build-dep)
|
||||
COMPREPLY=( $( compgen -W '
|
||||
-a --host-architecture
|
||||
-s --simulate --dry-run
|
||||
-P --build-profiles
|
||||
-t --target-release
|
||||
--purge --solver
|
||||
'"$GENERIC_APT_GET_OPTIONS" -- "$cur" ) )
|
||||
return 0
|
||||
;;
|
||||
moo)
|
||||
COMPREPLY=( $( compgen -W '
|
||||
--color
|
||||
' -- "$cur" ) )
|
||||
return 0
|
||||
;;
|
||||
clean|autoclean)
|
||||
COMPREPLY=( $( compgen -W '
|
||||
-s --simulate --dry-run
|
||||
' -- "$cur" ) )
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
# 定义目录路径
|
||||
primary_dir="/var/lib/apm/apm/files/ace-env/var/lib/apm/"
|
||||
fallback_dir="/var/lib/apm/"
|
||||
|
||||
# 查找不包含特定子目录的目录
|
||||
find_directories_without_ace_env() {
|
||||
local base_dir="$1"
|
||||
local result=()
|
||||
|
||||
# 检查基础目录是否存在
|
||||
if [[ ! -d "$base_dir" ]]; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
# 查找所有直接子目录,排除包含ace-env子目录的目录
|
||||
while IFS= read -r -d '' dir; do
|
||||
if [[ -d "$dir" ]] && [[ ! -d "$dir/files/ace-env" ]]; then
|
||||
result+=("$(basename $dir)")
|
||||
fi
|
||||
done < <(find "$base_dir" -maxdepth 1 -type d ! -path "$base_dir" -print0 2>/dev/null)
|
||||
|
||||
# 输出结果
|
||||
if [[ ${#result[@]} -gt 0 ]]; then
|
||||
printf '%s\n' "${result[@]}"
|
||||
return 0
|
||||
fi
|
||||
return 1
|
||||
}
|
||||
function apm_run_compgen(){
|
||||
result=$(find_directories_without_ace_env "$primary_dir")
|
||||
|
||||
if [[ -n "$result" ]]; then
|
||||
echo "$result"
|
||||
else
|
||||
result=$(find_directories_without_ace_env "$fallback_dir")
|
||||
if [[ -n "$result" ]]; then
|
||||
echo "$result"
|
||||
else
|
||||
echo ""
|
||||
fi
|
||||
fi
|
||||
}
|
||||
# specific command arguments
|
||||
if [[ -n $command ]]; then
|
||||
case $command in
|
||||
remove|purge|autoremove)
|
||||
# Debian system
|
||||
|
||||
|
||||
COMPREPLY=( $( compgen -W "$(ls /var/lib/apm/apm/files/ace-env/var/lib/apm/ )" $cur ) )
|
||||
|
||||
return 0
|
||||
;;
|
||||
show|list|download|changelog|depends|rdepends)
|
||||
COMPREPLY=( $( amber-pm-debug apt-cache --no-generate pkgnames "$cur" -o Dir::Cache="/var/lib/aptss/" \
|
||||
2> /dev/null ) )
|
||||
return 0
|
||||
;;
|
||||
install)
|
||||
COMPREPLY=( $( amber-pm-debug apt-cache --no-generate pkgnames "$cur" -o Dir::Cache="/var/lib/aptss/" \
|
||||
2> /dev/null ) )
|
||||
if [[ "$cur" == ./* || "$cur" == /* ]]; then
|
||||
_filedir "deb"
|
||||
fi
|
||||
return 0
|
||||
;;
|
||||
source|build-dep|showsrc|policy)
|
||||
COMPREPLY=( $( amber-pm-debug apt-cache --no-generate pkgnames "$cur" -o Dir::Cache="/var/lib/aptss/" \
|
||||
2> /dev/null ) $( apt-cache dumpavail -o Dir::Cache="/var/lib/aptss/" | \
|
||||
command grep "^Source: $cur" | sort -u | cut -f2 -d" " ) )
|
||||
return 0
|
||||
;;
|
||||
run)
|
||||
COMPREPLY=( $( compgen -W "$(apm_run_compgen)" "$cur" ) )
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# no command yet, show what commands we have
|
||||
if [ "$command" = "" ]; then
|
||||
COMPREPLY=( $( compgen -W '${COMMANDS[@]}' -- "$cur" ) )
|
||||
fi
|
||||
|
||||
return 0
|
||||
} &&
|
||||
complete -F _apm apm
|
||||
|
||||
# ex: ts=4 sw=4 et filetype=sh
|
||||
Executable
BIN
Binary file not shown.
|
After Width: | Height: | Size: 290 KiB |
Executable
BIN
Binary file not shown.
|
After Width: | Height: | Size: 290 KiB |
Executable
BIN
Binary file not shown.
|
After Width: | Height: | Size: 289 KiB |
Executable
+141
@@ -0,0 +1,141 @@
|
||||
#!/bin/bash
|
||||
|
||||
|
||||
|
||||
chrootEnvPath="${chrootEnvPath:-$(pwd)/ace-env}"
|
||||
|
||||
|
||||
|
||||
non_root_user=$(who | awk '{print $1}' | head -n 1)
|
||||
uid=$(id -u $non_root_user)
|
||||
|
||||
|
||||
#### This part is for args pharm
|
||||
if [ "$1" = "" ];then
|
||||
container_command="bash"
|
||||
else
|
||||
container_command="$1"
|
||||
shift
|
||||
for arg in "$@"; do
|
||||
arg="$(echo "${arg}x" | sed 's|'\''|'\'\\\\\'\''|g')"
|
||||
arg="${arg%x}"
|
||||
container_command="${container_command} '${arg}'"
|
||||
done
|
||||
fi
|
||||
#########################################################################################
|
||||
##########合成bwrap 1. 基础函数配置段
|
||||
# 初始化 EXEC_COMMAND 为 bwrap 基础指令
|
||||
EXEC_COMMAND="bwrap --dev-bind / / bwrap"
|
||||
|
||||
# add_command 函数定义
|
||||
function add_command() {
|
||||
# 参数拼接,考虑到转义和空格的处理
|
||||
for arg in "$@"; do
|
||||
EXEC_COMMAND="${EXEC_COMMAND} ${arg}"
|
||||
done
|
||||
}
|
||||
|
||||
function add_env_var() {
|
||||
local var_name="${1}"
|
||||
local var_value="${2}"
|
||||
if [ "$var_value" != "" ]; then
|
||||
add_command "--setenv $var_name $var_value"
|
||||
|
||||
fi
|
||||
}
|
||||
##########合成bwrap 2. 特殊需求函数配置段
|
||||
function cursor_theme_dir_integration() {
|
||||
|
||||
local directory=""
|
||||
if [ "$(id -u)" = "0" ]; then #####We don't want bother root to install themes,but will try to fix the unwriteable issue
|
||||
mkdir -p $chrootEnvPath/usr/share/icons
|
||||
chmod 777 -R $chrootEnvPath/usr/share/icons
|
||||
return
|
||||
fi
|
||||
|
||||
for directory in "/usr/share/icons"/*; do
|
||||
# 检查是否为目录
|
||||
if [ -d "$directory" ]; then
|
||||
# 检查目录中是否存在 cursors 文件
|
||||
if [ -d "$directory/cursors" ]; then
|
||||
if [ -w $chrootEnvPath/usr/share/icons ];then
|
||||
add_command "--ro-bind-try $directory $directory"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
##########合成bwrap 3. 环境变量和目录绑定配置段
|
||||
# 添加环境变量和其他初始设置
|
||||
ENV_VARS=(
|
||||
"FAKEROOTDONTTRYCHOWN 1"
|
||||
"PULSE_SERVER /run/user/\$uid/pulse/native"
|
||||
"PATH /amber-ce-tools/bin-override:\$PATH"
|
||||
"IS_ACE_ENV 1"
|
||||
"GTK_USE_PORTAL 1"
|
||||
"XDG_DATA_DIRS /amber-ce-tools/additional-data-dir-in-container:\$XDG_DATA_DIRS"
|
||||
)
|
||||
|
||||
BIND_DIRS=(
|
||||
"--dev-bind $chrootEnvPath/ /"
|
||||
"--dev-bind-try /media /media"
|
||||
"--dev-bind-try /mnt /mnt"
|
||||
"--dev-bind-try /tmp /tmp"
|
||||
"--dev-bind-try /data /data"
|
||||
"--dev-bind-try /dev /dev"
|
||||
"--proc /proc"
|
||||
"--dev-bind /sys /sys"
|
||||
"--dev-bind /run /run"
|
||||
"--dev-bind-try /run/user/\$uid/pulse /run/user/\$uid/pulse"
|
||||
"--dev-bind / /host"
|
||||
"--ro-bind-try /usr/share/themes /usr/local/share/themes"
|
||||
"--ro-bind-try /usr/share/icons /usr/share/icons"
|
||||
"--ro-bind-try /usr/share/fonts /usr/local/share/fonts"
|
||||
"--dev-bind-try /etc/resolv.conf /etc/resolv.conf"
|
||||
"--dev-bind-try /home /home"
|
||||
)
|
||||
EXTRA_ARGS=(
|
||||
"--hostname Amber-PM"
|
||||
"--unshare-uts"
|
||||
"--cap-add CAP_SYS_ADMIN"
|
||||
)
|
||||
|
||||
EXTRA_SCRIPTS=(
|
||||
# cursor_theme_dir_integration
|
||||
)
|
||||
|
||||
##########合成bwrap 4. 合成并执行指令
|
||||
# 逐一添加到 EXEC_COMMAND
|
||||
for var in "${ENV_VARS[@]}"; do
|
||||
add_env_var $var
|
||||
done
|
||||
|
||||
for var in "${BIND_DIRS[@]}"; do
|
||||
add_command "$var"
|
||||
done
|
||||
|
||||
for var in "${EXTRA_ARGS[@]}"; do
|
||||
add_command "$var"
|
||||
done
|
||||
|
||||
for var in "${EXTRA_SCRIPTS[@]}"; do
|
||||
$var
|
||||
done
|
||||
|
||||
# 添加最终的 bash 命令
|
||||
add_command "bash -c \"${container_command}\""
|
||||
|
||||
# 输出完整的 EXEC_COMMAND 以查看
|
||||
# echo "${EXEC_COMMAND}"
|
||||
|
||||
# 注意: 实际执行时,请确保所有变量(如 $uid, $chrootEnvPath 等)都已正确定义
|
||||
eval ${EXEC_COMMAND}
|
||||
|
||||
|
||||
Executable
+140
@@ -0,0 +1,140 @@
|
||||
#!/bin/bash
|
||||
|
||||
|
||||
|
||||
chrootEnvPath="${chrootEnvPath:-$(pwd)/ace-env}"
|
||||
|
||||
|
||||
|
||||
non_root_user=$(who | awk '{print $1}' | head -n 1)
|
||||
uid=$(id -u $non_root_user)
|
||||
|
||||
|
||||
#### This part is for args pharm
|
||||
if [ "$1" = "" ];then
|
||||
container_command="bash"
|
||||
else
|
||||
container_command="$1"
|
||||
shift
|
||||
for arg in "$@"; do
|
||||
arg="$(echo "${arg}x" | sed 's|'\''|'\'\\\\\'\''|g')"
|
||||
arg="${arg%x}"
|
||||
container_command="${container_command} '${arg}'"
|
||||
done
|
||||
fi
|
||||
#########################################################################################
|
||||
##########合成bwrap 1. 基础函数配置段
|
||||
# 初始化 EXEC_COMMAND 为 bwrap 基础指令
|
||||
EXEC_COMMAND="bwrap --dev-bind / / bwrap"
|
||||
|
||||
# add_command 函数定义
|
||||
function add_command() {
|
||||
# 参数拼接,考虑到转义和空格的处理
|
||||
for arg in "$@"; do
|
||||
EXEC_COMMAND="${EXEC_COMMAND} ${arg}"
|
||||
done
|
||||
}
|
||||
|
||||
function add_env_var() {
|
||||
local var_name="${1}"
|
||||
local var_value="${2}"
|
||||
if [ "$var_value" != "" ]; then
|
||||
add_command "--setenv $var_name $var_value"
|
||||
|
||||
fi
|
||||
}
|
||||
##########合成bwrap 2. 特殊需求函数配置段
|
||||
function cursor_theme_dir_integration() {
|
||||
|
||||
local directory=""
|
||||
if [ "$(id -u)" = "0" ]; then #####We don't want bother root to install themes,but will try to fix the unwriteable issue
|
||||
mkdir -p $chrootEnvPath/usr/share/icons
|
||||
chmod 777 -R $chrootEnvPath/usr/share/icons
|
||||
return
|
||||
fi
|
||||
|
||||
for directory in "/usr/share/icons"/*; do
|
||||
# 检查是否为目录
|
||||
if [ -d "$directory" ]; then
|
||||
# 检查目录中是否存在 cursors 文件
|
||||
if [ -d "$directory/cursors" ]; then
|
||||
if [ -w $chrootEnvPath/usr/share/icons ];then
|
||||
add_command "--ro-bind-try $directory $directory"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
##########合成bwrap 3. 环境变量和目录绑定配置段
|
||||
# 添加环境变量和其他初始设置
|
||||
ENV_VARS=(
|
||||
"FAKEROOTDONTTRYCHOWN 1"
|
||||
"PULSE_SERVER /run/user/\$uid/pulse/native"
|
||||
"PATH /amber-ce-tools/bin-override:\$PATH"
|
||||
"IS_ACE_ENV 1"
|
||||
"GTK_USE_PORTAL 1"
|
||||
"XDG_DATA_DIRS /amber-ce-tools/additional-data-dir-in-container:\$XDG_DATA_DIRS"
|
||||
)
|
||||
|
||||
BIND_DIRS=(
|
||||
"--dev-bind $chrootEnvPath/ /"
|
||||
"--dev-bind-try /media /media"
|
||||
"--dev-bind-try /root /root"
|
||||
"--dev-bind-try /www /www"
|
||||
"--dev-bind-try /mnt /mnt"
|
||||
"--dev-bind-try /tmp /tmp"
|
||||
"--dev-bind-try /data /data"
|
||||
"--dev-bind-try /dev /dev"
|
||||
"--proc /proc"
|
||||
"--dev-bind /sys /sys"
|
||||
"--dev-bind /run /run"
|
||||
"--dev-bind-try /run/user/\$uid/pulse /run/user/\$uid/pulse"
|
||||
"--dev-bind / /host"
|
||||
"--dev-bind-try /etc/resolv.conf /etc/resolv.conf"
|
||||
"--dev-bind-try /home /home"
|
||||
)
|
||||
EXTRA_ARGS=(
|
||||
"--hostname Amber-PM"
|
||||
"--unshare-uts"
|
||||
"--cap-add CAP_SYS_ADMIN"
|
||||
)
|
||||
|
||||
EXTRA_SCRIPTS=(
|
||||
# cursor_theme_dir_integration
|
||||
)
|
||||
|
||||
##########合成bwrap 4. 合成并执行指令
|
||||
# 逐一添加到 EXEC_COMMAND
|
||||
for var in "${ENV_VARS[@]}"; do
|
||||
add_env_var $var
|
||||
done
|
||||
|
||||
for var in "${BIND_DIRS[@]}"; do
|
||||
add_command "$var"
|
||||
done
|
||||
|
||||
for var in "${EXTRA_ARGS[@]}"; do
|
||||
add_command "$var"
|
||||
done
|
||||
|
||||
for var in "${EXTRA_SCRIPTS[@]}"; do
|
||||
$var
|
||||
done
|
||||
|
||||
# 添加最终的 bash 命令
|
||||
add_command "bash -c \"${container_command}\""
|
||||
|
||||
# 输出完整的 EXEC_COMMAND 以查看
|
||||
# echo "${EXEC_COMMAND}"
|
||||
|
||||
# 注意: 实际执行时,请确保所有变量(如 $uid, $chrootEnvPath 等)都已正确定义
|
||||
eval ${EXEC_COMMAND}
|
||||
|
||||
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
Package: ace-host-integration
|
||||
Version: 1.2.2
|
||||
Section: misc
|
||||
Priority: optional
|
||||
Depends: bash
|
||||
Maintainer: shenmo <shenmo@spark-app.store>
|
||||
Architecture: all
|
||||
Conflicts: apm
|
||||
Description: ace-host-integration
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
#!/bin/bash
|
||||
if [ "${1}" = "triggered" ];then
|
||||
/opt/ace-host-integration/ace-host-integration
|
||||
fi
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
interest-noawait /var/lib/apm
|
||||
interest-noawait /usr/share/applications
|
||||
Executable
+1
@@ -0,0 +1 @@
|
||||
IS_ACE_ENV=1
|
||||
+98
@@ -0,0 +1,98 @@
|
||||
#!/bin/bash
|
||||
# ===== Log =====
|
||||
# log.info xxx
|
||||
# log.warn xxx
|
||||
# log.info xxx
|
||||
# log.debug xxx
|
||||
# 带颜色的echo
|
||||
function log.color_output() {
|
||||
local color=$1
|
||||
shift 1
|
||||
|
||||
echo >&2 -e "\033[${color}m$@\033[0m"
|
||||
return 0
|
||||
}
|
||||
|
||||
# Log is named without prefix "utils." for convenience
|
||||
# Usage: log.log <level> ...content
|
||||
function log.log() {
|
||||
if [[ $# < 2 ]]; then
|
||||
return -1
|
||||
fi
|
||||
|
||||
local level=$1
|
||||
shift 1
|
||||
|
||||
case $level in
|
||||
error) log.color_output "0;31" "[ERROR] $@" ;;
|
||||
warn) log.color_output "1;33" "[WARN] $@" ;;
|
||||
info) log.color_output "1;37" "[INFO] $@" ;;
|
||||
debug) log.color_output "1;30" "[DEBUG] $@" ;;
|
||||
esac
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
function log.error() { log.log "error" "$@"; }
|
||||
function log.warn() { log.log "warn" $@; }
|
||||
function log.info() { log.log "info" $@; }
|
||||
function log.debug() { log.log "debug" $@; }
|
||||
|
||||
function do_integrate(){
|
||||
local file=$1
|
||||
if [ -f "$file" ]; then
|
||||
# 获取文件名(不带.desktop后缀)作为X-AMBER-CE-DESKTOP-NAME的值
|
||||
local desktop_name=$(basename "$file" .desktop)
|
||||
|
||||
# 检查是否已经处理过(通过检查X-AMBER-CE-DESKTOP-NAME字段)
|
||||
if ! grep -q "^X-AMBER-CE-DESKTOP-NAME=" "$file"; then
|
||||
echo "$file is detected. Processing host system integration..."
|
||||
|
||||
# 修改Exec行(如果尚未修改)
|
||||
if ! grep -q "^Exec=apm-debug " "$file"; then
|
||||
sed -i 's|^Exec=\(.*\)|Exec=apm-debug \1|' "$file"
|
||||
fi
|
||||
|
||||
# 删除TryExec行
|
||||
sed -i '/^TryExec=/d' "$file"
|
||||
|
||||
# 修改Name行(包括本地化Name)
|
||||
sed -i '/^Name=/ s/$/ (Amber-PM)/' "$file"
|
||||
sed -i "/^Name\[${LANGUAGE}\]=/ s/\$/ (Amber-PM)/" "$file"
|
||||
|
||||
# 修改GenericName行(包括本地化GenericName)
|
||||
sed -i '/^GenericName=/ s/$/ (Amber-PM)/' "$file"
|
||||
sed -i "/^GenericName\[${LANGUAGE}\]=/ s/\$/ (Amber-PM)/" "$file"
|
||||
|
||||
# 添加X-AMBER-CE-DESKTOP-NAME字段
|
||||
echo "X-AMBER-CE-DESKTOP-NAME=${desktop_name}" >> "$file"
|
||||
|
||||
# 处理Icon行
|
||||
icon_line=$(grep "^Icon=" "$file")
|
||||
if [[ "$icon_line" == "Icon=/"* ]]; then
|
||||
# 如果Icon=后面接的是/,则添加前缀
|
||||
sed -i 's|^Icon=/|Icon=/lib/apm/apm/files/ace-env/|' "$file"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
chmod +x "$file"
|
||||
}
|
||||
|
||||
if [ "${IS_ACE_ENV}" != "" ]; then
|
||||
if [ -e /opt/apps/ ]; then
|
||||
for app_dir in $(/apm/); do
|
||||
for file in /opt/apps/$app_dir/entries/applications/*.desktop; do
|
||||
do_integrate "$file"
|
||||
done
|
||||
done
|
||||
else
|
||||
log.warn "No /opt/apps directory. Skip..."
|
||||
fi
|
||||
|
||||
for file in /usr/share/applications/*.desktop; do
|
||||
do_integrate "$file"
|
||||
done
|
||||
find "/usr/share/applications/" -xtype l -delete
|
||||
else
|
||||
log.error "DO NOT run me on host OS"
|
||||
fi
|
||||
@@ -0,0 +1,176 @@
|
||||
#!/bin/bash
|
||||
|
||||
|
||||
|
||||
|
||||
#############################################################
|
||||
# ===== Log =====
|
||||
# log.info xxx
|
||||
# log.warn xxx
|
||||
# log.info xxx
|
||||
# log.debug xxx
|
||||
# 带颜色的echo
|
||||
function log.color_output() {
|
||||
local color=$1
|
||||
shift 1
|
||||
|
||||
echo >&2 -e "\033[${color}m$@\033[0m"
|
||||
return 0
|
||||
}
|
||||
|
||||
# Log is named without prefix "utils." for convenience
|
||||
# Usage: log.log <level> ...content
|
||||
function log.log() {
|
||||
if [[ $# < 2 ]]; then
|
||||
return -1
|
||||
fi
|
||||
|
||||
local level=$1
|
||||
shift 1
|
||||
|
||||
case $level in
|
||||
error) log.color_output "0;31" "[ERROR] $@" ;;
|
||||
warn) log.color_output "1;33" "[WARN] $@" ;;
|
||||
info) log.color_output "1;37" "[INFO] $@" ;;
|
||||
debug) log.color_output "1;30" "[DEBUG] $@" ;;
|
||||
esac
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
function log.error() { log.log "error" "$@"; }
|
||||
function log.warn() { log.log "warn" $@; }
|
||||
function log.info() { log.log "info" $@; }
|
||||
function log.debug() { log.log "debug" $@; }
|
||||
|
||||
|
||||
# 发送通知
|
||||
function notify-send() {
|
||||
|
||||
|
||||
# Detect user using the display
|
||||
local user=$(who | awk '{print $1}' | head -n 1)
|
||||
|
||||
# Detect uid of the user
|
||||
local uid=$(id -u $user)
|
||||
log.debug "User is $user and the uid of it is $uid"
|
||||
sudo -u $user DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/${uid}/bus notify-send $@
|
||||
}
|
||||
|
||||
|
||||
# 检测网络链接畅通
|
||||
function network-check()
|
||||
{
|
||||
# 超时时间
|
||||
local timeout=15
|
||||
|
||||
# 目标网站
|
||||
local target=www.baidu.com
|
||||
|
||||
# 获取响应状态码
|
||||
local ret_code=`curl -I -s --connect-timeout ${timeout} ${target} -w %{http_code} | tail -n1`
|
||||
|
||||
if [ "x$ret_code" = "x200" ] ; then
|
||||
# 网络畅通
|
||||
return 0
|
||||
else
|
||||
# 网络不畅通
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
###############################################################
|
||||
|
||||
if [ "$(id -u)" != "0" ]; then
|
||||
log.error "Nope we need root to run"
|
||||
exit -1
|
||||
fi
|
||||
|
||||
network-check
|
||||
if [ $? -ne 0 ] ; then
|
||||
log.error "NETWORK_FAIL"
|
||||
exit -1
|
||||
fi
|
||||
|
||||
# The code above is modified from https://blog.csdn.net/yaxuan88521/article/details/120516298
|
||||
|
||||
|
||||
|
||||
|
||||
if command -v aptss ;then
|
||||
APT_COMMAND=aptss
|
||||
/usr/bin/apt update
|
||||
log.info "Using aptss to operate the upgrade process since we detect it."
|
||||
elif [ -e /usr/bin/apt ];then
|
||||
APT_COMMAND=/usr/bin/apt
|
||||
log.info "Using apt to operate the upgrade process."
|
||||
else
|
||||
log.error "Nope we support debian only now"
|
||||
exit -1
|
||||
fi
|
||||
${APT_COMMAND} clean
|
||||
${APT_COMMAND} update
|
||||
|
||||
updatetext=`${APT_COMMAND} update 2>&1`
|
||||
|
||||
until [ "`echo $updatetext | grep E: `" = "" ];do
|
||||
log.info "UPDATE_ERROR_AND_WAIT_15_SEC"
|
||||
sleep 15
|
||||
updatetext=`${APT_COMMAND} update 2>&1`
|
||||
|
||||
|
||||
|
||||
done
|
||||
|
||||
|
||||
# 获取可升级包的数量
|
||||
update_app_number=$(env LANGUAGE=en_US ${APT_COMMAND} list --upgradable 2>/dev/null | grep -c upgradable)
|
||||
|
||||
if [ "$update_app_number" -le 0 ] ; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# 获取用户选择的要更新的应用
|
||||
PKG_LIST="$(env LANGUAGE=en_US ${APT_COMMAND} list --upgradable | awk NR\>1)"
|
||||
# 指定分隔符为 \n
|
||||
IFS_OLD="$IFS"
|
||||
IFS=$'\n'
|
||||
|
||||
for line in $PKG_LIST ; do
|
||||
PKG_NAME=$(echo $line | awk -F ' ' '{print $1}')
|
||||
PKG_NEW_VER=$(echo $line | awk -F ' ' '{print $2}')
|
||||
PKG_CUR_VER=$(echo $line | awk -F ' ' '{print $3}')
|
||||
|
||||
# dpkg --compare-versions $PKG_NEW_VER le $PKG_CUR_VER
|
||||
|
||||
# if [ $? -eq 0 ] ; then
|
||||
# let update_app_number=$update_app_number-1
|
||||
# continue
|
||||
# fi
|
||||
|
||||
## 检测是否是 hold 状态
|
||||
PKG_STA=$(dpkg-query -W -f='${db:Status-Want}' $PKG_NAME)
|
||||
if [ "$PKG_STA" = "hold" ] ; then
|
||||
let update_app_number=$update_app_number-1
|
||||
fi
|
||||
done
|
||||
|
||||
# 还原分隔符
|
||||
IFS="$IFS_OLD"
|
||||
if [ $update_app_number -le 0 ] ; then
|
||||
log.info "No package need to upgrade after ignoring those holded ones. exit"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
||||
## 如果都是hold或者版本一致的那就直接退出,否则把剩余的给提醒了
|
||||
|
||||
|
||||
user=$(who | awk '{print $1}' | head -n 1)
|
||||
|
||||
log.info "ACE Amber-PM 环境中有 $update_app_number 个软件包可升级,正在自动升级"
|
||||
notify-send -a apm "ACE Amber-PM" "ACE Amber-PM环境中有${update_app_number}个软件包可升级,执行自动升级..."
|
||||
|
||||
${APT_COMMAND} clean
|
||||
${APT_COMMAND} full-upgrade -y
|
||||
${APT_COMMAND} clean
|
||||
notify-send -a apm "ACE兼容环境" "自动升级结束"
|
||||
+1
@@ -0,0 +1 @@
|
||||
# File in this dir will be seen as one of XDG_DATA_DIRS in ACE container.
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
[Desktop Entry]
|
||||
Exec=xdg-open %U
|
||||
MimeType=inode/directory;application/x-mimearchive;x-scheme-handler/http;x-scheme-handler/https;application/msword;application/vnd.openxmlformats-officedocument.wordprocessingml.document;application/vnd.ms-excel;application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;application/vnd.ms-powerpoint;application/vnd.openxmlformats-officedocument.presentationml.presentation;application/x-gzip;application/zip;application/rar;application/x-tar;application/pdf;application/rtf;image/gif;image/jpeg;image/jp2;image/png;image/tiff;image/bmp;image/svg+xml;image/webp;image/x-icon;application/kswps;application/kset;application/ksdps;application/x-photoshop;application/x-coreldraw;application/x-shockwave-flash;text/plain;application/x-javascript;text/javascript;text/css;text/html;application/xhtml+xml;text/xml;text/x-vcard;application/x-httpd-php;application/java-archive;application/vnd.android.package-archive;application/octet-stream;application/x-x509-user-cert;audio/mpeg;audio/midi;audio/x-wav;audio/x-mpegurl;audio/x-m4a;audio/ogg;audio/x-realaudio;video/mp4;video/mpeg;video/quicktime;video/x-m4v;video/x-ms-wmv;video/x-msvideo;video/webm;video/x-flv;application/xhtml_xml;
|
||||
Name=ace-run-in-host-os
|
||||
NoDisplay=true
|
||||
Terminal=false
|
||||
TryExec=
|
||||
Type=Application
|
||||
Version=1.0
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
#!/bin/bash
|
||||
### We do not want users to install ACE in ACE.
|
||||
echo "Running ACE in ACE is NOT Tested or recommended. Exit"
|
||||
exit 1
|
||||
@@ -0,0 +1,2 @@
|
||||
#!/bin/bash
|
||||
host-spawn /var/lib/apm/apm/files/bin/ace-run-bwrap "$@"
|
||||
@@ -0,0 +1,6 @@
|
||||
#!/bin/bash
|
||||
if [ "$1" = "open" ];then
|
||||
xdg-open ${@:2}
|
||||
else
|
||||
/usr/bin/gio $@
|
||||
fi
|
||||
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,6 @@
|
||||
#!/bin/bash
|
||||
if [ "$UID" = "0" ];then
|
||||
$@
|
||||
else
|
||||
host-spawn pkexec apm-debug $@
|
||||
fi
|
||||
@@ -0,0 +1,6 @@
|
||||
#!/bin/bash
|
||||
if [ "$UID" = "0" ];then
|
||||
/usr/bin/sudo $@
|
||||
else
|
||||
host-spawn sudo apm-debug sudo env IS_ACE_ENV="1" PATH="/amber-ce-tools/bin-override:$PATH" "$@"
|
||||
fi
|
||||
+1072
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,143 @@
|
||||
#!/bin/bash
|
||||
if [ "$IS_ACE_ENV" != "1" ];then
|
||||
echo "ONLY RUN ME IN ACE"
|
||||
exit
|
||||
fi
|
||||
|
||||
|
||||
|
||||
printf "ACE: Setting up sudo...\n"
|
||||
mkdir -p /etc/sudoers.d
|
||||
# Do not check fqdn when doing sudo, it will not work anyways
|
||||
if ! grep -q 'Defaults !fqdn' /etc/sudoers.d/sudoers; then
|
||||
printf "Defaults !fqdn\n" >> /etc/sudoers.d/sudoers
|
||||
fi
|
||||
# Ensure passwordless sudo is set up for user
|
||||
if ! grep -q "\"${container_user_name}\" ALL = (root) NOPASSWD:ALL" /etc/sudoers.d/sudoers; then
|
||||
printf "\"%s\" ALL = (root) NOPASSWD:ALL\n" "${container_user_name}" >> /etc/sudoers.d/sudoers
|
||||
fi
|
||||
|
||||
|
||||
|
||||
|
||||
printf "ACE: Setting up groups...\n"
|
||||
# If not existing, ensure we have a group for our user.
|
||||
if ! grep -q "^${container_user_name}:" /etc/group; then
|
||||
if ! groupadd --force --gid "${container_user_gid}" "${container_user_name}"; then
|
||||
# It may occur that we have users with unsupported user name (eg. on LDAP or AD)
|
||||
# So let's try and force the group creation this way.
|
||||
printf "%s:x:%s:" "${container_user_name}" "${container_user_gid}" >> /etc/group
|
||||
fi
|
||||
fi
|
||||
|
||||
printf "ACE: Setting up users...\n"
|
||||
|
||||
# Setup kerberos integration with the host
|
||||
if [ -d "/run/host/var/kerberos" ] &&
|
||||
[ -d "/etc/krb5.conf.d" ] &&
|
||||
[ ! -e "/etc/krb5.conf.d/kcm_default_ccache" ]; then
|
||||
|
||||
cat << EOF > "/etc/krb5.conf.d/kcm_default_ccache"
|
||||
# # To disable the KCM credential cache, comment out the following lines.
|
||||
[libdefaults]
|
||||
default_ccache_name = KCM:
|
||||
EOF
|
||||
fi
|
||||
|
||||
# If we have sudo/wheel groups, let's add the user to them.
|
||||
additional_groups=""
|
||||
if grep -q "^sudo" /etc/group; then
|
||||
additional_groups="sudo"
|
||||
elif grep -q "^wheel" /etc/group; then
|
||||
additional_groups="wheel"
|
||||
fi
|
||||
|
||||
# Let's add our user to the container. if the user already exists, enforce properties.
|
||||
#
|
||||
# In case of AD or LDAP usernames, it is possible we will have a backslach in the name.
|
||||
# In that case grep would fail, so we replace the backslash with a point to make the regex work.
|
||||
# shellcheck disable=SC1003
|
||||
if ! grep -q "^$(printf '%s' "${container_user_name}" | tr '\\' '.'):" /etc/passwd &&
|
||||
! grep -q "^.*:.*:${container_user_uid}:" /etc/passwd; then
|
||||
if ! useradd \
|
||||
--home-dir "${container_user_home}" \
|
||||
--no-create-home \
|
||||
--groups "${additional_groups}" \
|
||||
--shell "${SHELL:-"/bin/bash"}" \
|
||||
--uid "${container_user_uid}" \
|
||||
--gid "${container_user_gid}" \
|
||||
"${container_user_name}"; then
|
||||
|
||||
printf "Warning: there was a problem setting up the user\n"
|
||||
printf "Warning: trying manual addition\n"
|
||||
printf "%s:x:%s:%s:%s:%s:%s" \
|
||||
"${container_user_name}" "${container_user_uid}" \
|
||||
"${container_user_gid}" "${container_user_name}" \
|
||||
"${container_user_home}" "${SHELL:-"/bin/bash"}" >> /etc/passwd
|
||||
printf "%s::1::::::" "${container_user_name}" >> /etc/shadow
|
||||
fi
|
||||
# Ensure we're not using the specified SHELL. Run it only once, so that future
|
||||
# user's preferences are not overwritten at each start.
|
||||
elif [ ! -e /etc/passwd.done ]; then
|
||||
# This situation is presented when podman or docker already creates the user
|
||||
# for us inside container. We should modify the user's prepopulated shadowfile
|
||||
# entry though as per user's active preferences.
|
||||
|
||||
# If the user was there with a different username, get that username so
|
||||
# we can modify it
|
||||
if ! grep -q "^$(printf '%s' "${container_user_name}" | tr '\\' '.'):" /etc/passwd; then
|
||||
user_to_modify=$(getent passwd "${container_user_uid}" | cut -d: -f1)
|
||||
fi
|
||||
|
||||
if ! usermod \
|
||||
--home "${container_user_home}" \
|
||||
--shell "${SHELL:-"/bin/bash"}" \
|
||||
--groups "${additional_groups}" \
|
||||
--uid "${container_user_uid}" \
|
||||
--gid "${container_user_gid}" \
|
||||
--login "${container_user_name}" \
|
||||
"${user_to_modify:-"${container_user_name}"}"; then
|
||||
|
||||
printf "Warning: there was a problem setting up the user\n"
|
||||
fi
|
||||
touch /etc/passwd.done
|
||||
fi
|
||||
|
||||
# We generate a random password to initialize the entry for the user and root.
|
||||
temporary_password="$(cat /proc/sys/kernel/random/uuid)"
|
||||
printf "%s\n%s\n" "${temporary_password}" "${temporary_password}" | passwd root
|
||||
printf "%s:%s" "${container_user_name}" "${temporary_password}" | chpasswd -e
|
||||
# Delete password for root and user
|
||||
printf "%s:" "root" | chpasswd -e
|
||||
printf "%s:" "${container_user_name}" | chpasswd -e
|
||||
|
||||
mkdir -p /usr/share/fonts
|
||||
mkdir -p /usr/share/icons
|
||||
mkdir -p /usr/share/themes
|
||||
|
||||
## init host-spawn
|
||||
unlink /amber-ce-tools/bin-override/host-spawn
|
||||
ln -sfv /amber-ce-tools/bin-override/host-spawn-$(uname -m) /amber-ce-tools/bin-override/host-spawn
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
exit 0
|
||||
|
||||
## install host-integration
|
||||
pushd /amber-ce-tools/ace-host-integration
|
||||
|
||||
dpkg-deb -Z xz -b . ../ace-host-integration.deb
|
||||
|
||||
popd
|
||||
apt install --reinstall /amber-ce-tools/ace-host-integration.deb -y
|
||||
|
||||
|
||||
cd /amber-ce-tools/data-dir/
|
||||
ln -sfv ../../usr/share/applications/ .
|
||||
ln -sfv ../../usr/share/icons/ .
|
||||
#ln -svf ../../usr/share/mime .
|
||||
rm -vf ./mime
|
||||
update-desktop-database /usr/share/applications || true
|
||||
update-mime-database /usr/share/mime || true
|
||||
@@ -0,0 +1 @@
|
||||
# App in this dir will be integrated to host os. Will create symbol link when installing
|
||||
Executable
+7
@@ -0,0 +1,7 @@
|
||||
#!/bin/bash
|
||||
if [ "$UID" != "0" ];then
|
||||
pkexec $0
|
||||
exit
|
||||
fi
|
||||
|
||||
apm-debug amber-pm-dstore-patch
|
||||
Executable
+119
@@ -0,0 +1,119 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [ "$(id -u)" != "0" ]; then
|
||||
echo "当前用户不是 root 用户,退出"
|
||||
exit
|
||||
fi
|
||||
if [ "$PACKAGE_NAME" = "" ];then
|
||||
curdir=`realpath $0`
|
||||
parent_dir=`dirname $curdir`
|
||||
pparent_dir=`dirname $parent_dir`
|
||||
ppparent_dir=`dirname $pparent_dir`
|
||||
PKGNAME=`basename $ppparent_dir`
|
||||
else
|
||||
|
||||
PKGNAME=$PACKAGE_NAME
|
||||
fi
|
||||
chrootEnvPath=/var/lib/apm/$PKGNAME/files/ace-env
|
||||
#if [ ! -e $chrootEnvPath ];then
|
||||
echo "Uncompress the env...."
|
||||
tar -xvf $chrootEnvPath.tar.xz -C /var/lib/apm/$PKGNAME/files/
|
||||
#fi
|
||||
|
||||
HERE="$(dirname $(realpath $0))"
|
||||
|
||||
function get_current_user() {
|
||||
# 优先通过 who 命令获取用户
|
||||
local user
|
||||
user=$(who | awk '{print $1}' | head -n 1 2>/dev/null)
|
||||
|
||||
# 如果 who 无输出,则通过 loginctl 获取
|
||||
if [[ -z "$user" ]]; then
|
||||
user=$(loginctl list-sessions --no-legend 2>/dev/null | awk '{print $3}' | head -n 1)
|
||||
fi
|
||||
|
||||
# 返回最终结果(可能为空)
|
||||
echo "${user}"
|
||||
}
|
||||
non_root_user=$(get_current_user)
|
||||
uid=$(id -u $non_root_user)
|
||||
|
||||
function bookworm-run(){
|
||||
bwrap --dev-bind $chrootEnvPath/ / \
|
||||
--setenv PULSE_SERVER /run/user/$uid/pulse/native \
|
||||
--setenv PATH /amber-ce-tools/bin-override:$PATH \
|
||||
--setenv IS_ACE_ENV "1" \
|
||||
--dev-bind-try /media /media \
|
||||
--dev-bind-try /tmp /tmp \
|
||||
--dev /dev \
|
||||
--dev-bind-try /dev/dri /dev/dri \
|
||||
--proc /proc \
|
||||
--dev-bind / /host \
|
||||
--dev-bind /sys /sys \
|
||||
--dev-bind /run /run \
|
||||
--dev-bind-try /run/user/$uid/pulse /run/user/$uid/pulse \
|
||||
--bind-try /usr/share/themes /usr/local/share/themes \
|
||||
--bind-try /usr/share/icons /usr/local/share/icons \
|
||||
--bind-try /usr/share/fonts /usr/local/share/fonts \
|
||||
--hostname Amber-PM \
|
||||
--unshare-uts \
|
||||
--dev-bind-try /etc/resolv.conf /etc/resolv.conf \
|
||||
--dev-bind-try /home /home \
|
||||
$@
|
||||
|
||||
|
||||
}
|
||||
|
||||
echo "Update the flamescion container tools"
|
||||
cp -r `dirname $chrootEnvPath`/amber-ce-tools/ $chrootEnvPath
|
||||
|
||||
|
||||
export container_user_gid="$(sudo -u $non_root_user id -rg)"
|
||||
export container_user_home="/home/${non_root_user}"
|
||||
export container_user_name="${non_root_user}"
|
||||
export container_user_uid="$(sudo -u $non_root_user id -ru)"
|
||||
|
||||
|
||||
|
||||
|
||||
#####init
|
||||
|
||||
|
||||
bookworm-run bash /amber-ce-tools/container-init/init.sh
|
||||
rm $chrootEnvPath/etc/localtime
|
||||
cp $(realpath /etc/localtime) $chrootEnvPath/etc/localtime
|
||||
chmod 777 $chrootEnvPath/etc/localtime
|
||||
bookworm-run cp /host/etc/locale.gen /etc/locale.gen && locale-gen
|
||||
bookworm-run touch /finish.flag
|
||||
bookworm-run apt clean
|
||||
bookworm-run chown -R $(get_current_user) /usr/lib/locale/
|
||||
sudo -u $(get_current_user) bwrap --dev-bind $chrootEnvPath/ / \
|
||||
--setenv PULSE_SERVER /run/user/$uid/pulse/native \
|
||||
--setenv PATH /amber-ce-tools/bin-override:$PATH \
|
||||
--setenv IS_ACE_ENV "1" \
|
||||
--dev-bind $chrootEnvPath/ / \
|
||||
--dev-bind-try /media /media \
|
||||
--dev-bind-try /tmp /tmp \
|
||||
--dev /dev \
|
||||
--dev-bind-try /dev/dri /dev/dri \
|
||||
--proc /proc \
|
||||
--dev-bind /sys /sys \
|
||||
--dev-bind /run /run \
|
||||
--dev-bind-try /run/user/$uid/pulse /run/user/$uid/pulse \
|
||||
--dev-bind / /host \
|
||||
--bind-try /usr/share/themes /usr/local/share/themes \
|
||||
--bind-try /usr/share/icons /usr/local/share/icons \
|
||||
--bind-try /usr/share/fonts /usr/local/share/fonts \
|
||||
--hostname Amber-PM \
|
||||
--unshare-uts \
|
||||
--dev-bind-try /etc/resolv.conf /etc/resolv.conf \
|
||||
--dev-bind-try /home /home \
|
||||
locale-gen
|
||||
bookworm-run update-locale LANG=$LANG
|
||||
chown -R root $chrootEnvPath
|
||||
mkdir -p $chrootEnvPath/amber-ce-tools/data-dir
|
||||
ln -sv ../../usr/share/applications $chrootEnvPath/amber-ce-tools/data-dir/
|
||||
ln -sv ../../usr/share/icons $chrootEnvPath/amber-ce-tools/data-dir/
|
||||
chmod 777 -R $chrootEnvPath/usr/share/icons
|
||||
rm -vfr $chrootEnvPath/dev/*
|
||||
true
|
||||
Executable
+154
@@ -0,0 +1,154 @@
|
||||
#!/bin/bash
|
||||
|
||||
curdir=`realpath $0`
|
||||
parent_dir=`dirname $curdir`
|
||||
pparent_dir=`dirname $parent_dir`
|
||||
ppparent_dir=`dirname $pparent_dir`
|
||||
PKGNAME=`basename $ppparent_dir`
|
||||
export ACE_PACKAGE_NAME=$PKGNAME
|
||||
|
||||
chrootEnvPath=/var/lib/apm/$PKGNAME/files/ace-env
|
||||
|
||||
if [ ! -e $chrootEnvPath/finish.flag ];then
|
||||
|
||||
if [ "$(id -u)" = "0" ]; then
|
||||
`dirname $chrootEnvPath`/bin/ace-init
|
||||
else
|
||||
pkexec `dirname $chrootEnvPath`/bin/ace-init
|
||||
fi
|
||||
|
||||
|
||||
fi
|
||||
non_root_user=$(who | awk '{print $1}' | head -n 1)
|
||||
uid=$(id -u $non_root_user)
|
||||
|
||||
|
||||
#### This part is for args pharm
|
||||
if [ "$1" = "" ];then
|
||||
container_command="bash"
|
||||
else
|
||||
container_command="$1"
|
||||
shift
|
||||
for arg in "$@"; do
|
||||
arg="$(echo "${arg}x" | sed 's|'\''|'\'\\\\\'\''|g')"
|
||||
arg="${arg%x}"
|
||||
container_command="${container_command} '${arg}'"
|
||||
done
|
||||
fi
|
||||
#########################################################################################
|
||||
##########合成bwrap 1. 基础函数配置段
|
||||
# 初始化 EXEC_COMMAND 为 bwrap 基础指令
|
||||
EXEC_COMMAND="bwrap --dev-bind / / bwrap"
|
||||
|
||||
# add_command 函数定义
|
||||
function add_command() {
|
||||
# 参数拼接,考虑到转义和空格的处理
|
||||
for arg in "$@"; do
|
||||
EXEC_COMMAND="${EXEC_COMMAND} ${arg}"
|
||||
done
|
||||
}
|
||||
|
||||
function add_env_var() {
|
||||
local var_name="${1}"
|
||||
local var_value="${2}"
|
||||
if [ "$var_value" != "" ]; then
|
||||
add_command "--setenv $var_name $var_value"
|
||||
|
||||
fi
|
||||
}
|
||||
##########合成bwrap 2. 特殊需求函数配置段
|
||||
function cursor_theme_dir_integration() {
|
||||
|
||||
local directory=""
|
||||
if [ "$(id -u)" = "0" ]; then #####We don't want bother root to install themes,but will try to fix the unwriteable issue
|
||||
mkdir -p $chrootEnvPath/usr/share/icons
|
||||
chmod 777 -R $chrootEnvPath/usr/share/icons
|
||||
return
|
||||
fi
|
||||
|
||||
for directory in "/usr/share/icons"/*; do
|
||||
# 检查是否为目录
|
||||
if [ -d "$directory" ]; then
|
||||
# 检查目录中是否存在 cursors 文件
|
||||
if [ -d "$directory/cursors" ]; then
|
||||
if [ -w $chrootEnvPath/usr/share/icons ];then
|
||||
add_command "--ro-bind-try $directory $directory"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
##########合成bwrap 3. 环境变量和目录绑定配置段
|
||||
# 添加环境变量和其他初始设置
|
||||
ENV_VARS=(
|
||||
"FAKEROOTDONTTRYCHOWN 1"
|
||||
"PULSE_SERVER /run/user/\$uid/pulse/native"
|
||||
"PATH /amber-ce-tools/bin-override:\$PATH"
|
||||
"IS_ACE_ENV 1"
|
||||
"IS_APM_ENV 1"
|
||||
"XDG_DATA_DIRS /amber-ce-tools/additional-data-dir-in-container:\$XDG_DATA_DIRS"
|
||||
)
|
||||
|
||||
BIND_DIRS=(
|
||||
"--dev-bind $chrootEnvPath/ /"
|
||||
"--dev-bind-try /media /media"
|
||||
"--dev-bind-try /mnt /mnt"
|
||||
"--dev-bind-try /tmp /tmp"
|
||||
"--dev-bind-try /data /data"
|
||||
"--dev-bind-try /dev /dev"
|
||||
"--proc /proc"
|
||||
"--dev-bind /sys /sys"
|
||||
"--dev-bind /run /run"
|
||||
"--dev-bind-try /run/user/\$uid/pulse /run/user/\$uid/pulse"
|
||||
"--dev-bind / /host"
|
||||
"--ro-bind-try /usr/share/themes /usr/local/share/themes"
|
||||
"--ro-bind-try /usr/share/icons /usr/local/share/icons"
|
||||
"--ro-bind-try /usr/share/fonts /usr/local/share/fonts"
|
||||
"--dev-bind-try /etc/resolv.conf /etc/resolv.conf"
|
||||
"--dev-bind-try /home /home"
|
||||
)
|
||||
EXTRA_ARGS=(
|
||||
"--hostname Amber-PM"
|
||||
"--unshare-uts"
|
||||
"--cap-add CAP_SYS_ADMIN"
|
||||
)
|
||||
|
||||
EXTRA_SCRIPTS=(
|
||||
# cursor_theme_dir_integration
|
||||
)
|
||||
|
||||
##########合成bwrap 4. 合成并执行指令
|
||||
# 逐一添加到 EXEC_COMMAND
|
||||
for var in "${ENV_VARS[@]}"; do
|
||||
add_env_var $var
|
||||
done
|
||||
|
||||
for var in "${BIND_DIRS[@]}"; do
|
||||
add_command "$var"
|
||||
done
|
||||
|
||||
for var in "${EXTRA_ARGS[@]}"; do
|
||||
add_command "$var"
|
||||
done
|
||||
|
||||
for var in "${EXTRA_SCRIPTS[@]}"; do
|
||||
$var
|
||||
done
|
||||
|
||||
# 添加最终的 bash 命令
|
||||
add_command "bash -c \"${container_command}\""
|
||||
|
||||
# 输出完整的 EXEC_COMMAND 以查看
|
||||
# echo "${EXEC_COMMAND}"
|
||||
|
||||
# 注意: 实际执行时,请确保所有变量(如 $uid, $chrootEnvPath 等)都已正确定义
|
||||
eval ${EXEC_COMMAND}
|
||||
|
||||
|
||||
Executable
+155
@@ -0,0 +1,155 @@
|
||||
#!/bin/bash
|
||||
|
||||
curdir=`realpath $0`
|
||||
parent_dir=`dirname $curdir`
|
||||
pparent_dir=`dirname $parent_dir`
|
||||
ppparent_dir=`dirname $pparent_dir`
|
||||
PKGNAME=`basename $ppparent_dir`
|
||||
export ACE_PACKAGE_NAME=$PKGNAME
|
||||
|
||||
chrootEnvPath=/var/lib/apm/$PKGNAME/files/ace-env
|
||||
|
||||
if [ ! -e $chrootEnvPath/finish.flag ];then
|
||||
|
||||
if [ "$(id -u)" = "0" ]; then
|
||||
`dirname $chrootEnvPath`/bin/ace-init
|
||||
else
|
||||
pkexec `dirname $chrootEnvPath`/bin/ace-init
|
||||
fi
|
||||
|
||||
|
||||
fi
|
||||
non_root_user=$(who | awk '{print $1}' | head -n 1)
|
||||
uid=$(id -u $non_root_user)
|
||||
|
||||
|
||||
#### This part is for args pharm
|
||||
if [ "$1" = "" ];then
|
||||
container_command="bash"
|
||||
else
|
||||
container_command="$1"
|
||||
shift
|
||||
for arg in "$@"; do
|
||||
arg="$(echo "${arg}x" | sed 's|'\''|'\'\\\\\'\''|g')"
|
||||
arg="${arg%x}"
|
||||
container_command="${container_command} '${arg}'"
|
||||
done
|
||||
fi
|
||||
#########################################################################################
|
||||
##########合成bwrap 1. 基础函数配置段
|
||||
# 初始化 EXEC_COMMAND 为 bwrap 基础指令
|
||||
EXEC_COMMAND="bwrap --dev-bind / / bwrap"
|
||||
|
||||
# add_command 函数定义
|
||||
function add_command() {
|
||||
# 参数拼接,考虑到转义和空格的处理
|
||||
for arg in "$@"; do
|
||||
EXEC_COMMAND="${EXEC_COMMAND} ${arg}"
|
||||
done
|
||||
}
|
||||
|
||||
function add_env_var() {
|
||||
local var_name="${1}"
|
||||
local var_value="${2}"
|
||||
if [ "$var_value" != "" ]; then
|
||||
add_command "--setenv $var_name $var_value"
|
||||
|
||||
fi
|
||||
}
|
||||
##########合成bwrap 2. 特殊需求函数配置段
|
||||
function cursor_theme_dir_integration() {
|
||||
|
||||
local directory=""
|
||||
if [ "$(id -u)" = "0" ]; then #####We don't want bother root to install themes,but will try to fix the unwriteable issue
|
||||
mkdir -p $chrootEnvPath/usr/share/icons
|
||||
chmod 777 -R $chrootEnvPath/usr/share/icons
|
||||
return
|
||||
fi
|
||||
|
||||
for directory in "/usr/share/icons"/*; do
|
||||
# 检查是否为目录
|
||||
if [ -d "$directory" ]; then
|
||||
# 检查目录中是否存在 cursors 文件
|
||||
if [ -d "$directory/cursors" ]; then
|
||||
if [ -w $chrootEnvPath/usr/share/icons ];then
|
||||
add_command "--ro-bind-try $directory $directory"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
##########合成bwrap 3. 环境变量和目录绑定配置段
|
||||
# 添加环境变量和其他初始设置
|
||||
ENV_VARS=(
|
||||
"FAKEROOTDONTTRYCHOWN 1"
|
||||
"PULSE_SERVER /run/user/\$uid/pulse/native"
|
||||
"PATH /amber-ce-tools/bin-override:\$PATH"
|
||||
"IS_ACE_ENV 1"
|
||||
"XDG_DATA_DIRS /amber-ce-tools/additional-data-dir-in-container:\$XDG_DATA_DIRS"
|
||||
)
|
||||
|
||||
BIND_DIRS=(
|
||||
"--dev-bind $chrootEnvPath/ /"
|
||||
"--dev-bind-try /media /media"
|
||||
"--dev-bind-try /mnt /mnt"
|
||||
"--dev-bind-try /tmp /tmp"
|
||||
"--dev-bind-try /data /data"
|
||||
"--dev-bind-try /dev /dev"
|
||||
"--proc /proc"
|
||||
"--dev-bind /sys /sys"
|
||||
"--dev-bind /run /run"
|
||||
"--dev-bind-try /run/user/\$uid/pulse /run/user/\$uid/pulse"
|
||||
"--dev-bind / /host"
|
||||
"--ro-bind-try /usr/share/themes /usr/local/share/themes"
|
||||
"--ro-bind-try /usr/share/icons /usr/local/share/icons"
|
||||
"--ro-bind-try /usr/share/fonts /usr/local/share/fonts"
|
||||
"--dev-bind-try /etc/resolv.conf /etc/resolv.conf"
|
||||
"--dev-bind-try /home /home"
|
||||
)
|
||||
EXTRA_ARGS=(
|
||||
"--hostname Amber-PM"
|
||||
"--unshare-uts"
|
||||
# "--cap-add CAP_SYS_ADMIN"
|
||||
)
|
||||
|
||||
EXTRA_SCRIPTS=(
|
||||
cursor_theme_dir_integration
|
||||
)
|
||||
|
||||
##########合成bwrap 4. 合成并执行指令
|
||||
# 逐一添加到 EXEC_COMMAND
|
||||
for var in "${ENV_VARS[@]}"; do
|
||||
add_env_var $var
|
||||
done
|
||||
|
||||
for var in "${BIND_DIRS[@]}"; do
|
||||
add_command "$var"
|
||||
done
|
||||
|
||||
for var in "${EXTRA_ARGS[@]}"; do
|
||||
add_command "$var"
|
||||
done
|
||||
|
||||
for var in "${EXTRA_SCRIPTS[@]}"; do
|
||||
$var
|
||||
done
|
||||
|
||||
|
||||
|
||||
# 添加最终的 bash 命令
|
||||
add_command "bash -c \"/usr/bin/bwrap ${container_command}\""
|
||||
|
||||
# 输出完整的 EXEC_COMMAND 以查看
|
||||
# echo "${EXEC_COMMAND}"
|
||||
|
||||
# 注意: 实际执行时,请确保所有变量(如 $uid, $chrootEnvPath 等)都已正确定义
|
||||
eval ${EXEC_COMMAND}
|
||||
|
||||
|
||||
+91
@@ -0,0 +1,91 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [ "$UID" != "0" ];then
|
||||
echo "Need to be run as root."
|
||||
exit 1
|
||||
fi
|
||||
# 清除先前的变量值
|
||||
unset ABSOLUTE_PATH IN_CONTAINER_PATH PKGNAME_GUESS DPKG_LIST_FILE ACE_ENV_PATH
|
||||
|
||||
# 定义环境路径变量
|
||||
ACE_ENV_PATH="/var/lib/apm/apm/files/ace-env"
|
||||
|
||||
# 检查参数个数
|
||||
if [ "$#" -ne 1 ]; then
|
||||
echo "Usage: $0 <desktop-file>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 保存并验证绝对路径
|
||||
ABSOLUTE_PATH=$1
|
||||
if [[ $ABSOLUTE_PATH != "$ACE_ENV_PATH"* ]]; then
|
||||
echo "Error: Invalid path. Must start with $ACE_ENV_PATH"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 验证是否为desktop文件
|
||||
if [[ ! $ABSOLUTE_PATH == *.desktop ]]; then
|
||||
if [ ! -e $ABSOLUTE_PATH ];then
|
||||
echo "$ABSOLUTE_PATH does not exist. May have already been uninstalled. Ignore it."
|
||||
exit
|
||||
else
|
||||
echo "Error: The file is not a desktop file."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# 截取路径
|
||||
IN_CONTAINER_PATH=${ABSOLUTE_PATH#"$ACE_ENV_PATH"}
|
||||
|
||||
# 截取并保存包名
|
||||
PKGNAME_GUESS=$(basename "$ABSOLUTE_PATH" .desktop)
|
||||
|
||||
# 检查dpkg列表文件
|
||||
DPKG_INFO_PATH="$ACE_ENV_PATH/var/lib/dpkg/info"
|
||||
if [ -f "$DPKG_INFO_PATH/$PKGNAME_GUESS.list" ]; then
|
||||
DPKG_LIST_FILE="$DPKG_INFO_PATH/$PKGNAME_GUESS.list"
|
||||
elif ls "$DPKG_INFO_PATH/${PKGNAME_GUESS}:*.list" 1> /dev/null 2>&1; then
|
||||
DPKG_LIST_FILE=$(ls "$DPKG_INFO_PATH/${PKGNAME_GUESS}:*.list" | head -n 1)
|
||||
else
|
||||
echo "Warn:No dpkg list file found for $PKGNAME_GUESS.desktop,try to scan to search for the package"
|
||||
fi
|
||||
|
||||
# 验证文件并执行操作
|
||||
if [ -f "$DPKG_LIST_FILE" ]; then
|
||||
|
||||
if grep -q "$IN_CONTAINER_PATH" "$DPKG_LIST_FILE" || grep -q "/var/lib/apm/$PKGNAME_GUESS/entries/applications/$PKGNAME_GUESS.desktop" "$DPKG_LIST_FILE"; then
|
||||
apm-debug apt autopurge $PKGNAME_GUESS -y
|
||||
ret=$?
|
||||
if [ "$ret" = "0" ];then
|
||||
echo "Operation succeeded."
|
||||
exit
|
||||
else
|
||||
echo "Operation failed."
|
||||
exit $ret
|
||||
fi
|
||||
|
||||
else
|
||||
echo "Warn: Path not found in the dpkg list file,try to scan to search for the package"
|
||||
fi
|
||||
fi
|
||||
# 遍历所有list文件 As fallback
|
||||
for file in "$DPKG_INFO_PATH"/*.list; do
|
||||
if grep -q "$IN_CONTAINER_PATH" "$file"; then
|
||||
PKGNAME_GUESS=$(basename "$file" .list | cut -d':' -f1)
|
||||
echo "Get pkgname $PKGNAME_GUESS, uninstalling..."
|
||||
apm-debug apt autopurge $PKGNAME_GUESS -y
|
||||
ret=$?
|
||||
if [ "$ret" = "0" ];then
|
||||
echo "Operation succeeded."
|
||||
exit 0
|
||||
else
|
||||
echo "Operation failed."
|
||||
exit $ret
|
||||
fi
|
||||
|
||||
fi
|
||||
done
|
||||
echo "Error: No matching package found."
|
||||
exit 1
|
||||
|
||||
|
||||
+77
@@ -0,0 +1,77 @@
|
||||
#!/bin/bash
|
||||
if [ "$UID" != "0" ];then
|
||||
pkexec $0
|
||||
exit
|
||||
fi
|
||||
# 定义应用列表文件路径
|
||||
ACE_dir="/var/lib/apm/apm/files/ace-env"
|
||||
HERE="$(dirname $(realpath $0))"
|
||||
# 读取所有.desktop文件,并构造应用列表
|
||||
app_list=()
|
||||
for file in "$ACE_dir"/usr/share/applications/*.desktop; do
|
||||
if [ ! -e "$file" ];then ##可能是软链接,对主机来说无用
|
||||
file=$ACE_dir$(readlink $file)
|
||||
fi
|
||||
if [ "$(grep -m 1 '^NoDisplay=' "$file" | cut -d '=' -f 2)" = "true" ] || [ "$(grep -m 1 '^NoDisplay=' "$file" | cut -d '=' -f 2)" = "True" ];then
|
||||
continue
|
||||
fi
|
||||
# 读取应用名称和简介
|
||||
name_orig=$(grep -m 1 '^Name=' "$file" | cut -d '=' -f 2)
|
||||
name_i18n=$(grep -m 1 "^Name\[${LANGUAGE}\]\=" "$file" | cut -d '=' -f 2)
|
||||
if [ -z "$name_i18n" ] ;then
|
||||
name=$name_orig
|
||||
else
|
||||
name=$name_i18n
|
||||
fi
|
||||
comment_orig=$(grep -m 1 '^Comment=' "$file" | cut -d '=' -f 2)
|
||||
comment_i18n=$(grep -m 1 "^Comment\[${LANGUAGE}\]\=" "$file" | cut -d '=' -f 2)
|
||||
if [ -z "$comment_i18n" ] ;then
|
||||
comment=$comment_orig
|
||||
else
|
||||
comment=$comment_i18n
|
||||
fi
|
||||
# 如果没有简介,则显示"N/A"
|
||||
[[ -z "$comment" ]] && comment="N/A"
|
||||
# 添加到应用列表数组
|
||||
app_list+=("false" "$name" "$comment" "$file")
|
||||
done
|
||||
|
||||
# 使用 Zenity 显示应用列表,并获取用户选择
|
||||
selected_apps=$(zenity --list --title "应用列表" --column "是否卸载" --column "应用名称" --column "应用介绍" --column "desktop文件位置" --checklist "${app_list[@]}" --print-column=4 --hide-column=4 --separator=" " --width=800 --height=400)
|
||||
|
||||
|
||||
# 检查用户是否做出了选择
|
||||
if [ -n "$selected_apps" ]; then
|
||||
# 卸载选中的应用
|
||||
(for app_desktop_path in $selected_apps; do
|
||||
${HERE}/ace-uninstall-helper "$app_desktop_path"
|
||||
ret=$?
|
||||
if [ "$ret" != "0" ];then
|
||||
zenity --error --width 768 --text "$app_desktop_path 卸载失败,中止操作\n请手动执行\nsudo $0 $app_desktop_path \n查看报错!"
|
||||
exit 1
|
||||
break
|
||||
fi
|
||||
done ) &
|
||||
|
||||
cmd_pid=$!
|
||||
|
||||
|
||||
(while kill -0 $cmd_pid 2> /dev/null; do
|
||||
echo "# 正在执行..."
|
||||
sleep 1
|
||||
done)| zenity --progress --text="正在执行卸载操作..." --pulsate --auto-close --no-cancel --width 400
|
||||
wait $cmd_pid
|
||||
cmd_status=$?
|
||||
|
||||
if [ "$cmd_status" = "1" ];then
|
||||
zenity --error --width 200 --text "卸载过程出现错误"
|
||||
exit 1
|
||||
else
|
||||
zenity --info --width 200 --text "选定应用已卸载"
|
||||
fi
|
||||
|
||||
|
||||
else
|
||||
zenity --info --text "未选择任何应用"
|
||||
fi
|
||||
|
||||
+71
@@ -0,0 +1,71 @@
|
||||
#!/bin/bash
|
||||
log.warn() { echo -e "[\e[33mWARN\e[0m]: \e[1m$*\e[0m"; }
|
||||
log.error() { echo -e "[\e[31mERROR\e[0m]: \e[1m$*\e[0m"; }
|
||||
log.info() { echo -e "[\e[96mINFO\e[0m]: \e[1m$*\e[0m"; }
|
||||
log.debug() { echo -e "[\e[32mDEBUG\e[0m]: \e[1m$*\e[0m"; }
|
||||
|
||||
if [ "$UID" != "0" ];then
|
||||
log.error "需要以root权限运行 Need to be run as root."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$1" ];then
|
||||
log.error "需要把ace-env所在的路径设置为第一个参数"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 1\. 获取宿主机 NVIDIA 驱动版本
|
||||
nvidia_version=$(cat /sys/module/nvidia/version 2>/dev/null)
|
||||
if [ -z "$nvidia_version" ]; then
|
||||
log.warn "无法获取 NVIDIA 驱动版本 Can not determine NVIDIA Driver version"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 2\. 目标目录准备
|
||||
ACE_DIR="$1"
|
||||
if [[ ! -e "${ACE_DIR}" ]];then
|
||||
log.error "未检测到 apm安装,请安装后再试 apm is not detected. Please try again after installation"
|
||||
log.info "请按回车关闭... Press Enter to close..."
|
||||
read
|
||||
exit 1
|
||||
fi
|
||||
mkdir -p "$ACE_DIR/usr/lib" "$ACE_DIR/usr/lib32"
|
||||
|
||||
log.info "正在链接 NVIDIA 驱动库 Linking NVIDIA Driver Libs"
|
||||
|
||||
# 3\. 收集库文件路径
|
||||
lib_list=$(ldconfig -p | grep -Ei "nvidia|libcuda" | cut -d'>' -f2)
|
||||
|
||||
# 4\. 复制库文件
|
||||
copied=0
|
||||
for lib in $lib_list; do
|
||||
resolved=$(readlink -f "$lib") # 解析符号链接
|
||||
if file "$resolved" | grep -q "32-bit"; then
|
||||
ln -sf "/host/$resolved" "$ACE_DIR/usr/lib32/$(basename $lib)"
|
||||
else
|
||||
ln -sf "/host/$resolved" "$ACE_DIR/usr/lib/$(basename $lib)"
|
||||
copied=1
|
||||
fi
|
||||
done
|
||||
|
||||
# 5\. 复制辅助文件
|
||||
additional_files=(
|
||||
/usr/share/vulkan/icd.d/nvidia_icd.json
|
||||
/usr/share/egl/egl_external_platform.d/20_nvidia_xcb.json
|
||||
)
|
||||
for file in "${additional_files[@]}"; do
|
||||
if [ -f "$file" ]; then
|
||||
file=$(readlink -f "$file")
|
||||
dir=$(dirname "$file")
|
||||
mkdir -p "$ACE_DIR/$dir"
|
||||
ln -sf "/host/$file" "$ACE_DIR/$dir"
|
||||
fi
|
||||
done
|
||||
|
||||
# 6\. 标记版本
|
||||
if [ $copied -eq 1 ]; then
|
||||
echo "$nvidia_version" > "$ACE_DIR/current_version"
|
||||
log.info "NVIDIA 驱动库已成功链接 Nvidia Driver Libs are successfully linked. "
|
||||
else
|
||||
log.info "未找到有效 NVIDIA 库文件 No valid NVIDIA Driver Libs found."
|
||||
fi
|
||||
Executable
+60
@@ -0,0 +1,60 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
if [ `which debootstrap` = "" ];then
|
||||
echo "Need to install debootstrap!"
|
||||
exit
|
||||
fi
|
||||
|
||||
if [ `which systemd-nspawn` = "" ];then
|
||||
echo "Need to install systemd-container!"
|
||||
exit
|
||||
fi
|
||||
if [ "$2" = "" ];then
|
||||
echo "Usage: $0 ARCHITECTURE CODENAME"
|
||||
exit
|
||||
fi
|
||||
|
||||
sudo cp /usr/share/debootstrap/scripts/sid /usr/share/debootstrap/scripts/crimson -v
|
||||
sudo cp /usr/share/debootstrap/scripts/sid /usr/share/debootstrap/scripts/beige -v
|
||||
|
||||
CODENAME=$2
|
||||
|
||||
# Set distroname and components based on codename
|
||||
if [ "$CODENAME" = "beige" ] || [ "$CODENAME" = "crimson" ]; then
|
||||
DISTRONAME="deepin/beige"
|
||||
COMPONENTS="main,community,commercial"
|
||||
GPG_CHECK="--no-check-gpg"
|
||||
else
|
||||
DISTRONAME="debian"
|
||||
COMPONENTS="main,contrib,non-free,non-free-firmware"
|
||||
GPG_CHECK=""
|
||||
fi
|
||||
|
||||
if [ "$1" = "amd64" ] || [ "$1" = "x86_64" ];then
|
||||
ARCH="amd64"
|
||||
ARCH_ANOTHERWAY="x64"
|
||||
cd "`dirname $0`"
|
||||
sudo debootstrap $GPG_CHECK --components=$COMPONENTS --include=libnotify-bin,apt-utils,bash-completion,bc,curl,dialog,diffutils,findutils,less,libnss-myhostname,libvte-common,lsof,ncurses-base,passwd,pinentry-curses,procps,sudo,time,util-linux,wget,libegl1,libvulkan1,mesa-vulkan-drivers,locales,libglib2.0-bin --arch=${ARCH} $2 ./ace-env https://mirrors.cernet.edu.cn/${DISTRONAME}/
|
||||
|
||||
elif [ "$1" = "arm64" ] || [ "$1" = "arm" ]|| [ "$1" = "aarch64" ];then
|
||||
ARCH="arm64"
|
||||
ARCH_ANOTHERWAY="arm64"
|
||||
cd "`dirname $0`"
|
||||
sudo debootstrap $GPG_CHECK --components=$COMPONENTS --include=libnotify-bin,apt-utils,bash-completion,bc,curl,dialog,diffutils,findutils,less,libnss-myhostname,libvte-common,lsof,ncurses-base,passwd,pinentry-curses,procps,sudo,time,util-linux,wget,libegl1,libvulkan1,mesa-vulkan-drivers,locales,libglib2.0-bin --arch=${ARCH} $2 ./ace-env https://mirrors.cernet.edu.cn/${DISTRONAME}/
|
||||
|
||||
elif [ "$1" = "loong64" ] || [ "$1" = "loongarch64" ];then
|
||||
if [ "$CODENAME" = "beige" ] || [ "$CODENAME" = "crimson" ]; then
|
||||
ARCH="loong64"
|
||||
ARCH_ANOTHERWAY="loongarch64"
|
||||
cd "`dirname $0`"
|
||||
sudo debootstrap $GPG_CHECK --components=$COMPONENTS --include=libnotify-bin,apt-utils,bash-completion,bc,curl,dialog,diffutils,findutils,less,libnss-myhostname,libvte-common,lsof,ncurses-base,passwd,pinentry-curses,procps,sudo,time,util-linux,wget,libegl1,libvulkan1,mesa-vulkan-drivers,locales,libglib2.0-bin --arch=${ARCH} $2 ./ace-env https://mirrors.cernet.edu.cn/${DISTRONAME}/
|
||||
else
|
||||
echo "LoongArch64 is only supported on Deepin (beige/crimson)"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
sudo rm -rf ace-env/var/cache/apt/archives/*.deb
|
||||
sudo rm -vfr ace-env/dev/*
|
||||
sudo tar -I 'xz -T0' -cvf ace-env.tar.xz ace-env/*
|
||||
sudo rm -rf ace-env
|
||||
@@ -0,0 +1,45 @@
|
||||
# Tips
|
||||
|
||||
1. apm run 会优先尝试独立环境内启动,失败后会在主机环境尝试启动
|
||||
|
||||
2. apm 添加了一个钩子(debian only),在安装到 /var/lib/apm 下的应用存在ace-env时,进行configure nvidia操作;若存在entries,则进行链接到/usr/share/applications操作
|
||||
|
||||
3. apm 内置 ubuntu rootfs的修改如下
|
||||
|
||||
|
||||
* 安装xz-utils
|
||||
* 安装 bash-completion
|
||||
* 安装 ca-certificates
|
||||
* 使用支持apm源的aptss,使用独立的sources.list.d,删除原有的源
|
||||
* 安装一个空的apm包,用于填充依赖,附带 amber-pm-dstore-patch
|
||||
* 删除/var/lib/dpkg的 status status-old available cmethopt diversions diversions-old
|
||||
|
||||
|
||||
4. 打包 apm 包时需要注意的
|
||||
|
||||
* 对应的desktop的 Exec 和 Tryexec 均需要加入 `apm run 包名` 前缀(未完成自动化)
|
||||
* 完成释放后应删除tar.xz(未完成)
|
||||
|
||||
5. apm todo(未完成)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
* 重要:如何在APM内更新内容——如何覆盖?
|
||||
* deb全自动转apm
|
||||
* apm版融合商店
|
||||
* 类似 Wine 运行器的方式全图形化傻瓜式打包
|
||||
* 自动融合 APM 应用到系统主机,并实现右键卸载
|
||||
|
||||
|
||||
---
|
||||
|
||||
已完成
|
||||
|
||||
* apm 自动刷新 apm 仓库
|
||||
* 完善 amber-pm-common 以快速创建rootfs(生成所有 locales )
|
||||
* 添加 gxde fixer 确保在GXDE下可以正常展示应用(即进行一次host integration类操作)
|
||||
* 完成amd64软件源配置
|
||||
* 修改aptss以兼容APM源加速
|
||||
* apm环境变量添加 IS_APM_ENV=1 GTK_USE_PORTAL=1
|
||||
Reference in New Issue
Block a user