~comcloudway/cabin

948eebcaf73a9da6a6593fae2997a57bbc87f6ec — Jakob Meier 1 year, 1 month ago 5447a26
Updated documentation
2 files changed, 118 insertions(+), 9 deletions(-)

M README.org
M src/main.rs
M README.org => README.org +111 -6
@@ 12,6 12,35 @@ to use the [[gitlab.alpinelinux.org/alpine/aports/][offical aports repo]] somewh
by indexing and compiling packages locally.

** Usage

*** Help
You can use the help command to view a command description
#+begin_src bash
$ cabin

Simple alpine package builder with dependency resolution using abuild

Usage: cabin <COMMAND>

Commands:
  list       Lists all known packages
  scan       Rescans all folders
  build-all  Build all packages in repo
  build      Builds the package
  info       Displays package information
  search     Searches the database for a package with the name or containing the name
  tree       show a list of all dependencies
  help       Print this message or the help of the given subcommand(s)

Options:
  -h, --help     Print help
  -V, --version  Print version
#+end_src

You can also combine the commands with
~help~ to view available options

*** Scan
First of all,
you have to generate a database file for the ~aports~ directory.
#+begin_src bash


@@ 20,21 49,94 @@ cabin scan
This will automatically scan the current folder (~.~),
and all child-folders recursively and save the database to ~db.yml~.

Now you're essentially done,
try ~list~-ing all available packages,
or ~search~-ing for a specific one.
Maybe use ~cabin help~ for more option.
#+begin_src bash
$ cabin help scan

Searches the folder for APKBUILDs recursively and builds a local database

Usage: cabin scan [FOLDER] [DB]

Arguments:
  [FOLDER]  workspace
  [DB]      package database path

Options:
  -h, --help  Print help
#+end_src

*NOTE*: you have to rerun the ~scan~ command
every time the ~aports~ change.
*** List
#+begin_src bash
$ cabin help list

Lists all known packages

Usage: cabin list [OPTIONS]

Options:
  -d, --db <DB>  package database path
  -h, --help     Print help
#+end_src
*** Search
unimplemented
*** Build
To build a given package in the repo,
run the following command:
#+begin_src bash
cabin build <package>
#+end_src.
#+end_src
Keep in mind,
that you have to add ~$HOME/packages~ to ~/etc/apk/repositories~
if you want to use the dependency resolution / auto build feature.

Also you have to rerun the ~scan~ command every time the ~aports~ change.
#+begin_src bash
$ cabin help build

Builds the package

Usage: cabin build [OPTIONS] <PACKAGE>

Arguments:
  <PACKAGE>  the packagename

Options:
  -a, --arch <ARCH>  build the package for a target architecture requires abuild-rootbld and qemu-binfmt to be installed (for the given architecture) and the .rootbld-repositories file to be configured correctly (even if set to host architecture)
  -r                 disables dependency resolution wont compile the dependencies locally however this will still pass -r to abuild and fetch the prebuild packages from upstream
  -d, --db <DB>      package database path
  -v                 allows the build log to be toggled on and off
  -h, --help         Print help
#+end_src
*** Build All
#+begin_src bash
$ cabin help build-all

Build all packages in repo

Usage: cabin build-all [OPTIONS]

Options:
  -a, --arch <ARCH>  build the package for a target architecture requires abuild-rootbld and qemu-binfmt to be installed (for the given architecture) and the .rootbld-repositories file to be configured correctly (even if set to host architecture)
  -d, --db <DB>      package database path
  -v                 allows the build log to be toggled on and off
  -h, --help         Print help
#+end_src
*** Tree
#+begin_src bash
$ cabin help tree

show a list of all dependencies

Usage: cabin tree [OPTIONS] <PACKAGE>

Arguments:
  <PACKAGE>  the packagename

Options:
  -d, --db <DB>  package database path
  -l             shows only local dependencies, that can be found in the local database will also topologically sort the dependencies
  -h, --help     Print help
#+end_src

** Dependencies
*** Compile-time


@@ 46,6 148,9 @@ just follow [[https://rustup.rs/][the official setup instructions]].
*** Runtime
- ~apk~ (to install packages)
- ~abuild~ (to build packages)
- ~qemu-binfmt~ (and the user packages for the given architecture,
  only needed when building with ~-a~ (~arch~)
  set to an architecture other than the host architecture)

Assuming you are running [[alpinelinux.org/][Alpine Linux]],
you can use the following command to install ~abuild~

M src/main.rs => src/main.rs +7 -3
@@ 13,8 13,10 @@ enum Commands {
        #[arg(short='d',long)]
        db: Option<PathBuf>
    },
    /// Rescans all folders
    /// Searches the folder for APKBUILDs recursively
    /// and builds a local database
    Scan {
        /// workspace
        folder: Option<PathBuf>,
        /// package database path
        db: Option<PathBuf>


@@ 22,7 24,8 @@ enum Commands {
    /// Build all packages in repo
    BuildAll {
        /// build the package for a target architecture
        /// requires abuild-rootbld to be installed,
        /// requires abuild-rootbld and qemu-binfmt to be installed
        /// (for the given architecture)
        /// and the .rootbld-repositories file to be configured correctly
        /// (even if set to host architecture)
        #[arg(short='a',long)]


@@ 39,7 42,8 @@ enum Commands {
        /// the packagename
        package: String,
        /// build the package for a target architecture
        /// requires abuild-rootbld to be installed,
        /// requires abuild-rootbld and qemu-binfmt to be installed
        /// (for the given architecture)
        /// and the .rootbld-repositories file to be configured correctly
        /// (even if set to host architecture)
        #[arg(short='a',long)]