From 2b6815e28769f1a9e2c0f5e1044b51b4cffa2e57 Mon Sep 17 00:00:00 2001 From: Arsen Musayelyan Date: Sun, 2 Oct 2022 20:19:50 -0700 Subject: [PATCH] Add docs for version() function --- docs/build-scripts.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/docs/build-scripts.md b/docs/build-scripts.md index ed56ec1..b387dd8 100644 --- a/docs/build-scripts.md +++ b/docs/build-scripts.md @@ -26,6 +26,11 @@ LURE uses build scripts similar to the AUR's PKGBUILDs. This is the documentatio - [checksums](#checksums) - [backup](#backup) - [scripts](#scripts) +- [Functions](#functions) + - [prepare](#prepare) + - [version](#version-1) + - [build](#build) + - [package](#package) --- @@ -225,6 +230,21 @@ All functions start in the `$srcdir` directory The `prepare()` function runs first. It is meant to prepare the sources for building and packaging. This is the function in which patches should be applied, for example, by the `patch` command, and where tools like `go generate` should be executed. +### version + +The `version()` function updates the `version` variable. This allows for automatically deriving the version from sources. This is most useful for git packages, which usually don't need to be changed, so their `version` variable stays the same. + +An example of using this for git: + +```bash +version() { + cd "$srcdir/itd" + printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)" +} +``` + +The AUR equivalent is the [`pkgver()` function](https://wiki.archlinux.org/title/VCS_package_guidelines#The_pkgver()_function) + ### build The `build()` function is where the package is actually built. Use the same commands that would be used to manually compile the software. Often, this function is just one line: