release blend 2.0.0
This commit is contained in:
parent
4e4bdd33d2
commit
37d4a6155e
36 changed files with 2557 additions and 458 deletions
7
.gitignore
vendored
7
.gitignore
vendored
|
@ -1,5 +1,2 @@
|
|||
/debian/*.debhelper
|
||||
/debian/*.substvars
|
||||
/debian/debhelper-build-stamp
|
||||
/debian/blend
|
||||
/debian/files
|
||||
/blend-settings/node_modules
|
||||
/blend-settings/package-lock.json
|
||||
|
|
675
LICENSE.md
Normal file
675
LICENSE.md
Normal file
|
@ -0,0 +1,675 @@
|
|||
# GNU GENERAL PUBLIC LICENSE
|
||||
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc.
|
||||
<https://fsf.org/>
|
||||
|
||||
Everyone is permitted to copy and distribute verbatim copies of this
|
||||
license document, but changing it is not allowed.
|
||||
|
||||
## Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom
|
||||
to share and change all versions of a program--to make sure it remains
|
||||
free software for all its users. We, the Free Software Foundation, use
|
||||
the GNU General Public License for most of our software; it applies
|
||||
also to any other work released this way by its authors. You can apply
|
||||
it to your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you
|
||||
have certain responsibilities if you distribute copies of the
|
||||
software, or if you modify it: responsibilities to respect the freedom
|
||||
of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the
|
||||
manufacturer can do so. This is fundamentally incompatible with the
|
||||
aim of protecting users' freedom to change the software. The
|
||||
systematic pattern of such abuse occurs in the area of products for
|
||||
individuals to use, which is precisely where it is most unacceptable.
|
||||
Therefore, we have designed this version of the GPL to prohibit the
|
||||
practice for those products. If such problems arise substantially in
|
||||
other domains, we stand ready to extend this provision to those
|
||||
domains in future versions of the GPL, as needed to protect the
|
||||
freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish
|
||||
to avoid the special danger that patents applied to a free program
|
||||
could make it effectively proprietary. To prevent this, the GPL
|
||||
assures that patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
### TERMS AND CONDITIONS
|
||||
|
||||
#### 0. Definitions
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds
|
||||
of works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of
|
||||
an exact copy. The resulting work is called a "modified version" of
|
||||
the earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user
|
||||
through a computer network, with no transfer of a copy, is not
|
||||
conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices" to
|
||||
the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
#### 1. Source Code
|
||||
|
||||
The "source code" for a work means the preferred form of the work for
|
||||
making modifications to it. "Object code" means any non-source form of
|
||||
a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users can
|
||||
regenerate automatically from other parts of the Corresponding Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that same
|
||||
work.
|
||||
|
||||
#### 2. Basic Permissions
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not convey,
|
||||
without conditions so long as your license otherwise remains in force.
|
||||
You may convey covered works to others for the sole purpose of having
|
||||
them make modifications exclusively for you, or provide you with
|
||||
facilities for running those works, provided that you comply with the
|
||||
terms of this License in conveying all material for which you do not
|
||||
control copyright. Those thus making or running the covered works for
|
||||
you must do so exclusively on your behalf, under your direction and
|
||||
control, on terms that prohibit them from making any copies of your
|
||||
copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under the
|
||||
conditions stated below. Sublicensing is not allowed; section 10 makes
|
||||
it unnecessary.
|
||||
|
||||
#### 3. Protecting Users' Legal Rights From Anti-Circumvention Law
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such
|
||||
circumvention is effected by exercising rights under this License with
|
||||
respect to the covered work, and you disclaim any intention to limit
|
||||
operation or modification of the work as a means of enforcing, against
|
||||
the work's users, your or third parties' legal rights to forbid
|
||||
circumvention of technological measures.
|
||||
|
||||
#### 4. Conveying Verbatim Copies
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
#### 5. Conveying Modified Source Versions
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these
|
||||
conditions:
|
||||
|
||||
- a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
- b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under
|
||||
section 7. This requirement modifies the requirement in section 4
|
||||
to "keep intact all notices".
|
||||
- c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
- d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
#### 6. Conveying Non-Source Forms
|
||||
|
||||
You may convey a covered work in object code form under the terms of
|
||||
sections 4 and 5, provided that you also convey the machine-readable
|
||||
Corresponding Source under the terms of this License, in one of these
|
||||
ways:
|
||||
|
||||
- a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
- b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the Corresponding
|
||||
Source from a network server at no charge.
|
||||
- c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
- d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
- e) Convey the object code using peer-to-peer transmission,
|
||||
provided you inform other peers where the object code and
|
||||
Corresponding Source of the work are being offered to the general
|
||||
public at no charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal,
|
||||
family, or household purposes, or (2) anything designed or sold for
|
||||
incorporation into a dwelling. In determining whether a product is a
|
||||
consumer product, doubtful cases shall be resolved in favor of
|
||||
coverage. For a particular product received by a particular user,
|
||||
"normally used" refers to a typical or common use of that class of
|
||||
product, regardless of the status of the particular user or of the way
|
||||
in which the particular user actually uses, or expects or is expected
|
||||
to use, the product. A product is a consumer product regardless of
|
||||
whether the product has substantial commercial, industrial or
|
||||
non-consumer uses, unless such uses represent the only significant
|
||||
mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to
|
||||
install and execute modified versions of a covered work in that User
|
||||
Product from a modified version of its Corresponding Source. The
|
||||
information must suffice to ensure that the continued functioning of
|
||||
the modified object code is in no case prevented or interfered with
|
||||
solely because modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or
|
||||
updates for a work that has been modified or installed by the
|
||||
recipient, or for the User Product in which it has been modified or
|
||||
installed. Access to a network may be denied when the modification
|
||||
itself materially and adversely affects the operation of the network
|
||||
or violates the rules and protocols for communication across the
|
||||
network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
#### 7. Additional Terms
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders
|
||||
of that material) supplement the terms of this License with terms:
|
||||
|
||||
- a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
- b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
- c) Prohibiting misrepresentation of the origin of that material,
|
||||
or requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
- d) Limiting the use for publicity purposes of names of licensors
|
||||
or authors of the material; or
|
||||
- e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
- f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions
|
||||
of it) with contractual assumptions of liability to the recipient,
|
||||
for any liability that these contractual assumptions directly
|
||||
impose on those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions; the
|
||||
above requirements apply either way.
|
||||
|
||||
#### 8. Termination
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your license
|
||||
from a particular copyright holder is reinstated (a) provisionally,
|
||||
unless and until the copyright holder explicitly and finally
|
||||
terminates your license, and (b) permanently, if the copyright holder
|
||||
fails to notify you of the violation by some reasonable means prior to
|
||||
60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
#### 9. Acceptance Not Required for Having Copies
|
||||
|
||||
You are not required to accept this License in order to receive or run
|
||||
a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
#### 10. Automatic Licensing of Downstream Recipients
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
#### 11. Patents
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims owned
|
||||
or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within the
|
||||
scope of its coverage, prohibits the exercise of, or is conditioned on
|
||||
the non-exercise of one or more of the rights that are specifically
|
||||
granted under this License. You may not convey a covered work if you
|
||||
are a party to an arrangement with a third party that is in the
|
||||
business of distributing software, under which you make payment to the
|
||||
third party based on the extent of your activity of conveying the
|
||||
work, and under which the third party grants, to any of the parties
|
||||
who would receive the covered work from you, a discriminatory patent
|
||||
license (a) in connection with copies of the covered work conveyed by
|
||||
you (or copies made from those copies), or (b) primarily for and in
|
||||
connection with specific products or compilations that contain the
|
||||
covered work, unless you entered into that arrangement, or that patent
|
||||
license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
#### 12. No Surrender of Others' Freedom
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under
|
||||
this License and any other pertinent obligations, then as a
|
||||
consequence you may not convey it at all. For example, if you agree to
|
||||
terms that obligate you to collect a royalty for further conveying
|
||||
from those to whom you convey the Program, the only way you could
|
||||
satisfy both those terms and this License would be to refrain entirely
|
||||
from conveying the Program.
|
||||
|
||||
#### 13. Use with the GNU Affero General Public License
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
#### 14. Revised Versions of this License
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions
|
||||
of the GNU General Public License from time to time. Such new versions
|
||||
will be similar in spirit to the present version, but may differ in
|
||||
detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies that a certain numbered version of the GNU General Public
|
||||
License "or any later version" applies to it, you have the option of
|
||||
following the terms and conditions either of that numbered version or
|
||||
of any later version published by the Free Software Foundation. If the
|
||||
Program does not specify a version number of the GNU General Public
|
||||
License, you may choose any version ever published by the Free
|
||||
Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future versions
|
||||
of the GNU General Public License can be used, that proxy's public
|
||||
statement of acceptance of a version permanently authorizes you to
|
||||
choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
#### 15. Disclaimer of Warranty
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT
|
||||
WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND
|
||||
PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE
|
||||
DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR
|
||||
CORRECTION.
|
||||
|
||||
#### 16. Limitation of Liability
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR
|
||||
CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES
|
||||
ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT
|
||||
NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR
|
||||
LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM
|
||||
TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER
|
||||
PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
#### 17. Interpretation of Sections 15 and 16
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
### How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these
|
||||
terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest to
|
||||
attach them to the start of each source file to most effectively state
|
||||
the exclusion of warranty; and each file should have at least the
|
||||
"copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper
|
||||
mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands \`show w' and \`show c' should show the
|
||||
appropriate parts of the General Public License. Of course, your
|
||||
program's commands might be different; for a GUI interface, you would
|
||||
use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. For more information on this, and how to apply and follow
|
||||
the GNU GPL, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your
|
||||
program into proprietary programs. If your program is a subroutine
|
||||
library, you may consider it more useful to permit linking proprietary
|
||||
applications with the library. If this is what you want to do, use the
|
||||
GNU Lesser General Public License instead of this License. But first,
|
||||
please read <https://www.gnu.org/licenses/why-not-lgpl.html>.
|
65
README.md
65
README.md
|
@ -1,67 +1,16 @@
|
|||
<div align="center">
|
||||
<h1 align="center">blend</h1>
|
||||
<p align="center">A package manager for blendOS</p>
|
||||
<p align="center">A tool to manage overlays, containers and multiple distributions</p>
|
||||
</div>
|
||||
|
||||
### Help
|
||||
```
|
||||
Usage:
|
||||
blend [command] [options] [arguments]
|
||||
This repository also contains **blend-settings**, a tool for configuring blend and overlays, as well as many other utilities.
|
||||
|
||||
Version: 1.0.4
|
||||
## Credits
|
||||
|
||||
blend is a package manager for blendOS, which includes support for Arch, Ubuntu and Fedora packages.
|
||||
The `init-blend` file in this repository uses a few lines (two sections) uses from distrobox's init script. These lines have been marked and attributed appropriately, and are licensed under [the GPL-3.0 license](https://github.com/89luca89/distrobox/blob/main/COPYING.md).
|
||||
|
||||
default distro: arch (default container's name is the same as that of the default distro)
|
||||
Aside from these lines, all the other code in this repository has been written by me (rs2009). `blend-settings` is based on [Modren](https://github.com/RudraSwat/modren), a software store I (rs2009) had written long ago, and is licensed under the same license as the rest of the code in this repository, [the GPL-3.0 license](https://github.com/blend-os/blend/blob/main/LICENSE).
|
||||
|
||||
Here's a list of the supported distros:
|
||||
1. arch
|
||||
2. fedora-rawhide
|
||||
3. ubuntu-22.04
|
||||
4. ubuntu-22.10
|
||||
(debian support is coming soon)
|
||||
## Usage
|
||||
|
||||
You can use any of these distros by passing the option --distro=[NAME OF THE DISTRO].
|
||||
|
||||
You can even install a supported desktop environment in a blend container (run `blend install-de [DESKTOP ENVIRONMENT NAME]` to install your favorite desktop environment).
|
||||
|
||||
However, this feature is still somewhat experimental, and some apps might be buggy.
|
||||
|
||||
Here's a list of the supported desktop environments:
|
||||
1. gnome
|
||||
2. mate
|
||||
(support for many more DEs is coming soon)
|
||||
|
||||
arch also supports AUR packages, for an extremely large app catalog.
|
||||
|
||||
available commands:
|
||||
help Show this help message and exit.
|
||||
version Show version information and exit.
|
||||
enter Enter the container shell.
|
||||
export Export the desktop entry for an installed blend.
|
||||
unexport Unexport the desktop entry for a blend.
|
||||
install Install packages inside a container.
|
||||
install-de Install a desktop environment inside a container. (EXPERIMENTAL)
|
||||
remove Remove packages inside a managed container.
|
||||
create-container Create a container managed by blend.
|
||||
remove-container Remove a container managed by blend.
|
||||
list-containers List all the containers managed by blend.
|
||||
start-containers Start all the container managed by blend.
|
||||
sync Sync list of available packages from repository.
|
||||
search Search for packages in a managed container.
|
||||
show Show details about a package.
|
||||
update Update all the packages in a managed container.
|
||||
|
||||
options for commands:
|
||||
-cn CONTAINER NAME, --container-name CONTAINER NAME
|
||||
set the container name (the default is the name of the distro)
|
||||
-d DISTRO, --distro DISTRO
|
||||
set the distro name (supported: arch fedora-rawhide ubuntu-22.04 ubuntu-22.10; default is arch)
|
||||
-y, --noconfirm assume yes for all questions
|
||||
-v, --version show version information and exit
|
||||
|
||||
options:
|
||||
-h, --help show this help message and exit
|
||||
|
||||
Made with ❤ by Rudra Saraswat.
|
||||
```
|
||||
It's recommended to use the `blend-settings` UI, instead of the `blend` CLI.
|
466
blend
466
blend
|
@ -1,11 +1,30 @@
|
|||
#!/usr/bin/env python3
|
||||
# Copyright (C) 2023 Rudra Saraswat
|
||||
#
|
||||
# This file is part of blend.
|
||||
#
|
||||
# blend is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# blend is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with blend. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import os, sys
|
||||
|
||||
import os, sys, getpass, time
|
||||
import shutil
|
||||
import socket
|
||||
import pexpect
|
||||
import argparse
|
||||
import subprocess
|
||||
|
||||
__version = '1.0.4'
|
||||
__version = '2.0.0'
|
||||
|
||||
### Colors
|
||||
class colors:
|
||||
|
@ -58,9 +77,9 @@ def error(err):
|
|||
|
||||
distro_map = {
|
||||
'arch': 'docker.io/library/archlinux',
|
||||
'fedora-rawhide': 'fedora:rawhide',
|
||||
'ubuntu-22.04': 'ubuntu:22.04',
|
||||
'ubuntu-22.10': 'ubuntu:22.10'
|
||||
'fedora-rawhide': 'docker.io/library/fedora:rawhide',
|
||||
'ubuntu-22.04': 'docker.io/library/ubuntu:22.04',
|
||||
'ubuntu-22.10': 'docker.io/library/ubuntu:22.10'
|
||||
}
|
||||
|
||||
default_distro = 'arch'
|
||||
|
@ -72,267 +91,191 @@ def get_distro():
|
|||
error(f"{args.distro} isn't supported by blend.")
|
||||
exit()
|
||||
|
||||
def distrobox_list_containers():
|
||||
def list_containers():
|
||||
_list = subprocess.run(['podman', 'ps', '-a', '--no-trunc', '--size', '--format',
|
||||
'{{.Names}}:{{.Mounts}}'], stdout=subprocess.PIPE).stdout.decode('utf-8').strip()
|
||||
if len(_list) == 0:
|
||||
info('No containers. Create one by installing a package (`blend install hello`), or manually create one (`blend create-container arch`).')
|
||||
else:
|
||||
info('List of containers:')
|
||||
for container in _list.splitlines(keepends=False):
|
||||
if 'distrobox' in container.split(':')[1]:
|
||||
print(container.split(':')[0])
|
||||
for i, container in enumerate(_list.splitlines(keepends=False)):
|
||||
if 'blend' in container.split(':')[1]:
|
||||
print(f"{colors.bold}{i}.{colors.reset} {container.split(':')[0]}")
|
||||
return False
|
||||
|
||||
def distrobox_check_container(name):
|
||||
def check_container(name):
|
||||
_list = subprocess.run(['podman', 'ps', '-a', '--no-trunc', '--size', '--format',
|
||||
'{{.Names}}:{{.Mounts}}'], stdout=subprocess.PIPE).stdout.decode('utf-8').strip()
|
||||
for container in _list.splitlines(keepends=False):
|
||||
if 'distrobox' in container.split(':')[1] and name.strip() == container.split(':')[0]:
|
||||
if 'blend' in container.split(':')[1] and name.strip() == container.split(':')[0]:
|
||||
return True
|
||||
return False
|
||||
|
||||
def distrobox_create_container():
|
||||
def check_container_status(name):
|
||||
return host_get_output("podman inspect --type container " + name + " --format \"{{.State.Status}}\"")
|
||||
|
||||
def core_start_container(name):
|
||||
subprocess.call(['podman', 'start', name], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
||||
|
||||
start_time = time.time() - 1000 # workaround
|
||||
if check_container_status(name) != 'running':
|
||||
print('')
|
||||
error('the entry point failed to run; try again later')
|
||||
info("here are the container's logs:")
|
||||
subprocess.call(['podman', 'logs', '--since', str(start_time), name])
|
||||
exit(1)
|
||||
|
||||
logproc = pexpect.spawn('podman', args=['logs', '-f', '--since', str(start_time), name], timeout=300)
|
||||
logproc.logfile_read = sys.stdout.buffer
|
||||
|
||||
logproc.expect('Completed container setup')
|
||||
logproc.terminate()
|
||||
|
||||
def core_create_container():
|
||||
name = args.container_name
|
||||
distro = args.distro
|
||||
info(f'creating container {name}, using {distro}')
|
||||
if subprocess.run(['distrobox-create', '-Y', '-n', name, '-i', get_distro()], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL).returncode != 0:
|
||||
if distrobox_check_container(name):
|
||||
|
||||
podman_command = []
|
||||
|
||||
# Basic stuff
|
||||
podman_command.extend(['podman', 'create', '--name', name])
|
||||
podman_command.extend(['--hostname', name + '.' + socket.gethostname()])
|
||||
podman_command.extend(['--privileged', '--ipc', 'host'])
|
||||
podman_command.extend(['--network', 'host'])
|
||||
podman_command.extend(['--security-opt', 'label=disable'])
|
||||
podman_command.extend(['--user', 'root:root', '--pid', 'host'])
|
||||
podman_command.extend(['--label', 'manager=blend']) # identify as blend container
|
||||
|
||||
# Env variables
|
||||
podman_command.extend(['--env', 'HOME=' + os.path.expanduser('~')])
|
||||
|
||||
# Volumes
|
||||
podman_command.extend(['--volume', '/:/run/host:rslave'])
|
||||
podman_command.extend(['--volume', '/tmp:/tmp:rslave'])
|
||||
podman_command.extend(['--volume', f"{os.path.expanduser('~')}:{os.path.expanduser('~')}:rslave"])
|
||||
podman_command.extend(['--volume', f"/run/user/{os.geteuid()}:/run/user/{os.geteuid()}:rslave"])
|
||||
|
||||
# Volumes (config files)
|
||||
podman_command.extend(['--volume', f"/etc/hosts:/etc/hosts:ro"])
|
||||
podman_command.extend(['--volume', f"/etc/localtime:/etc/localtime:ro"])
|
||||
podman_command.extend(['--volume', f"/etc/resolv.conf:/etc/resolv.conf:ro"])
|
||||
|
||||
# Volumes (files and tools)
|
||||
podman_command.extend(['--volume', '/usr/bin/init-blend:/usr/bin/init-blend:ro',
|
||||
'--entrypoint', '/usr/bin/init-blend']) # our entrypoint
|
||||
podman_command.extend(['--volume', '/usr/bin/host-blend:/usr/bin/host-blend:ro']) # and the tool to run commands on the host
|
||||
podman_command.extend(['--volume', '/var/log/journal'])
|
||||
|
||||
podman_command.extend(['--mount', 'type=devpts,destination=/dev/pts',
|
||||
'--userns', 'keep-id',
|
||||
'--annotation', 'run.oci.keep_original_groups=1'])
|
||||
|
||||
podman_command.extend([get_distro()])
|
||||
|
||||
# User (for init-blend)
|
||||
podman_command.extend(['--uid', str(os.geteuid())])
|
||||
podman_command.extend(['--group', str(os.getgid())])
|
||||
podman_command.extend(['--username', getpass.getuser()])
|
||||
podman_command.extend(['--home', os.path.expanduser('~')])
|
||||
|
||||
ret = subprocess.run(podman_command).returncode
|
||||
if ret != 0:
|
||||
if check_container(name):
|
||||
error(f'container {name} already exists')
|
||||
exit(1)
|
||||
error(f'failed to create container {name}')
|
||||
exit(1)
|
||||
subprocess.call(['distrobox-enter', '-nw', '-n', args.container_name, '--', 'echo -n'])
|
||||
|
||||
core_start_container(name)
|
||||
|
||||
if distro == 'arch':
|
||||
distrobox_run_container('sudo pacman -Sy')
|
||||
distrobox_run_container('sudo pacman --noconfirm -S --needed git base-devel')
|
||||
distrobox_run_container('cd ~; git clone https://aur.archlinux.org/yay.git')
|
||||
distrobox_run_container('cd ~/yay; makepkg --noconfirm -si')
|
||||
core_run_container('sudo pacman -Sy')
|
||||
core_run_container('sudo pacman --noconfirm -Syu --needed git base-devel')
|
||||
core_run_container('TEMP_DIR="$(mktemp -d)"; cd "${TEMP_DIR}"; git clone https://aur.archlinux.org/yay.git; cd yay; makepkg --noconfirm -si; rm -rf "${TEMP_DIR}"')
|
||||
|
||||
distrobox_get_output = lambda cmd: subprocess.run(['distrobox-enter', '-nw', '-n', args.container_name, '--', 'sh', '-c', cmd],
|
||||
stdout=subprocess.PIPE, stderr=subprocess.DEVNULL).stdout.decode('UTF-8').strip()
|
||||
core_get_output = lambda cmd: subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL).stdout.decode('UTF-8').strip()
|
||||
|
||||
def distrobox_run_container(cmd):
|
||||
subprocess.call(['podman', 'exec', '-u', os.environ['USER'], '-it', args.container_name, 'sh', '-c', cmd])
|
||||
host_get_output = lambda cmd: subprocess.run(['bash', '-c', cmd],
|
||||
stdout=subprocess.PIPE, stderr=subprocess.DEVNULL).stdout.decode('UTF-8').strip()
|
||||
|
||||
def distrobox_install_pkg(pkg):
|
||||
core_get_retcode = lambda cmd: subprocess.run(['podman', 'exec', '--user', getpass.getuser(), '-it', args.container_name, 'bash', '-c', cmd],
|
||||
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL).returncode
|
||||
|
||||
def core_run_container(cmd):
|
||||
if os.getcwd() == os.path.expanduser('~') or os.getcwd().startswith(os.path.expanduser('~') + '/'):
|
||||
subprocess.call(['podman', 'exec', '--user', getpass.getuser(), '-w', os.getcwd(), '-it', args.container_name, 'bash', '-c', cmd])
|
||||
|
||||
def core_install_pkg(pkg):
|
||||
if args.distro == 'fedora-rawhide':
|
||||
if args.noconfirm == True:
|
||||
distrobox_run_container(f'sudo dnf -y install {pkg}')
|
||||
core_run_container(f'sudo dnf -y install {pkg}')
|
||||
else:
|
||||
distrobox_run_container(f'sudo dnf install {pkg}')
|
||||
core_run_container(f'sudo dnf install {pkg}')
|
||||
elif args.distro == 'arch':
|
||||
if distrobox_get_output('yay --version') == '':
|
||||
distrobox_run_container('sudo pacman -Sy')
|
||||
distrobox_run_container('sudo pacman --noconfirm -S --needed git base-devel')
|
||||
distrobox_run_container('git clone https://aur.archlinux.org/yay.git')
|
||||
distrobox_run_container('cd yay; makepkg --noconfirm -si')
|
||||
distrobox_run_container(f'yay -Sy')
|
||||
if core_get_retcode('[ -f /usr/bin/yay ]') != 0:
|
||||
core_run_container('sudo pacman -Sy')
|
||||
core_run_container('sudo pacman --noconfirm -Syu --needed git base-devel')
|
||||
core_run_container('TEMP_DIR="$(mktemp -d)"; cd "${TEMP_DIR}"; git clone https://aur.archlinux.org/yay.git; cd yay; makepkg --noconfirm -si; rm -rf "${TEMP_DIR}"')
|
||||
core_run_container(f'yay -Sy')
|
||||
if args.noconfirm == True:
|
||||
distrobox_run_container(f'yay --noconfirm -S {pkg}')
|
||||
core_run_container(f'yay --noconfirm -Syu {pkg}')
|
||||
else:
|
||||
distrobox_run_container(f'yay -S {pkg}')
|
||||
core_run_container(f'yay -Syu {pkg}')
|
||||
elif args.distro.startswith('ubuntu-'):
|
||||
distrobox_run_container(f'sudo apt-get update')
|
||||
core_run_container(f'sudo apt-get update')
|
||||
if args.noconfirm == True:
|
||||
distrobox_run_container(f'sudo apt-get install -y {pkg}')
|
||||
core_run_container(f'sudo apt-get install -y {pkg}')
|
||||
else:
|
||||
distrobox_run_container(f'sudo apt-get install {pkg}')
|
||||
core_run_container(f'sudo apt-get install {pkg}')
|
||||
|
||||
def distrobox_remove_pkg(pkg):
|
||||
def core_remove_pkg(pkg):
|
||||
if args.distro == 'fedora-rawhide':
|
||||
if args.noconfirm == True:
|
||||
distrobox_run_container(f'sudo dnf -y remove {pkg}')
|
||||
core_run_container(f'sudo dnf -y remove {pkg}')
|
||||
else:
|
||||
distrobox_run_container(f'sudo dnf remove {pkg}')
|
||||
core_run_container(f'sudo dnf remove {pkg}')
|
||||
elif args.distro == 'arch':
|
||||
if args.noconfirm == True:
|
||||
distrobox_run_container(f'sudo pacman --noconfirm -Rcns {pkg}')
|
||||
core_run_container(f'sudo pacman --noconfirm -Rcns {pkg}')
|
||||
else:
|
||||
distrobox_run_container(f'sudo pacman -Rcns {pkg}')
|
||||
core_run_container(f'sudo pacman -Rcns {pkg}')
|
||||
elif args.distro.startswith('ubuntu-'):
|
||||
if args.noconfirm == True:
|
||||
distrobox_run_container(f'sudo apt-get purge -y {pkg}')
|
||||
core_run_container(f'sudo apt-get purge -y {pkg}')
|
||||
else:
|
||||
distrobox_run_container(f'sudo apt-get purge {pkg}')
|
||||
distrobox_run_container(f'sudo apt-get autoremove --purge -y {pkg}')
|
||||
core_run_container(f'sudo apt-get purge {pkg}')
|
||||
core_run_container(f'sudo apt-get autoremove --purge -y {pkg}')
|
||||
|
||||
def distrobox_search_pkg(pkg):
|
||||
def core_search_pkg(pkg):
|
||||
if args.distro == 'fedora-rawhide':
|
||||
distrobox_run_container(f'dnf search {pkg}')
|
||||
core_run_container(f'dnf search {pkg}')
|
||||
elif args.distro == 'arch':
|
||||
distrobox_run_container(f'yay -Sy')
|
||||
distrobox_run_container(f'yay {pkg}')
|
||||
core_run_container(f'yay -Sy')
|
||||
core_run_container(f'yay {pkg}')
|
||||
elif args.distro.startswith('ubuntu-'):
|
||||
distrobox_run_container(f'sudo apt-get update')
|
||||
distrobox_run_container(f'apt-cache search {pkg}')
|
||||
core_run_container(f'sudo apt-get update')
|
||||
core_run_container(f'apt-cache search {pkg}')
|
||||
|
||||
def distrobox_show_pkg(pkg):
|
||||
def core_show_pkg(pkg):
|
||||
if args.distro == 'fedora-rawhide':
|
||||
distrobox_run_container(f'dnf info {pkg}')
|
||||
core_run_container(f'dnf info {pkg}')
|
||||
elif args.distro == 'arch':
|
||||
distrobox_run_container(f'yay -Sy')
|
||||
distrobox_run_container(f'yay -Si {pkg}')
|
||||
core_run_container(f'yay -Sy')
|
||||
core_run_container(f'yay -Si {pkg}')
|
||||
elif args.distro.startswith('ubuntu-'):
|
||||
distrobox_run_container(f'sudo apt-get update')
|
||||
distrobox_run_container(f'apt-cache show {pkg}')
|
||||
|
||||
def install_de():
|
||||
if len(args.pkg) == 0:
|
||||
error('you need to specify a desktop environment (gnome and mate are supported)')
|
||||
exit()
|
||||
name = args.pkg[0]
|
||||
if name == 'mate' or name == 'gnome':
|
||||
if distro_input == None and cn_input == None:
|
||||
info(f'using fedora-rawhide instead of {default_distro}, as it\'s recommended for {name}')
|
||||
info('if you want to use arch, you can specify `--distro arch`')
|
||||
args.distro = 'fedora-rawhide'
|
||||
args.container_name = 'fedora-rawhide'
|
||||
else:
|
||||
error(f'desktop environment {name} is not supported')
|
||||
info('gnome and mate are supported')
|
||||
exit()
|
||||
if not distrobox_check_container(args.container_name):
|
||||
distrobox_create_container()
|
||||
info(f'installing {name} on {args.container_name} (using {args.distro})')
|
||||
print()
|
||||
info('ignore any errors after this')
|
||||
try:
|
||||
subprocess.run('sudo nearly enter rw', shell=True)
|
||||
distrobox_run_container('sudo umount /run/systemd/system')
|
||||
distrobox_run_container('sudo rmdir /run/systemd/system')
|
||||
distrobox_run_container('sudo ln -s /run/host/run/systemd/system /run/systemd &> /dev/null')
|
||||
distrobox_run_container('sudo ln -s /run/host/run/dbus/system_bus_socket /run/dbus/ &> /dev/null')
|
||||
distrobox_run_container('sudo mkdir -p /usr/local/bin')
|
||||
distrobox_run_container('echo "#!/usr/bin/env bash" | sudo tee /usr/local/bin/disable_dbusactivatable_blend')
|
||||
distrobox_run_container('echo "if [[ \$DISABLE_REPEAT -ne 1 ]]; then" | sudo tee -a /usr/local/bin/disable_dbusactivatable_blend')
|
||||
distrobox_run_container('''echo 'while true; do for dir in ${XDG_DATA_DIRS//:/ }; do sudo find $dir/applications -type f -exec sed -i -e '"'s/DBusActivatable=.*//g'"' {} '"';'"'; done; sleep 5; done' | sudo tee -a /usr/local/bin/disable_dbusactivatable_blend''')
|
||||
distrobox_run_container('echo "else" | sudo tee -a /usr/local/bin/disable_dbusactivatable_blend')
|
||||
distrobox_run_container('''echo 'for dir in ${XDG_DATA_DIRS//:/ }; do sudo find $dir/applications -type f -exec sed -i -e '"'s/DBusActivatable=.*//g'"' {} '"';'"'; done' | sudo tee -a /usr/local/bin/disable_dbusactivatable_blend''')
|
||||
distrobox_run_container('echo "fi" | sudo tee -a /usr/local/bin/disable_dbusactivatable_blend')
|
||||
distrobox_run_container('sudo chmod 755 /usr/local/bin/disable_dbusactivatable_blend')
|
||||
distrobox_run_container('sudo mkdir -p /etc/xdg/autostart')
|
||||
distrobox_run_container('echo "[Desktop Entry]" | sudo tee /usr/share/applications/disable_dbusactivatable_blend.desktop')
|
||||
distrobox_run_container('echo "Version=1.0" | sudo tee -a /usr/share/applications/disable_dbusactivatable_blend.desktop')
|
||||
distrobox_run_container('echo "Name=Remove DBusActivatable (blend)" | sudo tee -a /usr/share/applications/disable_dbusactivatable_blend.desktop')
|
||||
distrobox_run_container('echo "Comment=Remove DBusActivatable in all desktop files" | sudo tee -a /usr/share/applications/disable_dbusactivatable_blend.desktop')
|
||||
distrobox_run_container('echo "Exec=disable_dbusactivatable_blend" | sudo tee -a /usr/share/applications/disable_dbusactivatable_blend.desktop')
|
||||
distrobox_run_container('echo "Type=Application" | sudo tee -a /usr/share/applications/disable_dbusactivatable_blend.desktop')
|
||||
distrobox_run_container('sudo chmod 755 /usr/share/applications/disable_dbusactivatable_blend.desktop')
|
||||
if name == 'mate':
|
||||
if args.distro == 'fedora-rawhide':
|
||||
if args.noconfirm == True:
|
||||
distrobox_run_container(f'sudo dnf --allowerasing -y groupinstall MATE')
|
||||
else:
|
||||
distrobox_run_container(f'sudo dnf --allowerasing groupinstall MATE')
|
||||
elif args.distro == 'arch':
|
||||
if args.noconfirm == True:
|
||||
distrobox_run_container(f'sudo pacman --noconfirm -S mate mate-extra')
|
||||
else:
|
||||
distrobox_run_container(f'sudo pacman -S mate mate-extra')
|
||||
elif args.distro.startswith('ubuntu-'):
|
||||
distrobox_run_container(f'sudo apt-get update')
|
||||
if args.noconfirm == True:
|
||||
distrobox_run_container(f'sudo apt-get install -y ubuntu-mate-desktop')
|
||||
else:
|
||||
distrobox_run_container(f'sudo apt-get install ubuntu-mate-desktop')
|
||||
subprocess.run('sudo mkdir -p /usr/local/bin', stdout=subprocess.DEVNULL, shell=True)
|
||||
subprocess.run(f'echo "#!/usr/bin/env sh" | sudo tee /usr/local/bin/{args.container_name}-mate-blend', stdout=subprocess.DEVNULL, shell=True)
|
||||
subprocess.run(f'echo "export GTK_MODULES=" | sudo tee -a /usr/local/bin/{args.container_name}-mate-blend', stdout=subprocess.DEVNULL, shell=True)
|
||||
subprocess.run(f'echo "export GTK3_MODULES=" | sudo tee -a /usr/local/bin/{args.container_name}-mate-blend', stdout=subprocess.DEVNULL, shell=True)
|
||||
subprocess.run(f'echo "export LD_PRELOAD=" | sudo tee -a /usr/local/bin/{args.container_name}-mate-blend', stdout=subprocess.DEVNULL, shell=True)
|
||||
subprocess.run(f'echo "chown -f -R $USER:$USER /tmp/.X11-unix" | sudo tee -a /usr/local/bin/{args.container_name}-mate-blend', stdout=subprocess.DEVNULL, shell=True)
|
||||
subprocess.run(f'echo "distrobox-enter {args.container_name} -- mate-session" | sudo tee -a /usr/local/bin/{args.container_name}-mate-blend', stdout=subprocess.DEVNULL, shell=True)
|
||||
subprocess.run(f'sudo chmod 755 /usr/local/bin/{args.container_name}-mate-blend', stdout=subprocess.DEVNULL, shell=True)
|
||||
subprocess.run(f'echo "[Desktop Entry]" | sudo tee /usr/share/xsessions/mate-blend-{args.container_name}.desktop', stdout=subprocess.DEVNULL, shell=True)
|
||||
subprocess.run(f'echo "Version=1.0" | sudo tee -a /usr/share/xsessions/mate-blend-{args.container_name}.desktop', stdout=subprocess.DEVNULL, shell=True)
|
||||
subprocess.run(f'echo "Name=MATE ({args.container_name})" | sudo tee -a /usr/share/xsessions/mate-blend-{args.container_name}.desktop', stdout=subprocess.DEVNULL, shell=True)
|
||||
subprocess.run(f'echo "Comment=Use this session to run MATE as your desktop environment" | sudo tee -a /usr/share/xsessions/mate-blend-{args.container_name}.desktop', stdout=subprocess.DEVNULL, shell=True)
|
||||
subprocess.run(f'echo "Exec={args.container_name}-mate-blend" | sudo tee -a /usr/share/xsessions/mate-blend-{args.container_name}.desktop', stdout=subprocess.DEVNULL, shell=True)
|
||||
subprocess.run(f'echo "Type=Application" | sudo tee -a /usr/share/xsessions/mate-blend-{args.container_name}.desktop', stdout=subprocess.DEVNULL, shell=True)
|
||||
subprocess.run(f'sudo chmod 755 /usr/share/xsessions/mate-blend-{args.container_name}.desktop', stdout=subprocess.DEVNULL, shell=True)
|
||||
elif name == 'gnome':
|
||||
if args.distro == 'fedora-rawhide':
|
||||
if args.noconfirm == True:
|
||||
distrobox_run_container(f'sudo dnf --allowerasing -y groupinstall GNOME')
|
||||
distrobox_run_container(f'sudo dnf --allowerasing -y remove gnome-terminal')
|
||||
distrobox_run_container(f'sudo dnf --allowerasing -y install gnome-console')
|
||||
else:
|
||||
distrobox_run_container(f'sudo dnf --allowerasing groupinstall GNOME')
|
||||
distrobox_run_container(f'sudo dnf --allowerasing -y remove gnome-terminal')
|
||||
distrobox_run_container(f'sudo dnf --allowerasing -y install gnome-console')
|
||||
elif args.distro == 'arch':
|
||||
if args.noconfirm == True:
|
||||
distrobox_run_container(f'sudo pacman --noconfirm -S gnome gnome-console')
|
||||
distrobox_run_container(f'sudo pacman --noconfirm -Rcns gnome-terminal')
|
||||
else:
|
||||
distrobox_run_container(f'sudo pacman -S gnome gnome-console')
|
||||
distrobox_run_container(f'sudo pacman --noconfirm -Rcns gnome-terminal')
|
||||
elif args.distro.startswith('ubuntu-'):
|
||||
distrobox_run_container(f'sudo apt-get update')
|
||||
if args.noconfirm == True:
|
||||
distrobox_run_container(f'sudo apt-get install -y ubuntu-desktop gnome-console')
|
||||
distrobox_run_container(f'sudo apt-get purge -y gnome-terminal')
|
||||
distrobox_run_container(f'sudo apt-get purge -y --auto-remove')
|
||||
else:
|
||||
distrobox_run_container(f'sudo apt-get install ubuntu-desktop gnome-console')
|
||||
distrobox_run_container(f'sudo apt-get purge -y gnome-terminal')
|
||||
distrobox_run_container(f'sudo apt-get purge -y --auto-remove')
|
||||
subprocess.run(f'echo "[Desktop Entry]" | sudo tee /usr/share/wayland-sessions/gnome-wayland-{args.container_name}.desktop', stdout=subprocess.DEVNULL, shell=True)
|
||||
subprocess.run(f'echo "Name=GNOME on Wayland ({args.container_name})" | sudo tee -a /usr/share/wayland-sessions/gnome-wayland-{args.container_name}.desktop', stdout=subprocess.DEVNULL, shell=True)
|
||||
subprocess.run(f'echo "Comment=This session logs you into GNOME" | sudo tee -a /usr/share/wayland-sessions/gnome-wayland-{args.container_name}.desktop', stdout=subprocess.DEVNULL, shell=True)
|
||||
subprocess.run(f'echo "Exec=distrobox-enter -n {args.container_name} -- gnome-session --builtin" | sudo tee -a /usr/share/wayland-sessions/gnome-wayland-{args.container_name}.desktop', stdout=subprocess.DEVNULL, shell=True)
|
||||
subprocess.run(f'echo "Type=Application" | sudo tee -a /usr/share/wayland-sessions/gnome-wayland-{args.container_name}.desktop', stdout=subprocess.DEVNULL, shell=True)
|
||||
subprocess.run(f'echo "DesktopNames=GNOME" | sudo tee -a /usr/share/wayland-sessions/gnome-wayland-{args.container_name}.desktop', stdout=subprocess.DEVNULL, shell=True)
|
||||
subprocess.run(f'echo "X-GDM-SessionRegisters=true" | sudo tee -a /usr/share/wayland-sessions/gnome-wayland-{args.container_name}.desktop', stdout=subprocess.DEVNULL, shell=True)
|
||||
subprocess.run(f'echo "[Desktop Entry]" | sudo tee /usr/share/xsessions/gnome-xorg-{args.container_name}.desktop', stdout=subprocess.DEVNULL, shell=True)
|
||||
subprocess.run(f'echo "Name=GNOME on Xorg ({args.container_name})" | sudo tee -a /usr/share/xsessions/gnome-xorg-{args.container_name}.desktop', stdout=subprocess.DEVNULL, shell=True)
|
||||
subprocess.run(f'echo "Comment=This session logs you into GNOME" | sudo tee -a /usr/share/xsessions/gnome-xorg-{args.container_name}.desktop', stdout=subprocess.DEVNULL, shell=True)
|
||||
subprocess.run(f'echo "Exec=distrobox-enter -n {args.container_name} -- gnome-session --builtin" | sudo tee -a /usr/share/xsessions/gnome-xorg-{args.container_name}.desktop', stdout=subprocess.DEVNULL, shell=True)
|
||||
subprocess.run(f'echo "Type=Application" | sudo tee -a /usr/share/xsessions/gnome-xorg-{args.container_name}.desktop', stdout=subprocess.DEVNULL, shell=True)
|
||||
subprocess.run(f'echo "DesktopNames=GNOME" | sudo tee -a /usr/share/xsessions/gnome-xorg-{args.container_name}.desktop', stdout=subprocess.DEVNULL, shell=True)
|
||||
subprocess.run(f'echo "X-GDM-SessionRegisters=true" | sudo tee -a /usr/share/xsessions/gnome-xorg-{args.container_name}.desktop', stdout=subprocess.DEVNULL, shell=True)
|
||||
subprocess.run(f'sudo chmod 755 /usr/share/wayland-sessions/gnome-wayland-{args.container_name}.desktop', stdout=subprocess.DEVNULL, shell=True)
|
||||
subprocess.run(f'sudo chmod 755 /usr/share/xsessions/gnome-xorg-{args.container_name}.desktop', stdout=subprocess.DEVNULL, shell=True)
|
||||
distrobox_run_container('sudo mkdir -p /usr/share/applications /usr/local/share/applications')
|
||||
distrobox_run_container('''echo 'for dir in /usr/share/applications /usr/local/share/applications; do sudo find $dir -type f -exec sed -i -e '"'s/DBusActivatable=.*//g'"' {} '"';'"'; done' | sudo bash''')
|
||||
subprocess.run('sudo nearly enter ro', shell=True)
|
||||
except:
|
||||
try:
|
||||
subprocess.call(['sudo', 'nearly', 'enter', 'ro'])
|
||||
except KeyboardInterrupt:
|
||||
error('looks like you interrupted blend. your system is currently in read-write mode')
|
||||
info('run `nearly enter ro\' to enable immutability again')
|
||||
exit(1)
|
||||
|
||||
def copy_desktop_files(pkg):
|
||||
distrobox_run_container(f'CONTAINER_ID={args.container_name} distrobox-export --app {pkg} &>/dev/null')
|
||||
|
||||
def del_desktop_files(pkg):
|
||||
subprocess.call(['distrobox-enter', '-n', args.container_name, '-e', f'sh -c "CONTAINER_ID={args.container_name} distrobox-export --app {pkg} --delete &>/dev/null"'])
|
||||
|
||||
def export_blend():
|
||||
for pkg in args.pkg:
|
||||
copy_desktop_files(pkg)
|
||||
|
||||
def unexport_blend():
|
||||
for pkg in args.pkg:
|
||||
del_desktop_files(pkg)
|
||||
core_run_container(f'sudo apt-get update')
|
||||
core_run_container(f'apt-cache show {pkg}')
|
||||
|
||||
def install_blend():
|
||||
if len(args.pkg) != 0:
|
||||
info('installed binaries can be executed from each container\'s respective terminal')
|
||||
print()
|
||||
|
||||
if len(args.pkg) == 0:
|
||||
error('no packages to install')
|
||||
|
||||
for pkg in args.pkg:
|
||||
info(f'installing blend {pkg}')
|
||||
if not distrobox_check_container(args.container_name):
|
||||
distrobox_create_container()
|
||||
distrobox_install_pkg(pkg)
|
||||
copy_desktop_files(pkg)
|
||||
if not check_container(args.container_name):
|
||||
core_create_container()
|
||||
core_install_pkg(pkg)
|
||||
|
||||
def remove_blend():
|
||||
if len(args.pkg) == 0:
|
||||
|
@ -340,19 +283,18 @@ def remove_blend():
|
|||
|
||||
for pkg in args.pkg:
|
||||
info(f'removing blend {pkg}')
|
||||
if not distrobox_check_container(args.container_name):
|
||||
if not check_container(args.container_name):
|
||||
error(f"container {args.container_name} doesn't exist")
|
||||
distrobox_remove_pkg(pkg)
|
||||
del_desktop_files(pkg)
|
||||
core_remove_pkg(pkg)
|
||||
|
||||
def search_blend():
|
||||
if len(args.pkg) == 0:
|
||||
error('no packages to search for')
|
||||
|
||||
for pkg in args.pkg:
|
||||
if not distrobox_check_container(args.container_name):
|
||||
if not check_container(args.container_name):
|
||||
error(f"container {args.container_name} doesn't exist")
|
||||
distrobox_search_pkg(pkg)
|
||||
core_search_pkg(pkg)
|
||||
|
||||
def show_blend():
|
||||
if len(args.pkg) == 0:
|
||||
|
@ -360,89 +302,99 @@ def show_blend():
|
|||
|
||||
for pkg in args.pkg:
|
||||
info(f'info about blend {pkg}')
|
||||
if not distrobox_check_container(args.container_name):
|
||||
if not check_container(args.container_name):
|
||||
error(f"container {args.container_name} doesn't exist")
|
||||
distrobox_show_pkg(pkg)
|
||||
core_show_pkg(pkg)
|
||||
|
||||
def sync_blends():
|
||||
if args.distro == 'fedora-rawhide':
|
||||
distrobox_run_container(f'dnf makecache')
|
||||
core_run_container(f'dnf makecache')
|
||||
elif args.distro == 'arch':
|
||||
distrobox_run_container(f'yay -Syy')
|
||||
core_run_container(f'yay -Syy')
|
||||
elif args.distro.startswith('ubuntu-'):
|
||||
distrobox_run_container(f'sudo apt-get update')
|
||||
core_run_container(f'sudo apt-get update')
|
||||
|
||||
def update_blends():
|
||||
if args.distro == 'fedora-rawhide':
|
||||
if args.noconfirm == True:
|
||||
distrobox_run_container(f'sudo dnf -y upgrade')
|
||||
core_run_container(f'sudo dnf -y upgrade')
|
||||
else:
|
||||
distrobox_run_container(f'sudo dnf upgrade')
|
||||
core_run_container(f'sudo dnf upgrade')
|
||||
elif args.distro == 'arch':
|
||||
if args.noconfirm == True:
|
||||
distrobox_run_container(f'yay --noconfirm')
|
||||
core_run_container(f'yay --noconfirm')
|
||||
else:
|
||||
distrobox_run_container(f'yay')
|
||||
core_run_container(f'yay')
|
||||
elif args.distro.startswith('ubuntu-'):
|
||||
distrobox_run_container(f'sudo apt-get update')
|
||||
core_run_container(f'sudo apt-get update')
|
||||
if args.noconfirm == True:
|
||||
distrobox_run_container(f'sudo apt-get dist-upgrade -y')
|
||||
core_run_container(f'sudo apt-get dist-upgrade -y')
|
||||
else:
|
||||
distrobox_run_container(f'sudo apt-get dist-upgrade')
|
||||
core_run_container(f'sudo apt-get dist-upgrade')
|
||||
else:
|
||||
error(f'distribution {args.distro} is not supported')
|
||||
|
||||
def system_update():
|
||||
try:
|
||||
if args.noconfirm == True:
|
||||
ret = subprocess.call(['sudo', 'nearly', 'run', '/usr/bin/pacman --noconfirm -Syu'])
|
||||
else:
|
||||
ret = subprocess.call(['sudo', 'nearly', 'run', '/usr/bin/pacman -Syu'])
|
||||
except:
|
||||
try:
|
||||
subprocess.call(['sudo', 'nearly', 'enter', 'ro'])
|
||||
except KeyboardInterrupt:
|
||||
error('looks like you interrupted blend. your system is currently in read-write mode')
|
||||
info('run `nearly enter ro\' to enable immutability again')
|
||||
exit(1)
|
||||
|
||||
def enter_container():
|
||||
if not distrobox_check_container(args.container_name):
|
||||
distrobox_create_container()
|
||||
if os.environ.get('BLEND_COMMAND') == None or os.environ.get('BLEND_COMMAND') == '':
|
||||
exit(subprocess.call(['distrobox-enter', '-n', args.container_name]))
|
||||
if os.environ.get('BLEND_NO_CHECK') == None:
|
||||
if not check_container(args.container_name):
|
||||
core_create_container()
|
||||
if check_container_status(args.container_name) != 'running':
|
||||
core_start_container(args.container_name)
|
||||
podman_args = []
|
||||
sudo = []
|
||||
if os.environ.get('SUDO_USER') == None:
|
||||
podman_args = ['--user', getpass.getuser()]
|
||||
else:
|
||||
exit(subprocess.call(['distrobox-enter', '-n', args.container_name, '-e', os.environ['BLEND_COMMAND']]))
|
||||
sudo = ['sudo', '-u', os.environ.get('SUDO_USER'), f'PATH={os.path.expanduser("~/.local/share/bin/blend_bin")}:/usr/bin']
|
||||
for name, val in os.environ.items():
|
||||
if name not in ['LANG', 'LC_CTYPE', 'PATH', 'HOST', 'HOSTNAME', 'SHELL'] and not name.startswith('_'):
|
||||
podman_args.append('--env')
|
||||
podman_args.append(name + '=' + val)
|
||||
if os.environ.get('BLEND_COMMAND') == None or os.environ.get('BLEND_COMMAND') == '':
|
||||
if args.pkg == []:
|
||||
if os.getcwd() == os.path.expanduser('~') or os.getcwd().startswith(os.path.expanduser('~') + '/'):
|
||||
exit(subprocess.call([*sudo, 'podman', 'exec', *podman_args, '-w', os.getcwd(), '-it', args.container_name, 'bash']))
|
||||
else:
|
||||
exit(subprocess.call([*sudo, 'podman', 'exec', *podman_args, '-w', '/run/host' + os.getcwd(), '-it', args.container_name, 'bash']))
|
||||
else:
|
||||
if os.getcwd() == os.path.expanduser('~') or os.getcwd().startswith(os.path.expanduser('~') + '/'):
|
||||
exit(subprocess.call([*sudo, 'podman', 'exec', *podman_args, '-w', os.getcwd(), '-it', args.container_name, *args.pkg]))
|
||||
else:
|
||||
exit(subprocess.call([*sudo, 'podman', 'exec', *podman_args, '-w', '/run/host' + os.getcwd(), '-it', args.container_name, *args.pkg]))
|
||||
else:
|
||||
if os.getcwd() == os.path.expanduser('~') or os.getcwd().startswith(os.path.expanduser('~') + '/'):
|
||||
exit(subprocess.call([*sudo, 'podman', 'exec', *podman_args, '-w', os.getcwd(), '-it', args.container_name, 'bash', '-c', os.environ.get('BLEND_COMMAND')]))
|
||||
else:
|
||||
exit(subprocess.call([*sudo, 'podman', 'exec', *podman_args, '-w', '/run/host' + os.getcwd(), '-it', args.container_name, 'bash']))
|
||||
|
||||
def create_container():
|
||||
for container in args.pkg:
|
||||
args.container_name = container
|
||||
if container in distro_map.keys() and distro_input == None:
|
||||
args.distro = container
|
||||
distrobox_create_container()
|
||||
subprocess.call(['distrobox-enter', '-nw', '-n', args.container_name, '--', 'echo -n'])
|
||||
core_create_container()
|
||||
|
||||
def remove_container():
|
||||
for container in args.pkg:
|
||||
info(f'removing container {container}')
|
||||
subprocess.run(['podman', 'stop', container], stderr=subprocess.DEVNULL, stdout=subprocess.DEVNULL)
|
||||
subprocess.run(['distrobox-rm', container, '--force'], stdout=subprocess.DEVNULL)
|
||||
subprocess.run(['podman', 'rm', '-f', container], stdout=subprocess.DEVNULL)
|
||||
|
||||
def start_containers():
|
||||
_list = subprocess.run(['podman', 'ps', '-a', '--no-trunc', '--size', '--format',
|
||||
'{{.Names}}:{{.Mounts}}'], stdout=subprocess.PIPE).stdout.decode('utf-8').strip()
|
||||
if len(_list) == 0:
|
||||
info('No containers. Create one by installing a package (`blend install hello`), or manually create one (`blend create-container arch`).')
|
||||
info('No containers. Create one by installing a package (`blend install hello`), or manually create one (`blend create-container -d arch`).')
|
||||
for container in _list.splitlines(keepends=False):
|
||||
container = container.split(':')[0]
|
||||
info(f'starting container {container}')
|
||||
subprocess.call(['distrobox-enter', '-n', args.container_name, '--', 'true'])
|
||||
subprocess.call(['podman', 'start', container])
|
||||
|
||||
if shutil.which('distrobox') is None:
|
||||
error("distrobox isn't installed, which is a hard dep")
|
||||
if shutil.which('podman') is None:
|
||||
error("podman isn't installed, which is a hard dep")
|
||||
exit(1)
|
||||
|
||||
if os.geteuid() == 0:
|
||||
if os.geteuid() == 0 and os.environ['BLEND_ALLOW_ROOT'] == None:
|
||||
error("do not run as root")
|
||||
exit(1)
|
||||
|
||||
|
@ -480,10 +432,7 @@ Here's a list of the supported desktop environments:
|
|||
{colors.bold}help{colors.reset} Show this help message and exit.
|
||||
{colors.bold}version{colors.reset} Show version information and exit.
|
||||
{colors.bold}enter{colors.reset} Enter the container shell.
|
||||
{colors.bold}export{colors.reset} Export the desktop entry for an installed blend.
|
||||
{colors.bold}unexport{colors.reset} Unexport the desktop entry for a blend.
|
||||
{colors.bold}install{colors.reset} Install packages inside a container.
|
||||
{colors.bold}install-de{colors.reset} Install a desktop environment inside a container. {colors.bold}(EXPERIMENTAL){colors.reset}
|
||||
{colors.bold}remove{colors.reset} Remove packages inside a managed container.
|
||||
{colors.bold}create-container{colors.reset} Create a container managed by blend.
|
||||
{colors.bold}remove-container{colors.reset} Remove a container managed by blend.
|
||||
|
@ -493,7 +442,6 @@ Here's a list of the supported desktop environments:
|
|||
{colors.bold}search{colors.reset} Search for packages in a managed container.
|
||||
{colors.bold}show{colors.reset} Show details about a package.
|
||||
{colors.bold}update{colors.reset} Update all the packages in a managed container.
|
||||
{colors.bold}system-update{colors.reset} Update all the system packages.
|
||||
|
||||
{colors.bold}{colors.fg.purple}options for commands{colors.reset}:
|
||||
{colors.bold}-cn CONTAINER NAME, --container-name CONTAINER NAME{colors.reset}
|
||||
|
@ -512,17 +460,13 @@ parser = argparse.ArgumentParser(description=description, usage=argparse.SUPPRES
|
|||
epilog=epilog, formatter_class=argparse.RawTextHelpFormatter)
|
||||
command_map = { 'install': install_blend,
|
||||
'remove': remove_blend,
|
||||
'install-de': install_de,
|
||||
'enter': enter_container,
|
||||
'create-container': create_container,
|
||||
'create-container': core_create_container,
|
||||
'remove-container': remove_container,
|
||||
'list-containers': distrobox_list_containers,
|
||||
'list-containers': list_containers,
|
||||
'start-containers': start_containers,
|
||||
'sync': sync_blends,
|
||||
'update': update_blends,
|
||||
'system-update': system_update,
|
||||
'export': export_blend,
|
||||
'unexport': unexport_blend,
|
||||
'search': search_blend,
|
||||
'show': show_blend,
|
||||
'help': 'help',
|
||||
|
|
210
blend-files
Executable file
210
blend-files
Executable file
|
@ -0,0 +1,210 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import os, sys, yaml, time, getpass, shutil, fileinput, subprocess
|
||||
|
||||
def get_containers():
|
||||
container_list = subprocess.run(['sudo', '-u', user, 'podman', 'ps', '-a', '--no-trunc', '--size', '--sort=created', '--format',
|
||||
'{{.Names}}'], stdout=subprocess.PIPE).stdout.decode('utf-8').strip().split('\n')
|
||||
|
||||
try:
|
||||
with open(os.path.expanduser('~/.config/blend/config.yaml')) as config_file:
|
||||
data = yaml.safe_load(config_file)
|
||||
order = data['container_order'].copy()
|
||||
order.reverse()
|
||||
container_list.reverse()
|
||||
for i in container_list:
|
||||
if i.strip() not in order:
|
||||
order.insert(0, i)
|
||||
for i, o in enumerate(order):
|
||||
if o not in container_list:
|
||||
del order[i]
|
||||
return order
|
||||
except:
|
||||
return container_list
|
||||
|
||||
def list_use_container_bin():
|
||||
try:
|
||||
with open(os.path.expanduser('~/.config/blend/config.yaml')) as config_file:
|
||||
data = yaml.safe_load(config_file)
|
||||
return data['use_container_bins']
|
||||
except:
|
||||
return []
|
||||
|
||||
def check_if_present(attr, desktop_str):
|
||||
for l in desktop_str:
|
||||
if l.startswith(attr + '='):
|
||||
return True
|
||||
return False
|
||||
|
||||
def which(bin):
|
||||
results = []
|
||||
for dir in os.environ.get('PATH').split(':'):
|
||||
if os.path.isdir(dir):
|
||||
for i in os.listdir(dir):
|
||||
if os.path.basename(bin) == i:
|
||||
results.append(os.path.join(dir, i))
|
||||
if results == []:
|
||||
return None
|
||||
return results
|
||||
|
||||
def create_container_binaries():
|
||||
_binaries = []
|
||||
remove_binaries = []
|
||||
|
||||
for c in _list:
|
||||
c = c.strip()
|
||||
for i in con_get_output(c, '''find /usr/bin -type f -printf "%P\n" 2>/dev/null;
|
||||
find /usr/local/bin -type f -printf "%P\n" 2>/dev/null;
|
||||
find /usr/sbin -type f -printf "%P\n" 2>/dev/null;''').split('\n'):
|
||||
i = i.strip()
|
||||
os.makedirs(os.path.expanduser(f'~/.local/bin/blend_{c}'), exist_ok=True)
|
||||
i_present = False
|
||||
orig_which_out = which(os.path.basename(i))
|
||||
which_out = None
|
||||
if orig_which_out != None:
|
||||
which_out = orig_which_out.copy()
|
||||
try:
|
||||
which_out.remove(os.path.expanduser(f'~/.local/bin/blend_bin/{os.path.basename(i)}'))
|
||||
except ValueError:
|
||||
pass
|
||||
if which_out == []:
|
||||
which_out = None
|
||||
if which_out != None and os.path.basename(i) not in _exceptions:
|
||||
i_present = True
|
||||
|
||||
if os.path.basename(i) != 'host-spawn' and i != '' and not i_present:
|
||||
with open(os.path.expanduser(f'~/.local/bin/blend_{c}/{os.path.basename(i)}.tmp'), 'w') as f:
|
||||
f.write('#!/bin/sh\n')
|
||||
f.write(f'# blend container: {i}\n')
|
||||
if os.path.basename(i) in _exceptions:
|
||||
f.write(f'# EXCEPTION\n')
|
||||
f.write(f'BLEND_ALLOW_ROOT= BLEND_NO_CHECK= blend enter -cn {c} -- {i} "$@"\n')
|
||||
# XXX: make this bit fully atomic
|
||||
os.chmod(os.path.expanduser(f'~/.local/bin/blend_{c}/{os.path.basename(i)}.tmp'), 0o775)
|
||||
subprocess.call(['mv', os.path.expanduser(f'~/.local/bin/blend_{c}/{os.path.basename(i)}.tmp'),
|
||||
os.path.expanduser(f'~/.local/bin/blend_{c}/{os.path.basename(i)}')])
|
||||
_binaries.append((c, os.path.basename(os.path.basename(i))))
|
||||
|
||||
os.makedirs(os.path.expanduser(f'~/.local/bin/blend_bin'), exist_ok=True)
|
||||
|
||||
for c, i in _binaries:
|
||||
try:
|
||||
os.symlink(os.path.expanduser(f'~/.local/bin/blend_{c}/{i}'), os.path.expanduser(f'~/.local/bin/blend_bin/{i}'))
|
||||
except FileExistsError:
|
||||
if not subprocess.call(['grep', '-q', f'^# container: {c}$', os.path.expanduser(f'~/.local/bin/blend_bin/{i}')]):
|
||||
os.remove(os.path.expanduser(f'~/.local/bin/blend_bin/{i}'))
|
||||
os.symlink(os.path.expanduser(f'~/.local/bin/blend_{c}/{i}'), os.path.expanduser(f'~/.local/bin/blend_bin/{i}'))
|
||||
|
||||
for i in remove_binaries:
|
||||
try:
|
||||
os.remove(i)
|
||||
except:
|
||||
pass
|
||||
|
||||
for b in os.listdir(os.path.expanduser(f'~/.local/bin/blend_bin')):
|
||||
if [_b for _b in _binaries if _b[1] == b] == []:
|
||||
os.remove(os.path.join(os.path.expanduser(f'~/.local/bin/blend_bin'), b))
|
||||
|
||||
def create_container_applications():
|
||||
_apps = []
|
||||
|
||||
os.makedirs(os.path.expanduser(f'~/.local/share/applications'), exist_ok=True)
|
||||
|
||||
for c in _list:
|
||||
c = c.strip()
|
||||
for i in con_get_output(c, 'find /usr/share/applications -type f 2>/dev/null; find /usr/local/share/applications -type f 2>/dev/null').split('\n'):
|
||||
orig_path = i.strip()
|
||||
i = os.path.basename(orig_path)
|
||||
i_present = (os.path.isfile(f'/usr/share/applications/{i}') or os.path.isfile(f'/usr/local/share/applications/{i}')
|
||||
or os.path.isfile(os.path.expanduser(f'~/.local/share/applications/{i}')))
|
||||
if i != '' and not i_present:
|
||||
with open(os.path.expanduser(f'~/.local/share/applications/blend;{i}'), 'w') as f:
|
||||
_ = con_get_output(c, f"sudo sed -i '/^DBusActivatable=/d' {orig_path}")
|
||||
_ = con_get_output(c, f"sudo sed -i '/^TryExec=/d' {orig_path}")
|
||||
contents = con_get_output(c, f'cat {orig_path}')
|
||||
f.write(contents)
|
||||
for line in fileinput.input(os.path.expanduser(f'~/.local/share/applications/blend;{i}'), inplace=True):
|
||||
if line.strip().startswith('Exec='):
|
||||
line = f'Exec=env BLEND_NO_CHECK= blend enter -cn {c} -- {line[5:]}\n'
|
||||
elif line.strip().startswith('Icon='):
|
||||
if '/' in line:
|
||||
line = line.strip()
|
||||
_ = con_get_output(c, f"mkdir -p ~/.local/share/blend/icons/file/\"{c}_{i}\"; cp {line[5:]} ~/.local/share/blend/icons/file/\"{c}_{i}\"")
|
||||
line = f'Icon={os.path.expanduser("~/.local/share/blend/icons/file/" + c + "_" + i + "/" + os.path.basename(line[5:]))}\n'
|
||||
else:
|
||||
line = line.strip()
|
||||
icons = con_get_output(c, f'''find /usr/share/icons /usr/share/pixmaps /var/lib/flatpak/exports/share/icons \\
|
||||
-type f -iname "*{line[5:]}*" 2> /dev/null | sort''').split('\r\n')
|
||||
_ = con_get_output(c, f"mkdir -p ~/.local/share/blend/icons/\"{c}_{i}\"; cp {icons[0]} ~/.local/share/blend/icons/\"{c}_{i}\"")
|
||||
line = f'Icon={os.path.expanduser("~/.local/share/blend/icons/" + c + "_" + i + "/" + os.path.basename(icons[0]))}\n'
|
||||
sys.stdout.write(line)
|
||||
os.chmod(os.path.expanduser(f'~/.local/share/applications/blend;{i}'), 0o775)
|
||||
_apps.append((c, i))
|
||||
del _
|
||||
|
||||
for a in os.listdir(os.path.expanduser(f'~/.local/share/applications')):
|
||||
if a.startswith('blend;'):
|
||||
a = a.removeprefix('blend;')
|
||||
if [_a for _a in _apps if _a[1] == a] == []:
|
||||
os.remove(os.path.expanduser(f'~/.local/share/applications/blend;{a}'))
|
||||
|
||||
def create_container_sessions(type='xsessions'):
|
||||
session_dir = f'/usr/share/{type}'
|
||||
|
||||
os.makedirs('/usr/share/xsessions', exist_ok=True)
|
||||
|
||||
for session in os.listdir(session_dir):
|
||||
if session.startswith(os.path.join(session_dir, 'blend-')):
|
||||
os.remove(os.path.join(session_dir, session))
|
||||
|
||||
for c in _list:
|
||||
c = c.strip()
|
||||
for i in con_get_output(c, f'find {session_dir} -type f 2>/dev/null').split('\n'):
|
||||
orig_path = i.strip()
|
||||
i = os.path.basename(orig_path)
|
||||
if i != '':
|
||||
with open(os.path.expanduser(f'{session_dir}/blend-{c};{i}'), 'w') as f:
|
||||
contents = con_get_output(c, f'cat {orig_path}')
|
||||
f.write(contents)
|
||||
for line in fileinput.input(os.path.expanduser(f'/{session_dir}/blend-{c};{i}'), inplace=True):
|
||||
if line.strip().startswith('Name'):
|
||||
name = line.split('=')[1]
|
||||
line = f'Name=Container {c}: {name}'
|
||||
elif line.strip().startswith('Exec='):
|
||||
line = f'Exec=blend enter -cn {c} -- {line[5:]}'
|
||||
elif line.strip().startswith('TryExec='):
|
||||
continue
|
||||
|
||||
sys.stdout.write(line)
|
||||
os.chmod(os.path.expanduser(f'{session_dir}/blend-{c};{i}'), 0o775)
|
||||
|
||||
con_get_output = lambda name, cmd: subprocess.run(['sudo', '-u', user, 'podman', 'exec', '--user', getpass.getuser(), '-it', name, 'bash', '-c', cmd],
|
||||
stdout=subprocess.PIPE, stderr=subprocess.DEVNULL).stdout.decode('UTF-8').strip()
|
||||
|
||||
user = getpass.getuser()
|
||||
|
||||
try:
|
||||
user = sys.argv[2]
|
||||
except:
|
||||
pass
|
||||
|
||||
try:
|
||||
if sys.argv[1] == 'sessions':
|
||||
_list = get_containers()
|
||||
create_container_sessions(type='xsessions')
|
||||
create_container_sessions(type='wayland-sessions')
|
||||
exit(0)
|
||||
except IndexError:
|
||||
pass
|
||||
|
||||
for c in get_containers():
|
||||
c = c.strip()
|
||||
subprocess.call(['podman', 'start', c])
|
||||
|
||||
while True:
|
||||
_list = get_containers()
|
||||
_exceptions = list_use_container_bin()
|
||||
|
||||
create_container_binaries()
|
||||
create_container_applications()
|
||||
time.sleep(6)
|
10
blend-files.service
Normal file
10
blend-files.service
Normal file
|
@ -0,0 +1,10 @@
|
|||
[Unit]
|
||||
Description=Make container apps accessible
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
StandardOutput=journal
|
||||
ExecStart=/usr/bin/blend-files
|
||||
|
||||
[Install]
|
||||
WantedBy=default.target
|
|
@ -1,73 +0,0 @@
|
|||
# shellcheck shell=sh
|
||||
|
||||
# Expand $PATH to include the directory where blend's package manager shortcuts
|
||||
# are located.
|
||||
blend_pkgmanager_bin_path="/blend/pkgmanagers"
|
||||
if [ -n "${PATH##*${blend_pkgmanager_bin_path}}" ] && [ -n "${PATH##*${blend_pkgmanager_bin_path}:*}" ]; then
|
||||
export PATH="${blend_pkgmanager_bin_path}:${PATH}"
|
||||
fi
|
||||
|
||||
# Start all the containers
|
||||
blend start-containers &>/dev/null || :
|
||||
|
||||
if [[ ! -f "${HOME}/.disable_blend_msg" ]]; then
|
||||
shell_bold='\033[01m'
|
||||
shell_color_purple='\033[35m'
|
||||
shell_reset='\033[0m'
|
||||
|
||||
echo -e "${shell_bold}Welcome to the ${shell_color_purple}blendOS${shell_reset}${shell_bold} shell!"
|
||||
|
||||
echo -e "${shell_reset}note: if you don't want to see this message, you can create a file in your"
|
||||
echo -e "home directory named .disable_blend_msg${shell_bold}"
|
||||
echo
|
||||
|
||||
echo -e 'Here are some useful commands:'
|
||||
echo -e "${shell_reset}To install a package in an Arch container:${shell_bold}"
|
||||
echo -e " blend install <PKG>"
|
||||
echo -e "${shell_reset}To remove a package in an Arch container:${shell_bold}"
|
||||
echo -e " blend remove <PKG>"
|
||||
echo -e "${shell_reset}To install a package in a Fedora container:${shell_bold}"
|
||||
echo -e " blend install <PKG> -d fedora-rawhide"
|
||||
echo -e "${shell_reset}To enter a Fedora container:${shell_bold}"
|
||||
echo -e " blend enter -cn fedora-rawhide"
|
||||
echo -e "${shell_reset}To update all the system packages:${shell_bold}"
|
||||
echo -e " blend system-update${shell_reset} (do not use 'pacman -Syu', as it will only update the"
|
||||
echo -e " packages in the Arch container)"
|
||||
echo -e "${shell_reset}To list all the containers:${shell_bold}"
|
||||
echo -e " blend list-containers"
|
||||
|
||||
echo -e "Keep in mind that none of these commands should be run as root."
|
||||
|
||||
echo
|
||||
echo -e "${shell_reset}Most apps installed through blend will automatically appear in the applications"
|
||||
echo -e "list. However, if they don't, you can always manually export them by running:"
|
||||
echo -e " ${shell_bold}blend export [DESKTOP FILE WITHOUT EXTENSION]${shell_reset}"
|
||||
echo
|
||||
|
||||
echo -e "You can always specify a distribution (default is arch) by appending ${shell_bold}"
|
||||
echo -e "--distro=[DISTRO]${shell_reset} to the end of a blend command."
|
||||
echo -e "(for example: ${shell_bold}blend install hello --distro=ubuntu-22.10)${shell_reset}"
|
||||
echo
|
||||
echo -e "Here are the supported distributions:"
|
||||
echo -e "${shell_bold}1.${shell_reset} arch (default)"
|
||||
echo -e "${shell_bold}2.${shell_reset} fedora-rawhide"
|
||||
echo -e "${shell_bold}3.${shell_reset} ubuntu-22.04"
|
||||
echo -e "${shell_bold}4.${shell_reset} ubuntu-22.10"
|
||||
echo -e "You can also specify a custom container name (default is the distro's name) by"
|
||||
echo -e "appending ${shell_bold}--container-name=[CONTAINER]${shell_reset} to the end of a blend command."
|
||||
|
||||
echo
|
||||
echo -e "You can also use these packages managers directly:"
|
||||
echo -e "${shell_bold}1.${shell_reset} pacman/yay (distro: arch)"
|
||||
echo -e "${shell_bold}2.${shell_reset} apt/apt-get (distro: ubuntu-22.10)"
|
||||
echo -e "${shell_bold}3.${shell_reset} dnf/yum (distro: fedora-rawhide)"
|
||||
echo -e "However, you'll need to manually export the desktop files"
|
||||
echo -e "for packages installed this way, by running:"
|
||||
echo -e " ${shell_bold}blend export [DESKTOP FILE WITHOUT EXTENSION] --distro=[DISTRO]${shell_reset}"
|
||||
|
||||
echo
|
||||
echo -e "For more information about ${shell_color_purple}blend${shell_reset}${shell_bold}, run:"
|
||||
echo -e " blend help"
|
||||
|
||||
echo -e "${shell_reset}"
|
||||
fi
|
4
blend-settings/.gitignore
vendored
Normal file
4
blend-settings/.gitignore
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
dist/
|
||||
node_modules/
|
||||
package-lock.json
|
||||
web-server/data/applist.json
|
|
@ -631,8 +631,8 @@ 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>
|
||||
Grapes
|
||||
Copyright (C) 2023 Rudra Saraswat <rs2009@ubuntu.com>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
@ -652,7 +652,7 @@ Also add information on how to contact you by electronic and paper mail.
|
|||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
<program> Copyright (C) 2023 Rudra Saraswat <rs2009@ubuntu.com>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
@ -671,4 +671,4 @@ into proprietary programs. If your program is a subroutine library, you
|
|||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
||||
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
BIN
blend-settings/build/icon.png
Normal file
BIN
blend-settings/build/icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 16 KiB |
156
blend-settings/main.js
Normal file
156
blend-settings/main.js
Normal file
|
@ -0,0 +1,156 @@
|
|||
const { app, BrowserWindow, ipcMain, dialog } = require('electron')
|
||||
const path = require('path')
|
||||
const pty = require("node-pty");
|
||||
|
||||
var mainWindow, terminalWindow, ptyProcess
|
||||
|
||||
function createWindow() {
|
||||
mainWindow = new BrowserWindow({
|
||||
minWidth: 1000,
|
||||
minHeight: 600,
|
||||
maxWidth: 1000,
|
||||
maxHeight: 600,
|
||||
webPreferences: {
|
||||
nodeIntegration: true,
|
||||
nodeIntegrationInWorker: true,
|
||||
contextIsolation: false,
|
||||
enableRemoteModule: true,
|
||||
sandbox: false,
|
||||
preload: path.join(__dirname, 'src/preload.js')
|
||||
},
|
||||
autoHideMenuBar: true
|
||||
})
|
||||
|
||||
//mainWindow.setMenu(null)
|
||||
|
||||
mainWindow.loadFile('src/index.html')
|
||||
}
|
||||
|
||||
function createTerminalWindow() {
|
||||
terminalWindow = new BrowserWindow({
|
||||
minWidth: 800,
|
||||
minHeight: 600,
|
||||
webPreferences: {
|
||||
nodeIntegration: true,
|
||||
contextIsolation: false,
|
||||
sandbox: false
|
||||
},
|
||||
autoHideMenuBar: true,
|
||||
show: false
|
||||
})
|
||||
|
||||
terminalWindow.loadFile('src/pages/terminal.html')
|
||||
|
||||
terminalWindow.setMenu(null)
|
||||
}
|
||||
|
||||
function loadTerminalWindow(title, cmd) {
|
||||
if (terminalWindow.isDestroyed()) {
|
||||
createTerminalWindow()
|
||||
}
|
||||
|
||||
if (terminalWindow.isVisible() && (title.startsWith('Container: ') && terminalWindow.getTitle().startsWith('Creating container: '))) {
|
||||
dialog.showErrorBox('Error opening container window', 'You cannot open a container window while creating a container.')
|
||||
return
|
||||
}
|
||||
|
||||
if (terminalWindow.isVisible() && title.startsWith('Container: ')) {
|
||||
dialog.showErrorBox('Error opening container window', 'You must close any other container windows before opening a new one.')
|
||||
return
|
||||
}
|
||||
|
||||
if (terminalWindow.isVisible() && (title.startsWith('Creating container: ') && terminalWindow.getTitle().startsWith('Creating container: '))) {
|
||||
dialog.showErrorBox('Error creating container', 'You cannot create two containers simultaneously.')
|
||||
return
|
||||
}
|
||||
|
||||
if (terminalWindow.isVisible() && title.startsWith('Creating container: ')) {
|
||||
dialog.showErrorBox('Error creating container', 'You must close the container window before creating a container.')
|
||||
return
|
||||
}
|
||||
|
||||
terminalWindow.show()
|
||||
|
||||
ipcMain.removeAllListeners('terminal.reset')
|
||||
ipcMain.removeAllListeners('terminal.keystroke')
|
||||
ipcMain.removeAllListeners('terminal.incomingData')
|
||||
ipcMain.removeAllListeners('title')
|
||||
|
||||
terminalWindow.removeAllListeners()
|
||||
|
||||
terminalWindow.on('close', e => {
|
||||
if (terminalWindow.getTitle().startsWith('Creating container: ')) {
|
||||
dialog.showMessageBox(terminalWindow, {
|
||||
'type': 'question',
|
||||
'title': 'Are you sure?',
|
||||
'message': "A container is being created. Closing this window will prevent you from seeing its creation status. Are you sure?",
|
||||
'buttons': [
|
||||
'Yes',
|
||||
'No'
|
||||
]
|
||||
}).then((result) => {
|
||||
if (result.response === 0) {
|
||||
terminalWindow.hide()
|
||||
ptyProcess.destroy()
|
||||
}
|
||||
})
|
||||
} else {
|
||||
terminalWindow.hide()
|
||||
ptyProcess.destroy()
|
||||
}
|
||||
e.preventDefault()
|
||||
})
|
||||
|
||||
terminalWindow.webContents.send("terminal.reset")
|
||||
|
||||
terminalWindow.webContents.send("title", title);
|
||||
|
||||
ptyProcess = pty.spawn('/bin/bash', ['-c', cmd], {
|
||||
name: "xterm-color",
|
||||
cols: 80,
|
||||
rows: 30,
|
||||
cwd: process.env.HOME,
|
||||
env: process.env
|
||||
});
|
||||
|
||||
ptyProcess.on('data', data => {
|
||||
if (!terminalWindow.isDestroyed()) {
|
||||
terminalWindow.webContents.send("terminal.incomingData", data)
|
||||
}
|
||||
});
|
||||
ptyProcess.on('exit', () => {
|
||||
if (!terminalWindow.isDestroyed()) {
|
||||
terminalWindow.webContents.send("terminal.reset")
|
||||
terminalWindow.hide()
|
||||
if (title.startsWith('Creating container: ')) {
|
||||
mainWindow.webContents.send("container-created")
|
||||
}
|
||||
}
|
||||
})
|
||||
ipcMain.on("terminal.keystroke", (event, key) => {
|
||||
ptyProcess.write(key)
|
||||
});
|
||||
ipcMain.on("terminal.resize", (event, size) => {
|
||||
ptyProcess.resize(size[0], size[1])
|
||||
});
|
||||
}
|
||||
|
||||
app.whenReady().then(() => {
|
||||
app.allowRendererProcessReuse = false
|
||||
|
||||
createWindow()
|
||||
createTerminalWindow()
|
||||
|
||||
ipcMain.on('create-term', (event, data) => {
|
||||
loadTerminalWindow(data['title'], data['cmd'])
|
||||
})
|
||||
|
||||
app.on('activate', () => {
|
||||
if (BrowserWindow.getAllWindows().length === 0) createWindow()
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
app.on('window-all-closed', function () {
|
||||
if (process.platform !== 'darwin') app.quit()
|
||||
})
|
28
blend-settings/package.json
Normal file
28
blend-settings/package.json
Normal file
|
@ -0,0 +1,28 @@
|
|||
{
|
||||
"name": "blend-settings",
|
||||
"version": "1.0.0",
|
||||
"description": "A settings app for blendOS",
|
||||
"main": "main.js",
|
||||
"homepage": "https://blendos.org",
|
||||
"author": "Rudra Saraswat",
|
||||
"license": "GPL-3.0-or-later",
|
||||
"scripts": {
|
||||
"start": "electron .",
|
||||
"pack": "electron-builder --dir",
|
||||
"dist": "electron-builder"
|
||||
},
|
||||
"dependencies": {
|
||||
"@electron/remote": "^2.0.9",
|
||||
"@types/jquery": "^3.5.16",
|
||||
"jquery": "^3.6.3",
|
||||
"js-yaml": "^4.1.0",
|
||||
"node-pty": "github:daniel-brenot/node-pty#rust-port",
|
||||
"sortablejs": "^1.15.0",
|
||||
"xterm": "^5.1.0",
|
||||
"xterm-addon-fit": "^0.7.0",
|
||||
"xterm-addon-ligatures": "^0.6.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"electron": "^23.0.0"
|
||||
}
|
||||
}
|
7
blend-settings/src/external/css/bootstrap.min.css
vendored
Normal file
7
blend-settings/src/external/css/bootstrap.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
7
blend-settings/src/external/js/bootstrap.bundle.min.js
vendored
Normal file
7
blend-settings/src/external/js/bootstrap.bundle.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
64
blend-settings/src/index.html
Normal file
64
blend-settings/src/index.html
Normal file
|
@ -0,0 +1,64 @@
|
|||
<html>
|
||||
|
||||
<head>
|
||||
<title>Settings</title>
|
||||
|
||||
<!-- Import bootstrap v5.0. -->
|
||||
<link href="external/css/bootstrap.min.css" rel="stylesheet">
|
||||
|
||||
<!-- Import common styling. -->
|
||||
<link href="internal/css/common.css" rel="stylesheet">
|
||||
</head>
|
||||
|
||||
<body style="height: 100%;">
|
||||
<br>
|
||||
<div class="topnav">
|
||||
<div class="btn-group" role="group" aria-label="Stores">
|
||||
<button class="btn btn-outline-light active shadow-none" id="containers-button"
|
||||
onclick="page('containers')">Containers</button>
|
||||
<button class="btn btn-outline-light shadow-none" id="overlay-button" onclick="page('overlay')">System</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Import bootstrap JS bundle. -->
|
||||
<script src="external/js/bootstrap.bundle.min.js"></script>
|
||||
|
||||
<script>
|
||||
const Sortable = require('sortablejs')
|
||||
const child_process = require('child_process')
|
||||
const path = require('path')
|
||||
const fs = require('fs')
|
||||
const ipc = require('electron').ipcRenderer
|
||||
|
||||
let webview = document.createElement("div")
|
||||
webview.style.flexGrow = 1
|
||||
webview.setAttribute("id", "webview")
|
||||
webview.style.marginTop = "70px"
|
||||
|
||||
document.body.appendChild(webview)
|
||||
|
||||
const $ = require("jquery")
|
||||
|
||||
function page(page) {
|
||||
switch (page) {
|
||||
case 'containers':
|
||||
$('#webview').load("pages/containers.html");
|
||||
$('#containers-button').addClass('active')
|
||||
$('#overlay-button').removeClass('active')
|
||||
break;
|
||||
case 'overlay':
|
||||
$('#webview').load("pages/overlay.html");
|
||||
$('#containers-button').removeClass('active')
|
||||
$('#overlay-button').addClass('active')
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
page('containers')
|
||||
</script>
|
||||
|
||||
<!-- Import generic page JS. -->
|
||||
<script src="internal/js/generic_page.js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
98
blend-settings/src/internal/css/common.css
Normal file
98
blend-settings/src/internal/css/common.css
Normal file
|
@ -0,0 +1,98 @@
|
|||
body {
|
||||
margin: 0 !important;
|
||||
background-color: rgb(36, 36, 48);
|
||||
color: rgba(240, 240, 255, 1);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.btn-dark {
|
||||
background-color: rgb(36, 36, 48);
|
||||
}
|
||||
|
||||
.btn-dark:focus {
|
||||
background-color: rgb(36, 36, 48);
|
||||
}
|
||||
|
||||
.btn-dark:hover {
|
||||
background-color: rgb(32, 32, 44);
|
||||
}
|
||||
|
||||
.topnav {
|
||||
display: flex;
|
||||
position: fixed;
|
||||
top: 20px;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
}
|
||||
|
||||
.list-group-item {
|
||||
border: 1px solid rgba(255, 255, 255, 0.05);
|
||||
}
|
||||
|
||||
.form-control {
|
||||
border: 0;
|
||||
background-color: rgba(255, 255, 255, 0.05) !important;
|
||||
color: white !important;
|
||||
}
|
||||
|
||||
.form-check-input:not(:checked) {
|
||||
background-color: rgba(255, 255, 255, 0.05) !important;
|
||||
}
|
||||
|
||||
select option {
|
||||
color: white;
|
||||
background-color: rgb(36, 36, 48);
|
||||
border: 0;
|
||||
}
|
||||
|
||||
.form-group {
|
||||
margin-top: 8px;
|
||||
}
|
||||
|
||||
#webview {
|
||||
overflow-y: scroll !important;
|
||||
position: fixed;
|
||||
width: 100%;
|
||||
height: calc(100% - 100px);
|
||||
}
|
||||
|
||||
#webview::-webkit-scrollbar-track
|
||||
{
|
||||
background-color: rgb(36, 36, 48);
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
#webview::-webkit-scrollbar
|
||||
{
|
||||
width: 5px;
|
||||
background-color: rgb(36, 36, 48);
|
||||
}
|
||||
|
||||
#webview::-webkit-scrollbar-thumb
|
||||
{
|
||||
background-color: rgb(61, 61, 74);
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
.form-check-input {
|
||||
position: absolute;
|
||||
font-size: 1.5em;
|
||||
top: 0.67em;
|
||||
}
|
||||
|
||||
.list-group-item {
|
||||
background-color: rgb(29, 29, 37);
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
-webkit-scrollbar-track
|
||||
{
|
||||
box-shadow: inset 0 0 6px rgba(0,0,0,0.3);
|
||||
background-color: #F5F5F5;
|
||||
}
|
||||
|
||||
-webkit-scrollbar
|
||||
{
|
||||
width: 10px;
|
||||
background-color: #F5F5F5;
|
||||
}
|
184
blend-settings/src/internal/js/containers.js
Normal file
184
blend-settings/src/internal/js/containers.js
Normal file
|
@ -0,0 +1,184 @@
|
|||
var term
|
||||
|
||||
function open_container(name) {
|
||||
ipc.send("create-term", { 'title': `Container: ${name}`, 'cmd': `blend enter -cn ${name}` });
|
||||
}
|
||||
|
||||
function create_container () {
|
||||
container_name = $('#inputContainerName').val()
|
||||
if (!(/^[\w\-\.]+$/.test(container_name))) {
|
||||
$('#inputContainerName').get(0).setCustomValidity('Container name can only contain alphanumeric characters and dashes (no spaces allowed).')
|
||||
$('#inputContainerName').get(0).reportValidity();
|
||||
return
|
||||
}
|
||||
container_distro = $('#inputContainerDistro').val().toLowerCase().replace(' ', '-')
|
||||
ipc.send("create-term", { 'title': `Creating container: ${container_name}`,
|
||||
'cmd': `blend create-container -cn ${container_name} -d ${container_distro} \
|
||||
&& echo 'created container successfully (exiting automatically in 5 seconds)' \
|
||||
|| echo 'container creation failed (exiting automatically in 5 seconds)';
|
||||
sleep 5` });
|
||||
ipc.on('container-created', () => {
|
||||
worker.postMessage('update-list')
|
||||
})
|
||||
}
|
||||
|
||||
async function remove_container (name) {
|
||||
let rm_worker = new Worker(
|
||||
`data:text/javascript,
|
||||
require('child_process').spawnSync('podman', ['stop', '-t', '0', '${name}'], { encoding: 'utf8' })
|
||||
require('child_process').spawnSync('podman', ['rm', '-f', '${name}'], { encoding: 'utf8' })
|
||||
postMessage('')
|
||||
`
|
||||
)
|
||||
rm_worker.onmessage = e => worker.postMessage('update-list')
|
||||
}
|
||||
|
||||
window.worker = new Worker(
|
||||
`data:text/javascript,
|
||||
function list_containers() {
|
||||
let container_list = require('child_process').spawnSync('podman', ['ps', '-a', '--no-trunc', '--size', '--format', '{{.Names}}'], { encoding: 'utf8' }).stdout.split(/\\r?\\n/).filter(Boolean).reverse();
|
||||
if (require('fs').existsSync(require('path').join(require('os').homedir(), '.config/blend/config.yaml'), 'utf8')) {
|
||||
try {
|
||||
let fileContents = require('fs').readFileSync(require('path').join(require('os').homedir(), '.config/blend/config.yaml'), 'utf8')
|
||||
let data = require('js-yaml').load(fileContents);
|
||||
new_container_list = data['container_order']
|
||||
container_list.forEach(container => {
|
||||
if (!new_container_list.includes(container)) {
|
||||
new_container_list.push(container)
|
||||
}
|
||||
});
|
||||
new_container_list = new_container_list.filter(container => container_list.includes(container))
|
||||
new_container_list.filter((item, index) => arr.indexOf(item) === index)
|
||||
data = {
|
||||
container_order: [...new_container_list],
|
||||
use_container_bins: []
|
||||
};
|
||||
contents = require('js-yaml').dump(data)
|
||||
require('fs').writeFileSync(require('path').join(require('os').homedir(), '.config/blend/config.yaml'), contents, 'utf8')
|
||||
return new_container_list
|
||||
} catch (e) {
|
||||
let data = {
|
||||
container_order: [...container_list],
|
||||
use_container_bins: []
|
||||
};
|
||||
contents = require('js-yaml').dump(data)
|
||||
require('fs').writeFileSync(require('path').join(require('os').homedir(), '.config/blend/config.yaml'), contents, 'utf8')
|
||||
|
||||
return container_list
|
||||
}
|
||||
} else {
|
||||
let data = {
|
||||
container_order: [...container_list],
|
||||
use_container_bins: []
|
||||
};
|
||||
require('fs').mkdirSync(require('path').join(require('os').homedir(), '.config/blend'), { recursive: true });
|
||||
contents = require('js-yaml').dump(data)
|
||||
require('fs').writeFileSync(require('path').join(require('os').homedir(), '.config/blend/config.yaml'), contents, 'utf8')
|
||||
|
||||
return container_list
|
||||
}
|
||||
}
|
||||
|
||||
function truncateText(text, maxLength=30) {
|
||||
let truncated = text
|
||||
|
||||
if (truncated.length > maxLength) {
|
||||
truncated = truncated.substr(0, maxLength) + '...';
|
||||
}
|
||||
|
||||
return truncated;
|
||||
}
|
||||
|
||||
function update_container_list() {
|
||||
container_list = list_containers()
|
||||
|
||||
container_list_html_default = \`
|
||||
<div class="list-group-item">
|
||||
<div class="row align-items-center">
|
||||
<div class="col">
|
||||
<strong class="mb-0">No containers present.</strong>
|
||||
<p class="text-muted mb-0">Create one from below.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
\`
|
||||
|
||||
container_list_html = ''
|
||||
|
||||
container_list.forEach(container => {
|
||||
container_list_html += \`
|
||||
<div class="list-group-item" style="padding-top: 10px; padding-bottom: 10px; border: 0.5px solid rgba(255, 255, 255, 0.05);">
|
||||
<div class="row align-items-center" style="cursor: grab;">
|
||||
<div class="col">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" fill="currentColor" class="bi bi-grip-vertical" viewBox="0 0 16 16" style="margin-right: 12px;">
|
||||
<path d="M7 2a1 1 0 1 1-2 0 1 1 0 0 1 2 0zm3 0a1 1 0 1 1-2 0 1 1 0 0 1 2 0zM7 5a1 1 0 1 1-2 0 1 1 0 0 1 2 0zm3 0a1 1 0 1 1-2 0 1 1 0 0 1 2 0zM7 8a1 1 0 1 1-2 0 1 1 0 0 1 2 0zm3 0a1 1 0 1 1-2 0 1 1 0 0 1 2 0zm-3 3a1 1 0 1 1-2 0 1 1 0 0 1 2 0zm3 0a1 1 0 1 1-2 0 1 1 0 0 1 2 0zm-3 3a1 1 0 1 1-2 0 1 1 0 0 1 2 0zm3 0a1 1 0 1 1-2 0 1 1 0 0 1 2 0z"/>
|
||||
</svg>
|
||||
<strong class="mb-0 container_name">\${container}</strong>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" class="bi bi-play" viewBox="0 0 16 16" onclick="open_container('\${container}')" style="cursor: pointer; margin-right: 8px;">
|
||||
<path d="M10.804 8 5 4.633v6.734L10.804 8zm.792-.696a.802.802 0 0 1 0 1.392l-6.363 3.692C4.713 12.69 4 12.345 4 11.692V4.308c0-.653.713-.998 1.233-.696l6.363 3.692z"/>
|
||||
</svg>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" fill="currentColor" class="bi bi-trash" viewBox="0 0 16 16" onclick="remove_container('\${container}')" style="cursor: pointer; margin-right: 20px; z-index: 10;">
|
||||
<path d="M5.5 5.5A.5.5 0 0 1 6 6v6a.5.5 0 0 1-1 0V6a.5.5 0 0 1 .5-.5zm2.5 0a.5.5 0 0 1 .5.5v6a.5.5 0 0 1-1 0V6a.5.5 0 0 1 .5-.5zm3 .5a.5.5 0 0 0-1 0v6a.5.5 0 0 0 1 0V6z"/>
|
||||
<path fill-rule="evenodd" d="M14.5 3a1 1 0 0 1-1 1H13v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V4h-.5a1 1 0 0 1-1-1V2a1 1 0 0 1 1-1H6a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1h3.5a1 1 0 0 1 1 1v1zM4.118 4 4 4.059V13a1 1 0 0 0 1 1h6a1 1 0 0 0 1-1V4.059L11.882 4H4.118zM2.5 3V2h11v1h-11z"/>
|
||||
</svg>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" fill="currentColor" class="bi bi-grip-vertical" viewBox="0 0 16 16">
|
||||
<path d="M7 2a1 1 0 1 1-2 0 1 1 0 0 1 2 0zm3 0a1 1 0 1 1-2 0 1 1 0 0 1 2 0zM7 5a1 1 0 1 1-2 0 1 1 0 0 1 2 0zm3 0a1 1 0 1 1-2 0 1 1 0 0 1 2 0zM7 8a1 1 0 1 1-2 0 1 1 0 0 1 2 0zm3 0a1 1 0 1 1-2 0 1 1 0 0 1 2 0zm-3 3a1 1 0 1 1-2 0 1 1 0 0 1 2 0zm3 0a1 1 0 1 1-2 0 1 1 0 0 1 2 0zm-3 3a1 1 0 1 1-2 0 1 1 0 0 1 2 0zm3 0a1 1 0 1 1-2 0 1 1 0 0 1 2 0z"/>
|
||||
</svg>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
\`
|
||||
});
|
||||
|
||||
if (container_list.length == 0) {
|
||||
postMessage(container_list_html_default)
|
||||
} else {
|
||||
postMessage(container_list_html)
|
||||
}
|
||||
}
|
||||
|
||||
self.onmessage = msg => {
|
||||
switch(msg) {
|
||||
case 'update-list':
|
||||
update_container_list()
|
||||
break;
|
||||
}
|
||||
update_container_list()
|
||||
}
|
||||
`
|
||||
);
|
||||
|
||||
worker.postMessage('update-list')
|
||||
|
||||
worker.onmessage = function (event) {
|
||||
window.data = event.data
|
||||
if (event.data.includes('bi-grip-vertical')) {
|
||||
$('#container-list').addClass('sortable')
|
||||
$('#container-list').html(event.data)
|
||||
} else {
|
||||
$('#container-list').removeClass('sortable')
|
||||
$('#container-list').html(event.data)
|
||||
}
|
||||
|
||||
$('.sortable').each((i, e) => {
|
||||
Sortable.create(e, {
|
||||
animation: 100,
|
||||
onEnd: () => {
|
||||
let container_list = []
|
||||
$('.container_name').each((i, e) => {
|
||||
container_list.push(e.innerText)
|
||||
})
|
||||
let data = {
|
||||
container_order: [...container_list],
|
||||
use_container_bins: []
|
||||
};
|
||||
require('fs').mkdirSync(require('path').join(require('os').homedir(), '.config/blend'), { recursive: true });
|
||||
contents = require('js-yaml').dump(data)
|
||||
require('fs').writeFileSync(require('path').join(require('os').homedir(), '.config/blend/config.yaml'), contents, 'utf8')
|
||||
}
|
||||
});
|
||||
e.addEventListener("dragstart", e => e.dataTransfer.setDragImage(new Image(), 0, 0), false);
|
||||
})
|
||||
}
|
15
blend-settings/src/internal/js/generic_page.js
Normal file
15
blend-settings/src/internal/js/generic_page.js
Normal file
|
@ -0,0 +1,15 @@
|
|||
if (typeof variable !== typeof undefined) {
|
||||
Sortable = undefined
|
||||
} else {
|
||||
window.Sortable = require('sortablejs')
|
||||
}
|
||||
|
||||
function truncateText(text, maxLength=30) {
|
||||
let truncated = text
|
||||
|
||||
if (truncated.length > maxLength) {
|
||||
truncated = truncated.substr(0, maxLength) + '...';
|
||||
}
|
||||
|
||||
return truncated;
|
||||
}
|
132
blend-settings/src/internal/js/overlay.js
Normal file
132
blend-settings/src/internal/js/overlay.js
Normal file
|
@ -0,0 +1,132 @@
|
|||
function rollback() {
|
||||
let rollback_worker = new Worker(
|
||||
`data:text/javascript,
|
||||
let s = require('child_process').spawnSync('pkexec', ['blend-system', 'rollback']).status
|
||||
if (s === 0) {
|
||||
postMessage('success')
|
||||
} else {
|
||||
postMessage('failure')
|
||||
}
|
||||
`
|
||||
)
|
||||
rollback_worker.onmessage = e => {
|
||||
if (e.data == 'success') {
|
||||
document.getElementById('rollback-btn').outerHTML =
|
||||
'<button type="button" class="btn btn-danger" onclick="undo_rollback()" id="rollback-btn">Cancel rollback</button>'
|
||||
} else {
|
||||
document.getElementById('rollback-btn').outerHTML =
|
||||
'<button type="button" class="btn btn-danger" id="rollback-btn" disabled>Failed</button>'
|
||||
setTimeout(() => document.getElementById('rollback-btn').outerHTML =
|
||||
'<button type="button" class="btn btn-danger" onclick="rollback()" id="rollback-btn">Rollback</button>', 2000)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function undo_rollback() {
|
||||
let undo_rollback_worker = new Worker(
|
||||
`data:text/javascript,
|
||||
let s = require('child_process').spawnSync('pkexec', ['rm', '-f', '/blend/states/.load_prev_state']).status
|
||||
if (s === 0) {
|
||||
postMessage('success')
|
||||
} else {
|
||||
postMessage('failure')
|
||||
}
|
||||
`
|
||||
)
|
||||
undo_rollback_worker.onmessage = e => {
|
||||
if (e.data == 'success') {
|
||||
document.getElementById('rollback-btn').outerHTML =
|
||||
'<button type="button" class="btn btn-danger" onclick="rollback()" id="rollback-btn">Rollback</button>'
|
||||
} else {
|
||||
document.getElementById('rollback-btn').outerHTML =
|
||||
'<button type="button" class="btn btn-danger" id="rollback-btn" disabled>Failed</button>'
|
||||
setTimeout(() => document.getElementById('rollback-btn').outerHTML =
|
||||
'<button type="button" class="btn btn-danger" onclick="undo_rollback()" id="rollback-btn">Cancel rollback</button>', 2000)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function save_state() {
|
||||
let save_state_worker = new Worker(
|
||||
`data:text/javascript,
|
||||
let s = require('child_process').spawnSync('pkexec', ['blend-system', 'save-state']).status
|
||||
if (s === 0) {
|
||||
postMessage('success')
|
||||
} else {
|
||||
postMessage('failure')
|
||||
}
|
||||
`
|
||||
)
|
||||
save_state_worker.onmessage = e => {
|
||||
if (e.data == 'success') {
|
||||
document.getElementById('save-state-btn').outerHTML =
|
||||
'<button type="button" class="btn btn-success" id="save-state-btn" disabled>Saved state</button>'
|
||||
setTimeout(() => document.getElementById('save-state-btn').outerHTML =
|
||||
'<button type="button" id="save-state-btn" onclick="save_state()" class="btn btn-success">Save state</button>', 2000)
|
||||
} else {
|
||||
document.getElementById('save-state-btn').outerHTML =
|
||||
'<button type="button" class="btn btn-success" id="save-state-btn" disabled>Failed</button>'
|
||||
setTimeout(() => document.getElementById('save-state-btn').outerHTML =
|
||||
'<button type="button" id="save-state-btn" onclick="save_state()" class="btn btn-success">Save state</button>', 2000)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function check_rollback() {
|
||||
if (require('fs').existsSync('/blend/states/.load_prev_state')) {
|
||||
document.getElementById('rollback-btn').outerHTML =
|
||||
'<button type="button" class="btn btn-danger" onclick="undo_rollback()" id="rollback-btn">Cancel rollback</button>'
|
||||
} else {
|
||||
document.getElementById('rollback-btn').outerHTML =
|
||||
'<button type="button" class="btn btn-danger" onclick="rollback()" id="rollback-btn">Rollback</button>'
|
||||
}
|
||||
}
|
||||
|
||||
function check_state_creation() {
|
||||
if (require('fs').existsSync('/blend/states/.disable_states')) {
|
||||
document.getElementById('automatic-state-toggle').setAttribute('checked', '')
|
||||
}
|
||||
}
|
||||
|
||||
check_state_creation()
|
||||
check_rollback()
|
||||
|
||||
$('#automatic-state-toggle').on('change', () => {
|
||||
if (!document.getElementById('automatic-state-toggle').checked) {
|
||||
let enable_autostate_worker = new Worker(
|
||||
`data:text/javascript,
|
||||
let s = require('child_process').spawnSync('pkexec', ['rm', '-f', '/blend/states/.disable_states']).status
|
||||
if (s === 0) {
|
||||
postMessage('success')
|
||||
} else {
|
||||
postMessage('failure')
|
||||
}
|
||||
`
|
||||
)
|
||||
enable_autostate_worker.onmessage = e => {
|
||||
if (e.data == 'success') {
|
||||
document.getElementById('automatic-state-toggle').checked = false
|
||||
} else {
|
||||
document.getElementById('automatic-state-toggle').checked = true
|
||||
}
|
||||
}
|
||||
} else {
|
||||
let disable_autostate_worker = new Worker(
|
||||
`data:text/javascript,
|
||||
let s = require('child_process').spawnSync('pkexec', ['blend-system', 'toggle-states']).status
|
||||
if (s === 0) {
|
||||
postMessage('success')
|
||||
} else {
|
||||
postMessage('failure')
|
||||
}
|
||||
`
|
||||
)
|
||||
disable_autostate_worker.onmessage = e => {
|
||||
if (e.data == 'success') {
|
||||
document.getElementById('automatic-state-toggle').checked = true
|
||||
} else {
|
||||
document.getElementById('automatic-state-toggle').checked = false
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
49
blend-settings/src/pages/containers.html
Normal file
49
blend-settings/src/pages/containers.html
Normal file
|
@ -0,0 +1,49 @@
|
|||
<div class="container-fluid d-flex justify-content-center">
|
||||
<div class="col-12 col-lg-10 col-xl-8 mx-auto">
|
||||
<strong class="mb-0">Containers</strong>
|
||||
<p>You can install any app from any of the supported distributions (Arch, Fedora, and Ubuntu). Any apps you install in them will appear as regular applications on your system, and so will any binaries. In case a binary is common between two containers, the binary from the most recently created container will be exported. You can override this by rearranging (dragging) the containers below to select the priority that should be assigned to each container.</p>
|
||||
<div class="list-group mb-5 shadow" id="container-list">
|
||||
<div class="list-group-item">
|
||||
<div class="row align-items-center">
|
||||
<div class="col">
|
||||
<strong class="mb-0">Loading list of containers.</strong>
|
||||
<p class="text-muted mb-0">You'll find a list of all the containers here.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="container-fluid d-flex justify-content-center">
|
||||
<div class="col-12 col-lg-10 col-xl-8 mx-auto">
|
||||
<strong class="mb-0">Create new container</strong>
|
||||
<form onsubmit="create_container(); return false">
|
||||
<div class="form-group row">
|
||||
<label for="inputContainerName" class="col-sm-3 col-form-label">Container name</label>
|
||||
<div class="col-sm-4">
|
||||
<input type="text" class="form-control" id="inputContainerName" placeholder="Container name" required>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<label for="inputContainerDistro" class="col-sm-3 col-form-label">Distribution</label>
|
||||
<div class="col-sm-4">
|
||||
<select class="form-control" id="inputContainerDistro">
|
||||
<option selected>Arch</option>
|
||||
<option>Fedora Rawhide</option>
|
||||
<option>Ubuntu 22.04</option>
|
||||
<option>Ubuntu 22.10</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<br>
|
||||
<button type="submit" id="publish-button" class="btn btn-primary">Create container</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Import generic page JS. -->
|
||||
<script src="internal/js/generic_page.js"></script>
|
||||
|
||||
<!-- Import containers JS. -->
|
||||
<script src="internal/js/containers.js"></script>
|
64
blend-settings/src/pages/overlay.html
Normal file
64
blend-settings/src/pages/overlay.html
Normal file
|
@ -0,0 +1,64 @@
|
|||
<div class="container-fluid d-flex justify-content-center">
|
||||
<div class="col-12 col-lg-10 col-xl-8 mx-auto">
|
||||
<strong class="mb-0">System Settings</strong>
|
||||
<br><br>
|
||||
<div class="list-group mb-5 shadow">
|
||||
<div class="list-group-item">
|
||||
<div class="row align-items-center">
|
||||
<div class="col">
|
||||
<strong class="mb-0">Disable automatic state creation</strong>
|
||||
<p class="text-muted mb-0">blendOS creates copies of apps and config every 6 hours (and keeps the
|
||||
last two).</p>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<div class="form-check form-switch align-middle">
|
||||
<input class="form-check-input align-middle" type="checkbox" role="switch"
|
||||
id="automatic-state-toggle">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="list-group-item">
|
||||
<div class="row align-items-center">
|
||||
<div class="col">
|
||||
<strong class="mb-0">Save current state</strong>
|
||||
<p class="text-muted mb-0">Create a copy of the current system state, including apps and config.</p>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<div class="form-check form-switch align-middle">
|
||||
<button type="button" id="save-state-btn" onclick="save_state()" class="btn btn-success">Save state</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="list-group-item">
|
||||
<div class="row align-items-center">
|
||||
<div class="col">
|
||||
<strong class="mb-0">Rollback</strong>
|
||||
<p class="text-muted mb-0">Rollback to the most recent state on the next boot. (note: this is irreversible)
|
||||
</p>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<div class="form-check form-switch align-middle">
|
||||
<button type="button" class="btn btn-danger" onclick="rollback()" id="rollback-btn">Rollback</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="container-fluid d-flex justify-content-center">
|
||||
<div class="col-12 col-lg-10 col-xl-8 mx-auto">
|
||||
<p>
|
||||
You can install packages just like you would on a regular Arch system, or install them in containers.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Import generic page JS. -->
|
||||
<script src="internal/js/generic_page.js"></script>
|
||||
|
||||
<!-- Import overlay JS. -->
|
||||
<script src="internal/js/overlay.js"></script>
|
110
blend-settings/src/pages/terminal.html
Normal file
110
blend-settings/src/pages/terminal.html
Normal file
|
@ -0,0 +1,110 @@
|
|||
<html>
|
||||
|
||||
<head>
|
||||
<link rel="stylesheet" href="../../node_modules/xterm/css/xterm.css" />
|
||||
<style>
|
||||
html,
|
||||
body,
|
||||
#term {
|
||||
margin: 0;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
background-color: #242430;
|
||||
}
|
||||
|
||||
.xterm {
|
||||
padding: 30px !important;
|
||||
}
|
||||
|
||||
*,
|
||||
*::before,
|
||||
*::after {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
*::-webkit-scrollbar-track {
|
||||
background-color: rgb(36, 36, 48);
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
*::-webkit-scrollbar {
|
||||
width: 5px;
|
||||
background-color: rgb(36, 36, 48);
|
||||
}
|
||||
|
||||
*::-webkit-scrollbar-thumb {
|
||||
background-color: rgb(61, 61, 74);
|
||||
border-radius: 10px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body style="height: 100%;">
|
||||
<div id="term" style="height: 100%; width: 100%;"></div>
|
||||
<script>
|
||||
var os = require("os");
|
||||
var pty = require("node-pty");
|
||||
var xterm = require("xterm");
|
||||
var ipc = require("electron").ipcRenderer;
|
||||
var { FitAddon } = require("xterm-addon-fit");
|
||||
|
||||
const fit = new FitAddon();
|
||||
|
||||
var once;
|
||||
|
||||
function create_term() {
|
||||
ipc.removeAllListeners('terminal.reset')
|
||||
ipc.removeAllListeners('terminal.keystroke')
|
||||
ipc.removeAllListeners('terminal.incomingData')
|
||||
ipc.removeAllListeners('title')
|
||||
|
||||
ipc.on("terminal.reset", (event, data) => {
|
||||
document.getElementById('term').innerHTML = ''
|
||||
create_term()
|
||||
});
|
||||
|
||||
var term = new xterm.Terminal({
|
||||
fontSize: 14,
|
||||
experimentalCharAtlas: 'dynamic',
|
||||
theme: {
|
||||
background: '#242430'
|
||||
}
|
||||
});
|
||||
|
||||
once = true
|
||||
|
||||
term.loadAddon(fit)
|
||||
|
||||
var term_e = document.getElementById('term');
|
||||
term.open(term_e);
|
||||
fit.fit()
|
||||
|
||||
ipc.on("terminal.incomingData", (event, data) => {
|
||||
term.write(data);
|
||||
});
|
||||
|
||||
ipc.on("title", (event, title) => {
|
||||
document.title = title;
|
||||
});
|
||||
|
||||
window.addEventListener('beforeunload', (event) => {
|
||||
term.dispose()
|
||||
})
|
||||
|
||||
window.onresize = function () {
|
||||
fit.fit();
|
||||
term.resize(term.cols, term.rows)
|
||||
ipc.send("terminal.resize", [term.cols, term.rows])
|
||||
};
|
||||
|
||||
term.onData(e => {
|
||||
ipc.send("terminal.keystroke", e);
|
||||
});
|
||||
}
|
||||
|
||||
ipc.on("terminal.reset", (event) => create_term)
|
||||
create_term()
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
0
blend-settings/src/preload.js
Normal file
0
blend-settings/src/preload.js
Normal file
183
blend-system
Executable file
183
blend-system
Executable file
|
@ -0,0 +1,183 @@
|
|||
#!/usr/bin/env python3
|
||||
# Copyright (C) 2023 Rudra Saraswat
|
||||
#
|
||||
# This file is part of blend.
|
||||
#
|
||||
# blend is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# blend is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with blend. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
import os, re, sys, time
|
||||
import argparse
|
||||
import subprocess
|
||||
|
||||
__version = '2.0.0'
|
||||
|
||||
### Colors
|
||||
class colors:
|
||||
reset = '\033[0m'
|
||||
bold = '\033[01m'
|
||||
disable = '\033[02m'
|
||||
underline = '\033[04m'
|
||||
reverse = '\033[07m'
|
||||
strikethrough = '\033[09m'
|
||||
invisible = '\033[08m'
|
||||
|
||||
class fg:
|
||||
black = '\033[30m'
|
||||
red = '\033[31m'
|
||||
green = '\033[32m'
|
||||
orange = '\033[33m'
|
||||
blue = '\033[34m'
|
||||
purple = '\033[35m'
|
||||
cyan = '\033[36m'
|
||||
lightgrey = '\033[37m'
|
||||
darkgrey = '\033[90m'
|
||||
lightred = '\033[91m'
|
||||
lightgreen = '\033[92m'
|
||||
yellow = '\033[93m'
|
||||
lightblue = '\033[94m'
|
||||
pink = '\033[95m'
|
||||
lightcyan = '\033[96m'
|
||||
|
||||
class bg:
|
||||
black = '\033[40m'
|
||||
red = '\033[41m'
|
||||
green = '\033[42m'
|
||||
orange = '\033[43m'
|
||||
blue = '\033[44m'
|
||||
purple = '\033[45m'
|
||||
cyan = '\033[46m'
|
||||
lightgrey = '\033[47m'
|
||||
|
||||
### END
|
||||
|
||||
### Helper functions
|
||||
|
||||
def info(msg):
|
||||
print (colors.bold + colors.fg.cyan + '>> i: ' + colors.reset + colors.bold + msg + colors.reset)
|
||||
|
||||
def error(err):
|
||||
print (colors.bold + colors.fg.red + '>> e: ' + colors.reset + colors.bold + err + colors.reset)
|
||||
|
||||
def load_prev_state():
|
||||
subprocess.call(['rm', '-rf', '/blend/overlay/current'], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
||||
subprocess.call(['mkdir', '-p', '/blend/overlay/current/usr'], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
||||
subprocess.call(['tar', '-xvpzf', f'/blend/states/state{current_state()}.tar.gz', '-C', '/blend/overlay/current/usr', '--numeric-owner'],
|
||||
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
||||
subprocess.call(['rm', '-f', f'/blend/states/state{current_state()}.tar.gz'], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
||||
|
||||
### END
|
||||
|
||||
def current_state():
|
||||
_state = -1
|
||||
for s in os.listdir('/blend/states'):
|
||||
if re.match(r'^state([0-9]+)\.tar\.gz$', s):
|
||||
if int(s[5:-7]) > _state:
|
||||
_state = int(s[5:-7])
|
||||
return _state
|
||||
|
||||
def load_overlay():
|
||||
if os.path.isfile('/blend/states/.load_prev_state') and os.path.isfile(f'/blend/states/state{current_state()}.tar.gz'):
|
||||
load_prev_state()
|
||||
os.remove('/blend/states/.load_prev_state')
|
||||
subprocess.call(['mkdir', '-p', '/blend/overlay/current/usr'], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
||||
subprocess.call(['rm', '-rf', '/blend/overlay/workdir'], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
||||
subprocess.call(['mkdir', '-p', '/blend/overlay/workdir'], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
||||
subprocess.call(['touch', '/blend/overlay/current/usr/.blend_overlay'], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
||||
subprocess.call(['chattr', '+i', '/blend/overlay/current/usr/.blend_overlay'], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
||||
subprocess.call(['mount', '-t', 'overlay', 'overlay', '-o', 'rw,lowerdir=/usr,upperdir=/blend/overlay/current/usr,workdir=/blend/overlay/workdir',
|
||||
'/usr', '-o', 'index=off'], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
||||
info('mounted overlay')
|
||||
|
||||
def save_state():
|
||||
subprocess.call(['mkdir', '-p', '/blend/states'], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
||||
state = current_state() + 1
|
||||
|
||||
subprocess.call(r"find /blend/states/ -type f -not -name 'state" + str(state - 1) + ".tar.gz' -print0 | xargs -0 -I {} rm {}", stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, shell=True)
|
||||
subprocess.call(['tar', '-C', '/blend/overlay/current/usr', '-cpzf', f'/blend/states/state{state}.tar.gz', '.'], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
||||
info(f'saved state {state}')
|
||||
|
||||
def autosave_state():
|
||||
while True:
|
||||
if not os.path.isfile('/blend/states/.disable_states'):
|
||||
save_state()
|
||||
time.sleep(6*60*60) # XXX: make this configurable
|
||||
|
||||
def toggle_states():
|
||||
if os.path.isfile('/blend/states/.disable_states'):
|
||||
os.remove('/blend/states/.disable_states')
|
||||
info('enabled saving states automatically (every 6 hours; this will be configurable in future releases)')
|
||||
else:
|
||||
subprocess.call(['touch', '/blend/states/.disable_states'], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
||||
info('disabled saving states automatically')
|
||||
|
||||
def rollback():
|
||||
if current_state() == -1:
|
||||
error('no states present')
|
||||
exit(1)
|
||||
subprocess.call(['touch', '/blend/states/.load_prev_state'], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
||||
info(f'will rollback to the previous state on the next boot')
|
||||
|
||||
description = f'''
|
||||
{colors.bold}{colors.fg.purple}Usage:{colors.reset}
|
||||
blend-system [command] [options] [arguments]
|
||||
|
||||
{colors.bold}{colors.fg.purple}Version:{colors.reset} {__version}{colors.bold}
|
||||
|
||||
{colors.bold}{colors.fg.purple}available commands{colors.reset}:
|
||||
{colors.bold}help{colors.reset} Show this help message and exit.
|
||||
{colors.bold}version{colors.reset} Show version information and exit.
|
||||
{colors.bold}load-overlay{colors.reset} Load the current overlay.
|
||||
{colors.bold}save-state{colors.reset} Save the current state (backup).
|
||||
{colors.bold}toggle-states{colors.reset} Enable/disable automatic state creation (you can still manually save states).
|
||||
{colors.bold}rollback{colors.reset} Rollback to previous state.
|
||||
|
||||
{colors.bold}{colors.fg.purple}options for commands{colors.reset}:
|
||||
{colors.bold}-v, --version{colors.reset} show version information and exit
|
||||
'''
|
||||
|
||||
epilog = f'''
|
||||
{colors.bold}Made with {colors.fg.red}\u2764{colors.reset}{colors.bold} by Rudra Saraswat.{colors.reset}
|
||||
'''
|
||||
|
||||
parser = argparse.ArgumentParser(description=description, usage=argparse.SUPPRESS,
|
||||
epilog=epilog, formatter_class=argparse.RawTextHelpFormatter)
|
||||
command_map = { 'help': 'help',
|
||||
'version': 'version',
|
||||
'load-overlay': load_overlay,
|
||||
'save-state': save_state,
|
||||
'toggle-states': toggle_states,
|
||||
'autosave-state': autosave_state,
|
||||
'rollback': rollback }
|
||||
parser.add_argument('command', choices=command_map.keys(), help=argparse.SUPPRESS)
|
||||
parser.add_argument('-v', '--version', action='version', version=f'%(prog)s {__version}', help=argparse.SUPPRESS)
|
||||
|
||||
if len(sys.argv) == 1:
|
||||
parser.print_help()
|
||||
exit()
|
||||
|
||||
if os.geteuid() != 0:
|
||||
error('requires root')
|
||||
exit(1)
|
||||
|
||||
args = parser.parse_intermixed_args()
|
||||
|
||||
command = command_map[args.command]
|
||||
|
||||
if command == 'help':
|
||||
parser.print_help()
|
||||
elif command == 'version':
|
||||
parser.parse_args(['--version'])
|
||||
else:
|
||||
command()
|
10
blend-system.service
Normal file
10
blend-system.service
Normal file
|
@ -0,0 +1,10 @@
|
|||
[Unit]
|
||||
Description=Save system state
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
ExecStart=/usr/bin/blend-system autosave-state
|
||||
User=root
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
22
blend.hook
Normal file
22
blend.hook
Normal file
|
@ -0,0 +1,22 @@
|
|||
#!/bin/bash
|
||||
|
||||
run_latehook() {
|
||||
if [[ -f /new_root/blend/states/.load_prev_state ]] && compgen -G "/new_root/blend/states/state+([0-9]).tar.gz" >/dev/null; then
|
||||
rm -rf /new_root/blend/overlay/current
|
||||
mkdir -p /new_root/blend/overlay/current/usr
|
||||
c=0
|
||||
for i in $(compgen -G "/new_root/blend/states/state*.tar.gz"); do
|
||||
n="${i:19:-7}"
|
||||
if [[ "$n" -gt "$c" ]]; then
|
||||
c="$n"
|
||||
fi
|
||||
done
|
||||
tar -xvpzf "/new_root/blend/states/state${c}.tar.gz" -C "/new_root/blend/overlay/current/usr" --numeric-owner &>/dev/null
|
||||
rm -f "/new_root/blend/states/state${c}.tar.gz" "/new_root/blend/states/.load_prev_state"
|
||||
fi
|
||||
|
||||
mkdir -p /new_root/blend/overlay/current/usr /new_root/usr
|
||||
rm -rf /new_root/blend/overlay/workdir
|
||||
mkdir -p /new_root/blend/overlay/workdir
|
||||
mount -t overlay overlay -o 'lowerdir=/new_root/usr,upperdir=/new_root/blend/overlay/current/usr,workdir=/new_root/blend/overlay/workdir' /new_root/usr -o index=off
|
||||
}
|
18
blend.install
Normal file
18
blend.install
Normal file
|
@ -0,0 +1,18 @@
|
|||
#!/usr/bin/env bash
|
||||
# SPDX-License-Identifier: GPL-3.0
|
||||
|
||||
build() {
|
||||
add_module overlay
|
||||
add_binary bash
|
||||
add_binary tar
|
||||
add_runscript
|
||||
}
|
||||
|
||||
help() {
|
||||
cat <<HELPEOF
|
||||
This provides a support for mounting the blend /usr overlay. No
|
||||
configuration is needed.
|
||||
HELPEOF
|
||||
}
|
||||
|
||||
# vim: set ft=sh ts=4 sw=4 et:
|
|
@ -1,17 +0,0 @@
|
|||
#/usr/bin/env bash
|
||||
|
||||
set +e
|
||||
|
||||
_completions() {
|
||||
SUGGESTIONS=()
|
||||
|
||||
if [[ "$COMP_CWORD" == 1 ]]; then
|
||||
SUGGESTIONS=('install' 'remove' 'update' 'show' 'search' 'enter' 'create-container' 'remove-container' \
|
||||
'install-de' 'list-containers' 'start-containers' 'sync' 'help' 'version' 'export' 'unexport' 'system-update' \
|
||||
'--container-name=' '--distro=' '--noconfirm' '--version')
|
||||
fi
|
||||
|
||||
COMPREPLY=($(compgen -W "${SUGGESTIONS[*]}" -- "${COMP_WORDS[$COMP_CWORD]}"))
|
||||
}
|
||||
|
||||
complete -F _completions -- blend
|
36
host-blend
Executable file
36
host-blend
Executable file
|
@ -0,0 +1,36 @@
|
|||
#!/bin/sh
|
||||
# Copyright (C) 2023 Rudra Saraswat
|
||||
#
|
||||
# This file is part of blend.
|
||||
#
|
||||
# blend is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# blend is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with blend. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
[ -f /run/.containerenv ] || echo 'not running in a blend container'
|
||||
[ -f /run/.containerenv ] || exit 1
|
||||
|
||||
args=""
|
||||
|
||||
if [ ! -t 1 ] || [ "$(basename $0)" == xdg-open ] || [ "$(basename $0)" == gio ]; then
|
||||
args="${args} --no-pty"
|
||||
fi
|
||||
|
||||
if [ "$(basename $0)" == host-blend ]; then
|
||||
if [ "$#" -ne 1 ]; then
|
||||
host-spawn $args sh; exit $?
|
||||
else
|
||||
host-spawn $args "$@"; exit $?
|
||||
fi
|
||||
else
|
||||
host-spawn $args "$(basename $0)" "$@"; exit $?
|
||||
fi
|
257
init-blend
Executable file
257
init-blend
Executable file
|
@ -0,0 +1,257 @@
|
|||
#!/usr/bin/env bash
|
||||
# Copyright (C) 2023 Rudra Saraswat
|
||||
#
|
||||
# This file is part of blend.
|
||||
#
|
||||
# blend is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# blend is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with blend. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
if [ ! -f '/run/.containerenv' ]; then
|
||||
echo 'not running in container'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
while true; do
|
||||
case $1 in
|
||||
--uid)
|
||||
if [ -n "$2" ]; then
|
||||
_cuid="$2"
|
||||
shift
|
||||
shift
|
||||
fi
|
||||
;;
|
||||
--group)
|
||||
if [ -n "$2" ]; then
|
||||
_cgid="$2"
|
||||
shift
|
||||
shift
|
||||
fi
|
||||
;;
|
||||
--username)
|
||||
if [ -n "$2" ]; then
|
||||
_uname="$2"
|
||||
shift
|
||||
shift
|
||||
fi
|
||||
;;
|
||||
--home)
|
||||
if [ -n "$2" ]; then
|
||||
_uhome="$2"
|
||||
shift
|
||||
shift
|
||||
fi
|
||||
;;
|
||||
-*)
|
||||
exit 1
|
||||
;;
|
||||
*)
|
||||
break
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
cat << 'EOF'
|
||||
|
||||
|
||||
▄▄▄▄ ██▓ ▓█████ ███▄ █ ▓█████▄
|
||||
▓█████▄ ▓██▒ ▓█ ▀ ██ ▀█ █ ▒██▀ ██▌
|
||||
▒██▒ ▄██▒██░ ▒███ ▓██ ▀█ ██▒░██ █▌
|
||||
▒██░█▀ ▒██░ ▒▓█ ▄ ▓██▒ ▐▌██▒░▓█▄ ▌
|
||||
░▓█ ▀█▓░██████▒░▒████▒▒██░ ▓██░░▒████▓
|
||||
░▒▓███▀▒░ ▒░▓ ░░░ ▒░ ░░ ▒░ ▒ ▒ ▒▒▓ ▒
|
||||
▒░▒ ░ ░ ░ ▒ ░ ░ ░ ░░ ░░ ░ ▒░ ░ ▒ ▒
|
||||
░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░
|
||||
░ ░ ░ ░ ░ ░ ░
|
||||
░ ░
|
||||
|
||||
EOF
|
||||
|
||||
echo
|
||||
echo 'Starting blend... (this may take a few minutes)'
|
||||
echo
|
||||
|
||||
bmount() {
|
||||
! [[ -d "$1" ]] && ! [[ -f "$1" ]] && return 0 # check if source dir exists
|
||||
! [[ -e "$2" ]] && findmnt "$2" &>/dev/null && umount "$2" # unmount target dir if a mount
|
||||
|
||||
[[ -d "$1" ]] && mkdir -p "$2" # create target dir if source is a dir
|
||||
[[ -f "$1" ]] && touch "$2" # create target file if source is a file
|
||||
|
||||
mountflags="rslave"
|
||||
|
||||
! [[ -z "$3" ]] && mountflags="$3"
|
||||
|
||||
mount --rbind -o "$mountflags" "$1" "$2" &>/dev/null
|
||||
}
|
||||
|
||||
if [[ ! -f '/.init_blend.lock' ]]; then
|
||||
|
||||
###
|
||||
|
||||
if command -v apt-get &>/dev/null; then
|
||||
apt-get update &>/dev/null
|
||||
DEBIAN_FRONTEND=noninteractive apt-get -y install bash bc curl less wget apt-utils apt-transport-https dialog \
|
||||
diffutils findutils gnupg2 sudo time util-linux libnss-myhostname \
|
||||
libvte-2.9[0-9]-common libvte-common lsof ncurses-base passwd \
|
||||
pinentry-curses libegl1-mesa libgl1-mesa-glx libvulkan1 mesa-vulkan-drivers &>/dev/null
|
||||
elif command -v pacman &>/dev/null; then
|
||||
pacman --noconfirm -Syyu &>/dev/null
|
||||
pacman --noconfirm -Sy bash bc curl wget diffutils findutils gnupg sudo time util-linux vte-common lsof ncurses pinentry \
|
||||
mesa opengl-driver vulkan-intel vulkan-radeon &>/dev/null
|
||||
elif command -v dnf &>/dev/null; then
|
||||
dnf install -y --allowerasing bash bc curl wget diffutils findutils dnf-plugins-core gnupg2 less lsof passwd pinentry \
|
||||
procps-ng vte-profile ncurses util-linux sudo time shadow-utils vulkan mesa-vulkan-drivers \
|
||||
mesa-dri-drivers &>/dev/null
|
||||
|
||||
fi
|
||||
|
||||
mkdir -p /usr/local/bin
|
||||
wget -O /usr/local/bin/host-spawn "https://github.com/1player/host-spawn/releases/latest/download/host-spawn-$(uname -m)" &>/dev/null
|
||||
chmod 755 /usr/local/bin/host-spawn
|
||||
|
||||
fi
|
||||
|
||||
###
|
||||
|
||||
for i in /var/log/journal /var/lib/systemd/coredump /var/lib/flatpak; do
|
||||
bmount "/run/host/${i}" "$i" ro
|
||||
done
|
||||
|
||||
for i in /etc/host.conf /run/media /media /mnt /var/mnt \
|
||||
/run/libvirt /etc/machine-id /run/netconfig/ /run/udev \
|
||||
/run/systemd/journal /run/systemd/seats /run/systemd/sessions \
|
||||
/run/systemd/users /run/systemd/resolve/ /srv /var/lib/libvirt; do
|
||||
bmount "/run/host/${i}" "$i" rw
|
||||
done
|
||||
|
||||
init_ro_mounts="
|
||||
/run/systemd/journal
|
||||
/var/log/journal
|
||||
/run/systemd/resolve
|
||||
/run/systemd/seats
|
||||
/run/systemd/sessions
|
||||
/run/systemd/users
|
||||
/var/lib/systemd/coredump
|
||||
/etc/localtime"
|
||||
|
||||
### Section START https://github.com/89luca89/distrobox/blob/main/distrobox-init#L772
|
||||
host_sockets="$(find /run/host/run -name 'user' \
|
||||
-prune -o -path /run/host/run/media \
|
||||
-prune -o -name 'nscd' \
|
||||
-prune -o -name 'bees' \
|
||||
-prune -o -name 'system_bus_socket' \
|
||||
-prune -o -type s -print \
|
||||
2> /dev/null || :)"
|
||||
### Section END
|
||||
|
||||
for i in ${host_sockets}; do
|
||||
container_socket="$(echo -n "$i" | sed 's/\/run\/host//g')"
|
||||
if [ ! -S "${container_socket}" ] && [ ! -L "${container_socket}" ]; then
|
||||
rm -f "${container_socket}"
|
||||
mkdir -p "$(dirname "${container_socket}")"
|
||||
ln -s "$i" "${container_socket}"
|
||||
fi
|
||||
done
|
||||
|
||||
bmount "/run/host/usr/share/themes" "/usr/local/share/themes" ro
|
||||
bmount "/run/host/usr/share/icons" "/usr/local/share/icons" ro
|
||||
bmount "/run/host/usr/share/fonts" "/usr/local/share/fonts" ro
|
||||
|
||||
bmount "/usr/bin/host-blend" "/usr/bin/blend" ro
|
||||
|
||||
# sudo touch /.init_blend.lock
|
||||
|
||||
if [[ ! -f '/.init_blend.lock' ]]; then
|
||||
|
||||
### Section START (based on https://github.com/89luca89/distrobox/blob/main/distrobox-init#L816)
|
||||
|
||||
if [ -d "/usr/lib/rpm/" ]; then
|
||||
mkdir -p /usr/lib/rpm/macros.d
|
||||
net_mounts=""
|
||||
for net_mount in \
|
||||
${HOST_MOUNTS_RO} ${HOST_MOUNTS} \
|
||||
'/dev' '/proc' '/sys' '/tmp' \
|
||||
'/etc/host.conf' '/etc/hosts' '/etc/resolv.conf' '/etc/localtime' \
|
||||
'/usr/share/zoneinfo'; do
|
||||
|
||||
net_mounts="${net_mount}:${net_mounts}"
|
||||
|
||||
done
|
||||
net_mounts=${net_mounts%?}
|
||||
echo "%_netsharedpath ${net_mounts}" > /usr/lib/rpm/macros.d/macros.blend
|
||||
elif [ -d "/etc/dpkg/" ]; then
|
||||
mkdir -p /etc/dpkg/dpkg.cfg.d
|
||||
echo -n > /etc/dpkg/dpkg.cfg.d/00_blend
|
||||
for net_mount in ${HOST_MOUNTS_RO} ${HOST_MOUNTS} '/etc/hosts' '/etc/resolv.conf' '/etc/localtime'; do
|
||||
printf "path-exclude %s/*\n" "${net_mount}" >> /etc/dpkg/dpkg.cfg.d/00_blend
|
||||
done
|
||||
### Section END
|
||||
elif [ -d "/usr/share/libalpm/scripts" ]; then
|
||||
echo "#!/bin/sh" > /usr/share/libalpm/scripts/00_blend_pre_hook.sh
|
||||
echo "#!/bin/sh" > /usr/share/libalpm/scripts/01_blend_post_hook.sh
|
||||
echo "#!/bin/sh" > /usr/share/libalpm/scripts/02_blend_post_hook.sh
|
||||
|
||||
for net_mount in ${HOST_MOUNTS_RO}; do
|
||||
echo "findmnt ${net_mount} &>/dev/null && umount ${net_mount} || :" >> /usr/share/libalpm/scripts/00_blend_pre_hook.sh
|
||||
echo "test -e /run/host/${net_mount} && mount --rbind -o ro /run/host/${net_mount} ${net_mount} || :" >> /usr/share/libalpm/scripts/02_blend_post_hook.sh
|
||||
done
|
||||
|
||||
echo -e '#!/bin/sh\necho -e "#!/bin/sh\nexit 0" > /usr/share/libalpm/scripts/systemd-hook' >/usr/share/libalpm/scripts/01_blend_post_hook.sh
|
||||
|
||||
chmod 755 /usr/share/libalpm/scripts/*blend*.sh
|
||||
|
||||
for p in 00_blend_pre_hook 01_blend_post_hook.sh 02_blend_post_hook; do
|
||||
when=PostTransaction
|
||||
|
||||
[[ -z "${p##*pre*}" ]] && when=PreTransaction
|
||||
cat << EOF > "/usr/share/libalpm/hooks/${p}.hook"
|
||||
[Trigger]
|
||||
Operation = Install
|
||||
Operation = Upgrade
|
||||
Type = Package
|
||||
Target = *
|
||||
[Action]
|
||||
Description = blend ${p}
|
||||
When = ${when}
|
||||
Exec = /usr/share/libalpm/scripts/${p}.sh
|
||||
EOF
|
||||
done
|
||||
fi
|
||||
|
||||
mkdir -p /etc/sudoers.d
|
||||
if ! grep -q 'Defaults !fqdn' /etc/sudoers.d/sudoers &>/dev/null; then
|
||||
printf "Defaults !fqdn\n" >> /etc/sudoers.d/sudoers
|
||||
fi
|
||||
if ! grep -q "\"${_uname}\" ALL = (root) NOPASSWD:ALL" /etc/sudoers.d/sudoers &>/dev/null; then
|
||||
printf "\"%s\" ALL = (root) NOPASSWD:ALL\n" "$_uname" >> /etc/sudoers.d/sudoers
|
||||
fi
|
||||
if ! grep -q "^${_uname}:" /etc/group; then
|
||||
if ! groupadd --force --gid "$_cgid" "$_uname"; then
|
||||
printf "%s:x:%s:" "$_uname" "$_cgid" >> /etc/group
|
||||
fi
|
||||
fi
|
||||
useradd --uid "$_cuid" --gid "$_cgid" --shell "/bin/bash" --no-create-home --home "$_uhome" "$_uname" &>/dev/null
|
||||
|
||||
fi
|
||||
|
||||
touch /.init_blend.lock
|
||||
|
||||
echo
|
||||
echo "Completed container setup."
|
||||
|
||||
while true; do
|
||||
for i in /etc/hosts /etc/localtime /etc/resolv.conf; do
|
||||
cp "/run/host/${i}" / &>/dev/null || :
|
||||
done
|
||||
sleep 5
|
||||
done
|
|
@ -1,6 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
BLEND_COMMAND="sudo apt $@" blend enter ubuntu-22.10 --distro ubuntu-22.10
|
||||
ret=$?
|
||||
|
||||
exit $ret
|
|
@ -1,6 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
BLEND_COMMAND="sudo apt-get $@" blend enter ubuntu-22.10 --distro ubuntu-22.10
|
||||
ret=$?
|
||||
|
||||
exit $ret
|
|
@ -1,6 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
BLEND_COMMAND="sudo dnf $@" blend enter fedora-rawhide --distro fedora-rawhide
|
||||
ret=$?
|
||||
|
||||
exit $ret
|
|
@ -1,10 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
[[ -z "$SUDO_USER" ]] || {
|
||||
[[ "$SUDO_USER" == root ]] || { SUDO_USER= sudo -u "$SUDO_USER" "$0" "$@"; exit $?; }
|
||||
}
|
||||
|
||||
BLEND_COMMAND="sudo pacman $@" blend enter arch
|
||||
ret=$?
|
||||
|
||||
exit $ret
|
|
@ -1,6 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
BLEND_COMMAND="yay $@" blend enter arch
|
||||
ret=$?
|
||||
|
||||
exit $ret
|
|
@ -1,6 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
BLEND_COMMAND="sudo yum $@" blend enter fedora-rawhide --distro fedora-rawhide
|
||||
ret=$?
|
||||
|
||||
exit $ret
|
Loading…
Reference in a new issue