diff options
Diffstat (limited to 'kiss')
-rwxr-xr-x | kiss | 76 |
1 files changed, 36 insertions, 40 deletions
@@ -28,22 +28,18 @@ die() { # Print a message and exit with '1' (error). - printf '\033[1;31m!!\033[m %s.\n' "$@" >&2 + printf '\033[1;31m!>\033[m %s.\n' "$@" >&2 exit 1 } log() { # Print a message prettily. - if [ "$2" ]; then - printf '\033[1;32m-- \033[1;33m%s\033[m (%s)\n' "$1" "$2" - else - printf '\033[1;34m->\033[m %s.\n' "$1" - fi + printf '\033[1;32m=>\033[m %s.\n' "$@" } pkg_lint() { # Check that each mandatory file in the package entry exists. - log "$1" "Checking repository files" + log "[$1] Checking repository files" # Figure out *where* the repository entry for the package is located. repo_dir=$(pkg_search "$1") @@ -109,7 +105,7 @@ pkg_list() { } [ -f "$pkg/version" ] || { - log "$pkg" "Warning, package has no version file" + log "[$pkg] Warning, package has no version file" continue } @@ -121,7 +117,7 @@ pkg_list() { pkg_sources() { # Download any remote package sources. The existence of local # files is also checked. - log "$1" "Downloading sources" + log "[$1] Downloading sources" # Store each downloaded source in named after the package it # belongs to. This avoid conflicts between two packages having a @@ -143,7 +139,7 @@ pkg_sources() { # Remote source. *://*) [ -f "${src##*/}" ] && { - log "$1" "Found cached source '${src##*/}'" + log "[$1] Found cached source '${src##*/}'" continue } @@ -157,7 +153,7 @@ pkg_sources() { *) [ -f "$repo_dir/$src" ] || die "[$1] No local file '$src'" - log "$1" "Found local file '$src'" + log "[$1] Found local file '$src'" ;; esac done < "$repo_dir/sources" @@ -166,7 +162,7 @@ pkg_sources() { pkg_extract() { # Extract all source archives to the build directory and copy over # any local repository files. - log "$1" "Extracting sources" + log "[$1] Extracting sources" # Store each downloaded source in named after the package it # belongs to. This avoid conflicts between two packages having a @@ -257,7 +253,7 @@ pkg_verify() { # Compare the checksums using 'cmp'. cmp -s "$cac_dir/c-$1" "$repo_dir/checksums" || { - log "$1" "Checksum mismatch" + log "[$1] Checksum mismatch" # Instead of dying above, log it to the terminal. Also define a # variable so we *can* die after all checksum files have been @@ -278,7 +274,7 @@ pkg_strip() { # Package has stripping disabled, stop here. [ -f "$repo_dir/nostrip" ] && return - log "$1" "Stripping binaries and libraries" + log "[$1] Stripping binaries and libraries" # Strip only files matching the below mime-types from the package # directory. No alternative to 'file' here sadly. @@ -319,7 +315,7 @@ pkg_fixdeps() { # redefines the argument list. pkg_name=$1 - log "$1" "Checking 'ldd' for missing dependencies" + log "[$1] Checking 'ldd' for missing dependencies" # Go to the directory containing the built package to # simplify path building. @@ -384,7 +380,7 @@ pkg_manifest() ( # Generate the package's manifest file. This is a list of each file # and directory inside the package. The file is used when uninstalling # packages, checking for package conflicts and for general debugging. - log "$1" "Generating manifest" + log "[$1] Generating manifest" # This funcion runs as a sub-shell to avoid having to 'cd' back to the # prior directory before being able to continue. @@ -400,7 +396,7 @@ pkg_manifest() ( pkg_tar() { # Create a tar-ball from the built package's files. # This tar-ball also contains the package's database entry. - log "$1" "Creating tar-ball" + log "[$1] Creating tar-ball" # Find the package's repository files. This needs to keep # happening as we can't store this data in any kind of data @@ -416,7 +412,7 @@ pkg_tar() { tar zpcf "$bin_dir/$1#$version-$release.tar.gz" -C "$pkg_dir/$1" . || die "[$1] Failed to create tar-ball" - log "$1" "Successfully created tar-ball" + log "[$1] Successfully created tar-ball" } pkg_build() { @@ -496,7 +492,7 @@ pkg_build() { # This calls 'args' to inherit a root check and call # to 'sudo' to elevate permissions. [ -f "$bin_dir/$pkg#$version-$release.tar.gz" ] && { - log "$pkg" "Found pre-built binary, installing" + log "[$pkg] Found pre-built binary, installing" args i "$bin_dir/$pkg#$version-$release.tar.gz" continue } @@ -515,7 +511,7 @@ pkg_build() { # Ensure that checksums exist prior to building the package. [ -f "$repo_dir/checksums" ] || { - log "$pkg" "Checksums are missing" + log "[$pkg] Checksums are missing" # Instead of dying above, log it to the terminal. Also define a # variable so we *can* die after all checksum files have been @@ -558,7 +554,7 @@ pkg_build() { # This acts as the database entry. cp -Rf "$repo_dir" "$pkg_dir/$pkg/$pkg_db/" - log "$pkg" "Successfully built package" + log "[$pkg] Successfully built package" # Create the manifest file early and make it empty. # This ensure that the manifest is added to the manifest... @@ -583,8 +579,8 @@ pkg_build() { # Only ask for confirmation if more than one package needs to be installed. [ $# -gt 1 ] && { - log "Install built packages? [$*]" - log "Press Enter to continue or Ctrl+C to abort here" + log "Install built packages? [$*]" \ + "Press Enter to continue or Ctrl+C to abort here" # POSIX 'read' has none of the "nice" options like '-n', '-p' # etc etc. This is the most basic usage of 'read'. @@ -641,7 +637,7 @@ pkg_checksums() { pkg_conflicts() { # Check to see if a package conflicts with another. # This function takes a path to a KISS tar-ball as an argument. - log "$2" "Checking for package conflicts" + log "[$2] Checking for package conflicts" # Save the package name as we modify the argument list below. tar_file=$1 @@ -688,7 +684,7 @@ pkg_remove() { # The package is not installed, don't do anything. pkg_list "$1" >/dev/null || { - log "$1" "Not installed" + log "[$1] Not installed" return } @@ -724,7 +720,7 @@ pkg_remove() { rmdir "$KISS_ROOT/$file" 2>/dev/null || continue else rm -f -- "$KISS_ROOT/$file" || - log "$1" "Failed to remove '$file'" + log "[$1] Failed to remove '$file'" fi done < "$KISS_ROOT/$pkg_db/$1/manifest" @@ -732,7 +728,7 @@ pkg_remove() { # we no longer need to block 'Ctrl+C'. trap pkg_clean EXIT INT - log "$1" "Removed successfully" + log "[$1] Removed successfully" } pkg_install() { @@ -780,7 +776,7 @@ pkg_install() { tar pxf "$tar_file" -C "$tar_dir/$pkg_name" || die "[$pkg_name] Failed to extract tar-ball" - log "$pkg_name" "Checking that all dependencies are installed" + log "[$pkg_name] Checking that all dependencies are installed" # Make sure that all run-time dependencies are installed prior to # installing the package. @@ -795,7 +791,7 @@ pkg_install() { die "[$1] Package requires ${required_install%, }" \ "[$1]: Aborting here" - log "$pkg_name" "Installing package" + log "[$pkg_name] Installing package" # Block being able to abort the script with Ctrl+C during installation. # Removes all risk of the user aborting a package installation leaving @@ -850,11 +846,11 @@ pkg_install() { # Run the post install script and suppress errors. If it exists, # it will run, else nothing will happen. [ -x "$KISS_ROOT/$pkg_db/$pkg_name/post-install" ] && { - log "$pkg_name" "Running post-install script" + log "[$pkg_name] Running post-install script" "$KISS_ROOT/$pkg_db/$pkg_name/post-install" ||: } - log "$pkg_name" "Installed successfully" + log "[$pkg_name] Installed successfully" done } @@ -1008,7 +1004,7 @@ args() { for pkg; do pkg_checksums "$pkg" > "$(pkg_search "$pkg")/checksums" - log "$pkg" "Generated checksums" + log "[$pkg] Generated checksums" done ;; @@ -1074,14 +1070,14 @@ args() { ;; h|help|-h|--help|'') - log "kiss [b|c|i|l|r|s|u] [pkg] [pkg] [pkg]" - log "build: Build a package" - log "checksum: Generate checksums" - log "install: Install a package" - log "list: List installed packages" - log "remove: Remove a package" - log "search: Search for a package" - log "update: Check for updates" + log "kiss [b|c|i|l|r|s|u] [pkg] [pkg] [pkg]" \ + "build: Build a package" \ + "checksum: Generate checksums" \ + "install: Install a package" \ + "list: List installed packages" \ + "remove: Remove a package" \ + "search: Search for a package" \ + "update: Check for updates" ;; *) die "'kiss $action' is not a valid command" ;; |