├── .github
├── ISSUE_TEMPLATE
│ ├── bug_report.md
│ └── feature_request.md
└── workflows
│ └── ci.yaml
├── .gitignore
├── LICENSE
├── README.md
├── bin
└── opi
├── demo.gif
├── opi.changes
├── opi.default.cfg
├── opi
├── __init__.py
├── config
│ └── __init__.py
├── github.py
├── http.py
├── pager.py
├── plugins
│ ├── __init__.py
│ ├── anydesk.py
│ ├── atom.py
│ ├── brave.py
│ ├── chrome.py
│ ├── collabora.py
│ ├── dotnet.py
│ ├── freeoffice.py
│ ├── jami.py
│ ├── libation.py
│ ├── librewolf.py
│ ├── maptool.py
│ ├── megasync.py
│ ├── ms_edge.py
│ ├── mullvad-browser.py
│ ├── ocenaudio.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
├── 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
/.github/ISSUE_TEMPLATE/bug_report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Bug report
3 | about: Create a report to help us improve
4 | title: ''
5 | labels: ''
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Please also attach the output of these commands to your bug**
11 | ```
12 | cat /etc/os-release
13 | (cd /etc/zypp/repos.d; \ls | while read line ; do echo -e "\n----\n$(ls -l $line):"; cat "$line" ; done)
14 | ```
15 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature_request.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Feature request
3 | about: Suggest an idea for this project
4 | title: ''
5 | labels: ''
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Is your feature request related to a problem? Please describe.**
11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12 |
13 | **Describe the solution you'd like**
14 | A clear and concise description of what you want to happen.
15 |
16 | **Describe alternatives you've considered**
17 | A clear and concise description of any alternative solutions or features you've considered.
18 |
19 | **Additional context**
20 | Add any other context or screenshots about the feature request here.
21 |
--------------------------------------------------------------------------------
/.github/workflows/ci.yaml:
--------------------------------------------------------------------------------
1 | name: CI
2 | on:
3 | push:
4 | branches: [ master ]
5 | pull_request:
6 | branches: [ master ]
7 |
8 | # Allows you to run this workflow manually from the Actions tab
9 | workflow_dispatch:
10 |
11 | jobs:
12 | Tumbleweed:
13 | # The type of runner that the job will run on
14 | runs-on: ubuntu-latest
15 |
16 | # Steps represent a sequence of tasks that will be executed as part of the job
17 | steps:
18 | # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
19 | - uses: actions/checkout@v4
20 |
21 | # Runs a single command using the runners shell
22 | - name: Run testsuite
23 | run: ./test/run_all.sh opensuse/tumbleweed
24 | Leap:
25 | runs-on: ubuntu-latest
26 | steps:
27 | # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
28 | - uses: actions/checkout@v4
29 |
30 | # Runs a single command using the runners shell
31 | - name: Run testsuite
32 | run: ./test/run_all.sh opensuse/leap
33 | MicroOS:
34 | runs-on: ubuntu-latest
35 | steps:
36 | # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
37 | - uses: actions/checkout@v4
38 |
39 | # Runs a single command using the runners shell
40 | - name: Run testsuite
41 | run: ./test/run_all.sh opensuse/microos
42 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | !Build/
2 | .last_cover_stats
3 | /META.yml
4 | /META.json
5 | /MYMETA.*
6 | *.o
7 | *.pm.tdy
8 | *.bs
9 |
10 | # Devel::Cover
11 | cover_db/
12 |
13 | # Devel::NYTProf
14 | nytprof.out
15 |
16 | # Dizt::Zilla
17 | /.build/
18 |
19 | # Module::Build
20 | _build/
21 | Build
22 | Build.bat
23 |
24 | # Module::Install
25 | inc/
26 |
27 | # ExtUtils::MakeMaker
28 | /blib/
29 | /_eumm/
30 | /*.gz
31 | /Makefile
32 | /Makefile.old
33 | /MANIFEST.bak
34 | /pm_to_blib
35 | /*.zip
36 | /search.xml
37 |
38 | .*.swp
39 | __pycache__
40 |
41 | # Distribution / packaging
42 | .Python
43 | env/
44 | build/
45 | develop-eggs/
46 | dist/
47 | downloads/
48 | eggs/
49 | .eggs/
50 | lib/
51 | lib64/
52 | parts/
53 | sdist/
54 | var/
55 | wheels/
56 | *.egg-info/
57 | .installed.cfg
58 | *.egg
59 |
60 | config.json
61 | .idea
62 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 |
635 | Copyright (C)
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | Copyright (C)
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # OPI
2 |
3 | **O**BS **P**ackage **I**nstaller
4 |
5 | Search and install almost all packages available for openSUSE and SLE:
6 |
7 | 1. openSUSE Build Service
8 | 2. Packman
9 | 3. Popular packages for Microsoft and other vendors
10 |
11 | ## System Requirements
12 |
13 | - openSUSE Tumbleweed, openSUSE Leap 42.1+, SLE 12+
14 | - python3
15 | - python3-requests
16 | - python3-lxml
17 | - python3-termcolor
18 |
19 | ## Install
20 |
21 | ### openSUSE Tumbleweed and Leap
22 |
23 | ```
24 | sudo zypper install opi
25 | ```
26 |
27 | ### SLE
28 |
29 | ```
30 | # eg. for SLE 15 SP4
31 | sudo SUSEConnect -p PackageHub/15.4/x86_64
32 |
33 | sudo zypper refresh
34 | sudo zypper install opi
35 | ```
36 |
37 | ## Use
38 |
39 | Run:
40 |
41 | ```
42 | opi [package_name]
43 | ```
44 |
45 | Example:
46 |
47 | ```
48 | opi filezilla
49 | ```
50 |
51 | Demo:
52 |
53 | 
54 |
55 | ### Config options
56 |
57 | Change the config by editing the content of `/etc/opi.cfg`.
58 |
59 | #### Disabling auto-refresh for new repositories
60 |
61 | If you want to, you can disable auto-refreshing of new repositories.
62 |
63 | ```cfg
64 | new_repo_auto_refresh = false
65 | ```
66 |
67 | If you want to reactivate auto-refreshing for new repositories, just change the value of `new_repo_auto_refresh` back to `true`.
68 |
69 | ### Packages from Other Repositories
70 |
71 | **Packman Codecs** (enable you to play MP4 videos and YouTube)
72 |
73 | ```
74 | opi packman
75 |
76 | # or
77 |
78 | opi codecs
79 | ```
80 |
81 | ```
82 | usage: opi [-h] [-v] [-n] [-P] [-m] [query ...]
83 |
84 | openSUSE Package Installer
85 | ==========================
86 |
87 | Search and install almost all packages available for openSUSE and SLE:
88 | 1. openSUSE Build Service
89 | 2. Packman
90 | 3. Popular packages for various vendors
91 |
92 | positional arguments:
93 | query can be any package name or part of it and will be searched for both at the openSUSE Build Service and Packman.
94 | If multiple query arguments are provided only results matching all of them are returned.
95 | Please use the -m option if you want to use the query arguments as individual package queries.
96 |
97 | options:
98 | -h, --help show this help message and exit
99 | -v, --version show program's version number and exit
100 | -n run in non interactive mode
101 | -P don't run any plugins - only search repos, OBS and Packman
102 | -m use query args as space separated package queries
103 |
104 | Also these queries (provided by plugins) can be used to install packages from various other vendors:
105 | anydesk AnyDesk remote access
106 | atom Atom Text Editor
107 | brave Brave web browser
108 | chrome Google Chrome web browser
109 | codecs Media Codecs from Packman and official repo
110 | collabora Collabora desktop office
111 | dotnet Microsoft .NET framework
112 | freeoffice Office suite from SoftMaker (See OSS alternative libreoffice)
113 | jami Jami p2p messenger
114 | libation Tool for managing audible audiobooks
115 | maptool Virtual Tabletop for playing roleplaying games
116 | megasync Mega Desktop App
117 | msedge Microsoft Edge web browser
118 | ocenaudio Audio Editor
119 | orcaslicer Slicer and controller for Bambu and other 3D printers
120 | plex Plex Media Server (See OSS alternative jellyfin)
121 | resilio-sync Decentralized file sync between devices using bittorrent protocol (See OSS alternative syncthing)
122 | skype Microsoft Skype
123 | slack Slack messenger
124 | spotify Listen to music for a monthly fee
125 | sublime Editor for code, markup and prose
126 | teams-for-linux Unofficial Microsoft Teams for Linux client
127 | teamviewer TeamViewer remote access
128 | vivaldi Vivaldi web browser
129 | vscode Microsoft Visual Studio Code
130 | vscodium Visual Studio Codium
131 | yandex-browser Yandex web browser
132 | yandex-disk Yandex.Disk cloud storage client
133 | zoom Zoom Video Conference
134 | ```
135 |
--------------------------------------------------------------------------------
/bin/opi:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 |
3 | import os
4 | import sys
5 | import re
6 | import argparse
7 | import textwrap
8 | import subprocess
9 | from termcolor import colored, cprint
10 |
11 | sys.path.insert(0, os.path.abspath(os.path.dirname(__file__) + '/..'))
12 | import opi
13 | from opi.plugins import PluginManager
14 | from opi.version import __version__
15 | from opi.state import global_state
16 |
17 |
18 | class PreserveWhiteSpaceWrapRawTextHelpFormatter(argparse.RawTextHelpFormatter):
19 | def __add_whitespace(self, idx, iWSpace, text):
20 | if idx == 0:
21 | return text
22 | return (' ' * iWSpace) + text
23 |
24 | def _split_lines(self, text, width):
25 | textRows = text.splitlines()
26 | for idx,line in enumerate(textRows):
27 | search = re.search(r'\s*[\d\-]*\.?\s*', line)
28 | if line.strip() == '':
29 | textRows[idx] = ' '
30 | elif search:
31 | lWSpace = search.end()
32 | lines = [self.__add_whitespace(i,lWSpace,x) for i,x in enumerate(textwrap.wrap(line, width))]
33 | textRows[idx] = lines
34 | return [item for sublist in textRows for item in sublist]
35 |
36 |
37 | def setup_argparser(plugin_manager):
38 | ap = argparse.ArgumentParser(
39 | formatter_class=PreserveWhiteSpaceWrapRawTextHelpFormatter,
40 | description=textwrap.dedent('''\
41 | openSUSE Package Installer
42 | ==========================
43 |
44 | Search and install almost all packages available for openSUSE and SLE:
45 | 1. openSUSE Build Service
46 | 2. Packman
47 | 3. Popular packages for various vendors
48 |
49 | '''),
50 | epilog=textwrap.dedent('''\
51 | Also these queries (provided by plugins) can be used to install packages from various other vendors:
52 | ''') + plugin_manager.get_plugin_string(' ' * 2))
53 |
54 | ap.add_argument('query', nargs='*', type=str, help=textwrap.dedent('''\
55 | can be any package name or part of it and will be searched for both at the openSUSE Build Service and Packman.
56 | If multiple query arguments are provided only results matching all of them are returned.
57 | Please use the -m option if you want to use the query arguments as individual package queries.
58 | '''))
59 | ap.add_argument('-V', '--version', action='version', version=f'opi version {__version__}')
60 | ap.add_argument('-n', dest='non_interactive', action='store_true', help='run in non interactive mode')
61 | ap.add_argument('-P', dest='no_plugins', action='store_true', help="don't run any plugins - only search repos, OBS and Packman")
62 | ap.add_argument('-m', dest='multi_install', action='store_true', help='use query args as space separated package queries')
63 | ap.add_argument('-v', '--verbose', dest='verbose_mode', action='store_true', help='make the operation more talkative')
64 |
65 | return ap
66 |
67 |
68 | def repo_query(query):
69 | try:
70 | print(f'Searching repos for: {(" ".join(query) if isinstance(query, list) else query)}')
71 |
72 | packages = []
73 | packages.extend(opi.search_published_packages('openSUSE', query))
74 | packages.extend(opi.search_published_packages('Packman', query))
75 | packages = opi.sort_uniq_packages(packages)
76 | if len(packages) == 0:
77 | print('No package found.')
78 | return
79 |
80 | # Print and select a package name option
81 | package_names = opi.get_package_names(packages)
82 | selected_pkg_name = opi.ask_for_option(package_names)
83 | print('You have selected package name:', selected_pkg_name)
84 |
85 | # Inject packages from local repos
86 | packages = opi.search_local_repos(selected_pkg_name) + packages
87 |
88 | instable_pkg_options = [pkg for pkg in packages if pkg.name == selected_pkg_name]
89 |
90 | # Print and select a package option
91 | selected_pkg = opi.ask_for_option(instable_pkg_options, option_filter=opi.format_pkg_option, disable_pager=True)
92 | print('You have selected package:', opi.format_pkg_option(selected_pkg, table=False))
93 | if isinstance(selected_pkg, opi.OBSPackage):
94 | if selected_pkg.is_from_personal_project():
95 | cprint(
96 | 'BE CAREFUL! The package is from a personal repository and NOT reviewed by others.\n'
97 | 'You can ask the author to submit the package to development projects and openSUSE:Factory.\n'
98 | 'Learn more at https://en.opensuse.org/openSUSE:How_to_contribute_to_Factory',
99 | 'red'
100 | )
101 | elif selected_pkg.project == 'openSUSE:Factory':
102 | cprint(
103 | 'BE CAREFUL! You are about to add the Factory Repository.\n'
104 | 'This repo contains the unreleased Tumbleweed distro before openQA tests have been run.\n'
105 | 'Only proceed if you know what you are doing!',
106 | 'yellow'
107 | )
108 | if not opi.ask_yes_or_no('Do you want to continue?', default_answer='n'):
109 | return
110 | elif selected_pkg.project.startswith('openSUSE:Factory:Staging'):
111 | cprint(
112 | 'BE CAREFUL! You are about to add a Factory Staging Repository.\n'
113 | 'This repo is used to test submissions to the Factory repo (the unreleased Tumbleweed distro before openQA tests have been run).\n'
114 | 'Only proceed if you know what you are doing!',
115 | 'yellow'
116 | )
117 | if not opi.ask_yes_or_no('Do you want to continue?', default_answer='n'):
118 | return
119 |
120 | # Install selected package
121 | selected_pkg.install()
122 | except (opi.NoOptionSelected, opi.HTTPError):
123 | return
124 |
125 |
126 | if __name__ == '__main__':
127 | try:
128 | pm = PluginManager()
129 | ap = setup_argparser(pm)
130 | args = ap.parse_args()
131 |
132 | if not args.query:
133 | ap.print_help()
134 | sys.exit()
135 |
136 | if args.verbose_mode:
137 | global_state.arg_verbose_mode = True
138 |
139 | if args.non_interactive:
140 | global_state.arg_non_interactive = True
141 | if subprocess.run(['sudo', '-n', 'true']).returncode != 0:
142 | print('Error: In non-interactive mode this command must be run as root')
143 | print(' or sudo must not require interaction.')
144 | sys.exit(1)
145 |
146 | # Search plugins
147 | if not args.no_plugins:
148 | # Iterate over queries, copy list as modifying it from within the loop
149 | for query in list(args.query):
150 | # Try to find a matching plugin for the query (and run it); runs just first query if not in multi_install mode
151 | if pm.run(query):
152 | # After plugin successfully ran, remove from queries to not try again in repo search
153 | args.query.remove(query)
154 | if not args.multi_install:
155 | sys.exit()
156 |
157 | # Search repos
158 | if not args.multi_install:
159 | repo_query(args.query)
160 | else:
161 | for query in args.query:
162 | repo_query(query)
163 |
164 | except KeyboardInterrupt:
165 | print()
166 |
--------------------------------------------------------------------------------
/demo.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openSUSE/opi/72d6483a731af960c412737571c3962c25b91cc9/demo.gif
--------------------------------------------------------------------------------
/opi.changes:
--------------------------------------------------------------------------------
1 | -------------------------------------------------------------------
2 | Mon Jun 2 10:16:26 UTC 2025 - Dominik Heidler
3 |
4 | - Version 5.8.5
5 | * add librewolf plugin (#205)
6 | * Install .NET 9
7 | * Add verbose mode
8 | * Change the order of the process in the github module
9 | * Add rustdesk plugin
10 |
11 | -------------------------------------------------------------------
12 | Mon May 26 10:40:34 UTC 2025 - Dominik Heidler
13 |
14 | - Version 5.8.4
15 | * Use arm64 rpm for libation on aarch64
16 |
17 | -------------------------------------------------------------------
18 | Tue Apr 22 11:55:07 UTC 2025 - Dominik Heidler
19 |
20 | - Version 5.8.3
21 | * Install dependencies rpm-build and squashfs at runtime if needed
22 | * Drop DNF support
23 |
24 | -------------------------------------------------------------------
25 | Tue Apr 22 08:08:34 UTC 2025 - Dominik Heidler
26 |
27 | - Version 5.8.2
28 | * Warn about adding staging repos
29 | * Gracefully handle zypper exit code 106 (repos without cache present)
30 |
31 | -------------------------------------------------------------------
32 | Wed Mar 12 11:07:52 UTC 2025 - Dominik Heidler
33 |
34 | - Version 5.8.1
35 | * Fix SyntaxWarning: invalid escape sequence '\s'
36 |
37 | -------------------------------------------------------------------
38 | Mon Feb 24 11:39:20 UTC 2025 - Dominik Heidler
39 |
40 | - Version 5.8.0
41 | * Add mullvad-brower
42 |
43 | -------------------------------------------------------------------
44 | Sun Feb 16 16:13:17 UTC 2025 - Dominik Heidler
45 |
46 | - Version 5.7.0
47 | * Add leap-only plugin to install zellij from github release
48 | * Don't use subprocess.run user kwarg on 15.6
49 | * Fix tests: Use helloworld-opi-tests instead of zfs
50 | * Perform search despite locked rpmdb
51 | * Simplify backend code
52 |
53 | -------------------------------------------------------------------
54 | Thu Jan 23 13:53:06 UTC 2025 - Dominik Heidler
55 |
56 | - Version 5.6.0
57 | * Add plugin to install vagrant from hashicorp repo
58 |
59 | -------------------------------------------------------------------
60 | Tue Jan 14 15:35:14 UTC 2025 - Dominik Heidler
61 |
62 | - Version 5.5.0
63 | * Update opi/plugins/collabora.py
64 | * add collabora office desktop
65 | * Omit unsupported cli args on leap in 99_install_opi.py
66 | * Switch to PEP517 install
67 | * Fix 09_install_with_multi_repos_in_single_file_non_interactive.py
68 | * Fix 07_install_multiple.py on tumbleweed
69 | * Fix test suite on tumbleweed
70 | * Update available apps in opi - README.md
71 |
72 | -------------------------------------------------------------------
73 | Mon Nov 4 12:13:42 UTC 2024 - Dominik Heidler
74 |
75 | - Version 5.4.0
76 | * Show key ID when importing or deleting package signing keys
77 | * Add option to install google-chrome-canary
78 |
79 | -------------------------------------------------------------------
80 | Fri Oct 25 12:03:28 UTC 2024 - Dominik Heidler
81 |
82 | - Version 5.3.0
83 | * Fix tests for new zypper version
84 | * fix doblue slash in packman repo url
85 | * Add Plugin to install Libation
86 |
87 | -------------------------------------------------------------------
88 | Mon Jun 24 09:04:47 UTC 2024 - Dominik Heidler
89 |
90 | - Version 5.2.1
91 | * Update freeoffice.py: Install version 2024
92 |
93 | -------------------------------------------------------------------
94 | Tue Jun 11 14:12:30 UTC 2024 - Dominik Heidler
95 |
96 | - Version 5.2.0
97 | * Add config option to reverse option order
98 |
99 | -------------------------------------------------------------------
100 | Fri Jun 7 13:17:38 UTC 2024 - Dominik Heidler
101 |
102 | - Version 5.1.0
103 | * Use checkout@v4 for CI
104 | * Update issue templates
105 | * Increase prio from 90 to 70 for packman/openh264 repos
106 |
107 | -------------------------------------------------------------------
108 | Thu Feb 1 09:41:57 UTC 2024 - Dominik Heidler
109 |
110 | - Version 5.0.0
111 | * Allow selecting mirror 1st time when adding packman repo
112 | * Add Plugin for SoftMaker Freeoffice
113 | * Use new osc service run cmd syntax
114 | * Codecs: Install AV1 decoder for mpv
115 | * Bump .NET SDK plugin to .NET 8.0
116 |
117 | -------------------------------------------------------------------
118 | Tue Jan 2 13:54:28 UTC 2024 - Dominik Heidler
119 |
120 | - Version 4.4.0
121 | * Match repos by alias when searching local repos
122 | * Rephrase OSS alternative hints
123 | * Fix typo in rpmbuild.py
124 |
125 | -------------------------------------------------------------------
126 | Fri Dec 15 18:09:52 UTC 2023 - Dominik Heidler
127 |
128 | - Version 4.3.0
129 | * Hint open source alternatives
130 | * Fix issue with installing from existing openh264 repo
131 |
132 | -------------------------------------------------------------------
133 | Tue Dec 12 12:40:20 UTC 2023 - Dominik Heidler
134 |
135 | - Version 4.2.0
136 | * Support multiple repos defined in a single .repo file
137 | * Automatically import packman key in non-interactive mode
138 | * Restructure code: Add classes for Repository, OBSPackage and LocalPackage
139 | * Hide package release for pkgs from local repos (same as with OBS pkgs)
140 | * Use tumbleweed repo for openh264 on Slowroll
141 | * Expand repovar $basearch (to e.g. x86_64 or aarch64)
142 |
143 | -------------------------------------------------------------------
144 | Thu Dec 7 10:30:24 UTC 2023 - Dominik Heidler
145 |
146 | - Version 4.1.0
147 | * Add support for Slowroll
148 | * Replace $releasever also with ${releasever} syntax
149 | * Update changelog prefix to *
150 |
151 | -------------------------------------------------------------------
152 | Fri Nov 17 14:05:21 UTC 2023 - Dominik Heidler
153 |
154 | - Version 4.0.0
155 | * Simplify rpmbuild by removing %install
156 | * Add opi new dependencies to testsuite: rpm-build, squashfs
157 | * Rename rpmbuild internal dirs to uppercase
158 | * Fix building RPMs for Leap 15.5
159 | * Update opi-proxy .service file to listen on IPv6 as well
160 | * Add Snap library and Spotify plugin
161 | * Allow installing non-rpm applications (add OrcaSlicer)
162 | * chore: update multi_install description
163 | * Indent changes in changelog further than version
164 |
165 | -------------------------------------------------------------------
166 | Wed Oct 11 10:08:35 UTC 2023 - Dominik Heidler
167 |
168 | - Version 3.6.0
169 | - Increase timeouts in testsuite and improve output
170 | - test: remove yandex-disk from multi-install test
171 | - Run testsuite for (fake) MicroOS
172 | - Fix repo URL generation for MicroOS and Leap Micro (fixes #158)
173 | - Add multi package option
174 | - Add ocenaudio audio editor (fixes #155)
175 | - Ignore gpg check for unsigned pkgs (or pkgs without published key)
176 |
177 | -------------------------------------------------------------------
178 | Mon Sep 25 13:23:05 UTC 2023 - Dominik Heidler
179 |
180 | - Version 3.5.0
181 | - Expand releasever for local repo names
182 | - Make resilio comment shorter
183 | - Add option to skip plugins
184 | - Update repo URL for MEGASync
185 |
186 | -------------------------------------------------------------------
187 | Wed Aug 30 13:32:14 UTC 2023 - Dominik Heidler
188 |
189 | - Version 3.4.0
190 | - Add unofficial Teams-for-linux client
191 | - Improve non interactive tests
192 | - Strip test module name
193 | - chore: fix indentation
194 | - docs: add config options, update opi help page
195 |
196 | -------------------------------------------------------------------
197 | Fri Jul 28 10:01:21 UTC 2023 - Dominik Heidler
198 |
199 | - Version 3.3.0
200 | - Add tests and tweak weighting algorithm for non interactive mode
201 | - Allow running without user interaction
202 | - Add config option to disable auto refresh
203 |
204 | -------------------------------------------------------------------
205 | Thu Jul 13 09:12:57 UTC 2023 - Dominik Heidler
206 |
207 | - Version 3.2.0
208 | - fix: add missing format string marks, remove empty lines
209 | - Make release.sh more robust
210 |
211 | -------------------------------------------------------------------
212 | Tue Jul 11 18:07:59 UTC 2023 - Dominik Heidler
213 |
214 | - Version 3.1.0
215 | - Add MapTool RPM tool
216 |
217 | -------------------------------------------------------------------
218 | Mon Jun 19 08:56:53 UTC 2023 - Dominik Heidler
219 |
220 | - Version 3.0.0
221 | - Use best repo for each project (fixes #113)
222 | - Use new rpm signing key for zoom (fixes #133)
223 | - cleanup code
224 | - Remove MS teams as it is discontinued
225 |
226 | -------------------------------------------------------------------
227 | Mon Apr 3 12:49:29 UTC 2023 - Dominik Heidler
228 |
229 | - Version 2.17.0
230 | - Codecs: Don't force ffmpeg>=5 on leap 15.5
231 | - Use new checkout version in ci.yaml
232 |
233 | -------------------------------------------------------------------
234 | Mon Apr 3 10:23:42 UTC 2023 - Dominik Heidler
235 |
236 | - Version 2.16.0
237 | - dotnet: Install dotnet-sdk-7.0 (#124)
238 | - Add jami p2p messenger plugin (#121)
239 |
240 | -------------------------------------------------------------------
241 | Sat Feb 18 22:42:32 UTC 2023 - Dominik Heidler
242 |
243 | - Version 2.15.0
244 | - Fix repo name encoding when asking for new key addition
245 |
246 | -------------------------------------------------------------------
247 | Mon Feb 13 16:35:28 UTC 2023 - Dominik Heidler
248 |
249 | - Version 2.14.0
250 | - Install openh264 according to arch
251 | - Use http instead of https for openh264 repo
252 |
253 | -------------------------------------------------------------------
254 | Mon Feb 13 10:27:03 UTC 2023 - Dominik Heidler
255 |
256 | - Version 2.13.0
257 | - Add openh264 (#119)
258 |
259 | -------------------------------------------------------------------
260 | Mon Feb 13 09:41:31 UTC 2023 - Dominik Heidler
261 |
262 | - Version 2.12.0
263 | - Enforce ffmpeg>=5 on tumbleweed
264 |
265 | -------------------------------------------------------------------
266 | Mon Jan 30 14:41:42 UTC 2023 - Dominik Heidler
267 |
268 | - Version 2.11.0
269 | - Handle repos with multiple keys in key file (fixes #118)
270 |
271 | -------------------------------------------------------------------
272 | Wed Jan 25 12:57:21 UTC 2023 - Dominik Heidler
273 |
274 | - Version 2.10.0
275 | - Ask for submit in release.sh
276 | - Fix packman plugin for 15.4
277 | - Introduce repo key handling (bsc#1207334)
278 |
279 | -------------------------------------------------------------------
280 | Mon Jan 2 11:27:29 UTC 2023 - Dominik Heidler
281 |
282 | - Version 2.9.0
283 | - Install selected package explicitly from the selected repo
284 | - Switch to resilio-sync for testsuite
285 | - add resilio-sync
286 |
287 | -------------------------------------------------------------------
288 | Tue Aug 9 13:58:57 UTC 2022 - Dominik Heidler
289 |
290 | - Version 2.8.0
291 | - add anydesk
292 | - add yandex browser
293 | - Use list for plugin queries and check for conflicts
294 | - Don't show projects with non-matching repo
295 |
296 | -------------------------------------------------------------------
297 | Mon Jun 13 09:08:05 UTC 2022 - Dominik Heidler
298 |
299 | - Version 2.7.0
300 | - Make repo parsing more stable and improve error handling
301 |
302 | -------------------------------------------------------------------
303 | Tue May 31 14:44:14 UTC 2022 - Dominik Heidler
304 |
305 | - Version 2.6.0
306 | - Move to global config in /etc/opi.cfg
307 | - Check if desired repo is already added instead of relying on prefix
308 | - Add config option use_releasever_var
309 |
310 | -------------------------------------------------------------------
311 | Mon May 16 15:07:53 UTC 2022 - Dominik Heidler
312 |
313 | - Version 2.5.0
314 | - Run ci for both tumbleweed and leap
315 | - Use $releasever in repo creation on Leap
316 |
317 | -------------------------------------------------------------------
318 | Mon Apr 25 08:54:45 UTC 2022 - Dominik Heidler
319 |
320 | - Version 2.4.7
321 | - Fix numbering in --help
322 | - Add release helper script
323 |
324 | -------------------------------------------------------------------
325 | Fri Apr 22 12:43:05 UTC 2022 - Dominik Heidler
326 |
327 | - Version 2.4.6
328 | - Update .NET SDK to 6.0
329 |
330 | -------------------------------------------------------------------
331 | Tue Mar 1 17:44:14 UTC 2022 - Dominik Heidler
332 |
333 | - Version 2.4.5
334 | - Update packman codecs plugin to reflect recent changes
335 | that apply to Tumbleweed and releases after 15.4
336 | see https://lists.opensuse.org/archives/list/factory@lists.opensuse.org/thread/VMXOWQWC4WW3W6PM7WPZDRMNCV26KKGY/
337 |
338 | -------------------------------------------------------------------
339 | Fri Jan 28 11:07:25 UTC 2022 - Dominik Heidler
340 |
341 | - Version 2.4.4
342 | - Fix for Alpha/Beta dist versions
343 |
344 | -------------------------------------------------------------------
345 | Mon Jan 24 11:23:50 UTC 2022 - Dominik Heidler
346 |
347 | - Version 2.4.3
348 | - Fix for tumbleweed based MicroOS
349 |
350 | -------------------------------------------------------------------
351 |
352 | - Version 2.4.2 - 2021-10-25
353 |
354 | ## Changed
355 |
356 | - Switched to opensuse provided opi proxy
357 |
358 | -------------------------------------------------------------------
359 |
360 | - Version 2.4.1 - 2021-10-11
361 |
362 | ## Changed
363 |
364 | - Don't expect output to be a tty
365 |
366 | -------------------------------------------------------------------
367 |
368 | - Version 2.4.0 - 2021-10-11
369 |
370 | ## Added
371 |
372 | - Scroll results if they not fit on the screen
373 | - Plugin for atom editor
374 |
375 | -------------------------------------------------------------------
376 |
377 | # Version 2.3.0 - 2021-06-06
378 |
379 | ### Changed
380 |
381 | - Fixed gpgcheck entry in `add_repo()`
382 | - Allowed using multiple query keywords that are combined using AND
383 |
384 | ### Added
385 |
386 | - Plugin for sublime text
387 | - Plugin for yandex-disk
388 |
389 | -------------------------------------------------------------------
390 |
391 | - Version 2.2.0 - 2021-08-20
392 |
393 | ### Added
394 |
395 | - Plugin for MEGA
396 | - Plugin for Edge Beta
397 | - Argument parser with option for reverse output order
398 |
399 | -------------------------------------------------------------------
400 |
401 | - Version 2.1.1 - 2021-08-10
402 |
403 | ### Added
404 |
405 | - Plugin for Brave Browser [#60](https://github.com/openSUSE/opi/pull/60)
406 |
407 | -------------------------------------------------------------------
408 |
409 | - Version 2.1.0 - 2021-07-05
410 |
411 | ### Added
412 |
413 | - Support for dnf backend [#58](https://github.com/openSUSE/opi/pull/58)
414 |
415 | ### Changed
416 |
417 | - Deduplicated packman repo creation code
418 |
419 | -------------------------------------------------------------------
420 |
421 | - Version 2.0.0 - 2021-05-03
422 |
423 | ### Added
424 |
425 | - [Automated tests](https://github.com/openSUSE/opi/actions)
426 | - Extensible Plugin interface for plugins (eg. [this one](https://github.com/openSUSE/opi/blob/master/opi/plugins/vivaldi.py))
427 | - Added plugins for chrome, dotnet, edge, teams, packman, plex, skype, slack, teamviewer, vivaldi, vscode, vscodium, zoom
428 |
429 | ### Changed
430 |
431 | - Rewrote the complete tool in python3
432 |
433 | -------------------------------------------------------------------
434 |
435 | - Version 0.10.0 - 2021-01-17
436 |
437 | ### Added
438 |
439 | - Microsoft Teams installer [#34](https://github.com/openSUSE/opi/pulls/34)
440 | - Warning for personal repository [#35](https://github.com/openSUSE/opi/pulls/35)
441 |
442 | -------------------------------------------------------------------
443 |
444 | - Version 0.9.0 - 2020-10-03
445 |
446 | ### Added
447 |
448 | - Help (-h, --help) and version (-v, --version) option
449 |
450 | ### Changed
451 |
452 | - Filter out -devel, -docs and -lang packages [#30](https://github.com/openSUSE/opi/pulls/30)
453 | - Don't show i586 packages on x86_64 system
454 |
455 | -------------------------------------------------------------------
456 |
457 | - Version 0.8.3 - 2020-07-25
458 |
459 | ### Fixed
460 |
461 | - ffmpeg/libav packages due to Packman update
462 |
463 | -------------------------------------------------------------------
464 |
465 | - Version 0.8.2 - 2020-05-16
466 |
467 | ### Fixed
468 |
469 | - Ghost process on XML parsing failure [#27](https://github.com/openSUSE/opi/pulls/27)
470 |
471 | -------------------------------------------------------------------
472 |
473 | - Version 0.8.1 - 2020-04-03
474 |
475 | ### Fixed
476 |
477 | - OBS limit error when searching php, test, etc.
478 |
479 | -------------------------------------------------------------------
480 |
481 | - Version 0.8.0
482 |
483 | ### Changed
484 |
485 | - Type number `0` to exit [#26](https://github.com/openSUSE/opi/pulls/26)
486 |
487 | -------------------------------------------------------------------
488 |
489 | - Version 0.7.1
490 |
491 | ### Fixed
492 |
493 | - Missing `use File::Temp;` [#24](https://github.com/openSUSE/opi/issues/24)
494 |
495 | -------------------------------------------------------------------
496 |
497 | - Version 0.7.0
498 |
499 | ### Changed
500 |
501 | - Force repo URL to HTTPS [#22](https://github.com/openSUSE/opi/issues/22)
502 |
503 | ### Fixed
504 |
505 | - Ctrl + C handling of spinner
506 |
507 | -------------------------------------------------------------------
508 |
509 | - Version 0.6.0
510 |
511 | ### Added
512 |
513 | - Search spinner [#21](https://github.com/openSUSE/opi/issues/21)
514 |
515 | ### Fixed
516 |
517 | - Packman repo doesn't have *.repo file [#19](https://github.com/openSUSE/opi/issues/19)
518 | - Long version numbers are cutted [#17](https://github.com/openSUSE/opi/issues/17)
519 |
520 | -------------------------------------------------------------------
521 |
522 | - Version 0.5.2
523 |
524 | ### Fixed
525 |
526 | - Trim "NAME" and "VERSION" string [#13](https://github.com/openSUSE/opi/issues/13)
527 |
528 | -------------------------------------------------------------------
529 |
530 | - Version 0.5.1
531 |
532 | ### Fixed
533 |
534 | - Fix dependency not found issue [#11](https://github.com/openSUSE/opi/issues/11)
535 |
536 | -------------------------------------------------------------------
537 |
538 | - Version 0.5.0
539 |
540 | ### Added
541 |
542 | - API proxy server to prevent hard-coded passwords in the script [#4](https://github.com/openSUSE/opi/issues/4)
543 |
544 | -------------------------------------------------------------------
545 |
546 | - Version 0.4.0
547 |
548 | ### Added
549 |
550 | - PMBS (Packman Build Service) support [#5](https://github.com/openSUSE/opi/issues/5)
551 |
552 | -------------------------------------------------------------------
553 |
554 | - Version 0.3.2
555 |
556 | ### Fixed
557 |
558 | - `opi opi` cannot find `opi` [#9](https://github.com/openSUSE/opi/issues/9)
559 |
560 | -------------------------------------------------------------------
561 |
562 | - Version 0.3.1
563 |
564 | ### Fixed
565 |
566 | - Remove quotes from version number. So Leap and SLE can search packages.
567 |
568 | -------------------------------------------------------------------
569 |
570 | - Version 0.3.0
571 |
572 | ### Added
573 |
574 | - Support SLE [#8](https://github.com/openSUSE/opi/issues/8)
575 |
576 | ### Changed
577 |
578 | - Better print column alignment
579 |
580 | -------------------------------------------------------------------
581 |
582 | - Version 0.2.0
583 |
584 | ### Added
585 |
586 | - Install Packman Codecs with `opi packman` or `opi codecs` [#6](https://github.com/openSUSE/opi/issues/6)
587 | - Install Skype with `opi skype` [#6](https://github.com/openSUSE/opi/issues/6)
588 | - Install VS Code with `opi vs code` [#6](https://github.com/openSUSE/opi/issues/6)
589 |
590 | -------------------------------------------------------------------
591 |
592 | - Version 0.1.2
593 |
594 | ### Fixed
595 |
596 | - Fixed lost of "noarch" packages [#3](https://github.com/openSUSE/opi/issues/3)
597 | - Be able to search with dashes in keywords [#2](https://github.com/openSUSE/opi/issues/2)
598 |
599 | -------------------------------------------------------------------
600 |
601 | - Version 0.1.1
602 |
603 | ### Fixed
604 |
605 | - Removed XML dump which may cause problems.
606 |
607 | -------------------------------------------------------------------
608 |
609 | - Version 0.1.0
610 |
611 | ### Added
612 |
613 | - Search packages from OBS
614 | - List properly sorted search result
615 | - Use different colors for official, experimental and personal projects
616 | - Choose package and install
617 | - Keep or remove repository after installation
618 |
619 | [Unreleased]: https://github.com/openSUSE/opi/compare/v0.10.0...HEAD
620 | [0.10.0]: https://github.com/openSUSE/opi/compare/v0.9.0...v0.10.0
621 | [0.9.0]: https://github.com/openSUSE/opi/compare/v0.8.3...v0.9.0
622 | [0.8.3]: https://github.com/openSUSE/opi/compare/v0.8.2...v0.8.3
623 | [0.8.2]: https://github.com/openSUSE/opi/compare/v0.8.1...v0.8.2
624 | [0.8.1]: https://github.com/openSUSE/opi/compare/v0.8.0...v0.8.1
625 | [0.8.0]: https://github.com/openSUSE/opi/compare/v0.7.1...v0.8.0
626 | [0.7.1]: https://github.com/openSUSE/opi/compare/v0.7.0...v0.7.1
627 | [0.7.0]: https://github.com/openSUSE/opi/compare/v0.6.0...v0.7.0
628 | [0.6.0]: https://github.com/openSUSE/opi/compare/v0.5.2...v0.6.0
629 | [0.5.2]: https://github.com/openSUSE/opi/compare/v0.5.1...v0.5.2
630 | [0.5.1]: https://github.com/openSUSE/opi/compare/v0.5.0...v0.5.1
631 | [0.5.0]: https://github.com/openSUSE/opi/compare/v0.4.0...v0.5.0
632 | [0.4.0]: https://github.com/openSUSE/opi/compare/v0.3.2...v0.4.0
633 | [0.3.2]: https://github.com/openSUSE/opi/compare/v0.3.1...v0.3.2
634 | [0.3.1]: https://github.com/openSUSE/opi/compare/v0.3.0...v0.3.1
635 | [0.3.0]: https://github.com/openSUSE/opi/compare/v0.2.0...v0.3.0
636 | [0.2.0]: https://github.com/openSUSE/opi/compare/v0.1.2...v0.2.0
637 | [0.1.2]: https://github.com/openSUSE/opi/compare/v0.1.1...v0.1.2
638 | [0.1.1]: https://github.com/openSUSE/opi/compare/v0.1.0...v0.1.1
639 | [0.1.0]: https://github.com/openSUSE/opi/releases/tag/v0.1.0
640 |
--------------------------------------------------------------------------------
/opi.default.cfg:
--------------------------------------------------------------------------------
1 | [opi]
2 | use_releasever_var = true
3 | new_repo_auto_refresh = true
4 | list_in_reverse = false
5 |
--------------------------------------------------------------------------------
/opi/__init__.py:
--------------------------------------------------------------------------------
1 | import os
2 | import sys
3 | import subprocess
4 | import re
5 | import tempfile
6 | import configparser
7 | from functools import cmp_to_key
8 | from collections import defaultdict
9 |
10 | import requests
11 | import lxml.etree
12 | import rpm
13 |
14 | from termcolor import colored, cprint
15 |
16 | from opi import pager
17 | from opi import config
18 | from opi.state import global_state
19 |
20 | OBS_APIROOT = {
21 | 'openSUSE': 'https://api.opensuse.org',
22 | 'Packman': 'https://pmbs.links2linux.de'
23 | }
24 | PROXY_URL = 'https://opi-proxy.opensuse.org/'
25 |
26 | REPO_DIR = '/etc/zypp/repos.d/'
27 |
28 | ##################
29 | ### Exceptions ###
30 | ##################
31 |
32 | class NoOptionSelected(Exception):
33 | pass
34 |
35 | class HTTPError(Exception):
36 | pass
37 |
38 | ###################
39 | ### System Info ###
40 | ###################
41 |
42 | cpu_arch = None
43 | def get_cpu_arch():
44 | """
45 | returns e.g. x86_64, aarch64
46 | """
47 | global cpu_arch
48 | if not cpu_arch:
49 | cpu_arch = os.uname().machine
50 | if re.match(r'^i.86$', cpu_arch):
51 | cpu_arch = 'i586'
52 | return cpu_arch
53 |
54 | os_release = {}
55 | def get_os_release():
56 | global os_release
57 | if not os_release:
58 | with open('/etc/os-release') as f:
59 | for line in f.readlines():
60 | line = line.strip()
61 | if line.startswith('#') or '=' not in line:
62 | continue
63 | key, value = line.split('=', 1)
64 | key = key.strip()
65 | value = value.strip()
66 | if '"' in value:
67 | value = value.split('"', 1)[1].split('"', 1)[0]
68 | os_release[key] = value
69 | return os_release
70 |
71 | def get_distribution(prefix=False, use_releasever_variable=False):
72 | os_release = get_os_release()
73 | name = os_release['NAME']
74 | version = os_release.get('VERSION') # VERSION is not set for TW
75 | if version:
76 | # strip prerelease suffix (eg. ' Alpha')
77 | version = version.split(' ', 1)[0]
78 | if name in ('openSUSE Tumbleweed', 'openSUSE MicroOS'):
79 | project = 'openSUSE:Factory'
80 | elif name in ('openSUSE Tumbleweed-Slowroll', 'openSUSE MicroOS-Slowroll'):
81 | project = 'openSUSE:Slowroll'
82 | elif name == 'openSUSE Leap':
83 | if use_releasever_variable:
84 | project = 'openSUSE:Leap:$releasever'
85 | else:
86 | project = 'openSUSE:Leap:' + version
87 | elif name == 'openSUSE Leap Micro':
88 | # Leap Micro major version seems to be 10 lower than Leap the version it is based on
89 | if use_releasever_variable:
90 | project = 'openSUSE:Leap:1$releasever'
91 | else:
92 | project = 'openSUSE:Leap:1' + version
93 | elif name.startswith('SLE'):
94 | project = 'SLE' + version
95 | if prefix:
96 | project = 'openSUSE.org:' + project
97 | return project
98 |
99 | def get_version() -> str:
100 | os_release = get_os_release()
101 | version = os_release.get('VERSION') # VERSION is not set for TW
102 | return version
103 |
104 | def expand_vars(s: str) -> str:
105 | s = s.replace('${releasever}', get_version() or '${releasever}')
106 | s = s.replace('$releasever', get_version() or '$releasever')
107 | s = s.replace('${basearch}', get_cpu_arch() or '${basearch}')
108 | s = s.replace('$basearch', get_cpu_arch() or '$basearch')
109 | return s
110 |
111 |
112 | ###############
113 | ### PACKMAN ###
114 | ###############
115 |
116 | def add_packman_repo(dup=False):
117 | repos_by_alias = {repo.alias: repo for repo in get_repos()}
118 | if 'packman' in repos_by_alias:
119 | print("Installing from existing packman repo")
120 | else:
121 | print("Adding packman repo")
122 | packman_mirrors = {
123 | "ftp.fau.de - University of Erlangen, Germany - 1h sync": "https://ftp.fau.de/packman",
124 | "ftp.halifax.rwth-aachen.de - University of Aachen, Germany - 1h sync": "https://ftp.halifax.rwth-aachen.de/packman",
125 | "ftp.gwdg.de - University of Göttingen, Germany - 4h sync": "https://ftp.gwdg.de/pub/linux/misc/packman",
126 | "mirror.karneval.cz - TES Media, Czech Republic - 1h sync": "https://mirror.karneval.cz/pub/linux/packman",
127 | "mirrors.aliyun.com - Alibaba Cloud, China - 24h sync": "https://mirrors.aliyun.com/packman",
128 | }
129 | mirror = ask_for_option(list(packman_mirrors.keys()), 'Pick a mirror near your location (0 to quit):')
130 | mirror = packman_mirrors[mirror]
131 |
132 | project = get_distribution(use_releasever_variable=config.get_key_from_config('use_releasever_var'))
133 | project = project.replace(':', '_')
134 | project = project.replace('Factory', 'Tumbleweed')
135 | add_repo(
136 | filename = 'packman',
137 | name = 'Packman',
138 | url = f'{mirror}/suse/{project}/',
139 | gpgkey = f'https://ftp.fau.de/packman/suse/{project}/repodata/repomd.xml.key', # always fetch gpgkey from FAU server
140 | auto_refresh = config.get_key_from_config('new_repo_auto_refresh'),
141 | priority = 70
142 | )
143 |
144 | if dup:
145 | dist_upgrade(from_repo='packman', allow_downgrade=True, allow_vendor_change=True)
146 |
147 | def add_openh264_repo(dup=False):
148 | project = get_os_release()['NAME']
149 | project = project.replace('-Slowroll', '')
150 | project = project.replace('openSUSE MicroOS', 'openSUSE Tumbleweed')
151 | project = project.replace('openSUSE Leap Micro', 'openSUSE Leap')
152 | project = project.replace(':', '_').replace(' ', '_')
153 |
154 | url = f'http://codecs.opensuse.org/openh264/{project}/'
155 | existing_repo = get_enabled_repo_by_url(url)
156 | if existing_repo:
157 | print(f"Installing from existing repo '{existing_repo.name}'")
158 | repo = existing_repo.alias
159 | else:
160 | repo = 'openh264'
161 | print(f"Adding repo '{repo}'")
162 | add_repo(
163 | filename = repo,
164 | name = repo,
165 | url = url,
166 | gpgkey = f"{url.replace('http://', 'https://')}repodata/repomd.xml.key",
167 | auto_refresh = config.get_key_from_config('new_repo_auto_refresh'),
168 | priority = 70
169 | )
170 |
171 | if dup:
172 | dist_upgrade(from_repo=repo, allow_downgrade=True, allow_vendor_change=True)
173 |
174 | def install_packman_packages(packages, **kwargs):
175 | install_packages(packages, from_repo='packman', **kwargs)
176 |
177 |
178 | ################
179 | ### ZYPP/DNF ###
180 | ################
181 |
182 | class Repository:
183 | def __init__(self, alias: str, name: str, url: str, auto_refresh: bool, gpgkey: str = None, filename: str = None):
184 | self.alias = alias
185 | self.name = name
186 | self.url = url
187 | self.auto_refresh = auto_refresh
188 | self.gpgkey = gpgkey
189 | self.filename = filename or alias
190 |
191 | def name_expanded(self):
192 | """ Return name with all supported vars expanded """
193 | return expand_vars(self.name)
194 |
195 | def url_expanded(self):
196 | """ Return url with all supported vars expanded """
197 | return expand_vars(self.url)
198 |
199 | def search_local_repos(package):
200 | """
201 | Search local default repos
202 | """
203 | search_results = defaultdict(list)
204 | try:
205 | zc = tempfile.NamedTemporaryFile('w')
206 | zc.file.write(f'[main]\nshowAlias = true\n')
207 | zc.file.flush()
208 | os.chmod(zc.name, 0o644)
209 | # ensure to run as non-root as this allows the cmd to run even if rpmdb is locked
210 | user = None if os.getuid() else 'nobody'
211 | cmd = ['zypper', '-ntc', zc.name, '--no-refresh', 'se', '-sx', '-tpackage', package]
212 | env = {'LANG': 'c'}
213 | try:
214 | sr = subprocess.check_output(cmd, env=env, user=user).decode()
215 | except TypeError:
216 | # no user arg on old python versions
217 | sr = subprocess.check_output(cmd, env=env).decode()
218 | for line in re.split(r'-\+-+\n', sr, re.MULTILINE)[1].strip().split('\n'):
219 | version, arch, repo_alias = [s.strip() for s in line.split('|')[3:]]
220 | version, release = version.split('-')
221 | if arch not in (get_cpu_arch(), 'noarch'):
222 | continue
223 | if repo_alias == '(System Packages)':
224 | continue
225 | search_results[repo_alias].append({'version': version, 'release': release, 'arch': arch})
226 | except subprocess.CalledProcessError as e:
227 | if e.returncode == 104:
228 | # 104 ZYPPER_EXIT_INF_CAP_NOT_FOUND is returned if there are no results
229 | pass
230 | elif e.returncode == 7:
231 | # 7 ZYPPER_EXIT_ZYPP_LOCKED - error is already printed by zypper
232 | sys.exit(1)
233 | elif e.returncode == 106:
234 | # 106 - ZYPPER_EXIT_INF_REPOS_SKIPPED - some repos have no cache
235 | cprint("Warning: The repos listed above have no local cache and will be ignored for this query.", 'yellow')
236 | cprint(" Run 'zypper refresh' as root to fix this.", 'yellow')
237 | else:
238 | raise # TODO: don't exit program, use exception that will be handled in repo_query except block
239 |
240 | repos_by_alias = {repo.alias: repo for repo in get_repos()}
241 | local_installables = []
242 | for repo_alias, installables in search_results.items():
243 | # get the newest package for each repo
244 | try:
245 | installables.sort(key=lambda p: cmp_to_key(rpm.labelCompare)("%(version)s-%(release)s" % p))
246 | except TypeError:
247 | # rpm 4.14 needs a tuple of (epoch, version, release) - rpm 4.18 can handle a string
248 | installables.sort(key=lambda p: cmp_to_key(rpm.labelCompare)(['1', p['version'], p['release']]))
249 | installable = installables[-1]
250 |
251 | installable['repository'] = repos_by_alias[repo_alias]
252 | installable['name'] = package
253 | # filter out OBS/Packman repos as they are already searched via OBS/Packman API
254 | if 'download.opensuse.org/repositories' in installable['repository'].url:
255 | continue
256 | if installable['repository'].filename == 'packman':
257 | continue
258 | local_installables.append(LocalPackage(**installable))
259 | return local_installables
260 |
261 | def url_normalize(url):
262 | return expand_vars(re.sub(r'^https?', '', url).rstrip('/'))
263 |
264 | def get_repos():
265 | for repo_file in os.listdir(REPO_DIR):
266 | if not repo_file.endswith('.repo'):
267 | continue
268 | try:
269 | cp = configparser.ConfigParser()
270 | cp.read(os.path.join(REPO_DIR, repo_file))
271 | for alias in cp.sections():
272 | if not bool(int(cp.get(alias, 'enabled'))):
273 | continue
274 | repo = {
275 | 'alias': alias,
276 | 'filename': re.sub(r'\.repo$', '', repo_file),
277 | 'name': cp[alias].get('name', alias),
278 | 'url': cp[alias].get('baseurl'),
279 | 'auto_refresh': bool(int(cp[alias].get('autorefresh', '0'))),
280 | }
281 | if cp.has_option(alias, 'gpgkey'):
282 | repo['gpgkey'] = cp[alias].get('gpgkey')
283 | yield Repository(**repo)
284 | except Exception as e:
285 | print(f"Error parsing '{repo_file}': {e}")
286 |
287 | def get_enabled_repo_by_url(url):
288 | for repo in get_repos():
289 | if url_normalize(repo.url) == url_normalize(url):
290 | return repo
291 |
292 | 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):
293 | tf = tempfile.NamedTemporaryFile('w')
294 | tf.file.write(f'[{filename}]\n')
295 | tf.file.write(f'name={name}\n')
296 | tf.file.write(f'baseurl={url}\n')
297 | tf.file.write(f'enabled={enabled:d}\n')
298 | tf.file.write(f'type={repo_type}\n')
299 | tf.file.write(f'gpgcheck={gpgcheck:d}\n')
300 | if gpgkey:
301 | ask_import_key(gpgkey)
302 | tf.file.write(f'gpgkey={gpgkey}\n')
303 | if auto_refresh:
304 | tf.file.write('autorefresh=1\n')
305 | if priority:
306 | tf.file.write(f'priority={priority}\n')
307 | tf.file.flush()
308 | repo_file = os.path.join(REPO_DIR, f'{filename}.repo')
309 | subprocess.call(['sudo', 'cp', tf.name, repo_file])
310 | subprocess.call(['sudo', 'chmod', '644', repo_file])
311 | tf.file.close()
312 | if global_state.arg_verbose_mode:
313 | print(f"Wrote {repo_file}:\n{'-'*8}\n{open(repo_file).read()}{'-'*8}")
314 | refresh_repos(auto_import_keys=auto_import_keys)
315 |
316 | def refresh_repos(repo_alias=None, auto_import_keys=False):
317 | refresh_cmd = []
318 | refresh_cmd = ['sudo', 'zypper']
319 | if auto_import_keys:
320 | refresh_cmd.append('--gpg-auto-import-keys')
321 | refresh_cmd.append('ref')
322 | if repo_alias:
323 | refresh_cmd.append(repo_alias)
324 | subprocess.call(refresh_cmd)
325 |
326 | def normalize_key(pem):
327 | new_lines = []
328 | for line in pem.split('\n'):
329 | line = line.strip()
330 | if not line:
331 | continue
332 | if line.lower().startswith('version:'):
333 | continue
334 | new_lines.append(line)
335 | new_lines.insert(1, '')
336 | return '\n'.join(new_lines)
337 |
338 | def split_keys(keys):
339 | for key in keys.split('-----BEGIN PGP PUBLIC KEY BLOCK-----')[1:]:
340 | yield '-----BEGIN PGP PUBLIC KEY BLOCK-----' + key
341 |
342 | def get_keys_from_rpmdb():
343 | s = subprocess.check_output(['rpm', '-q', 'gpg-pubkey', '--qf',
344 | '%{NAME}-%{VERSION}\n%{PACKAGER}\n%{DESCRIPTION}\nOPI-SPLIT-TOKEN-TO-TELL-KEY-PACKAGES-APART\n'])
345 | keys = []
346 | for raw_kpkg in s.decode().strip().split('OPI-SPLIT-TOKEN-TO-TELL-KEY-PACKAGES-APART'):
347 | raw_kpkg = raw_kpkg.strip()
348 | if not raw_kpkg:
349 | continue
350 | kid, name, pubkey = raw_kpkg.strip().split('\n', 2)
351 | keys.append({
352 | 'kid': kid,
353 | 'name': name,
354 | 'pubkey': normalize_key(pubkey)
355 | })
356 | return keys
357 |
358 | def install_packages(packages, **kwargs):
359 | pkgmgr_action('in', packages, **kwargs)
360 |
361 | def dist_upgrade(**kwargs):
362 | pkgmgr_action('dup', **kwargs)
363 |
364 | 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):
365 | args = ['sudo', 'zypper']
366 | if global_state.arg_non_interactive or non_interactive:
367 | args.append('-n')
368 | if allow_unsigned:
369 | args.append('--no-gpg-checks')
370 | args.append(action)
371 | if from_repo:
372 | args.extend(['--from', from_repo])
373 | if allow_downgrade:
374 | args.append('--allow-downgrade')
375 | if allow_arch_change:
376 | args.append('--allow-arch-change')
377 | if allow_name_change:
378 | args.append('--allow-name-change')
379 | if allow_vendor_change:
380 | args.append('--allow-vendor-change')
381 | if action == 'in':
382 | args.append('--oldpackage')
383 | if no_recommends:
384 | args.append('--no-recommends')
385 | args.extend(packages)
386 | subprocess.call(args)
387 |
388 |
389 | ###########
390 | ### OBS ###
391 | ###########
392 |
393 | class Installable:
394 | def __init__(self, name: str, version: str, release: str, arch: str):
395 | self.name = name # e.g. MozillaFirefox
396 | self.version = version # e.g. 1.2.3
397 | self.release = release # e.g. 150500.1.1
398 | self.arch = arch # e.g. x86_64, aarch64 or noarch
399 |
400 | def install(self):
401 | raise NotImplemented()
402 |
403 | def name_with_arch(self):
404 | return f'{self.name}.{self.arch}'
405 |
406 | def _install_from_existing_repo(self, repo: Repository):
407 | # Install from existing repos (don't add a repo)
408 | print(f"Installing from existing repo '{repo.name_expanded()}'")
409 | # ensure that this repo is up to date if no auto_refresh is configured
410 | if not repo.auto_refresh:
411 | refresh_repos(repo.alias)
412 | install_packages([self.name_with_arch()], from_repo=repo.alias)
413 |
414 | class OBSPackage(Installable):
415 | """ Package returned from OBS API """
416 | def __init__(self,
417 | name: str, version: str, release: str, arch: str,
418 | package: str, project: str, repository: str, obs_instance: str):
419 | super().__init__(name, version, release, arch)
420 | self.package = package # same as name unless this is a subpackage (then package is name of parent)
421 | self.project = project # e.g. devel:languages:perl
422 | self.repository = repository # e.g. openSUSE_Tumbleweed
423 | self.obs_instance = obs_instance # openSUSE or Packman
424 |
425 | def install(self):
426 | if self.obs_instance == 'Packman':
427 | # Install from Packman Repo
428 | add_packman_repo()
429 | install_packman_packages([self.name_with_arch()])
430 | return
431 |
432 | repo_alias = self.project.replace(':', '_')
433 | project_path = self.project.replace(':', ':/')
434 | repository = self.repository
435 | if config.get_key_from_config('use_releasever_var'):
436 | version = get_version()
437 | if version:
438 | # version is None on tw
439 | repository = repository.replace(version, '$releasever')
440 | url = f'https://download.opensuse.org/repositories/{project_path}/{repository}/'
441 | gpgkey = url + 'repodata/repomd.xml.key'
442 | existing_repo = get_enabled_repo_by_url(url)
443 |
444 | if existing_repo:
445 | self._install_from_existing_repo(existing_repo)
446 | else:
447 | print(f"Adding repo '{self.project}'")
448 | add_repo(
449 | filename = repo_alias,
450 | name = self.project,
451 | url = url,
452 | gpgkey = gpgkey,
453 | gpgcheck = True,
454 | auto_refresh = config.get_key_from_config('new_repo_auto_refresh')
455 | )
456 | install_packages([self.name_with_arch()], from_repo=repo_alias,
457 | allow_downgrade=True,
458 | allow_arch_change=True,
459 | allow_name_change=True,
460 | allow_vendor_change=True
461 | )
462 | ask_keep_repo(repo_alias)
463 |
464 | def weight(self):
465 | weight = 0
466 |
467 | dash_count = self.name.count('-')
468 | weight += 1e5 * (0.5 ** dash_count)
469 |
470 | weight -= 1e4 * len(self.name)
471 |
472 | if self.is_from_official_project():
473 | weight += 2e3
474 | elif not self.is_from_personal_project():
475 | weight += 1e3
476 |
477 | if self.name == self.package:
478 | # this rpm is the main or only subpackage
479 | weight += 1e2
480 |
481 | if not (get_cpu_arch() == 'x86_64' and self.arch == 'i586'):
482 | weight += 1e1
483 |
484 | if self.repository.startswith('openSUSE_Tumbleweed'):
485 | weight += 2
486 | elif self.repository.startswith('openSUSE_Factory'):
487 | weight += 1
488 | elif self.repository == 'standard':
489 | weight += 0
490 |
491 | return weight
492 |
493 | def __lt__(self, other):
494 | """ Note that we sort from high weight to low weight """
495 | return self.weight() > other.weight()
496 |
497 | def is_from_official_project(self):
498 | return self.project.startswith('openSUSE:')
499 |
500 | def is_from_personal_project(self):
501 | return self.project.startswith('home:') or self.project.startswith('isv:')
502 |
503 | class LocalPackage(Installable):
504 | """ Package found in local repo (metadata) cache """
505 | def __init__(self, name: str, version: str, release: str, arch: str, repository: Repository):
506 | super().__init__(name, version, release, arch)
507 | self.repository = repository
508 |
509 | def install(self):
510 | self._install_from_existing_repo(self.repository)
511 |
512 | def search_published_packages(obs_instance, query):
513 | distribution = get_distribution(prefix=(obs_instance != 'openSUSE'))
514 | endpoint = '/search/published/binary/id'
515 | url = OBS_APIROOT[obs_instance] + endpoint
516 | if isinstance(query, list):
517 | xquery = "'" + "', '".join(query) + "'"
518 | else:
519 | xquery = f"'{query}'"
520 | xpath = f"contains-ic(@name, {xquery}) and path/project='{distribution}'"
521 | url = requests.Request('GET', url, params={'match': xpath, 'limit': 0}).prepare().url
522 | try:
523 | r = requests.get(PROXY_URL, params={'obs_api_link': url, 'obs_instance': obs_instance})
524 | r.raise_for_status()
525 |
526 | dom = lxml.etree.fromstring(r.text)
527 | packages = []
528 | for binary in dom.xpath('/collection/binary'):
529 | binary_data = {k: v for k, v in binary.items()}
530 | binary_data['obs_instance'] = obs_instance
531 |
532 | del binary_data['filename']
533 | del binary_data['filepath']
534 | del binary_data['baseproject']
535 | del binary_data['type']
536 | for k in ('name', 'project', 'repository', 'version', 'release', 'arch'):
537 | assert k in binary_data, f"Key '{k}' missing"
538 |
539 | # Filter out ghost binary
540 | # (package has been deleted, but binary still exists)
541 | if not binary_data.get('package'):
542 | continue
543 |
544 | package = OBSPackage(**binary_data)
545 |
546 | # Filter out branch projects
547 | if ':branches:' in package.project:
548 | continue
549 |
550 | # Filter out Packman personal projects
551 | if package.obs_instance != 'openSUSE' and package.is_from_personal_project():
552 | continue
553 |
554 | # Filter out debuginfo, debugsource, devel, buildsymbols, lang and docs packages
555 | regex = r'-(debuginfo|debugsource|buildsymbols|devel|lang|l10n|trans|doc|docs)(-.+)?$'
556 | if re.match(regex, package.name):
557 | continue
558 |
559 | # Filter out source packages
560 | if package.arch == 'src':
561 | continue
562 |
563 | # Filter architecture
564 | cpu_arch = get_cpu_arch()
565 | if package.arch not in (cpu_arch, 'noarch'):
566 | continue
567 |
568 | # Filter repo architecture
569 | if package.repository == 'openSUSE_Factory' and (cpu_arch not in ('x86_64' 'i586')):
570 | continue
571 | elif package.repository == 'openSUSE_Factory_ARM' and not cpu_arch.startswith('arm') and not cpu_arch == 'aarch64':
572 | continue
573 | elif package.repository == 'openSUSE_Factory_PowerPC' and not cpu_arch.startswith('ppc'):
574 | continue
575 | elif package.repository == 'openSUSE_Factory_zSystems' and not cpu_arch.startswith('s390'):
576 | continue
577 | elif package.repository == 'openSUSE_Factory_RISCV' and not cpu_arch.startswith('risc'):
578 | continue
579 |
580 | packages.append(package)
581 |
582 | return packages
583 | except requests.exceptions.HTTPError as e:
584 | if e.response.status_code == 413:
585 | print('Please use different search keywords. Some short keywords cause OBS timeout.')
586 | else:
587 | print('HTTPError:', e)
588 | raise HTTPError()
589 |
590 | def get_package_names(packages: list):
591 | """ return a list of package names but without duplicates """
592 | names = []
593 | for pkg in packages:
594 | name = pkg.name
595 | if name not in names:
596 | names.append(name)
597 | return names
598 |
599 | def sort_uniq_packages(packages: list):
600 | """ sort -u for packages; sort by weight and keep only the one with the best repo """
601 | packages = sorted(packages)
602 | new_packages = []
603 | added_packages = set()
604 | for package in packages:
605 | # only select the first package for each name/project combination
606 | # which will be the one with the highest repo weight
607 | query = (package.name, package.project)
608 | if query not in added_packages:
609 | new_packages.append(package)
610 | added_packages.add(query)
611 | return new_packages
612 |
613 | ########################
614 | ### User Interaction ###
615 | ########################
616 |
617 | def ask_yes_or_no(question, default_answer='y'):
618 | q = question + ' '
619 | if default_answer == 'y':
620 | q += '(Y/n)'
621 | else:
622 | q += '(y/N)'
623 | q += ' '
624 | if global_state.arg_non_interactive:
625 | print(q)
626 | answer = default_answer
627 | else:
628 | answer = input(q) or default_answer
629 | return answer.strip().lower() == 'y'
630 |
631 | def ask_for_option(options, question='Pick a number (0 to quit):', option_filter=lambda a: a, disable_pager=False):
632 | """
633 | Ask the user for a number to pick in order to select an option.
634 | Exit if the number is 0.
635 | Specify the number with question and the corresponding option will be returned.
636 | Via option_filter a callback function to format option entries can be supplied,
637 | but this doesn't work with the pager.
638 | If needed, a pager will be used, unless disable_pager is True.
639 | """
640 |
641 | padding_len = len(str(len(options)))
642 | i = 1
643 | numbered_options = []
644 | terminal_width = os.get_terminal_size().columns - 1 if sys.stdout.isatty() else 0
645 | for option in options:
646 | number = f'{i:{padding_len}}. '
647 | numbered_option = number + option_filter(option)
648 | if terminal_width and not disable_pager:
649 | # break too long lines:
650 | # if pager is disabled this might mean that we get terminal sequences here
651 | # which might get broken by some spaces and newlines.
652 | # also too long lines are not fatal outside of the pager
653 | while len(numbered_option) > terminal_width:
654 | numbered_options.append(numbered_option[:terminal_width])
655 | numbered_option = ' ' * len(number) + numbered_option[terminal_width:]
656 | numbered_options.append(numbered_option)
657 | i += 1
658 | if config.get_key_from_config('list_in_reverse'):
659 | numbered_options.reverse()
660 | text = '\n'.join(numbered_options)
661 | if global_state.arg_non_interactive:
662 | input_string = '1' # default to first option in the list
663 | print(f"{text}\n{question} {input_string}")
664 | elif not sys.stdout.isatty() or len(numbered_options) < (os.get_terminal_size().lines - 1) or disable_pager:
665 | # no pager needed
666 | print(text)
667 | input_string = input(question + ' ')
668 | else:
669 | input_string = pager.ask_number_with_pager(text, question, start_at_bottom=config.get_key_from_config('list_in_reverse'))
670 |
671 | input_string = input_string.strip() or '0'
672 | num = int(input_string) if input_string.isdecimal() else -1
673 | if num == 0:
674 | raise NoOptionSelected()
675 | elif not (num >= 1 and num <= len(options)):
676 | return ask_for_option(options, question, option_filter, disable_pager)
677 | else:
678 | return options[num - 1]
679 |
680 | def ask_import_key(keyurl):
681 | keys = requests.get(expand_vars(keyurl)).text
682 | db_keys = get_keys_from_rpmdb()
683 | for key in split_keys(keys):
684 | for line in subprocess.check_output(['gpg', '--quiet', '--show-keys', '--with-colons', '-'], input=key.encode()).decode().strip().split('\n'):
685 | if line.startswith('uid:'):
686 | key_info = line.split(':')[9].replace('\\x3a', ':')
687 | elif line.startswith('pub:'):
688 | kid = f"gpg-pubkey-{line.split(':')[4][-8:].lower()}"
689 | if [db_key for db_key in db_keys if normalize_key(key) in normalize_key(db_key['pubkey'])]:
690 | print(f"Package signing key {kid} ('{key_info}) is already present.")
691 | else:
692 | if ask_yes_or_no(f"Import package signing key {kid} ({key_info})"):
693 | tf = tempfile.NamedTemporaryFile('w')
694 | tf.file.write(key)
695 | tf.file.flush()
696 | subprocess.call(['sudo', 'rpm', '--import', tf.name])
697 | tf.file.close()
698 |
699 | def ask_keep_key(keyurl, repo_alias=None):
700 | """
701 | Ask to remove the key given by url to key file.
702 | Warns about all repos still using the key except the repo given by repo_alias param.
703 | """
704 | urlkeys = split_keys(requests.get(expand_vars(keyurl)).text)
705 | urlkeys_normalized = [normalize_key(urlkey) for urlkey in urlkeys]
706 | db_keys = get_keys_from_rpmdb()
707 | keys_to_ask_user = [key for key in db_keys if key['pubkey'] in urlkeys_normalized]
708 | for key in keys_to_ask_user:
709 | repos_using_this_key = []
710 | for repo in get_repos():
711 | if repo_alias and repo.filename == repo_alias:
712 | continue
713 | if repo.gpgkey:
714 | repokey = normalize_key(requests.get(repo.gpgkey).text)
715 | if repokey == key['pubkey']:
716 | repos_using_this_key.append(repo)
717 | if repos_using_this_key:
718 | default_answer = 'y'
719 | print('This key is still in use by the following remaining repos - removal is NOT recommended:')
720 | print(' - ' + '\n - '.join([repo.filename for repo in repos_using_this_key]))
721 | else:
722 | default_answer = 'n'
723 | print('This key is not in use by any remaining repos.')
724 | print('Keeping the key will allow additional packages signed by this key to be installed in the future without further warning.')
725 | if not ask_yes_or_no(f"Keep package signing key {key['kid']} ({key['name']})?", default_answer):
726 | subprocess.call(['sudo', 'rpm', '-e', key['kid']])
727 |
728 | def ask_keep_repo(repo_alias):
729 | if not ask_yes_or_no(f"Do you want to keep the repo '{repo_alias}'?"):
730 | repo = next((r for r in get_repos() if r.filename == repo_alias))
731 | subprocess.call(['sudo', 'zypper', 'rr', repo_alias])
732 | if repo.gpgkey:
733 | ask_keep_key(repo.gpgkey, repo)
734 |
735 | def format_pkg_option(package, table=True):
736 | if isinstance(package, LocalPackage):
737 | color = 'green'
738 | symbol = '+'
739 | elif package.is_from_official_project():
740 | color = 'yellow'
741 | symbol = '-'
742 | elif package.is_from_personal_project():
743 | color = 'red'
744 | symbol = '!'
745 | else:
746 | color = 'cyan'
747 | symbol = '?'
748 |
749 | if isinstance(package, LocalPackage):
750 | project = package.repository.name_expanded()
751 | else:
752 | project = package.project
753 | if package.obs_instance != 'openSUSE':
754 | project = f"{package.obs_instance} {project}"
755 |
756 | colored_name = colored(f'{project[:39]} {symbol}', color)
757 |
758 | if table:
759 | return f"{colored_name:50} | {package.version[:25]:25} | {package.arch}"
760 | else:
761 | return f"{colored_name} | {package.version} | {package.arch}"
762 |
--------------------------------------------------------------------------------
/opi/config/__init__.py:
--------------------------------------------------------------------------------
1 | import os
2 | import configparser
3 |
4 | default_config = {
5 | 'use_releasever_var': True,
6 | 'new_repo_auto_refresh': True,
7 | 'list_in_reverse': False,
8 | }
9 |
10 | class ConfigError(Exception):
11 | pass
12 |
13 | config_cache = None
14 | def get_key_from_config(key: str):
15 | global config_cache
16 | if not config_cache:
17 | config_cache = default_config.copy()
18 | path = os.environ.get('OPI_CONFIG', '/etc/opi.cfg')
19 | if os.path.exists(path):
20 | cp = configparser.ConfigParser()
21 | cp.read(path)
22 | ocfg = cp['opi']
23 | config_cache.update({
24 | 'use_releasever_var': ocfg.getboolean('use_releasever_var'),
25 | 'new_repo_auto_refresh': ocfg.getboolean('new_repo_auto_refresh'),
26 | 'list_in_reverse': ocfg.getboolean('list_in_reverse'),
27 | })
28 | return config_cache[key]
29 |
--------------------------------------------------------------------------------
/opi/github.py:
--------------------------------------------------------------------------------
1 | import requests
2 | import opi
3 | from opi.state import global_state
4 |
5 | def http_get_json(url):
6 | r = requests.get(url)
7 | r.raise_for_status()
8 | return r.json()
9 |
10 | def get_releases(org, repo, filter_prereleases=True, filters=[]):
11 | releases = http_get_json(f'https://api.github.com/repos/{org}/{repo}/releases')
12 | if filter_prereleases:
13 | releases = [release for release in releases if not release['prerelease']]
14 | for f in filters:
15 | releases = [r for r in releases if f(r)]
16 | return releases
17 |
18 | def get_latest_release(org, repo, filter_prereleases=True, filters=[]):
19 | releases = get_releases(org, repo, filter_prereleases, filters)
20 | return releases[0] if releases else None
21 |
22 | def get_release_assets(release):
23 | return [{'name': a['name'], 'url': a['browser_download_url']} for a in http_get_json(release['assets_url'])]
24 |
25 | def get_release_asset(release, filters=[]):
26 | assets = get_release_assets(release)
27 | for f in filters:
28 | assets = [r for r in assets if f(r)]
29 | return assets[0] if assets else None
30 |
31 | def install_rpm_release(org, repo, filters=[lambda a: a['name'].endswith('.rpm')], allow_unsigned=False):
32 | latest_release = get_latest_release(org, repo)
33 | if not latest_release:
34 | print(f'No release found for {org}/{repo}')
35 | return
36 | asset = get_release_asset(latest_release, filters=filters)
37 | if not asset:
38 | print(f"No RPM asset found for {org}/{repo} release {latest_release['tag_name']}")
39 | return
40 | if global_state.arg_verbose_mode:
41 | print(f"Found: {asset['url']}")
42 | if not opi.ask_yes_or_no(f"Do you want to install {repo} release {latest_release['tag_name']} RPM from {org} github repo?"):
43 | return
44 | opi.install_packages([asset['url']], allow_unsigned=allow_unsigned)
45 |
--------------------------------------------------------------------------------
/opi/http.py:
--------------------------------------------------------------------------------
1 | import os
2 | import requests
3 |
4 | def download_file(url, local_filename):
5 | response = requests.get(url, stream=True)
6 | response.raise_for_status()
7 |
8 | total_size = int(response.headers.get('content-length', 0))
9 | block_size = 1024*512
10 |
11 | os.makedirs(os.path.dirname(local_filename), exist_ok=True)
12 |
13 | print(f"Downloading to {local_filename}:")
14 | with open(local_filename, 'wb') as local_file:
15 | total_bytes_received = 0
16 | for data in response.iter_content(chunk_size=block_size):
17 | local_file.write(data)
18 | total_bytes_received += len(data)
19 | print_progress(total_bytes_received, total_size)
20 | print()
21 |
22 | def print_progress(bytes_received, total_size):
23 | progress = (bytes_received / total_size) * 100
24 | progress = min(100, progress)
25 | print(f"Progress: [{int(progress)}%] [{'=' * int(progress / 2)}{' ' * (50 - int(progress / 2))}]", end='\r')
26 |
--------------------------------------------------------------------------------
/opi/pager.py:
--------------------------------------------------------------------------------
1 | import sys
2 |
3 | import curses
4 |
5 | def ask_number_with_pager(text, question='Pick a number (0 to quit):', start_at_bottom=False):
6 | try:
7 | stdscr = curses.initscr()
8 | curses.noecho()
9 | curses.cbreak() # react on keys without enter
10 |
11 | text_len_lines = len(text.split('\n'))
12 | max_top_line = text_len_lines - (curses.LINES - 2)
13 | scrollarea = curses.newpad(text_len_lines, curses.COLS)
14 | scrollarea.addstr(0, 0, text)
15 | scrollarea_topline_ptr = max_top_line if start_at_bottom else 0
16 | def ensure_scrollarea_bounds(scrollarea_topline_ptr):
17 | scrollarea_topline_ptr = max(scrollarea_topline_ptr, 0)
18 | scrollarea_topline_ptr = min(scrollarea_topline_ptr, max_top_line)
19 | return scrollarea_topline_ptr
20 | def scrollarea_refresh():
21 | scrollarea.refresh(scrollarea_topline_ptr, 0, 0, 0, curses.LINES - 3, curses.COLS - 1)
22 | # remove artefacts due to smaller status line when scrolling up
23 | controlbar.addstr(0, 0, ' ' * curses.COLS)
24 | controlbar.addstr(0, 0,
25 | 'Use arrow keys or PgUp/PgDown to scroll - lines %i-%i/%i %i%%' % (
26 | scrollarea_topline_ptr,
27 | scrollarea_topline_ptr + (curses.LINES - 2),
28 | text_len_lines,
29 | int(100 * scrollarea_topline_ptr / max_top_line)
30 | ),
31 | curses.A_REVERSE
32 | )
33 |
34 | controlbar = stdscr.subwin(2, curses.COLS, curses.LINES - 2, 0)
35 | controlbar.keypad(True) # enable key bindings and conversions
36 | # ensure clean line
37 | controlbar.addstr(1, 0, ' ' * (curses.COLS - 1))
38 | controlbar.addstr(1, 0, question, curses.A_BOLD)
39 | controlbar.refresh()
40 | scrollarea_refresh()
41 |
42 | question += ' '
43 | input_string = ''
44 | while not input_string.endswith('\n'):
45 | c = controlbar.getkey(1, len(question) + len(input_string))
46 | if c == 'KEY_PPAGE':
47 | scrollarea_topline_ptr -= (curses.LINES - 2) // 2
48 | scrollarea_topline_ptr = ensure_scrollarea_bounds(scrollarea_topline_ptr)
49 | scrollarea_refresh()
50 | elif c == 'KEY_NPAGE':
51 | scrollarea_topline_ptr += (curses.LINES - 2) // 2
52 | scrollarea_topline_ptr = ensure_scrollarea_bounds(scrollarea_topline_ptr)
53 | scrollarea_refresh()
54 | elif c == 'KEY_UP':
55 | scrollarea_topline_ptr -= 1
56 | scrollarea_topline_ptr = ensure_scrollarea_bounds(scrollarea_topline_ptr)
57 | scrollarea_refresh()
58 | elif c == 'KEY_DOWN':
59 | scrollarea_topline_ptr += 1
60 | scrollarea_topline_ptr = ensure_scrollarea_bounds(scrollarea_topline_ptr)
61 | scrollarea_refresh()
62 | elif c == 'KEY_HOME':
63 | scrollarea_topline_ptr = 0
64 | scrollarea_topline_ptr = ensure_scrollarea_bounds(scrollarea_topline_ptr)
65 | scrollarea_refresh()
66 | elif c == 'KEY_END':
67 | scrollarea_topline_ptr = sys.maxsize
68 | scrollarea_topline_ptr = ensure_scrollarea_bounds(scrollarea_topline_ptr)
69 | scrollarea_refresh()
70 | elif c == 'KEY_BACKSPACE':
71 | input_string = input_string[:-1]
72 | controlbar.addstr(1, len(question) + len(input_string), ' ')
73 | #elif c == 'KEY_LEFT' or c == 'KEY_RIGHT':
74 | # pass
75 | elif c.startswith('KEY_') or len(c) > 1:
76 | pass
77 | else:
78 | input_string += c
79 | if c != '\n':
80 | controlbar.addstr(1, 0, question, curses.A_BOLD)
81 | controlbar.addstr(1, len(question), input_string)
82 | return input_string
83 | finally:
84 | curses.nocbreak()
85 | stdscr.keypad(False)
86 | curses.echo()
87 | curses.endwin()
88 |
--------------------------------------------------------------------------------
/opi/plugins/__init__.py:
--------------------------------------------------------------------------------
1 | import os
2 | from importlib import import_module
3 | import inspect
4 | from opi import NoOptionSelected
5 |
6 | class BasePlugin:
7 | main_query = ''
8 | description = ''
9 | queries = []
10 |
11 | @classmethod
12 | def matches(cls, query):
13 | return query in cls.queries
14 |
15 | @classmethod
16 | def run(cls, query):
17 | pass
18 |
19 | class PluginManager:
20 | def __init__(self):
21 | self.plugins = []
22 | for module in os.listdir(os.path.dirname(__file__)):
23 | if module == '__init__.py' or not module.endswith('.py') or module == '__pycache__':
24 | continue
25 | m = import_module(f'opi.plugins.{module[:-3]}')
26 | for name, obj in inspect.getmembers(m):
27 | if inspect.isclass(obj) and issubclass(obj, BasePlugin) and obj is not BasePlugin:
28 | self.plugins.append(obj)
29 | self.plugins.sort(key=lambda p: p.main_query)
30 |
31 | def run(self, query):
32 | query = query.lower()
33 | for plugin in self.plugins:
34 | if plugin.matches(query):
35 | try:
36 | plugin.run(query)
37 | except NoOptionSelected:
38 | pass
39 | return True
40 |
41 | def get_plugin_string(self, indent=''):
42 | plugins = ''
43 | for plugin in self.plugins:
44 | description = plugin.description.replace('\n', '\n' + (' ' * 16) + ' ')
45 | plugins += f'{indent}{plugin.main_query:16} {description}\n'
46 | return plugins
47 |
--------------------------------------------------------------------------------
/opi/plugins/anydesk.py:
--------------------------------------------------------------------------------
1 | import opi
2 | from opi.plugins import BasePlugin
3 |
4 | class AnyDesk(BasePlugin):
5 | main_query = 'anydesk'
6 | description = 'AnyDesk remote access'
7 | queries = ['anydesk']
8 |
9 | @classmethod
10 | def run(cls, query):
11 | if not opi.ask_yes_or_no('Do you want to install AnyDesk from AnyDesk repository?'):
12 | return
13 |
14 | opi.add_repo(
15 | filename = 'anydesk',
16 | name = 'anydesk',
17 | url = 'http://rpm.anydesk.com/opensuse/$basearch/',
18 | gpgkey = 'https://keys.anydesk.com/repos/RPM-GPG-KEY'
19 | )
20 |
21 | opi.install_packages(['anydesk'])
22 | opi.ask_keep_repo('anydesk')
23 |
--------------------------------------------------------------------------------
/opi/plugins/atom.py:
--------------------------------------------------------------------------------
1 | import opi
2 |
3 | from opi.plugins import BasePlugin
4 |
5 | class Atom(BasePlugin):
6 | main_query = 'atom'
7 | description = 'Atom Text Editor'
8 | queries = ['atom', 'atom-editor']
9 |
10 | @classmethod
11 | def run(cls, query):
12 | if not opi.ask_yes_or_no('Do you want to install Atom from Atom repository?'):
13 | return
14 |
15 | opi.add_repo(
16 | filename = 'atom',
17 | name = 'Atom',
18 | url = 'https://packagecloud.io/AtomEditor/atom/el/7/x86_64/?type=rpm',
19 | gpgkey = 'https://packagecloud.io/AtomEditor/atom/gpgkey'
20 | )
21 |
22 | opi.install_packages(['atom'])
23 |
24 | opi.ask_keep_repo('atom')
25 |
--------------------------------------------------------------------------------
/opi/plugins/brave.py:
--------------------------------------------------------------------------------
1 | import opi
2 | from opi.plugins import BasePlugin
3 | import subprocess
4 |
5 | class BraveBrowser(BasePlugin):
6 | main_query = 'brave'
7 | description = 'Brave web browser'
8 | queries = ['brave', 'brave-browser']
9 |
10 | @classmethod
11 | def run(cls, query):
12 | if not opi.ask_yes_or_no('Do you want to install Brave from Brave repository?'):
13 | return
14 |
15 | opi.add_repo(
16 | filename = 'brave-browser',
17 | name = 'Brave Browser',
18 | url = 'https://brave-browser-rpm-release.s3.brave.com/x86_64/',
19 | gpgkey = 'https://brave-browser-rpm-release.s3.brave.com/brave-core.asc'
20 | )
21 |
22 | # prevent post install script from messing with our repos
23 | subprocess.call(['sudo', 'rm', '-f', '/etc/default/brave-browser'])
24 | subprocess.call(['sudo', 'touch', '/etc/default/brave-browser'])
25 |
26 | opi.install_packages(['brave-browser'])
27 | opi.ask_keep_repo('brave-browser')
28 |
--------------------------------------------------------------------------------
/opi/plugins/chrome.py:
--------------------------------------------------------------------------------
1 | import opi
2 | from opi.plugins import BasePlugin
3 | import subprocess
4 |
5 | class GoogleChrome(BasePlugin):
6 | main_query = 'chrome'
7 | description = 'Google Chrome web browser'
8 | queries = ['chrome', 'google-chrome']
9 |
10 | @classmethod
11 | def run(cls, query):
12 | if not opi.ask_yes_or_no('Do you want to install Chrome from Google repository?'):
13 | return
14 |
15 | print('Which version do you want to install?')
16 | option = opi.ask_for_option(options=[
17 | 'google-chrome-stable',
18 | 'google-chrome-beta',
19 | 'google-chrome-unstable',
20 | 'google-chrome-canary',
21 | ])
22 | opi.add_repo(
23 | filename = 'google-chrome',
24 | name = 'google-chrome',
25 | url = 'http://dl.google.com/linux/chrome/rpm/stable/x86_64',
26 | gpgkey = 'https://dl.google.com/linux/linux_signing_key.pub'
27 | )
28 |
29 | # prevent post install script from messing with our repos
30 | defaults_file = option.replace('-stable', '')
31 | subprocess.call(['sudo', 'rm', '-f', f'/etc/default/{defaults_file}'])
32 | subprocess.call(['sudo', 'touch', f'/etc/default/{defaults_file}'])
33 |
34 | opi.install_packages([option])
35 | opi.ask_keep_repo('google-chrome')
36 |
--------------------------------------------------------------------------------
/opi/plugins/collabora.py:
--------------------------------------------------------------------------------
1 | import opi
2 | from opi.plugins import BasePlugin
3 |
4 | class collabora(BasePlugin):
5 | main_query = 'collabora'
6 | description = 'Collabora desktop office'
7 | queries = ['collabora', 'collaboraoffice', 'collaboraoffice-desktop']
8 |
9 | @classmethod
10 | def run(cls, query):
11 | if not opi.ask_yes_or_no('Do you want to install collaboraoffice-desktop from collaboraoffice repository?'):
12 | return
13 |
14 | opi.add_repo(
15 | filename = 'collabora-office',
16 | name = 'Collabora Office 24.04 Snapshot',
17 | url = 'https://www.collaboraoffice.com/downloads/Collabora-Office-24-Snapshot/Linux/yum',
18 | gpgkey = 'https://www.collaboraoffice.com/downloads/Collabora-Office-24-Snapshot/Linux/yum/repodata/repomd.xml.key',
19 | gpgcheck = True
20 | )
21 |
22 | opi.install_packages(['collaboraoffice-desktop'])
23 | opi.ask_keep_repo('collabora-office')
24 |
--------------------------------------------------------------------------------
/opi/plugins/dotnet.py:
--------------------------------------------------------------------------------
1 | import opi
2 | from opi.plugins import BasePlugin
3 |
4 | class MSDotnet(BasePlugin):
5 | main_query = 'dotnet'
6 | description = 'Microsoft .NET framework'
7 | queries = ['dotnet-sdk', 'dotnet']
8 |
9 | @classmethod
10 | def run(cls, query):
11 | if not opi.ask_yes_or_no('Do you want to install .NET from Microsoft repository?'):
12 | return
13 |
14 | opi.add_repo(
15 | filename = 'dotnet',
16 | name = 'Microsoft .NET',
17 | url = 'https://packages.microsoft.com/opensuse/15/prod/',
18 | gpgkey = 'https://packages.microsoft.com/keys/microsoft.asc'
19 | )
20 |
21 | opi.install_packages(['dotnet-sdk-9.0'])
22 | opi.ask_keep_repo('dotnet')
23 |
--------------------------------------------------------------------------------
/opi/plugins/freeoffice.py:
--------------------------------------------------------------------------------
1 | import opi
2 | from opi.plugins import BasePlugin
3 |
4 | class SoftMakerFreeOffice(BasePlugin):
5 | main_query = 'freeoffice'
6 | description = 'Office suite from SoftMaker (See OSS alternative libreoffice)'
7 | queries = ['freeoffice']
8 |
9 | @classmethod
10 | def run(cls, query):
11 | if not opi.ask_yes_or_no('Do you want to install FreeOffice from SoftMaker repository?'):
12 | return
13 |
14 | opi.add_repo(
15 | filename = 'SoftMaker',
16 | name = 'SoftMaker',
17 | url = 'https://shop.softmaker.com/repo/rpm',
18 | gpgkey = 'https://shop.softmaker.com/repo/linux-repo-public.key'
19 | )
20 |
21 | opi.install_packages(['softmaker-freeoffice-2024'])
22 | opi.ask_keep_repo('SoftMaker')
23 |
--------------------------------------------------------------------------------
/opi/plugins/jami.py:
--------------------------------------------------------------------------------
1 | import opi
2 | from opi.plugins import BasePlugin
3 |
4 | class Jami(BasePlugin):
5 | main_query = 'jami'
6 | description = 'Jami p2p messenger'
7 | queries = [main_query, 'jami-qt', 'jami-gnome', 'jami-daemon']
8 |
9 | @classmethod
10 | def run(cls, query):
11 | if not opi.ask_yes_or_no('Do you want to install jami from jami repository?'):
12 | return
13 |
14 | print('Which version do you want to install?')
15 | option = opi.ask_for_option(options=[
16 | 'jami',
17 | 'jami-qt',
18 | 'jami-gnome',
19 | 'jami-daemon',
20 | ])
21 |
22 | print('You have chosen', option)
23 |
24 | if opi.get_distribution().startswith('openSUSE:Leap'):
25 | repourl = f'https://dl.jami.net/nightly/opensuse-leap_{opi.get_version()}/'
26 | else:
27 | repourl = 'https://dl.jami.net/nightly/opensuse-tumbleweed/'
28 |
29 | opi.add_repo(
30 | filename = 'jami',
31 | name = 'jami',
32 | url = repourl,
33 | gpgkey = 'https://dl.jami.net/jami.pub.key',
34 | gpgcheck = False
35 | )
36 |
37 | opi.install_packages([option])
38 | opi.ask_keep_repo('jami')
39 |
--------------------------------------------------------------------------------
/opi/plugins/libation.py:
--------------------------------------------------------------------------------
1 | import opi
2 | from opi.plugins import BasePlugin
3 | from opi import github
4 |
5 | class Libation(BasePlugin):
6 | main_query = 'libation'
7 | description = 'Tool for managing audible audiobooks'
8 | queries = [main_query, 'Libation']
9 |
10 | @classmethod
11 | def run(cls, query):
12 | arch = opi.get_cpu_arch().replace('aarch64', 'arm64').replace('x86_64', 'amd64')
13 | github.install_rpm_release('rmcrackan', 'Libation',
14 | filters=[lambda a: a['name'].endswith(f'{arch}.rpm')],
15 | allow_unsigned=True # no key available
16 | )
17 |
--------------------------------------------------------------------------------
/opi/plugins/librewolf.py:
--------------------------------------------------------------------------------
1 | import opi
2 | from opi.plugins import BasePlugin
3 |
4 | class librewolf(BasePlugin):
5 | main_query = 'librewolf'
6 | description = 'Custom version of Firefox, focused on privacy, security and freedom'
7 | queries = ['librewolf', 'Librewolf', 'LibreWolf']
8 |
9 | @classmethod
10 | def run(cls, query):
11 | if not opi.ask_yes_or_no('Do you want to install librewolf from librewolf repository?'):
12 | return
13 |
14 | opi.add_repo(
15 | filename = 'librewolf',
16 | name = 'librewolf',
17 | url = 'https://rpm.librewolf.net',
18 | gpgkey = 'https://rpm.librewolf.net/pubkey.gpg'
19 | )
20 |
21 | opi.install_packages(['librewolf'])
22 | opi.ask_keep_repo('librewolf')
23 |
--------------------------------------------------------------------------------
/opi/plugins/maptool.py:
--------------------------------------------------------------------------------
1 | import opi
2 | from opi.plugins import BasePlugin
3 | from opi import github
4 |
5 | class MapTool(BasePlugin):
6 | main_query = 'maptool'
7 | description = 'Virtual Tabletop for playing roleplaying games'
8 | queries = ['maptool', 'MapTool']
9 |
10 | @classmethod
11 | def run(cls, query):
12 | github.install_rpm_release('RPTools', 'maptool', allow_unsigned=True) # no key available
13 |
--------------------------------------------------------------------------------
/opi/plugins/megasync.py:
--------------------------------------------------------------------------------
1 | import opi
2 |
3 | from opi.plugins import BasePlugin
4 | from shutil import which
5 |
6 | class MEGAsync(BasePlugin):
7 | main_query = 'megasync'
8 | description = 'Mega Desktop App'
9 | queries = ['megasync', 'megasyncapp']
10 |
11 | @classmethod
12 | def run(cls, query):
13 | if not opi.ask_yes_or_no('Do you want to install MEGAsync from MEGAsync repository?'):
14 | return
15 |
16 | opi.add_repo(
17 | filename = 'megasync',
18 | name = 'MEGAsync',
19 | url = 'https://mega.nz/linux/repo/openSUSE_Tumbleweed/',
20 | gpgkey = 'https://mega.nz/linux/repo/openSUSE_Tumbleweed/repodata/repomd.xml.key'
21 | )
22 |
23 | packages = ['megasync']
24 |
25 | if which('nautilus'):
26 | packages.append('nautilus-megasync')
27 |
28 | if which('nemo'):
29 | packages.append('nemo-megasync')
30 |
31 | if which('thunar'):
32 | packages.append('thunar-megasync')
33 |
34 | if which('dolphin'):
35 | packages.append('dolphin-megasync')
36 |
37 | opi.install_packages(packages)
38 |
39 | opi.ask_keep_repo('megasync')
40 |
--------------------------------------------------------------------------------
/opi/plugins/ms_edge.py:
--------------------------------------------------------------------------------
1 | import opi
2 | import subprocess
3 |
4 | from opi.plugins import BasePlugin
5 |
6 | class MSEdge(BasePlugin):
7 | main_query = 'msedge'
8 | description = 'Microsoft Edge web browser'
9 | queries = ['microsoft-edge', 'msedge', 'edge']
10 |
11 | @classmethod
12 | def run(cls, query):
13 | if not opi.ask_yes_or_no('Do you want to install Microsoft Edge from Microsoft repository?'):
14 | return
15 |
16 | print('Which version do you want to install?')
17 | option = opi.ask_for_option(options=[
18 | 'microsoft-edge-stable',
19 | 'microsoft-edge-beta',
20 | 'microsoft-edge-dev',
21 | ])
22 |
23 | opi.add_repo(
24 | filename = 'microsoft-edge',
25 | name = 'Microsoft Edge',
26 | url = 'https://packages.microsoft.com/yumrepos/edge',
27 | gpgkey = 'https://packages.microsoft.com/keys/microsoft.asc'
28 | )
29 |
30 | # prevent post install script from messing with our repos
31 | defaults_file = option.replace('-stable', '')
32 | subprocess.call(['sudo', 'rm', '-f', f'/etc/default/{defaults_file}'])
33 | subprocess.call(['sudo', 'touch', f'/etc/default/{defaults_file}'])
34 |
35 | opi.install_packages([option])
36 | opi.ask_keep_repo('microsoft-edge')
37 |
--------------------------------------------------------------------------------
/opi/plugins/mullvad-browser.py:
--------------------------------------------------------------------------------
1 | import opi
2 | from opi.plugins import BasePlugin
3 | import subprocess
4 |
5 | class MullvadBrowser(BasePlugin):
6 | main_query = 'mullvad-browser'
7 | description = 'Mullvad web browser'
8 | queries = ['mullvad', 'mullvad-browser']
9 |
10 | @classmethod
11 | def run(cls, query):
12 | if not opi.ask_yes_or_no('Do you want to install mullvad-browser from Mullvad repository?'):
13 | return
14 |
15 | opi.add_repo(
16 | filename = 'mullvad',
17 | name = 'Mullvad VPN',
18 | url = 'https://repository.mullvad.net/rpm/stable/$basearch/',
19 | gpgkey = 'https://repository.mullvad.net/rpm/mullvad-keyring.asc',
20 | gpgcheck = 1
21 | )
22 |
23 | opi.install_packages(['mullvad-browser'])
24 | opi.ask_keep_repo('mullvad')
25 |
--------------------------------------------------------------------------------
/opi/plugins/ocenaudio.py:
--------------------------------------------------------------------------------
1 | import opi
2 | from opi.plugins import BasePlugin
3 |
4 | class Ocenaudio(BasePlugin):
5 | main_query = 'ocenaudio'
6 | description = 'Audio Editor'
7 | queries = [main_query]
8 |
9 | @classmethod
10 | def run(cls, query):
11 | if not opi.ask_yes_or_no('Do you want to install ocenaudio from ocenaudio.com?'):
12 | return
13 |
14 | opi.install_packages(['https://www.ocenaudio.com/downloads/index.php/ocenaudio_opensuse.rpm'], allow_unsigned=True) # rpm is unsigned
15 |
--------------------------------------------------------------------------------
/opi/plugins/orca_slicer.py:
--------------------------------------------------------------------------------
1 | import os
2 | import opi
3 | from opi.plugins import BasePlugin
4 | from opi import github
5 | from opi import rpmbuild
6 | from opi import http
7 |
8 | class OrcaSlicer(BasePlugin):
9 | main_query = 'orcaslicer'
10 | description = 'Slicer and controller for Bambu and other 3D printers'
11 | queries = [main_query, 'orca-slicer', 'OrcaSlicer']
12 |
13 | @classmethod
14 | def run(cls, query):
15 | org = 'SoftFever'
16 | repo = 'OrcaSlicer'
17 | latest_release = github.get_latest_release(org, repo)
18 | if not latest_release:
19 | print(f'No release found for {org}/{repo}')
20 | return
21 | version = latest_release['tag_name'].lstrip('v').replace('-', '_')
22 | if not opi.ask_yes_or_no(f"Do you want to install {repo} release {version} from {org} github repo?"):
23 | return
24 | asset = github.get_release_asset(latest_release, filters=[lambda a: a['name'].endswith('.AppImage')])
25 | if not asset:
26 | print(f"No asset found for {org}/{repo} release {version}")
27 | return
28 | url = asset['url']
29 |
30 | binary_path = 'usr/bin/OrcaSlicer'
31 | icon_path = 'usr/share/pixmaps/OrcaSlicer.svg'
32 |
33 | rpm = rpmbuild.RPMBuild('OrcaSlicer', version, cls.description, "x86_64", files=[
34 | f"/{binary_path}",
35 | f"/{icon_path}"
36 | ])
37 |
38 | binary_abspath = os.path.join(rpm.buildroot, binary_path)
39 | http.download_file(url, binary_abspath)
40 | os.chmod(binary_abspath, 0o755)
41 |
42 | icon_abspath = os.path.join(rpm.buildroot, icon_path)
43 | icon_url = "https://raw.githubusercontent.com/SoftFever/OrcaSlicer/2d849f/resources/images/OrcaSlicer.svg"
44 | http.download_file(icon_url, icon_abspath)
45 |
46 | rpm.add_desktop_file(cmd="OrcaSlicer", icon=f"/{icon_path}")
47 |
48 | rpm.build()
49 |
50 | opi.install_packages([rpm.rpmfile_path], allow_unsigned=True)
51 |
--------------------------------------------------------------------------------
/opi/plugins/packman.py:
--------------------------------------------------------------------------------
1 | import opi
2 | from opi.plugins import BasePlugin
3 |
4 | class PackmanCodecsPlugin(BasePlugin):
5 | main_query = 'codecs'
6 | description = 'Media Codecs from Packman and official repo'
7 | queries = ['packman', 'codecs']
8 |
9 | @classmethod
10 | def run(cls, query):
11 | # Install Packman Codecs
12 | if not opi.ask_yes_or_no('Do you want to install codecs from Packman repository?'):
13 | return
14 |
15 | opi.add_packman_repo(dup=True)
16 | packman_packages = [
17 | 'ffmpeg',
18 | 'libavcodec-full',
19 | 'vlc-codecs',
20 | 'gstreamer-plugins-bad-codecs',
21 | 'gstreamer-plugins-ugly-codecs',
22 | 'gstreamer-plugins-libav',
23 | 'libfdk-aac2',
24 | ]
25 | if opi.get_version() not in ('15.4', '15.5'):
26 | packman_packages.append('pipewire-aptx')
27 | packman_packages.append('ffmpeg>=5')
28 | opi.install_packman_packages(packman_packages)
29 |
30 | opi.install_packages([
31 | 'gstreamer-plugins-good',
32 | 'gstreamer-plugins-good-extra',
33 | 'gstreamer-plugins-bad',
34 | 'gstreamer-plugins-ugly',
35 | 'dav1d',
36 | ])
37 |
38 | if not opi.ask_yes_or_no('Do you want to install openh264 codecs from openSUSE openh264 repository?'):
39 | return
40 | opi.add_openh264_repo(dup=True)
41 |
42 | openh264_packages = [
43 | 'mozilla-openh264',
44 | ]
45 | # install something like gstreamer-1.20-plugin-openh264 without actually specifying any version number
46 | gstreamer_plugin_openh264_pkg = 'libgstopenh264.so()'
47 | if not (opi.get_cpu_arch() == 'i586' or opi.get_cpu_arch().startswith('armv7')):
48 | gstreamer_plugin_openh264_pkg += '(64bit)'
49 | openh264_packages.append(gstreamer_plugin_openh264_pkg)
50 | opi.install_packages(openh264_packages)
51 |
--------------------------------------------------------------------------------
/opi/plugins/plex.py:
--------------------------------------------------------------------------------
1 | import opi
2 | from opi.plugins import BasePlugin
3 |
4 | class PlexMediaServer(BasePlugin):
5 | main_query = 'plex'
6 | description = 'Plex Media Server (See OSS alternative jellyfin)'
7 | queries = ['plex', 'plexmediaserver']
8 |
9 | @classmethod
10 | def run(cls, query):
11 | if not opi.ask_yes_or_no('Do you want to install plexmediaserver from Plex repository?'):
12 | return
13 |
14 | opi.add_repo(
15 | filename = 'PlexRepo',
16 | name = 'PlexRepo',
17 | url = 'https://downloads.plex.tv/repo/rpm/$basearch/',
18 | gpgkey = 'https://downloads.plex.tv/plex-keys/PlexSign.key'
19 | )
20 |
21 | opi.install_packages(['plexmediaserver'])
22 | opi.ask_keep_repo('PlexRepo')
23 |
--------------------------------------------------------------------------------
/opi/plugins/resilio-sync.py:
--------------------------------------------------------------------------------
1 | import opi
2 | from opi.plugins import BasePlugin
3 |
4 | class ResilioSync(BasePlugin):
5 | main_query = 'resilio-sync'
6 | description = 'Decentralized file sync between devices using bittorrent protocol (See OSS alternative syncthing)'
7 | queries = ['resilio-sync', 'resilio', 'rslsync']
8 |
9 | @classmethod
10 | def run(cls, query):
11 | if not opi.ask_yes_or_no('Do you want to install resilio-sync from resilio-sync repository?'):
12 | return
13 |
14 | opi.add_repo(
15 | filename = 'resilio-sync',
16 | name = 'resilio-sync',
17 | url = 'https://linux-packages.resilio.com/resilio-sync/rpm/$basearch',
18 | gpgkey = 'https://linux-packages.resilio.com/resilio-sync/key.asc',
19 | gpgcheck = False
20 | )
21 |
22 | opi.install_packages(['resilio-sync'])
23 | opi.ask_keep_repo('resilio-sync')
24 |
--------------------------------------------------------------------------------
/opi/plugins/rustdesk.py:
--------------------------------------------------------------------------------
1 | import opi
2 | from opi.plugins import BasePlugin
3 | from opi import github
4 |
5 | class RustDesk(BasePlugin):
6 | main_query = 'rustdesk'
7 | description = 'Open Source remote desktop application'
8 | queries = ['rustdesk', 'RustDesk']
9 |
10 | @classmethod
11 | def run(cls, query):
12 | arch = opi.get_cpu_arch()
13 | github.install_rpm_release('rustdesk', 'rustdesk',
14 | filters=[lambda a: a['name'].endswith(f'{arch}-suse.rpm')],
15 | allow_unsigned=True # no key available
16 | )
17 |
--------------------------------------------------------------------------------
/opi/plugins/skype.py:
--------------------------------------------------------------------------------
1 | import opi
2 | from opi.plugins import BasePlugin
3 |
4 | class Skype(BasePlugin):
5 | main_query = 'skype'
6 | description = 'Microsoft Skype'
7 | queries = ['skype']
8 |
9 | @classmethod
10 | def run(cls, query):
11 | if not opi.ask_yes_or_no('Do you want to install Skype from Microsoft repository?'):
12 | return
13 |
14 | opi.add_repo(
15 | filename = 'skype-stable',
16 | name = 'Microsoft Skype',
17 | url = 'https://repo.skype.com/rpm/stable/',
18 | gpgkey = 'https://repo.skype.com/data/SKYPE-GPG-KEY'
19 | )
20 |
21 | opi.install_packages(['skypeforlinux'])
22 | opi.ask_keep_repo('skype-stable')
23 |
--------------------------------------------------------------------------------
/opi/plugins/slack.py:
--------------------------------------------------------------------------------
1 | import opi
2 | from opi.plugins import BasePlugin
3 | import subprocess
4 |
5 | class Slack(BasePlugin):
6 | main_query = 'slack'
7 | description = 'Slack messenger'
8 | queries = ['slack']
9 |
10 | @classmethod
11 | def run(cls, query):
12 | if not opi.ask_yes_or_no('Do you want to install slack from the slack repository?'):
13 | return
14 |
15 | opi.add_repo(
16 | filename = 'slack',
17 | name = 'slack',
18 | url = 'https://packagecloud.io/slacktechnologies/slack/fedora/21/$basearch',
19 | gpgkey = 'https://packagecloud.io/slacktechnologies/slack/gpgkey'
20 | )
21 |
22 | # tell slack cron not to mess with our repos
23 | subprocess.call(['sudo', 'rm', '-f', '/etc/default/slack'])
24 | subprocess.call(['sudo', 'touch', '/etc/default/slack'])
25 |
26 | opi.install_packages(['slack'])
27 | opi.ask_keep_repo('slack')
28 |
--------------------------------------------------------------------------------
/opi/plugins/spotify.py:
--------------------------------------------------------------------------------
1 | import os
2 | import opi
3 | import shutil
4 | from opi.plugins import BasePlugin
5 | from opi import rpmbuild
6 | from opi import snap
7 | from opi import http
8 |
9 | class Spotify(BasePlugin):
10 | main_query = 'spotify'
11 | description = 'Listen to music for a monthly fee'
12 | queries = [main_query]
13 |
14 | @classmethod
15 | def run(cls, query):
16 | s = snap.get_snap('spotify')
17 | if not opi.ask_yes_or_no(f"Do you want to install spotify release {s['version']} converted to RPM from snapcraft repo?"):
18 | return
19 |
20 | binary_path = 'usr/bin/spotify'
21 | data_path = 'usr/share/spotify'
22 |
23 | rpm = rpmbuild.RPMBuild('spotify', s['version'], cls.description, "x86_64",
24 | conflicts = ["spotify-client"],
25 | requires = [
26 | "libasound2",
27 | "libatk-bridge-2_0-0",
28 | "libatomic1",
29 | "libcurl4",
30 | "libgbm1",
31 | "libglib-2_0-0",
32 | "libgtk-3-0",
33 | "mozilla-nss",
34 | "libopenssl1_1",
35 | "libxshmfence1",
36 | "libXss1",
37 | "libXtst6",
38 | "xdg-utils",
39 | "libayatana-appindicator3-1",
40 | ],
41 | autoreq = False,
42 | recommends = [
43 | "libavcodec.so",
44 | "libavformat.so",
45 | ],
46 | suggests = ["libnotify4"],
47 | files = [
48 | f"/{binary_path}",
49 | f"/{data_path}"
50 | ]
51 | )
52 |
53 | snap_path = os.path.join(rpm.tmpdir.name, 'spotify.snap')
54 | snap_path_extracted = os.path.join(rpm.tmpdir.name, 'spotify')
55 | http.download_file(s['url'], snap_path)
56 | snap.extract_snap(snap_path, snap_path_extracted)
57 |
58 | binary_abspath = os.path.join(rpm.buildroot, binary_path)
59 | rpmbuild.copy(os.path.join(snap_path_extracted, binary_path), binary_abspath)
60 |
61 | data_abspath = os.path.join(rpm.buildroot, data_path)
62 | rpmbuild.copy(os.path.join(snap_path_extracted, data_path), data_abspath)
63 |
64 | rpm.add_desktop_file(cmd="spotify %U", icon="/usr/share/spotify/icons/spotify_icon.ico",
65 | Categories="Audio;Music;Player;AudioVideo;",
66 | MimeType="x-scheme-handler/spotify"
67 | )
68 |
69 | rpm.build()
70 | opi.install_packages([rpm.rpmfile_path], allow_unsigned=True)
71 |
--------------------------------------------------------------------------------
/opi/plugins/sublime.py:
--------------------------------------------------------------------------------
1 | import opi
2 | from opi.plugins import BasePlugin
3 |
4 | class SublimeText(BasePlugin):
5 | main_query = 'sublime'
6 | description = 'Editor for code, markup and prose'
7 | queries = ['sublime', 'sublime-text', 'sublimetext']
8 |
9 | @classmethod
10 | def run(cls, query):
11 | if not opi.ask_yes_or_no('Do you want to install sublime-text from sublime-text repository?'):
12 | return
13 |
14 | opi.add_repo(
15 | filename = 'sublime-text',
16 | name = 'sublime-text',
17 | url = 'https://download.sublimetext.com/rpm/stable/x86_64',
18 | gpgkey = 'https://download.sublimetext.com/sublimehq-rpm-pub.gpg'
19 | )
20 |
21 | opi.install_packages(['sublime-text'])
22 | opi.ask_keep_repo('sublime-text')
23 |
--------------------------------------------------------------------------------
/opi/plugins/teams-for-linux.py:
--------------------------------------------------------------------------------
1 | import opi
2 | from opi.plugins import BasePlugin
3 |
4 | class TeamsForLinux(BasePlugin):
5 | main_query = 'teams-for-linux'
6 | description = 'Unofficial Microsoft Teams for Linux client'
7 | queries = ['teams-for-linux','teams']
8 |
9 | @classmethod
10 | def run(cls, query):
11 | if not opi.ask_yes_or_no('Do you want to install teams-for-linux from teamsforlinux.de repository?'):
12 | return
13 |
14 | opi.add_repo(
15 | filename = 'teams-for-linux',
16 | name = 'Unofficial Teams for Linux',
17 | url = 'https://repo.teamsforlinux.de/rpm/',
18 | gpgkey = 'https://repo.teamsforlinux.de/teams-for-linux.asc'
19 | )
20 |
21 | opi.install_packages(['teams-for-linux'])
22 | opi.ask_keep_repo('teams-for-linux')
23 |
--------------------------------------------------------------------------------
/opi/plugins/teamviewer.py:
--------------------------------------------------------------------------------
1 | import opi
2 | import os
3 | from opi.plugins import BasePlugin
4 | import subprocess
5 |
6 | class Teamviewer(BasePlugin):
7 | main_query = 'teamviewer'
8 | description = 'TeamViewer remote access'
9 | queries = ['teamviewer']
10 |
11 | @classmethod
12 | def run(cls, query):
13 | if not opi.ask_yes_or_no('Do you want to install Teamviewer from Teamviewer repository?'):
14 | return
15 |
16 | opi.add_repo(
17 | filename = 'teamviewer',
18 | name = 'Teamviewer',
19 | url = 'https://linux.teamviewer.com/yum/stable/main/binary-$basearch/',
20 | gpgkey = 'https://linux.teamviewer.com/pubkey/currentkey.asc'
21 | )
22 |
23 | opi.install_packages(['teamviewer-suse'])
24 | # Teamviewer packages its own repo file so our repo file got saved as rpmorig
25 | subprocess.call(['sudo', 'rm', '-f', os.path.join(opi.REPO_DIR, 'teamviewer.repo.rpmorig')])
26 | opi.ask_keep_repo('teamviewer')
27 |
--------------------------------------------------------------------------------
/opi/plugins/vagrant.py:
--------------------------------------------------------------------------------
1 | import opi
2 | from opi.plugins import BasePlugin
3 |
4 | class Vagrant(BasePlugin):
5 | main_query = 'vagrant'
6 | description = 'Tool for building and distributing development environments'
7 | queries = [main_query]
8 |
9 | @classmethod
10 | def run(cls, query):
11 | if not opi.ask_yes_or_no('Do you want to install Vagrant from Hashicorp repository?'):
12 | return
13 |
14 | opi.add_repo(
15 | filename = 'hashicorp',
16 | name = 'Hashicorp',
17 | url = 'https://rpm.releases.hashicorp.com/AmazonLinux/latest/$basearch/stable',
18 | gpgkey = 'https://rpm.releases.hashicorp.com/gpg'
19 | )
20 |
21 | opi.install_packages(['vagrant'])
22 | opi.ask_keep_repo('hashicorp')
23 |
--------------------------------------------------------------------------------
/opi/plugins/vivaldi.py:
--------------------------------------------------------------------------------
1 | import opi
2 | from opi.plugins import BasePlugin
3 |
4 | class Vivaldi(BasePlugin):
5 | main_query = 'vivaldi'
6 | description = 'Vivaldi web browser'
7 | queries = ['vivaldi']
8 |
9 | @classmethod
10 | def run(cls, query):
11 | if not opi.ask_yes_or_no('Do you want to install Vivaldi from Vivaldi repository?'):
12 | return
13 |
14 | option = opi.ask_for_option(options=[
15 | 'vivaldi-stable',
16 | 'vivaldi-snapshot',
17 | ])
18 |
19 | opi.add_repo(
20 | filename = 'vivaldi',
21 | name = 'vivaldi',
22 | url = 'https://repo.vivaldi.com/archive/rpm/$basearch',
23 | gpgkey = 'https://repo.vivaldi.com/archive/linux_signing_key.pub'
24 | )
25 |
26 | opi.install_packages([option])
27 | opi.ask_keep_repo('vivaldi')
28 |
--------------------------------------------------------------------------------
/opi/plugins/vs_code.py:
--------------------------------------------------------------------------------
1 | import opi
2 | from opi.plugins import BasePlugin
3 |
4 | class VSCode(BasePlugin):
5 | main_query = 'vscode'
6 | description = 'Microsoft Visual Studio Code'
7 | queries = ['visualstudiocode', 'vscode', 'vsc']
8 |
9 | @classmethod
10 | def run(cls, query):
11 | if not opi.ask_yes_or_no('Do you want to install VS Code from Microsoft repository?'):
12 | return
13 |
14 | option = opi.ask_for_option(options=[
15 | 'code',
16 | 'code-exploration',
17 | 'code-insiders',
18 | ])
19 |
20 | opi.add_repo(
21 | filename = 'vscode',
22 | name = 'Visual Studio Code',
23 | url = 'https://packages.microsoft.com/yumrepos/vscode',
24 | gpgkey = 'https://packages.microsoft.com/keys/microsoft.asc'
25 | )
26 |
27 | opi.install_packages([option])
28 | opi.ask_keep_repo('vscode')
29 |
--------------------------------------------------------------------------------
/opi/plugins/vs_codium.py:
--------------------------------------------------------------------------------
1 | import opi
2 | from opi.plugins import BasePlugin
3 |
4 | class VSCodium(BasePlugin):
5 | main_query = 'vscodium'
6 | description = 'Visual Studio Codium'
7 | queries = ['visualstudiocodium', 'vscodium', 'codium']
8 |
9 | @classmethod
10 | def run(cls, query):
11 | if not opi.ask_yes_or_no('Do you want to install VS Codium from paulcarroty_vscodium repository?'):
12 | return
13 |
14 | opi.add_repo(
15 | filename = 'vscodium',
16 | name = 'Visual Studio Codium',
17 | url = 'https://paulcarroty.gitlab.io/vscodium-deb-rpm-repo/rpms',
18 | gpgkey = 'https://gitlab.com/paulcarroty/vscodium-deb-rpm-repo/raw/master/pub.gpg'
19 | )
20 |
21 | opi.install_packages(['codium'])
22 | opi.ask_keep_repo('vscodium')
23 |
--------------------------------------------------------------------------------
/opi/plugins/yandex-browser.py:
--------------------------------------------------------------------------------
1 | import opi
2 | from opi.plugins import BasePlugin
3 |
4 | class YandexBrowser(BasePlugin):
5 | main_query = 'yandex-browser'
6 | description = 'Yandex web browser'
7 | queries = ['yandex-browser-stable', 'yandex-browser-beta', 'yandex-browser']
8 |
9 | @classmethod
10 | def run(cls, query):
11 | if not opi.ask_yes_or_no('Do you want to install yandex-browser from yandex-browser repository?'):
12 | return
13 |
14 | print('Which version do you want to install?')
15 | option = opi.ask_for_option(options=[
16 | 'yandex-browser-stable',
17 | 'yandex-browser-beta',
18 | ])
19 |
20 | release = option.split('-')[-1]
21 | print('You have chosen', release)
22 |
23 | opi.add_repo(
24 | filename = option,
25 | name = option,
26 | url = f'https://repo.yandex.ru/yandex-browser/rpm/{release}/$basearch/',
27 | gpgkey = 'https://repo.yandex.ru/yandex-browser/YANDEX-BROWSER-KEY.GPG',
28 | gpgcheck = False
29 | )
30 |
31 | opi.install_packages([option])
32 | opi.ask_keep_repo(option)
33 |
--------------------------------------------------------------------------------
/opi/plugins/yandex-disk.py:
--------------------------------------------------------------------------------
1 | import opi
2 | from opi.plugins import BasePlugin
3 |
4 | class YandexDisk(BasePlugin):
5 | main_query = 'yandex-disk'
6 | description = 'Yandex.Disk cloud storage client'
7 | queries = ['yandex-disk']
8 |
9 | @classmethod
10 | def run(cls, query):
11 | if not opi.ask_yes_or_no('Do you want to install yandex-disk from yandex-disk repository?'):
12 | return
13 |
14 | opi.add_repo(
15 | filename = 'yandex-disk',
16 | name = 'yandex-disk',
17 | url = 'https://repo.yandex.ru/yandex-disk/rpm/stable/$basearch/',
18 | gpgkey = 'https://repo.yandex.ru/yandex-disk/YANDEX-DISK-KEY.GPG',
19 | gpgcheck = False
20 | )
21 |
22 | opi.install_packages(['yandex-disk'])
23 | opi.ask_keep_repo('yandex-disk')
24 |
--------------------------------------------------------------------------------
/opi/plugins/zellij.py:
--------------------------------------------------------------------------------
1 | import os
2 | import subprocess
3 | import opi
4 | from opi.plugins import BasePlugin
5 | from opi import github
6 | from opi import rpmbuild
7 | from opi import http
8 |
9 | # VERSION is only set on leap based distros - not tumbleweed, where this package is available via default repos
10 | if opi.get_version():
11 | class Zellij(BasePlugin):
12 | main_query = 'zellij'
13 | description = 'A terminal workspace with batteries included'
14 | queries = [main_query]
15 |
16 | @classmethod
17 | def run(cls, query):
18 | org = "zellij-org"
19 | repo = "zellij"
20 | latest_release = github.get_latest_release(org, repo)
21 | if not latest_release:
22 | print(f'No release found for {org}/{repo}')
23 | return
24 | version = latest_release['tag_name'].lstrip('v')
25 | if not opi.ask_yes_or_no(f"Do you want to install {repo} release {version} from {org} github repo?"):
26 | return
27 | arch = opi.get_cpu_arch()
28 | asset_name = f'zellij-{arch}-unknown-linux-musl.tar.gz'
29 | asset = github.get_release_asset(latest_release, filters=[lambda e: e['name'] == asset_name])
30 | if not asset:
31 | print(f"No asset found for {org}/{repo} release {version}")
32 | return
33 | url = asset['url']
34 |
35 | binary_path = 'usr/bin/zellij'
36 |
37 | rpm = rpmbuild.RPMBuild('zellij', version, cls.description, arch, files=[
38 | f"/{binary_path}",
39 | ])
40 |
41 | bindir_abspath = os.path.join(rpm.buildroot, os.path.dirname(binary_path))
42 | binary_abspath = os.path.join(rpm.buildroot, binary_path)
43 | tarball_abspath = os.path.join(rpm.tmpdir.name, asset_name)
44 |
45 | http.download_file(url, tarball_abspath)
46 | os.makedirs(bindir_abspath, exist_ok=True)
47 | subprocess.call(['tar', 'xvf', tarball_abspath, '-C', bindir_abspath, 'zellij'])
48 | os.chmod(binary_abspath, 0o755)
49 |
50 | rpm.build()
51 | opi.install_packages([rpm.rpmfile_path], allow_unsigned=True)
52 |
--------------------------------------------------------------------------------
/opi/plugins/zoom.py:
--------------------------------------------------------------------------------
1 | import opi
2 | from opi.plugins import BasePlugin
3 |
4 | class Zoom(BasePlugin):
5 | main_query = 'zoom'
6 | description = 'Zoom Video Conference'
7 | queries = ['zoom']
8 |
9 | @classmethod
10 | def run(cls, query):
11 | if not opi.ask_yes_or_no('Do you want to install Zoom from zoom.us?'):
12 | return
13 |
14 | key_url = 'https://zoom.us/linux/download/pubkey?version=5-12-6'
15 | opi.ask_import_key(key_url)
16 | opi.install_packages(['https://zoom.us/client/latest/zoom_openSUSE_x86_64.rpm'])
17 | opi.ask_keep_key(key_url)
18 |
--------------------------------------------------------------------------------
/opi/rpmbuild.py:
--------------------------------------------------------------------------------
1 | import os
2 | import tempfile
3 | import re
4 | import subprocess
5 | import glob
6 | import shutil
7 | from shutil import which
8 | from opi import install_packages
9 |
10 | def copy(src, dst):
11 | """
12 | Copy src to dst using hardlinks.
13 | dst will be the full final path.
14 | Directories will be created as needed.
15 | """
16 | if os.path.islink(src) or os.path.isfile(src):
17 | os.makedirs(os.path.dirname(dst), exist_ok=True)
18 | if os.path.islink(src):
19 | link_target = os.readlink(src)
20 | os.symlink(link_target, dst)
21 | elif os.path.isfile(src):
22 | shutil.copy2(src, dst)
23 | else:
24 | shutil.copytree(src, dst, copy_function=os.link, symlinks=True, ignore_dangling_symlinks=False)
25 |
26 | def dedent(s):
27 | """ Other than textwrap's implementation this one has no problems with some lines unindented.
28 | It will unconditionally strip any leading whitespaces for each line.
29 | """
30 | return re.sub(r"^\s*", "", s, flags=re.M)
31 |
32 | class RPMBuild:
33 | def __init__(self, name, version, description, buildarch="noarch",
34 | requires=[], recommends=[], provides=[], suggests=[], conflicts=[], autoreq=True,
35 | files=[], dirs=[], config=[]):
36 | self.name = name
37 | self.version = version
38 | self.description = description
39 | self.buildarch = buildarch
40 | self.requires = requires
41 | self.recommends = recommends
42 | self.provides = provides
43 | self.suggests = suggests
44 | self.conflicts = conflicts
45 | self.autoreq = autoreq
46 | self.files = files
47 | self.dirs = dirs
48 | self.config = config
49 |
50 | self.tmpdir = tempfile.TemporaryDirectory()
51 |
52 | self.buildroot = os.path.join(self.tmpdir.name, "buildroot") # buildroot where plugins copy files to
53 | self.spec_path = os.path.join(self.tmpdir.name, "specfile.spec")
54 | self.rpm_out_dir = os.path.join(self.tmpdir.name, "rpms")
55 |
56 | os.mkdir(self.buildroot)
57 | os.mkdir(self.rpm_out_dir)
58 |
59 | if not which('rpmbuild'):
60 | print("Installing requirement: rpm-build")
61 | install_packages(['rpm-build'], no_recommends=True, non_interactive=True)
62 |
63 | def mkspec(self):
64 | nl = "\n"
65 | spec = dedent(f"""
66 | Name: {self.name}
67 | Version: {self.version}
68 | Release: 0
69 | Summary: {self.description}
70 | License: n/a
71 | BuildArch: {self.buildarch}
72 | {nl.join(f"Requires: {r}" for r in self.requires)}
73 | {nl.join(f"Recommends: {r}" for r in self.recommends)}
74 | {nl.join(f"Provides: {r}" for r in self.provides)}
75 | {nl.join(f"Suggests: {r}" for r in self.suggests)}
76 | {nl.join(f"Conflicts: {r}" for r in self.conflicts)}
77 | {"AutoReq: no" if not self.autoreq else ''}
78 |
79 | %description
80 | {self.description}
81 | Built locally using OPI.
82 |
83 | %files
84 | {nl.join(self.files)}
85 | {nl.join(f"%dir {d}" for d in self.dirs)}
86 | {nl.join(f"%config {c}" for c in self.config)}
87 |
88 | %changelog
89 | """)
90 | return spec
91 |
92 | def add_desktop_file(self, cmd, icon, **kwargs):
93 | os.makedirs(os.path.join(self.buildroot, 'usr/share/applications'))
94 | desktop_path = f'usr/share/applications/{self.name}.desktop'
95 | desktop_abspath = os.path.join(self.buildroot, desktop_path)
96 | self.files.append(f"/{desktop_path}")
97 | with open(desktop_abspath, 'w') as f:
98 | nl = "\n"
99 | f.write(dedent(f"""
100 | [Desktop Entry]
101 | Name={self.name}
102 | Comment={self.description}
103 | Exec={cmd}
104 | Icon={icon}
105 | Type=Application
106 | {nl.join(["%s=%s" % (k, v) for k, v in kwargs.items()])}
107 | """))
108 |
109 | def build(self):
110 | print(f"Creating RPM for {self.name}")
111 | with open(self.spec_path, 'w') as f:
112 | spec = self.mkspec()
113 | f.write(spec)
114 | subprocess.check_call([
115 | "rpmbuild", "-bb", "--build-in-place",
116 | "--buildroot", self.buildroot,
117 | "--define", f"_rpmdir {self.rpm_out_dir}",
118 | "specfile.spec"
119 | ], cwd=self.tmpdir.name)
120 | rpmfile = glob.glob(f"{self.rpm_out_dir}/*/*.rpm")[0]
121 | self.rpmfile_path = rpmfile
122 | return rpmfile
123 |
--------------------------------------------------------------------------------
/opi/snap.py:
--------------------------------------------------------------------------------
1 | import subprocess
2 | import requests
3 | from shutil import which
4 | from opi import install_packages
5 |
6 | def http_get_json(url):
7 | r = requests.get(url, headers={'Snap-Device-Series': '16'})
8 | r.raise_for_status()
9 | return r.json()
10 |
11 | def get_snap(snap, channel='stable', arch=None):
12 | channels = http_get_json(f'https://api.snapcraft.io/v2/snaps/info/{snap}')['channel-map']
13 | if arch:
14 | arch.replace('x86_64', 'amd64')
15 | channels = [c for c in channels if c['channel']['architecture'] == arch]
16 | channels = [c for c in channels if c['channel']['name'] == channel]
17 | c = channels[0]
18 | return {"version": c['version'], "url": c['download']['url']}
19 |
20 | def extract_snap(snap, target_dir):
21 | if not which('unsquashfs'):
22 | print("Installing requirement: squashfs")
23 | install_packages(['squashfs'], no_recommends=True, non_interactive=True)
24 | subprocess.check_call(['unsquashfs', '-d', target_dir, snap])
25 |
--------------------------------------------------------------------------------
/opi/state.py:
--------------------------------------------------------------------------------
1 | class GlobalState:
2 | default_state = {
3 | 'arg_non_interactive': False,
4 | 'arg_verbose_mode': False,
5 | }
6 | state = {
7 | }
8 |
9 | def __setattr__(self, key, value):
10 | type(self).state[key] = value
11 |
12 | def __getattr__(self, key):
13 | return type(self).state.get(key, type(self).default_state[key])
14 |
15 | global_state = GlobalState()
16 |
--------------------------------------------------------------------------------
/opi/version.py:
--------------------------------------------------------------------------------
1 | __version__ = '5.8.5'
2 |
--------------------------------------------------------------------------------
/org.openSUSE.opi.appdata.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | org.openSUSE.opi
4 | CC0-1.0
5 | OPI
6 | openSUSE Package Installer
7 |
8 |
9 | Search and install almost all packages available for openSUSE and SLE:
10 |