Jump to content

Installing pmbootstrap: Difference between revisions

From postmarketOS Wiki
Add instructions for pmbootstrap autocompletion on the Fish shell
merged into pmbootstrap article, leave redirect behind
Tag: New redirect
 
(7 intermediate revisions by 6 users not shown)
Line 1: Line 1:
{{note|Running postmarketOS, Alpine, Fedora, or Void Linux? Grab pmbootstrap straight from your distribution's package manager (e.g. <code>apk add pmbootstrap</code>)! Note that when using a recent version of Alpine you might have to enable the community repository for this to work, see [https://wiki.alpinelinux.org/wiki/Enable_Community_Repository] on how to do that. You also have to install sudo or doas and set it up so that you user can use it.}}
#REDIRECT [[Pmbootstrap#Installation]]
 
== Requirements ==
* <code>python</code> >=3.6
* <code>openssl</code> or alternative(like <code>libressl</code>)
* Depending on the installation method:
** <code>pip3</code> (possibly shipped with Python)
** <code>git</code>
 
Alpine Linux users also need to install <code>procps</code>:
<syntaxhighlight lang="shell-session">
$ apk add python3 procps
</syntaxhighlight>
 
== pmaports.git ==
pmbootstrap will automatically clone the [https://gitlab.com/postmarketOS/pmaports/ pmaports.git] repository during <code>pmbootstrap init</code> to the work dir of your choice, and afterwards you can look up the full path with <code>pmbootstrap config aports</code>. See [[git workflow]] for more information.
 
== Installing automatically ==
=== Latest release with pip ===
pmbootstrap is up on [https://pypi.org/project/pmbootstrap/ pypi] now, so it can be installed with:
<syntaxhighlight lang="shell-session">
$ pip3 install --user pmbootstrap
</syntaxhighlight>
 
You may need to reload your configuration by running <code>source ~/.profile</code>.
 
That's it. The steps below are for alternative methods of installing <code>pmbootstrap</code>. Read on at [[#Tab completion]] if you are interested.
 
==== Updating ====
 
Updating to the latest version of pmbootstrap can be done like this:
 
<syntaxhighlight lang="shell-session">
$ pip3 install --user --upgrade pmbootstrap
</syntaxhighlight>
 
=== Latest development version from git ===
==== Download pmbootstrap ====
<syntaxhighlight lang="shell-session">
$ git clone https://gitlab.com/postmarketOS/pmbootstrap.git
</syntaxhighlight>
 
==== Install ====
<syntaxhighlight lang="shell-session">
$ cd pmbootstrap && python3 setup.py install
</syntaxhighlight>
 
== Installing manually ==
 
This setup is useful for hacking on pmbootstrap code, because you are directly running the code from your git tree. No need to run setup.py after each change.
 
==== Download pmbootstrap ====
<syntaxhighlight lang="shell-session">
$ git clone https://gitlab.com/postmarketOS/pmbootstrap.git
</syntaxhighlight>
 
==== Create a link ====
If the directory <code>~/.local/bin</code> does not already exist, create it with:
<syntaxhighlight lang="shell-session">
$ mkdir -p ~/.local/bin
</syntaxhighlight>
 
Create a symbolic link in <code>~/.local/bin</code> named <code>pmbootstrap</code>:
<syntaxhighlight lang="shell-session">
$ ln -s "$PWD/pmbootstrap/pmbootstrap.py" ~/.local/bin/pmbootstrap
</syntaxhighlight>
 
==== Test installation ====
To test that pmbootstrap is installed correctly, open a new terminal and run:
<syntaxhighlight lang="shell-session">
$ pmbootstrap --version
</syntaxhighlight>
 
If this returns something like <code>pmbootstrap: command not found</code> instead of a version number, ensure that the following lines are in <code>~/.profile</code> (zsh: <code>~/.zprofile</code>):
<syntaxhighlight lang="shell">
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/.local/bin" ] ; then
    PATH="$HOME/.local/bin:$PATH"
fi
</syntaxhighlight>
Then open a new terminal and try again.
 
==== Uninstalling after installing manually ====
<source lang="shell-session">
$ export WORK=$(pmbootstrap config work)
$ # Let's say that pmbootstrap is in ~/pmos/pmbootstrap/
$ pmbootstrap zap
...
$ pmbootstrap shutdown
...
$ rm -rf $WORK
$ rm -rf ~/pmos/pmbootstrap
$ rm ~/.config/pmbootstrap.cfg
$ rm ~/.local/bin/pmbootstrap
</source>
 
== Tab completion ==
[https://en.wikipedia.org/wiki/Command-line_completion Tab completion] is an optional feature that saves you time by automatically filling in the rest of a command when you press the tab key. You can also see a list of possible commands by double pressing the tab key.
 
Install [https://kislyuk.github.io/argcomplete argcomplete] with:
<syntaxhighlight lang="shell-session">
$ pip3 install --user argcomplete
</syntaxhighlight>
 
Alternatively you can use your distro package manager to install <code>argcomplete</code>, for example in Ubuntu:
<syntaxhighlight lang="shell-session">
$ sudo apt install python-argcomplete
</syntaxhighlight>
For Ubuntu 20.04+:
<syntaxhighlight lang="shell-session">
$ sudo apt install python3-argcomplete
</syntaxhighlight>
in Gentoo:
<syntaxhighlight lang="shell-session">
$ sudo emerge dev-python/argcomplete
</syntaxhighlight>
in Arch Linux:
<syntaxhighlight lang="shell-session">
$ sudo pacman -S python-argcomplete
</syntaxhighlight>
in Fedora:
<syntaxhighlight lang="shell-session">
$ dnf install python3-argcomplete
</syntaxhighlight>
 
Next, do one of the following depending on the shell you use.
 
==== Bash ====
Add the following line to <code>~/.bashrc</code>:
<syntaxhighlight lang="shell">
eval "$(register-python-argcomplete pmbootstrap)"
</syntaxhighlight>
 
For Ubuntu 20.04+:
<syntaxhighlight lang="shell">
eval "$(register-python-argcomplete3 pmbootstrap)"
</syntaxhighlight>
 
 
Then reload your configuration by opening a new terminal or by running <code>source ~/.bashrc</code>.
 
==== Zsh ====
Add the following lines to <code>~/.zshrc</code>:
<syntaxhighlight lang="shell">
autoload bashcompinit
bashcompinit
eval "$(register-python-argcomplete pmbootstrap)"
</syntaxhighlight>
 
Then reload your configuration by opening a new terminal or by running <code>source ~/.zshrc</code>.
 
==== Fish ====
Run the following to add an autocomplete file for pmbootstrap:
<syntaxhighlight lang="shell">
register-python-argcomplete --shell fish pmbootstrap > ~/.config/fish/completions/pmbootstrap.fish
</syntaxhighlight>
 
== Troubleshooting during installation==
===ERROR: We have split the aports repository from the pmbootstrap repository (#383). Please run 'pmbootstrap init' again to clone it===
According to [https://www.reddit.com/r/postmarketOS/comments/hkop88/pmbootstrap_setup/ this reddit post] you need to :
  - Delete ~/.config/pmbootstrap.cfg  => command rm
  - Delete ~/.local/var/pmbootstrap
  - Run the pmbootstrap init again
 
In command line :
  rm  ~/.config/pmbootstrap.cfg
  rm -r ~/.local/var/pmbootstrap
  pmbootstrap init
 
 
== See also ==
* {{MR|1656}} implement bash tab completion
 
[[Category:Guide]]

Latest revision as of 18:39, 9 January 2023