From a5742ec0d46f60fcbeec141744a2e35a9e5dd6d5 Mon Sep 17 00:00:00 2001 From: merakor Date: Fri, 24 Jul 2020 09:45:05 +0000 Subject: contrib: rename scripts FossilOrigin-Name: d35a756a5d603ac894873aeb0a30826cb4b3fe9e257ecf21298225e07f517ddd --- contrib/cpt-cat | 13 +++++++++ contrib/cpt-chbuild | 73 ++++++++++++++++++++++++++++++++++++++++++++++ contrib/cpt-chroot | 68 ++++++++++++++++++++++++++++++++++++++++++ contrib/cpt-depends | 7 +++++ contrib/cpt-export | 31 ++++++++++++++++++++ contrib/cpt-fork | 24 +++++++++++++++ contrib/cpt-link | 18 ++++++++++++ contrib/cpt-manifest | 6 ++++ contrib/cpt-manifest-tree | 7 +++++ contrib/cpt-new | 23 +++++++++++++++ contrib/cpt-outdated | 59 +++++++++++++++++++++++++++++++++++++ contrib/cpt-owns | 30 +++++++++++++++++++ contrib/cpt-repodepends | 7 +++++ contrib/cpt-reset | 24 +++++++++++++++ contrib/cpt-revdepends | 12 ++++++++ contrib/cpt-size | 15 ++++++++++ contrib/cpt-which | 7 +++++ contrib/kiss-cat | 13 --------- contrib/kiss-chbuild | 73 ---------------------------------------------- contrib/kiss-chroot | 68 ------------------------------------------ contrib/kiss-depends | 7 ----- contrib/kiss-export | 31 -------------------- contrib/kiss-fork | 24 --------------- contrib/kiss-link | 18 ------------ contrib/kiss-manifest | 6 ---- contrib/kiss-manifest-tree | 7 ----- contrib/kiss-new | 23 --------------- contrib/kiss-outdated | 59 ------------------------------------- contrib/kiss-owns | 30 ------------------- contrib/kiss-repodepends | 7 ----- contrib/kiss-reset | 24 --------------- contrib/kiss-revdepends | 12 -------- contrib/kiss-size | 15 ---------- contrib/kiss-which | 7 ----- 34 files changed, 424 insertions(+), 424 deletions(-) create mode 100755 contrib/cpt-cat create mode 100755 contrib/cpt-chbuild create mode 100755 contrib/cpt-chroot create mode 100755 contrib/cpt-depends create mode 100755 contrib/cpt-export create mode 100755 contrib/cpt-fork create mode 100755 contrib/cpt-link create mode 100755 contrib/cpt-manifest create mode 100755 contrib/cpt-manifest-tree create mode 100755 contrib/cpt-new create mode 100755 contrib/cpt-outdated create mode 100755 contrib/cpt-owns create mode 100755 contrib/cpt-repodepends create mode 100755 contrib/cpt-reset create mode 100755 contrib/cpt-revdepends create mode 100755 contrib/cpt-size create mode 100755 contrib/cpt-which delete mode 100755 contrib/kiss-cat delete mode 100755 contrib/kiss-chbuild delete mode 100755 contrib/kiss-chroot delete mode 100755 contrib/kiss-depends delete mode 100755 contrib/kiss-export delete mode 100755 contrib/kiss-fork delete mode 100755 contrib/kiss-link delete mode 100755 contrib/kiss-manifest delete mode 100755 contrib/kiss-manifest-tree delete mode 100755 contrib/kiss-new delete mode 100755 contrib/kiss-outdated delete mode 100755 contrib/kiss-owns delete mode 100755 contrib/kiss-repodepends delete mode 100755 contrib/kiss-reset delete mode 100755 contrib/kiss-revdepends delete mode 100755 contrib/kiss-size delete mode 100755 contrib/kiss-which diff --git a/contrib/cpt-cat b/contrib/cpt-cat new file mode 100755 index 0000000..7f21760 --- /dev/null +++ b/contrib/cpt-cat @@ -0,0 +1,13 @@ +#!/bin/sh -e +# Concatanate package files in the installed package database +# File names are printed to stderr. +case "$1" in ''|--help|-h) printf '\033[1;33m-> \033[musage: %s [pkg] [file...]\n' "${0##*/}" ; exit 0; esac + +kiss l "${pkg:=$1}" >/dev/null ; shift + +for file in ${*:-build depends sources version} ; do + [ -f "/var/db/kiss/installed/$pkg/$file" ] && { + printf '\033[1m%s:\033[m\n' "$file" >&2 + cat "/var/db/kiss/installed/$pkg/$file" + } +done diff --git a/contrib/cpt-chbuild b/contrib/cpt-chbuild new file mode 100755 index 0000000..3ee7c42 --- /dev/null +++ b/contrib/cpt-chbuild @@ -0,0 +1,73 @@ +#!/bin/sh -e +# Create/destroy temporary chroots +case "$1" in + --help|-h) printf '\033[1;33m-> \033[m%s\n' "usage: ${0##*/} [pkg...]"; exit 0 +esac + +log() { printf '\033[31;1m->\033[m %s.\n' "$@" ;} + +die() { + rm -f carbs-rootfs.tar.xz carbs-rootfs.tar.xz.sum + + log "$@" + log "Re-run 'kiss-chbuild' to try again." + + exit 1 +} + +sh256() { + # There's no standard utility to generate sha256 checksums. + # This is a simple wrapper around sha256sum, sha256, shasum + # and openssl which will use whatever is available. + # + # All utilities must match 'sha256sum' output. + # + # Example: ' ' + [ -e "$1" ] || return 0 + + hash=$(sha256sum "$1" || + sha256 -r "$1" || + openssl dgst -sha256 -r "$1" || + shasum -a 256 "$1") + + printf '%s %s\n' "${hash%% *}" "$1" +} 2>/dev/null + +case "$(uname -m)" in i*86) arch=i686; esac +url="https://dl.carbslinux.org/releases/${arch:-$(uname -m)}/carbs-rootfs.tar.xz" +pid=$$ + +cd "${cac_dir:=$KISS_ROOT${XDG_CACHE_HOME:-$HOME/.cache}/kiss}" + +[ -f carbs-rootfs.tar.xz ] || { + log "Downloading chroot tarball" + curl -fLO "$url" +} + +[ -f carbs-rootfs.tar.xz.sum ] || { + log "Downloading checksums" + curl -fLo- "${url%/*}/sha256sums.txt" | + grep ' carbs-rootfs.tar.xz$' > carbs-rootfs.tar.xz.sum +} + +log "Verifying checksums" +sh256 carbs-rootfs.tar.xz | diff - carbs-rootfs.tar.xz.sum || + die "Checksum verification failed" + + +[ -d carbs-chroot ] || { + log "Extracting chroot" + mkdir -p carbs-chroot + ( cd carbs-chroot; tar xf ../carbs-rootfs.tar.xz ) +} + +log "Creating temporary chroot" +cp -a carbs-chroot "chroot-$pid" + +[ "$1" ] && { + log "Installing extra packages" + KISS_ROOT=$PWD/chroot-$pid kiss i "$@" +} + +log "Entering chroot" +su -c "kiss-chroot chroot-$pid; rm -rf chroot-$pid" diff --git a/contrib/cpt-chroot b/contrib/cpt-chroot new file mode 100755 index 0000000..7d0585c --- /dev/null +++ b/contrib/cpt-chroot @@ -0,0 +1,68 @@ +#!/bin/sh -e +# Enter a chroot + +log() { + printf '\033[32m->\033[m %s.\n' "$*" +} + +usage() { printf '\033[1;33m-> \033[m%s\n' "usage: ${0##*/} [dir]" ; exit 0 ;} + +die() { + log "$*" >&2 + exit 1 +} + +clean() { + log Unmounting /dev, /proc and /sys from chroot; { + umount "$1/dev" ||: + umount "$1/proc" ||: + umount "$1/sys" ||: + } + + log Cleaning leftover host files; { + rm -f "$1/root/.ash_history" + } +} + +main() { + case "$1" in ''|--help|-h) usage; esac + [ -d "$1" ] || die Given path does not exist + [ "$(id -u)" = 0 ] || die Script needs to be run as root + + [ "$2" ] || { + march=$(uname -m 2>/dev/null) ||: + case "$march" in + '') march=native ;; + x86_64) march=x86-64 ;; + i*86) march=i686 ;; + esac + } + + trap 'clean "$1"' EXIT INT + + log Mounting /dev, /proc and /sys from host; { + mountpoint -q "$1/dev" || mount -o bind /dev "$1/dev" + mountpoint -q "$1/proc" || mount -t proc proc "$1/proc" + mountpoint -q "$1/sys" || mount -t sysfs sys "$1/sys" + + } + + log Copying /etc/resolv.conf from host; { + [ -f "$1/etc/resolv.conf" ] || cp /etc/resolv.conf "$1/etc" + } + + log Entering chroot; { + chroot "$1" /usr/bin/env -i \ + HOME=/root \ + TERM="$TERM" \ + SHELL=/bin/sh \ + USER=root \ + KISS_ASROOT=1 \ + CFLAGS="${CFLAGS:--march=$march -mtune=generic -pipe -Os}" \ + CXXFLAGS="${CXXFLAGS:--march=$march -mtune=generic -pipe -Os}" \ + MAKEFLAGS="${MAKFLAGS:--j$(nproc 2>/dev/null || echo 1)}" \ + /bin/sh -l + } +} + +main "$@" diff --git a/contrib/cpt-depends b/contrib/cpt-depends new file mode 100755 index 0000000..b549ff9 --- /dev/null +++ b/contrib/cpt-depends @@ -0,0 +1,7 @@ +#!/bin/sh -ef +# Display a package's dependencies + +case "$1" in ''|--help|-h) printf '\033[1;33m-> \033[m%s\n' "usage: ${0##*/} [pkg]" ; exit 0 ; esac + +kiss l "$1" >/dev/null +cat "$KISS_ROOT/var/db/kiss/installed/$1/depends" 2>/dev/null diff --git a/contrib/cpt-export b/contrib/cpt-export new file mode 100755 index 0000000..c124822 --- /dev/null +++ b/contrib/cpt-export @@ -0,0 +1,31 @@ +#!/bin/sh -ef +# Turn an installed package into a KISS tarball + +case "$1" in ''|--help|-h) printf '\033[1;33m-> \033[m%s\n' "usage: ${0##*/} [pkg]" ; exit 0 ; esac + +kiss l "${1:-null}" >/dev/null + +# Grab the package's version.. +read -r ver rel 2>/dev/null < \ + "$KISS_ROOT/var/db/kiss/installed/$1/version" + +# Reset the argument list. +pkg=$1 +set -- + +# Construct the argument list using each file. +while read -r file; do + [ -d "$KISS_ROOT/$file" ] || set -- "$@" ".$file" +done < "$KISS_ROOT/var/db/kiss/installed/$pkg/manifest" + +# Turn the list of files back into a package. +: "${KISS_COMPRESS:=gz}" +tar cf - -C / -- "$@" | case "$KISS_COMPRESS" in + bz2) bzip2 -z ;; + gz) gzip -6 ;; + xz) xz -zT 0 ;; + zst) zstd -3 ;; + *) gzip -6 ;; # Fallback to gzip +esac > "$pkg#$ver-$rel.tar.$KISS_COMPRESS" + +printf 'tarball created in %s\n' "$PWD/$pkg#$ver-$rel.tar.$KISS_COMPRESS" diff --git a/contrib/cpt-fork b/contrib/cpt-fork new file mode 100755 index 0000000..bfaaa7d --- /dev/null +++ b/contrib/cpt-fork @@ -0,0 +1,24 @@ +#!/bin/sh -ef +# Fork a package to the current directory + +case "$1" in ''|--help|-h) printf '\033[1;33m-> \033[m%s\n' "usage: ${0##*/} [pkg]" ; exit 0 ; esac +[ "$KISS_FORCE" ] || { + [ -d "$1" ] && { + printf '\033[1;31m!> \033[m%s\n' "$1 already exists on the current directory" \ + "You can set KISS_FORCE=1 to ignore this." + exit 1 + } +} + +kiss s "$1" >/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 +( + set -- $(kiss s "$1") + + cp -r "$1" . +) + +printf 'forked package to %s\n' "$PWD/$1" diff --git a/contrib/cpt-link b/contrib/cpt-link new file mode 100755 index 0000000..e5368bf --- /dev/null +++ b/contrib/cpt-link @@ -0,0 +1,18 @@ +#!/bin/sh -ef +# Link a forked package's files to the other repository + +case "$1" in ''|--help|-h) printf '\033[1;33m-> \033[musage: kiss-link [file...]\n' ; exit 0 ; esac + +# 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 "${PKG:=${PWD##*/}}" >/dev/null + +oPKG="$(kiss s "$PKG" | grep -v "^$PWD\$\|/var/db/kiss/installed/$PKG" | sed 1q)" + +for file in "$@" ; do + [ -e "${oPKG:?}/$file" ] + [ -d "$file" ] && rm -rf "$file" + ln -sf "$oPKG/$file" "$file" + printf 'linked %s to %s\n' "$oPKG/$file" "$PWD/$file" +done diff --git a/contrib/cpt-manifest b/contrib/cpt-manifest new file mode 100755 index 0000000..bb9afc8 --- /dev/null +++ b/contrib/cpt-manifest @@ -0,0 +1,6 @@ +#!/bin/sh -ef +# Display all files owned by a package +case "$1" in ''|--help|-h) printf '\033[1;33m-> \033[m%s\n' "usage: ${0##*/} [pkg]" ; exit 0 ; esac + +kiss l "$1" >/dev/null +cat "$KISS_ROOT/var/db/kiss/installed/$1/manifest" 2>/dev/null diff --git a/contrib/cpt-manifest-tree b/contrib/cpt-manifest-tree new file mode 100755 index 0000000..0cc047e --- /dev/null +++ b/contrib/cpt-manifest-tree @@ -0,0 +1,7 @@ +#!/bin/sh -ef +# Display all files owned by a package with a tree view + +case "$1" in ''|--help|-h) printf '\033[1;33m-> \033[m%s\n' "usage: ${0##*/} [pkg]" ; exit 0 ; esac +kiss l "$1" >/dev/null +printf '%s\n' "[$1]:" +tree -C --fromfile "$KISS_ROOT/var/db/kiss/installed/$1/manifest" | sed 1,2d diff --git a/contrib/cpt-new b/contrib/cpt-new new file mode 100755 index 0000000..a068704 --- /dev/null +++ b/contrib/cpt-new @@ -0,0 +1,23 @@ +#!/bin/sh -e +# Create a boilerplate KISS package + +out() { printf '\033[1;33m-> \033[m%s\n' "$@" >&2 ;} +die() { printf '\033[1;31m!> \033[m%s\n' "$@" >&2 ; exit 1 ;} + +case "$1" in ''|--help|-h) out "usage: ${0##*/} [name] [version] [source]"; exit 0; esac + +[ -d "$1" ] && die "Package '$1' already exists." + +# Create the directory +mkdir -p "$1" + +# Create the build file +printf '%s\n' "#!/bin/sh -e" > "$1/build" ; chmod +x "$1/build" + +# Create the version file +printf '%s\n' "$2 1" > "$1/version" + +# Create the sources file +printf '%s\n' "$3" > "$1/sources" + +out "Package '$1' created to '$PWD/$1'" diff --git a/contrib/cpt-outdated b/contrib/cpt-outdated new file mode 100755 index 0000000..27bb1ee --- /dev/null +++ b/contrib/cpt-outdated @@ -0,0 +1,59 @@ +#!/bin/sh +# Check installed packages for updates + +old_IFS=$IFS + +# Notify the user +printf '\033[1;33m-> \033[1;36mnote \033[m%s\n' \ + "If you are doing too many requests you will note be" \ + "able to get information for every package you have" >&2 + +# List via arguments or all installed packages. +if [ "$1" ]; then + set -- printf '%s\n' "$@" +else + set -- kiss l +fi + +"$@" | (while read -r pkg _; do { + read -r ver _ < "/var/db/kiss/installed/$pkg/version" + + # Fix some package names. + case $pkg in + *-bin) fix=${pkg%%-bin} ;; + esac + + # Grab the repology version from the SVG file. + rep=$(curl -s "https://repology.org/badge/latest-versions/${fix:-$pkg}.svg") + + # Skip these instead of outputting empty + # version informations. + # shellcheck disable=2106 + case "$rep" in (*'Too Many Requests'*) continue ;; esac + + rep=${rep%*} + rep=${rep##*>} + + # Skip these. + # shellcheck disable=2106 + { + [ "${rep:--}" = - ] && continue + [ "$ver" = git ] && continue + } + + # Split the comma separated list. + # shellcheck disable=2086 + { + IFS=', ' + set -f + set +f -- $rep + IFS=$old_IFS + } + + # Parse comma separated version lists. + { + for v; do case $v in "$ver") match=1; esac; done + + [ "$match" ] || printf '%s\n' "$pkg $ver -> $rep" + } +} & done; wait) diff --git a/contrib/cpt-owns b/contrib/cpt-owns new file mode 100755 index 0000000..e14d579 --- /dev/null +++ b/contrib/cpt-owns @@ -0,0 +1,30 @@ +#!/bin/sh -e +# Check which package owns a file + +case "$1" in ''|--help|-h) printf '%s\n' "usage: kiss-owns [file]" ; exit 0 ; esac + +# Strip 'KISS_ROOT' from the file path if passed and +# follow symlinks. +file="${1#$KISS_ROOT}" +dirname=$(kiss-readlink "$KISS_ROOT/${file%/*}") +file="$dirname/${file##*/}" + +# Check if the file exists and exit if it is not. +[ -f "$file" ] || { + [ -d "$file" ] && printf '%s\n' \ + "error: please specify a file instead of a directory" >&2 || + printf '%s\n' "error: file '$1' doesn't exist." >&2 + exit 1 +} + +# Print the full path to the manifest file which contains +# the match to our search. +pkg_owns=$(grep -lFx "${file#$KISS_ROOT}" \ + "$KISS_ROOT/var/db/kiss/installed/"*/manifest) + + +# Extract the package name from the path above. +pkg_owns=${pkg_owns%/*} +pkg_owns=${pkg_owns##*/} + +printf '%s\n' "[$pkg_owns] owns '$1'" diff --git a/contrib/cpt-repodepends b/contrib/cpt-repodepends new file mode 100755 index 0000000..ca72605 --- /dev/null +++ b/contrib/cpt-repodepends @@ -0,0 +1,7 @@ +#!/bin/sh -e +# Display a package's dependencies in the repository + +case "$1" in ''|--help|-h) printf '%s\n' "usage: kiss-repodepends [pkg]" ; exit 0 ; esac +kiss s "$1" >/dev/null + +cat "$(kiss s "$1" | sed 1q)/depends" 2>/dev/null diff --git a/contrib/cpt-reset b/contrib/cpt-reset new file mode 100755 index 0000000..326cb80 --- /dev/null +++ b/contrib/cpt-reset @@ -0,0 +1,24 @@ +#!/bin/sh -ef +# Remove all packages except for the base +# +# Disable word-splittng warnings as they're safe here. +# shellcheck disable=SC2046 + +set -- + +while read -r pkg _; do + case $pkg in + baselayout|binutils|bison|busybox|bzip2|curl|flex|gcc|rsync|\ + gzip|kiss|libressl|linux-headers|m4|make|musl|pkgconf|xz|zlib) ;; + + *) set -- "$@" "$pkg" ;; + esac +done </dev/null + +# 'cd' to the database directory as a simple way of +# stripping the path and performing a 'basename'. +cd "$KISS_ROOT/var/db/kiss/installed" + +# Use a simple 'grep' to display packages depending on '$1'. +grep "^$1" -- */depends diff --git a/contrib/cpt-size b/contrib/cpt-size new file mode 100755 index 0000000..d2e8259 --- /dev/null +++ b/contrib/cpt-size @@ -0,0 +1,15 @@ +#!/bin/sh -ef +# Show the size on disk for a package + +case "$1" in ''|--help|-h) printf '%s\n' "usage: kiss-size [pkg]" ; exit 0 ; esac +kiss s "$1" >/dev/null + +# Filter directories from manifest and leave only files. +# Directories in the manifest end in a trailing '/'. +files=$(sed 's|.*/$||' "$KISS_ROOT/var/db/kiss/installed/$1/manifest") + +# Send the file list to 'du'. +# This unquoted variable is safe as word splitting is intended +# and globbing is globally disabled in this script. +# shellcheck disable=2086 +du -shc -- $files 2>/dev/null diff --git a/contrib/cpt-which b/contrib/cpt-which new file mode 100755 index 0000000..1364e04 --- /dev/null +++ b/contrib/cpt-which @@ -0,0 +1,7 @@ +#!/bin/sh -e +# Locate the first instance of a KISS package + +case "$1" in ''|--help|-h) printf '\033[1;33m-> \033[m%s\n' "usage: ${0##*/} [pkg]" ; exit 0; esac + +{ kiss s "$1" || exit 1 ;} | + sed 1q diff --git a/contrib/kiss-cat b/contrib/kiss-cat deleted file mode 100755 index 7f21760..0000000 --- a/contrib/kiss-cat +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh -e -# Concatanate package files in the installed package database -# File names are printed to stderr. -case "$1" in ''|--help|-h) printf '\033[1;33m-> \033[musage: %s [pkg] [file...]\n' "${0##*/}" ; exit 0; esac - -kiss l "${pkg:=$1}" >/dev/null ; shift - -for file in ${*:-build depends sources version} ; do - [ -f "/var/db/kiss/installed/$pkg/$file" ] && { - printf '\033[1m%s:\033[m\n' "$file" >&2 - cat "/var/db/kiss/installed/$pkg/$file" - } -done diff --git a/contrib/kiss-chbuild b/contrib/kiss-chbuild deleted file mode 100755 index 3ee7c42..0000000 --- a/contrib/kiss-chbuild +++ /dev/null @@ -1,73 +0,0 @@ -#!/bin/sh -e -# Create/destroy temporary chroots -case "$1" in - --help|-h) printf '\033[1;33m-> \033[m%s\n' "usage: ${0##*/} [pkg...]"; exit 0 -esac - -log() { printf '\033[31;1m->\033[m %s.\n' "$@" ;} - -die() { - rm -f carbs-rootfs.tar.xz carbs-rootfs.tar.xz.sum - - log "$@" - log "Re-run 'kiss-chbuild' to try again." - - exit 1 -} - -sh256() { - # There's no standard utility to generate sha256 checksums. - # This is a simple wrapper around sha256sum, sha256, shasum - # and openssl which will use whatever is available. - # - # All utilities must match 'sha256sum' output. - # - # Example: ' ' - [ -e "$1" ] || return 0 - - hash=$(sha256sum "$1" || - sha256 -r "$1" || - openssl dgst -sha256 -r "$1" || - shasum -a 256 "$1") - - printf '%s %s\n' "${hash%% *}" "$1" -} 2>/dev/null - -case "$(uname -m)" in i*86) arch=i686; esac -url="https://dl.carbslinux.org/releases/${arch:-$(uname -m)}/carbs-rootfs.tar.xz" -pid=$$ - -cd "${cac_dir:=$KISS_ROOT${XDG_CACHE_HOME:-$HOME/.cache}/kiss}" - -[ -f carbs-rootfs.tar.xz ] || { - log "Downloading chroot tarball" - curl -fLO "$url" -} - -[ -f carbs-rootfs.tar.xz.sum ] || { - log "Downloading checksums" - curl -fLo- "${url%/*}/sha256sums.txt" | - grep ' carbs-rootfs.tar.xz$' > carbs-rootfs.tar.xz.sum -} - -log "Verifying checksums" -sh256 carbs-rootfs.tar.xz | diff - carbs-rootfs.tar.xz.sum || - die "Checksum verification failed" - - -[ -d carbs-chroot ] || { - log "Extracting chroot" - mkdir -p carbs-chroot - ( cd carbs-chroot; tar xf ../carbs-rootfs.tar.xz ) -} - -log "Creating temporary chroot" -cp -a carbs-chroot "chroot-$pid" - -[ "$1" ] && { - log "Installing extra packages" - KISS_ROOT=$PWD/chroot-$pid kiss i "$@" -} - -log "Entering chroot" -su -c "kiss-chroot chroot-$pid; rm -rf chroot-$pid" diff --git a/contrib/kiss-chroot b/contrib/kiss-chroot deleted file mode 100755 index 7d0585c..0000000 --- a/contrib/kiss-chroot +++ /dev/null @@ -1,68 +0,0 @@ -#!/bin/sh -e -# Enter a chroot - -log() { - printf '\033[32m->\033[m %s.\n' "$*" -} - -usage() { printf '\033[1;33m-> \033[m%s\n' "usage: ${0##*/} [dir]" ; exit 0 ;} - -die() { - log "$*" >&2 - exit 1 -} - -clean() { - log Unmounting /dev, /proc and /sys from chroot; { - umount "$1/dev" ||: - umount "$1/proc" ||: - umount "$1/sys" ||: - } - - log Cleaning leftover host files; { - rm -f "$1/root/.ash_history" - } -} - -main() { - case "$1" in ''|--help|-h) usage; esac - [ -d "$1" ] || die Given path does not exist - [ "$(id -u)" = 0 ] || die Script needs to be run as root - - [ "$2" ] || { - march=$(uname -m 2>/dev/null) ||: - case "$march" in - '') march=native ;; - x86_64) march=x86-64 ;; - i*86) march=i686 ;; - esac - } - - trap 'clean "$1"' EXIT INT - - log Mounting /dev, /proc and /sys from host; { - mountpoint -q "$1/dev" || mount -o bind /dev "$1/dev" - mountpoint -q "$1/proc" || mount -t proc proc "$1/proc" - mountpoint -q "$1/sys" || mount -t sysfs sys "$1/sys" - - } - - log Copying /etc/resolv.conf from host; { - [ -f "$1/etc/resolv.conf" ] || cp /etc/resolv.conf "$1/etc" - } - - log Entering chroot; { - chroot "$1" /usr/bin/env -i \ - HOME=/root \ - TERM="$TERM" \ - SHELL=/bin/sh \ - USER=root \ - KISS_ASROOT=1 \ - CFLAGS="${CFLAGS:--march=$march -mtune=generic -pipe -Os}" \ - CXXFLAGS="${CXXFLAGS:--march=$march -mtune=generic -pipe -Os}" \ - MAKEFLAGS="${MAKFLAGS:--j$(nproc 2>/dev/null || echo 1)}" \ - /bin/sh -l - } -} - -main "$@" diff --git a/contrib/kiss-depends b/contrib/kiss-depends deleted file mode 100755 index b549ff9..0000000 --- a/contrib/kiss-depends +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh -ef -# Display a package's dependencies - -case "$1" in ''|--help|-h) printf '\033[1;33m-> \033[m%s\n' "usage: ${0##*/} [pkg]" ; exit 0 ; esac - -kiss l "$1" >/dev/null -cat "$KISS_ROOT/var/db/kiss/installed/$1/depends" 2>/dev/null diff --git a/contrib/kiss-export b/contrib/kiss-export deleted file mode 100755 index c124822..0000000 --- a/contrib/kiss-export +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/sh -ef -# Turn an installed package into a KISS tarball - -case "$1" in ''|--help|-h) printf '\033[1;33m-> \033[m%s\n' "usage: ${0##*/} [pkg]" ; exit 0 ; esac - -kiss l "${1:-null}" >/dev/null - -# Grab the package's version.. -read -r ver rel 2>/dev/null < \ - "$KISS_ROOT/var/db/kiss/installed/$1/version" - -# Reset the argument list. -pkg=$1 -set -- - -# Construct the argument list using each file. -while read -r file; do - [ -d "$KISS_ROOT/$file" ] || set -- "$@" ".$file" -done < "$KISS_ROOT/var/db/kiss/installed/$pkg/manifest" - -# Turn the list of files back into a package. -: "${KISS_COMPRESS:=gz}" -tar cf - -C / -- "$@" | case "$KISS_COMPRESS" in - bz2) bzip2 -z ;; - gz) gzip -6 ;; - xz) xz -zT 0 ;; - zst) zstd -3 ;; - *) gzip -6 ;; # Fallback to gzip -esac > "$pkg#$ver-$rel.tar.$KISS_COMPRESS" - -printf 'tarball created in %s\n' "$PWD/$pkg#$ver-$rel.tar.$KISS_COMPRESS" diff --git a/contrib/kiss-fork b/contrib/kiss-fork deleted file mode 100755 index bfaaa7d..0000000 --- a/contrib/kiss-fork +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/sh -ef -# Fork a package to the current directory - -case "$1" in ''|--help|-h) printf '\033[1;33m-> \033[m%s\n' "usage: ${0##*/} [pkg]" ; exit 0 ; esac -[ "$KISS_FORCE" ] || { - [ -d "$1" ] && { - printf '\033[1;31m!> \033[m%s\n' "$1 already exists on the current directory" \ - "You can set KISS_FORCE=1 to ignore this." - exit 1 - } -} - -kiss s "$1" >/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 -( - 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 deleted file mode 100755 index e5368bf..0000000 --- a/contrib/kiss-link +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/sh -ef -# Link a forked package's files to the other repository - -case "$1" in ''|--help|-h) printf '\033[1;33m-> \033[musage: kiss-link [file...]\n' ; exit 0 ; esac - -# 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 "${PKG:=${PWD##*/}}" >/dev/null - -oPKG="$(kiss s "$PKG" | grep -v "^$PWD\$\|/var/db/kiss/installed/$PKG" | sed 1q)" - -for file in "$@" ; do - [ -e "${oPKG:?}/$file" ] - [ -d "$file" ] && rm -rf "$file" - ln -sf "$oPKG/$file" "$file" - printf 'linked %s to %s\n' "$oPKG/$file" "$PWD/$file" -done diff --git a/contrib/kiss-manifest b/contrib/kiss-manifest deleted file mode 100755 index bb9afc8..0000000 --- a/contrib/kiss-manifest +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh -ef -# Display all files owned by a package -case "$1" in ''|--help|-h) printf '\033[1;33m-> \033[m%s\n' "usage: ${0##*/} [pkg]" ; exit 0 ; esac - -kiss l "$1" >/dev/null -cat "$KISS_ROOT/var/db/kiss/installed/$1/manifest" 2>/dev/null diff --git a/contrib/kiss-manifest-tree b/contrib/kiss-manifest-tree deleted file mode 100755 index 0cc047e..0000000 --- a/contrib/kiss-manifest-tree +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh -ef -# Display all files owned by a package with a tree view - -case "$1" in ''|--help|-h) printf '\033[1;33m-> \033[m%s\n' "usage: ${0##*/} [pkg]" ; exit 0 ; esac -kiss l "$1" >/dev/null -printf '%s\n' "[$1]:" -tree -C --fromfile "$KISS_ROOT/var/db/kiss/installed/$1/manifest" | sed 1,2d diff --git a/contrib/kiss-new b/contrib/kiss-new deleted file mode 100755 index a068704..0000000 --- a/contrib/kiss-new +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/sh -e -# Create a boilerplate KISS package - -out() { printf '\033[1;33m-> \033[m%s\n' "$@" >&2 ;} -die() { printf '\033[1;31m!> \033[m%s\n' "$@" >&2 ; exit 1 ;} - -case "$1" in ''|--help|-h) out "usage: ${0##*/} [name] [version] [source]"; exit 0; esac - -[ -d "$1" ] && die "Package '$1' already exists." - -# Create the directory -mkdir -p "$1" - -# Create the build file -printf '%s\n' "#!/bin/sh -e" > "$1/build" ; chmod +x "$1/build" - -# Create the version file -printf '%s\n' "$2 1" > "$1/version" - -# Create the sources file -printf '%s\n' "$3" > "$1/sources" - -out "Package '$1' created to '$PWD/$1'" diff --git a/contrib/kiss-outdated b/contrib/kiss-outdated deleted file mode 100755 index 27bb1ee..0000000 --- a/contrib/kiss-outdated +++ /dev/null @@ -1,59 +0,0 @@ -#!/bin/sh -# Check installed packages for updates - -old_IFS=$IFS - -# Notify the user -printf '\033[1;33m-> \033[1;36mnote \033[m%s\n' \ - "If you are doing too many requests you will note be" \ - "able to get information for every package you have" >&2 - -# List via arguments or all installed packages. -if [ "$1" ]; then - set -- printf '%s\n' "$@" -else - set -- kiss l -fi - -"$@" | (while read -r pkg _; do { - read -r ver _ < "/var/db/kiss/installed/$pkg/version" - - # Fix some package names. - case $pkg in - *-bin) fix=${pkg%%-bin} ;; - esac - - # Grab the repology version from the SVG file. - rep=$(curl -s "https://repology.org/badge/latest-versions/${fix:-$pkg}.svg") - - # Skip these instead of outputting empty - # version informations. - # shellcheck disable=2106 - case "$rep" in (*'Too Many Requests'*) continue ;; esac - - rep=${rep%*} - rep=${rep##*>} - - # Skip these. - # shellcheck disable=2106 - { - [ "${rep:--}" = - ] && continue - [ "$ver" = git ] && continue - } - - # Split the comma separated list. - # shellcheck disable=2086 - { - IFS=', ' - set -f - set +f -- $rep - IFS=$old_IFS - } - - # Parse comma separated version lists. - { - for v; do case $v in "$ver") match=1; esac; done - - [ "$match" ] || printf '%s\n' "$pkg $ver -> $rep" - } -} & done; wait) diff --git a/contrib/kiss-owns b/contrib/kiss-owns deleted file mode 100755 index e14d579..0000000 --- a/contrib/kiss-owns +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/sh -e -# Check which package owns a file - -case "$1" in ''|--help|-h) printf '%s\n' "usage: kiss-owns [file]" ; exit 0 ; esac - -# Strip 'KISS_ROOT' from the file path if passed and -# follow symlinks. -file="${1#$KISS_ROOT}" -dirname=$(kiss-readlink "$KISS_ROOT/${file%/*}") -file="$dirname/${file##*/}" - -# Check if the file exists and exit if it is not. -[ -f "$file" ] || { - [ -d "$file" ] && printf '%s\n' \ - "error: please specify a file instead of a directory" >&2 || - printf '%s\n' "error: file '$1' doesn't exist." >&2 - exit 1 -} - -# Print the full path to the manifest file which contains -# the match to our search. -pkg_owns=$(grep -lFx "${file#$KISS_ROOT}" \ - "$KISS_ROOT/var/db/kiss/installed/"*/manifest) - - -# Extract the package name from the path above. -pkg_owns=${pkg_owns%/*} -pkg_owns=${pkg_owns##*/} - -printf '%s\n' "[$pkg_owns] owns '$1'" diff --git a/contrib/kiss-repodepends b/contrib/kiss-repodepends deleted file mode 100755 index ca72605..0000000 --- a/contrib/kiss-repodepends +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh -e -# Display a package's dependencies in the repository - -case "$1" in ''|--help|-h) printf '%s\n' "usage: kiss-repodepends [pkg]" ; exit 0 ; esac -kiss s "$1" >/dev/null - -cat "$(kiss s "$1" | sed 1q)/depends" 2>/dev/null diff --git a/contrib/kiss-reset b/contrib/kiss-reset deleted file mode 100755 index 326cb80..0000000 --- a/contrib/kiss-reset +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/sh -ef -# Remove all packages except for the base -# -# Disable word-splittng warnings as they're safe here. -# shellcheck disable=SC2046 - -set -- - -while read -r pkg _; do - case $pkg in - baselayout|binutils|bison|busybox|bzip2|curl|flex|gcc|rsync|\ - gzip|kiss|libressl|linux-headers|m4|make|musl|pkgconf|xz|zlib) ;; - - *) set -- "$@" "$pkg" ;; - esac -done </dev/null - -# 'cd' to the database directory as a simple way of -# stripping the path and performing a 'basename'. -cd "$KISS_ROOT/var/db/kiss/installed" - -# Use a simple 'grep' to display packages depending on '$1'. -grep "^$1" -- */depends diff --git a/contrib/kiss-size b/contrib/kiss-size deleted file mode 100755 index d2e8259..0000000 --- a/contrib/kiss-size +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/sh -ef -# Show the size on disk for a package - -case "$1" in ''|--help|-h) printf '%s\n' "usage: kiss-size [pkg]" ; exit 0 ; esac -kiss s "$1" >/dev/null - -# Filter directories from manifest and leave only files. -# Directories in the manifest end in a trailing '/'. -files=$(sed 's|.*/$||' "$KISS_ROOT/var/db/kiss/installed/$1/manifest") - -# Send the file list to 'du'. -# This unquoted variable is safe as word splitting is intended -# and globbing is globally disabled in this script. -# shellcheck disable=2086 -du -shc -- $files 2>/dev/null diff --git a/contrib/kiss-which b/contrib/kiss-which deleted file mode 100755 index 1364e04..0000000 --- a/contrib/kiss-which +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh -e -# Locate the first instance of a KISS package - -case "$1" in ''|--help|-h) printf '\033[1;33m-> \033[m%s\n' "usage: ${0##*/} [pkg]" ; exit 0; esac - -{ kiss s "$1" || exit 1 ;} | - sed 1q -- cgit v1.2.3