[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Chicken-users] Add support for sudo alternatives
From: |
Timo Myyrä |
Subject: |
[Chicken-users] Add support for sudo alternatives |
Date: |
Fri, 25 Mar 2016 16:11:41 +0200 |
Hi,
Here is an simple patch to add support for alternative commands than sudo.
OpenBSD doesn't have sudo in base install so this allows chicken-install to work
with OpenBSD doas (and others like it).
The idea is that if user provides SUDO=/usr/bin/doas in env, then
chicken-install will run that command when using `-s' flag.
Timo
diff --git a/chicken-install.1 b/chicken-install.1
index 065f987..359e540 100644
--- a/chicken-install.1
+++ b/chicken-install.1
@@ -45,6 +45,10 @@ path selected during configuration (usually
.B $prefix/lib/chicken/<binary\-version>
)
+.TP
+.B SUDO
+The command to execute when using \-s flag in command. If not provided,
defaults to the sudo(1).
+
.SH DOCUMENTATION
More information can be found in the
diff --git a/chicken-install.scm b/chicken-install.scm
index 7420160..610097d 100644
--- a/chicken-install.scm
+++ b/chicken-install.scm
@@ -805,7 +805,7 @@ usage: chicken-install [OPTION | EXTENSION[:VERSION]] ...
-l -location LOCATION install from given location instead of default
-t -transport TRANSPORT use given transport instead of default
-proxy HOST[:PORT] download via HTTP proxy
- -s -sudo use sudo(1) for filesystem operations
+ -s -sudo use external command to elevate privileges for
filesystem operations
-r -retrieve only retrieve egg into current directory,
don't install
-n -no-install do not install, just build (implies `-keep')
-p -prefix PREFIX change installation prefix to PREFIX
@@ -829,7 +829,7 @@ usage: chicken-install [OPTION | EXTENSION[:VERSION]] ...
-show-depends display a list of egg dependencies for the
given egg(s)
-show-foreign-depends display a list of foreign dependencies for the
given egg(s)
-chicken-install recognizes the http_proxy, and proxy_auth environment
variables, if set.
+chicken-install recognizes the SUDO, http_proxy and proxy_auth environment
variables, if set.
EOF
);|
diff --git a/chicken-uninstall.1 b/chicken-uninstall.1
index 8767cc6..90b6f46 100644
--- a/chicken-uninstall.1
+++ b/chicken-uninstall.1
@@ -44,6 +44,9 @@ path selected during configuration (usually
.B $prefix/lib/chicken/<binary\-version>
)
+.TP
+.B SUDO
+The command to execute when using \-s flag in command. If not provided,
defaults to the sudo(1).
.SH DOCUMENTATION
diff --git a/chicken-uninstall.scm b/chicken-uninstall.scm
index 04250ed..488cc8a 100644
--- a/chicken-uninstall.scm
+++ b/chicken-uninstall.scm
@@ -109,7 +109,7 @@ usage: chicken-uninstall [OPTION | PATTERN] ...
-version show version and exit
-force don't ask, delete whatever matches
-exact treat PATTERN as exact match (not a pattern)
- -s -sudo use sudo(1) for deleting files
+ -s -sudo use external command to elevate privileges for
deleting files
-p -prefix PREFIX change installation prefix to PREFIX
-deploy prefix is a deployment directory
-host when cross-compiling, uninstall host
extensions only
diff --git a/setup-api.scm b/setup-api.scm
index d675f0f..402e11b 100644
--- a/setup-api.scm
+++ b/setup-api.scm
@@ -155,12 +155,15 @@
(print "Warning: cannot install as superuser with Windows") )
(define (unix-sudo-install-setup)
- (set! *copy-command* "sudo cp -r")
- (set! *remove-command* "sudo rm -fr")
- (set! *move-command* "sudo mv")
- (set! *chmod-command* "sudo chmod")
- (set! *ranlib-command* "sudo ranlib")
- (set! *mkdir-command* "sudo mkdir") )
+
+(define (unix-sudo-install-setup)
+ (let ((sudo-cmd (or (get-environment-variable "SUDO") "sudo")))
+ (set! *copy-command* (sprintf "~a cp -r" sudo-cmd))
+ (set! *remove-command* (sprintf "~a rm -rf" sudo-cmd))
+ (set! *move-command* (sprintf "~a mv" sudo-cmd))
+ (set! *chmod-command* (sprintf "~a chmod" sudo-cmd))
+ (set! *ranlib-command* (sprintf "~a ranlib" sudo-cmd))
+ (set! *mkdir-command* (sprintf "~a mkdir" sudo-cmd))))
(define (user-install-setup)
(set! *sudo* #f)
@@ -608,7 +611,8 @@
(error 'remove-directory "cannot remove - directory not found" dir)
#f))
(*sudo*
- (ignore-errors ($system (sprintf "sudo rm -fr ~a" (shellpath dir)))))
+ (ignore-errors (let ((sudo-cmd (or (get-environment-variable "SUDO")
"sudo")))
+ ($system (sprintf "~a rm -fr ~a" sudo-cmd (shellpath
dir)))))
(else
(let walk ((dir dir))
(let ((files (directory dir #t)))
- [Chicken-users] Add support for sudo alternatives,
Timo Myyrä <=