aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordylan.araps@gmail.com <dylan.araps@gmail.com>2019-08-19 18:02:18 +0000
committerdylan.araps@gmail.com <dylan.araps@gmail.com>2019-08-19 18:02:18 +0000
commit5eaf24755283c8c1c21f19743bb3e74760615662 (patch)
treeecf4d2c0132cd96e3f0f4e70c45741d020c22065
parent0b1a8f9810f0674bf3523c90bdc73da5172e877c (diff)
downloadcpt-5eaf24755283c8c1c21f19743bb3e74760615662.tar.gz
kiss: simplify logs
FossilOrigin-Name: 201f23e845abbcbb819abd2a5534e9f527772bb20d25738b0e151eb12d227025
-rwxr-xr-xkiss86
1 files changed, 43 insertions, 43 deletions
diff --git a/kiss b/kiss
index fc25760..fb6cfe9 100755
--- a/kiss
+++ b/kiss
@@ -39,15 +39,15 @@ log() {
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")
cd "$repo_dir" || die "'$repo_dir' not accessible"
- [ -f sources ] || die "[$1]: Sources file not found"
- [ -x build ] || die "[$1]: Build file not found or not executable"
- [ -s version ] || die "[$1]: Version file not found or empty"
+ [ -f sources ] || die "[$1] Sources file not found"
+ [ -x build ] || die "[$1] Build file not found or not executable"
+ [ -s version ] || die "[$1] Version file not found or empty"
# Ensure that the release field in the version file is set
# to something. The above test checks for the version field inclusively.
@@ -120,7 +120,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,22 +143,22 @@ pkg_sources() {
# Remote source.
*://*)
[ -f "${src##*/}" ] && {
- log "[$1]: Found cached source '${src##*/}'"
+ log "[$1] Found cached source '${src##*/}'"
continue
}
wget "$src" || {
rm -f "${src##*/}"
- die "[$1]: Failed to download $src"
+ die "[$1] Failed to download $src"
}
;;
# Local files (Any source that is non-remote is assumed to be local).
*)
[ -f "$repo_dir/$src" ] ||
- die "[$1]: No local file '$src'"
+ die "[$1] No local file '$src'"
- log "[$1]: Found local file '$src'"
+ log "[$1] Found local file '$src'"
;;
esac
done < "$repo_dir/sources"
@@ -167,7 +167,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
@@ -193,7 +193,7 @@ pkg_extract() {
*://*.tar*|*://*.tgz)
tar xf "$src_dir/$1/${src##*/}" -C "./$dest" \
--strip-components 1 \
- || die "[$1]: Couldn't extract ${src##*/}"
+ || die "[$1] Couldn't extract ${src##*/}"
;;
# Local files (Any source that is non-remote is assumed to be local).
@@ -205,7 +205,7 @@ pkg_extract() {
cp -f "$src_dir/$1/${src##*/}" "./$dest"
else
- die "[$1]: Local file $src not found"
+ die "[$1] Local file $src not found"
fi
;;
esac
@@ -258,7 +258,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
@@ -279,7 +279,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.
@@ -311,7 +311,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.
@@ -376,7 +376,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.
@@ -388,13 +388,13 @@ pkg_manifest() (
find . -mindepth 1 -type d -exec printf '%s/\n' {} + -or -print |
sort -r | sed -e ss.ss > "$pkg_dir/$1/$pkg_db/$1/manifest"
- log "[$1]: Generated manifest"
+ log "[$1] Generated 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
@@ -408,9 +408,9 @@ pkg_tar() {
# is used here to correct issues with file ownership.
fakeroot \
tar zpcf "$bin_dir/$1#$version-$release.tar.gz" -C "$pkg_dir/$1" . ||
- die "[$1]: Failed to create tar-ball"
+ die "[$1] Failed to create tar-ball"
- log "[$1]: Successfully created tar-ball"
+ log "[$1] Successfully created tar-ball"
}
pkg_build() {
@@ -490,7 +490,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
}
@@ -509,7 +509,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
@@ -546,13 +546,13 @@ pkg_build() {
# Move to the build directory and call the build script.
cd "$mak_dir/$pkg"
fakeroot "$repo_dir/build" "$pkg_dir/$pkg" ||
- die "[$pkg]: Build failed"
+ die "[$pkg] Build failed"
# Copy the repository files to the package directory.
# 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...
@@ -617,12 +617,12 @@ pkg_checksums() {
# Die here if source for some reason, doesn't exist.
[ "$src_path" ] ||
- die "[$1]: Couldn't find source '$src'"
+ die "[$1] Couldn't find source '$src'"
# An easy way to get 'sha256sum' to print with the 'basename'
# of files is to 'cd' to the file's directory beforehand.
(cd "$src_path" && sha256sum "${src##*/}") ||
- die "[$1]: Failed to generate checksums"
+ die "[$1] Failed to generate checksums"
# Unset this variable so it isn't used again on a failed
# source. There's no 'local' keyword in POSIX sh.
@@ -635,7 +635,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"
# Extract manifest from the tar-ball and only extract files entries.
tar xf "$1" -O "./$pkg_db/$2/manifest" |
@@ -669,7 +669,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
}
@@ -688,8 +688,8 @@ pkg_remove() {
set -f
[ "$required_by" ] &&
- die "[$1]: Package is required by ${required_by%, }" \
- "[$1]: Aborting here..."
+ die "[$1] Package is required by ${required_by%, }" \
+ "[$1] Aborting here..."
# Block being able to abort the script with 'Ctrl+C' during removal.
# Removes all risk of the user aborting a package removal leaving
@@ -705,7 +705,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"
@@ -713,7 +713,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() {
@@ -759,9 +759,9 @@ pkg_install() {
# 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"
+ 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.
@@ -773,10 +773,10 @@ pkg_install() {
done < "$tar_dir/$pkg_name/$pkg_db/$pkg_name/depends"
[ "$required_install" ] &&
- die "[$1]: Package requires ${required_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
@@ -830,11 +830,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
}
@@ -857,7 +857,7 @@ pkg_updates() {
cd "$(git rev-parse --show-toplevel 2>/dev/null)" 2>/dev/null ||:
[ -d .git ] || {
- log "[$repo]: Not a git repository, skipping"
+ log "[$repo] Not a git repository, skipping"
continue
}
@@ -867,12 +867,12 @@ pkg_updates() {
*)
repos="$repos $PWD "
- log "[$PWD]: Updating repository"
+ log "[$PWD] Updating repository"
if [ -w "$PWD" ]; then
git pull
else
- log "[$PWD]: Need root to update"
+ log "[$PWD] Need root to update"
sudo git pull
fi
;;
@@ -975,7 +975,7 @@ args() {
for pkg; do
pkg_checksums "$pkg" > "$(pkg_search "$pkg")/checksums"
- log "[$pkg]: Generated checksums"
+ log "[$pkg] Generated checksums"
done
;;
@@ -1040,7 +1040,7 @@ args() {
for pkg in $remove_pkgs; do
pkg_list "$pkg" >/dev/null ||
- die "[$pkg]: Not installed"
+ die "[$pkg] Not installed"
pkg_remove "$pkg" check
done