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