public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/R_overlay:master commit in: files/shlib/
@ 2013-06-22 15:24 André Erdmann
  0 siblings, 0 replies; 13+ messages in thread
From: André Erdmann @ 2013-06-22 15:24 UTC (permalink / raw
  To: gentoo-commits

commit:     b333d613f634a15b59776caa277fec4db577c406
Author:     André Erdmann <dywi <AT> mailerd <DOT> de>
AuthorDate: Sat Jun 22 10:02:23 2013 +0000
Commit:     André Erdmann <dywi <AT> mailerd <DOT> de>
CommitDate: Sat Jun 22 10:02:23 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/R_overlay.git;a=commit;h=b333d613

files/shlib/functions.sh:dodir: don't deadlock

Added a missing 'shift' statement.

---
 files/shlib/functions.sh | 1 +
 1 file changed, 1 insertion(+)

diff --git a/files/shlib/functions.sh b/files/shlib/functions.sh
index d429ff2..5de73d5 100644
--- a/files/shlib/functions.sh
+++ b/files/shlib/functions.sh
@@ -267,6 +267,7 @@ dodir() {
    local fail=0
    while [ $# -gt 0 ]; do
       [ -d "${1}" ] || mkdir -p -- "${1}" || fail=$(( ${fail} + 1 ))
+      shift
    done
    return ${fail}
 }


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [gentoo-commits] proj/R_overlay:master commit in: files/shlib/
@ 2013-06-30 15:58 André Erdmann
  0 siblings, 0 replies; 13+ messages in thread
From: André Erdmann @ 2013-06-30 15:58 UTC (permalink / raw
  To: gentoo-commits

commit:     f0fafb79fcda9debe74eea42151a378ef972dab9
Author:     André Erdmann <dywi <AT> mailerd <DOT> de>
AuthorDate: Tue Jun 25 21:07:24 2013 +0000
Commit:     André Erdmann <dywi <AT> mailerd <DOT> de>
CommitDate: Tue Jun 25 21:07:24 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/R_overlay.git;a=commit;h=f0fafb79

files/shlib/functions.sh: correct typo

---
 files/shlib/functions.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/files/shlib/functions.sh b/files/shlib/functions.sh
index 5de73d5..05df7fa 100644
--- a/files/shlib/functions.sh
+++ b/files/shlib/functions.sh
@@ -303,7 +303,7 @@ yesno() {
    esac
 }
 
-# ~int str_strim ( *args )
+# ~int str_trim ( *args )
 #
 #  Removes whitespace at the beginning + end of a string
 #  and replaces any whitespace sequence within the string


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [gentoo-commits] proj/R_overlay:master commit in: files/shlib/
@ 2013-06-30 15:58 André Erdmann
  0 siblings, 0 replies; 13+ messages in thread
From: André Erdmann @ 2013-06-30 15:58 UTC (permalink / raw
  To: gentoo-commits

commit:     411585260d9f58b4b088c4ec816eb417a6c5877b
Author:     André Erdmann <dywi <AT> mailerd <DOT> de>
AuthorDate: Wed Jun 26 17:20:05 2013 +0000
Commit:     André Erdmann <dywi <AT> mailerd <DOT> de>
CommitDate: Wed Jun 26 17:20:05 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/R_overlay.git;a=commit;h=41158526

files/shlib/functions.sh: make $SHLIB PATH-like

$SHLIB is now a colon-separated list of directories where function files could
be found.

---
 files/shlib/functions.sh | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/files/shlib/functions.sh b/files/shlib/functions.sh
index 05df7fa..03eb28b 100644
--- a/files/shlib/functions.sh
+++ b/files/shlib/functions.sh
@@ -204,10 +204,23 @@ autodie() {
 load_functions() {
    [ -n "${SHLIB-}" ] || die "\$SHLIB is not set."
    local f
+   local sdir
+   local IFS="${IFS_DEFAULT}"
    while [ $# -gt 0 ]; do
-      f="${SHLIB}/${1%.sh}.sh"
-      veinfo "Trying to load functions file ${f} ... "
-      . "${f}" || die "failed to load functions file ${f}."
+      f=
+      IFS=":"
+      for sdir in ${SHLIB}; do
+         IFS="${IFS_DEFAULT}"
+         f="${sdir}/${1%.sh}.sh"
+         if [ -f "${f}" ]; then
+            veinfo "Trying to load functions file ${f} ... "
+            . "${f}" || die "failed to load functions file ${f}."
+            break 1
+         else
+            f=
+         fi
+      done
+      [ -n "${f}" ] || die "failed to locate functions file '${1}'."
       shift
    done
    return 0


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [gentoo-commits] proj/R_overlay:master commit in: files/shlib/
@ 2013-08-05 11:44 André Erdmann
  0 siblings, 0 replies; 13+ messages in thread
From: André Erdmann @ 2013-08-05 11:44 UTC (permalink / raw
  To: gentoo-commits

commit:     475ca26fe74ad9882d2b8c076328ad485f7ce017
Author:     André Erdmann <dywi <AT> mailerd <DOT> de>
AuthorDate: Mon Aug  5 09:12:56 2013 +0000
Commit:     André Erdmann <dywi <AT> mailerd <DOT> de>
CommitDate: Mon Aug  5 09:12:56 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/R_overlay.git;a=commit;h=475ca26f

files/shlib/functions.sh: constants

make some shenv variables (recently added) readonly:
* DATADIR (if defined)
* ROVERLAY_EXE, ROVERLAY_HELPER_EXE
* WORKDIR
* HAS_CHANGES

---
 files/shlib/functions.sh | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/files/shlib/functions.sh b/files/shlib/functions.sh
index 304e3e6..97e4847 100644
--- a/files/shlib/functions.sh
+++ b/files/shlib/functions.sh
@@ -73,16 +73,19 @@ readonly __HAVE_CORE_FUNCTIONS__=y
 ## make some env vars readonly
 
 readonly FUNCTIONS
-[ -z "${SHLIB-}" ] || readonly SHLIB
+[ -z "${SHLIB-}"   ] || readonly SHLIB
+[ -z "${DATADIR-}" ] || readonly DATADIR
 
 readonly DEBUG VERBOSE QUIET NO_COLOR
 
-readonly ROVERLAY_PHASE \
+readonly \
+   ROVERLAY_PHASE \
+   EBUILD ROVERLAY_EXE ROVERLAY_HELPER_EXE \
    OVERLAY S OVERLAY_NAME \
    DISTROOT \
    TMPDIR T \
-   ADDITIONS_DIR FILESDIR \
-   EBUILD NOSYNC
+   ADDITIONS_DIR FILESDIR WORKDIR \
+   NOSYNC HAS_CHANGES
 
 
 ## vars / constants


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [gentoo-commits] proj/R_overlay:master commit in: files/shlib/
@ 2013-09-04 10:16 André Erdmann
  0 siblings, 0 replies; 13+ messages in thread
From: André Erdmann @ 2013-09-04 10:16 UTC (permalink / raw
  To: gentoo-commits

commit:     1b5d0fb2b118712b03b410229294e1dae7afeb45
Author:     André Erdmann <dywi <AT> mailerd <DOT> de>
AuthorDate: Wed Sep  4 10:15:25 2013 +0000
Commit:     André Erdmann <dywi <AT> mailerd <DOT> de>
CommitDate: Wed Sep  4 10:15:25 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/R_overlay.git;a=commit;h=1b5d0fb2

files/shlib/functions: make ROVERLAY_HOOKRC a constant

---
 files/shlib/functions.sh | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/files/shlib/functions.sh b/files/shlib/functions.sh
index 97e4847..d27fd8a 100644
--- a/files/shlib/functions.sh
+++ b/files/shlib/functions.sh
@@ -73,8 +73,9 @@ readonly __HAVE_CORE_FUNCTIONS__=y
 ## make some env vars readonly
 
 readonly FUNCTIONS
-[ -z "${SHLIB-}"   ] || readonly SHLIB
-[ -z "${DATADIR-}" ] || readonly DATADIR
+[ -z "${SHLIB-}"           ] || readonly SHLIB
+[ -z "${DATADIR-}"         ] || readonly DATADIR
+[ -z "${ROVERLAY_HOOKRC-}" ] || readonly ROVERLAY_HOOKRC
 
 readonly DEBUG VERBOSE QUIET NO_COLOR
 
@@ -105,7 +106,6 @@ readonly SCRIPT_NAME="${SCRIPT_FILENAME%.*}"
 
 readonly lf=load_functions
 
-
 ## message functions
 
 # void veinfo ( message ) [**DEBUG]
@@ -360,4 +360,5 @@ is_positive() { [ -n "${1-}" ] && [ "${1}" -gt 0 2>>${DEVNULL} ]; }
 # @intcheck <0 is_negative()
 is_negative() { [ -n "${1-}" ] && [ "${1}" -lt 0 2>>${DEVNULL} ]; }
 
-fi
+
+fi # __HAVE_CORE_FUNCTIONS__


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [gentoo-commits] proj/R_overlay:master commit in: files/shlib/
@ 2013-09-04 12:50 André Erdmann
  0 siblings, 0 replies; 13+ messages in thread
From: André Erdmann @ 2013-09-04 12:50 UTC (permalink / raw
  To: gentoo-commits

commit:     87e3466bb990109cdbe694d9966a57a88a40e5f6
Author:     André Erdmann <dywi <AT> mailerd <DOT> de>
AuthorDate: Wed Sep  4 12:44:28 2013 +0000
Commit:     André Erdmann <dywi <AT> mailerd <DOT> de>
CommitDate: Wed Sep  4 12:44:28 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/R_overlay.git;a=commit;h=87e3466b

files/shlib/git: minor comment

---
 files/shlib/git.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/files/shlib/git.sh b/files/shlib/git.sh
index 2d0551f..e68b74e 100644
--- a/files/shlib/git.sh
+++ b/files/shlib/git.sh
@@ -74,4 +74,4 @@ git_has_changes() {
    return ${has_changes}
 }
 
-fi
+fi # __HAVE_GIT_FUNCTIONS__


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [gentoo-commits] proj/R_overlay:master commit in: files/shlib/
@ 2013-09-04 12:50 André Erdmann
  0 siblings, 0 replies; 13+ messages in thread
From: André Erdmann @ 2013-09-04 12:50 UTC (permalink / raw
  To: gentoo-commits

commit:     20fefd213dead9ec0d760b0473288d3ed5d34d4e
Author:     André Erdmann <dywi <AT> mailerd <DOT> de>
AuthorDate: Wed Sep  4 12:47:26 2013 +0000
Commit:     André Erdmann <dywi <AT> mailerd <DOT> de>
CommitDate: Wed Sep  4 12:47:26 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/R_overlay.git;a=commit;h=20fefd21

files/shlib/git: git_update_config()

---
 files/shlib/git.sh | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/files/shlib/git.sh b/files/shlib/git.sh
index e68b74e..3a143d3 100644
--- a/files/shlib/git.sh
+++ b/files/shlib/git.sh
@@ -8,7 +8,9 @@
 #
 # --- functions provided by this file ---
 #
-# int git_has_changes ( [*files] ), raises die()
+# int  git_has_changes ( [*files] ), raises die()
+# void git_update_config ( config_key, [user_value], [fallback_value] ),
+#  raises die()
 #
 #
 # --- variables provided by this file ---
@@ -74,4 +76,22 @@ git_has_changes() {
    return ${has_changes}
 }
 
+# void git_update_config (
+#    config_key, [user_value], [fallback_value]
+# ), raises die()
+#
+# Sets config_key to user_value (if defined), else sets it to fallback_value
+# if config_key's value is empty/does not exist.
+#
+#
+git_update_config() {
+   if [ -n "${2-}" ]; then
+      autodie ${GIT} config "${1}" "${2}"
+   elif [ -z "${3-}" ] || ${GIT} config --get "${1}" | grep -q .; then
+      true
+   else
+      autodie ${GIT} config "${1}" "${3?}"
+   fi
+}
+
 fi # __HAVE_GIT_FUNCTIONS__


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [gentoo-commits] proj/R_overlay:master commit in: files/shlib/
@ 2013-09-04 12:50 André Erdmann
  0 siblings, 0 replies; 13+ messages in thread
From: André Erdmann @ 2013-09-04 12:50 UTC (permalink / raw
  To: gentoo-commits

commit:     11b43b0d1f2cbf099b221724a9d5c04f41f37180
Author:     André Erdmann <dywi <AT> mailerd <DOT> de>
AuthorDate: Wed Sep  4 12:44:48 2013 +0000
Commit:     André Erdmann <dywi <AT> mailerd <DOT> de>
CommitDate: Wed Sep  4 12:44:48 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/R_overlay.git;a=commit;h=11b43b0d

files/shlib/functions: add EX_GIT_* error codes

---
 files/shlib/functions.sh | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/files/shlib/functions.sh b/files/shlib/functions.sh
index d27fd8a..14dab08 100644
--- a/files/shlib/functions.sh
+++ b/files/shlib/functions.sh
@@ -57,6 +57,11 @@
 # EX_ERR
 # EX_ARG_ERR
 #
+# EX_GIT_ERR
+# EX_GIT_ADD_ERR
+# EX_GIT_COMMIT_ERR
+# EX_GIT_PUSH_ERR
+#
 # SCRIPT_FILENAME
 # SCRIPT_NAME
 #
@@ -101,6 +106,11 @@ readonly DEVNULL
 readonly EX_ERR=2
 readonly EX_ARG_ERR=5
 
+readonly EX_GIT_ERR=30
+readonly EX_GIT_ADD_ERR=35
+readonly EX_GIT_COMMIT_ERR=36
+readonly EX_GIT_PUSH_ERR=37
+
 readonly SCRIPT_FILENAME="${0##*/}"
 readonly SCRIPT_NAME="${SCRIPT_FILENAME%.*}"
 
@@ -186,7 +196,7 @@ run_command_logged() {
 
 # void autodie ( *cmdv ), raises die()
 #
-#  Executes a commands. Dies on non-zero return code.
+#  Executes a command. Dies on non-zero return code.
 #
 autodie() {
    local rc=0


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [gentoo-commits] proj/R_overlay:master commit in: files/shlib/
@ 2013-09-06 10:22 André Erdmann
  0 siblings, 0 replies; 13+ messages in thread
From: André Erdmann @ 2013-09-06 10:22 UTC (permalink / raw
  To: gentoo-commits

commit:     5d015c81a4526fba80ab714c01d606c5db77875e
Author:     André Erdmann <dywi <AT> mailerd <DOT> de>
AuthorDate: Fri Sep  6 10:19:37 2013 +0000
Commit:     André Erdmann <dywi <AT> mailerd <DOT> de>
CommitDate: Fri Sep  6 10:19:37 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/R_overlay.git;a=commit;h=5d015c81

files/shlib/git: more meaningful messages

---
 files/shlib/git.sh | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/files/shlib/git.sh b/files/shlib/git.sh
index 3a143d3..24b483c 100644
--- a/files/shlib/git.sh
+++ b/files/shlib/git.sh
@@ -69,9 +69,10 @@ git_has_changes() {
    fi
 
    if ${GIT} diff-index --cached ${__GIT_DIFF_OPTS} HEAD -- "$@"; then
-      veinfo "git index: no uncommitted changes found (that's good)"
+      veinfo "git index: clean commit can be made."
    else
-      die "uncommitted changes in git index found."
+      die \
+         "clean commit cannot be made - uncommitted changes staged for commit found."
    fi
    return ${has_changes}
 }


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [gentoo-commits] proj/R_overlay:master commit in: files/shlib/
@ 2013-09-06 17:27 André Erdmann
  0 siblings, 0 replies; 13+ messages in thread
From: André Erdmann @ 2013-09-06 17:27 UTC (permalink / raw
  To: gentoo-commits

commit:     e412ce185f1e516d30373edf8e1f63292c418160
Author:     André Erdmann <dywi <AT> mailerd <DOT> de>
AuthorDate: Fri Sep  6 13:34:05 2013 +0000
Commit:     André Erdmann <dywi <AT> mailerd <DOT> de>
CommitDate: Fri Sep  6 13:34:05 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/R_overlay.git;a=commit;h=e412ce18

allow files/shlib/functions.sh to be used standalone

Setting FUNCTIONS_STANDALONE=y allows to use the functions file without
roverlay's hook env.

---
 files/shlib/functions.sh | 60 ++++++++++++++++++++++++++++++++++--------------
 1 file changed, 43 insertions(+), 17 deletions(-)

diff --git a/files/shlib/functions.sh b/files/shlib/functions.sh
index 405ed3a..ccf6d48 100644
--- a/files/shlib/functions.sh
+++ b/files/shlib/functions.sh
@@ -79,24 +79,50 @@
 if [ -z "${__HAVE_CORE_FUNCTIONS__-}" ]; then
 readonly __HAVE_CORE_FUNCTIONS__=y
 
-## make some env vars readonly
-
-readonly FUNCTIONS
-[ -z "${SHLIB-}"           ] || readonly SHLIB
-[ -z "${DATADIR-}"         ] || readonly DATADIR
-[ -z "${ROVERLAY_HOOKRC-}" ] || readonly ROVERLAY_HOOKRC
-
-readonly DEBUG VERBOSE QUIET NO_COLOR
-
-readonly \
-   ROVERLAY_PHASE \
-   EBUILD ROVERLAY_EXE ROVERLAY_HELPER_EXE \
-   OVERLAY S OVERLAY_NAME \
-   DISTROOT \
-   TMPDIR T \
-   ADDITIONS_DIR FILESDIR WORKDIR \
-   NOSYNC HAS_CHANGES
+if [ "${FUNCTIONS_STANDALONE:-n}" = "y" ]; then
+   : ${DEBUG:=n}
+   : ${VERBOSE:=y}
+   : ${QUIET:=n}
+   : ${NO_COLOR:=n}
+   readonly DEBUG VERBOSE QUIET NO_COLOR
+
+   : ${NOSYNC:=n}
+
+   if \
+      [ "${ROVERLAY_INSTALLED:-n}" = "y" ] || \
+      { [ -z "${ROVERLAY_INSTALLED-}" ] && [ -d /usr/share/roverlay ]; }
+   then
+      : ${ROVERLAY_INSTALLED:=y}
+      readonly DATADIR="/usr/share/roverlay"
+      SHLIB="${DATADIR}/shlib${SHLIB:+:}${SHLIB-}"
+      FUNCTIONS="${SHLIB}/functions.sh"
+   else
+      : ${ROVERLAY_INSTALLED:=n}
+      [ -z "${FUNCTIONS-}" ] || \
+         SHLIB="$(dirname "${FUNCTIONS}")${SHLIB:+:}${SHLIB-}"
+   fi
 
+else
+   ## make some env vars readonly
+   : ${FUNCTIONS?}
+
+   readonly FUNCTIONS
+   [ -z "${SHLIB-}"           ] || readonly SHLIB
+   [ -z "${DATADIR-}"         ] || readonly DATADIR
+   [ -z "${ROVERLAY_HOOKRC-}" ] || readonly ROVERLAY_HOOKRC
+
+   readonly DEBUG VERBOSE QUIET NO_COLOR
+
+   readonly \
+      ROVERLAY_PHASE \
+      EBUILD ROVERLAY_EXE ROVERLAY_HELPER_EXE \
+      OVERLAY S OVERLAY_NAME \
+      DISTROOT \
+      TMPDIR T \
+      ADDITIONS_DIR FILESDIR WORKDIR \
+      NOSYNC HAS_CHANGES
+
+fi # FUNCTIONS_STANDALONE
 
 ## vars / constants
 


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [gentoo-commits] proj/R_overlay:master commit in: files/shlib/
@ 2013-09-23 12:34 André Erdmann
  0 siblings, 0 replies; 13+ messages in thread
From: André Erdmann @ 2013-09-23 12:34 UTC (permalink / raw
  To: gentoo-commits

commit:     ae0fad0aeae49b8092cdce40ac2ec6c5f26236b2
Author:     André Erdmann <dywi <AT> mailerd <DOT> de>
AuthorDate: Mon Sep 23 10:19:06 2013 +0000
Commit:     André Erdmann <dywi <AT> mailerd <DOT> de>
CommitDate: Mon Sep 23 10:19:06 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/R_overlay.git;a=commit;h=ae0fad0a

files/shlib/functions.sh: do not reset FUNCTIONS

don't set FUNCTIONS if already set (could be a constant, e.g. in
roverlay-setup-interactive).

---
 files/shlib/functions.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/files/shlib/functions.sh b/files/shlib/functions.sh
index ccf6d48..08a3f36 100644
--- a/files/shlib/functions.sh
+++ b/files/shlib/functions.sh
@@ -95,7 +95,7 @@ if [ "${FUNCTIONS_STANDALONE:-n}" = "y" ]; then
       : ${ROVERLAY_INSTALLED:=y}
       readonly DATADIR="/usr/share/roverlay"
       SHLIB="${DATADIR}/shlib${SHLIB:+:}${SHLIB-}"
-      FUNCTIONS="${SHLIB}/functions.sh"
+      [ -n "${FUNCTIONS-}" ] || FUNCTIONS="${SHLIB}/functions.sh"
    else
       : ${ROVERLAY_INSTALLED:=n}
       [ -z "${FUNCTIONS-}" ] || \


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [gentoo-commits] proj/R_overlay:master commit in: files/shlib/
@ 2013-09-23 12:34 André Erdmann
  0 siblings, 0 replies; 13+ messages in thread
From: André Erdmann @ 2013-09-23 12:34 UTC (permalink / raw
  To: gentoo-commits

commit:     2e05c49467dc8618718e3f944461e9192578bc96
Author:     André Erdmann <dywi <AT> mailerd <DOT> de>
AuthorDate: Mon Sep 23 10:20:45 2013 +0000
Commit:     André Erdmann <dywi <AT> mailerd <DOT> de>
CommitDate: Mon Sep 23 10:20:45 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/R_overlay.git;a=commit;h=2e05c494

files/shlib/setup-interactive: safer --target-gid

Check if $roverlay_user is in $roverlay_group and (un)set $roverlay_group
accordingly:

* if calling user is not root: unset unless user in $roverlay_group
* if calling user is root: offer to add target user to $roverlay_group

---
 files/shlib/setup-interactive.sh | 51 +++++++++++++++++++++++++++++++++++-----
 1 file changed, 45 insertions(+), 6 deletions(-)

diff --git a/files/shlib/setup-interactive.sh b/files/shlib/setup-interactive.sh
index 73d285a..44188b3 100644
--- a/files/shlib/setup-interactive.sh
+++ b/files/shlib/setup-interactive.sh
@@ -9,6 +9,7 @@
 # --- functions provided by this file ---
 #
 # @private int setup_interactive__read_input (...)
+# @private int setup_interactive__user_in_group ( user, group )
 # void roverlay_setup_main ( *args, **ROVERLAY_INSTALLED? ), raises die()
 #
 # --- variables provided by this file ---
@@ -49,6 +50,17 @@ setup_interactive__read_input() {
    [ -n "${v0}" ]
 }
 
+# @private int setup_interactive__user_in_group ( user, group )
+#
+#  Returns 0 if %user is in %group, else 1.
+#
+setup_interactive__user_in_group() {
+   : ${2:?}
+   local user_name=$(id -nu "${1:?}" 2>>${DEVNULL})
+   [ -n "${user_name}" ] && \
+      list_has "${2}" $(groups ${user_name} 2>>${DEVNULL})
+}
+
 setup_interactive_main() {
    [ -n "${ROVERLAY_INSTALLED-}" ] || die "\$ROVERLAY_INSTALLED is not set."
    export ROVERLAY_INSTALLED
@@ -65,14 +77,12 @@ setup_interactive_main() {
    local work_root
    local want_default_hooks=y
 
-   local roverlay_user
-   local roverlay_group
+   local roverlay_user=
+   local roverlay_group=
    local user_is_root
 
    if getent group "${PN}" 1>>${DEVNULL}; then
       roverlay_group="${PN}"
-   else
-      roverlay_group=
    fi
 
    roverlay_user="$(id -nu 2>>${DEVNULL})"
@@ -87,12 +97,14 @@ setup_interactive_main() {
       if getent passwd "${PN}" 1>>${DEVNULL}; then
          roverlay_user="${PN}"
       fi
+
       if $ask \
          "Enter user/uid that will run ${PN} (user has to exist!)" \
          "${roverlay_user}"
       then
          roverlay_user="${v0}"
       fi
+
       case "${roverlay_user}" in
          '0'|'root')
             user_is_root=y
@@ -101,7 +113,31 @@ setup_interactive_main() {
             user_is_root=n
          ;;
       esac
+
+      if [ -n "${roverlay_group-}" ] && ! setup_interactive__user_in_group \
+         "${roverlay_user}" "${roverlay_group}"
+      then
+         ewarn "${roverlay_user} is not in the ${roverlay_group} group!"
+         if \
+            $ask "Add ${roverlay_user} to ${roverlay_group}? (y/n)" "n" && \
+            yesno "${v0}"
+         then
+            autodie gpasswd -a \
+               "$(id -nu "${roverlay_user}")" "${roverlay_group}"
+
+         elif ! $ask "Keep group anyway? (y/n)" "n" || ! yesno "${v0}"; then
+            roverlay_group=
+         fi
+      fi
+
    else
+      if [ -n "${roverlay_group-}" ] && ! setup_interactive__user_in_group \
+         "${roverlay_user}" "${roverlay_group}"
+      then
+         ewarn "${roverlay_user} is not in the ${roverlay_group} group!"
+         ewarn "(--target-gid will not be passed to roverlay-setup)"
+         roverlay_group=
+      fi
       user_is_root=n
    fi
 
@@ -185,15 +221,18 @@ setup_interactive_main() {
    else
       varopts="${varopts-} --no-default-hooks"
    fi
+   [ -z "${roverlay_user-}" ]  || \
+      varopts="${varopts-} --target-uid ${roverlay_user}"
+   [ -z "${roverlay_group-}" ] || \
+      varopts="${varopts-} --target-gid ${roverlay_group}"
 
+   # construct cmdv
    set -- \
       ${ROVERLAY_SETUP?} \
          -W "${work_root}" -D "${data_root}" -C "${user_conf_root}" \
          --conf-root "${ROVERLAY_CONF_ROOT}" -I "${want_conf_import}" \
-         --target-uid "${roverlay_user}" --target-gid "${roverlay_group}" \
          ${varopts-} "$@"
 
-
    if $ask "Show what would be done first? (y/n)" "n" && yesno "${v0}"; then
       autodie "$@" --pretend init
       $ask "Press Enter to continue..." || true


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [gentoo-commits] proj/R_overlay:master commit in: files/shlib/
@ 2013-11-14 18:24 André Erdmann
  0 siblings, 0 replies; 13+ messages in thread
From: André Erdmann @ 2013-11-14 18:24 UTC (permalink / raw
  To: gentoo-commits

commit:     f3d02d54049ef80def2bd96ac0c4ef81c9406382
Author:     André Erdmann <dywi <AT> mailerd <DOT> de>
AuthorDate: Thu Nov 14 17:56:29 2013 +0000
Commit:     André Erdmann <dywi <AT> mailerd <DOT> de>
CommitDate: Thu Nov 14 17:56:29 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/R_overlay.git;a=commit;h=f3d02d54

files/shlib/functions.sh: minor doc typo

---
 files/shlib/functions.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/files/shlib/functions.sh b/files/shlib/functions.sh
index 08a3f36..1603376 100644
--- a/files/shlib/functions.sh
+++ b/files/shlib/functions.sh
@@ -36,7 +36,7 @@
 #
 # str util:
 # int  yesno     ( word, **YESNO_YES=0, **YESNO_NO=1, **YESNO_EMPTY=2 )
-# ~int str_strim ( *args )
+# ~int str_trim  ( *args )
 # ~int str_upper ( *args )
 # ~int str_lower ( *args )
 # ~int str_field ( fieldspec, *args, **FIELD_SEPARATOR=' ' )


^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2013-11-14 18:24 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-04 10:16 [gentoo-commits] proj/R_overlay:master commit in: files/shlib/ André Erdmann
  -- strict thread matches above, loose matches on Subject: below --
2013-11-14 18:24 André Erdmann
2013-09-23 12:34 André Erdmann
2013-09-23 12:34 André Erdmann
2013-09-06 17:27 André Erdmann
2013-09-06 10:22 André Erdmann
2013-09-04 12:50 André Erdmann
2013-09-04 12:50 André Erdmann
2013-09-04 12:50 André Erdmann
2013-08-05 11:44 André Erdmann
2013-06-30 15:58 André Erdmann
2013-06-30 15:58 André Erdmann
2013-06-22 15:24 André Erdmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox