From 20f3f66ec8207da6eba70d749495a1f8a172cae6 Mon Sep 17 00:00:00 2001 From: "dylan.araps@gmail.com" Date: Fri, 13 Sep 2019 18:25:33 +0000 Subject: kiss: handle dependencies 'smarter' FossilOrigin-Name: 8fbe60ea5fd04526e7fe405b9fcf1731a51396e33510ef4b0e631aea4435bdc1 --- kiss | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/kiss b/kiss index 0142d9b..abb553c 100755 --- a/kiss +++ b/kiss @@ -187,7 +187,7 @@ pkg_depends() { # After child dependencies are added to the list, # add the package which depends on them. - deps="$deps $1 " + [ "$2" ] || deps="$deps $1 " ;; esac } @@ -341,23 +341,30 @@ pkg_build() { # also checks checksums, downloads sources and ensure all dependencies # are installed. - log "Resolving dependencies" - for pkg; do pkg_depends "$pkg"; done - # Store the explicit packages so we can handle them differently # below. Dependencies are automatically installed but packages # passed to KISS aren't. explicit=" $* " + explicit_build=" $* " + + log "Resolving dependencies" + for pkg; do pkg_depends "$pkg" explicit; done + + for pkg; do + case $deps in + *" $pkg "*) explicit=$(echo "$explicit" | sed "s/ $pkg / /g") + esac + done # Set the resolved dependency list as the function's arguments. - set -- $deps + set -- $deps $explicit # The dependency solver always lists all dependencies regardless of # whether or not they are installed. Ensure that all explicit packages # are included and ensure that all installed packages are excluded. for pkg; do - case $explicit in - *" $pkg "*) ;; + case $explicit_build in + *" $pkg "*|-) ;; *) pkg_list "$pkg" >/dev/null && continue ;; esac @@ -387,7 +394,7 @@ pkg_build() { for pkg; do # Don't check for a pre-built package if it was passed to KISS # directly. - case $explicit in + case $explicit_build in *" $pkg "*) shift set -- "$@" "$pkg" -- cgit v1.2.3 From f1513e01163e08ec883f19a9a086c1698308cf05 Mon Sep 17 00:00:00 2001 From: "dylan.araps@gmail.com" Date: Fri, 13 Sep 2019 18:30:16 +0000 Subject: kiss: handle dependencies 'smarter' FossilOrigin-Name: 061cc01524677a9b7023e67edb6676d351f87458a55d93f3cfc1484c43ed87d5 --- kiss | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/kiss b/kiss index abb553c..30fe95b 100755 --- a/kiss +++ b/kiss @@ -350,6 +350,9 @@ pkg_build() { log "Resolving dependencies" for pkg; do pkg_depends "$pkg" explicit; done + # If an explicit package is a dependency of another explicit + # package, remove it from the explicit list as it needs to be + # installed as a dependency. for pkg; do case $deps in *" $pkg "*) explicit=$(echo "$explicit" | sed "s/ $pkg / /g") @@ -364,7 +367,7 @@ pkg_build() { # are included and ensure that all installed packages are excluded. for pkg; do case $explicit_build in - *" $pkg "*|-) ;; + *" $pkg "*) ;; *) pkg_list "$pkg" >/dev/null && continue ;; esac -- cgit v1.2.3 From 8cf5c9f14b74374033720645f0b9f1af46e57d75 Mon Sep 17 00:00:00 2001 From: "dylan.araps@gmail.com" Date: Fri, 13 Sep 2019 18:31:54 +0000 Subject: kiss: handle dependencies 'smarter' FossilOrigin-Name: 1185464c59a61a8ffc4e5b8049a8f445f7de87dfc9fa50fbe6a88b454976bf04 --- kiss | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kiss b/kiss index 30fe95b..c63c06b 100755 --- a/kiss +++ b/kiss @@ -355,6 +355,8 @@ pkg_build() { # installed as a dependency. for pkg; do case $deps in + # There's no better way to remove a word from a string in + # POSIX 'sh' sadly. *" $pkg "*) explicit=$(echo "$explicit" | sed "s/ $pkg / /g") esac done -- cgit v1.2.3 From 3eafc2a57e88994fbb85c96a50ef231c95d9d99d Mon Sep 17 00:00:00 2001 From: "dylan.araps@gmail.com" Date: Fri, 13 Sep 2019 18:43:23 +0000 Subject: kiss: fix build duplicates FossilOrigin-Name: c18e3e11cd9010525bdfbf5bda1532b9ca116b60f6627f4f70bc5325d420568c --- kiss | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/kiss b/kiss index c63c06b..5635513 100755 --- a/kiss +++ b/kiss @@ -341,14 +341,22 @@ pkg_build() { # also checks checksums, downloads sources and ensure all dependencies # are installed. - # Store the explicit packages so we can handle them differently - # below. Dependencies are automatically installed but packages - # passed to KISS aren't. - explicit=" $* " - explicit_build=" $* " - log "Resolving dependencies" - for pkg; do pkg_depends "$pkg" explicit; done + for pkg; do + case $explicit in + *" $pkg "*) ;; + + *) + pkg_depends "$pkg" explicit + + # Store the explicit packages so we can handle them differently + # below. Dependencies are automatically installed but packages + # passed to KISS aren't. + explicit="$explicit $pkg " + explicit_build="$explicit_build $pkg " + ;; + esac + done # If an explicit package is a dependency of another explicit # package, remove it from the explicit list as it needs to be -- cgit v1.2.3 From 1e065ce97101b1b7d2f12a5675783e73d904189d Mon Sep 17 00:00:00 2001 From: "dylan.araps@gmail.com" Date: Fri, 13 Sep 2019 18:49:29 +0000 Subject: kiss: better comment FossilOrigin-Name: 48f4079168b4621ea7aac5537918f328b238db7bada52497f827e93b3ce959d1 --- kiss | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/kiss b/kiss index 5635513..69ed0be 100755 --- a/kiss +++ b/kiss @@ -349,9 +349,8 @@ pkg_build() { *) pkg_depends "$pkg" explicit - # Store the explicit packages so we can handle them differently - # below. Dependencies are automatically installed but packages - # passed to KISS aren't. + # Mark packages passed on the command-line + # separately from those detected as dependencies. explicit="$explicit $pkg " explicit_build="$explicit_build $pkg " ;; -- cgit v1.2.3 From bf3d78de744e11d840ae72c1dbefdf1116f35988 Mon Sep 17 00:00:00 2001 From: "dylan.araps@gmail.com" Date: Fri, 13 Sep 2019 20:52:14 +0000 Subject: kiss: extract first FossilOrigin-Name: a897b18a4b04cef5f1ff2d619c511c76a8541b73db3d09221ae82b1c191b2069 --- kiss | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/kiss b/kiss index 69ed0be..066e089 100755 --- a/kiss +++ b/kiss @@ -352,11 +352,12 @@ pkg_build() { # Mark packages passed on the command-line # separately from those detected as dependencies. explicit="$explicit $pkg " - explicit_build="$explicit_build $pkg " ;; esac done + explicit_build="$explicit" + # If an explicit package is a dependency of another explicit # package, remove it from the explicit list as it needs to be # installed as a dependency. @@ -372,8 +373,7 @@ pkg_build() { set -- $deps $explicit # The dependency solver always lists all dependencies regardless of - # whether or not they are installed. Ensure that all explicit packages - # are included and ensure that all installed packages are excluded. + # whether or not they are installed. Filter out installed dependencies. for pkg; do case $explicit_build in *" $pkg "*) ;; @@ -456,11 +456,13 @@ pkg_build() { # Die here as packages with differing checksums were found above. [ "$mismatch" ] && die "Checksum mismatch with: ${mismatch% }" + # Extract all packages before build to catch any extraction + # errors early. + for pkg; do pkg_extract "$pkg"; done + # Finally build and create tarballs for all passed packages and # dependencies. for pkg; do - pkg_extract "$pkg" - repo_dir=$(pkg_find "$pkg") # Install built packages to a directory under the package name -- cgit v1.2.3 From 415996a57943fe3aad3dfe4d5979ffc67f8ba3dc Mon Sep 17 00:00:00 2001 From: "dylan.araps@gmail.com" Date: Fri, 13 Sep 2019 21:19:19 +0000 Subject: kiss: add helper function to remove duplicate code FossilOrigin-Name: e3aeedfacdab1fc8e663d01650a3e07816ebdacc7b972dbabf168216a14c6e6c --- kiss | 148 +++++++++++++++++++++++++++++-------------------------------------- 1 file changed, 65 insertions(+), 83 deletions(-) diff --git a/kiss b/kiss index 066e089..6c5ebac 100755 --- a/kiss +++ b/kiss @@ -24,6 +24,13 @@ log() { printf '\033[1;32m->\033[m %s.\n' "$@" } +contains() { + # Check if a "string list" contains a word. + case " $1 " in *" $2 "*) return 0; esac + + return 1 +} + pkg_lint() { # Check that each mandatory file in the package entry exists. log "[$1] Checking repository files" @@ -172,24 +179,19 @@ pkg_depends() { # This does a depth-first search. The deepest dependencies are # listed first and then the parents in reverse order. - case $deps in - # Dependency is already in list, skip it. - *" $1 "*) ;; - - *) - # Recurse through the dependencies of the child - # packages. Keep doing this. - [ -f "$repo_dir/depends" ] && - while read -r dep _; do - [ "${dep##\#*}" ] || continue - pkg_depends "$dep" ||: - done < "$repo_dir/depends" - - # After child dependencies are added to the list, - # add the package which depends on them. - [ "$2" ] || deps="$deps $1 " - ;; - esac + contains "$deps" "$1" || { + # Recurse through the dependencies of the child + # packages. Keep doing this. + [ -f "$repo_dir/depends" ] && + while read -r dep _; do + [ "${dep##\#*}" ] || continue + pkg_depends "$dep" ||: + done < "$repo_dir/depends" + + # After child dependencies are added to the list, + # add the package which depends on them. + [ "$2" ] || deps="$deps $1 " + } } pkg_verify() { @@ -343,17 +345,13 @@ pkg_build() { log "Resolving dependencies" for pkg; do - case $explicit in - *" $pkg "*) ;; - - *) - pkg_depends "$pkg" explicit + contains "$explicit" "$pkg" || { + pkg_depends "$pkg" explicit - # Mark packages passed on the command-line - # separately from those detected as dependencies. - explicit="$explicit $pkg " - ;; - esac + # Mark packages passed on the command-line + # separately from those detected as dependencies. + explicit="$explicit $pkg " + } done explicit_build="$explicit" @@ -362,11 +360,10 @@ pkg_build() { # package, remove it from the explicit list as it needs to be # installed as a dependency. for pkg; do - case $deps in - # There's no better way to remove a word from a string in - # POSIX 'sh' sadly. - *" $pkg "*) explicit=$(echo "$explicit" | sed "s/ $pkg / /g") - esac + # There's no better way to remove a word from a string in + # POSIX 'sh' sadly. + contains "$deps" "$pkg" && + explicit=$(echo "$explicit" | sed "s/ $pkg / /g") done # Set the resolved dependency list as the function's arguments. @@ -375,10 +372,9 @@ pkg_build() { # The dependency solver always lists all dependencies regardless of # whether or not they are installed. Filter out installed dependencies. for pkg; do - case $explicit_build in - *" $pkg "*) ;; - *) pkg_list "$pkg" >/dev/null && continue ;; - esac + contains "$explicit_build" "$pkg" || { + pkg_list "$pkg" >/dev/null && continue + } build_packages="$build_packages$pkg " done @@ -406,13 +402,11 @@ pkg_build() { for pkg; do # Don't check for a pre-built package if it was passed to KISS # directly. - case $explicit_build in - *" $pkg "*) - shift - set -- "$@" "$pkg" - continue - ;; - esac + contains "$explicit_build" "$pkg" && { + shift + set -- "$@" "$pkg" + continue + } # Figure out the version and release. read -r version release < "$(pkg_find "$pkg")/version" @@ -492,9 +486,7 @@ pkg_build() { # Install only dependencies of passed packages. # Skip this check if this is a package update. - case $explicit in - *" $pkg "*) [ "$pkg_update" ] || continue - esac + contains "$explicit" "$pkg" && [ -z "$pkg_update" ] && continue log "[$pkg] Needed as a dependency or has an update, installing" args i "$pkg" @@ -789,22 +781,18 @@ pkg_updates() { continue } - case $repos in - # If the repository has already been updated, skip it. - *" $PWD "*) ;; - *) - repos="$repos $PWD " + contains "$repos" "$PWD" || { + repos="$repos $PWD " - log "[$PWD] Updating repository" + log "[$PWD] Updating repository" - if [ -w "$PWD" ]; then - git pull - else - log "[$PWD] Need root to update" - sudo git pull - fi - ;; - esac + if [ -w "$PWD" ]; then + git pull + else + log "[$PWD] Need root to update" + sudo git pull + fi + } done log "Checking for new package versions" @@ -828,26 +816,24 @@ pkg_updates() { done # If the package manager has an update, handle it first. - case $outdated in - *" kiss "*) - log "Detected package manager update" \ - "The package manager will be updated first" \ - "Continue?: Press Enter to continue or Ctrl+C to abort here" + contains "$outdated" kiss && { + log "Detected package manager update" \ + "The package manager will be updated first" \ + "Continue?: 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'. - # '_' is used as 'dash' errors when no variable is given to 'read'. - read -r _ || exit + # POSIX 'read' has none of the "nice" options like '-n', '-p' + # etc etc. This is the most basic usage of 'read'. + # '_' is used as 'dash' errors when no variable is given to 'read'. + read -r _ || exit - pkg_build kiss - args i kiss + pkg_build kiss + args i kiss - log "Updated the package manager" \ - "Re-run 'kiss update' to update your system" + log "Updated the package manager" \ + "Re-run 'kiss update' to update your system" - exit 0 - ;; - esac + exit 0 + } # Disable globbing. set -f @@ -951,9 +937,7 @@ args() { # The purpose of these two loops is to order the # argument list based on dependence. for pkg in $deps; do - case " $* " in - *" $pkg "*) pkg_install "$pkg" ;; - esac + contains "$*" "$pkg" && pkg_install "$pkg" done ;; @@ -966,9 +950,7 @@ args() { # Reverse the list of dependencies filtering out anything # not explicitly set for removal. for pkg in $deps; do - case " $* " in - *" $pkg "*) remove_pkgs="$pkg $remove_pkgs" - esac + contains "$*" "$pkg" && remove_pkgs="$pkg $remove_pkgs" done for pkg in $remove_pkgs; do -- cgit v1.2.3 From 3dae8d344f19875b89c99f73ced8303ee3de61dd Mon Sep 17 00:00:00 2001 From: "dylan.araps@gmail.com" Date: Fri, 13 Sep 2019 21:20:21 +0000 Subject: kiss: clean up FossilOrigin-Name: ca9dbc481c4759a19d6e836100aef2cb77e9089d03eccff7b3c8a908094ab130 --- kiss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kiss b/kiss index 6c5ebac..465ce87 100755 --- a/kiss +++ b/kiss @@ -354,7 +354,7 @@ pkg_build() { } done - explicit_build="$explicit" + explicit_build=$explicit # If an explicit package is a dependency of another explicit # package, remove it from the explicit list as it needs to be -- cgit v1.2.3 From 433a4c8d8744f54df2568abb733e94cd80aa18a8 Mon Sep 17 00:00:00 2001 From: "dylan.araps@gmail.com" Date: Fri, 13 Sep 2019 21:20:32 +0000 Subject: kiss: clean up FossilOrigin-Name: 87c19a6960fbe64965b74a98c6f9c7d654576ab4b43f6b99f9f0d28e3efbd7be --- kiss | 1 + 1 file changed, 1 insertion(+) diff --git a/kiss b/kiss index 465ce87..d5aa9f4 100755 --- a/kiss +++ b/kiss @@ -344,6 +344,7 @@ pkg_build() { # are installed. log "Resolving dependencies" + for pkg; do contains "$explicit" "$pkg" || { pkg_depends "$pkg" explicit -- cgit v1.2.3 From 6fb5f4908998e8d1814bb42c982d04fd6dda8423 Mon Sep 17 00:00:00 2001 From: "dylan.araps@gmail.com" Date: Fri, 13 Sep 2019 21:28:30 +0000 Subject: kiss: clean up FossilOrigin-Name: 0c0035cf51023fba8dfa74ed880fc45f69452aa50525e8763acda128f36ec12a --- kiss | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/kiss b/kiss index d5aa9f4..87ca4d5 100755 --- a/kiss +++ b/kiss @@ -612,7 +612,7 @@ pkg_remove() { if [ -d "$KISS_ROOT/$file" ]; then rmdir "$KISS_ROOT/$file" 2>/dev/null || continue else - rm -f -- "$KISS_ROOT/$file" + rm -f "$KISS_ROOT/$file" fi done < "$sys_db/$1/manifest" @@ -727,8 +727,7 @@ pkg_install() { unlink "$file" ||: # Skip directory symlinks. - elif [ -L "$file" ] && [ -d "$file" ]; then - : + elif [ -L "$file" ] && [ -d "$file" ]; then : # Remove directories if empty. elif [ -d "$file" ]; then -- cgit v1.2.3 From 1a9ead11568cb947726ca7d6baea877733a1fb1f Mon Sep 17 00:00:00 2001 From: "dylan.araps@gmail.com" Date: Fri, 13 Sep 2019 21:47:58 +0000 Subject: kiss: clean up FossilOrigin-Name: 1edeb1f6f400dc13819741de892658bfe421e193e55a5bb379b3579decf9c922 --- kiss | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/kiss b/kiss index 87ca4d5..98f1776 100755 --- a/kiss +++ b/kiss @@ -367,21 +367,17 @@ pkg_build() { explicit=$(echo "$explicit" | sed "s/ $pkg / /g") done - # Set the resolved dependency list as the function's arguments. - set -- $deps $explicit - # The dependency solver always lists all dependencies regardless of # whether or not they are installed. Filter out installed dependencies. - for pkg; do + for pkg in $deps $explicit; do contains "$explicit_build" "$pkg" || { pkg_list "$pkg" >/dev/null && continue } - build_packages="$build_packages$pkg " + build="$build$pkg " done - # Set the filtered dependency list as the function's arguments. - set -- $build_packages + set -- $build log "Building: $*" -- cgit v1.2.3