Commit Graph

29 Commits

Author SHA1 Message Date
Oliver Smith 5d28c5ccf3
pmbootstrap.py: move all features to pmb:main()
Prepare to modernize the python packaging. pmbootstrap.py will not be
part of the packaging, so add a note there and move both features
(python version check, ^C check) to pmb/__init__.py:main().

Reviewed-by: Luca Weiss <luca@z3ntu.xyz>
Link: https://lists.sr.ht/~postmarketos/pmbootstrap-devel/%3C20230407233026.1712-3-ollieparanoid@postmarketos.org%3E
2023-04-15 01:44:37 +02:00
Oliver Smith 49cd288078
pmbootstrap.py: require at least python 3.7
The minimum python version was already increased to 3.7, but it wasn't
adjusted here yet.

Reviewed-by: Luca Weiss <luca@z3ntu.xyz>
Link: https://lists.sr.ht/~postmarketos/pmbootstrap-devel/%3C20230407233026.1712-2-ollieparanoid@postmarketos.org%3E
2023-04-15 01:44:36 +02:00
Oliver Smith 9975d373b0
Bump copyright to 2023 2023-01-22 19:18:06 +01:00
Oliver Smith 6f6a3b0408
Happy new year 2022! 2022-01-02 22:39:14 +01:00
Newbyte 446a8fc430
pmbootstrap.py: Check which version of Python pmbootstrap is run with (MR 2118)
This prevents people from getting strange syntax errors if they
accidentally run pmbootstrap with e.g. Python 2.
2021-10-01 22:46:23 -07:00
Newbyte 73d242485a
pmbootstrap.py: Don't print stacktrace when KeyboardInterrupt is caught (MR 2078)
This looks obnoxious and I cannot think of a single time I found it
useful, so let's make it prettier.
2021-07-05 12:19:35 +02:00
Oliver Smith 1c791da482
treewide: bump copyright to 2021 2021-01-07 23:30:47 +01:00
Oliver Smith f21c216a26
Cosmetic: use SPDX license header (!1877)
While at it, also remove unnecessary "#!/usr/bin/env python3" in files
that only get imported, and adjust other empty/comment lines in the
beginnings of the files for consistency.

This makes files easier to read, and makes the pmbootstrap codebase more
consistent with the build.postmarketos.org codebase.
2020-02-24 03:11:10 +03:00
Oliver Smith 948e3f931f
Change copyright to 2020 2020-01-06 02:43:00 +01:00
Oliver Smith f16bdaf0ca
Update copyright to 2019
Happy new year \o/
2019-01-02 09:31:20 +01:00
Grant Miller 7eaf9de000 Implement bash tab completion 2018-08-27 21:35:05 +00:00
Oliver Smith 7750c1dd40
Happy new year! (update copyright to 2018) 2018-01-04 04:53:35 +01:00
Yuval Adam b6003a2815 Close #327: Add initial setup.py (#443) 2017-09-02 19:30:40 +00:00
Oliver Smith 1aae094b50 Close #174: Put frontend functions in extra file (#185) 2017-07-18 19:01:11 +00:00
clayton craft fc3e4bfe4a Fix PR #160, Fix #172 (#173)
Thanks craftyguy!
Probably meant to call 'globals()' and not 'locals()'. As @MartijnBraam
pointed out in IRC, probably best to have these functions in a separate
module so they can be parsed with getattr
2017-07-17 18:41:39 +00:00
cclauss a502b50475 Reduce complexity in pmbootstrap.py (#160)
Thanks, @cclauss!

* Dictionary lookup of event loop actions

This was kind of an experiment that adds lots of blank lines to this script -- feel free to reject it.

The observation that triggered this was that in main() all actions can execute using just one parameter, args.  This means that it is possible to use args.action to do a dict lookup to get the corresponding function.  This approach adds tons of blank lines to the script in exchange for a rapid seek to the action implementation and a substantial reduction of the McCabe complexity of main().

$ __flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics__
```
./pmbootstrap.py:43:1: C901 'main' is too complex (23)
./pmb/aportgen/core.py:38:1: C901 'rewrite' is too complex (17)
[ ... ]
```

* Remove action_dict and use locals() instead
2017-07-17 15:38:45 +00:00
Oliver Smith 34622368d9
Fix #107: Grsec check: read file in /proc as root 2017-07-11 18:50:40 +02:00
Oliver Smith 51bdc24315 Properly rebuild/install packages when something changed (Fix #120, #108, #131) (#129)
TLDR: Always rebuild/install packages when something changed when executing "pmbootstrap install/initfs/flash", more speed in dependency resolution.
---
pmbootstrap has already gotten some support for "timestamp based rebuilds", which modifies the logic for when packages should be rebuilt. It doesn't only consider packages outdated with old pkgver/pkgrel combinations, but also packages, where a source file has a newer timestamp, than the built package has.

I've found out, that this can lead to more rebuilds than expected. For example, when you check out the pmbootstrap git repository again into another folder, although you have already built packages. Then all files have the timestamp of the checkout, and the packages will appear to be outdated. While this is not largely a concern now, this will become a problem once we have a binary package repository, because then the packages from the binary repo will always seem to be outdated, if you just freshly checked out the repository.

To combat this, git gets asked if the files from the aport we're looking at are in sync with upstream, or not. Only when the files are not in sync with upstream and the timestamps of the sources are newer, a rebuild gets triggered from now on.

In case this logic should fail, I've added an option during "pmbootstrap init" where you can enable or disable the "timestamp based rebuilds" option.

In addition to that, this commit also works on fixing #120: packages do not get updated in "pmbootstrap install" after they have been rebuilt. For this to work, we specify all packages explicitly for abuild, instead of letting abuild do the resolving. This feature will also work with the "timestamp based rebuilds".

This commit also fixes the working_dir argument in pmb.helpers.run.user, which was simply ignored before.

Finally, the performance of the dependency resolution is faster again (when compared to the current version in master), because the parsed apkbuilds and finding the aport by pkgname gets cached during one pmbootstrap call (in args.cache, which also makes it easy to put fake data there in testcases).

The new dependency resolution code can output lots of verbose messages for debugging by specifying the `-v` parameter. The meaning of that changed, it used to output the file names where log messages come from, but no one seemed to use that anyway.
2017-07-10 15:23:43 +00:00
Oliver Smith 05e79c1d5c
Fix #107: Meaningful error for grsecurity/chroot_deny_chmod 2017-07-06 21:16:00 +02:00
Oliver Smith 10fd0f312d
Display short troubleshooting URL on exception 2017-07-06 19:09:45 +02:00
Oliver Smith fcc5501a44
Slightly improve error handling
* Fix: Do not swallow traces when crashing before log init (e.g.
  during argument parsing)
* Show a link to the troubleshooting page, when an error happens
* (Formatting done by autopep8 in pmb/config/init.py)
2017-06-27 00:23:21 +02:00
Oliver Smith fb1e8ec73b
Update min apk version/add more apk version checks
* Minimum version: 2.7.2 (which fixes two CVEs)
* Check the minimum apk version before doing something with apk and
  before entering the chroot manually (previously, it has just checked
  the apk-tools-static version, which gets used to set up the chroot)
* Reword the message for an outdated APK version. Most likely it is
  just the outdated http cache, instead of a man-in-the-middle attack.

See also:
b849b481a0
2017-06-23 17:04:49 +02:00
Oliver Smith 112dc5e70c
Move challenge code to own folder (#64)
...and add a stub for 'pmbootstrap challenge APKINDEX.tar.gz'.
2017-06-17 17:42:28 +02:00
Oliver Smith 3a3dd8063f
Merge branch 'lazy-reproducible-builds'
We have "lazy reproducible builds" now. What I mean by that is, that
the resulting "apk" archive is not fully reproducible, but all binaries
inside it are. This is necessary to kick-off the binary repo, which is
in turn required to get the testsuite going on Travis. Read #64 for more
information.

Usage:
```
pmbootstrap build hello-world --buildinfo
pmbootstrap challenge /tmp/path/to/hello-world-1-r2.apk
```

The "--buildinfo" parameter generates a "buildinfo.json", which contains
the versions of all dependencies. It is not very optimizied, so this
is a performance bottleneck and takes 10 seconds (which is quite much
considering that the hello-world package builds in less than a second).
This can be improved in the future, and then the buildinfo parameter
may become the default.
2017-06-11 14:19:57 +02:00
Oliver Smith 18339d0a14
Close #69: add 'pmbootstrap initfs' and improve initfs workflow
* allows to build/extract/list initramfs, add/del hook
* rebuild the initfs whenever running install or trying to flash/boot it
* flasher flash/boot: automatically set up a minimal rootfs with kernel and initfs,
  if it does not exist yet
2017-06-09 19:22:25 +02:00
Oliver Smith 32ad868cdc
apk.installed(): Retuns all packages and versions now
pmb.chroot.apk.installed() used to return only the explicitly installed
packages. This is not good enough for the initfs check functions (and
especially for the "lazy reproducible builds", from which branch this
commit was cherry picked).

This commit introduces more noise for the logfile - if this becomes
a problem, raise your voice in the issues tracker and we'll do something
about it.

(This commit also changes minor code styling in other files, I did
not run autopep8 last time, because flake8 didn't complain...)
2017-06-09 18:01:39 +02:00
Oliver Smith 50195a6af2
pmbootstrap log: Add a -n/--lines parameter (like tail has)
...also increase the default line count to 30, so it's easier to
spot an error if you didn't have the log open when it happened.

This parameter also works for 'pmbootstrap log_distccd', for consistency.
2017-06-08 18:15:38 +02:00
Oliver Smith 63ac1f5f6c
WIP #64: "lazy reproducible builds" 2017-06-05 03:58:45 +02:00
Oliver Smith ae950fb9f7
Hello, there! 2017-05-26 22:08:45 +02:00