aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md216
-rwxr-xr-xcontrib/kiss-cargo-urlgen11
-rwxr-xr-xcontrib/kiss-chroot4
-rwxr-xr-xcontrib/kiss-depends-finder2
-rwxr-xr-xcontrib/kiss-export2
-rwxr-xr-xcontrib/kiss-fork17
-rwxr-xr-xcontrib/kiss-link45
-rwxr-xr-xcontrib/kiss-reset10
-rwxr-xr-xkiss112
-rw-r--r--kiss.15
10 files changed, 153 insertions, 271 deletions
diff --git a/README.md b/README.md
index 250bad6..0b7f081 100644
--- a/README.md
+++ b/README.md
@@ -36,8 +36,6 @@ Read: https://k1ss.org/guidestones.txt
<!-- vim-markdown-toc GFM -->
* [Package format](#package-format)
-* [Customization](#customization)
-* [Alternatives system](#alternatives-system)
* [Extending the package manager](#extending-the-package-manager)
<!-- vim-markdown-toc -->
@@ -45,227 +43,21 @@ Read: https://k1ss.org/guidestones.txt
## Package format
-See: <https://k1ss.org/pages/package-system/>
+See: <https://k1ss.org/package-system>
-## Customization
-
-```sh
-# The package manager is controlled through environment variables.
-#
-# These can be set in your '.profile' or '/etc/profile.d' to have
-# the options apply all the time.
-#
-# These can also be set in the current shell to have them apply
-# only for the current session.
-#
-# NOTE: The values shown below are the defaults.
-
-# Managing repositories.
-#
-# This works exactly like '$PATH' (Colon separated).
-#
-# A list of repositories the package manager will use. You can
-# add your own repositories or remove the default ones.
-export KISS_PATH=/var/db/kiss/repo/core:/var/db/kiss/repo/extra:/var/db/kiss/repo/xorg
-
-# Force package installation or removal.
-#
-# This can be used to bypass the dependency checks on installation
-# and removal of packages.
-#
-# Set it to '1' to force.
-export KISS_FORCE=0
-
-# Hook into kiss through a script.
-#
-# This can be used set custom CFLAGS per package, modify builds,
-# etc. This environment variable must point to a shellscript.
-#
-# The script will have the following environment variables set.
-#
-# $PKG: Name of the current package .
-# $TYPE: The type of hook (valid: pre-build, post-build).
-# $DEST: The full path to where 'make install' will put the package.
-#
-# Simple example script:
-#
-# case $TYPE in
-# pre-build)
-# case $PKG in
-# zlib) export CFLAGS="-Os -static" ;;
-# curl) export CFLAGS="-O3" ;;
-# esac
-# ;;
-#
-# post-build)
-# : "${DEST:?DEST is unset}"
-#
-# rm -rf "$DEST/usr/share/doc"
-# rm -rf "$DEST/usr/share/gettext"
-# ;;
-# esac
-#
-export KISS_HOOK=/path/to/script
-
-# Root directory.
-#
-# Where installed packages will go. You won't ever need
-# to touch this during normal usage.
-#
-# This can be used to have the package manager run in a "fake root".
-export KISS_ROOT=/
-
-# Keep build logs around for successful builds and not just failing
-# ones. Helpful when debugging.
-#
-# Set it to '1' to enable.
-export KISS_DEBUG=0
-
-# Force the usage of a different 'sudo' tool.
-#
-# Values: 'su', 'sudo', 'doas'
-export KISS_SU=
-
-# Use a reproducible cache naming scheme.
-#
-# The package manager builds packages inside 'build-$PID/' with '$PID'
-# being the package manager's process ID. This allows for multiple
-# builds to happen at once.
-#
-# You can override this and _know_ the location beforehand with the
-# below environment variable. 'KISS_PID=test' will build the package
-# in 'build-test'.
-#
-# Unset by default.
-export KISS_PID=
-
-
-#
-# non-package-manager related options.
-# These are listed for clarity.
-#
-
-
-# Cache directory location.
-export XDG_CACHE_HOME=$HOME/.cache/
-
-# Compiler.
-export CC=gcc
-export CXX=g++
-
-# AR.
-export AR=ar
-
-# NM.
-export NM=nm
-
-# RANLIB.
-export RANLIB=ranlib
-
-# Compiler flags.
-# Good value: CFLAGS/CXXFLAGS='-march=native -pipe -O2'
-export CFLAGS=
-export CXXFLAGS=
-
-# Linker flags.
-export LDFLAGS=
-
-# Make flags.
-# Good value: MAKEFLAGS='-j4' (number of cores).
-export MAKEFLAGS=
-
-# Ninja (Samurai) flags.
-# Good value: SAMUFLAGS='-j4' (number of cores).
-export SAMUFLAGS=
-
-# Cmake Generator.
-# Good value (Ninja): export CMAKE_GENERATOR='Ninja'
-# Good value (Makefiles): export CMAKE_GENERATOR='Unix Makefiles'
-export CMAKE_GENERATOR=
-```
-
-## Alternatives system
-
-When a package with conflicts is installed the conflicting
-files will be added as "choices" to the alternatives system.
-
-Afterwards, running kiss a/kiss alternatives will list all of
-the choices you are able to make. Each line of output with this
-command is also usable directly as input.
-
-NOTE: To disable this functionality, set 'KISS_CHOICE=0'.
-
-Example usage:
-
-```sh
-# List alternatives.
--> kiss a
--> Alternatives:
-ncurses /usr/bin/clear
-ncurses /usr/bin/reset
-
-# Swap to ncurses 'clear'.
--> kiss a ncurses /usr/bin/clear
--> Swapping '/usr/bin/clear' from 'busybox' to 'ncurses'
-Password:
-
-# New listing (busybox clear was swapped out).
--> kiss a
--> Alternatives:
-busybox /usr/bin/clear
-ncurses /usr/bin/reset
-```
-
-Example usage (complex):
-
-```sh
--> kiss i sbase
-# More lines...
--> sbase Found conflict (/usr/bin/renice), adding choice
--> sbase Found conflict (/usr/bin/logger), adding choice
--> sbase Found conflict (/usr/bin/flock), adding choice
--> sbase Found conflict (/usr/bin/cal), adding choice
--> sbase Installing package incrementally
--> sbase Installed successfully
-
-# List alternatives.
--> kiss a
--> Alternatives:
-# More lines...
-sbase /usr/bin/uuencode
-sbase /usr/bin/wc
-sbase /usr/bin/which
-sbase /usr/bin/whoami
-sbase /usr/bin/xargs
-sbase /usr/bin/yes
-
-# Swapping in bulk (all of sbase).
-# The 'kiss a' command with '-' as an argument will read
-# from stdin and use each line as arguments to 'kiss a'.
-kiss a | grep ^sbase | kiss a -
-
-# New listing, sbase has replaced busybox utilities.
--> kiss a
--> Alternatives:
-# More lines...
-busybox /usr/bin/uuencode
-busybox /usr/bin/wc
-busybox /usr/bin/which
-busybox /usr/bin/whoami
-busybox /usr/bin/xargs
-busybox /usr/bin/yes
-```
-
## Extending the package manager
The `contrib` directory contains a set of simple scripts to extend the package manager. These are just simple and stupid automations which parse the package format.
+- `kiss-cargo-urlgen`: Generate sources for rust packages.
- `kiss-chbuild`: Spawn a throwaway chroot.
- `kiss-chroot`: Enter a KISS `chroot`.
- `kiss-depends-finder`: Find missing dependencies by parsing 'ldd'.
- `kiss-depends`: Display a package's dependencies.
- `kiss-export`: Turn an installed package into a KISS tarball.
+- `kiss-fork`: Copy a package's repository files into the current directory.
+- `kiss-link`: Link a repository file to another repository.
- `kiss-manifest-tree`: Display all files as tree owned by a package.
- `kiss-manifest`: Display all files owned by a package.
- `kiss-maintainer`: Display the package maintainers.
diff --git a/contrib/kiss-cargo-urlgen b/contrib/kiss-cargo-urlgen
new file mode 100755
index 0000000..ba14aa9
--- /dev/null
+++ b/contrib/kiss-cargo-urlgen
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+[ "$1" ] || {
+ printf 'usage: kiss-carg-urlgen [crate-ver] [crate-ver]\n'
+ exit 1
+}
+
+for crate in "$@"; do
+ printf 'https://static.crates.io/crates/%s/%s.crate vendor\n' \
+ "${crate%-*}" "$crate"
+done
diff --git a/contrib/kiss-chroot b/contrib/kiss-chroot
index c89271a..71bfbb2 100755
--- a/contrib/kiss-chroot
+++ b/contrib/kiss-chroot
@@ -48,8 +48,8 @@ main() {
SHELL=/bin/sh \
USER=root \
KISS_ASROOT=1 \
- CFLAGS="-march=x86-64 -mtune=generic -pipe -Os" \
- CXXFLAGS="-march=x86-64 -mtune=generic -pipe -Os" \
+ CFLAGS="${2:--march=x86-64 -mtune=generic -pipe -Os}" \
+ CXXFLAGS="${2:--march=x86-64 -mtune=generic -pipe -Os}" \
MAKEFLAGS="-j$(nproc 2>/dev/null || echo 1)" \
/bin/sh -l
}
diff --git a/contrib/kiss-depends-finder b/contrib/kiss-depends-finder
index 32b2b17..432a105 100755
--- a/contrib/kiss-depends-finder
+++ b/contrib/kiss-depends-finder
@@ -9,7 +9,7 @@ grep=$(command -v ggrep) || grep='grep'
printf '=> Detected dependencies:\n'
-while read -r file || [ "$file" ]; do
+while read -r file; do
[ -d "$KISS_ROOT/$file" ] && continue
ldd "$KISS_ROOT/$file" 2>/dev/null | while read -r dep; do
diff --git a/contrib/kiss-export b/contrib/kiss-export
index dd5dedd..f8add7c 100755
--- a/contrib/kiss-export
+++ b/contrib/kiss-export
@@ -13,7 +13,7 @@ pkg=$1
set --
# Construct the argument list using each file.
-while read -r file || [ "$file" ]; do
+while read -r file; do
[ -d "$KISS_ROOT/$file" ] || set -- "$@" ".$file"
done < "$KISS_ROOT/var/db/kiss/installed/$pkg/manifest"
diff --git a/contrib/kiss-fork b/contrib/kiss-fork
new file mode 100755
index 0000000..6e1245c
--- /dev/null
+++ b/contrib/kiss-fork
@@ -0,0 +1,17 @@
+#!/bin/sh -ef
+
+kiss s "${1:-null}" >/dev/null || {
+ printf 'usage: kiss-fork pkg_name\n'
+ exit 1
+}
+
+# Disable this warning as globbing is disabled and word splitting
+# is intentional. This grabs the location of the package's files.
+# shellcheck disable=2046
+(
+ set -- $(kiss s "$1")
+
+ cp -r "$1" .
+)
+
+printf 'forked package to %s\n' "$PWD/$1"
diff --git a/contrib/kiss-link b/contrib/kiss-link
new file mode 100755
index 0000000..9412917
--- /dev/null
+++ b/contrib/kiss-link
@@ -0,0 +1,45 @@
+#!/bin/sh -ef
+
+[ "$1" ] || {
+ printf 'usage: kiss-link file\n'
+ exit 1
+}
+
+[ -f "${file:=$1}" ] || {
+ printf 'file %s does not exist in the current directory\n' "$1"
+ exit 1
+}
+
+oPWD=$PWD
+
+# Check if the package exists in a repository and error out here
+# if it does not. The error message from the package manager will
+# be displayed.
+kiss s "${PWD##*/}" >/dev/null
+
+# Disable this warning as globbing is disabled and word splitting
+# is intentional. This grabs the location of the package's files.
+# shellcheck disable=2046
+{
+ # Generate a list of repositories in which the package
+ # exists. Then 'cd' to the first found directory to do a
+ # comparison.
+ set -- $(kiss s "${PWD##*/}"); cd "$1"
+
+ # Error if the package exists nowhere but the current
+ # directory and this script would create a broken symlink.
+ [ -z "$2" ] && [ "$PWD" = "$oPWD" ] && {
+ printf 'error: cannot symlink file to itself\n'
+ exit 1
+ }
+
+ # If the first repository in '$KISS_PATH' is the current
+ # directory, use the second repository in the list.
+ [ "$PWD" = "$oPWD" ] && shift
+
+ # Finally, make the link to the file in whatever repository
+ # it was found in.
+ ln -sf "$1/$file" "$file"
+}
+
+printf 'linked %s to %s\n' "$file" "$1"
diff --git a/contrib/kiss-reset b/contrib/kiss-reset
index 9845109..aee6547 100755
--- a/contrib/kiss-reset
+++ b/contrib/kiss-reset
@@ -7,15 +7,17 @@
set --
-kiss l | while read -r pkg _; do
+while read -r pkg _; do
case $pkg in
baselayout|binutils|bison|busybox|bzip2|curl|flex|gcc|git|\
- gzip|kiss|libelf|libressl|linux-headers|m4|make|musl|perl|\
- pkgconf|rsync|xz|zlib) ;;
+ gzip|kiss|libressl|linux-headers|m4|make|musl|pkgconf|rsync|\
+ xz|zlib) ;;
*) set -- "$@" "$pkg" ;;
esac
-done
+done <<EOF
+$(kiss l)
+EOF
[ "$1" ] && {
printf 'WARNING: This will remove \033[1m%s\033[m package(s).\n' "$#"
diff --git a/kiss b/kiss
index 32561a1..663bf65 100755
--- a/kiss
+++ b/kiss
@@ -75,7 +75,7 @@ pop() {
# Remove an item from a "string list". This allows us
# to remove a 'sed' call and reuse this code throughout.
del=$1
- shift "$(($# ? 1 : 0))"
+ shift
for i; do [ "$i" = "$del" ] || printf %s " $i "; done
}
@@ -88,6 +88,14 @@ run_hook() {
TYPE=$1 PKG=$2 DEST=$3 . "$KISS_HOOK"
}
+decompress() {
+ case $1 in
+ *.bz2) bzip2 -d ;;
+ *.xz) xz -dcT 0 ;;
+ *.tgz|*.gz) gzip -d ;;
+ esac < "$1"
+}
+
pkg_lint() {
# Check that each mandatory file in the package entry exists.
log "$1" "Checking repository files"
@@ -120,7 +128,7 @@ pkg_find() {
# '$KISS_PATH' as POSIX 'find' has no '-mindepth'/'-maxdepth'.
# See: https://unix.stackexchange.com/a/330372
IFS=:; set --
- for path in $KISS_PATH; do set "$@" "$path/."; done
+ for path in $KISS_PATH; do set -- "$@" "$path/."; done
IFS=$old_ifs
# Find the repository containing a package.
@@ -172,6 +180,15 @@ pkg_list() {
done
}
+pkg_cache() {
+ read -r version release 2>/dev/null < "$(pkg_find "$1")/version"
+
+ set +f; set -f -- "$bin_dir/$1#$version-$release.tar."*
+ tar_file=$1
+
+ [ -f "$tar_file" ]
+}
+
pkg_sources() {
# Download any remote package sources. The existence of local
# files is also checked.
@@ -287,7 +304,8 @@ pkg_extract() {
# Any other file-types are simply copied to '$mak_dir' which
# allows for manual extraction.
*://*.tar|*://*.tar.??|*://*.tar.???|*://*.tar.????|*://*.tgz)
- "$tar" xf "$src_dir/$1/${src##*/}" --strip-components 1 ||
+ decompress "$src_dir/$1/${src##*/}" |
+ tar xf - --strip-components 1 ||
die "$1" "Couldn't extract ${src##*/}"
;;
@@ -339,8 +357,8 @@ pkg_order() {
for pkg; do
case $pkg in
- *.tar.gz) deps="$deps $pkg " ;;
- *) pkg_depends "$pkg" raw
+ *.tar.*) deps="$deps $pkg " ;;
+ *) pkg_depends "$pkg" raw
esac
done
@@ -446,7 +464,7 @@ pkg_fixdeps() {
# first column.
sort -uk1,1 -o depends depends 2>/dev/null ||:
- # Display a diff of the new dependencies against the old ones.
+ # Display a diff of the new dependencies against the old ones.
diff "$dep_file" depends 2>/dev/null ||:
# Remove the depends file if it is empty.
@@ -493,8 +511,13 @@ pkg_tar() {
read -r version release < "$(pkg_find "$1")/version"
# Create a tar-ball from the contents of the built package.
- "$tar" zpcf "$bin_dir/$1#$version-$release.tar.gz" -C "$pkg_dir/$1" . ||
- die "$1" "Failed to create tar-ball"
+ "$tar" cf - -C "$pkg_dir/$1" . |
+ case ${KISS_COMPRESS:=gz} in
+ bz2) bzip2 -z ;;
+ xz) xz -zT 0 ;;
+ gz) gzip -6 ;;
+ esac \
+ > "$bin_dir/$1#$version-$release.tar.${KISS_COMPRESS:=gz}"
log "$1" "Successfully created tar-ball"
}
@@ -543,23 +566,16 @@ pkg_build() {
# directory and are up to date.
for pkg; do
# Don't check for a pre-built package if it was passed
- # to KISS directly.
- contains "$explicit_build" "$pkg" || {
- # Figure out the version and release.
- read -r version release < "$(pkg_find "$pkg")/version"
-
- # Install any pre-built binaries if they exist.
- # This calls 'args' to inherit a root check
- # to 'su' to elevate permissions.
- [ -f "$bin_dir/$pkg#$version-$release.tar.gz" ] && {
- log "$pkg" "Found pre-built binary, installing"
- (KISS_FORCE=1 args i "$bin_dir/$pkg#$version-$release.tar.gz")
-
- # Remove the now installed package from the build list.
- # See [1] at top of script.
- # shellcheck disable=2046,2086
- set -- $(pop "$pkg" "$@")
- }
+ # to KISS directly and install any pre-built binaries if
+ # they exist.
+ ! contains "$explicit_build" "$pkg" && pkg_cache "$pkg" && {
+ log "$pkg" "Found pre-built binary, installing"
+ (KISS_FORCE=1 args i "$tar_file")
+
+ # Remove the now installed package from the build list.
+ # See [1] at top of script.
+ # shellcheck disable=2046,2086
+ set -- $(pop "$pkg" "$@")
}
done
@@ -712,20 +728,20 @@ pkg_verify() {
pkg_conflicts() {
# Check to see if a package conflicts with another.
- log "$2" "Checking for package conflicts"
+ log "$1" "Checking for package conflicts"
# Filter the tarball's manifest and select only files
# and any files they resolve to on the filesystem
# (/bin/ls -> /usr/bin/ls).
- "$tar" xf "$1" -O "./$pkg_db/$2/manifest" | while read -r file; do
+ while read -r file; do
case $file in */) continue; esac
printf '%s/%s\n' \
"$(readlink -f "$KISS_ROOT/${file%/*}" 2>/dev/null)" \
"${file##*/}"
- done > "$cac_dir/$pid-m"
+ done < "$tar_dir/$1/$sys_db/$1/manifest" > "$cac_dir/$pid-m"
- p_name=$2
+ p_name=$1
# Generate a list of all installed package manifests
# and remove the current package from the list.
@@ -767,7 +783,7 @@ pkg_conflicts() {
# this work.
#
# Pretty nifty huh?
- while IFS=: read -r pro con || [ "$pro" ]; do
+ while IFS=: read -r _ con; do
log "$p_name" "Found conflict ($con), adding choice"
# Create the "choices" directory inside of the tarball.
@@ -898,37 +914,29 @@ pkg_install() {
# Install can also take the full path to a tar-ball.
# We don't need to check the repository if this is the case.
- if [ -f "$1" ] && [ -z "${1%%*.tar.gz}" ] ; then
+ if [ -f "$1" ] && [ -z "${1%%*.tar.*}" ] ; then
tar_file=$1
+ pkg_name=${1##*/}
+ pkg_name=${pkg_name%#*}
else
- # Read the version information to name the package.
- read -r version release < "$(pkg_find "$1")/version"
+ pkg_cache "$1" ||
+ die "package has not been built, run 'kiss b pkg'"
- # Construct the name of the package tarball.
- tar_file=$bin_dir/$1\#$version-$release.tar.gz
-
- [ -f "$tar_file" ] ||
- die "Package '$1' has not been built, run 'kiss build $1'"
+ pkg_name=$1
fi
- # Figure out which package the tar-ball installs by checking for
- # a database entry inside the tar-ball. If no database entry exists,
- # exit here as the tar-ball is *most likely* not a KISS package.
- pkg_name=$("$tar" tf "$tar_file" | "$grep" -x "\./$pkg_db/.*/version") ||
- die "'${tar_file##*/}' is not a valid KISS package"
-
- pkg_name=${pkg_name%/*}
- pkg_name=${pkg_name##*/}
-
mkdir -p "$tar_dir/$pkg_name"
+ log "$pkg_name" "Extracting $tar_file"
# Extract the tar-ball to catch any errors before installation begins.
- "$tar" pxf "$tar_file" -C "$tar_dir/$pkg_name" ||
- die "$pkg_name" "Failed to extract tar-ball"
+ decompress "$tar_file" | "$tar" pxf - -C "$tar_dir/$pkg_name"
log "$pkg_name" "Checking that all dependencies are installed"
+ [ -f "$tar_dir/$pkg_name/$pkg_db/$pkg_name/manifest" ] ||
+ die "'${tar_file##*/}' is not a valid KISS package"
+
# Make sure that all run-time dependencies are installed prior to
# installing the package.
[ -f "$tar_dir/$pkg_name/$pkg_db/$pkg_name/depends" ] &&
@@ -943,7 +951,7 @@ pkg_install() {
run_hook pre-install "$pkg_name" "$tar_dir/$pkg_name"
- pkg_conflicts "$tar_file" "$pkg_name"
+ pkg_conflicts "$pkg_name"
log "$pkg_name" "Installing package incrementally"
@@ -1059,6 +1067,8 @@ pkg_install() {
"$sys_db/$pkg_name/post-install" ||:
fi
+ run_hook post-install "$pkg_name" "$sys_db/$pkg_name"
+
log "$pkg_name" "Installed successfully"
}
@@ -1319,7 +1329,7 @@ args() {
l|list) pkg_list "$@" ;;
u|update) pkg_updates ;;
s|search) for pkg; do pkg_find "$pkg" all; done ;;
- v|version) log kiss 1.7.7 ;;
+ v|version) log kiss 1.8.1 ;;
h|help|-h|--help|'')
log 'kiss [a|b|c|f|i|l|r|s|u|v] [pkg] [pkg] [pkg]'
diff --git a/kiss.1 b/kiss.1
index 6454cde..07cea02 100644
--- a/kiss.1
+++ b/kiss.1
@@ -98,6 +98,11 @@ export KISS_ROOT=/
# Set it to '1' to enable.
export KISS_KEEPLOG=0
+# Compression method to use for package tarballs.
+#
+# Valid options: 'gz' (default), 'xz', 'bz2'
+export KISS_COMPRESS=gz
+
# Keep build, package and extraction cache directories for debugging
# purposes.
#