├── .gitignore
├── LICENSE.md
├── Readme.md
├── download.py
├── example
├── Dockerfile
├── Readme.md
├── example.lpi
├── example.lpr
├── indyExample.ico
├── indyExample.lpi
├── indyExample.lpr
├── indyexamplemainform.lfm
└── indyexamplemainform.pas
├── logger.py
├── lpm
├── opm.py
├── packagemanager.py
└── project.py
/.gitignore:
--------------------------------------------------------------------------------
1 |
2 | # Created by https://www.gitignore.io/api/python,lazarus
3 | # Edit at https://www.gitignore.io/?templates=python,lazarus
4 |
5 | ### Lazarus ###
6 | # Lazarus compiler-generated binaries (safe to delete)
7 | *.exe
8 | *.dll
9 | *.so
10 | *.dylib
11 | *.lrs
12 | *.res
13 | *.compiled
14 | *.dbg
15 | *.ppu
16 | *.o
17 | *.or
18 | *.a
19 |
20 | # Lazarus autogenerated files (duplicated info)
21 | *.rst
22 | *.rsj
23 | *.lrt
24 |
25 | # Lazarus local files (user-specific info)
26 | *.lps
27 |
28 | # Lazarus backups and unit output folders.
29 | # These can be changed by user in Lazarus/project options.
30 | backup/
31 | *.bak
32 | lib/
33 |
34 | # Application bundle for Mac OS
35 | *.app/
36 |
37 | ### Python ###
38 | # Byte-compiled / optimized / DLL files
39 | __pycache__/
40 | *.py[cod]
41 | *$py.class
42 |
43 | # C extensions
44 |
45 | # Distribution / packaging
46 | .Python
47 | build/
48 | develop-eggs/
49 | dist/
50 | downloads/
51 | eggs/
52 | .eggs/
53 | lib64/
54 | parts/
55 | sdist/
56 | var/
57 | wheels/
58 | pip-wheel-metadata/
59 | share/python-wheels/
60 | *.egg-info/
61 | .installed.cfg
62 | *.egg
63 | MANIFEST
64 |
65 | # PyInstaller
66 | # Usually these files are written by a python script from a template
67 | # before PyInstaller builds the exe, so as to inject date/other infos into it.
68 | *.manifest
69 | *.spec
70 |
71 | # Installer logs
72 | pip-log.txt
73 | pip-delete-this-directory.txt
74 |
75 | # Unit test / coverage reports
76 | htmlcov/
77 | .tox/
78 | .nox/
79 | .coverage
80 | .coverage.*
81 | .cache
82 | nosetests.xml
83 | coverage.xml
84 | *.cover
85 | .hypothesis/
86 | .pytest_cache/
87 |
88 | # Translations
89 | *.mo
90 | *.pot
91 |
92 | # Scrapy stuff:
93 | .scrapy
94 |
95 | # Sphinx documentation
96 | docs/_build/
97 |
98 | # PyBuilder
99 | target/
100 |
101 | # pyenv
102 | .python-version
103 |
104 | # pipenv
105 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
106 | # However, in case of collaboration, if having platform-specific dependencies or dependencies
107 | # having no cross-platform support, pipenv may install dependencies that don't work, or not
108 | # install all needed dependencies.
109 | #Pipfile.lock
110 |
111 | # celery beat schedule file
112 | celerybeat-schedule
113 |
114 | # SageMath parsed files
115 | *.sage.py
116 |
117 | # Spyder project settings
118 | .spyderproject
119 | .spyproject
120 |
121 | # Rope project settings
122 | .ropeproject
123 |
124 | # Mr Developer
125 | .mr.developer.cfg
126 | .project
127 | .pydevproject
128 |
129 | # mkdocs documentation
130 | /site
131 |
132 | # mypy
133 | .mypy_cache/
134 | .dmypy.json
135 | dmypy.json
136 |
137 | # Pyre type checker
138 | .pyre/
139 |
140 | # End of https://www.gitignore.io/api/python,lazarus
141 |
142 |
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | ### GNU AFFERO GENERAL PUBLIC LICENSE
2 |
3 | Version 3, 19 November 2007
4 |
5 | Copyright (C) 2007 Free Software Foundation, Inc.
6 |
7 |
8 | Everyone is permitted to copy and distribute verbatim copies of this
9 | license document, but changing it is not allowed.
10 |
11 | ### Preamble
12 |
13 | The GNU Affero General Public License is a free, copyleft license for
14 | software and other kinds of works, specifically designed to ensure
15 | cooperation with the community in the case of network server software.
16 |
17 | The licenses for most software and other practical works are designed
18 | to take away your freedom to share and change the works. By contrast,
19 | our General Public Licenses are intended to guarantee your freedom to
20 | share and change all versions of a program--to make sure it remains
21 | free software for all its users.
22 |
23 | When we speak of free software, we are referring to freedom, not
24 | price. Our General Public Licenses are designed to make sure that you
25 | have the freedom to distribute copies of free software (and charge for
26 | them if you wish), that you receive source code or can get it if you
27 | want it, that you can change the software or use pieces of it in new
28 | free programs, and that you know you can do these things.
29 |
30 | Developers that use our General Public Licenses protect your rights
31 | with two steps: (1) assert copyright on the software, and (2) offer
32 | you this License which gives you legal permission to copy, distribute
33 | and/or modify the software.
34 |
35 | A secondary benefit of defending all users' freedom is that
36 | improvements made in alternate versions of the program, if they
37 | receive widespread use, become available for other developers to
38 | incorporate. Many developers of free software are heartened and
39 | encouraged by the resulting cooperation. However, in the case of
40 | software used on network servers, this result may fail to come about.
41 | The GNU General Public License permits making a modified version and
42 | letting the public access it on a server without ever releasing its
43 | source code to the public.
44 |
45 | The GNU Affero General Public License is designed specifically to
46 | ensure that, in such cases, the modified source code becomes available
47 | to the community. It requires the operator of a network server to
48 | provide the source code of the modified version running there to the
49 | users of that server. Therefore, public use of a modified version, on
50 | a publicly accessible server, gives the public access to the source
51 | code of the modified version.
52 |
53 | An older license, called the Affero General Public License and
54 | published by Affero, was designed to accomplish similar goals. This is
55 | a different license, not a version of the Affero GPL, but Affero has
56 | released a new version of the Affero GPL which permits relicensing
57 | under this license.
58 |
59 | The precise terms and conditions for copying, distribution and
60 | modification follow.
61 |
62 | ### TERMS AND CONDITIONS
63 |
64 | #### 0. Definitions.
65 |
66 | "This License" refers to version 3 of the GNU Affero General Public
67 | License.
68 |
69 | "Copyright" also means copyright-like laws that apply to other kinds
70 | of works, such as semiconductor masks.
71 |
72 | "The Program" refers to any copyrightable work licensed under this
73 | License. Each licensee is addressed as "you". "Licensees" and
74 | "recipients" may be individuals or organizations.
75 |
76 | To "modify" a work means to copy from or adapt all or part of the work
77 | in a fashion requiring copyright permission, other than the making of
78 | an exact copy. The resulting work is called a "modified version" of
79 | the earlier work or a work "based on" the earlier work.
80 |
81 | A "covered work" means either the unmodified Program or a work based
82 | on the Program.
83 |
84 | To "propagate" a work means to do anything with it that, without
85 | permission, would make you directly or secondarily liable for
86 | infringement under applicable copyright law, except executing it on a
87 | computer or modifying a private copy. Propagation includes copying,
88 | distribution (with or without modification), making available to the
89 | public, and in some countries other activities as well.
90 |
91 | To "convey" a work means any kind of propagation that enables other
92 | parties to make or receive copies. Mere interaction with a user
93 | through a computer network, with no transfer of a copy, is not
94 | conveying.
95 |
96 | An interactive user interface displays "Appropriate Legal Notices" to
97 | the extent that it includes a convenient and prominently visible
98 | feature that (1) displays an appropriate copyright notice, and (2)
99 | tells the user that there is no warranty for the work (except to the
100 | extent that warranties are provided), that licensees may convey the
101 | work under this License, and how to view a copy of this License. If
102 | the interface presents a list of user commands or options, such as a
103 | menu, a prominent item in the list meets this criterion.
104 |
105 | #### 1. Source Code.
106 |
107 | The "source code" for a work means the preferred form of the work for
108 | making modifications to it. "Object code" means any non-source form of
109 | a work.
110 |
111 | A "Standard Interface" means an interface that either is an official
112 | standard defined by a recognized standards body, or, in the case of
113 | interfaces specified for a particular programming language, one that
114 | is widely used among developers working in that language.
115 |
116 | The "System Libraries" of an executable work include anything, other
117 | than the work as a whole, that (a) is included in the normal form of
118 | packaging a Major Component, but which is not part of that Major
119 | Component, and (b) serves only to enable use of the work with that
120 | Major Component, or to implement a Standard Interface for which an
121 | implementation is available to the public in source code form. A
122 | "Major Component", in this context, means a major essential component
123 | (kernel, window system, and so on) of the specific operating system
124 | (if any) on which the executable work runs, or a compiler used to
125 | produce the work, or an object code interpreter used to run it.
126 |
127 | The "Corresponding Source" for a work in object code form means all
128 | the source code needed to generate, install, and (for an executable
129 | work) run the object code and to modify the work, including scripts to
130 | control those activities. However, it does not include the work's
131 | System Libraries, or general-purpose tools or generally available free
132 | programs which are used unmodified in performing those activities but
133 | which are not part of the work. For example, Corresponding Source
134 | includes interface definition files associated with source files for
135 | the work, and the source code for shared libraries and dynamically
136 | linked subprograms that the work is specifically designed to require,
137 | such as by intimate data communication or control flow between those
138 | subprograms and other parts of the work.
139 |
140 | The Corresponding Source need not include anything that users can
141 | regenerate automatically from other parts of the Corresponding Source.
142 |
143 | The Corresponding Source for a work in source code form is that same
144 | work.
145 |
146 | #### 2. Basic Permissions.
147 |
148 | All rights granted under this License are granted for the term of
149 | copyright on the Program, and are irrevocable provided the stated
150 | conditions are met. This License explicitly affirms your unlimited
151 | permission to run the unmodified Program. The output from running a
152 | covered work is covered by this License only if the output, given its
153 | content, constitutes a covered work. This License acknowledges your
154 | rights of fair use or other equivalent, as provided by copyright law.
155 |
156 | You may make, run and propagate covered works that you do not convey,
157 | without conditions so long as your license otherwise remains in force.
158 | You may convey covered works to others for the sole purpose of having
159 | them make modifications exclusively for you, or provide you with
160 | facilities for running those works, provided that you comply with the
161 | terms of this License in conveying all material for which you do not
162 | control copyright. Those thus making or running the covered works for
163 | you must do so exclusively on your behalf, under your direction and
164 | control, on terms that prohibit them from making any copies of your
165 | copyrighted material outside their relationship with you.
166 |
167 | Conveying under any other circumstances is permitted solely under the
168 | conditions stated below. Sublicensing is not allowed; section 10 makes
169 | it unnecessary.
170 |
171 | #### 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
172 |
173 | No covered work shall be deemed part of an effective technological
174 | measure under any applicable law fulfilling obligations under article
175 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
176 | similar laws prohibiting or restricting circumvention of such
177 | measures.
178 |
179 | When you convey a covered work, you waive any legal power to forbid
180 | circumvention of technological measures to the extent such
181 | circumvention is effected by exercising rights under this License with
182 | respect to the covered work, and you disclaim any intention to limit
183 | operation or modification of the work as a means of enforcing, against
184 | the work's users, your or third parties' legal rights to forbid
185 | circumvention of technological measures.
186 |
187 | #### 4. Conveying Verbatim Copies.
188 |
189 | You may convey verbatim copies of the Program's source code as you
190 | receive it, in any medium, provided that you conspicuously and
191 | appropriately publish on each copy an appropriate copyright notice;
192 | keep intact all notices stating that this License and any
193 | non-permissive terms added in accord with section 7 apply to the code;
194 | keep intact all notices of the absence of any warranty; and give all
195 | recipients a copy of this License along with the Program.
196 |
197 | You may charge any price or no price for each copy that you convey,
198 | and you may offer support or warranty protection for a fee.
199 |
200 | #### 5. Conveying Modified Source Versions.
201 |
202 | You may convey a work based on the Program, or the modifications to
203 | produce it from the Program, in the form of source code under the
204 | terms of section 4, provided that you also meet all of these
205 | conditions:
206 |
207 | - a) The work must carry prominent notices stating that you modified
208 | it, and giving a relevant date.
209 | - b) The work must carry prominent notices stating that it is
210 | released under this License and any conditions added under
211 | section 7. This requirement modifies the requirement in section 4
212 | to "keep intact all notices".
213 | - c) You must license the entire work, as a whole, under this
214 | License to anyone who comes into possession of a copy. This
215 | License will therefore apply, along with any applicable section 7
216 | additional terms, to the whole of the work, and all its parts,
217 | regardless of how they are packaged. This License gives no
218 | permission to license the work in any other way, but it does not
219 | invalidate such permission if you have separately received it.
220 | - d) If the work has interactive user interfaces, each must display
221 | Appropriate Legal Notices; however, if the Program has interactive
222 | interfaces that do not display Appropriate Legal Notices, your
223 | work need not make them do so.
224 |
225 | A compilation of a covered work with other separate and independent
226 | works, which are not by their nature extensions of the covered work,
227 | and which are not combined with it such as to form a larger program,
228 | in or on a volume of a storage or distribution medium, is called an
229 | "aggregate" if the compilation and its resulting copyright are not
230 | used to limit the access or legal rights of the compilation's users
231 | beyond what the individual works permit. Inclusion of a covered work
232 | in an aggregate does not cause this License to apply to the other
233 | parts of the aggregate.
234 |
235 | #### 6. Conveying Non-Source Forms.
236 |
237 | You may convey a covered work in object code form under the terms of
238 | sections 4 and 5, provided that you also convey the machine-readable
239 | Corresponding Source under the terms of this License, in one of these
240 | ways:
241 |
242 | - a) Convey the object code in, or embodied in, a physical product
243 | (including a physical distribution medium), accompanied by the
244 | Corresponding Source fixed on a durable physical medium
245 | customarily used for software interchange.
246 | - b) Convey the object code in, or embodied in, a physical product
247 | (including a physical distribution medium), accompanied by a
248 | written offer, valid for at least three years and valid for as
249 | long as you offer spare parts or customer support for that product
250 | model, to give anyone who possesses the object code either (1) a
251 | copy of the Corresponding Source for all the software in the
252 | product that is covered by this License, on a durable physical
253 | medium customarily used for software interchange, for a price no
254 | more than your reasonable cost of physically performing this
255 | conveying of source, or (2) access to copy the Corresponding
256 | Source from a network server at no charge.
257 | - c) Convey individual copies of the object code with a copy of the
258 | written offer to provide the Corresponding Source. This
259 | alternative is allowed only occasionally and noncommercially, and
260 | only if you received the object code with such an offer, in accord
261 | with subsection 6b.
262 | - d) Convey the object code by offering access from a designated
263 | place (gratis or for a charge), and offer equivalent access to the
264 | Corresponding Source in the same way through the same place at no
265 | further charge. You need not require recipients to copy the
266 | Corresponding Source along with the object code. If the place to
267 | copy the object code is a network server, the Corresponding Source
268 | may be on a different server (operated by you or a third party)
269 | that supports equivalent copying facilities, provided you maintain
270 | clear directions next to the object code saying where to find the
271 | Corresponding Source. Regardless of what server hosts the
272 | Corresponding Source, you remain obligated to ensure that it is
273 | available for as long as needed to satisfy these requirements.
274 | - e) Convey the object code using peer-to-peer transmission,
275 | provided you inform other peers where the object code and
276 | Corresponding Source of the work are being offered to the general
277 | public at no charge under subsection 6d.
278 |
279 | A separable portion of the object code, whose source code is excluded
280 | from the Corresponding Source as a System Library, need not be
281 | included in conveying the object code work.
282 |
283 | A "User Product" is either (1) a "consumer product", which means any
284 | tangible personal property which is normally used for personal,
285 | family, or household purposes, or (2) anything designed or sold for
286 | incorporation into a dwelling. In determining whether a product is a
287 | consumer product, doubtful cases shall be resolved in favor of
288 | coverage. For a particular product received by a particular user,
289 | "normally used" refers to a typical or common use of that class of
290 | product, regardless of the status of the particular user or of the way
291 | in which the particular user actually uses, or expects or is expected
292 | to use, the product. A product is a consumer product regardless of
293 | whether the product has substantial commercial, industrial or
294 | non-consumer uses, unless such uses represent the only significant
295 | mode of use of the product.
296 |
297 | "Installation Information" for a User Product means any methods,
298 | procedures, authorization keys, or other information required to
299 | install and execute modified versions of a covered work in that User
300 | Product from a modified version of its Corresponding Source. The
301 | information must suffice to ensure that the continued functioning of
302 | the modified object code is in no case prevented or interfered with
303 | solely because modification has been made.
304 |
305 | If you convey an object code work under this section in, or with, or
306 | specifically for use in, a User Product, and the conveying occurs as
307 | part of a transaction in which the right of possession and use of the
308 | User Product is transferred to the recipient in perpetuity or for a
309 | fixed term (regardless of how the transaction is characterized), the
310 | Corresponding Source conveyed under this section must be accompanied
311 | by the Installation Information. But this requirement does not apply
312 | if neither you nor any third party retains the ability to install
313 | modified object code on the User Product (for example, the work has
314 | been installed in ROM).
315 |
316 | The requirement to provide Installation Information does not include a
317 | requirement to continue to provide support service, warranty, or
318 | updates for a work that has been modified or installed by the
319 | recipient, or for the User Product in which it has been modified or
320 | installed. Access to a network may be denied when the modification
321 | itself materially and adversely affects the operation of the network
322 | or violates the rules and protocols for communication across the
323 | network.
324 |
325 | Corresponding Source conveyed, and Installation Information provided,
326 | in accord with this section must be in a format that is publicly
327 | documented (and with an implementation available to the public in
328 | source code form), and must require no special password or key for
329 | unpacking, reading or copying.
330 |
331 | #### 7. Additional Terms.
332 |
333 | "Additional permissions" are terms that supplement the terms of this
334 | License by making exceptions from one or more of its conditions.
335 | Additional permissions that are applicable to the entire Program shall
336 | be treated as though they were included in this License, to the extent
337 | that they are valid under applicable law. If additional permissions
338 | apply only to part of the Program, that part may be used separately
339 | under those permissions, but the entire Program remains governed by
340 | this License without regard to the additional permissions.
341 |
342 | When you convey a copy of a covered work, you may at your option
343 | remove any additional permissions from that copy, or from any part of
344 | it. (Additional permissions may be written to require their own
345 | removal in certain cases when you modify the work.) You may place
346 | additional permissions on material, added by you to a covered work,
347 | for which you have or can give appropriate copyright permission.
348 |
349 | Notwithstanding any other provision of this License, for material you
350 | add to a covered work, you may (if authorized by the copyright holders
351 | of that material) supplement the terms of this License with terms:
352 |
353 | - a) Disclaiming warranty or limiting liability differently from the
354 | terms of sections 15 and 16 of this License; or
355 | - b) Requiring preservation of specified reasonable legal notices or
356 | author attributions in that material or in the Appropriate Legal
357 | Notices displayed by works containing it; or
358 | - c) Prohibiting misrepresentation of the origin of that material,
359 | or requiring that modified versions of such material be marked in
360 | reasonable ways as different from the original version; or
361 | - d) Limiting the use for publicity purposes of names of licensors
362 | or authors of the material; or
363 | - e) Declining to grant rights under trademark law for use of some
364 | trade names, trademarks, or service marks; or
365 | - f) Requiring indemnification of licensors and authors of that
366 | material by anyone who conveys the material (or modified versions
367 | of it) with contractual assumptions of liability to the recipient,
368 | for any liability that these contractual assumptions directly
369 | impose on those licensors and authors.
370 |
371 | All other non-permissive additional terms are considered "further
372 | restrictions" within the meaning of section 10. If the Program as you
373 | received it, or any part of it, contains a notice stating that it is
374 | governed by this License along with a term that is a further
375 | restriction, you may remove that term. If a license document contains
376 | a further restriction but permits relicensing or conveying under this
377 | License, you may add to a covered work material governed by the terms
378 | of that license document, provided that the further restriction does
379 | not survive such relicensing or conveying.
380 |
381 | If you add terms to a covered work in accord with this section, you
382 | must place, in the relevant source files, a statement of the
383 | additional terms that apply to those files, or a notice indicating
384 | where to find the applicable terms.
385 |
386 | Additional terms, permissive or non-permissive, may be stated in the
387 | form of a separately written license, or stated as exceptions; the
388 | above requirements apply either way.
389 |
390 | #### 8. Termination.
391 |
392 | You may not propagate or modify a covered work except as expressly
393 | provided under this License. Any attempt otherwise to propagate or
394 | modify it is void, and will automatically terminate your rights under
395 | this License (including any patent licenses granted under the third
396 | paragraph of section 11).
397 |
398 | However, if you cease all violation of this License, then your license
399 | from a particular copyright holder is reinstated (a) provisionally,
400 | unless and until the copyright holder explicitly and finally
401 | terminates your license, and (b) permanently, if the copyright holder
402 | fails to notify you of the violation by some reasonable means prior to
403 | 60 days after the cessation.
404 |
405 | Moreover, your license from a particular copyright holder is
406 | reinstated permanently if the copyright holder notifies you of the
407 | violation by some reasonable means, this is the first time you have
408 | received notice of violation of this License (for any work) from that
409 | copyright holder, and you cure the violation prior to 30 days after
410 | your receipt of the notice.
411 |
412 | Termination of your rights under this section does not terminate the
413 | licenses of parties who have received copies or rights from you under
414 | this License. If your rights have been terminated and not permanently
415 | reinstated, you do not qualify to receive new licenses for the same
416 | material under section 10.
417 |
418 | #### 9. Acceptance Not Required for Having Copies.
419 |
420 | You are not required to accept this License in order to receive or run
421 | a copy of the Program. Ancillary propagation of a covered work
422 | occurring solely as a consequence of using peer-to-peer transmission
423 | to receive a copy likewise does not require acceptance. However,
424 | nothing other than this License grants you permission to propagate or
425 | modify any covered work. These actions infringe copyright if you do
426 | not accept this License. Therefore, by modifying or propagating a
427 | covered work, you indicate your acceptance of this License to do so.
428 |
429 | #### 10. Automatic Licensing of Downstream Recipients.
430 |
431 | Each time you convey a covered work, the recipient automatically
432 | receives a license from the original licensors, to run, modify and
433 | propagate that work, subject to this License. You are not responsible
434 | for enforcing compliance by third parties with this License.
435 |
436 | An "entity transaction" is a transaction transferring control of an
437 | organization, or substantially all assets of one, or subdividing an
438 | organization, or merging organizations. If propagation of a covered
439 | work results from an entity transaction, each party to that
440 | transaction who receives a copy of the work also receives whatever
441 | licenses to the work the party's predecessor in interest had or could
442 | give under the previous paragraph, plus a right to possession of the
443 | Corresponding Source of the work from the predecessor in interest, if
444 | the predecessor has it or can get it with reasonable efforts.
445 |
446 | You may not impose any further restrictions on the exercise of the
447 | rights granted or affirmed under this License. For example, you may
448 | not impose a license fee, royalty, or other charge for exercise of
449 | rights granted under this License, and you may not initiate litigation
450 | (including a cross-claim or counterclaim in a lawsuit) alleging that
451 | any patent claim is infringed by making, using, selling, offering for
452 | sale, or importing the Program or any portion of it.
453 |
454 | #### 11. Patents.
455 |
456 | A "contributor" is a copyright holder who authorizes use under this
457 | License of the Program or a work on which the Program is based. The
458 | work thus licensed is called the contributor's "contributor version".
459 |
460 | A contributor's "essential patent claims" are all patent claims owned
461 | or controlled by the contributor, whether already acquired or
462 | hereafter acquired, that would be infringed by some manner, permitted
463 | by this License, of making, using, or selling its contributor version,
464 | but do not include claims that would be infringed only as a
465 | consequence of further modification of the contributor version. For
466 | purposes of this definition, "control" includes the right to grant
467 | patent sublicenses in a manner consistent with the requirements of
468 | this License.
469 |
470 | Each contributor grants you a non-exclusive, worldwide, royalty-free
471 | patent license under the contributor's essential patent claims, to
472 | make, use, sell, offer for sale, import and otherwise run, modify and
473 | propagate the contents of its contributor version.
474 |
475 | In the following three paragraphs, a "patent license" is any express
476 | agreement or commitment, however denominated, not to enforce a patent
477 | (such as an express permission to practice a patent or covenant not to
478 | sue for patent infringement). To "grant" such a patent license to a
479 | party means to make such an agreement or commitment not to enforce a
480 | patent against the party.
481 |
482 | If you convey a covered work, knowingly relying on a patent license,
483 | and the Corresponding Source of the work is not available for anyone
484 | to copy, free of charge and under the terms of this License, through a
485 | publicly available network server or other readily accessible means,
486 | then you must either (1) cause the Corresponding Source to be so
487 | available, or (2) arrange to deprive yourself of the benefit of the
488 | patent license for this particular work, or (3) arrange, in a manner
489 | consistent with the requirements of this License, to extend the patent
490 | license to downstream recipients. "Knowingly relying" means you have
491 | actual knowledge that, but for the patent license, your conveying the
492 | covered work in a country, or your recipient's use of the covered work
493 | in a country, would infringe one or more identifiable patents in that
494 | country that you have reason to believe are valid.
495 |
496 | If, pursuant to or in connection with a single transaction or
497 | arrangement, you convey, or propagate by procuring conveyance of, a
498 | covered work, and grant a patent license to some of the parties
499 | receiving the covered work authorizing them to use, propagate, modify
500 | or convey a specific copy of the covered work, then the patent license
501 | you grant is automatically extended to all recipients of the covered
502 | work and works based on it.
503 |
504 | A patent license is "discriminatory" if it does not include within the
505 | scope of its coverage, prohibits the exercise of, or is conditioned on
506 | the non-exercise of one or more of the rights that are specifically
507 | granted under this License. You may not convey a covered work if you
508 | are a party to an arrangement with a third party that is in the
509 | business of distributing software, under which you make payment to the
510 | third party based on the extent of your activity of conveying the
511 | work, and under which the third party grants, to any of the parties
512 | who would receive the covered work from you, a discriminatory patent
513 | license (a) in connection with copies of the covered work conveyed by
514 | you (or copies made from those copies), or (b) primarily for and in
515 | connection with specific products or compilations that contain the
516 | covered work, unless you entered into that arrangement, or that patent
517 | license was granted, prior to 28 March 2007.
518 |
519 | Nothing in this License shall be construed as excluding or limiting
520 | any implied license or other defenses to infringement that may
521 | otherwise be available to you under applicable patent law.
522 |
523 | #### 12. No Surrender of Others' Freedom.
524 |
525 | If conditions are imposed on you (whether by court order, agreement or
526 | otherwise) that contradict the conditions of this License, they do not
527 | excuse you from the conditions of this License. If you cannot convey a
528 | covered work so as to satisfy simultaneously your obligations under
529 | this License and any other pertinent obligations, then as a
530 | consequence you may not convey it at all. For example, if you agree to
531 | terms that obligate you to collect a royalty for further conveying
532 | from those to whom you convey the Program, the only way you could
533 | satisfy both those terms and this License would be to refrain entirely
534 | from conveying the Program.
535 |
536 | #### 13. Remote Network Interaction; Use with the GNU General Public License.
537 |
538 | Notwithstanding any other provision of this License, if you modify the
539 | Program, your modified version must prominently offer all users
540 | interacting with it remotely through a computer network (if your
541 | version supports such interaction) an opportunity to receive the
542 | Corresponding Source of your version by providing access to the
543 | Corresponding Source from a network server at no charge, through some
544 | standard or customary means of facilitating copying of software. This
545 | Corresponding Source shall include the Corresponding Source for any
546 | work covered by version 3 of the GNU General Public License that is
547 | incorporated pursuant to the following paragraph.
548 |
549 | Notwithstanding any other provision of this License, you have
550 | permission to link or combine any covered work with a work licensed
551 | under version 3 of the GNU General Public License into a single
552 | combined work, and to convey the resulting work. The terms of this
553 | License will continue to apply to the part which is the covered work,
554 | but the work with which it is combined will remain governed by version
555 | 3 of the GNU General Public License.
556 |
557 | #### 14. Revised Versions of this License.
558 |
559 | The Free Software Foundation may publish revised and/or new versions
560 | of the GNU Affero General Public License from time to time. Such new
561 | versions will be similar in spirit to the present version, but may
562 | differ in detail to address new problems or concerns.
563 |
564 | Each version is given a distinguishing version number. If the Program
565 | specifies that a certain numbered version of the GNU Affero General
566 | Public License "or any later version" applies to it, you have the
567 | option of following the terms and conditions either of that numbered
568 | version or of any later version published by the Free Software
569 | Foundation. If the Program does not specify a version number of the
570 | GNU Affero General Public License, you may choose any version ever
571 | published by the Free Software Foundation.
572 |
573 | If the Program specifies that a proxy can decide which future versions
574 | of the GNU Affero General Public License can be used, that proxy's
575 | public statement of acceptance of a version permanently authorizes you
576 | to choose that version for the Program.
577 |
578 | Later license versions may give you additional or different
579 | permissions. However, no additional obligations are imposed on any
580 | author or copyright holder as a result of your choosing to follow a
581 | later version.
582 |
583 | #### 15. Disclaimer of Warranty.
584 |
585 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
586 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
587 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT
588 | WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT
589 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
590 | A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND
591 | PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE
592 | DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR
593 | CORRECTION.
594 |
595 | #### 16. Limitation of Liability.
596 |
597 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
598 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR
599 | CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
600 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES
601 | ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT
602 | NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR
603 | LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM
604 | TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER
605 | PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
606 |
607 | #### 17. Interpretation of Sections 15 and 16.
608 |
609 | If the disclaimer of warranty and limitation of liability provided
610 | above cannot be given local legal effect according to their terms,
611 | reviewing courts shall apply local law that most closely approximates
612 | an absolute waiver of all civil liability in connection with the
613 | Program, unless a warranty or assumption of liability accompanies a
614 | copy of the Program in return for a fee.
615 |
616 | END OF TERMS AND CONDITIONS
617 |
618 | ### How to Apply These Terms to Your New Programs
619 |
620 | If you develop a new program, and you want it to be of the greatest
621 | possible use to the public, the best way to achieve this is to make it
622 | free software which everyone can redistribute and change under these
623 | terms.
624 |
625 | To do so, attach the following notices to the program. It is safest to
626 | attach them to the start of each source file to most effectively state
627 | the exclusion of warranty; and each file should have at least the
628 | "copyright" line and a pointer to where the full notice is found.
629 |
630 |
631 | Copyright (C)
632 |
633 | This program is free software: you can redistribute it and/or modify
634 | it under the terms of the GNU Affero General Public License as
635 | published by the Free Software Foundation, either version 3 of the
636 | License, or (at your option) any later version.
637 |
638 | This program is distributed in the hope that it will be useful,
639 | but WITHOUT ANY WARRANTY; without even the implied warranty of
640 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
641 | GNU Affero General Public License for more details.
642 |
643 | You should have received a copy of the GNU Affero General Public License
644 | along with this program. If not, see .
645 |
646 | Also add information on how to contact you by electronic and paper
647 | mail.
648 |
649 | If your software can interact with users remotely through a computer
650 | network, you should also make sure that it provides a way for users to
651 | get its source. For example, if your program is a web application, its
652 | interface could display a "Source" link that leads users to an archive
653 | of the code. There are many ways you could offer source, and different
654 | solutions will be better for different programs; see section 13 for
655 | the specific requirements.
656 |
657 | You should also get your employer (if you work as a programmer) or
658 | school, if any, to sign a "copyright disclaimer" for the program, if
659 | necessary. For more information on this, and how to apply and follow
660 | the GNU AGPL, see .
661 |
--------------------------------------------------------------------------------
/Readme.md:
--------------------------------------------------------------------------------
1 | # LazarusPackageManager
2 | This project contains a command-line package manager for Lazarus.
3 |
4 | Features:
5 | - Handling of multiple lazarus versions
6 | - Download and install packages from OPM
7 | - Search OPM
8 | - Download and install packages from GIT, SVN or HTTP downloads
9 |
10 | ## Purpose:
11 |
12 | The goal of this program is not to manage packages for development lazarus version, as the OPM does a great job there, but to install packages for buildsystems, e.g. via docker, where no GUI (and therefore no OPM) is available.
13 |
14 | An example for building a project that requires a package from OPM can be found in `example`. See `example/Readme.md` for further informations
15 |
16 | ## Usage:
17 | The lpm executable saves all the information in the `~/.lpm` directory, to change this use the `--target` option (see `lpm -h` for further information).
18 |
19 | To use the OPM functionality, first the package list must be synchronized via
20 | ```
21 | $> ./lpm update
22 | ```
23 | OPM packages can then be searched with `search` and downloaded with `fetch`
24 | ```
25 | $> ./lpm search indy
26 | ...
27 | $> ./lpm fetch Indy10
28 | ```
29 | To download any non OPM packages, we can use `direct-download`
30 | ```
31 | $> ./lpm direct-download indy https://packages.lazarus-ide.org/Indy10.zip Indy10/indylaz.lpk
32 | ```
33 | If we don't add any lpk files after the URL, the lpm will automatically search for all lpk files in the target directory
34 |
35 | To install any packages we first need to register a lazarus verions where we want to install the package to:
36 | ```
37 | $> ./lpm lazarus add 2.0.6 /developer/lazarus/2.0.6
38 | ```
39 | The LPM stores the current lazarus version to perform operations on. The first one added will be the default one, it can be switched via:
40 | ```
41 | $> ./lpm lazarus select 2.0.6
42 | ```
43 | We can then install packages to the currently selected lazarus version
44 | ```
45 | # the OPM package and the downloaded package
46 | $> ./lpm install Indy10 indy
47 | ```
48 | If a package was not downloaded previously, but can be found with the OPM (like Indy10), it will be downloaded. Of course there is no way to find non OPM packages without downloading them beforehand with `direct-download`
49 |
50 | To ease building of projects as well as package searching, the command `build` provides a wrapper that:
51 | 1. seaches all the required packages that where not previously downloaded in the OPM
52 | 2. installs missing packages that where not installed to the given lazarus version
53 | 3. compiles the project using lazbuild
54 |
55 | It also supports lazarus build modes, so if you want to build the build mode Release and Release64 you can use the following
56 | ```
57 | $> ./lpm build projectPath Release Release64
58 | ```
59 | If no build mode is given, all will be build. Also, it will ask you before installing packages, to skip this pass the `-y` or `--yes` option
60 |
61 | The last command is `upgrade`, which takes all packages installed via OPM, and downloads (and installs) the newest version of them, if a newer one is available than installed.
62 |
63 | So to summarize, to build a program that requires packages the following has to be done:
64 | ```
65 | $> lpm update
66 | $> lpm lazarus add 2.0.6 /developer/lazarus/2.0.6
67 | # manual install
68 | $> lpm install Indy10
69 | $> lazbuild project.lpi
70 | # Or simply
71 | $> lpm build -y project.lpi
72 | ```
73 |
--------------------------------------------------------------------------------
/download.py:
--------------------------------------------------------------------------------
1 | from urllib import request
2 | from enum import Enum
3 | from os import makedirs
4 | from subprocess import Popen, call
5 | from tempfile import mkdtemp
6 | from shutil import rmtree
7 | from pathlib import Path
8 | from logger import noLogger
9 |
10 |
11 | class Packtype(Enum):
12 | TAR = ".tar"
13 | TAR_GZ = ".tar.gz"
14 | TAR_BZ2 = ".tar.bz2"
15 | ZIP = ".zip"
16 |
17 | def packtypeFromFilename(filename):
18 | for pt in Packtype:
19 | if filename.endswith(pt.value):
20 | return pt
21 | return None
22 |
23 | def filenameFromUrl(url):
24 | return url.split("/")[-1]
25 |
26 | class HTTPDownload:
27 | def __init__(self, url, filename=None, logger=noLogger):
28 | self.url = url
29 | self.logger=logger
30 | self.filename = filenameFromUrl(url) if filename is None else filename
31 | self.packtype = packtypeFromFilename(self.filename)
32 | def __downloadRaw(self, target):
33 | self.logger.log(f"Downloading {self.filename} from {self.url}")
34 | request.urlretrieve(self.url, target/self.filename)
35 | return True
36 | def __downloadTar(self, target, tarArgs):
37 | self.logger.log(f"Downloading and unpacking {self.filename} from {self.url}")
38 | with request.urlopen(self.url) as req:
39 | tar = Popen(["tar", tarArgs], cwd=target, stdin=req)
40 | tar.communicate()
41 | return tar.returncode == 0
42 | def __downloadZip(self, target):
43 | tmpDir = Path(mkdtemp())
44 | try:
45 | self.__downloadRaw(tmpDir)
46 | self.logger.log(f"Inflating {self.filename}")
47 | return call(["unzip", "-q", str(tmpDir/self.filename)], cwd=target) == 0
48 | finally:
49 | rmtree(tmpDir)
50 | def download(self, target):
51 | makedirs(target, exist_ok=True)
52 | if self.packtype == Packtype.TAR:
53 | return self.__downloadTar(target, "-x")
54 | if self.packtype == Packtype.TAR_GZ:
55 | return self.__downloadTar(target, "-xz")
56 | if self.packtype == Packtype.TAR_BZ2:
57 | return self.__downloadTar(target, "-xj")
58 | if self.packtype == Packtype.ZIP:
59 | return self.__downloadZip(target)
60 | return self.__downloadRaw(target)
61 | def serialize(self):
62 | return {
63 | "protocol": "HTTP",
64 | "url": self.url,
65 | "filename": self.filename
66 | }
67 |
68 | class GITDownload:
69 | def __init__(self, url, branch="master", shallow=True, logger=noLogger):
70 | self.url = url
71 | self.logger = logger
72 | self.branch = branch
73 | self.shallow = shallow
74 | def download(self, target):
75 | self.logger.log(f"cloning {self.url} branch {self.branch} into {target}")
76 | callArgs = ["git", "clone" f"--branch={self.branch}"]
77 | if self.shallow:
78 | callArgs.append("--depth 1")
79 | callArgs.extend([self.url, target])
80 | return call(callArgs) == 0
81 | def serialize(self):
82 | return {
83 | "protocol": "GIT",
84 | "url": self.url,
85 | "branch": self.branch,
86 | "shallow": self.shallow
87 | }
88 |
89 | class SVNDownload:
90 | def __init__(self, url, logger=noLogger):
91 | self.url = url
92 | self.logger = logger
93 | def download(self, target, print_action=None):
94 | self.logger.log(f"checking {self.url} out into {target}")
95 | return call(["svn", "co", "-q", self.url, target]) == 0
96 | def serialize(self):
97 | return {
98 | "protocol": "SVN",
99 | "url": self.url
100 | }
101 |
102 | def deserializeDownload(serialized):
103 | proto = serialized["protocol"]
104 | if proto == "HTTP":
105 | return HTTPDownload(serialized["url"], serialized.get("filename", None))
106 | if proto == "GIT":
107 | return GITDownload(serialized["url"], serialized.get("branch", "master"), serialized.get("shallow", True))
108 | if proto == "SVN":
109 | return SVNDownload(serialized["url"])
110 | return None
111 |
--------------------------------------------------------------------------------
/example/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM debian:sid
2 |
3 | RUN apt-get update && apt-get install --yes lazarus-ide-qt5 unzip
4 |
5 | COPY . /example
6 | RUN cd /example && ./lpm update && ./lpm lazarus add 2.0.6 /usr/lib/lazarus/2.0.6 && ./lpm install dcpcrypt-2.0.4.1 && lazbuild example/example.lpi
7 | RUN cd /example && ./lpm build -y example/indyExample.lpi
8 |
--------------------------------------------------------------------------------
/example/Readme.md:
--------------------------------------------------------------------------------
1 | The directory for building this docker example needs to be the root of the repository (as it need access to the sources).
2 |
3 | ```
4 | $> docker build -f Dockerfile -t build_example ..
5 | ```
6 | After building the container with the build result can be accessed:
7 | ```
8 | $> docker run -it build_example
9 | #container> cd /example/example
10 | #container> ./exampe #runs the builded executable
11 | ```
12 | To delete the image afterwards simply call
13 | ```
14 | $> docker rmi build_example
15 | ```
16 |
--------------------------------------------------------------------------------
/example/example.lpi:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
--------------------------------------------------------------------------------
/example/example.lpr:
--------------------------------------------------------------------------------
1 | program example;
2 |
3 | {$mode objfpc}{$H+}
4 |
5 | uses
6 | {$IFDEF UNIX}{$IFDEF UseCThreads}
7 | cthreads,
8 | {$ENDIF}{$ENDIF}
9 | Classes, DCPrijndael, DCPsha256
10 | { you can add units after this };
11 |
12 | var c: TDCP_rijndael;
13 | str: String;
14 | enc: String;
15 | begin
16 | ReadLn(str);
17 | c := TDCP_rijndael.Create(nil);
18 | // I've heard random passwords are really secure
19 | c.InitStr('Random1234', TDCP_sha256);
20 | enc := c.EncryptString(str);
21 | c.Free;
22 | WriteLn(enc);
23 | end.
24 |
25 |
--------------------------------------------------------------------------------
/example/indyExample.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Warfley/LazarusPackageManager/a7522dc6dea1e16bf99254f9053333eb6718bf36/example/indyExample.ico
--------------------------------------------------------------------------------
/example/indyExample.lpi:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
--------------------------------------------------------------------------------
/example/indyExample.lpr:
--------------------------------------------------------------------------------
1 | program indyExample;
2 |
3 | {$mode objfpc}{$H+}
4 |
5 | uses
6 | {$IFDEF UNIX}{$IFDEF UseCThreads}
7 | cthreads,
8 | {$ENDIF}{$ENDIF}
9 | Interfaces, // this includes the LCL widgetset
10 | Forms, indyExampleMainForm, indylaz
11 | { you can add units after this };
12 |
13 | {$R *.res}
14 |
15 | begin
16 | RequireDerivedFormResource:=True;
17 | Application.Scaled:=True;
18 | Application.Initialize;
19 | Application.CreateForm(TForm1, Form1);
20 | Application.Run;
21 | end.
22 |
23 |
--------------------------------------------------------------------------------
/example/indyexamplemainform.lfm:
--------------------------------------------------------------------------------
1 | object Form1: TForm1
2 | Left = 399
3 | Height = 240
4 | Top = 250
5 | Width = 320
6 | Caption = 'Form1'
7 | ClientHeight = 240
8 | ClientWidth = 320
9 | object Memo1: TMemo
10 | Left = 0
11 | Height = 206
12 | Top = 34
13 | Width = 320
14 | Align = alClient
15 | Lines.Strings = (
16 | 'Memo1'
17 | )
18 | TabOrder = 0
19 | end
20 | object Panel1: TPanel
21 | Left = 0
22 | Height = 34
23 | Top = 0
24 | Width = 320
25 | Align = alTop
26 | BevelOuter = bvNone
27 | ClientHeight = 34
28 | ClientWidth = 320
29 | TabOrder = 1
30 | object Edit1: TEdit
31 | Left = 0
32 | Height = 34
33 | Top = 0
34 | Width = 245
35 | Align = alClient
36 | TabOrder = 0
37 | Text = 'https://google.de'
38 | end
39 | object Button1: TButton
40 | Left = 245
41 | Height = 34
42 | Top = 0
43 | Width = 75
44 | Align = alRight
45 | Caption = 'Load'
46 | OnClick = Button1Click
47 | TabOrder = 1
48 | end
49 | end
50 | object IdHTTP1: TIdHTTP
51 | ProxyParams.BasicAuthentication = False
52 | ProxyParams.ProxyPort = 0
53 | Request.ContentLength = -1
54 | Request.ContentRangeEnd = -1
55 | Request.ContentRangeStart = -1
56 | Request.ContentRangeInstanceLength = -1
57 | Request.Date = 0
58 | Request.Expires = 0
59 | Request.LastModified = 0
60 | Request.Accept = 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'
61 | Request.BasicAuthentication = False
62 | Request.UserAgent = 'Mozilla/3.0 (compatible; Indy Library)'
63 | Request.Ranges.Units = 'bytes'
64 | Request.Ranges = <>
65 | HTTPOptions = [hoForceEncodeParams]
66 | left = 259
67 | top = 48
68 | end
69 | end
70 |
--------------------------------------------------------------------------------
/example/indyexamplemainform.pas:
--------------------------------------------------------------------------------
1 | unit indyExampleMainForm;
2 |
3 | {$mode objfpc}{$H+}
4 |
5 | interface
6 |
7 | uses
8 | Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, ExtCtrls,
9 | IdHTTP;
10 |
11 | type
12 |
13 | { TForm1 }
14 |
15 | TForm1 = class(TForm)
16 | Button1: TButton;
17 | Edit1: TEdit;
18 | IdHTTP1: TIdHTTP;
19 | Memo1: TMemo;
20 | Panel1: TPanel;
21 | procedure Button1Click(Sender: TObject);
22 | private
23 |
24 | public
25 |
26 | end;
27 |
28 | var
29 | Form1: TForm1;
30 |
31 | implementation
32 |
33 | {$R *.lfm}
34 |
35 | { TForm1 }
36 |
37 | procedure TForm1.Button1Click(Sender: TObject);
38 | begin
39 | Memo1.Text := IdHTTP1.Get(Edit1.Text);
40 | end;
41 |
42 | end.
43 |
44 |
--------------------------------------------------------------------------------
/logger.py:
--------------------------------------------------------------------------------
1 | import sys
2 | from enum import Enum
3 |
4 |
5 | class LogLevel(Enum):
6 | DEBUG=0
7 | INFO=1
8 | WARNING=2
9 | ERROR=3
10 | NONE=10
11 |
12 | class Logger:
13 | def __init__(self, loglevel):
14 | self.loglevel = loglevel
15 | self.files = {
16 | LogLevel.DEBUG: [sys.stdout],
17 | LogLevel.INFO: [sys.stdout],
18 | LogLevel.WARNING: [sys.stderr],
19 | LogLevel.ERROR: [sys.stderr]
20 | }
21 | def __write(self, level, pref, message):
22 | if self.loglevel.value > level.value:
23 | return
24 | for f in self.files[level]:
25 | f.write(pref)
26 | f.write(message)
27 | f.write("\n")
28 | def debug(self, message):
29 | self.__write(LogLevel.DEBUG, "[DEBUG] ", message)
30 | def log(self, message):
31 | self.__write(LogLevel.INFO, "[INFO] ", message)
32 | def warning(self, message):
33 | self.__write(LogLevel.WARNING, "[WARN] ", message)
34 | def error(self, message):
35 | self.__write(LogLevel.ERROR, "[ERROR] ", message)
36 |
37 | noLogger = Logger(LogLevel.NONE)
38 |
--------------------------------------------------------------------------------
/lpm:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | import sys
3 | from pathlib import Path
4 | from argparse import ArgumentParser
5 | from os import makedirs
6 | from shutil import get_terminal_size
7 | from download import HTTPDownload, GITDownload, SVNDownload
8 | from packagemanager import PackageManager
9 | from opm import OnlinePackageManager
10 | from logger import Logger, LogLevel
11 | from project import LazarusProject
12 | from subprocess import call
13 |
14 | def performUpdate(opm):
15 | opm.downloadPackageList()
16 | return True
17 |
18 | def performFetch(lpm, opm, packages, logger):
19 | result = True
20 | for pkgName in packages:
21 | pkg = opm.packages.get(pkgName)
22 | if pkg is None:
23 | logger.error(f"Package {pkgName} not found... skipping")
24 | result = False
25 | continue
26 | result = result and lpm.fetchFromOPM(pkg)
27 | return result
28 |
29 | def performInstall(lpm, opm, packages, logger):
30 | fetchFirst = [p for p in packages if p not in lpm.packages]
31 | result = performFetch(lpm, opm, fetchFirst, logger)
32 | for pkgName in packages:
33 | result = result and lpm.installPackage(pkgName)
34 | return result
35 |
36 | def performUpgrade(lpm, opm, packages, logger):
37 | result = True
38 | if len(packages) == 0:
39 | packages = [name for name, _ in lpm.packages.items()]
40 | updateable = [p for p in packages if p in opm.packages]
41 | for p in updateable:
42 | pkg = lpm.packages.get(p)
43 | if pkg is None:
44 | logger.error(f"Package {p} not found... skipping")
45 | result = False
46 | continue
47 | opmPkg = opm.packages[p]
48 | if pkg.date >= opmPkg.file_date:
49 | logger.log(f"{p} is up to date")
50 | continue
51 | logger.log(f"updating {p}")
52 | pkgResult = performFetch(lpm, opm, [p], logger)
53 | if not pkgResult:
54 | result = False
55 | continue
56 | sel = lpm.selected
57 | for i in pkg.installed:
58 | if lpm.selectLazarus(i):
59 | result = result and performInstall(lpm, opm, [p], logger)
60 | else:
61 | result = False
62 | lpm.selectLazarus(sel)
63 | return result
64 |
65 | def performSearch(opm, searchstring):
66 | result = opm.searchPackages(searchstring)
67 | nameSize = 0
68 | catSize = 0
69 | for pkg in result:
70 | nameSize = max(nameSize, len(pkg.name))
71 | cats = pkg.categories[:2]
72 | cat = ", ".join(pkg.categories[0:2])
73 | if len(cats) < len(pkg.categories):
74 | cat += ", ..."
75 | catSize = max(catSize, len(cat))
76 | for pkg in result:
77 | namePadding = " "*(nameSize-len(pkg.name))
78 | cats = pkg.categories[:2]
79 | cat = ", ".join(pkg.categories[0:2])
80 | if len(cats) < len(pkg.categories):
81 | cat += ", ..."
82 | catPadding = " "*(catSize-len(cat))
83 | desc = pkg.description.replace("\n", " ")
84 | desc = desc.replace("\r", "")
85 | separator = " | "
86 | wndSize = get_terminal_size((0, 0)).columns
87 | totalLen = nameSize + catSize + len(desc) + 2*len(separator)
88 | totalLenWithouDesc = totalLen - len(desc)
89 | if totalLen > wndSize > 0 and totalLenWithouDesc + 3 < wndSize:
90 | desc = desc[:wndSize-totalLenWithouDesc-3] + "..."
91 | print(f"{pkg.name}{namePadding}{separator}{cat}{catPadding}{separator}{desc}")
92 | return len(result) > 0
93 |
94 | def performDirectDownload(lpm, name, url, dltype, branch, packages, logger):
95 | download = None
96 | if dltype == "git":
97 | download = GITDownload(url, branch, logger=logger)
98 | elif dltype == "svn":
99 | download = SVNDownload(url, logger=logger)
100 | elif dltype == "http":
101 | download = HTTPDownload(url, logger=logger)
102 | if download is None:
103 | print(f"download method {dltype} unkown")
104 | return False
105 | return lpm.fetchFromDownloader(name, download, 0, packages)
106 |
107 | def handleLazarus(lpm, action, name, path):
108 | if action == "add":
109 | return lpm.addLazarus(name, Path(path).expanduser())
110 | if action == "delete":
111 | return lpm.removeLazarus(name)
112 | if action == "select":
113 | return lpm.selectLazarus(name)
114 | return False
115 |
116 | def performBuild(lpm, opm, project, modes, yes, logger):
117 | lazbuild = lpm.getLazbuild()
118 | if lazbuild is None:
119 | return False
120 | project = LazarusProject(Path(project).expanduser())
121 | basePackages = lpm.getLazarusbasePackages()
122 | if basePackages is None:
123 | return False
124 | availableModes = project.getModes()
125 | if len(modes) == 0:
126 | modes = availableModes
127 | dependencies = [f"{d}.lpk" for d in project.getDependencies()]
128 | for dep in dependencies:
129 | dep = dep.lower()
130 | if dep in basePackages:
131 | continue
132 | pkg = lpm.packageByPackage(dep)
133 | toInstall = None
134 | if (pkg is not None) and (lpm.selected not in pkg.installed):
135 | toInstall = pkg.name
136 | elif pkg is None:
137 | opmPkg = opm.packageMap.get(dep)
138 | if opmPkg is None:
139 | logger.error(f"dependency {dep} could not be resolved")
140 | return False
141 | toInstall = opmPkg.name
142 | if toInstall is not None:
143 | if not yes:
144 | print(f"Dependency {dep} is found but not installed, install now?")
145 | inp = input("[Y/n] > ")
146 | if inp.lower() == "n":
147 | logger.error(f"dependency {dep} could not be resolved")
148 | return False
149 | performInstall(lpm, opm, [toInstall], logger)
150 |
151 | result = True
152 | for mode in modes:
153 | if mode not in availableModes:
154 | logger.error(f"Buildmode {mode} requested but not available for project")
155 | result = False
156 | continue
157 | result = result and project.build(lazbuild, mode)
158 | return result
159 |
160 | def performSelfUpdate():
161 | git_dir = Path(__file__).resolve().parent
162 | return call(["git", "pull"], cwd=git_dir) == 0
163 |
164 | def main():
165 | parser = ArgumentParser(description="online package manager CLI")
166 | parser.add_argument("--target", type=str, help="target directory for the package list and downloaded packages (default=~/.lpm)", default="~/.lpm")
167 | parser.add_argument("--quiet", "-q", action="store_true", required=False, help="only output errors", default=False)
168 | sp = parser.add_subparsers(dest="mainaction", required=True)
169 |
170 | updateArg = sp.add_parser("update", help="updates package list from server")
171 |
172 | upgradeArg = sp.add_parser("upgrade", help="update packages from server")
173 | upgradeArg.add_argument("packages", type=str, nargs="*", help="packages to upgrade, if none are given all are updated")
174 |
175 | fetchArg = sp.add_parser("fetch", help="download newest version of a package")
176 | fetchArg.add_argument("packages", type=str, help="packages to download", nargs="+")
177 |
178 | installArg = sp.add_parser("install", help="installs the package to a lazarus installation")
179 | installArg.add_argument("packages", type=str, help="packages to install", nargs="+")
180 |
181 | searchArg = sp.add_parser("search", help="search for packages")
182 | searchArg.add_argument("searchstring", type=str, help="the string to search for")
183 |
184 | rawArg = sp.add_parser("direct-download", help="download a package not using OPM")
185 | rawArg.add_argument("--type", "-t", type=str, choices=["http", "git", "svn"], help="downloading method. Default=http", default="http")
186 | rawArg.add_argument("--branch", "-b", type=str, help="branch to checkout (git only). Default=master", default="master")
187 | rawArg.add_argument("name", type=str, help="the name under which this package will be registered")
188 | rawArg.add_argument("url", type=str, help="the download url of the file")
189 | rawArg.add_argument("packages", type=str, nargs="*", help="list of lpk files in that file, if none are given a file search for *.lpk will be done")
190 |
191 | lazArg = sp.add_parser("lazarus", help="configure lazarus installations")
192 | lazArg.add_argument("action", type=str, choices=["add", "delete", "select"], help="action to perform")
193 | lazArg.add_argument("name", type=str, help="name of the lazarus installation (for references)")
194 | lazArg.add_argument("path", nargs="?", type=str, help="path of the lazarus installation")
195 |
196 | buildArg = sp.add_parser("build", help="buidling lazarus projects")
197 | buildArg.add_argument("--yes", "-y", action="store_true", default=False, required=False, help="answer all yes-no questions with yes")
198 | buildArg.add_argument("project", type=str, help="lpi file to build")
199 | buildArg.add_argument("modes", type=str, nargs="*", help="the build modes to build, if left out, all are build")
200 |
201 | selfUpdateArg = sp.add_parser("self-update", help="Update lpm via git")
202 |
203 | args = parser.parse_args()
204 |
205 | quiet = args.quiet
206 | target = Path(args.target).expanduser()
207 | makedirs(target, exist_ok=True)
208 |
209 | logger = Logger(LogLevel.WARNING if quiet else LogLevel.DEBUG)
210 |
211 | opm = OnlinePackageManager(target, logger)
212 | opm.loadPackageList()
213 |
214 | lpm = PackageManager(target, logger)
215 | lpm.load()
216 |
217 | action = args.mainaction
218 | success = False
219 | if action == "update":
220 | success = performUpdate(opm)
221 | elif action == "upgrade":
222 | success = performUpgrade(lpm, opm, args.packages, logger)
223 | elif action == "fetch":
224 | success = performFetch(lpm, opm, args.packages, logger)
225 | elif action == "install":
226 | success = performInstall(lpm, opm, args.packages, logger)
227 | elif action == "search":
228 | success = performSearch(opm, args.searchstring)
229 | elif action == "direct-download":
230 | success = performDirectDownload(lpm, args.name, args.url, args.type, args.branch, args.packages, logger)
231 | elif action == "lazarus":
232 | success = handleLazarus(lpm, args.action, args.name, args.path)
233 | elif action == "build":
234 | success = performBuild(lpm, opm, args.project, args.modes, args.yes, logger)
235 | elif action == "self-update":
236 | success = performSelfUpdate()
237 |
238 | lpm.save()
239 | if not success:
240 | sys.exit(1)
241 |
242 |
243 | if __name__=="__main__":
244 | main()
245 |
--------------------------------------------------------------------------------
/opm.py:
--------------------------------------------------------------------------------
1 | import json
2 | import re
3 | from pathlib import Path
4 | from os import makedirs
5 | from download import HTTPDownload
6 |
7 | repositoryURL = "https://packages.lazarus-ide.org"
8 | targetFileName = "opm.json"
9 |
10 | def normalizeFileName(fname):
11 | fname = fname.replace("\\/", "/")
12 | if len(fname) > 1 and fname[-1] == "/":
13 | fname = fname[:-1]
14 | return fname
15 |
16 | class PackageDependency:
17 | def __init__(self, dependencyString):
18 | dependencyReg = re.compile("([A-Za-z0-9,.-]+)(\\((.+)\\))?")
19 | m = dependencyReg.match(dependencyString.strip())
20 | assert m is not None
21 | self.name = m.group(1)
22 | self.version = m.group(3)
23 |
24 |
25 | from os import makedirs
26 | from download import HTTPDownload
27 | class OPMPackageFile:
28 | def __init__(self, dataObject):
29 | self.name = dataObject["Name"]
30 | self.description = dataObject["Description"]
31 | self.author = dataObject["Author"]
32 | self.license = dataObject["License"]
33 | self.relative_path = normalizeFileName(dataObject["RelativeFilePath"])
34 | self.version = dataObject["VersionAsString"]
35 | self.lazarus_versions = [v.strip() for v in dataObject["LazCompatibility"].split(",")]
36 | self.fpc_versions = [v.strip() for v in dataObject["FPCCompatibility"].split(",")]
37 | self.widgetsets = [v.strip() for v in dataObject["SupportedWidgetSet"].split(",")]
38 | self.package_type = dataObject["PackageType"]
39 | dependency_string = dataObject["DependenciesAsString"].strip()
40 | if dependency_string == "":
41 | self.dependencies = []
42 | else:
43 | self.dependencies = [PackageDependency(v) for v in dataObject["DependenciesAsString"].split(",")]
44 | def getFilename(self):
45 | if self.relative_path == "":
46 | return self.name
47 | return f"{self.relative_path}/{self.name}"
48 |
49 | class OPMPackage:
50 | def __init__(self, dataObject):
51 | self.name = dataObject["Name"]
52 | self.display_name = dataObject["DisplayName"]
53 | self.categories = [c.strip() for c in dataObject["Category"].split(",")]
54 | self.description = dataObject["CommunityDescription"]
55 | self.file_name = dataObject["RepositoryFileName"]
56 | self.file_size = dataObject["RepositoryFileSize"]
57 | self.file_hash = dataObject["RepositoryFileHash"]
58 | self.file_date = dataObject["RepositoryDate"]
59 | self.package_dir = normalizeFileName(dataObject["PackageBaseDir"])
60 | self.homepage = dataObject["HomePageURL"]
61 | self.download_url = dataObject["DownloadURL"]
62 | self.svn_url = dataObject["SVNURL"]
63 | self.files = []
64 | def getPackageFilenames(self):
65 | return [fl.name for fl in self.files]
66 | def getDownloader(self, logger):
67 | return HTTPDownload(f"{repositoryURL}/{self.file_name}", logger=logger)
68 |
69 | def readPackageList(packageListData):
70 | packages = {}
71 | nameMatcher = re.compile("Package(Data|Files)(\\d+)")
72 | for name, value in packageListData.items():
73 | m = nameMatcher.match(name)
74 | assert m is not None
75 | pkg_num = int(m.group(2))
76 | data, files = packages.get(pkg_num, (None, None))
77 | if m.group(1) == "Data":
78 | data = OPMPackage(value)
79 | else:
80 | files = [OPMPackageFile(v) for v in value]
81 | packages[pkg_num] = (data, files)
82 | result = {}
83 | for _, (data, files) in packages.items():
84 | data.files = files
85 | result[data.name] = data
86 | return result
87 |
88 |
89 | class OnlinePackageManager:
90 | def __init__(self, target, logger):
91 | self.logger = logger
92 | self.packages = {}
93 | self.target = target
94 | self.packageMap = {}
95 | def __constructPackageNameMap(self):
96 | result = {}
97 | for _, pkg in self.packages.items():
98 | for fl in pkg.files:
99 | result[fl.name.lower()] = pkg
100 | return result
101 | def downloadPackageList(self):
102 | HTTPDownload(f"{repositoryURL}/packagelist.json", targetFileName, logger=self.logger).download(self.target)
103 | def loadPackageList(self):
104 | destFile = self.target/targetFileName
105 | if not destFile.is_file():
106 | self.packages = {}
107 | self.packageMap = {}
108 | return
109 | with open(destFile, "r") as f:
110 | self.packages = readPackageList(json.load(f))
111 | self.packageMap = self.__constructPackageNameMap()
112 | def searchPackages(self, searchString):
113 | result = set()
114 | for name, pkg in self.packages.items():
115 | cat = ", ".join(pkg.categories)
116 | if (searchString in name) \
117 | or (searchString in pkg.display_name) \
118 | or (searchString in pkg.description) \
119 | or (searchString in cat):
120 | result.add(pkg)
121 | continue
122 | for fl in pkg.files:
123 | if (searchString in fl.name) \
124 | or (searchString in fl.description) \
125 | or (searchString in fl.author):
126 | result.add(pkg)
127 | return list(result)
128 |
--------------------------------------------------------------------------------
/packagemanager.py:
--------------------------------------------------------------------------------
1 | import json
2 | import os
3 | from pathlib import Path
4 | from os import makedirs
5 | from subprocess import call
6 | from shutil import rmtree
7 |
8 | lazbuildName = "lazbuild" + (".exe" if os.name == "nt" else "")
9 |
10 |
11 | class Package:
12 | def __init__(self, name, directory, date, package_files, installed=[]):
13 | self.name = name
14 | self.directory = directory
15 | self.date = date
16 | self.package_files = package_files
17 | self.installed = set(installed)
18 | def serialize(self):
19 | return {
20 | "name": self.name,
21 | "date": self.date,
22 | "directory": self.directory,
23 | "packages": self.package_files,
24 | "installed": list(self.installed)
25 | }
26 | def deserializePackage(serialized):
27 | return Package(serialized["name"],
28 | serialized["directory"],
29 | serialized["date"],
30 | serialized["packages"],
31 | serialized["installed"])
32 |
33 | class PackageManager:
34 | def __init__(self, target, logger):
35 | self.logger = logger
36 | self.target = target
37 | self.configFile = target/"lpm.json"
38 | self.packages = {}
39 | self.installations = {}
40 | self.selected = None
41 | def load(self):
42 | self.packages = {}
43 | self.installations = {}
44 | if not self.configFile.is_file():
45 | return
46 | with open(self.configFile, "r") as f:
47 | serialized = json.load(f)
48 | for p in [deserializePackage(p) for p in serialized["packages"]]:
49 | self.packages[p.name] = p
50 | for n, p in serialized["installations"].items():
51 | self.installations[n] = Path(p)
52 | self.selected = serialized.get("selected")
53 | def save(self):
54 | installations = {}
55 | for n, p in self.installations.items():
56 | installations[n] = str(p)
57 | serialized = {
58 | "version": 1,
59 | "installations": installations,
60 | "packages": [p.serialize() for _, p in self.packages.items()]
61 | }
62 | if self.selected is not None:
63 | serialized["selected"] = self.selected
64 | with open(self.configFile, "w") as f:
65 | json.dump(serialized, f, indent=2)
66 | def fetchFromDownloader(self, name, downloader, date, packages):
67 | target = self.target/"packages"/name
68 | # remove old if there
69 | if target.is_dir():
70 | rmtree(target)
71 | # download file
72 | downloader.download(target)
73 | # if no package names are given, search for lpks
74 | if len(packages) == 0:
75 | pkgs = target.rglob("*.lpk")
76 | packages = [str(p.relative_to(target)) for p in pkgs]
77 | self.logger.log("Packages found:")
78 | for p in packages:
79 | self.logger.log(p)
80 | # create package
81 | pkg = Package(name, name, date, packages)
82 | # if previously installed, add install information
83 | if name in self.packages:
84 | pkg.installed = self.packages[pkg.name].installed
85 | self.packages[name] = pkg
86 | return True
87 | def fetchFromOPM(self, pkg):
88 | downloader = pkg.getDownloader(self.logger)
89 | packages = [f"{pkg.package_dir}/{fl.getFilename()}" for fl in pkg.files]
90 | return self.fetchFromDownloader(pkg.name, downloader, pkg.file_date, packages)
91 | def getLazbuild(self):
92 | lazarus = self.installations.get(self.selected)
93 | if lazarus is None:
94 | self.logger.error(f"No such lazarus installation found: {self.selected}")
95 | return None
96 | return lazarus/lazbuildName
97 | def installPackage(self, packageName):
98 | # resolve package
99 | pkg = self.packages.get(packageName)
100 | if pkg is None:
101 | self.logger.error(f"Package {packageName} not found")
102 | return False
103 | pkgDir = self.target/"packages"/pkg.directory
104 | #resolve lazbuild
105 | lazbuild = self.getLazbuild()
106 | if lazbuild is None:
107 | return False
108 | # call lazbuild for all lpks
109 | result = True
110 | for fl in pkg.package_files:
111 | self.logger.log(f"installing {fl}")
112 | pkgFile = pkgDir/fl
113 | result = result and call([lazbuild.resolve(), "--add-package-link", pkgFile.resolve()]) == 0
114 | # add lazarus version to installed list
115 | pkg.installed.add(str(self.selected))
116 | return result
117 | def addLazarus(self, name, path):
118 | self.installations[name] = str(path.resolve())
119 | if self.selected is None:
120 | self.selected = name
121 | return True
122 | def removeLazarus(self, name):
123 | if name not in self.installations:
124 | self.logger.error(f"Installation {name} not found")
125 | return False
126 | if self.selected == name:
127 | self.selected = None if len(self.installations) == 0 else self.installations.keys()[0]
128 | del self.installations[name]
129 | return True
130 | def selectLazarus(self, name):
131 | if name is not None and name not in self.installations:
132 | return False
133 | self.selected = name
134 | return True
135 | def packageByPackage(self, lpkName):
136 | for _, pkg in self.packages.items():
137 | for fl in pkg.package_files:
138 | fName = Path(fl).name
139 | if fName == lpkName:
140 | return pkg
141 | return None
142 | def getLazarusbasePackages(self):
143 | lazarus = self.installations.get(self.selected)
144 | compDir = lazarus/"components"
145 | result = ["fcl.lpk", "lcl.lpk", "lclbase.lpk"]
146 | if lazarus is None:
147 | self.logger.error(f"No such lazarus installation found: {self.selected}")
148 | return None
149 | result.extend([p.name.lower() for p in compDir.rglob("*.lpk")])
150 | return result
151 |
--------------------------------------------------------------------------------
/project.py:
--------------------------------------------------------------------------------
1 | from xml.etree import ElementTree
2 | from subprocess import call
3 |
4 | class LazarusProject:
5 | def __init__(self, lpiFile):
6 | self.lpiFile = lpiFile
7 | self.tree = ElementTree.parse(lpiFile)
8 | def build(self, lazbuild, mode=None):
9 | callArgs = [str(lazbuild.resolve())]
10 | if mode is not None:
11 | callArgs.append(f"--build-mode={mode}")
12 | callArgs.append(str(self.lpiFile.resolve()))
13 | return call(callArgs) == 0
14 | def getModes(self):
15 | optNode = self.tree.getroot().find("ProjectOptions")
16 | modeNode = optNode.find("BuildModes")
17 | return [item.attrib["Name"] for item in modeNode if item.tag.startswith("Item")]
18 | def getDependencies(self):
19 | optNode = self.tree.getroot().find("ProjectOptions")
20 | reqNode = optNode.find("RequiredPackages")
21 | if reqNode is None:
22 | return []
23 | return [item[0].attrib["Value"] for item in reqNode]
24 |
--------------------------------------------------------------------------------