Repository: openSUSE/opi
Branch: master
Commit: 229986eb1dc8
Files: 81
Total size: 150.6 KB
Directory structure:
gitextract_fb_mcbpx/
├── .github/
│ ├── ISSUE_TEMPLATE/
│ │ ├── bug_report.md
│ │ └── feature_request.md
│ └── workflows/
│ └── ci.yaml
├── .gitignore
├── LICENSE
├── README.md
├── bin/
│ └── opi
├── opi/
│ ├── __init__.py
│ ├── config/
│ │ └── __init__.py
│ ├── deb.py
│ ├── github.py
│ ├── http.py
│ ├── pager.py
│ ├── plugins/
│ │ ├── __init__.py
│ │ ├── antigravity.py
│ │ ├── anydesk.py
│ │ ├── atom.py
│ │ ├── brave.py
│ │ ├── chrome.py
│ │ ├── collabora.py
│ │ ├── dotnet.py
│ │ ├── freeoffice.py
│ │ ├── jami.py
│ │ ├── libation.py
│ │ ├── librewolf.py
│ │ ├── localsend.py
│ │ ├── maptool.py
│ │ ├── megasync.py
│ │ ├── ms_edge.py
│ │ ├── mullvad-browser.py
│ │ ├── ocenaudio.py
│ │ ├── onlyoffice.py
│ │ ├── orca_slicer.py
│ │ ├── packman.py
│ │ ├── plex.py
│ │ ├── resilio-sync.py
│ │ ├── rustdesk.py
│ │ ├── skype.py
│ │ ├── slack.py
│ │ ├── spotify.py
│ │ ├── sublime.py
│ │ ├── teams-for-linux.py
│ │ ├── teamviewer.py
│ │ ├── vagrant.py
│ │ ├── vivaldi.py
│ │ ├── vs_code.py
│ │ ├── vs_codium.py
│ │ ├── yandex-browser.py
│ │ ├── yandex-disk.py
│ │ ├── zellij.py
│ │ └── zoom.py
│ ├── rpmbuild.py
│ ├── snap.py
│ ├── state.py
│ └── version.py
├── opi.changes
├── opi.default.cfg
├── org.openSUSE.opi.appdata.xml
├── proxy/
│ ├── .gitignore
│ ├── README.txt
│ ├── config.sample.json
│ ├── dependencies.txt
│ ├── install.sh
│ ├── opi-proxy.service
│ ├── opi_proxy/
│ │ └── __init__.py
│ └── setup.py
├── release.sh
├── setup.py
└── test/
├── 01_install_from_packman.py
├── 02_install_from_home.py
├── 03_install_using_plugin.py
├── 04_check_plugins.py
├── 05_install_from_local_repo.py
├── 06_install_non_interactive.py
├── 07_install_multiple.py
├── 08_install_from_packman_non_interactive.py
├── 09_install_with_multi_repos_in_single_file_non_interactive.py
├── 99_install_opi.py
├── run.sh
├── run_all.sh
└── run_container_test.sh
================================================
FILE CONTENTS
================================================
================================================
FILE: .github/ISSUE_TEMPLATE/bug_report.md
================================================
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''
---
**Please also attach the output of these commands to your bug**
```
cat /etc/os-release
(cd /etc/zypp/repos.d; \ls | while read line ; do echo -e "\n----\n$(ls -l $line):"; cat "$line" ; done)
```
================================================
FILE: .github/ISSUE_TEMPLATE/feature_request.md
================================================
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: ''
assignees: ''
---
**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
**Describe the solution you'd like**
A clear and concise description of what you want to happen.
**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
**Additional context**
Add any other context or screenshots about the feature request here.
================================================
FILE: .github/workflows/ci.yaml
================================================
name: CI
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
Tumbleweed:
# The type of runner that the job will run on
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v4
# Runs a single command using the runners shell
- name: Run testsuite
run: ./test/run_all.sh opensuse/tumbleweed
Leap:
runs-on: ubuntu-latest
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v4
# Runs a single command using the runners shell
- name: Run testsuite
run: ./test/run_all.sh opensuse/leap
MicroOS:
runs-on: ubuntu-latest
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v4
# Runs a single command using the runners shell
- name: Run testsuite
run: ./test/run_all.sh opensuse/microos
================================================
FILE: .gitignore
================================================
!Build/
.last_cover_stats
/META.yml
/META.json
/MYMETA.*
*.o
*.pm.tdy
*.bs
# Devel::Cover
cover_db/
# Devel::NYTProf
nytprof.out
# Dizt::Zilla
/.build/
# Module::Build
_build/
Build
Build.bat
# Module::Install
inc/
# ExtUtils::MakeMaker
/blib/
/_eumm/
/*.gz
/Makefile
/Makefile.old
/MANIFEST.bak
/pm_to_blib
/*.zip
/search.xml
.*.swp
__pycache__
# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg
config.json
.idea
================================================
FILE: LICENSE
================================================
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc.
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
Copyright (C)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
Copyright (C)
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
.
================================================
FILE: README.md
================================================
# OPI
**O**BS **P**ackage **I**nstaller
Search and install almost all packages available for openSUSE and SLE:
1. openSUSE Build Service
2. Packman
3. Popular packages for Microsoft and other vendors
## System Requirements
- openSUSE Tumbleweed, openSUSE Leap 42.1+, SLE 12+
- python3
- python3-requests
- python3-lxml
- python3-termcolor
## Install
### openSUSE Tumbleweed and Leap
```
sudo zypper install opi
```
### SLE
```
# eg. for SLE 15 SP4
sudo SUSEConnect -p PackageHub/15.4/x86_64
sudo zypper refresh
sudo zypper install opi
```
## Use
Run:
```
opi [package_name]
```
Example:
```
opi filezilla
```
Demo:

### Config options
Change the config by editing the content of `/etc/opi.cfg`.
#### Disabling auto-refresh for new repositories
If you want to, you can disable auto-refreshing of new repositories.
```cfg
new_repo_auto_refresh = false
```
If you want to reactivate auto-refreshing for new repositories, just change the value of `new_repo_auto_refresh` back to `true`.
### Packages from Other Repositories
**Packman Codecs** (enable you to play MP4 videos and YouTube)
```
opi packman
# or
opi codecs
```
```
usage: opi [-h] [-v] [-n] [-P] [-m] [query ...]
openSUSE Package Installer
==========================
Search and install almost all packages available for openSUSE and SLE:
1. openSUSE Build Service
2. Packman
3. Popular packages for various vendors
positional arguments:
query can be any package name or part of it and will be searched for both at the openSUSE Build Service and Packman.
If multiple query arguments are provided only results matching all of them are returned.
Please use the -m option if you want to use the query arguments as individual package queries.
options:
-h, --help show this help message and exit
-v, --version show program's version number and exit
-n run in non interactive mode
-P don't run any plugins - only search repos, OBS and Packman
-m use query args as space separated package queries
Also these queries (provided by plugins) can be used to install packages from various other vendors:
anydesk AnyDesk remote access
atom Atom Text Editor
brave Brave web browser
chrome Google Chrome web browser
codecs Media Codecs from Packman and official repo
collabora Collabora desktop office
dotnet Microsoft .NET framework
freeoffice Office suite from SoftMaker (See OSS alternative libreoffice)
jami Jami p2p messenger
libation Tool for managing audible audiobooks
maptool Virtual Tabletop for playing roleplaying games
megasync Mega Desktop App
msedge Microsoft Edge web browser
ocenaudio Audio Editor
orcaslicer Slicer and controller for Bambu and other 3D printers
plex Plex Media Server (See OSS alternative jellyfin)
resilio-sync Decentralized file sync between devices using bittorrent protocol (See OSS alternative syncthing)
skype Microsoft Skype
slack Slack messenger
spotify Listen to music for a monthly fee
sublime Editor for code, markup and prose
teams-for-linux Unofficial Microsoft Teams for Linux client
teamviewer TeamViewer remote access
vivaldi Vivaldi web browser
vscode Microsoft Visual Studio Code
vscodium Visual Studio Codium
yandex-browser Yandex web browser
yandex-disk Yandex.Disk cloud storage client
zoom Zoom Video Conference
```
================================================
FILE: bin/opi
================================================
#!/usr/bin/python3
import os
import sys
import re
import argparse
import textwrap
import subprocess
from termcolor import colored, cprint
sys.path.insert(0, os.path.abspath(os.path.dirname(__file__) + '/..'))
import opi
from opi.plugins import PluginManager
from opi.version import __version__
from opi.state import global_state
class PreserveWhiteSpaceWrapRawTextHelpFormatter(argparse.RawTextHelpFormatter):
def __add_whitespace(self, idx, iWSpace, text):
if idx == 0:
return text
return (' ' * iWSpace) + text
def _split_lines(self, text, width):
textRows = text.splitlines()
for idx,line in enumerate(textRows):
search = re.search(r'\s*[\d\-]*\.?\s*', line)
if line.strip() == '':
textRows[idx] = ' '
elif search:
lWSpace = search.end()
lines = [self.__add_whitespace(i,lWSpace,x) for i,x in enumerate(textwrap.wrap(line, width))]
textRows[idx] = lines
return [item for sublist in textRows for item in sublist]
def setup_argparser(plugin_manager):
ap = argparse.ArgumentParser(
formatter_class=PreserveWhiteSpaceWrapRawTextHelpFormatter,
description=textwrap.dedent('''\
openSUSE Package Installer
==========================
Search and install almost all packages available for openSUSE and SLE:
1. openSUSE Build Service
2. Packman
3. Popular packages for various vendors
'''),
epilog=textwrap.dedent('''\
Also these queries (provided by plugins) can be used to install packages from various other vendors:
''') + plugin_manager.get_plugin_string(' ' * 2))
ap.add_argument('query', nargs='*', type=str, help=textwrap.dedent('''\
can be any package name or part of it and will be searched for both at the openSUSE Build Service and Packman.
If multiple query arguments are provided only results matching all of them are returned.
Please use the -m option if you want to use the query arguments as individual package queries.
'''))
ap.add_argument('-V', '--version', action='version', version=f'opi version {__version__}')
ap.add_argument('-n', dest='non_interactive', action='store_true', help='run in non interactive mode')
ap.add_argument('-P', dest='no_plugins', action='store_true', help="don't run any plugins - only search repos, OBS and Packman")
ap.add_argument('-m', dest='multi_install', action='store_true', help='use query args as space separated package queries')
ap.add_argument('-v', '--verbose', dest='verbose_mode', action='store_true', help='make the operation more talkative')
return ap
def repo_query(query):
try:
print(f'Searching repos for: {(" ".join(query) if isinstance(query, list) else query)}')
packages = []
packages.extend(opi.search_published_packages('openSUSE', query))
packages.extend(opi.search_published_packages('Packman', query))
packages = opi.sort_uniq_packages(packages)
if len(packages) == 0:
print('No package found.')
return
# Print and select a package name option
package_names = opi.get_package_names(packages)
selected_pkg_name = opi.ask_for_option(package_names)
print('You have selected package name:', selected_pkg_name)
# Inject packages from local repos
packages = opi.search_local_repos(selected_pkg_name) + packages
instable_pkg_options = [pkg for pkg in packages if pkg.name == selected_pkg_name]
# Print and select a package option
selected_pkg = opi.ask_for_option(instable_pkg_options, option_filter=opi.format_pkg_option, disable_pager=True)
print('You have selected package:', opi.format_pkg_option(selected_pkg, table=False))
if isinstance(selected_pkg, opi.OBSPackage):
if selected_pkg.is_from_personal_project():
cprint(
'BE CAREFUL! The package is from a personal repository and NOT reviewed by others.\n'
'You can ask the author to submit the package to development projects and openSUSE:Factory.\n'
'Learn more at https://en.opensuse.org/openSUSE:How_to_contribute_to_Factory',
'red'
)
elif selected_pkg.project == 'openSUSE:Factory':
cprint(
'BE CAREFUL! You are about to add the Factory Repository.\n'
'This repo contains the unreleased Tumbleweed distro before openQA tests have been run.\n'
'Only proceed if you know what you are doing!',
'yellow'
)
if not opi.ask_yes_or_no('Do you want to continue?', default_answer='n'):
return
elif selected_pkg.project.startswith('openSUSE:Factory:Staging'):
cprint(
'BE CAREFUL! You are about to add a Factory Staging Repository.\n'
'This repo is used to test submissions to the Factory repo (the unreleased Tumbleweed distro before openQA tests have been run).\n'
'Only proceed if you know what you are doing!',
'yellow'
)
if not opi.ask_yes_or_no('Do you want to continue?', default_answer='n'):
return
# Install selected package
selected_pkg.install()
except (opi.NoOptionSelected, opi.HTTPError):
return
if __name__ == '__main__':
try:
pm = PluginManager()
ap = setup_argparser(pm)
args = ap.parse_args()
if not args.query:
ap.print_help()
sys.exit()
if args.verbose_mode:
global_state.arg_verbose_mode = True
if args.non_interactive:
global_state.arg_non_interactive = True
if subprocess.run(['sudo', '-n', 'true']).returncode != 0:
print('Error: In non-interactive mode this command must be run as root')
print(' or sudo must not require interaction.')
sys.exit(1)
# Search plugins
if not args.no_plugins:
# Iterate over queries, copy list as modifying it from within the loop
for query in list(args.query):
# Try to find a matching plugin for the query (and run it); runs just first query if not in multi_install mode
if pm.run(query):
# After plugin successfully ran, remove from queries to not try again in repo search
args.query.remove(query)
if not args.multi_install:
sys.exit()
# Search repos
if not args.multi_install:
repo_query(args.query)
else:
for query in args.query:
repo_query(query)
except KeyboardInterrupt:
print()
================================================
FILE: opi/__init__.py
================================================
import os
import sys
import subprocess
import re
import tempfile
import configparser
from functools import cmp_to_key
from collections import defaultdict
import requests
import lxml.etree
import rpm
from termcolor import colored, cprint
from opi import pager
from opi import config
from opi.state import global_state
OBS_APIROOT = {
'openSUSE': 'https://api.opensuse.org',
'Packman': 'https://pmbs.links2linux.de'
}
PROXY_URL = 'https://opi-proxy.opensuse.org/'
REPO_DIR = '/etc/zypp/repos.d/'
##################
### Exceptions ###
##################
class NoOptionSelected(Exception):
pass
class HTTPError(Exception):
pass
###################
### System Info ###
###################
cpu_arch = None
def get_cpu_arch():
"""
returns e.g. x86_64, aarch64
"""
global cpu_arch
if not cpu_arch:
cpu_arch = os.uname().machine
if re.match(r'^i.86$', cpu_arch):
cpu_arch = 'i586'
return cpu_arch
os_release = {}
def get_os_release():
global os_release
if not os_release:
with open('/etc/os-release') as f:
for line in f.readlines():
line = line.strip()
if line.startswith('#') or '=' not in line:
continue
key, value = line.split('=', 1)
key = key.strip()
value = value.strip()
if '"' in value:
value = value.split('"', 1)[1].split('"', 1)[0]
os_release[key] = value
return os_release
def get_distribution(prefix=False, use_releasever_variable=False):
os_release = get_os_release()
name = os_release['NAME']
version = os_release.get('VERSION') # VERSION is not set for TW
if version:
# strip prerelease suffix (eg. ' Alpha')
version = version.split(' ', 1)[0]
if name in ('openSUSE Tumbleweed', 'openSUSE MicroOS'):
project = 'openSUSE:Factory'
elif name in ('openSUSE Tumbleweed-Slowroll', 'openSUSE MicroOS-Slowroll'):
project = 'openSUSE:Slowroll'
elif name == 'openSUSE Leap':
if use_releasever_variable:
project = 'openSUSE:Leap:$releasever'
else:
project = 'openSUSE:Leap:' + version
elif name == 'openSUSE Leap Micro':
# Leap Micro major version seems to be 10 lower than Leap the version it is based on
if use_releasever_variable:
project = 'openSUSE:Leap:1$releasever'
else:
project = 'openSUSE:Leap:1' + version
elif name.startswith('SLE'):
project = 'SLE' + version
if prefix:
project = 'openSUSE.org:' + project
return project
def get_version() -> str:
os_release = get_os_release()
version = os_release.get('VERSION') # VERSION is not set for TW
return version
def expand_vars(s: str) -> str:
s = s.replace('${releasever}', get_version() or '${releasever}')
s = s.replace('$releasever', get_version() or '$releasever')
s = s.replace('${basearch}', get_cpu_arch() or '${basearch}')
s = s.replace('$basearch', get_cpu_arch() or '$basearch')
return s
###############
### PACKMAN ###
###############
def add_packman_repo(dup=False):
repos_by_alias = {repo.alias: repo for repo in get_repos()}
if 'packman' in repos_by_alias:
print("Installing from existing packman repo")
else:
print("Adding packman repo")
packman_mirrors = {
"ftp.fau.de - University of Erlangen, Germany - 1h sync": "https://ftp.fau.de/packman",
"ftp.halifax.rwth-aachen.de - University of Aachen, Germany - 1h sync": "https://ftp.halifax.rwth-aachen.de/packman",
"ftp.gwdg.de - University of Göttingen, Germany - 4h sync": "https://ftp.gwdg.de/pub/linux/misc/packman",
"mirror.karneval.cz - TES Media, Czech Republic - 1h sync": "https://mirror.karneval.cz/pub/linux/packman",
"mirrors.aliyun.com - Alibaba Cloud, China - 24h sync": "https://mirrors.aliyun.com/packman",
}
mirror = ask_for_option(list(packman_mirrors.keys()), 'Pick a mirror near your location (0 to quit):')
mirror = packman_mirrors[mirror]
project = get_distribution(use_releasever_variable=config.get_key_from_config('use_releasever_var'))
project = project.replace(':', '_')
project = project.replace('Factory', 'Tumbleweed')
add_repo(
filename = 'packman',
name = 'Packman',
url = f'{mirror}/suse/{project}/',
gpgkey = f'https://ftp.fau.de/packman/suse/{project}/repodata/repomd.xml.key', # always fetch gpgkey from FAU server
auto_refresh = config.get_key_from_config('new_repo_auto_refresh'),
priority = 70
)
if dup:
dist_upgrade(from_repo='packman', allow_downgrade=True, allow_vendor_change=True)
def add_openh264_repo(dup=False):
project = get_os_release()['NAME']
project = project.replace('-Slowroll', '')
project = project.replace('openSUSE MicroOS', 'openSUSE Tumbleweed')
project = project.replace('openSUSE Leap Micro', 'openSUSE Leap')
version = get_version()
if version and int(float(version)) == 16:
project = project.replace('openSUSE Leap', 'openSUSE Leap 16')
project = project.replace(':', '_').replace(' ', '_')
url = f'https://codecs.opensuse.org/openh264/{project}/'
existing_repo = get_enabled_repo_by_url(url)
if existing_repo:
print(f"Installing from existing repo '{existing_repo.name_expanded()}'")
repo = existing_repo.alias
else:
repo = 'openh264'
print(f"Adding repo '{repo}'")
add_repo(
filename = repo,
name = repo,
url = url,
gpgkey = f"{url.replace('http://', 'https://')}repodata/repomd.xml.key",
auto_refresh = config.get_key_from_config('new_repo_auto_refresh'),
priority = 70
)
if dup:
dist_upgrade(from_repo=repo, allow_downgrade=True, allow_vendor_change=True)
def install_packman_packages(packages, **kwargs):
install_packages(packages, from_repo='packman', **kwargs)
################
### ZYPP/DNF ###
################
class Repository:
def __init__(self, alias: str, name: str, url: str, auto_refresh: bool, gpgkey: str = None, filename: str = None):
self.alias = alias
self.name = name
self.url = url
self.auto_refresh = auto_refresh
self.gpgkey = gpgkey
self.filename = filename or alias
def name_expanded(self):
""" Return name with all supported vars expanded """
return expand_vars(self.name)
def url_expanded(self):
""" Return url with all supported vars expanded """
return expand_vars(self.url)
def search_local_repos(package):
"""
Search local default repos
"""
search_results = defaultdict(list)
try:
zc = tempfile.NamedTemporaryFile('w')
zc.file.write(f'[main]\nshowAlias = true\n')
zc.file.flush()
os.chmod(zc.name, 0o644)
# ensure to run as non-root as this allows the cmd to run even if rpmdb is locked
user = None if os.getuid() else 'nobody'
cmd = ['zypper', '-ntc', zc.name, '--no-refresh', 'se', '-sx', '-tpackage', package]
env = {'LANG': 'c'}
try:
sr = subprocess.check_output(cmd, env=env, user=user).decode()
except TypeError:
# no user arg on old python versions
sr = subprocess.check_output(cmd, env=env).decode()
for line in re.split(r'-\+-+\n', sr, re.MULTILINE)[1].strip().split('\n'):
version, arch, repo_alias = [s.strip() for s in line.split('|')[3:]]
version, release = version.split('-')
if arch not in (get_cpu_arch(), 'noarch'):
continue
if repo_alias == '(System Packages)':
continue
search_results[repo_alias].append({'version': version, 'release': release, 'arch': arch})
except subprocess.CalledProcessError as e:
if e.returncode == 104:
# 104 ZYPPER_EXIT_INF_CAP_NOT_FOUND is returned if there are no results
pass
elif e.returncode == 7:
# 7 ZYPPER_EXIT_ZYPP_LOCKED - error is already printed by zypper
sys.exit(1)
elif e.returncode == 106:
# 106 - ZYPPER_EXIT_INF_REPOS_SKIPPED - some repos have no cache
cprint("Warning: The repos listed above have no local cache and will be ignored for this query.", 'yellow')
cprint(" Run 'zypper refresh' as root to fix this.", 'yellow')
else:
raise # TODO: don't exit program, use exception that will be handled in repo_query except block
repos_by_alias = {repo.alias: repo for repo in get_repos()}
local_installables = []
for repo_alias, installables in search_results.items():
# get the newest package for each repo
try:
installables.sort(key=lambda p: cmp_to_key(rpm.labelCompare)("%(version)s-%(release)s" % p))
except TypeError:
# rpm 4.14 needs a tuple of (epoch, version, release) - rpm 4.18 can handle a string
installables.sort(key=lambda p: cmp_to_key(rpm.labelCompare)(['1', p['version'], p['release']]))
installable = installables[-1]
installable['repository'] = repos_by_alias[repo_alias]
installable['name'] = package
# filter out OBS/Packman repos as they are already searched via OBS/Packman API
if 'download.opensuse.org/repositories' in installable['repository'].url:
continue
if installable['repository'].filename == 'packman':
continue
local_installables.append(LocalPackage(**installable))
return local_installables
def url_normalize(url):
return expand_vars(re.sub(r'^https?', '', url).rstrip('/'))
def get_repos():
for repo_file in os.listdir(REPO_DIR):
if not repo_file.endswith('.repo'):
continue
try:
cp = configparser.ConfigParser()
cp.read(os.path.join(REPO_DIR, repo_file))
for alias in cp.sections():
if not bool(int(cp.get(alias, 'enabled'))):
continue
repo = {
'alias': alias,
'filename': re.sub(r'\.repo$', '', repo_file),
'name': cp[alias].get('name', alias),
'url': cp[alias].get('baseurl'),
'auto_refresh': bool(int(cp[alias].get('autorefresh', '0'))),
}
if cp.has_option(alias, 'gpgkey'):
repo['gpgkey'] = cp[alias].get('gpgkey')
yield Repository(**repo)
except Exception as e:
print(f"Error parsing '{repo_file}': {e}")
def get_enabled_repo_by_url(url):
for repo in get_repos():
if url_normalize(repo.url) == url_normalize(url):
return repo
def add_repo(filename, name, url, enabled=True, gpgcheck=True, gpgkey=None, repo_type='rpm-md', auto_import_keys=False, auto_refresh=False, priority=None):
tf = tempfile.NamedTemporaryFile('w')
tf.file.write(f'[{filename}]\n')
tf.file.write(f'name={name}\n')
tf.file.write(f'baseurl={url}\n')
tf.file.write(f'enabled={enabled:d}\n')
tf.file.write(f'type={repo_type}\n')
tf.file.write(f'gpgcheck={gpgcheck:d}\n')
if gpgkey:
ask_import_key(gpgkey)
tf.file.write(f'gpgkey={gpgkey}\n')
if auto_refresh:
tf.file.write('autorefresh=1\n')
if priority:
tf.file.write(f'priority={priority}\n')
tf.file.flush()
repo_file = os.path.join(REPO_DIR, f'{filename}.repo')
subprocess.call(['sudo', 'cp', tf.name, repo_file])
subprocess.call(['sudo', 'chmod', '644', repo_file])
tf.file.close()
if global_state.arg_verbose_mode:
print(f"Wrote {repo_file}:\n{'-'*8}\n{open(repo_file).read()}{'-'*8}")
refresh_repos(auto_import_keys=auto_import_keys)
def refresh_repos(repo_alias=None, auto_import_keys=False):
refresh_cmd = []
refresh_cmd = ['sudo', 'zypper']
if auto_import_keys:
refresh_cmd.append('--gpg-auto-import-keys')
refresh_cmd.append('ref')
if repo_alias:
refresh_cmd.append(repo_alias)
subprocess.call(refresh_cmd)
def normalize_key(pem):
new_lines = []
for line in pem.split('\n'):
line = line.strip()
if not line:
continue
if line.lower().startswith('version:'):
continue
new_lines.append(line)
new_lines.insert(1, '')
return '\n'.join(new_lines)
def split_keys(keys):
for key in keys.split('-----BEGIN PGP PUBLIC KEY BLOCK-----')[1:]:
yield '-----BEGIN PGP PUBLIC KEY BLOCK-----' + key
def get_keys_from_rpmdb():
s = subprocess.check_output(['rpm', '-q', 'gpg-pubkey', '--qf',
'%{NAME}-%{VERSION}\n%{PACKAGER}\n%{DESCRIPTION}\nOPI-SPLIT-TOKEN-TO-TELL-KEY-PACKAGES-APART\n'])
keys = []
for raw_kpkg in s.decode().strip().split('OPI-SPLIT-TOKEN-TO-TELL-KEY-PACKAGES-APART'):
raw_kpkg = raw_kpkg.strip()
if not raw_kpkg:
continue
kid, name, pubkey = raw_kpkg.strip().split('\n', 2)
keys.append({
'kid': kid,
'name': name,
'pubkey': normalize_key(pubkey)
})
return keys
def install_packages(packages, **kwargs):
pkgmgr_action('in', packages, **kwargs)
def dist_upgrade(**kwargs):
pkgmgr_action('dup', **kwargs)
def pkgmgr_action(action, packages=[], from_repo=None, allow_vendor_change=False, allow_arch_change=False, allow_downgrade=False, allow_name_change=False, allow_unsigned=False, no_recommends=False, non_interactive=False):
args = ['sudo', 'zypper']
if global_state.arg_non_interactive or non_interactive:
args.append('-n')
if allow_unsigned:
args.append('--no-gpg-checks')
args.append(action)
if from_repo:
args.extend(['--from', from_repo])
if allow_downgrade:
args.append('--allow-downgrade')
if allow_arch_change:
args.append('--allow-arch-change')
if allow_name_change:
args.append('--allow-name-change')
if allow_vendor_change:
args.append('--allow-vendor-change')
if action == 'in':
args.append('--oldpackage')
if no_recommends:
args.append('--no-recommends')
args.extend(packages)
subprocess.call(args)
###########
### OBS ###
###########
class Installable:
def __init__(self, name: str, version: str, release: str, arch: str):
self.name = name # e.g. MozillaFirefox
self.version = version # e.g. 1.2.3
self.release = release # e.g. 150500.1.1
self.arch = arch # e.g. x86_64, aarch64 or noarch
def install(self):
raise NotImplemented()
def name_with_arch(self):
return f'{self.name}.{self.arch}'
def _install_from_existing_repo(self, repo: Repository):
# Install from existing repos (don't add a repo)
print(f"Installing from existing repo '{repo.name_expanded()}'")
# ensure that this repo is up to date if no auto_refresh is configured
if not repo.auto_refresh:
refresh_repos(repo.alias)
install_packages([self.name_with_arch()], from_repo=repo.alias)
class OBSPackage(Installable):
""" Package returned from OBS API """
def __init__(self,
name: str, version: str, release: str, arch: str,
package: str, project: str, repository: str, obs_instance: str):
super().__init__(name, version, release, arch)
self.package = package # same as name unless this is a subpackage (then package is name of parent)
self.project = project # e.g. devel:languages:perl
self.repository = repository # e.g. openSUSE_Tumbleweed
self.obs_instance = obs_instance # openSUSE or Packman
def install(self):
if self.obs_instance == 'Packman':
# Install from Packman Repo
add_packman_repo()
install_packman_packages([self.name_with_arch()])
return
repo_alias = self.project.replace(':', '_')
project_path = self.project.replace(':', ':/')
repository = self.repository
if config.get_key_from_config('use_releasever_var'):
version = get_version()
if version:
# version is None on tw
repository = repository.replace(version, '$releasever')
url = f'https://download.opensuse.org/repositories/{project_path}/{repository}/'
gpgkey = url + 'repodata/repomd.xml.key'
existing_repo = get_enabled_repo_by_url(url)
if existing_repo:
self._install_from_existing_repo(existing_repo)
else:
print(f"Adding repo '{self.project}'")
add_repo(
filename = repo_alias,
name = self.project,
url = url,
gpgkey = gpgkey,
gpgcheck = True,
auto_refresh = config.get_key_from_config('new_repo_auto_refresh')
)
install_packages([self.name_with_arch()], from_repo=repo_alias,
allow_downgrade=True,
allow_arch_change=True,
allow_name_change=True,
allow_vendor_change=True
)
ask_keep_repo(repo_alias)
def weight(self):
weight = 0
dash_count = self.name.count('-')
weight += 1e5 * (0.5 ** dash_count)
weight -= 1e4 * len(self.name)
if self.is_from_official_project():
weight += 2e3
elif not self.is_from_personal_project():
weight += 1e3
if self.name == self.package:
# this rpm is the main or only subpackage
weight += 1e2
if not (get_cpu_arch() == 'x86_64' and self.arch == 'i586'):
weight += 1e1
if self.repository.startswith('openSUSE_Tumbleweed'):
weight += 2
elif self.repository.startswith('openSUSE_Factory'):
weight += 1
elif self.repository == 'standard':
weight += 0
return weight
def __lt__(self, other):
""" Note that we sort from high weight to low weight """
return self.weight() > other.weight()
def is_from_official_project(self):
return self.project.startswith('openSUSE:')
def is_from_personal_project(self):
return self.project.startswith('home:') or self.project.startswith('isv:')
class LocalPackage(Installable):
""" Package found in local repo (metadata) cache """
def __init__(self, name: str, version: str, release: str, arch: str, repository: Repository):
super().__init__(name, version, release, arch)
self.repository = repository
def install(self):
self._install_from_existing_repo(self.repository)
def search_published_packages(obs_instance, query):
distribution = get_distribution(prefix=(obs_instance != 'openSUSE'))
endpoint = '/search/published/binary/id'
url = OBS_APIROOT[obs_instance] + endpoint
if isinstance(query, list):
xquery = "'" + "', '".join(query) + "'"
else:
xquery = f"'{query}'"
xpath = f"contains-ic(@name, {xquery}) and path/project='{distribution}'"
url = requests.Request('GET', url, params={'match': xpath, 'limit': 0}).prepare().url
try:
r = requests.get(PROXY_URL, params={'obs_api_link': url, 'obs_instance': obs_instance})
r.raise_for_status()
dom = lxml.etree.fromstring(r.text)
packages = []
for binary in dom.xpath('/collection/binary'):
binary_data = {k: v for k, v in binary.items()}
binary_data['obs_instance'] = obs_instance
del binary_data['filename']
del binary_data['filepath']
del binary_data['baseproject']
del binary_data['type']
for k in ('name', 'project', 'repository', 'version', 'release', 'arch'):
assert k in binary_data, f"Key '{k}' missing"
# Filter out ghost binary
# (package has been deleted, but binary still exists)
if not binary_data.get('package'):
continue
package = OBSPackage(**binary_data)
# Filter out branch projects
if ':branches:' in package.project:
continue
# Filter out Packman personal projects
if package.obs_instance != 'openSUSE' and package.is_from_personal_project():
continue
# Filter out debuginfo, debugsource, devel, buildsymbols, lang and docs packages
regex = r'-(debuginfo|debugsource|buildsymbols|devel|lang|l10n|trans|doc|docs)(-.+)?$'
if re.match(regex, package.name):
continue
# Filter out source packages
if package.arch == 'src':
continue
# Filter architecture
cpu_arch = get_cpu_arch()
if package.arch not in (cpu_arch, 'noarch'):
continue
# Filter repo architecture
if package.repository == 'openSUSE_Factory' and (cpu_arch not in ('x86_64' 'i586')):
continue
elif package.repository == 'openSUSE_Factory_ARM' and not cpu_arch.startswith('arm') and not cpu_arch == 'aarch64':
continue
elif package.repository == 'openSUSE_Factory_PowerPC' and not cpu_arch.startswith('ppc'):
continue
elif package.repository == 'openSUSE_Factory_zSystems' and not cpu_arch.startswith('s390'):
continue
elif package.repository == 'openSUSE_Factory_RISCV' and not cpu_arch.startswith('risc'):
continue
packages.append(package)
return packages
except requests.exceptions.HTTPError as e:
if e.response.status_code == 413:
print('Please use different search keywords. Some short keywords cause OBS timeout.')
else:
print('HTTPError:', e)
raise HTTPError()
def get_package_names(packages: list):
""" return a list of package names but without duplicates """
names = []
for pkg in packages:
name = pkg.name
if name not in names:
names.append(name)
return names
def sort_uniq_packages(packages: list):
""" sort -u for packages; sort by weight and keep only the one with the best repo """
packages = sorted(packages)
new_packages = []
added_packages = set()
for package in packages:
# only select the first package for each name/project combination
# which will be the one with the highest repo weight
query = (package.name, package.project)
if query not in added_packages:
new_packages.append(package)
added_packages.add(query)
return new_packages
########################
### User Interaction ###
########################
def ask_yes_or_no(question, default_answer='y'):
q = question + ' '
if default_answer == 'y':
q += '(Y/n)'
else:
q += '(y/N)'
q += ' '
if global_state.arg_non_interactive:
print(q)
answer = default_answer
else:
answer = input(q) or default_answer
return answer.strip().lower() == 'y'
def ask_for_option(options, question='Pick a number (0 to quit):', option_filter=lambda a: a, disable_pager=False):
"""
Ask the user for a number to pick in order to select an option.
Exit if the number is 0.
Specify the number with question and the corresponding option will be returned.
Via option_filter a callback function to format option entries can be supplied,
but this doesn't work with the pager.
If needed, a pager will be used, unless disable_pager is True.
"""
padding_len = len(str(len(options)))
i = 1
numbered_options = []
terminal_width = os.get_terminal_size().columns - 1 if sys.stdout.isatty() else 0
for option in options:
number = f'{i:{padding_len}}. '
numbered_option = number + option_filter(option)
if terminal_width and not disable_pager:
# break too long lines:
# if pager is disabled this might mean that we get terminal sequences here
# which might get broken by some spaces and newlines.
# also too long lines are not fatal outside of the pager
while len(numbered_option) > terminal_width:
numbered_options.append(numbered_option[:terminal_width])
numbered_option = ' ' * len(number) + numbered_option[terminal_width:]
numbered_options.append(numbered_option)
i += 1
if config.get_key_from_config('list_in_reverse'):
numbered_options.reverse()
text = '\n'.join(numbered_options)
if global_state.arg_non_interactive:
input_string = '1' # default to first option in the list
print(f"{text}\n{question} {input_string}")
elif not sys.stdout.isatty() or len(numbered_options) < (os.get_terminal_size().lines - 1) or disable_pager:
# no pager needed
print(text)
input_string = input(question + ' ')
else:
input_string = pager.ask_number_with_pager(text, question, start_at_bottom=config.get_key_from_config('list_in_reverse'))
input_string = input_string.strip() or '0'
num = int(input_string) if input_string.isdecimal() else -1
if num == 0:
raise NoOptionSelected()
elif not (num >= 1 and num <= len(options)):
return ask_for_option(options, question, option_filter, disable_pager)
else:
return options[num - 1]
def ask_import_key(keyurl):
keys = requests.get(expand_vars(keyurl)).text
db_keys = get_keys_from_rpmdb()
for key in split_keys(keys):
for line in subprocess.check_output(['gpg', '--quiet', '--show-keys', '--with-colons', '-'], input=key.encode()).decode().strip().split('\n'):
if line.startswith('uid:'):
key_info = line.split(':')[9].replace('\\x3a', ':')
elif line.startswith('pub:'):
kid = f"gpg-pubkey-{line.split(':')[4][-8:].lower()}"
if [db_key for db_key in db_keys if normalize_key(key) in normalize_key(db_key['pubkey'])]:
print(f"Package signing key {kid} ('{key_info}) is already present.")
else:
if ask_yes_or_no(f"Import package signing key {kid} ({key_info})"):
tf = tempfile.NamedTemporaryFile('w')
tf.file.write(key)
tf.file.flush()
subprocess.call(['sudo', 'rpm', '--import', tf.name])
tf.file.close()
def ask_keep_key(keyurl, repo_alias=None):
"""
Ask to remove the key given by url to key file.
Warns about all repos still using the key except the repo given by repo_alias param.
"""
urlkeys = split_keys(requests.get(expand_vars(keyurl)).text)
urlkeys_normalized = [normalize_key(urlkey) for urlkey in urlkeys]
db_keys = get_keys_from_rpmdb()
keys_to_ask_user = [key for key in db_keys if key['pubkey'] in urlkeys_normalized]
for key in keys_to_ask_user:
repos_using_this_key = []
for repo in get_repos():
if repo_alias and repo.filename == repo_alias:
continue
if repo.gpgkey:
repokey = normalize_key(requests.get(repo.gpgkey).text)
if repokey == key['pubkey']:
repos_using_this_key.append(repo)
if repos_using_this_key:
default_answer = 'y'
print('This key is still in use by the following remaining repos - removal is NOT recommended:')
print(' - ' + '\n - '.join([repo.filename for repo in repos_using_this_key]))
else:
default_answer = 'n'
print('This key is not in use by any remaining repos.')
print('Keeping the key will allow additional packages signed by this key to be installed in the future without further warning.')
if not ask_yes_or_no(f"Keep package signing key {key['kid']} ({key['name']})?", default_answer):
subprocess.call(['sudo', 'rpm', '-e', key['kid']])
def ask_keep_repo(repo_alias):
if not ask_yes_or_no(f"Do you want to keep the repo '{repo_alias}'?"):
repo = next((r for r in get_repos() if r.filename == repo_alias))
subprocess.call(['sudo', 'zypper', 'rr', repo_alias])
if repo.gpgkey:
ask_keep_key(repo.gpgkey, repo)
def format_pkg_option(package, table=True):
if isinstance(package, LocalPackage):
color = 'green'
symbol = '+'
elif package.is_from_official_project():
color = 'yellow'
symbol = '-'
elif package.is_from_personal_project():
color = 'red'
symbol = '!'
else:
color = 'cyan'
symbol = '?'
if isinstance(package, LocalPackage):
project = package.repository.name_expanded()
else:
project = package.project
if package.obs_instance != 'openSUSE':
project = f"{package.obs_instance} {project}"
colored_name = colored(f'{project[:39]} {symbol}', color)
if table:
return f"{colored_name:50} | {package.version[:25]:25} | {package.arch}"
else:
return f"{colored_name} | {package.version} | {package.arch}"
================================================
FILE: opi/config/__init__.py
================================================
import os
import configparser
default_config = {
'use_releasever_var': True,
'new_repo_auto_refresh': True,
'list_in_reverse': False,
}
class ConfigError(Exception):
pass
config_cache = None
def get_key_from_config(key: str):
global config_cache
if not config_cache:
config_cache = default_config.copy()
path = os.environ.get('OPI_CONFIG', '/etc/opi.cfg')
if os.path.exists(path):
cp = configparser.ConfigParser()
cp.read(path)
ocfg = cp['opi']
config_cache.update({
'use_releasever_var': ocfg.getboolean('use_releasever_var'),
'new_repo_auto_refresh': ocfg.getboolean('new_repo_auto_refresh'),
'list_in_reverse': ocfg.getboolean('list_in_reverse'),
})
return config_cache[key]
================================================
FILE: opi/deb.py
================================================
import os
import subprocess
from shutil import which
from opi import install_packages
def extract_deb(deb, target_dir):
if not which('bsdtar'):
print("Installing requirement: bsdtar")
install_packages(['bsdtar'], no_recommends=True, non_interactive=True)
os.makedirs(target_dir, exist_ok=True)
subprocess.check_call(['bsdtar', 'xf', deb, '--directory', target_dir])
data_tar = os.path.join(target_dir, 'data.tar.xz')
subprocess.check_call(['bsdtar', 'xf', data_tar, '--directory', target_dir])
os.unlink(data_tar)
================================================
FILE: opi/github.py
================================================
import requests
import opi
from opi.state import global_state
def http_get_json(url):
r = requests.get(url)
r.raise_for_status()
return r.json()
def get_releases(org, repo, filter_prereleases=True, filters=[]):
releases = http_get_json(f'https://api.github.com/repos/{org}/{repo}/releases')
if filter_prereleases:
releases = [release for release in releases if not release['prerelease']]
for f in filters:
releases = [r for r in releases if f(r)]
return releases
def get_latest_release(org, repo, filter_prereleases=True, filters=[]):
releases = get_releases(org, repo, filter_prereleases, filters)
return releases[0] if releases else None
def get_release_assets(release):
return [{'name': a['name'], 'url': a['browser_download_url']} for a in http_get_json(release['assets_url'])]
def get_release_asset(release, filters=[]):
assets = get_release_assets(release)
for f in filters:
assets = [r for r in assets if f(r)]
return assets[0] if assets else None
def install_rpm_release(org, repo, filters=[lambda a: a['name'].endswith('.rpm')], allow_unsigned=False):
latest_release = get_latest_release(org, repo)
if not latest_release:
print(f'No release found for {org}/{repo}')
return
asset = get_release_asset(latest_release, filters=filters)
if not asset:
print(f"No RPM asset found for {org}/{repo} release {latest_release['tag_name']}")
return
if global_state.arg_verbose_mode:
print(f"Found: {asset['url']}")
if not opi.ask_yes_or_no(f"Do you want to install {repo} release {latest_release['tag_name']} RPM from {org} github repo?"):
return
opi.install_packages([asset['url']], allow_unsigned=allow_unsigned)
================================================
FILE: opi/http.py
================================================
import os
import requests
def download_file(url, local_filename):
response = requests.get(url, stream=True)
response.raise_for_status()
total_size = int(response.headers.get('content-length', 0))
block_size = 1024*512
os.makedirs(os.path.dirname(local_filename), exist_ok=True)
print(f"Downloading to {local_filename}:")
with open(local_filename, 'wb') as local_file:
total_bytes_received = 0
for data in response.iter_content(chunk_size=block_size):
local_file.write(data)
total_bytes_received += len(data)
print_progress(total_bytes_received, total_size)
print()
def print_progress(bytes_received, total_size):
progress = (bytes_received / total_size) * 100
progress = min(100, progress)
print(f"Progress: [{int(progress)}%] [{'=' * int(progress / 2)}{' ' * (50 - int(progress / 2))}]", end='\r')
================================================
FILE: opi/pager.py
================================================
import sys
import curses
def ask_number_with_pager(text, question='Pick a number (0 to quit):', start_at_bottom=False):
try:
stdscr = curses.initscr()
curses.noecho()
curses.cbreak() # react on keys without enter
text_len_lines = len(text.split('\n'))
max_top_line = text_len_lines - (curses.LINES - 2)
scrollarea = curses.newpad(text_len_lines, curses.COLS)
scrollarea.addstr(0, 0, text)
scrollarea_topline_ptr = max_top_line if start_at_bottom else 0
def ensure_scrollarea_bounds(scrollarea_topline_ptr):
scrollarea_topline_ptr = max(scrollarea_topline_ptr, 0)
scrollarea_topline_ptr = min(scrollarea_topline_ptr, max_top_line)
return scrollarea_topline_ptr
def scrollarea_refresh():
scrollarea.refresh(scrollarea_topline_ptr, 0, 0, 0, curses.LINES - 3, curses.COLS - 1)
# remove artefacts due to smaller status line when scrolling up
controlbar.addstr(0, 0, ' ' * curses.COLS)
controlbar.addstr(0, 0,
'Use arrow keys or PgUp/PgDown to scroll - lines %i-%i/%i %i%%' % (
scrollarea_topline_ptr,
scrollarea_topline_ptr + (curses.LINES - 2),
text_len_lines,
int(100 * scrollarea_topline_ptr / max_top_line)
),
curses.A_REVERSE
)
controlbar = stdscr.subwin(2, curses.COLS, curses.LINES - 2, 0)
controlbar.keypad(True) # enable key bindings and conversions
# ensure clean line
controlbar.addstr(1, 0, ' ' * (curses.COLS - 1))
controlbar.addstr(1, 0, question, curses.A_BOLD)
controlbar.refresh()
scrollarea_refresh()
question += ' '
input_string = ''
while not input_string.endswith('\n'):
c = controlbar.getkey(1, len(question) + len(input_string))
if c == 'KEY_PPAGE':
scrollarea_topline_ptr -= (curses.LINES - 2) // 2
scrollarea_topline_ptr = ensure_scrollarea_bounds(scrollarea_topline_ptr)
scrollarea_refresh()
elif c == 'KEY_NPAGE':
scrollarea_topline_ptr += (curses.LINES - 2) // 2
scrollarea_topline_ptr = ensure_scrollarea_bounds(scrollarea_topline_ptr)
scrollarea_refresh()
elif c == 'KEY_UP':
scrollarea_topline_ptr -= 1
scrollarea_topline_ptr = ensure_scrollarea_bounds(scrollarea_topline_ptr)
scrollarea_refresh()
elif c == 'KEY_DOWN':
scrollarea_topline_ptr += 1
scrollarea_topline_ptr = ensure_scrollarea_bounds(scrollarea_topline_ptr)
scrollarea_refresh()
elif c == 'KEY_HOME':
scrollarea_topline_ptr = 0
scrollarea_topline_ptr = ensure_scrollarea_bounds(scrollarea_topline_ptr)
scrollarea_refresh()
elif c == 'KEY_END':
scrollarea_topline_ptr = sys.maxsize
scrollarea_topline_ptr = ensure_scrollarea_bounds(scrollarea_topline_ptr)
scrollarea_refresh()
elif c == 'KEY_BACKSPACE':
input_string = input_string[:-1]
controlbar.addstr(1, len(question) + len(input_string), ' ')
#elif c == 'KEY_LEFT' or c == 'KEY_RIGHT':
# pass
elif c.startswith('KEY_') or len(c) > 1:
pass
else:
input_string += c
if c != '\n':
controlbar.addstr(1, 0, question, curses.A_BOLD)
controlbar.addstr(1, len(question), input_string)
return input_string
finally:
curses.nocbreak()
stdscr.keypad(False)
curses.echo()
curses.endwin()
================================================
FILE: opi/plugins/__init__.py
================================================
import os
from importlib import import_module
import inspect
from opi import NoOptionSelected
class BasePlugin:
main_query = ''
description = ''
queries = []
@classmethod
def matches(cls, query):
return query in cls.queries
@classmethod
def run(cls, query):
pass
class PluginManager:
def __init__(self):
self.plugins = []
for module in os.listdir(os.path.dirname(__file__)):
if module == '__init__.py' or not module.endswith('.py') or module == '__pycache__':
continue
m = import_module(f'opi.plugins.{module[:-3]}')
for name, obj in inspect.getmembers(m):
if inspect.isclass(obj) and issubclass(obj, BasePlugin) and obj is not BasePlugin:
self.plugins.append(obj)
self.plugins.sort(key=lambda p: p.main_query)
def run(self, query):
query = query.lower()
for plugin in self.plugins:
if plugin.matches(query):
try:
plugin.run(query)
except NoOptionSelected:
pass
return True
def get_plugin_string(self, indent=''):
plugins = ''
for plugin in self.plugins:
description = plugin.description.replace('\n', '\n' + (' ' * 16) + ' ')
plugins += f'{indent}{plugin.main_query:16} {description}\n'
return plugins
================================================
FILE: opi/plugins/antigravity.py
================================================
import opi
from opi.plugins import BasePlugin
class Antigravity(BasePlugin):
main_query = 'antigravity'
description = 'IDE with AI from Google'
queries = [main_query]
@classmethod
def run(cls, query):
if not opi.ask_yes_or_no('Do you want to install Antigravity from Google repository?'):
return
opi.add_repo(
filename = 'antigravity',
name = 'antigravity',
url = 'https://us-central1-yum.pkg.dev/projects/antigravity-auto-updater-dev/antigravity-rpm',
gpgkey = 'https://us-central1-yum.pkg.dev/doc/repo-signing-key.gpg'
)
opi.install_packages(['antigravity'])
opi.ask_keep_repo('antigravity')
================================================
FILE: opi/plugins/anydesk.py
================================================
import opi
from opi.plugins import BasePlugin
class AnyDesk(BasePlugin):
main_query = 'anydesk'
description = 'AnyDesk remote access'
queries = ['anydesk']
@classmethod
def run(cls, query):
if not opi.ask_yes_or_no('Do you want to install AnyDesk from AnyDesk repository?'):
return
opi.add_repo(
filename = 'anydesk',
name = 'anydesk',
url = 'https://rpm.anydesk.com/opensuse/$basearch/',
gpgkey = 'https://keys.anydesk.com/repos/RPM-GPG-KEY'
)
opi.install_packages(['anydesk'])
opi.ask_keep_repo('anydesk')
================================================
FILE: opi/plugins/atom.py
================================================
import opi
from opi.plugins import BasePlugin
class Atom(BasePlugin):
main_query = 'atom'
description = 'Atom Text Editor'
queries = ['atom', 'atom-editor']
@classmethod
def run(cls, query):
if not opi.ask_yes_or_no('Do you want to install Atom from Atom repository?'):
return
opi.add_repo(
filename = 'atom',
name = 'Atom',
url = 'https://packagecloud.io/AtomEditor/atom/el/7/x86_64/?type=rpm',
gpgkey = 'https://packagecloud.io/AtomEditor/atom/gpgkey'
)
opi.install_packages(['atom'])
opi.ask_keep_repo('atom')
================================================
FILE: opi/plugins/brave.py
================================================
import opi
from opi.plugins import BasePlugin
import subprocess
class BraveBrowser(BasePlugin):
main_query = 'brave'
description = 'Brave web browser'
queries = ['brave', 'brave-browser']
@classmethod
def run(cls, query):
if not opi.ask_yes_or_no('Do you want to install Brave from Brave repository?'):
return
opi.add_repo(
filename = 'brave-browser',
name = 'Brave Browser',
url = 'https://brave-browser-rpm-release.s3.brave.com/x86_64/',
gpgkey = 'https://brave-browser-rpm-release.s3.brave.com/brave-core.asc'
)
# prevent post install script from messing with our repos
subprocess.call(['sudo', 'rm', '-f', '/etc/default/brave-browser'])
subprocess.call(['sudo', 'touch', '/etc/default/brave-browser'])
opi.install_packages(['brave-browser'])
opi.ask_keep_repo('brave-browser')
================================================
FILE: opi/plugins/chrome.py
================================================
import opi
from opi.plugins import BasePlugin
import subprocess
class GoogleChrome(BasePlugin):
main_query = 'chrome'
description = 'Google Chrome web browser'
queries = ['chrome', 'google-chrome']
@classmethod
def run(cls, query):
if not opi.ask_yes_or_no('Do you want to install Chrome from Google repository?'):
return
print('Which version do you want to install?')
option = opi.ask_for_option(options=[
'google-chrome-stable',
'google-chrome-beta',
'google-chrome-unstable',
'google-chrome-canary',
])
opi.add_repo(
filename = 'google-chrome',
name = 'google-chrome',
url = 'https://dl.google.com/linux/chrome/rpm/stable/x86_64',
gpgkey = 'https://dl.google.com/linux/linux_signing_key.pub'
)
# prevent post install script from messing with our repos
defaults_file = option.replace('-stable', '')
subprocess.call(['sudo', 'rm', '-f', f'/etc/default/{defaults_file}'])
subprocess.call(['sudo', 'touch', f'/etc/default/{defaults_file}'])
opi.install_packages([option])
opi.ask_keep_repo('google-chrome')
================================================
FILE: opi/plugins/collabora.py
================================================
import opi
from opi.plugins import BasePlugin
class collabora(BasePlugin):
main_query = 'collabora'
description = 'Collabora desktop office'
queries = ['collabora', 'collaboraoffice', 'collaboraoffice-desktop']
@classmethod
def run(cls, query):
if not opi.ask_yes_or_no('Do you want to install collaboraoffice-desktop from collaboraoffice repository?'):
return
opi.add_repo(
filename = 'collabora-office',
name = 'Collabora Office 24.04 Snapshot',
url = 'https://www.collaboraoffice.com/downloads/Collabora-Office-24-Snapshot/Linux/yum',
gpgkey = 'https://www.collaboraoffice.com/downloads/Collabora-Office-24-Snapshot/Linux/yum/repodata/repomd.xml.key',
gpgcheck = True
)
opi.install_packages(['collaboraoffice-desktop'])
opi.ask_keep_repo('collabora-office')
================================================
FILE: opi/plugins/dotnet.py
================================================
import opi
from opi.plugins import BasePlugin
class MSDotnet(BasePlugin):
main_query = 'dotnet'
description = 'Microsoft .NET framework'
queries = ['dotnet-sdk', 'dotnet']
@classmethod
def run(cls, query):
if not opi.ask_yes_or_no('Do you want to install .NET from Microsoft repository?'):
return
opi.add_repo(
filename = 'dotnet',
name = 'Microsoft .NET',
url = 'https://packages.microsoft.com/opensuse/15/prod/',
gpgkey = 'https://packages.microsoft.com/keys/microsoft.asc'
)
opi.install_packages(['dotnet-sdk-9.0', 'libatomic1'])
opi.ask_keep_repo('dotnet')
================================================
FILE: opi/plugins/freeoffice.py
================================================
import opi
from opi.plugins import BasePlugin
class SoftMakerFreeOffice(BasePlugin):
main_query = 'freeoffice'
description = 'Office suite from SoftMaker (See OSS alternative libreoffice)'
queries = ['freeoffice']
@classmethod
def run(cls, query):
if not opi.ask_yes_or_no('Do you want to install FreeOffice from SoftMaker repository?'):
return
opi.add_repo(
filename = 'SoftMaker',
name = 'SoftMaker',
url = 'https://shop.softmaker.com/repo/rpm',
gpgkey = 'https://shop.softmaker.com/repo/linux-repo-public.key'
)
opi.install_packages(['softmaker-freeoffice-2024'])
opi.ask_keep_repo('SoftMaker')
================================================
FILE: opi/plugins/jami.py
================================================
import opi
from opi.plugins import BasePlugin
class Jami(BasePlugin):
main_query = 'jami'
description = 'Jami p2p messenger'
queries = [main_query, 'jami-qt', 'jami-gnome', 'jami-daemon']
@classmethod
def run(cls, query):
if not opi.ask_yes_or_no('Do you want to install jami from jami repository?'):
return
print('Which version do you want to install?')
option = opi.ask_for_option(options=[
'jami',
'jami-qt',
'jami-gnome',
'jami-daemon',
])
print('You have chosen', option)
if opi.get_distribution().startswith('openSUSE:Leap'):
repourl = f'https://dl.jami.net/nightly/opensuse-leap_{opi.get_version()}/'
else:
repourl = 'https://dl.jami.net/nightly/opensuse-tumbleweed/'
opi.add_repo(
filename = 'jami',
name = 'jami',
url = repourl,
gpgkey = 'https://dl.jami.net/jami.pub.key',
gpgcheck = False
)
opi.install_packages([option])
opi.ask_keep_repo('jami')
================================================
FILE: opi/plugins/libation.py
================================================
import opi
from opi.plugins import BasePlugin
from opi import github
class Libation(BasePlugin):
main_query = 'libation'
description = 'Tool for managing audible audiobooks'
queries = [main_query, 'Libation']
@classmethod
def run(cls, query):
arch = opi.get_cpu_arch().replace('aarch64', 'arm64').replace('x86_64', 'amd64')
github.install_rpm_release('rmcrackan', 'Libation',
filters=[lambda a: a['name'].endswith(f'{arch}.rpm')],
allow_unsigned=True # no key available
)
================================================
FILE: opi/plugins/librewolf.py
================================================
import opi
from opi.plugins import BasePlugin
class librewolf(BasePlugin):
main_query = 'librewolf'
description = 'Custom version of Firefox, focused on privacy, security and freedom'
queries = ['librewolf', 'Librewolf', 'LibreWolf']
@classmethod
def run(cls, query):
if not opi.ask_yes_or_no('Do you want to install librewolf from librewolf repository?'):
return
opi.add_repo(
filename = 'librewolf',
name = 'librewolf',
url = 'https://rpm.librewolf.net',
gpgkey = 'https://rpm.librewolf.net/pubkey.gpg'
)
opi.install_packages(['librewolf'])
opi.ask_keep_repo('librewolf')
================================================
FILE: opi/plugins/localsend.py
================================================
import os
import opi
from opi.plugins import BasePlugin
from opi.state import global_state
from opi import github
from opi import http
from opi import rpmbuild
from opi import deb
class LocalSend(BasePlugin):
main_query = 'localsend'
description = 'Share files to nearby devices'
queries = [main_query]
@classmethod
def run(cls, query):
latest_release = github.get_latest_release('localsend', 'localsend')
if not latest_release:
print(f'No release found for LocalSend')
return
match_filename_suffix = f'{opi.get_cpu_arch().replace("aarch64", "arm-64").replace("_", "-")}.deb'
asset = github.get_release_asset(latest_release, filters=[lambda a: a['name'].endswith(match_filename_suffix)])
if not asset:
print(f"No DEB asset found for LocalSend release {latest_release['tag_name']}")
return
if global_state.arg_verbose_mode:
print(f"Found: {asset['url']}")
if not opi.ask_yes_or_no(f"Do you want to install LocalSend DEB release {latest_release['tag_name']} converted to RPM from LocalSend github repo?"):
return
binary_path = 'usr/bin/localsend'
data_path = 'usr/share/localsend_app'
rpm = rpmbuild.RPMBuild('localsend', latest_release['tag_name'], cls.description, opi.get_cpu_arch(),
files = [
f"/{binary_path}",
f"/{data_path}"
]
)
deb_path = os.path.join(rpm.tmpdir.name, 'localsend.deb')
deb_path_extracted = os.path.join(rpm.tmpdir.name, 'localsend')
http.download_file(asset['url'], deb_path)
deb.extract_deb(deb_path, deb_path_extracted)
os.makedirs(os.path.join(rpm.buildroot, os.path.dirname(binary_path)), exist_ok=True)
os.symlink("../share/localsend_app/localsend_app", os.path.join(rpm.buildroot, binary_path))
rpmbuild.copy(os.path.join(deb_path_extracted, data_path), os.path.join(rpm.buildroot, data_path))
rpm.add_desktop_file(cmd="localsend %U", icon="/usr/share/localsend_app/data/flutter_assets/assets/img/logo-256.png",
Categories="GTK;FileTransfer;Utility;",
Keywords="Sharing;LAN;Files;",
StartupNotify="true"
)
rpm.build()
opi.install_packages([rpm.rpmfile_path], allow_unsigned=True)
================================================
FILE: opi/plugins/maptool.py
================================================
import opi
from opi.plugins import BasePlugin
from opi import github
class MapTool(BasePlugin):
main_query = 'maptool'
description = 'Virtual Tabletop for playing roleplaying games'
queries = ['maptool', 'MapTool']
@classmethod
def run(cls, query):
github.install_rpm_release('RPTools', 'maptool', allow_unsigned=True) # no key available
================================================
FILE: opi/plugins/megasync.py
================================================
import opi
from opi.plugins import BasePlugin
from shutil import which
class MEGAsync(BasePlugin):
main_query = 'megasync'
description = 'Mega Desktop App'
queries = ['megasync', 'megasyncapp']
@classmethod
def run(cls, query):
if not opi.ask_yes_or_no('Do you want to install MEGAsync from MEGAsync repository?'):
return
opi.add_repo(
filename = 'megasync',
name = 'MEGAsync',
url = 'https://mega.nz/linux/repo/openSUSE_Tumbleweed/',
gpgkey = 'https://mega.nz/linux/repo/openSUSE_Tumbleweed/repodata/repomd.xml.key'
)
packages = ['megasync']
if which('nautilus'):
packages.append('nautilus-megasync')
if which('nemo'):
packages.append('nemo-megasync')
if which('thunar'):
packages.append('thunar-megasync')
if which('dolphin'):
packages.append('dolphin-megasync')
opi.install_packages(packages)
opi.ask_keep_repo('megasync')
================================================
FILE: opi/plugins/ms_edge.py
================================================
import opi
import subprocess
from opi.plugins import BasePlugin
class MSEdge(BasePlugin):
main_query = 'msedge'
description = 'Microsoft Edge web browser'
queries = ['microsoft-edge', 'msedge', 'edge']
@classmethod
def run(cls, query):
if not opi.ask_yes_or_no('Do you want to install Microsoft Edge from Microsoft repository?'):
return
print('Which version do you want to install?')
option = opi.ask_for_option(options=[
'microsoft-edge-stable',
'microsoft-edge-beta',
'microsoft-edge-dev',
])
opi.add_repo(
filename = 'microsoft-edge',
name = 'Microsoft Edge',
url = 'https://packages.microsoft.com/yumrepos/edge',
gpgkey = 'https://packages.microsoft.com/keys/microsoft.asc'
)
# prevent post install script from messing with our repos
defaults_file = option.replace('-stable', '')
subprocess.call(['sudo', 'rm', '-f', f'/etc/default/{defaults_file}'])
subprocess.call(['sudo', 'touch', f'/etc/default/{defaults_file}'])
opi.install_packages([option])
opi.ask_keep_repo('microsoft-edge')
================================================
FILE: opi/plugins/mullvad-browser.py
================================================
import opi
from opi.plugins import BasePlugin
import subprocess
class MullvadBrowser(BasePlugin):
main_query = 'mullvad-browser'
description = 'Mullvad web browser'
queries = ['mullvad', 'mullvad-browser']
@classmethod
def run(cls, query):
if not opi.ask_yes_or_no('Do you want to install mullvad-browser from Mullvad repository?'):
return
opi.add_repo(
filename = 'mullvad',
name = 'Mullvad VPN',
url = 'https://repository.mullvad.net/rpm/stable/$basearch/',
gpgkey = 'https://repository.mullvad.net/rpm/mullvad-keyring.asc',
gpgcheck = 1
)
opi.install_packages(['mullvad-browser'])
opi.ask_keep_repo('mullvad')
================================================
FILE: opi/plugins/ocenaudio.py
================================================
import opi
from opi.plugins import BasePlugin
class Ocenaudio(BasePlugin):
main_query = 'ocenaudio'
description = 'Audio Editor'
queries = [main_query]
@classmethod
def run(cls, query):
if not opi.ask_yes_or_no('Do you want to install ocenaudio from ocenaudio.com?'):
return
opi.install_packages(['https://www.ocenaudio.com/downloads/index.php/ocenaudio_opensuse15.rpm'], allow_unsigned=True) # rpm is unsigned
================================================
FILE: opi/plugins/onlyoffice.py
================================================
import opi
from opi.plugins import BasePlugin
from opi import github
# only available for x86_64
if opi.get_cpu_arch() == 'x86_64':
class OnlyOffice(BasePlugin):
main_query = 'onlyoffice'
description = 'Office suite'
queries = [main_query]
@classmethod
def run(cls, query):
f1 = lambda a: a['name'] == 'onlyoffice-desktopeditors.suse12.x86_64.rpm'
github.install_rpm_release('ONLYOFFICE', 'DesktopEditors', filters=[f1], allow_unsigned=True) # no key available
print("Installation done.\nIf you experience scaling issues with the UI, try calling:\nonlyoffice-desktopeditors --force-scale=1")
================================================
FILE: opi/plugins/orca_slicer.py
================================================
import os
import opi
from opi.plugins import BasePlugin
from opi import github
from opi import rpmbuild
from opi import http
class OrcaSlicer(BasePlugin):
main_query = 'orcaslicer'
description = 'Slicer and controller for Bambu and other 3D printers'
queries = [main_query, 'orca-slicer', 'OrcaSlicer']
@classmethod
def run(cls, query):
org = 'SoftFever'
repo = 'OrcaSlicer'
latest_release = github.get_latest_release(org, repo)
if not latest_release:
print(f'No release found for {org}/{repo}')
return
version = latest_release['tag_name'].lstrip('v').replace('-', '_')
if not opi.ask_yes_or_no(f"Do you want to install {repo} release {version} from {org} github repo?"):
return
asset = github.get_release_asset(latest_release, filters=[lambda a: a['name'].endswith('.AppImage')])
if not asset:
print(f"No asset found for {org}/{repo} release {version}")
return
url = asset['url']
binary_path = 'usr/bin/OrcaSlicer'
icon_path = 'usr/share/pixmaps/OrcaSlicer.svg'
rpm = rpmbuild.RPMBuild('OrcaSlicer', version, cls.description, "x86_64", files=[
f"/{binary_path}",
f"/{icon_path}"
])
binary_abspath = os.path.join(rpm.buildroot, binary_path)
http.download_file(url, binary_abspath)
os.chmod(binary_abspath, 0o755)
icon_abspath = os.path.join(rpm.buildroot, icon_path)
icon_url = "https://raw.githubusercontent.com/SoftFever/OrcaSlicer/2d849f/resources/images/OrcaSlicer.svg"
http.download_file(icon_url, icon_abspath)
rpm.add_desktop_file(cmd="OrcaSlicer", icon=f"/{icon_path}")
rpm.build()
opi.install_packages([rpm.rpmfile_path], allow_unsigned=True)
================================================
FILE: opi/plugins/packman.py
================================================
import opi
from opi.plugins import BasePlugin
class PackmanCodecsPlugin(BasePlugin):
main_query = 'codecs'
description = 'Media Codecs from Packman and official repo'
queries = ['packman', 'codecs']
@classmethod
def run(cls, query):
# Install Packman Codecs
if not opi.ask_yes_or_no('Do you want to install codecs from Packman repository?'):
return
opi.add_packman_repo(dup=True)
packman_packages = [
'ffmpeg',
'libavcodec-full',
'vlc-codecs',
'gstreamer-plugins-bad-codecs',
'gstreamer-plugins-ugly-codecs',
'gstreamer-plugins-libav',
'libfdk-aac2',
]
if opi.get_version() not in ('15.4', '15.5'):
packman_packages.append('pipewire-aptx')
packman_packages.append('ffmpeg>=5')
opi.install_packman_packages(packman_packages)
opi.install_packages([
'gstreamer-plugins-good',
'gstreamer-plugins-good-extra',
'gstreamer-plugins-bad',
'gstreamer-plugins-ugly',
'dav1d',
])
if not opi.ask_yes_or_no('Do you want to install openh264 codecs from openSUSE openh264 repository?'):
return
opi.add_openh264_repo(dup=True)
openh264_packages = [
'mozilla-openh264',
]
# install something like gstreamer-1.20-plugin-openh264 without actually specifying any version number
gstreamer_plugin_openh264_pkg = 'libgstopenh264.so()'
if not (opi.get_cpu_arch() == 'i586' or opi.get_cpu_arch().startswith('armv7')):
gstreamer_plugin_openh264_pkg += '(64bit)'
openh264_packages.append(gstreamer_plugin_openh264_pkg)
opi.install_packages(openh264_packages)
================================================
FILE: opi/plugins/plex.py
================================================
import opi
from opi.plugins import BasePlugin
class PlexMediaServer(BasePlugin):
main_query = 'plex'
description = 'Plex Media Server (See OSS alternative jellyfin or emby)'
queries = ['plex', 'plexmediaserver']
@classmethod
def run(cls, query):
if not opi.ask_yes_or_no('Do you want to install plexmediaserver from Plex repository?'):
return
opi.add_repo(
filename = 'PlexRepo',
name = 'PlexRepo',
url = 'https://repo.plex.tv/rpm/',
gpgkey = 'https://downloads.plex.tv/plex-keys/PlexSign.v2.key'
)
opi.install_packages(['plexmediaserver'])
opi.ask_keep_repo('PlexRepo')
================================================
FILE: opi/plugins/resilio-sync.py
================================================
import opi
from opi.plugins import BasePlugin
class ResilioSync(BasePlugin):
main_query = 'resilio-sync'
description = 'Decentralized file sync between devices using bittorrent protocol (See OSS alternative syncthing)'
queries = ['resilio-sync', 'resilio', 'rslsync']
@classmethod
def run(cls, query):
if not opi.ask_yes_or_no('Do you want to install resilio-sync from resilio-sync repository?'):
return
opi.add_repo(
filename = 'resilio-sync',
name = 'resilio-sync',
url = 'https://linux-packages.resilio.com/resilio-sync/rpm/$basearch',
gpgkey = 'https://linux-packages.resilio.com/resilio-sync/key.asc',
gpgcheck = False
)
opi.install_packages(['resilio-sync'])
opi.ask_keep_repo('resilio-sync')
================================================
FILE: opi/plugins/rustdesk.py
================================================
import opi
from opi.plugins import BasePlugin
from opi import github
class RustDesk(BasePlugin):
main_query = 'rustdesk'
description = 'Open Source remote desktop application'
queries = ['rustdesk', 'RustDesk']
@classmethod
def run(cls, query):
arch = opi.get_cpu_arch()
github.install_rpm_release('rustdesk', 'rustdesk',
filters=[lambda a: a['name'].endswith(f'{arch}-suse.rpm')],
allow_unsigned=True # no key available
)
================================================
FILE: opi/plugins/skype.py
================================================
import opi
from opi.plugins import BasePlugin
class Skype(BasePlugin):
main_query = 'skype'
description = 'Microsoft Skype'
queries = ['skype']
@classmethod
def run(cls, query):
if not opi.ask_yes_or_no('Do you want to install Skype from Microsoft repository?'):
return
opi.add_repo(
filename = 'skype-stable',
name = 'Microsoft Skype',
url = 'https://repo.skype.com/rpm/stable/',
gpgkey = 'https://repo.skype.com/data/SKYPE-GPG-KEY'
)
opi.install_packages(['skypeforlinux'])
opi.ask_keep_repo('skype-stable')
================================================
FILE: opi/plugins/slack.py
================================================
import opi
from opi.plugins import BasePlugin
import subprocess
class Slack(BasePlugin):
main_query = 'slack'
description = 'Slack messenger'
queries = ['slack']
@classmethod
def run(cls, query):
if not opi.ask_yes_or_no('Do you want to install slack from the slack repository?'):
return
opi.add_repo(
filename = 'slack',
name = 'slack',
url = 'https://packagecloud.io/slacktechnologies/slack/fedora/21/$basearch',
gpgkey = 'https://packagecloud.io/slacktechnologies/slack/gpgkey'
)
# tell slack cron not to mess with our repos
subprocess.call(['sudo', 'rm', '-f', '/etc/default/slack'])
subprocess.call(['sudo', 'touch', '/etc/default/slack'])
opi.install_packages(['slack'])
opi.ask_keep_repo('slack')
================================================
FILE: opi/plugins/spotify.py
================================================
import os
import opi
import shutil
from opi.plugins import BasePlugin
from opi import rpmbuild
from opi import snap
from opi import http
class Spotify(BasePlugin):
main_query = 'spotify'
description = 'Listen to music for a monthly fee'
queries = [main_query]
@classmethod
def run(cls, query):
s = snap.get_snap('spotify')
if not opi.ask_yes_or_no(f"Do you want to install spotify release {s['version']} converted to RPM from snapcraft repo?"):
return
binary_path = 'usr/bin/spotify'
data_path = 'usr/share/spotify'
rpm = rpmbuild.RPMBuild('spotify', s['version'], cls.description, "x86_64",
conflicts = ["spotify-client"],
requires = [
"libasound2",
"libatk-bridge-2_0-0",
"libatomic1",
"libcurl4",
"libgbm1",
"libglib-2_0-0",
"libgtk-3-0",
"mozilla-nss",
"libopenssl1_1",
"libxshmfence1",
"libXss1",
"libXtst6",
"xdg-utils",
"libayatana-appindicator3-1",
],
autoreq = False,
recommends = [
"libavcodec.so",
"libavformat.so",
],
suggests = ["libnotify4"],
files = [
f"/{binary_path}",
f"/{data_path}"
]
)
snap_path = os.path.join(rpm.tmpdir.name, 'spotify.snap')
snap_path_extracted = os.path.join(rpm.tmpdir.name, 'spotify')
http.download_file(s['url'], snap_path)
snap.extract_snap(snap_path, snap_path_extracted)
binary_abspath = os.path.join(rpm.buildroot, binary_path)
rpmbuild.copy(os.path.join(snap_path_extracted, binary_path), binary_abspath)
data_abspath = os.path.join(rpm.buildroot, data_path)
rpmbuild.copy(os.path.join(snap_path_extracted, data_path), data_abspath)
rpm.add_desktop_file(cmd="spotify %U", icon="/usr/share/spotify/icons/spotify_icon.ico",
Categories="Audio;Music;Player;AudioVideo;",
MimeType="x-scheme-handler/spotify"
)
rpm.build()
opi.install_packages([rpm.rpmfile_path], allow_unsigned=True)
================================================
FILE: opi/plugins/sublime.py
================================================
import opi
from opi.plugins import BasePlugin
class SublimeText(BasePlugin):
main_query = 'sublime'
description = 'Editor for code, markup and prose'
queries = ['sublime', 'sublime-text', 'sublimetext']
@classmethod
def run(cls, query):
if not opi.ask_yes_or_no('Do you want to install sublime-text from sublime-text repository?'):
return
opi.add_repo(
filename = 'sublime-text',
name = 'sublime-text',
url = 'https://download.sublimetext.com/rpm/stable/x86_64',
gpgkey = 'https://download.sublimetext.com/sublimehq-rpm-pub.gpg'
)
opi.install_packages(['sublime-text'])
opi.ask_keep_repo('sublime-text')
================================================
FILE: opi/plugins/teams-for-linux.py
================================================
import opi
from opi.plugins import BasePlugin
class TeamsForLinux(BasePlugin):
main_query = 'teams-for-linux'
description = 'Unofficial Microsoft Teams for Linux client'
queries = ['teams-for-linux','teams']
@classmethod
def run(cls, query):
if not opi.ask_yes_or_no('Do you want to install teams-for-linux from teamsforlinux.de repository?'):
return
opi.add_repo(
filename = 'teams-for-linux',
name = 'Unofficial Teams for Linux',
url = 'https://repo.teamsforlinux.de/rpm/',
gpgkey = 'https://repo.teamsforlinux.de/teams-for-linux.asc'
)
opi.install_packages(['teams-for-linux'])
opi.ask_keep_repo('teams-for-linux')
================================================
FILE: opi/plugins/teamviewer.py
================================================
import opi
import os
from opi.plugins import BasePlugin
import subprocess
class Teamviewer(BasePlugin):
main_query = 'teamviewer'
description = 'TeamViewer remote access'
queries = ['teamviewer']
@classmethod
def run(cls, query):
if not opi.ask_yes_or_no('Do you want to install Teamviewer from Teamviewer repository?'):
return
opi.add_repo(
filename = 'teamviewer',
name = 'Teamviewer',
url = 'https://linux.teamviewer.com/yum/stable/main/binary-$basearch/',
gpgkey = 'https://linux.teamviewer.com/pubkey/currentkey.asc'
)
opi.install_packages(['teamviewer-suse'])
# Teamviewer packages its own repo file so our repo file got saved as rpmorig
subprocess.call(['sudo', 'rm', '-f', os.path.join(opi.REPO_DIR, 'teamviewer.repo.rpmorig')])
opi.ask_keep_repo('teamviewer')
================================================
FILE: opi/plugins/vagrant.py
================================================
import opi
from opi.plugins import BasePlugin
class Vagrant(BasePlugin):
main_query = 'vagrant'
description = 'Tool for building and distributing development environments'
queries = [main_query]
@classmethod
def run(cls, query):
if not opi.ask_yes_or_no('Do you want to install Vagrant from Hashicorp repository?'):
return
opi.add_repo(
filename = 'hashicorp',
name = 'Hashicorp',
url = 'https://rpm.releases.hashicorp.com/AmazonLinux/latest/$basearch/stable',
gpgkey = 'https://rpm.releases.hashicorp.com/gpg'
)
opi.install_packages(['vagrant'])
opi.ask_keep_repo('hashicorp')
================================================
FILE: opi/plugins/vivaldi.py
================================================
import opi
from opi.plugins import BasePlugin
class Vivaldi(BasePlugin):
main_query = 'vivaldi'
description = 'Vivaldi web browser'
queries = ['vivaldi']
@classmethod
def run(cls, query):
if not opi.ask_yes_or_no('Do you want to install Vivaldi from Vivaldi repository?'):
return
option = opi.ask_for_option(options=[
'vivaldi-stable',
'vivaldi-snapshot',
])
opi.add_repo(
filename = 'vivaldi',
name = 'vivaldi',
url = 'https://repo.vivaldi.com/archive/rpm/$basearch',
gpgkey = 'https://repo.vivaldi.com/archive/linux_signing_key.pub'
)
opi.install_packages([option])
opi.ask_keep_repo('vivaldi')
================================================
FILE: opi/plugins/vs_code.py
================================================
import opi
from opi.plugins import BasePlugin
class VSCode(BasePlugin):
main_query = 'vscode'
description = 'Microsoft Visual Studio Code'
queries = ['visualstudiocode', 'vscode', 'vsc']
@classmethod
def run(cls, query):
if not opi.ask_yes_or_no('Do you want to install VS Code from Microsoft repository?'):
return
option = opi.ask_for_option(options=[
'code',
'code-exploration',
'code-insiders',
])
opi.add_repo(
filename = 'vscode',
name = 'Visual Studio Code',
url = 'https://packages.microsoft.com/yumrepos/vscode',
gpgkey = 'https://packages.microsoft.com/keys/microsoft.asc'
)
opi.install_packages([option])
opi.ask_keep_repo('vscode')
================================================
FILE: opi/plugins/vs_codium.py
================================================
import opi
from opi.plugins import BasePlugin
class VSCodium(BasePlugin):
main_query = 'vscodium'
description = 'Visual Studio Codium'
queries = ['visualstudiocodium', 'vscodium', 'codium']
@classmethod
def run(cls, query):
if not opi.ask_yes_or_no('Do you want to install VS Codium from paulcarroty_vscodium repository?'):
return
opi.add_repo(
filename = 'vscodium',
name = 'Visual Studio Codium',
url = 'https://paulcarroty.gitlab.io/vscodium-deb-rpm-repo/rpms',
gpgkey = 'https://gitlab.com/paulcarroty/vscodium-deb-rpm-repo/raw/master/pub.gpg'
)
opi.install_packages(['codium'])
opi.ask_keep_repo('vscodium')
================================================
FILE: opi/plugins/yandex-browser.py
================================================
import opi
from opi.plugins import BasePlugin
class YandexBrowser(BasePlugin):
main_query = 'yandex-browser'
description = 'Yandex web browser'
queries = ['yandex-browser-stable', 'yandex-browser-beta', 'yandex-browser']
@classmethod
def run(cls, query):
if not opi.ask_yes_or_no('Do you want to install yandex-browser from yandex-browser repository?'):
return
print('Which version do you want to install?')
option = opi.ask_for_option(options=[
'yandex-browser-stable',
'yandex-browser-beta',
])
release = option.split('-')[-1]
print('You have chosen', release)
opi.add_repo(
filename = option,
name = option,
url = f'https://repo.yandex.ru/yandex-browser/rpm/{release}/$basearch/',
gpgkey = 'https://repo.yandex.ru/yandex-browser/YANDEX-BROWSER-KEY.GPG',
gpgcheck = False
)
opi.install_packages([option])
opi.ask_keep_repo(option)
================================================
FILE: opi/plugins/yandex-disk.py
================================================
import opi
from opi.plugins import BasePlugin
class YandexDisk(BasePlugin):
main_query = 'yandex-disk'
description = 'Yandex.Disk cloud storage client'
queries = ['yandex-disk']
@classmethod
def run(cls, query):
if not opi.ask_yes_or_no('Do you want to install yandex-disk from yandex-disk repository?'):
return
opi.add_repo(
filename = 'yandex-disk',
name = 'yandex-disk',
url = 'https://repo.yandex.ru/yandex-disk/rpm/stable/$basearch/',
gpgkey = 'https://repo.yandex.ru/yandex-disk/YANDEX-DISK-KEY.GPG',
gpgcheck = False
)
opi.install_packages(['yandex-disk'])
opi.ask_keep_repo('yandex-disk')
================================================
FILE: opi/plugins/zellij.py
================================================
import os
import subprocess
import opi
from opi.plugins import BasePlugin
from opi import github
from opi import rpmbuild
from opi import http
# VERSION is only set on leap based distros - not tumbleweed, where this package is available via default repos
if opi.get_version():
class Zellij(BasePlugin):
main_query = 'zellij'
description = 'A terminal workspace with batteries included'
queries = [main_query]
@classmethod
def run(cls, query):
org = "zellij-org"
repo = "zellij"
latest_release = github.get_latest_release(org, repo)
if not latest_release:
print(f'No release found for {org}/{repo}')
return
version = latest_release['tag_name'].lstrip('v')
if not opi.ask_yes_or_no(f"Do you want to install {repo} release {version} from {org} github repo?"):
return
arch = opi.get_cpu_arch()
asset_name = f'zellij-{arch}-unknown-linux-musl.tar.gz'
asset = github.get_release_asset(latest_release, filters=[lambda e: e['name'] == asset_name])
if not asset:
print(f"No asset found for {org}/{repo} release {version}")
return
url = asset['url']
binary_path = 'usr/bin/zellij'
rpm = rpmbuild.RPMBuild('zellij', version, cls.description, arch, files=[
f"/{binary_path}",
])
bindir_abspath = os.path.join(rpm.buildroot, os.path.dirname(binary_path))
binary_abspath = os.path.join(rpm.buildroot, binary_path)
tarball_abspath = os.path.join(rpm.tmpdir.name, asset_name)
http.download_file(url, tarball_abspath)
os.makedirs(bindir_abspath, exist_ok=True)
subprocess.call(['tar', 'xvf', tarball_abspath, '-C', bindir_abspath, 'zellij'])
os.chmod(binary_abspath, 0o755)
rpm.build()
opi.install_packages([rpm.rpmfile_path], allow_unsigned=True)
================================================
FILE: opi/plugins/zoom.py
================================================
import opi
from opi.plugins import BasePlugin
class Zoom(BasePlugin):
main_query = 'zoom'
description = 'Zoom Video Conference'
queries = ['zoom']
@classmethod
def run(cls, query):
if not opi.ask_yes_or_no('Do you want to install Zoom from zoom.us?'):
return
key_url = 'https://zoom.us/linux/download/pubkey?version=5-12-6'
opi.ask_import_key(key_url)
opi.install_packages(['https://zoom.us/client/latest/zoom_openSUSE_x86_64.rpm'])
opi.ask_keep_key(key_url)
================================================
FILE: opi/rpmbuild.py
================================================
import os
import tempfile
import re
import subprocess
import glob
import shutil
from shutil import which
from opi import install_packages
def copy(src, dst):
"""
Copy src to dst using hardlinks.
dst will be the full final path.
Directories will be created as needed.
"""
if os.path.islink(src) or os.path.isfile(src):
os.makedirs(os.path.dirname(dst), exist_ok=True)
if os.path.islink(src):
link_target = os.readlink(src)
os.symlink(link_target, dst)
elif os.path.isfile(src):
shutil.copy2(src, dst)
else:
shutil.copytree(src, dst, copy_function=os.link, symlinks=True, ignore_dangling_symlinks=False)
def dedent(s):
""" Other than textwrap's implementation this one has no problems with some lines unindented.
It will unconditionally strip any leading whitespaces for each line.
"""
return re.sub(r"^\s*", "", s, flags=re.M)
class RPMBuild:
def __init__(self, name, version, description, buildarch="noarch",
requires=[], recommends=[], provides=[], suggests=[], conflicts=[], autoreq=True,
files=[], dirs=[], config=[]):
self.name = name
self.version = version
self.description = description
self.buildarch = buildarch
self.requires = requires
self.recommends = recommends
self.provides = provides
self.suggests = suggests
self.conflicts = conflicts
self.autoreq = autoreq
self.files = files
self.dirs = dirs
self.config = config
self.tmpdir = tempfile.TemporaryDirectory()
self.buildroot = os.path.join(self.tmpdir.name, "buildroot") # buildroot where plugins copy files to
self.spec_path = os.path.join(self.tmpdir.name, "specfile.spec")
self.rpm_out_dir = os.path.join(self.tmpdir.name, "rpms")
os.mkdir(self.buildroot)
os.mkdir(self.rpm_out_dir)
if not which('rpmbuild'):
print("Installing requirement: rpm-build")
install_packages(['rpm-build'], no_recommends=True, non_interactive=True)
def mkspec(self):
nl = "\n"
spec = dedent(f"""
Name: {self.name}
Version: {self.version}
Release: 0
Summary: {self.description}
License: n/a
BuildArch: {self.buildarch}
{nl.join(f"Requires: {r}" for r in self.requires)}
{nl.join(f"Recommends: {r}" for r in self.recommends)}
{nl.join(f"Provides: {r}" for r in self.provides)}
{nl.join(f"Suggests: {r}" for r in self.suggests)}
{nl.join(f"Conflicts: {r}" for r in self.conflicts)}
{"AutoReq: no" if not self.autoreq else ''}
%description
{self.description}
Built locally using OPI.
%files
{nl.join(self.files)}
{nl.join(f"%dir {d}" for d in self.dirs)}
{nl.join(f"%config {c}" for c in self.config)}
%changelog
""")
return spec
def add_desktop_file(self, cmd, icon, **kwargs):
os.makedirs(os.path.join(self.buildroot, 'usr/share/applications'))
desktop_path = f'usr/share/applications/{self.name}.desktop'
desktop_abspath = os.path.join(self.buildroot, desktop_path)
self.files.append(f"/{desktop_path}")
with open(desktop_abspath, 'w') as f:
nl = "\n"
f.write(dedent(f"""
[Desktop Entry]
Name={self.name}
Comment={self.description}
Exec={cmd}
Icon={icon}
Type=Application
{nl.join(["%s=%s" % (k, v) for k, v in kwargs.items()])}
"""))
def build(self):
print(f"Creating RPM for {self.name}")
with open(self.spec_path, 'w') as f:
spec = self.mkspec()
f.write(spec)
subprocess.check_call([
"rpmbuild", "-bb", "--build-in-place",
"--buildroot", self.buildroot,
"--define", f"_rpmdir {self.rpm_out_dir}",
"specfile.spec"
], cwd=self.tmpdir.name)
rpmfile = glob.glob(f"{self.rpm_out_dir}/*/*.rpm")[0]
self.rpmfile_path = rpmfile
return rpmfile
================================================
FILE: opi/snap.py
================================================
import subprocess
import requests
from shutil import which
from opi import install_packages
def http_get_json(url):
r = requests.get(url, headers={'Snap-Device-Series': '16'})
r.raise_for_status()
return r.json()
def get_snap(snap, channel='stable', arch=None):
channels = http_get_json(f'https://api.snapcraft.io/v2/snaps/info/{snap}')['channel-map']
if arch:
arch.replace('x86_64', 'amd64')
channels = [c for c in channels if c['channel']['architecture'] == arch]
channels = [c for c in channels if c['channel']['name'] == channel]
c = channels[0]
return {"version": c['version'], "url": c['download']['url']}
def extract_snap(snap, target_dir):
if not which('unsquashfs'):
print("Installing requirement: squashfs")
install_packages(['squashfs'], no_recommends=True, non_interactive=True)
subprocess.check_call(['unsquashfs', '-d', target_dir, snap])
================================================
FILE: opi/state.py
================================================
class GlobalState:
default_state = {
'arg_non_interactive': False,
'arg_verbose_mode': False,
}
state = {
}
def __setattr__(self, key, value):
type(self).state[key] = value
def __getattr__(self, key):
return type(self).state.get(key, type(self).default_state[key])
global_state = GlobalState()
================================================
FILE: opi/version.py
================================================
__version__ = '5.12.0'
================================================
FILE: opi.changes
================================================
-------------------------------------------------------------------
Fri Mar 13 14:49:59 UTC 2026 - Dominik Heidler
- Version 5.12.0
* Fix plex repo cleanup
* plex repo update
* Harden the systemd service
* fetch openh264 repos via https
* get anydesk repo via https
* get chrome repos via https
-------------------------------------------------------------------
Fri Feb 13 14:53:11 UTC 2026 - Dominik Heidler
- Version 5.11.0
* Explicitly install libatomic1 required by dotnet
-------------------------------------------------------------------
Mon Jan 19 10:50:51 UTC 2026 - Dominik Heidler
- Version 5.10.0
* Add antigravity (fixes #214)
-------------------------------------------------------------------
Thu Nov 13 15:26:52 UTC 2025 - Dominik Heidler
- Version 5.9.0
* Add onlyoffice
-------------------------------------------------------------------
Tue Oct 7 22:08:09 UTC 2025 - Dominik Heidler
- Version 5.8.10
* Fix handling of None version on Tumbleweed
-------------------------------------------------------------------
Mon Oct 6 08:34:17 UTC 2025 - Dominik Heidler
- Version 5.8.9
* Fix VERSION KeyError in Tumbleweed
-------------------------------------------------------------------
Tue Sep 30 12:08:54 UTC 2025 - Dominik Heidler
- Version 5.8.8
* Fix adding openh264 repo on leap 16.0
-------------------------------------------------------------------
Thu Sep 4 09:23:19 UTC 2025 - Dominik Heidler
- Version 5.8.7
* Fix ocenaudio url
* Add LocalSend plugin
* Run all tests in verbose mode
* Print written repo files in verbose mode
* Increase timeouts in test/06_install_non_interactive.py
* Remove DNF references from README.md
-------------------------------------------------------------------
Mon Jun 2 10:16:26 UTC 2025 - Dominik Heidler
- Version 5.8.5
* add librewolf plugin (#205)
* Install .NET 9
* Add verbose mode
* Change the order of the process in the github module
* Add rustdesk plugin
-------------------------------------------------------------------
Mon May 26 10:40:34 UTC 2025 - Dominik Heidler
- Version 5.8.4
* Use arm64 rpm for libation on aarch64
-------------------------------------------------------------------
Tue Apr 22 11:55:07 UTC 2025 - Dominik Heidler
- Version 5.8.3
* Install dependencies rpm-build and squashfs at runtime if needed
* Drop DNF support
-------------------------------------------------------------------
Tue Apr 22 08:08:34 UTC 2025 - Dominik Heidler
- Version 5.8.2
* Warn about adding staging repos
* Gracefully handle zypper exit code 106 (repos without cache present)
-------------------------------------------------------------------
Wed Mar 12 11:07:52 UTC 2025 - Dominik Heidler
- Version 5.8.1
* Fix SyntaxWarning: invalid escape sequence '\s'
-------------------------------------------------------------------
Mon Feb 24 11:39:20 UTC 2025 - Dominik Heidler
- Version 5.8.0
* Add mullvad-brower
-------------------------------------------------------------------
Sun Feb 16 16:13:17 UTC 2025 - Dominik Heidler
- Version 5.7.0
* Add leap-only plugin to install zellij from github release
* Don't use subprocess.run user kwarg on 15.6
* Fix tests: Use helloworld-opi-tests instead of zfs
* Perform search despite locked rpmdb
* Simplify backend code
-------------------------------------------------------------------
Thu Jan 23 13:53:06 UTC 2025 - Dominik Heidler
- Version 5.6.0
* Add plugin to install vagrant from hashicorp repo
-------------------------------------------------------------------
Tue Jan 14 15:35:14 UTC 2025 - Dominik Heidler
- Version 5.5.0
* Update opi/plugins/collabora.py
* add collabora office desktop
* Omit unsupported cli args on leap in 99_install_opi.py
* Switch to PEP517 install
* Fix 09_install_with_multi_repos_in_single_file_non_interactive.py
* Fix 07_install_multiple.py on tumbleweed
* Fix test suite on tumbleweed
* Update available apps in opi - README.md
-------------------------------------------------------------------
Mon Nov 4 12:13:42 UTC 2024 - Dominik Heidler
- Version 5.4.0
* Show key ID when importing or deleting package signing keys
* Add option to install google-chrome-canary
-------------------------------------------------------------------
Fri Oct 25 12:03:28 UTC 2024 - Dominik Heidler
- Version 5.3.0
* Fix tests for new zypper version
* fix doblue slash in packman repo url
* Add Plugin to install Libation
-------------------------------------------------------------------
Mon Jun 24 09:04:47 UTC 2024 - Dominik Heidler
- Version 5.2.1
* Update freeoffice.py: Install version 2024
-------------------------------------------------------------------
Tue Jun 11 14:12:30 UTC 2024 - Dominik Heidler
- Version 5.2.0
* Add config option to reverse option order
-------------------------------------------------------------------
Fri Jun 7 13:17:38 UTC 2024 - Dominik Heidler
- Version 5.1.0
* Use checkout@v4 for CI
* Update issue templates
* Increase prio from 90 to 70 for packman/openh264 repos
-------------------------------------------------------------------
Thu Feb 1 09:41:57 UTC 2024 - Dominik Heidler
- Version 5.0.0
* Allow selecting mirror 1st time when adding packman repo
* Add Plugin for SoftMaker Freeoffice
* Use new osc service run cmd syntax
* Codecs: Install AV1 decoder for mpv
* Bump .NET SDK plugin to .NET 8.0
-------------------------------------------------------------------
Tue Jan 2 13:54:28 UTC 2024 - Dominik Heidler
- Version 4.4.0
* Match repos by alias when searching local repos
* Rephrase OSS alternative hints
* Fix typo in rpmbuild.py
-------------------------------------------------------------------
Fri Dec 15 18:09:52 UTC 2023 - Dominik Heidler
- Version 4.3.0
* Hint open source alternatives
* Fix issue with installing from existing openh264 repo
-------------------------------------------------------------------
Tue Dec 12 12:40:20 UTC 2023 - Dominik Heidler
- Version 4.2.0
* Support multiple repos defined in a single .repo file
* Automatically import packman key in non-interactive mode
* Restructure code: Add classes for Repository, OBSPackage and LocalPackage
* Hide package release for pkgs from local repos (same as with OBS pkgs)
* Use tumbleweed repo for openh264 on Slowroll
* Expand repovar $basearch (to e.g. x86_64 or aarch64)
-------------------------------------------------------------------
Thu Dec 7 10:30:24 UTC 2023 - Dominik Heidler
- Version 4.1.0
* Add support for Slowroll
* Replace $releasever also with ${releasever} syntax
* Update changelog prefix to *
-------------------------------------------------------------------
Fri Nov 17 14:05:21 UTC 2023 - Dominik Heidler
- Version 4.0.0
* Simplify rpmbuild by removing %install
* Add opi new dependencies to testsuite: rpm-build, squashfs
* Rename rpmbuild internal dirs to uppercase
* Fix building RPMs for Leap 15.5
* Update opi-proxy .service file to listen on IPv6 as well
* Add Snap library and Spotify plugin
* Allow installing non-rpm applications (add OrcaSlicer)
* chore: update multi_install description
* Indent changes in changelog further than version
-------------------------------------------------------------------
Wed Oct 11 10:08:35 UTC 2023 - Dominik Heidler
- Version 3.6.0
- Increase timeouts in testsuite and improve output
- test: remove yandex-disk from multi-install test
- Run testsuite for (fake) MicroOS
- Fix repo URL generation for MicroOS and Leap Micro (fixes #158)
- Add multi package option
- Add ocenaudio audio editor (fixes #155)
- Ignore gpg check for unsigned pkgs (or pkgs without published key)
-------------------------------------------------------------------
Mon Sep 25 13:23:05 UTC 2023 - Dominik Heidler
- Version 3.5.0
- Expand releasever for local repo names
- Make resilio comment shorter
- Add option to skip plugins
- Update repo URL for MEGASync
-------------------------------------------------------------------
Wed Aug 30 13:32:14 UTC 2023 - Dominik Heidler
- Version 3.4.0
- Add unofficial Teams-for-linux client
- Improve non interactive tests
- Strip test module name
- chore: fix indentation
- docs: add config options, update opi help page
-------------------------------------------------------------------
Fri Jul 28 10:01:21 UTC 2023 - Dominik Heidler
- Version 3.3.0
- Add tests and tweak weighting algorithm for non interactive mode
- Allow running without user interaction
- Add config option to disable auto refresh
-------------------------------------------------------------------
Thu Jul 13 09:12:57 UTC 2023 - Dominik Heidler
- Version 3.2.0
- fix: add missing format string marks, remove empty lines
- Make release.sh more robust
-------------------------------------------------------------------
Tue Jul 11 18:07:59 UTC 2023 - Dominik Heidler
- Version 3.1.0
- Add MapTool RPM tool
-------------------------------------------------------------------
Mon Jun 19 08:56:53 UTC 2023 - Dominik Heidler
- Version 3.0.0
- Use best repo for each project (fixes #113)
- Use new rpm signing key for zoom (fixes #133)
- cleanup code
- Remove MS teams as it is discontinued
-------------------------------------------------------------------
Mon Apr 3 12:49:29 UTC 2023 - Dominik Heidler
- Version 2.17.0
- Codecs: Don't force ffmpeg>=5 on leap 15.5
- Use new checkout version in ci.yaml
-------------------------------------------------------------------
Mon Apr 3 10:23:42 UTC 2023 - Dominik Heidler
- Version 2.16.0
- dotnet: Install dotnet-sdk-7.0 (#124)
- Add jami p2p messenger plugin (#121)
-------------------------------------------------------------------
Sat Feb 18 22:42:32 UTC 2023 - Dominik Heidler
- Version 2.15.0
- Fix repo name encoding when asking for new key addition
-------------------------------------------------------------------
Mon Feb 13 16:35:28 UTC 2023 - Dominik Heidler
- Version 2.14.0
- Install openh264 according to arch
- Use http instead of https for openh264 repo
-------------------------------------------------------------------
Mon Feb 13 10:27:03 UTC 2023 - Dominik Heidler
- Version 2.13.0
- Add openh264 (#119)
-------------------------------------------------------------------
Mon Feb 13 09:41:31 UTC 2023 - Dominik Heidler
- Version 2.12.0
- Enforce ffmpeg>=5 on tumbleweed
-------------------------------------------------------------------
Mon Jan 30 14:41:42 UTC 2023 - Dominik Heidler
- Version 2.11.0
- Handle repos with multiple keys in key file (fixes #118)
-------------------------------------------------------------------
Wed Jan 25 12:57:21 UTC 2023 - Dominik Heidler
- Version 2.10.0
- Ask for submit in release.sh
- Fix packman plugin for 15.4
- Introduce repo key handling (bsc#1207334)
-------------------------------------------------------------------
Mon Jan 2 11:27:29 UTC 2023 - Dominik Heidler
- Version 2.9.0
- Install selected package explicitly from the selected repo
- Switch to resilio-sync for testsuite
- add resilio-sync
-------------------------------------------------------------------
Tue Aug 9 13:58:57 UTC 2022 - Dominik Heidler
- Version 2.8.0
- add anydesk
- add yandex browser
- Use list for plugin queries and check for conflicts
- Don't show projects with non-matching repo
-------------------------------------------------------------------
Mon Jun 13 09:08:05 UTC 2022 - Dominik Heidler
- Version 2.7.0
- Make repo parsing more stable and improve error handling
-------------------------------------------------------------------
Tue May 31 14:44:14 UTC 2022 - Dominik Heidler
- Version 2.6.0
- Move to global config in /etc/opi.cfg
- Check if desired repo is already added instead of relying on prefix
- Add config option use_releasever_var
-------------------------------------------------------------------
Mon May 16 15:07:53 UTC 2022 - Dominik Heidler
- Version 2.5.0
- Run ci for both tumbleweed and leap
- Use $releasever in repo creation on Leap
-------------------------------------------------------------------
Mon Apr 25 08:54:45 UTC 2022 - Dominik Heidler
- Version 2.4.7
- Fix numbering in --help
- Add release helper script
-------------------------------------------------------------------
Fri Apr 22 12:43:05 UTC 2022 - Dominik Heidler
- Version 2.4.6
- Update .NET SDK to 6.0
-------------------------------------------------------------------
Tue Mar 1 17:44:14 UTC 2022 - Dominik Heidler
- Version 2.4.5
- Update packman codecs plugin to reflect recent changes
that apply to Tumbleweed and releases after 15.4
see https://lists.opensuse.org/archives/list/factory@lists.opensuse.org/thread/VMXOWQWC4WW3W6PM7WPZDRMNCV26KKGY/
-------------------------------------------------------------------
Fri Jan 28 11:07:25 UTC 2022 - Dominik Heidler
- Version 2.4.4
- Fix for Alpha/Beta dist versions
-------------------------------------------------------------------
Mon Jan 24 11:23:50 UTC 2022 - Dominik Heidler
- Version 2.4.3
- Fix for tumbleweed based MicroOS
-------------------------------------------------------------------
- Version 2.4.2 - 2021-10-25
## Changed
- Switched to opensuse provided opi proxy
-------------------------------------------------------------------
- Version 2.4.1 - 2021-10-11
## Changed
- Don't expect output to be a tty
-------------------------------------------------------------------
- Version 2.4.0 - 2021-10-11
## Added
- Scroll results if they not fit on the screen
- Plugin for atom editor
-------------------------------------------------------------------
# Version 2.3.0 - 2021-06-06
### Changed
- Fixed gpgcheck entry in `add_repo()`
- Allowed using multiple query keywords that are combined using AND
### Added
- Plugin for sublime text
- Plugin for yandex-disk
-------------------------------------------------------------------
- Version 2.2.0 - 2021-08-20
### Added
- Plugin for MEGA
- Plugin for Edge Beta
- Argument parser with option for reverse output order
-------------------------------------------------------------------
- Version 2.1.1 - 2021-08-10
### Added
- Plugin for Brave Browser [#60](https://github.com/openSUSE/opi/pull/60)
-------------------------------------------------------------------
- Version 2.1.0 - 2021-07-05
### Added
- Support for dnf backend [#58](https://github.com/openSUSE/opi/pull/58)
### Changed
- Deduplicated packman repo creation code
-------------------------------------------------------------------
- Version 2.0.0 - 2021-05-03
### Added
- [Automated tests](https://github.com/openSUSE/opi/actions)
- Extensible Plugin interface for plugins (eg. [this one](https://github.com/openSUSE/opi/blob/master/opi/plugins/vivaldi.py))
- Added plugins for chrome, dotnet, edge, teams, packman, plex, skype, slack, teamviewer, vivaldi, vscode, vscodium, zoom
### Changed
- Rewrote the complete tool in python3
-------------------------------------------------------------------
- Version 0.10.0 - 2021-01-17
### Added
- Microsoft Teams installer [#34](https://github.com/openSUSE/opi/pulls/34)
- Warning for personal repository [#35](https://github.com/openSUSE/opi/pulls/35)
-------------------------------------------------------------------
- Version 0.9.0 - 2020-10-03
### Added
- Help (-h, --help) and version (-v, --version) option
### Changed
- Filter out -devel, -docs and -lang packages [#30](https://github.com/openSUSE/opi/pulls/30)
- Don't show i586 packages on x86_64 system
-------------------------------------------------------------------
- Version 0.8.3 - 2020-07-25
### Fixed
- ffmpeg/libav packages due to Packman update
-------------------------------------------------------------------
- Version 0.8.2 - 2020-05-16
### Fixed
- Ghost process on XML parsing failure [#27](https://github.com/openSUSE/opi/pulls/27)
-------------------------------------------------------------------
- Version 0.8.1 - 2020-04-03
### Fixed
- OBS limit error when searching php, test, etc.
-------------------------------------------------------------------
- Version 0.8.0
### Changed
- Type number `0` to exit [#26](https://github.com/openSUSE/opi/pulls/26)
-------------------------------------------------------------------
- Version 0.7.1
### Fixed
- Missing `use File::Temp;` [#24](https://github.com/openSUSE/opi/issues/24)
-------------------------------------------------------------------
- Version 0.7.0
### Changed
- Force repo URL to HTTPS [#22](https://github.com/openSUSE/opi/issues/22)
### Fixed
- Ctrl + C handling of spinner
-------------------------------------------------------------------
- Version 0.6.0
### Added
- Search spinner [#21](https://github.com/openSUSE/opi/issues/21)
### Fixed
- Packman repo doesn't have *.repo file [#19](https://github.com/openSUSE/opi/issues/19)
- Long version numbers are cutted [#17](https://github.com/openSUSE/opi/issues/17)
-------------------------------------------------------------------
- Version 0.5.2
### Fixed
- Trim "NAME" and "VERSION" string [#13](https://github.com/openSUSE/opi/issues/13)
-------------------------------------------------------------------
- Version 0.5.1
### Fixed
- Fix dependency not found issue [#11](https://github.com/openSUSE/opi/issues/11)
-------------------------------------------------------------------
- Version 0.5.0
### Added
- API proxy server to prevent hard-coded passwords in the script [#4](https://github.com/openSUSE/opi/issues/4)
-------------------------------------------------------------------
- Version 0.4.0
### Added
- PMBS (Packman Build Service) support [#5](https://github.com/openSUSE/opi/issues/5)
-------------------------------------------------------------------
- Version 0.3.2
### Fixed
- `opi opi` cannot find `opi` [#9](https://github.com/openSUSE/opi/issues/9)
-------------------------------------------------------------------
- Version 0.3.1
### Fixed
- Remove quotes from version number. So Leap and SLE can search packages.
-------------------------------------------------------------------
- Version 0.3.0
### Added
- Support SLE [#8](https://github.com/openSUSE/opi/issues/8)
### Changed
- Better print column alignment
-------------------------------------------------------------------
- Version 0.2.0
### Added
- Install Packman Codecs with `opi packman` or `opi codecs` [#6](https://github.com/openSUSE/opi/issues/6)
- Install Skype with `opi skype` [#6](https://github.com/openSUSE/opi/issues/6)
- Install VS Code with `opi vs code` [#6](https://github.com/openSUSE/opi/issues/6)
-------------------------------------------------------------------
- Version 0.1.2
### Fixed
- Fixed lost of "noarch" packages [#3](https://github.com/openSUSE/opi/issues/3)
- Be able to search with dashes in keywords [#2](https://github.com/openSUSE/opi/issues/2)
-------------------------------------------------------------------
- Version 0.1.1
### Fixed
- Removed XML dump which may cause problems.
-------------------------------------------------------------------
- Version 0.1.0
### Added
- Search packages from OBS
- List properly sorted search result
- Use different colors for official, experimental and personal projects
- Choose package and install
- Keep or remove repository after installation
[Unreleased]: https://github.com/openSUSE/opi/compare/v0.10.0...HEAD
[0.10.0]: https://github.com/openSUSE/opi/compare/v0.9.0...v0.10.0
[0.9.0]: https://github.com/openSUSE/opi/compare/v0.8.3...v0.9.0
[0.8.3]: https://github.com/openSUSE/opi/compare/v0.8.2...v0.8.3
[0.8.2]: https://github.com/openSUSE/opi/compare/v0.8.1...v0.8.2
[0.8.1]: https://github.com/openSUSE/opi/compare/v0.8.0...v0.8.1
[0.8.0]: https://github.com/openSUSE/opi/compare/v0.7.1...v0.8.0
[0.7.1]: https://github.com/openSUSE/opi/compare/v0.7.0...v0.7.1
[0.7.0]: https://github.com/openSUSE/opi/compare/v0.6.0...v0.7.0
[0.6.0]: https://github.com/openSUSE/opi/compare/v0.5.2...v0.6.0
[0.5.2]: https://github.com/openSUSE/opi/compare/v0.5.1...v0.5.2
[0.5.1]: https://github.com/openSUSE/opi/compare/v0.5.0...v0.5.1
[0.5.0]: https://github.com/openSUSE/opi/compare/v0.4.0...v0.5.0
[0.4.0]: https://github.com/openSUSE/opi/compare/v0.3.2...v0.4.0
[0.3.2]: https://github.com/openSUSE/opi/compare/v0.3.1...v0.3.2
[0.3.1]: https://github.com/openSUSE/opi/compare/v0.3.0...v0.3.1
[0.3.0]: https://github.com/openSUSE/opi/compare/v0.2.0...v0.3.0
[0.2.0]: https://github.com/openSUSE/opi/compare/v0.1.2...v0.2.0
[0.1.2]: https://github.com/openSUSE/opi/compare/v0.1.1...v0.1.2
[0.1.1]: https://github.com/openSUSE/opi/compare/v0.1.0...v0.1.1
[0.1.0]: https://github.com/openSUSE/opi/releases/tag/v0.1.0
================================================
FILE: opi.default.cfg
================================================
[opi]
use_releasever_var = true
new_repo_auto_refresh = true
list_in_reverse = false
================================================
FILE: org.openSUSE.opi.appdata.xml
================================================
org.openSUSE.opiCC0-1.0OPIopenSUSE Package Installer
Search and install almost all packages available for openSUSE and SLE:
openSUSE Build Service
Packman Build Service
https://github.com/openSUSE/opihttps://github.com/openSUSE/opi/issueshttps://www.patreon.com/guoyunhe/creatorshttps://github.com/openSUSE/opi
================================================
FILE: proxy/.gitignore
================================================
vendor
config.php
================================================
FILE: proxy/README.txt
================================================
This proxy application is needed as OBS requires
authentication for certain API calls.
================================================
FILE: proxy/config.sample.json
================================================
{
"openSUSE": {
"user": "OBS_USERNAME",
"pass": "OBS_PASS",
"url": "https://api.opensuse.org/"
},
"Packman": {
"user": "PMBS_USERNAME",
"pass": "PMBS_PASS",
"url": "https://pmbs.links2linux.de/"
}
}
================================================
FILE: proxy/dependencies.txt
================================================
python3-gunicorn python3-Flask python3-requests python3-gevent
================================================
FILE: proxy/install.sh
================================================
#!/bin/bash
python3 setup.py install -f
cp -v opi-proxy.service /etc/systemd/system/
systemctl daemon-reload
test -e /etc/opi-proxy.json || cp -v config.sample.json /etc/opi-proxy.json
================================================
FILE: proxy/opi-proxy.service
================================================
[Unit]
Description=OPI Proxy
After=syslog.target
[Service]
ExecStart=/usr/bin/gunicorn -b [::]:80 opi_proxy:app -k gevent -u nobody -g nogroup --log-syslog
Environment=CONFIG=/etc/opi-proxy.json
Restart=always
Type=simple
# Filesystem isolation
ProtectSystem=strict
ProtectHome=yes
PrivateTmp=yes
# Device access
PrivateDevices=yes
DevicePolicy=closed
# Syscall filtering
SystemCallFilter=@system-service
# Kernel/system protection
ProtectKernelTunables=yes
ProtectKernelModules=yes
ProtectKernelLogs=yes
ProtectControlGroups=yes
ProtectClock=yes
ProtectHostname=yes
RestrictNamespaces=yes
RestrictRealtime=yes
RestrictSUIDSGID=yes
LockPersonality=yes
MemoryDenyWriteExecute=yes
[Install]
WantedBy=multi-user.target
================================================
FILE: proxy/opi_proxy/__init__.py
================================================
#!/usr/bin/python3
import os
import json
import requests
from flask import Flask, request, Response
app = Flask(__name__)
CONFIG_FILE = os.environ.get('CONFIG', 'config.json')
config = json.load(open(CONFIG_FILE))
@app.route('/')
def endpoint():
c = config[request.args['obs_instance']]
assert request.args['obs_api_link'].startswith(c['url'])
r = requests.get(request.args['obs_api_link'], auth=(c['user'], c['pass']))
r.raise_for_status()
return Response(
r.text,
status=r.status_code,
headers={
'Access-Control-Allow-Origin': '*'
},
mimetype=r.headers.get('content-type', 'text/plain')
)
if __name__ == '__main__':
app.run(host='0.0.0.0', debug=True)
================================================
FILE: proxy/setup.py
================================================
#!/usr/bin/python3
from distutils.core import setup
setup(
name='opi_proxy',
version='1.0',
license='GPLv3',
description='Proxy server for communication between OPI and OBS/PMBS',
author='Dominik Heidler',
author_email='dheidler@suse.de',
requires=['requests', 'Flask'],
packages=['opi_proxy'],
)
================================================
FILE: release.sh
================================================
#!/bin/bash -ex
version=$1
changes=$(git log $(git describe --tags --abbrev=0)..HEAD --no-merges --format=" * %s")
echo "__version__ = '${version}'" > opi/version.py
osc vc -m "Version ${version}\n${changes}" opi.changes
vi opi.changes
git commit opi/version.py opi.changes -m "Version ${version}"
git tag "v${version}"
read -p "Push now? "
git push
git push --tags
gh release create "v${version}" --generate-notes
read -p "Update RPM? "
cd ~/devel/obs/utilities/opi
osc up
sed -i -e "s/^\(Version: *\)[^ ]*$/\1${version}/" opi.spec
osc vc -m "Version ${version}\n${changes}"
vi opi.changes
osc rm --force opi-*.tar.gz
osc service run
osc add opi-*.tar.gz
osc st
osc diff|bat
read -p "Submit RPM? "
osc ci
osc sr
================================================
FILE: setup.py
================================================
#!/usr/bin/python3
from setuptools import setup, find_packages
import os
# Load __version__ from opi/version.py
exec(open(os.path.join(os.path.dirname(os.path.realpath(__file__)), 'opi/version.py')).read())
setup(
name='opi',
version=__version__,
license='GPLv3',
description='Tool to Search and install almost all packages available for openSUSE and SLE',
long_description=open('README.md').read(),
long_description_content_type='text/markdown',
author='Guo Yunhe, Dominik Heidler, KaratekHD',
author_email='i@guoyunhe.me, dheidler@suse.de, karatek@karatek.net',
install_requires=['lxml', 'requests', 'termcolor', 'curses'],
packages=['opi', 'opi.plugins', 'opi.config'],
scripts=['bin/opi'],
)
================================================
FILE: test/01_install_from_packman.py
================================================
#!/usr/bin/python3
import sys
import pexpect
import subprocess
import time
c = pexpect.spawn('./bin/opi -v x265', logfile=sys.stdout.buffer, echo=False)
c.expect('1. x265\r\n')
c.sendline('q')
c.expect('Pick a number')
c.sendline('1')
c.expect('1. .*Packman Essentials', timeout=10)
c.sendline('1')
c.expect('Pick a mirror near your location', timeout=10)
c.sendline('2')
c.expect('Import package signing key', timeout=10)
c.sendline('y')
c.expect('Package install size change', timeout=60)
c.expect('Continue', timeout=60)
time.sleep(3)
c.sendline('y')
c.interact()
c.wait()
c.close()
assert c.exitstatus == 0, f'Exit code: {c.exitstatus}'
subprocess.check_call(['rpm', '-qi', 'x265'])
================================================
FILE: test/02_install_from_home.py
================================================
#!/usr/bin/python3
import sys
import pexpect
import subprocess
c = pexpect.spawn('./bin/opi -v rtl8812au', logfile=sys.stdout.buffer, echo=False)
c.expect('1. rtl8812au\r\n')
c.sendline('q')
c.expect('Pick a number')
c.sendline('1')
c.expect(r'([0-9]+)\. [^ ]*hardware', timeout=10)
hwentryid = c.match.groups()[0]
print(f'PEXPECT: Found hardware entry id {hwentryid!r}')
c.sendline(hwentryid)
c.expect('Import package signing key', timeout=10)
c.sendline('y')
c.expect('new packages? to install', timeout=60)
c.expect('Continue', timeout=60)
c.sendline('y')
c.expect('Do you want to keep the repo', timeout=350)
c.sendline('n')
c.expect('Keep package signing key', timeout=10)
c.sendline('n')
c.interact()
c.wait()
c.close()
assert c.exitstatus == 0, f'Exit code: {c.exitstatus}'
subprocess.check_call(['rpm', '-qi', 'rtl8812au'])
subprocess.check_call('! zypper lr -u | grep hardware', shell=True)
subprocess.check_call('! rpm -q gpg-pubkey --qf "%{NAME}-%{VERSION}\t%{PACKAGER}\n" | grep hardware', shell=True)
================================================
FILE: test/03_install_using_plugin.py
================================================
#!/usr/bin/python3
import sys
import pexpect
import subprocess
c = pexpect.spawn('./bin/opi -v resilio-sync', logfile=sys.stdout.buffer, echo=False)
c.expect('Do you want to install')
c.sendline('y')
c.expect('Import package signing key', timeout=10)
c.sendline('y')
c.expect('Continue')
c.sendline('y')
c.expect('Do you want to keep', timeout=500)
c.sendline('y')
c.interact()
c.wait()
c.close()
assert c.exitstatus == 0, f'Exit code: {c.exitstatus}'
subprocess.check_call(['rpm', '-qi', 'resilio-sync'])
subprocess.check_call('zypper lr | grep resilio-sync', shell=True)
================================================
FILE: test/04_check_plugins.py
================================================
#!/usr/bin/python3
import os
import sys
sys.path.insert(0, os.path.abspath(os.path.dirname(__file__) + '/..'))
from opi.plugins import PluginManager
pm = PluginManager()
for plugin in pm.plugins:
print('Checking plugin:', plugin)
assert plugin.main_query != ''
assert plugin.description != ''
assert isinstance(plugin.queries, list)
assert plugin.main_query in plugin.queries, 'Plugin main query must be in queries list'
for other_plugin in pm.plugins:
if plugin == other_plugin:
continue
common_queries = set(plugin.queries) & set(other_plugin.queries)
assert not common_queries, f'Conflict in queries between {plugin} and {other_plugin}: Both have {common_queries}'
================================================
FILE: test/05_install_from_local_repo.py
================================================
#!/usr/bin/python3
import sys
import pexpect
c = pexpect.spawn('./bin/opi -v htop', logfile=sys.stdout.buffer, echo=False)
c.expect(r'([0-9]+)\. htop', timeout=10)
entry_id = c.match.groups()[0]
print(f'PEXPECT: Found entry id {entry_id!r}')
c.expect('Pick a number')
c.sendline(entry_id)
c.expect(r'([0-9]+)\. [^ ]*(openSUSE-Tumbleweed-Oss|Main Repository)', timeout=10)
entry_id = c.match.groups()[0]
print(f'PEXPECT: Found entry id {entry_id!r}')
c.sendline(entry_id)
c.expect('Installing from existing repo', timeout=10)
c.expect('Continue?', timeout=10)
c.sendline('n')
c.interact()
c.wait()
c.close()
print()
assert c.exitstatus == 0, f'Exit code: {c.exitstatus}'
================================================
FILE: test/06_install_non_interactive.py
================================================
#!/usr/bin/python3
import sys
import pexpect
import subprocess
c = pexpect.spawn('./bin/opi -v -n bottom', logfile=sys.stdout.buffer, echo=False)
c.expect(r'([0-9]+)\. bottom', timeout=20)
c.expect('Pick a number')
c.expect(r'([0-9]+)\. [^ ]*(openSUSE-Tumbleweed-Oss|Main Repository)', timeout=20)
c.expect('Installing from existing repo', timeout=20)
c.expect('Continue?', timeout=60)
c.interact()
c.wait()
c.close()
print()
assert c.exitstatus == 0, f'Exit code: {c.exitstatus}'
subprocess.check_call(['rpm', '-qi', 'bottom'])
c = pexpect.spawn('./bin/opi -v -n helloworld-opi-tests', logfile=sys.stdout.buffer, echo=False)
c.expect(r'([0-9]+)\. helloworld-opi-tests', timeout=20)
c.expect('Pick a number')
c.expect(r'([0-9]+)\. [^ ]*(home:dheidler:opitests)', timeout=20)
c.expect('Adding repo \'home:dheidler:opitests\'', timeout=20)
c.expect('Continue?', timeout=60)
c.interact()
c.wait()
c.close()
print()
assert c.exitstatus == 0, f'Exit code: {c.exitstatus}'
subprocess.check_call(['rpm', '-qi', 'helloworld-opi-tests'])
================================================
FILE: test/07_install_multiple.py
================================================
#!/usr/bin/python3
import sys
import pexpect
import subprocess
c = pexpect.spawn('./bin/opi -v -nm helloworld-opi-tests resilio-sync tmux', logfile=sys.stdout.buffer, echo=False)
# plugins are installed first
c.expect('Do you want to install')
c.expect('Import package signing key', timeout=10)
c.expect('Continue')
c.expect('Do you want to keep', timeout=500)
# packages come after plugins
c.expect(r'([0-9]+)\. helloworld-opi-tests', timeout=10)
c.expect('Pick a number')
c.expect(r'([0-9]+)\. [^ ]*(home:dheidler:opitests)', timeout=10)
c.expect('Adding repo \'home:dheidler:opitests\'', timeout=10)
c.expect('Continue?', timeout=60)
c.expect(r'([0-9]+)\. tmux', timeout=60)
c.expect('Pick a number')
c.expect(r'([0-9]+)\. [^ ]*(openSUSE-Tumbleweed-Oss|Main Repository)', timeout=10)
c.expect('Installing from existing repo', timeout=10)
c.expect('Continue?', timeout=60)
c.interact()
c.wait()
c.close()
print()
assert c.exitstatus == 0, f'Exit code: {c.exitstatus}'
subprocess.check_call(['rpm', '-qi', 'resilio-sync'])
subprocess.check_call(['rpm', '-qi', 'helloworld-opi-tests'])
subprocess.check_call(['rpm', '-qi', 'tmux'])
================================================
FILE: test/08_install_from_packman_non_interactive.py
================================================
#!/usr/bin/python3
import sys
import pexpect
import subprocess
c = pexpect.spawn('./bin/opi -v -n x265', logfile=sys.stdout.buffer, echo=False)
c.expect('1. x265\r\n')
c.expect('Pick a number')
c.expect('1. .*Packman Essentials', timeout=10)
c.expect('Package install size change', timeout=60)
c.interact()
c.wait()
c.close()
assert c.exitstatus == 0, f'Exit code: {c.exitstatus}'
subprocess.check_call(['rpm', '-qi', 'x265'])
================================================
FILE: test/09_install_with_multi_repos_in_single_file_non_interactive.py
================================================
#!/usr/bin/python3
import sys
import pexpect
import subprocess
subprocess.check_call("cat /etc/zypp/repos.d/*.repo > /tmp/singlefile.repo", shell=True)
subprocess.check_call("rm -v /etc/zypp/repos.d/*.repo", shell=True)
subprocess.check_call("mv -v /tmp/singlefile.repo /etc/zypp/repos.d/", shell=True)
c = pexpect.spawn('./bin/opi -v -n tmux', logfile=sys.stdout.buffer, echo=False)
c.expect(r'([0-9]+)\. tmux', timeout=10)
c.expect('Pick a number')
c.expect(r'([0-9]+)\. [^ ]*(openSUSE-Tumbleweed-Oss|Main Repository)', timeout=10)
c.expect('Installing from existing repo', timeout=10)
c.expect('Continue?', timeout=60)
c.interact()
c.wait()
c.close()
print()
assert c.exitstatus == 0, f'Exit code: {c.exitstatus}'
subprocess.check_call(['rpm', '-qi', 'tmux'])
c = pexpect.spawn('./bin/opi -v -n helloworld-opi-tests', logfile=sys.stdout.buffer, echo=False)
c.expect(r'([0-9]+)\. helloworld-opi-tests', timeout=10)
c.expect('Pick a number')
c.expect(r'([0-9]+)\. [^ ]*(home:dheidler:opitests)', timeout=10)
c.expect('Adding repo \'home:dheidler:opitests\'', timeout=10)
c.expect('Continue?', timeout=60)
c.interact()
c.wait()
c.close()
print()
assert c.exitstatus == 0, f'Exit code: {c.exitstatus}'
subprocess.check_call(['rpm', '-qi', 'helloworld-opi-tests'])
================================================
FILE: test/99_install_opi.py
================================================
#!/usr/bin/python3
import subprocess
def run(cmd, **kwargs):
print('% ' + (' '.join(cmd) if isinstance(cmd, list) else cmd))
subprocess.check_call(cmd, **kwargs)
version = subprocess.check_output(['python3', 'setup.py', '--version']).decode().strip()
run(['python3', '-mpip', 'wheel', '--verbose', '--progress-bar', 'off', '--disable-pip-version-check', '--use-pep517', '--no-build-isolation', '--no-deps', '--wheel-dir', './build', '.'])
cmd = ['python3', '-mpip', 'install', '--root-user-action=ignore', '--break-system-packages', '--verbose', '--progress-bar', 'off', '--disable-pip-version-check', '--no-compile', '--ignore-installed', '--no-deps', '--no-index', '--find-links', './build', f"opi=={version}"]
if subprocess.run('grep "openSUSE Leap" /etc/os-release', shell=True).returncode == 0:
cmd.remove('--root-user-action=ignore')
cmd.remove('--break-system-packages')
run(cmd)
run(f'opi --version | grep {version}', shell=True)
run('opi --help | grep --color -A1000 -B1000 Microsoft', shell=True)
================================================
FILE: test/run.sh
================================================
#!/bin/bash
echo "$(tput bold)$(tput setaf 6)===== Running test: $1 =====$(tput sgr0)"
cd /opi/
./test/$1
result=$?
echo "$(tput bold)$(tput setaf 6)===== Finished test: $1 =====$(tput sgr0)"
if [[ "$result" == "0" ]] ; then
echo "$(tput bold)$(tput setaf 2)>>>>> PASSED <<<<<$(tput sgr0)"
else
echo "$(tput bold)$(tput setaf 1)!!!!! FAILED !!!!!$(tput sgr0)"
fi
exit $result
================================================
FILE: test/run_all.sh
================================================
#!/bin/bash
test_dir="$(dirname "$(pwd)/$0")"
cd "$test_dir"
failed_tests=0
total_tests=0
for t in *.py ; do
let total_tests++
if ! sudo ./run_container_test.sh "$t" "$1" ; then
let failed_tests++
fi
done
if [[ "$failed_tests" != "0" ]] ; then
echo "$(tput bold)$(tput setaf 1)Error: ${failed_tests} out of ${total_tests} failed!$(tput sgr0)"
exit 1
else
echo "$(tput bold)$(tput setaf 2)All ${total_tests} tests succedeed!$(tput sgr0)"
fi
================================================
FILE: test/run_container_test.sh
================================================
#!/bin/bash -x
base_image="${2:-opensuse/tumbleweed}"
opi_base_image="opi_base_${base_image/\//_}"
if [[ "$2" == "opensuse/microos" ]] ; then
base_image="opensuse/tumbleweed"
opi_base_image="opi_base_opensuse_microos"
fi
# prepare container image
if ! podman image exists $opi_base_image ; then
echo "Preparing container"
podman run -td --dns=1.1.1.1 --name=opi_base $base_image
podman exec -it opi_base zypper -n ref
if [[ "$2" == "opensuse/microos" ]] ; then
# fake MicroOS
podman exec -it opi_base zypper -n install --force-resolution MicroOS-release
fi
# opi dependencies
podman exec -it opi_base zypper -n install sudo python3 python3-requests python3-lxml python3-termcolor python3-curses python3-rpm curl python3-pip python3-setuptools python3-wheel
# test dependencies
podman exec -it opi_base zypper -n install python3-pexpect shadow
podman commit opi_base $opi_base_image
podman kill opi_base
podman rm opi_base
fi
opi_dir="$(dirname $(pwd)/$0)/../"
test_module=$(basename $1)
podman run -ti --rm --volume "${opi_dir}:/opi/" $opi_base_image /opi/test/run.sh $test_module
exit $?