-
-
Notifications
You must be signed in to change notification settings - Fork 41
Different Package Build Systems
As you are making Pacscripts with certain build systems, such as Cargo, CMake, Make, Meson, Poetry, Shell, etc, you should know of some best practices in order to get the most out of your scripts.
There are a couple practices that should be used when using Cargo, such as:
- Using the
Cargo.lock
file, instead of theCargo.toml
file, by supplying the--locked
flag. This is used in order to make sure that you are using precise dependency version specifications chosen by upstream. - Using the
--release
flag, in order to build the fastest and smallest binary. - Use
-j"${NCPU}"
to build with all cores.
All together, your command to build the package should be this:
cargo build -j"${NCPU}" --release --locked
and all together for installation of the binary would be:
build() {
cargo build -j"${NCPU}" --release --locked
}
package() {
install -Dm755 "target/release/binary" -t "${pkgdir}/usr/bin"
}
- Set the package prefix to
/usr
using--prefix=/usr
(as to not default to/usr/local
as mandated by Debian packaging guidelines). - Set the buildtype to
release
, using--buildtype=release
. - Install using
DESTDIR
.
All together, your Pacscript should look similar to this:
prepare() {
# Use `build` as the build directory
meson build --buildtype=release --prefix=/usr
}
build() {
ninja -C build -j"${NCPU}"
}
package() {
DESTDIR="${pkgdir}" ninja -C build install
}
Generally, make
follows a cycle that is very easy to follow. Check with upstream first if they use anything else before running make
, but if they don't have that, generally you run:
-
make -j"${NCPU}"
to build the package with all cores. -
make DESTDIR="${pkgdir}" install
to install the package to the staging area for package creation.
All together your Pacscript might look like this:
build() {
make -j"${NCPU}"
}
package() {
make DESTDIR="${pkgdir}" install
}
Binary packages are one of the easiest package types to make besides -deb
. Most binary packages will have one required command to install the program, and maybe a couple more for the license and documentation if provided. The install
command is recommended because it can create the full directory you're installing to without needing mkdir
, and it offers install permissions all in one command.
package() {
install -Dm755 "binary" -t "${pkgdir}/usr/bin/"
# Or to install to another name
install -Dm755 "binary" "${pkgdir}/usr/bin/other_name"
}