aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--LICENSE21
-rw-r--r--README62
-rwxr-xr-xkiss-cargo-urlgen17
-rwxr-xr-xkiss-cargolock-urlgen21
-rwxr-xr-xkiss-changelog11
-rwxr-xr-xkiss-exec23
-rwxr-xr-xkiss-getchoice16
-rwxr-xr-xkiss-orphans23
-rwxr-xr-xkiss-reporevdepends17
9 files changed, 211 insertions, 0 deletions
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..4d1b26a
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright (c) 2020 Cem Keylan
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/README b/README
new file mode 100644
index 0000000..2a9919a
--- /dev/null
+++ b/README
@@ -0,0 +1,62 @@
+kiss-extra
+----------
+
+This is a repository for kiss utilities that do not belong with
+the rest of the utilities. These are non-essential scripts that
+someone could make use of in their scripts. Some of them can be
+used for repository management, so I think maintainers could be
+interested in a variety of utilities here.
+
+
+Install
+-------
+
+Those scripts currently only depend on kiss (and dependencies of
+kiss).
+
+You can install by doing
+
+ for script in kiss-*; do
+ install -Dm755 "$script" "/usr/local/bin/$script"
+ done
+
+
+Or install the `kiss-extra` package on Carbs Linux.
+
+
+New Scripts
+-----------
+
+New scripts should be added in a standard manner. You should
+keep these in mind,
+
+It should start with a docstring right after the shebang. No
+empty line in between.
+
+ #!/bin/sh
+ # A docstring explaining the script
+
+
+It should provide a usage if '--help' or '-h' is provided as an
+argument. If you script takes any arguments, it should also display
+a usage if not argument is given.
+
+Usage should exit with 0 status code, and should be printed to the
+standard output, not stderr. Usage should be a single line string
+small and to the point.
+
+ case "$1" in ''|--help|-h) printf 'usage......'; exit 0; esac
+
+
+Licensing
+---------
+
+This repository contains scripts that were initially in the package
+manager itself. Some of these were initially authored by Dylan Araps.
+License notices are made where needed.
+
+
+Carbs Linux directory
+---------------------
+
+Carbs Linux directory is for
diff --git a/kiss-cargo-urlgen b/kiss-cargo-urlgen
new file mode 100755
index 0000000..2105329
--- /dev/null
+++ b/kiss-cargo-urlgen
@@ -0,0 +1,17 @@
+#!/bin/sh
+# Create static cargo sources for Rust packages
+
+# Copyright (C) 2020 - Dylan Araps.
+# Copyright (C) 2020 - Cem Keylan.
+# Distributed under the terms of the MIT License
+
+case "$1" in ''|--help|-h) printf '\033[1;33m-> \033[m%s\n' "usage: ${0##*/} [crate+ver] [crate+ver]"; exit 0 ; esac
+
+# We convert the name-version seperator from '+' to '-' to
+# avoid issues that may arise from version numbers that include
+# a '-'.
+
+for crate in "$@"; do
+ printf 'https://static.crates.io/crates/%s/%s.crate vendor\n' \
+ "${crate%+*}" "$(echo "$crate" | sed 's/+/-/')"
+done
diff --git a/kiss-cargolock-urlgen b/kiss-cargolock-urlgen
new file mode 100755
index 0000000..7d78a6a
--- /dev/null
+++ b/kiss-cargolock-urlgen
@@ -0,0 +1,21 @@
+#!/bin/sh
+# Convert the given Cargo.lock file to sources
+
+case "$1" in
+ -) set -- /dev/stdin ;;
+ ''|--help|-h) printf '\033[1;33m-> \033[m%s\n' "usage: ${0##*/} <Cargo.lock file>" "" \
+ "'-' can be used to read from stdin." ; exit 0
+esac
+
+# Word splitting is intentional
+# shellcheck disable=2046
+set -- $(sed '/name =/b;/version =/b;d' "$1" |
+ sed 's/version = /#/g;s/name = //;s/"//g' |
+ tr '\n' ' ' | sed 's/ #/#/g')
+
+# We convert the name-version seperator to '#' and back to '-'
+# to avoid issues that may arise from version names with a '-'
+for crate in "$@" ; do
+ printf 'https://static.crates.io/crates/%s/%s.crate vendor\n' \
+ "${crate%#*}" "$crate" | sed 's/#/-/g'
+done
diff --git a/kiss-changelog b/kiss-changelog
new file mode 100755
index 0000000..ed323d8
--- /dev/null
+++ b/kiss-changelog
@@ -0,0 +1,11 @@
+#!/bin/sh -e
+# Print the git log of the specific package
+
+case "$1" in ''|--help|-h) printf '\033[1;33m-> \033[m%s\n' "usage: ${0##*/} [pkg]"; exit 0; esac
+
+kiss s "$1" >/dev/null
+cd "$(kiss s "$1" | sed 1q)"
+
+# Pipe to cat so it doesn't automatically paged
+# by git.
+git log --format='<%as> [%an] %s - %h' . | cat
diff --git a/kiss-exec b/kiss-exec
new file mode 100755
index 0000000..d2b3217
--- /dev/null
+++ b/kiss-exec
@@ -0,0 +1,23 @@
+#!/bin/sh
+# Execute a command inside the alternatives system
+
+usage() {
+ printf '\033[1;33m-> \033[m%s\n' "usage: ${0##*/} [pkg] [command]"
+ exit "$1"
+}
+
+case "$1" in ''|--help|-h) usage 0; esac
+[ "$2" ] || usage 1
+
+pkg=$1
+
+[ "${2##/*}" ] && command=">usr>bin>$2" ||
+ command="$(printf '%s' "$2" | sed 's#/#>#g')"
+
+[ -h "${file:=/var/db/kiss/choices/$pkg$command}" ] && {
+ printf 'ERROR: %s\n' "$file is a symlink"
+ exit 1
+}
+
+shift 2
+exec "/var/db/kiss/choices/$pkg$command" "$@"
diff --git a/kiss-getchoice b/kiss-getchoice
new file mode 100755
index 0000000..75521b4
--- /dev/null
+++ b/kiss-getchoice
@@ -0,0 +1,16 @@
+#!/bin/sh -e
+# Prints the full path to a file in the alternatives system.
+
+case "$1" in ''|--help|-h)
+ printf '\033[1;33m-> \033[m%s\n' "usage: ${0##*/} [pkg] [command]"
+ exit 0; esac
+
+~/proj/carbslinux/kiss/kiss l "$1" >/dev/null
+
+[ "$2" ]
+file="/var/db/kiss/choices/$1$(printf '%s' "$2" | sed 's#/#>#g')"
+[ -f "$file" ] || {
+ printf '\033[1;33m!> \033[1;36m%s \033[m%s\n' "$1" "choice '$2' not found" >&2
+ exit 1
+}
+printf '%s\n' "$file"
diff --git a/kiss-orphans b/kiss-orphans
new file mode 100755
index 0000000..fd8b9d1
--- /dev/null
+++ b/kiss-orphans
@@ -0,0 +1,23 @@
+#!/bin/sh -e
+# List orphaned packages
+
+# Copyright (C) 2019-2020 - Dylan Araps.
+# Distributed under the terms of the MIT License.
+
+case "$1" in ''|--help|-h)
+ printf '\033[1;33m-> \033[m%s\n' \
+ "${0##*/}: lists packages that do not have any packages depending on them" >&2
+ exit 0
+esac
+
+cd "$KISS_ROOT/var/db/kiss/installed/"
+
+for pkg in *; do
+ case $pkg in
+ baseinit|baselayout|gcc|pkgconf|e2fsprogs|musl|\
+ make|busybox|bzip2|grub|kiss|git|linux-headers)
+ continue
+ esac
+
+ grep -q "^$pkg$" ./*/depends || printf '%s\n' "$pkg"
+done
diff --git a/kiss-reporevdepends b/kiss-reporevdepends
new file mode 100755
index 0000000..59262f0
--- /dev/null
+++ b/kiss-reporevdepends
@@ -0,0 +1,17 @@
+#!/bin/sh
+# Display packages on the repository which depend on package
+# shellcheck disable=2086
+
+case "$1" in ''|--help|-h) printf 'usage: %s <pkg>\n' "${0##*/}"; exit 0; esac
+
+pkg="$1"
+IFS=:; set -- $KISS_PATH; unset IFS
+
+for repo do
+ # Change directory to the upper directory of the repository
+ # so it outputs packages in this nice looking format.
+ # repository/package:
+ cd "$repo/.." ||:
+ # This grep only checks for the full word
+ grep "^$pkg\$\|^$pkg\s" -- "${repo##*/}"/*/depends 2>/dev/null ||:
+done