This would make debugging the version number easier. We could add the following information in the system partition somewhere:
I suggest using /etc/os-release and make it somewhat compliant to lsb_release:
PRETTY_NAME="postmarketOS ${version}"
NAME="postmarketOS"
VERSION_ID="${version}"
VERSION="${version}"
ID=postmarketos
ID_LIKE=alpine
HOME_URL="http://www.postmarketos.org/"
SUPPORT_URL="https://github.com/postmarketOS"
BUG_REPORT_URL="https://github.com/postmarketOS"
PMOS_HASH="${hash}"
How would you do to have $version and $hash variables available in the post-install script?
One idea is writing these values during the install stage to some file in the device rootfs (e.g. /tmp/version) and then source this file from the post-install script. What do you think? Any simpler option?
I think the easiest option would be to write the entire /etc/os-release from within the Python code for now (during install).
When would VERSION be set? As pmbootstrap is now, it's more of a rolling release, it seems that for this to be meaningful there would need to be discrete "releases".
Or, maybe VERSION is the git hash? That doesn't seem like a good solution if/when the project becomes more stable.
It would be the current git rel which might be a tag or a hash
Or, maybe
VERSIONis the git hash? That doesn't seem like a good solution if/when the project becomes more stable.
True. I imagine that at some point we put the aports in an extra repository, and release stable versions of pmbootstrap (which we could put up on pip and maybe provide it for various Linux distributions, just like you can install debootstrap pretty much everywhere).
How about using the current version tag plus the hash as VERSION value? That way it would be upwards-compatible. Example:
0.2.0-asdfasdf (where 0.2.0 is from pmb/config/__init__.py and asdfasdf would be the first 8 letters of the last git hash).
Including the hash is important so you can see if the build is from something in master or from a branch, i'm for always including it.
Following @MartijnBraam's comment, I've tried to implement this feature in two different ways but none of these work.
https://github.com/PabloCastellano/pmbootstrap/commit/e0340d83c6d2a75636c53dcdef31a171a11bd94c (the file doesn't get created. Is it because we cannot use ">" in the command or something else?)
https://github.com/PabloCastellano/pmbootstrap/commit/1ad63c3f5de94d06eed71309a88f68cef87614b1 (Permission denied, since the script runs with user permissions).
Any pointers?
@ollieparanoid How would you write it from within the Python code?
Can you use pmb.chroot.user or pmb.chroot.root?
On August 20, 2017 6:06:35 PM PDT, Pablo Castellano notifications@github.com wrote:
Following @MartijnBraam's comment, I've tried to implement this feature
in two different ways but none of these work.https://github.com/PabloCastellano/pmbootstrap/commit/e0340d83c6d2a75636c53dcdef31a171a11bd94c
(the file doesn't get created. Is it because we cannot use ">" in the
command or something else?)https://github.com/PabloCastellano/pmbootstrap/commit/1ad63c3f5de94d06eed71309a88f68cef87614b1
(Permission denied, since the script runs with user permissions).Any pointers?
@ollieparanoid How would you write it from within the Python code?--
You are receiving this because you commented.
Reply to this email directly or view it on GitHub:
https://github.com/postmarketOS/pmbootstrap/issues/324#issuecomment-323624449
@craftyguy In my first try, I used pmb.chroot.root as
pmb.chroot.root(args, ["echo", os_release, ">", "/etc/os-release"], suffix)
But the file doesn't get created
@PabloCastellano here is the solution/workaround for the redirection in chroot
@PabloCastellano: you are right, for security reasons, the commands do not directly get executed in a shell.
There are two methods used for such cases throughout the pmbootstrap source:
Write the file with Python to args.work + "/chroot_" + suffix + "/tmp", then copy the file with pmb.chroot.root()to the right location andchown` it (what @drebrez linked)
Use something like ["sh", "-c", "echo a > /tmp/test"] (but when you have variables involved in the command string, then you should use shlex to escape them properly, and it gets ugly).
For writing /etc/os-release I recommend method 1.
Thanks for the advices!
PR is ready. This is the content my /etc/os-release now
PRETTY_NAME="postmarketOS 0.2.0"
NAME="postmarketOS"
VERSION_ID="0.2.0"
VERSION="0.2.0-783a0dde"
ID="postmarketos"
ID_LIKE="alpine"
HOME_URL="http://www.postmarketos.org/"
SUPPORT_URL="https://github.com/postmarketOS/"
BUG_REPORT_URL="https://github.com/postmarketOS/"
PMOS_HASH="783a0dde1645b2d6c9ebaa434206291b304c324c"
Also, documented the workaround to redirect shell input/output in the development guide.
Most helpful comment
I suggest using
/etc/os-releaseand make it somewhat compliant to lsb_release: