Update Kiss Package Manager

Signed-off-by: The-Repo-Club <wayne6324@gmail.com>
This commit is contained in:
The-Repo-Club 2022-10-02 13:06:33 +01:00
parent 127f414edb
commit 982ca2f2dc
No known key found for this signature in database
GPG Key ID: E30EC2FBFB05C44F
12 changed files with 501 additions and 581 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/sh -ef
# Enter a kiss chroot
log() {
@ -16,8 +16,8 @@ run() {
}
clean() {
log Unmounting host paths; {
run umount "$1/dev/shm" 2>/dev/null
log Unmounting host filesystems; {
run umount "$1/dev/shm"
run umount "$1/dev/pts"
run umount "$1/dev"
run umount "$1/proc"
@ -25,7 +25,10 @@ clean() {
run umount "$1/sys/firmware/efi/efivars" 2>/dev/null
run umount "$1/sys"
run umount "$1/tmp"
run umount "$1/etc/resolv.conf"
}
log Cleaning leftover host files; {
run rm -f "$1/etc/resolv.conf"
}
}
@ -59,18 +62,19 @@ main() {
trap 'clean "${1%"${1##*[!/]}"}"' EXIT INT
log Mounting host paths; {
mmount "$1/dev" -o bind /dev
log Mounting host filesystems; {
mmount "$1/dev" -o bind /dev
mmount "$1/dev/pts" -o bind /dev/pts
mmount "$1/dev/shm" -t tmpfs shmfs 2>/dev/null
mmount "$1/dev/shm" -t tmpfs shmfs
mmount "$1/proc" -t proc proc
mmount "$1/run" -t tmpfs tmpfs
mmount "$1/sys" -t sysfs sys
mmount "$1/sys/firmware/efi/efivars" -t efivarfs efivarfs 2>/dev/null
mmount "$1/tmp" -o mode=1777,nosuid,nodev -t tmpfs tmpfs
}
touch "$1/etc/resolv.conf"
mmount "$1/etc/resolv.conf" -o bind /etc/resolv.conf
log Copying /etc/resolv.conf from host; {
run cp -f /etc/resolv.conf "$1/etc"
}
log Entering chroot; {
@ -86,7 +90,7 @@ main() {
CXXFLAGS="${CXXFLAGS:--march=x86-64 -mtune=generic -pipe -O2}" \
MAKEFLAGS="${MAKEFLAGS:--j$(nproc 2>/dev/null || echo 1)}" \
/bin/sh -l
} || die chroot failed
}
}
main "$1"

View File

@ -0,0 +1,33 @@
#!/bin/sh -ef
# Turn an installed package into a KISS tarball
db=$KISS_ROOT/var/db/kiss/installed
pkg=${1:-"${PWD##*/}"}
kiss list "$pkg" >/dev/null || {
printf 'usage: kiss-export [pkg]\n'
exit 1
}
read -r ver rel 2>/dev/null < "$db/$1/version"
set --
while read -r file; do
[ -d "$KISS_ROOT/$file" ] || set -- "$@" ".$file"
done < "$db/$pkg/manifest"
cd "$KISS_ROOT/"
dest="$OLDPWD/$pkg@$ver-$rel.tar.${KISS_COMPRESS:-gz}"
tar cf - "$@" | case ${KISS_COMPRESS:-gz} in
bz2) bzip2 -z ;;
gz) gzip -6 ;;
lzma) lzma -z ;;
lz) lzip -z ;;
xz) xz -zT 0 ;;
zst) zstd -z ;;
esac > "$dest"
printf 'created %s\n' "$dest"

View File

@ -1,4 +1,4 @@
#!/bin/sh -e
#!/bin/sh -ef
# Read KISS documentation
cd "$KISS_ROOT/usr/share/doc/kiss" 2>/dev/null || {
@ -6,35 +6,23 @@ cd "$KISS_ROOT/usr/share/doc/kiss" 2>/dev/null || {
exit 1
}
_q=$1
! [ -f "${_q:-.}/index.txt" ] || file=./${_q:-.}/index.txt
! [ -f "${_q:-.}.txt" ] || file=./${_q:-.}.txt
! [ -f "${_q:-:}" ] || file=./${_q:-.}
# Fallback to package READMEs.
# False positive, intended behavior.
# shellcheck disable=2046
[ "$file" ] || {
set -f
set +f -- $(kiss s "${_q##*/}")
file=${1:+"$1/README"}
}
! [ -f "${1:-.}/index.txt" ] || file=./${1:-.}/index.txt
! [ -f "${1:-.}.txt" ] || file=./${1:-.}.txt
! [ -f "${1:-:}" ] || file=./${1:-.}
# Fallback to search (allows 'kiss help firefox' to work).
# False positive, intended behavior.
# shellcheck disable=2046
[ "$file" ] || {
set -f
set +f -- $(find . -name "${_q##*/}.txt")
set +f -- $(find . -name "${1##*/}.txt")
file=$1
}
: "${file:=404.txt}"
cat <<EOF - "$file" | "${PAGER:-less}"
Reading ${file#./}
Reading $PWD/${file#./}
________________________________________________________________________________
EOF

View File

@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/sh -ef
# Create a boilerplate package
die() {

View File

@ -1,41 +1,16 @@
#!/bin/sh -e
#!/bin/sh -ef
# List orphaned packages
n='
'
cd "$KISS_ROOT/var/db/kiss/installed/"
cd "$KISS_ROOT/var/db/kiss/installed"
set -- *
l=$n$(
for pkg do shift
set -- "$@" -e "$pkg"
done
# Get a list of non-orphans.
grep -Fx "$@" -- */depends |
{
# Strip filename.
sed s,.\*/depends:,,
# Exclude packages which are not really orphans.
printf '%s\n' baseinit baselayout busybox bzip2 e2fsprogs gcc \
git grub kiss make musl
} |
# Remove duplicates.
sort -u
)$n
# Generate the list of orphans by finding the inverse of the non-orphan list.
for pkg do shift
case $l in (*"$n$pkg$n"*)
continue
for pkg in *; do
case $pkg in
# Exemptions for orphans which aren't really
# orphans. Exclude them from the list.
baseinit|baselayout|gcc|e2fsprogs|musl|\
make|busybox|bzip2|grub|kiss|git)
continue
esac
set -- "$@" "$pkg"
grep -q "^$pkg$" ./*/depends || printf '%s\n' "$pkg"
done
printf '%s\n' "$@"

View File

@ -1,13 +1,15 @@
#!/bin/sh
#!/bin/sh -ef
# Check repository for outdated packages
die() {
printf '%s\n' "$*" >&2
exit 1
}
repology_version() {
# Grab the package's version as known by repology.org by downloading the
# svg latest-version badge and extracting the version from the xml.
repology_name "$1"
mkcd() {
mkdir -p "$1" && cd "$1"
r=$(curl -Ss "https://repology.org/badge/latest-versions/$remote.svg") && {
remote_ver=${r%</text>*}
remote_ver=${remote_ver##*>}
}
}
repology_name() {
@ -17,10 +19,11 @@ repology_name() {
remote=${1%%-bin}
remote=${remote%%-git}
printf %s "$remote" |
# Remote names are all lowercase.
tr '[:upper:]' '[:lower:]' <<EOF |
$remote
EOF
tr '[:upper:]' '[:lower:]' |
# Remote always uses -.
tr _ -
)
@ -68,10 +71,6 @@ EOF
remote=fonts:fontawesome
;;
foot-pgo)
remote=foot
;;
gc)
remote=boehm-gc
;;
@ -129,10 +128,6 @@ EOF
remote=${remote##lib}
;;
libseat)
remote=seatd
;;
links2)
# TODO [community]: Rename package?
remote=links
@ -207,10 +202,6 @@ EOF
remote=st-term
;;
sway-no-seat | sway-tiny)
remote=sway
;;
terminus-font)
remote=fonts:terminus
;;
@ -239,70 +230,60 @@ EOF
esac
}
repology_version() {
[ -f "$1.svg" ] || return 1
read -r remote_ver < "$1.svg" || :
remote_ver=${remote_ver%</text>*}
remote_ver=${remote_ver##*>}
}
repo_version() {
read -r ver _ 2>/dev/null < "$2/version" || {
printf '%-30s local version not found\n' "$1" >&2
return 1
}
[ "$ver" != git ]
}
get_outdated() {
repo=${repo%%/}
printf '\n[Checking Repology for outdated packages in %s]\n\n' "$repo" >&2
main() {
printf '\n[Checking Repology for outdated packages in %s]\n\n' "${1%%/}" >&2
for pkg in */; do
pkg=${pkg%%/}
repology_name "${pkg##*/}"
[ "$remote" = - ] ||
set -- "$@" -z "$remote.svg" \
"https://repology.org/badge/latest-versions/$remote.svg"
done
mkcd "$tmp/${repo##*/}"
curl -SsZ --parallel-max 16 --remote-name-all "$@" ||
die 'fatal: network error'
for _pkg in "$OLDPWD"/*/; do
pkg=${_pkg%%/}
pkg=${pkg##*/}
repo_version "$pkg" "$_pkg" || continue
repology_name "$pkg"
repology_version "$remote" || continue
case $remote_ver in *", $ver"* | *"$ver,"* | "$ver" | - | '')
read -r ver _ 2>/dev/null < "$pkg/version" || {
printf '%-30s local version not found\n' "$pkg" >&2
continue
}
[ "$ver" = git ] &&
continue
repology_version "$pkg" || {
printf '%-30s network error\n' "$pkg" >&2
continue
}
case $remote_ver in
*", $ver"* | *"$ver,"* | "$ver")
# Package up-to-date, do nothing.
;;
'' | ' ')
printf '\n%s: empty response\n' "$pkg" >&2
printf 'possible causes:\n' >&2
printf ' package name differs from repology name,\n' >&2
printf ' package not tracked by repology,\n' >&2
printf ' network error\n\n' >&2
;;
'-')
# No version scheme, do nothing.
;;
*)
printf '%-30s %s -> %s\n' "$pkg" "$ver" "$remote_ver"
;;
esac
printf '%-30s %s -> %s\n' "$pkg" "$ver" "$remote_ver"
done
}
main() {
set -e
for repo do
[ "$repo" ] || {
printf 'usage: kiss outdated /path/to/repo\n' >&2
exit 1
}
[ "$1" ] ||
die 'usage: kiss [ou]tdated /path/to/repo...'
cd "$repo" 2>/dev/null || {
printf 'repository %s is inaccessible\n' "$repo" >&2
exit 1
}
mkdir -p "${tmp:=${XDG_CACHE_HOME:-"$HOME/.cache"}/kiss/repology}"
for repo do
old_pwd=$PWD
cd "$repo"
get_outdated
cd "$old_pwd"
done
}
main "$@"
main "$repo"
cd "$OLDPWD" || exit 1
done

View File

@ -1,4 +1,4 @@
#!/bin/sh -e
#!/bin/sh -ef
# Check which package owns a file
# Follow symlinks to any paths.

View File

@ -1,4 +1,4 @@
#!/bin/sh -e
#!/bin/sh -ef
# Lists the owners of all files with conflicts
kiss a | while read -r _ path; do

View File

@ -0,0 +1,20 @@
#!/bin/sh -ef
# List packages which aren't present in any repository.
cd "$KISS_ROOT/var/db/kiss/installed"
kiss s ./* | while IFS=/ read -r _ path; do
pkg=${path##*/}
case $seen in *" $pkg "*)
continue
esac
case $path in "$PWD/$pkg")
printf '%s\n' "$pkg"
esac
seen="$seen $pkg "
done

View File

@ -1,9 +1,8 @@
#!/bin/sh -e
#!/bin/sh -ef
# Display packages which depend on package
[ "$1" ] || set -- "${PWD##*/}"
cd "$KISS_ROOT/var/db/kiss/installed"
grep -E "^$1( |$)" -- */depends
grep "^$1" -- */depends

View File

@ -27,11 +27,14 @@ kiss list "${1:-null}" >/dev/null || {
# Filter directories from manifest and leave only files.
# Directories in the manifest end in a trailing '/'.
# Send the file list to 'xargs' to run through 'du',
# this prevents du from exiting due to too many arguments
sed -e "s|^|$KISS_ROOT|" -e 's|.*/$||' \
"$KISS_ROOT/var/db/kiss/installed/$1/manifest" \
| xargs du -sk -- 2>/dev/null |
files=$(sed -e "s|^|$KISS_ROOT|" -e '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 -sk -- $files 2>/dev/null |
# Iterate over each line and convert the byte output to human
# readable (MB, KB, GB, etc).