Accepting request 991609 from Virtualization:containers

- Fix a (potential) problem with man and manpages
  * Patch added:
    0002-distrobox-handle-situations-with-weird-manpages-setu.patch
- Default to distrobox-enter when only typing distrobox
  * Patch added:
    0003-distrobox-if-no-command-is-specified-default-to-ente.patch
- Reordered the patchqueue:
  * Patch removed:
    0002-opensuse-check-for-the-config-file-in-usr-etc-too.patch
  * Patch added:
    0004-opensuse-check-for-the-config-file-in-usr-etc-too.patch
- enable non-interactive mode by default
- Fix a but with automatic cretion of rootful containers
  * Patch added:
    0001-enter-fix-automatic-container-creation-when-r-is-use.patch
- Rework the /usr/etc config file patch (better changelog)
  * Patch removed:
    0001-Read-config-in-usr-etc-too.patch
  * Patch added:
    0002-opensuse-check-for-the-config-file-in-usr-etc-too.patch
- Switched to %autosetup in the spec file

OBS-URL: https://build.opensuse.org/request/show/991609
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/distrobox?expand=0&rev=6
This commit is contained in:
Richard Brown 2022-07-29 14:47:24 +00:00 committed by Git OBS Bridge
commit a52c2d0995
7 changed files with 236 additions and 9 deletions

View File

@ -0,0 +1,44 @@
From 2773eff4dcafc8df176f74b001a56557c7893507 Mon Sep 17 00:00:00 2001
From: Dario Faggioli <dfaggioli@suse.com>
Date: Wed, 27 Jul 2022 13:17:34 +0200
Subject: [PATCH 1/4] enter: fix automatic container creation when '-r' is used
(#364)
When calling 'distrobox-create', from inside 'distrobox-enter' (in cause
automatic creation of the container is enabled) we were not "forwarding"
the '-r' flag properly. Therefore, when 'distrobox enter -r' was used,
we were trying to create a rootless container, which is obviously wrong!
Fixes: 8b195e3328d0a6fb19564555dec067c607fa8116
Signed-off-by: Dario Faggioli <dfaggioli@suse.com>
(cherry picked from commit 19aa7bfccc1726551eda9df36403da58beb00823)
Signed-off-by: Dario Faggioli <dfaggioli@suse.com>
---
distrobox-enter | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/distrobox-enter b/distrobox-enter
index 138446c..e754c6b 100755
--- a/distrobox-enter
+++ b/distrobox-enter
@@ -407,10 +407,15 @@ if [ "${container_status}" = "unknown" ]; then
case "${response}" in
y | Y | Yes | yes | YES)
# Ok, let's create the container with just 'distrobox create $container_name
+ create_command="$(dirname "${0}")/distrobox-create"
+ if [ "${rootful}" -ne 0 ]; then
+ create_command="${create_command} --root"
+ fi
+ create_command="${create_command} -i ${container_image} -n ${container_name}"
printf >&2 "Creating the container with command:\n"
- printf >&2 " distrobox create -i %s %s\n" "${container_image}" "${container_name}"
+ printf >&2 " %s\n" "${create_command}"
if [ "${dryrun}" -ne 1 ]; then
- "$(dirname "${0}")"/distrobox-create -i "${container_image}" -n "${container_name}"
+ eval "${create_command}"
fi
;;
n | N | No | no | NO)
--
2.37.1

View File

@ -0,0 +1,75 @@
From d8f81bb5a6169b4efce137c3538afa770abb1fbb Mon Sep 17 00:00:00 2001
From: Dario Faggioli <dfaggioli@suse.com>
Date: Thu, 28 Jul 2022 11:02:05 +0200
Subject: [PATCH 2/4] distrobox: handle situations with weird manpages setup
So, assume you're distro strip manpages during packages install. That
might mean the `man` command exists, but there isn't any entry for
anything. In that case, the following happens:
distrobox --help
No manual entry for distrobox
An error occurred
Fix this by checking also the return value of the `man` invocation too,
and show our own help if it failed.
Signed-off-by: Dario Faggioli <dfaggioli@suse.com>
(cherry picked from https://github.com/89luca89/distrobox/pull/365)
Signed-off-by: Dario Faggioli <dfaggioli@suse.com>
---
distrobox | 23 +++++++++++++----------
1 file changed, 13 insertions(+), 10 deletions(-)
diff --git a/distrobox b/distrobox
index 5cbb6de..4e37031 100755
--- a/distrobox
+++ b/distrobox
@@ -19,8 +19,6 @@
# along with distrobox; if not, see <http://www.gnu.org/licenses/>.
# POSIX
-set -o errexit
-set -o nounset
trap '[ "$?" -ne 0 ] && printf "\nAn error occurred\n"' EXIT
@@ -50,6 +48,19 @@ if [ $# -eq 0 ]; then
exit
fi
+# Handle 'help' here, before setting 'errexit', so we have a chance
+# to show our help if the man command is there but fails.
+if [ "$1" = "help" ] || [ "$1" = "--help" ] || [ "$1" = "-h" ]; then
+ if command -v man > /dev/null; then
+ man distrobox && exit 0
+ fi
+ show_help
+ exit 0
+fi
+
+set -o errexit
+set -o nounset
+
distrobox_path="$(dirname "${0}")"
distrobox_command="${1}"
shift
@@ -76,14 +87,6 @@ case "${distrobox_command}" in
printf "distrobox: %s\n" "${version}"
exit 0
;;
- help | --help | -h)
- if command -v man > /dev/null; then
- man distrobox
- exit 0
- fi
- show_help
- exit 0
- ;;
*) # Default case: If no more options then break out of the loop.
printf >&2 "Error: invalid command\n"
show_help
--
2.37.1

View File

@ -0,0 +1,73 @@
From 0f1a928d310ea35465f892ff0bda563d110a4ce7 Mon Sep 17 00:00:00 2001
From: Dario Faggioli <dfaggioli@suse.com>
Date: Thu, 28 Jul 2022 10:10:28 +0200
Subject: [PATCH 3/4] distrobox: if no command is specified, default to enter
If just `distrobox` is invoked, without any command, assume
`distrobox enter`.
Signed-off-by: Dario Faggioli <dfaggioli@suse.com>
---
distrobox | 19 ++++++++++++-------
docs/README.md | 1 +
2 files changed, 13 insertions(+), 7 deletions(-)
diff --git a/distrobox b/distrobox
index 4e37031..ce0469c 100755
--- a/distrobox
+++ b/distrobox
@@ -19,6 +19,11 @@
# along with distrobox; if not, see <http://www.gnu.org/licenses/>.
# POSIX
+# Optional env variables:
+# DBX_DEFAULT_COMMAND
+
+default_command="enter"
+[ -n "${DBX_DEFAULT_COMMAND}" ] && default_command="${DBX_DEFAULT_COMMAND}"
trap '[ "$?" -ne 0 ] && printf "\nAn error occurred\n"' EXIT
@@ -43,11 +48,6 @@ Choose one of the available commands:
EOF
}
-if [ $# -eq 0 ]; then
- show_help
- exit
-fi
-
# Handle 'help' here, before setting 'errexit', so we have a chance
# to show our help if the man command is there but fails.
if [ "$1" = "help" ] || [ "$1" = "--help" ] || [ "$1" = "-h" ]; then
@@ -62,8 +62,13 @@ set -o errexit
set -o nounset
distrobox_path="$(dirname "${0}")"
-distrobox_command="${1}"
-shift
+if [ $# -eq 0 ]; then
+ printf "No command specified. Assuming: distrobox-%s\n" "${default_command}"
+ distrobox_command="${default_command}"
+else
+ distrobox_command="${1}"
+ shift
+fi
# Simple wrapper to the distrobox utilities.
# We just detect the 1st argument and launch the matching distrobox utility.
diff --git a/docs/README.md b/docs/README.md
index df00785..64e4c0d 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -268,6 +268,7 @@ Alternatively it is possible to specify preferences using ENV variables:
- DBX_CONTAINER_NAME
- DBX_NON_INTERACTIVE
- DBX_SKIP_WORKDIR
+- DBX_DEFAULT_COMMAND
---
--
2.37.1

View File

@ -1,7 +1,7 @@
From fd1243898d3547e890bd11cc69077fb2c57cf2df Mon Sep 17 00:00:00 2001
From 9a9a4dd4843199e9e40668dc58986abb82fb9020 Mon Sep 17 00:00:00 2001
From: Dario Faggioli <dfaggioli@suse.com>
Date: Tue, 21 Jun 2022 18:17:59 +0200
Subject: [PATCH] Read config in /usr/etc too
Date: Wed, 27 Jul 2022 12:50:16 +0200
Subject: [PATCH 4/4] opensuse: check for the config file in /usr/etc too
Signed-off-by: Dario Faggioli <dfaggioli@suse.com>
---
@ -26,7 +26,7 @@ index b0bb0e9..94fe003 100755
${HOME}/.config/distrobox/distrobox.conf
${HOME}/.distroboxrc
diff --git a/distrobox-enter b/distrobox-enter
index 138446c..2ddf9ac 100755
index e754c6b..25870f2 100755
--- a/distrobox-enter
+++ b/distrobox-enter
@@ -69,6 +69,7 @@ version="1.3.1"
@ -74,7 +74,7 @@ index accfce0..f848b7e 100755
${HOME}/.config/distrobox/distrobox.conf
${HOME}/.distroboxrc
diff --git a/docs/README.md b/docs/README.md
index df00785..61b2c7a 100644
index 64e4c0d..58cf1d8 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -243,6 +243,7 @@ Configuration files can be placed in the following paths, from the least importa
@ -86,5 +86,5 @@ index df00785..61b2c7a 100644
- ${HOME}/.config/distrobox/distrobox.conf
- ${HOME}/.distroboxrc
--
2.36.1
2.37.1

View File

@ -1,3 +1,32 @@
-------------------------------------------------------------------
Thu Jul 28 09:48:32 UTC 2022 - Dario Faggioli <dfaggioli@suse.com>
- Fix a (potential) problem with man and manpages
* Patch added:
0002-distrobox-handle-situations-with-weird-manpages-setu.patch
- Default to distrobox-enter when only typing distrobox
* Patch added:
0003-distrobox-if-no-command-is-specified-default-to-ente.patch
- Reordered the patchqueue:
* Patch removed:
0002-opensuse-check-for-the-config-file-in-usr-etc-too.patch
* Patch added:
0004-opensuse-check-for-the-config-file-in-usr-etc-too.patch
-------------------------------------------------------------------
Wed Jul 27 11:31:23 UTC 2022 - Dario Faggioli <dfaggioli@suse.com>
- enable non-interactive mode by default
- Fix a but with automatic cretion of rootful containers
* Patch added:
0001-enter-fix-automatic-container-creation-when-r-is-use.patch
- Rework the /usr/etc config file patch (better changelog)
* Patch removed:
0001-Read-config-in-usr-etc-too.patch
* Patch added:
0002-opensuse-check-for-the-config-file-in-usr-etc-too.patch
- Switched to %autosetup in the spec file
-------------------------------------------------------------------
Tue Jun 21 16:49:28 UTC 2022 - Dario Faggioli <dfaggioli@suse.com>

View File

@ -1,3 +1,4 @@
container_image="registry.opensuse.org/opensuse/tumbleweed:latest"
container_name="tumbleweed"
container_manager="autodetect"
non_interactive="true"

View File

@ -23,8 +23,14 @@ License: GPL-3.0
URL: https://github.com/89luca89/distrobox
Source: distrobox-%{version}.tar.gz
Source1: distrobox.conf
# Fix a problem with automatic rootful container creation (from upstream)
Patch1: 0001-enter-fix-automatic-container-creation-when-r-is-use.patch
# Fix a problem if man is there but actual manpages are stripped (from upstream PR)
Patch2: 0002-distrobox-handle-situations-with-weird-manpages-setu.patch
# Default to distrobox-enter when just distrobox is used
Patch3: 0003-distrobox-if-no-command-is-specified-default-to-ente.patch
# Read the config from vendor specific directory (/usr/etc/distrobox) too
Patch1: 0001-Read-config-in-usr-etc-too.patch
Patch4: 0004-opensuse-check-for-the-config-file-in-usr-etc-too.patch
Requires: %{_bindir}/basename
Requires: %{_bindir}/find
Requires: %{_bindir}/grep
@ -40,8 +46,7 @@ allowing sharing of the HOME directory of the user, external storage,
external USB devices and graphical apps (X11/Wayland), and audio.
%prep
%setup -q -n distrobox-%{version}
%patch1 -p1
%autosetup -p1 -n distrobox-%{version}
%build