aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordylan.araps@gmail.com <dylan.araps@gmail.com>2019-08-12 23:57:31 +0000
committerdylan.araps@gmail.com <dylan.araps@gmail.com>2019-08-12 23:57:31 +0000
commitb9a72e1d75e1dcb1a21aa06f90d03f4d7665ee16 (patch)
treeb61635d054923a01ceee59d958c10a2b16391769
parentaf4314c30b3b0887d7ec91490f3240465f18fa31 (diff)
downloadcpt-b9a72e1d75e1dcb1a21aa06f90d03f4d7665ee16.tar.gz
kiss: fix issues with requiring root.
FossilOrigin-Name: 8a8f4ac9d1da6173204c7075d0b9a98ff18aefa789e3e086e4dcac8e9ac0f822
-rwxr-xr-x[-rw-r--r--].travis.yml0
-rwxr-xr-x[-rw-r--r--]LICENSE.md0
-rwxr-xr-x[-rw-r--r--]README.md0
-rwxr-xr-xkiss29
4 files changed, 21 insertions, 8 deletions
diff --git a/.travis.yml b/.travis.yml
index f03f369..f03f369 100644..100755
--- a/.travis.yml
+++ b/.travis.yml
diff --git a/LICENSE.md b/LICENSE.md
index 6867a5b..6867a5b 100644..100755
--- a/LICENSE.md
+++ b/LICENSE.md
diff --git a/README.md b/README.md
index a9ca00b..a9ca00b 100644..100755
--- a/README.md
+++ b/README.md
diff --git a/kiss b/kiss
index 2451615..270d2e9 100755
--- a/kiss
+++ b/kiss
@@ -133,7 +133,6 @@ pkg_sources() {
# belongs to. This avoid conflicts between two packages having a
# source of the same name.
mkdir -p "$src_dir/$1"
- chmod 1777 "$src_dir/$1"
cd "$src_dir/$1"
# Find the package's repository files. This needs to keep
@@ -424,9 +423,11 @@ pkg_build() {
shift
# Install any pre-built binaries if they exist.
+ # 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."
- pkg_install "$bin_dir/$pkg#$version-$release.tar.gz"
+ log "[$pkg]: Found pre-built binary, installing..."
+ args i "$bin_dir/$pkg#$version-$release.tar.gz"
continue
}
@@ -892,7 +893,14 @@ args() {
i|in|ins|inst|insta|instal|install)
shift
[ "$1" ] || die "'kiss install' requires an argument."
- root_check
+
+ # Rerun the script with 'sudo' if the user isn't root.
+ # Cheeky but 'sudo' can't be used on shell functions
+ # themselves.
+ [ "$(id -u)" != 0 ] && {
+ sudo KISS_PATH=$KISS_PATH kiss i "$@"
+ return
+ }
# Create a list of each package's dependencies.
for pkg; do
@@ -918,7 +926,15 @@ args() {
r|re|rem|remo|remov|remove)
shift
[ "$1" ] || die "'kiss remove' requires an argument."
- root_check
+
+ # Rerun the script with 'sudo' if the user isn't root.
+ # Cheeky but 'sudo' can't be used on shell functions
+ # themselves.
+ [ "$(id -u)" != 0 ] && {
+ sudo KISS_PATH=$KISS_PATH kiss r "$@"
+ return
+ }
+
log "Removing packages..."
# Create a list of each package's dependencies.
@@ -1063,9 +1079,6 @@ main() {
"${bin_dir:=$cac_dir/bin}" \
|| die "Couldn't create cache directories."
- # Set sticky bit in the "permanent" directories so users can write to it.
- chmod 1777 "$cac_dir" "$src_dir" "$bin_dir"
-
args "$@"
}