Home

Awesome

ppkg

A portable package builder/manager for Unix-like system.

Caveats

Two implementations

This software provides two implementations:

implemented in languagebranch
implemented in POSIX Shellmaster
implemented in Cc

In theroy, these two implementations should have the same behaver except for have bugs.

Using ppkg via GitHub Actions

In this way, you will be liberated from the rut of setting up the build environmemt.

In this way, all you need to do is just clicking the buttons and waiting for finishing. After finishing, a url refers to a zip archive will be provided to download.

For more details please refer to https://github.com/leleliu008/ppkg-package-manually-build

Install POSIX-Shell-based ppkg via curl

curl -LO https://raw.githubusercontent.com/leleliu008/ppkg/master/ppkg
chmod a+x ppkg
./ppkg setup

Install POSIX-Shell-based ppkg via wget

wget https://cdn.jsdelivr.net/gh/leleliu008/ppkg/ppkg
chmod a+x ppkg
./ppkg setup

Build from C source locally dependencies

dependencyrequired?purpose
GCC or LLVM+clangrequiredfor compiling C source code
cmakerequiredfor generating build.ninja
ninjarequiredfor doing jobs that read from build.ninja
pkg-config>=0.18requiredfor finding libraries
janssonrequiredfor parsing and creating JSON.
libyamlrequiredfor parsing formula files whose format is YAML.
libgit2requiredfor updating formula repositories.
libcurlrequiredfor http requesting support.
opensslrequiredfor https requesting support and SHA-256 sum checking support.
libarchiverequiredfor uncompressing .zip and .tar.* files.
zlibrequiredfor compress and uncompress data.
pcre2for Regular Expressions support. only required on OpenBSD.

Build from C source locally via ppkg

ppkg install ppkg

Build from C source locally via xcpkg

xcpkg install ppkg

Build from C source locally using vcpkg

# install g++ curl zip unzip tar git

git clone https://github.com/microsoft/vcpkg.git
cd vcpkg
./bootstrap-vcpkg.sh
export VCPKG_ROOT="$PWD/vcpkg"
export PATH="$VCPKG_ROOT:$PATH"

vcpkg install curl openssl libgit2 libarchive libyaml jansson

git clone --depth=1 --branch=c https://github.com/leleliu008/ppkg
cd ppkg

cmake -S . -B   build.d -G Ninja -DCMAKE_INSTALL_PREFIX=/usr/local -DCMAKE_TOOLCHAIN_FILE=$VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake
cmake --build   build.d
cmake --install build.d

Build from C source locally via HomeBrew

brew install --HEAD leleliu008/fpliu/ppkg

Build from C source locally using your system's default package manager

Ubuntu

apt -y update
apt -y install git cmake ninja-build pkg-config gcc libcurl4 libcurl4-openssl-dev libgit2-dev libarchive-dev libyaml-dev libjansson-dev zlib1g-dev

git clone --depth=1 --branch=c https://github.com/leleliu008/ppkg
cd ppkg

cmake -S . -B   build.d -G Ninja -DCMAKE_INSTALL_PREFIX=/usr/local
cmake --build   build.d
cmake --install build.d

Fedora

dnf -y update
dnf -y install git cmake ninja-build pkg-config gcc libcurl-devel libgit2-devel libarchive-devel libyaml-devel jansson-devel zlib-devel

git clone --depth=1 --branch=c https://github.com/leleliu008/ppkg
cd ppkg

cmake -S . -B   build.d -G Ninja -DCMAKE_INSTALL_PREFIX=/usr/local
cmake --build   build.d
cmake --install build.d

ArchLinux

pacman -Syyuu --noconfirm
pacman -S     --noconfirm git cmake ninja pkg-config gcc curl openssl libgit2 libarchive libyaml jansson zlib

git clone --depth=1 --branch=c https://github.com/leleliu008/ppkg
cd ppkg

cmake -S . -B   build.d -G Ninja -DCMAKE_INSTALL_PREFIX=/usr/local
cmake --build   build.d
cmake --install build.d

AlpineLinux

apk add git cmake ninja pkgconf gcc libc-dev curl-dev openssl-dev libgit2-dev libarchive-dev yaml-dev jansson-dev zlib-dev

git clone --depth=1 --branch=c https://github.com/leleliu008/ppkg
cd ppkg

cmake -S . -B   build.d -G Ninja -DCMAKE_INSTALL_PREFIX=/usr/local
cmake --build   build.d
cmake --install build.d

VoidLinux

xbps-install -Suy xbps
xbps-install -Suy cmake ninja gcc pkg-config libcurl-devel libgit2-devel libarchive-devel libyaml-devel jansson-devel zlib-devel

git clone --depth=1 --branch=c https://github.com/leleliu008/ppkg
cd ppkg

cmake -S . -B   build.d -G Ninja -DCMAKE_INSTALL_PREFIX=/usr/local
cmake --build   build.d
cmake --install build.d

Gentoo Linux

emerge dev-vcs/git cmake dev-util/ninja gcc pkg-config net-misc/curl dev-libs/libgit2 libarchive dev-libs/libyaml dev-libs/jansson dev-libs/zlib

git clone --depth=1 --branch=c https://github.com/leleliu008/ppkg
cd ppkg

cmake -S . -B   build.d -G Ninja -DCMAKE_INSTALL_PREFIX=/usr/local
cmake --build   build.d
cmake --install build.d

openSUSE

zypper update  -y
zypper install -y git cmake ninja gcc pkg-config libcurl-devel libgit2-devel libarchive-devel libyaml-devel libjansson-devel zlib-devel

git clone --depth=1 --branch=c https://github.com/leleliu008/ppkg
cd ppkg

cmake -S . -B   build.d -G Ninja -DCMAKE_INSTALL_PREFIX=/usr/local
cmake --build   build.d
cmake --install build.d

FreeBSD and DragonFlyBSD

pkg install -y git cmake ninja pkgconf gcc curl openssl libgit2 libarchive libyaml jansson zlib

git clone --depth=1 --branch=c https://github.com/leleliu008/ppkg
cd ppkg

cmake -S . -B   build.d -G Ninja -DCMAKE_INSTALL_PREFIX=/usr/local
cmake --build   build.d
cmake --install build.d

OpenBSD

pkg_add git cmake ninja pkgconf llvm curl libgit2 libarchive libyaml jansson zlib

git clone --depth=1 --branch=c https://github.com/leleliu008/ppkg
cd ppkg

cmake -S . -B   build.d -G Ninja -DCMAKE_INSTALL_PREFIX=/usr/local
cmake --build   build.d
cmake --install build.d

NetBSD

pkgin -y install git mozilla-rootcerts cmake ninja-build pkg-config clang curl openssl libgit2 libarchive libyaml jansson zlib

mozilla-rootcerts install

git clone --depth=1 --branch=c https://github.com/leleliu008/ppkg
cd ppkg

cmake -S . -B   build.d -G Ninja -DCMAKE_INSTALL_PREFIX=/usr/local
cmake --build   build.d
cmake --install build.d

~/.ppkg

all relevant directories and files are located under ~/.ppkg directory.

ppkg command usage

environment variables

Note: some commonly used environment variables are override by this software, these are CC, CXX, CPP, AS, AR, LD, CFLAGS, CPPFLAGS, LDFLAGS, PKG_CONFIG_LIBDIR, PKG_CONFIG_PATH, ACLOCAL_PATH

ppkg formula scheme

a ppkg formula is a YAML format file which is used to config a ppkg package's meta-information including one sentence description, package version, installation instructions, etc.

a ppkg formula's filename suffix must be .yml

a ppkg formula'a filename prefix would be treated as the package name.

a ppkg formula'a filename prefix must match the regular expression partten ^[A-Za-z0-9+-._@]{1,50}$

a ppkg formula's file content only has one level mapping and shall has following KEY:

KEYrequired?overview
pkgtypeoptionalindicates what type of this package. value shall be any one of exe, pie, lib, exe+lib.<br>To exe type package, ppkg would add --static -static options to LDFLAGS if --static install option is given.<br>To pie type package, it means that it doesn't support fully statically linking, it is supposed to be dynamically linked.<br>If this mapping is not present, ppkg will determine the package type by package name, if a package name starts/ends with lib, it would be recognized as type lib, otherwise, it would be recognized as type exe
summaryrequireddescribe this package in one sentence.
licenseoptionala space-separated list of SPDX license short identifiers
versionoptionalthe version of this package.<br>If this mapping is not present, it will be calculated from src-url, if src-url is also not present, it will be calculated from running time as format date +%Y.%m.%d
web-urloptionalthe home webpage of this package.<br>If this mapping is not present, git-url must be present.
git-urloptionalthe source code git repository.<br>If src-url is not present, this mapping must be present.
git-refoptionalreference: https://git-scm.com/book/en/v2/Git-Internals-Git-References <br>example values: HEAD refs/heads/master refs/heads/main refs/tags/v1, default value is HEAD
git-shaoptionalthe full git commit id, 40-byte hexadecimal string, if git-ref and git-sha both are present, git-sha takes precedence over git-ref
git-nthoptionaltell ppkg that how many depth commits would you like to be fetched. default is 1, this would save your time and storage. If you want to fetch all commits, set this to 0
src-urloptionalthe source code download url of this package.<br>If value of this mapping ends with one of .zip .tar.xz .tar.gz .tar.lz .tar.bz2 .tgz .txz .tlz .tbz2 .crate, it will be uncompressed to $PACKAGE_WORKING_DIR/src when this package is installing, otherwise, it will be copied to $PACKAGE_WORKING_DIR/src<br>also support format like dir://DIR
src-urioptionalthe mirror of src-url.
src-shaoptionalthe sha256sum of source code.<br>src-sha and src-url must appear together.
fix-urloptionalthe patch file download url of this package.<br>If value of this mapping ends with one of .zip .tar.xz .tar.gz .tar.lz .tar.bz2 .tgz .txz .tlz .tbz2 .crate, it will be uncompressed to $PACKAGE_WORKING_DIR/fix when this package is installing, otherwise, it will be copied to $PACKAGE_WORKING_DIR/fix.
fix-urioptionalthe mirror of fix-url.
fix-shaoptionalthe sha256sum of patch file.<br>fix-sha and fix-url must appear together.
fix-optoptionaloptions to be passed to patch command. default value is -p1.
patchesoptionalmultiple lines of <fix-sha>|<fix-url>[|fix-uri][|fix-opt].
res-urloptionalother resource download url of this package.<br>If value of this mapping ends with one of .zip .tar.xz .tar.gz .tar.lz .tar.bz2 .tgz .txz .tlz .tbz2 .crate, it will be uncompressed to $PACKAGE_WORKING_DIR/res when this package is installing, otherwise, it will be copied to $PACKAGE_WORKING_DIR/res.
res-urioptionalthe mirror of res-url.
res-shaoptionalthe sha256sum of resource file.<br>res-sha and res-url must appear together.
reslistoptionalmultiple lines of <res-sha>|<res-url>[|res-uri][|unpack-dir][|N]. unpack-dir is relative to $PACKAGE_WORKING_DIR/res, default value is empty. N is --strip-components=N
dep-pkgoptionala space-separated list of ppkg packages that are depended by this package when installing and/or runtime, which will be installed via ppkg.
dep-uppoptionala space-separated list of uppm packages that are depended by this package when installing and/or runtime, which will be installed via uppm.
dep-pymoptionala space-separated list of python packages that are depended by this package when installing and/or runtime, which will be installed via pip3.
dep-plmoptionala space-separated list of perl modules that are depended by this package when installing and/or runtime, which will be installed via cpan.
ccflagsoptionalappend to CFLAGS
xxflagsoptionalappend to CXXFLAGS
ppflagsoptionalappend to CPPFLAGS
ldflagsoptionalappend to LDFLAGS
bsystemoptionalbuild system name.<br>values can be one or a combination of autogen autotools configure cmake cmake+gmake cmake+ninja meson xmake gmake ninja cargo go rake
bscriptoptionalthe directory where the build script is located in, relative to PACKAGE_WORKING_DIR. build script such as configure, Makefile, CMakeLists.txt, meson.build, Cargo.toml, etc.
binbstdoptionalwhether to build in the directory where the build script is located in, otherwise build in other directory.<br>value shall be 0 or 1. default value is 0.
movableoptionalwhether can be moved/copied to other locations.<br>value shall be 0 or 1. default value is 1.
paralleloptionalwhether to allow build system running jobs in parallel.<br>value shall be 0 or 1. default value is 1.
onstartoptionalPOSIX shell code to be run when this package's formula is loaded.<br>PWD is $PACKAGE_WORKING_DIR
onreadyoptionalPOSIX shell code to be run when this package's needed resources all are ready.<br>PWD is $PACKAGE_BSCRIPT_DIR
onfinaloptionalPOSIX shell code to be run when this package is successfully installed.<br>PWD is $PACKAGE_INSTALL_DIR
do12345optionalPOSIX shell code to be run for native build.<br>It is only meaningful when requesting for cross building.<br>It is running in a separated process.
dopatchoptionalPOSIX shell code to be run to apply patches manually.<br>PWD is $PACKAGE_BSCRIPT_DIR
prepareoptionalPOSIX shell code to be run to do some additional preparation.<br>PWD is $PACKAGE_BSCRIPT_DIR
installoptionalPOSIX shell code to be run when user run ppkg install <PKG>. If this mapping is not present, ppkg will run default install code according to bsystem.<br>PWD is $PACKAGE_BSCRIPT_DIR if binbstd is 0, otherwise it is $PACKAGE_BCACHED_DIR
dotweakoptionalPOSIX shell code to be run to do some tweaks immediately after installing.<br>PWD is $PACKAGE_INSTALL_DIR
caveatsoptionalmultiple lines of plain text to be displayed after installation.
phases
phases
build system namebuild script file name
mesonmeson.build
cmakeCMakeLists.txt
gmakeGNUMakefile or Makefile
ninjabuild.ninja
xmakexmake.lua
cargoCargo.toml
gogo.mod
rakeRakefile
autogenautogen.sh
autotoolsconfigure.ac
configureconfigure

commands that can be used out of the box:

commandusage-example
bashReference
CoreUtilsReference
xargsReference
findReference
gawkReference
gsedReference
grepReference
treeReference
jqReference
yqReference
d2Reference
batReference
xxdReference
gitReference
curlReference
bsdtarReference
pkg-configReference
patchelfReference
sysinfoReference
echoecho 'your message.'
infoinfo 'your information.'
warnwarn "no package manager found."
errorerror 'error message.'
abortabort 1 "please specify a package name."
successsuccess "build success."
isIntegerisInteger $x || abort 1 "should be an integer."
isCrossBuildisCrossBuild && abort 1 "This package is not supposed to be cross built."
wfetchwfetch <URL> [--uri=<URL-MIRROR>] [--sha256=<SHA256>] [-o <PATH> [-q]
configureconfigure --enable-pic
mesonwmesonw -Dneon=disabled -Darm-simd=disabled
cmakewcmakew -DBUILD_SHARED_LIBS=ON -DBUILD_STATIC_LIBS=ON
gmakewgmakew
xmakewxmakew
cargowcargow
gowgow

shell variables can be used directly:

variableoverview
PPKG_ARG0the 1st arguments of ppkg that you've supplied.
PPKG_ARG1the 2nd arguments of ppkg that you've supplied.
PPKG_ARGVthe all arguments of ppkg that you've supplied.
PPKG_PATHthe full path of ppkg that you're running.
PPKG_HOMEthe home directory of ppkg that you're running.
PPKG_VERSIONthe version of ppkg that you're running.
UPPMthe executable filepath of uppm
TIMESTAMP_UNIXthe unix timestamp of this action.
NATIVE_OS_KINDcurrent running os kind. value shall be any one of linux darwin freebsd netbsd openbsd dragonflybsd
NATIVE_OS_TYPEcurrent running os type. value shall be any one of linux macos freebsd netbsd openbsd dragonflybsd
NATIVE_OS_NAMEcurrent running os name. value might be any one of Debian GNU/Linux Ubuntu CentOS Fedora FreeBSD NetBSD OpenBSD, DragonFlyBSD, etc
NATIVE_OS_VERScurrent running os version.
NATIVE_OS_ARCHcurrent running os arch. value might be any one of x86_64 amd64 arm64 aarch64, ppc64le, riscv64, s390x, etc
NATIVE_OS_NCPUcurrent running os's cpu core count.
NATIVE_OS_LIBCcurrent running os's libc name. value shall be any one of glibc and musl.
NATIVE_OS_EUIDcurrent running os's effective user ID.
NATIVE_OS_EGIDcurrent running os's effective group ID.
TARGET_PLATFORM_NAMEtarget platform name that is built for. value shall be any one of linux macos freebsd netbsd openbsd dragonflybsd
TARGET_PLATFORM_VERStarget platform version that is built with.
TARGET_PLATFORM_ARCHtarget platform arch that is built for. value might be any one of x86_64 amd64 arm64 aarch64, ppc64le, riscv64, s390x, etc
CROSS_COMPILINGvalue shall be 0 or 1. indicates whether is cross-compiling.
CCthe C Compiler.
CFLAGSthe flags of CC.
CXXthe C++ Compiler.
CXXFLAGSthe flags of CXX.
CPPthe C/C++ PreProcessor.
CPPFLAGSthe flags of CPP.
ASthe assembler.
ARthe archiver.
RANLIBthe archiver extra tool.
LDthe linker.
LDFLAGSthe flags of LD.
NMa command line tool to list symbols from object files.
STRIPa command line tool to discard symbols and other data from object files.
PACKAGE_WORKING_DIRthe working directory when installing.
PACKAGE_BSCRIPT_DIRthe directory where the build script (e.g. Makefile, configure, CMakeLists.txt, meson.build, Cargo.toml, etc) is located in.
PACKAGE_BCACHED_DIRthe directory where the temporary files are stored in when building.
PACKAGE_INSTALL_DIRthe directory where the final files will be installed to.
x_INSTALL_DIRthe installation directory of x package.
x_INCLUDE_DIR$x_INSTALL_DIR/include
x_LIBRARY_DIR$x_INSTALL_DIR/lib

ppkg formula repository

a typical hierarchical structure of a ppkg formula repository looks like below:

PPKGFormulaRepoName
├── formula
│   ├── packageA.yml
│   └── packageB.yml
├── LICENSE
└── README.md

ppkg formula repository local location

${PPKG_HOME}/repos.d/${PPKGFormulaRepoName}

ppkg formula repository local config

a ppkg formula repository's config file is located at ${PPKG_HOME}/repos.d/${PPKGFormulaRepoName}/.ppkg-formula-repo.yml

a typical ppkg formula repository's config file content looks like below:

url: https://github.com/leleliu008/ppkg-formula-repository-official-core
branch: master
pinned: 0
enabled: 1
created: 1673684639
updated: 1673684767

If a ppkg formula repository is pinned, which means it would not be updated.

If a ppkg formula repository is disabled, which means ppkg would not search formulas in this formula repository.

ppkg formula repository management

run ppkg formula-repo-add command to create a new formula repository locally from an exsting remote git repository.

run ppkg formula-repo-init command to create a new formula repository locally without taking any further action.

ppkg official formula repository

ppkg official formula repository is hosted at https://github.com/leleliu008/ppkg-formula-repository-official-core

It would be automatically fetched to your local repository as name official-core when you run ppkg update command.

Note: If you find that a package is not in ppkg official formula repository yet, PR is welcomed.

prebuild packages built by this software