SHA256
1
0
forked from pool/supermin

Accepting request 510114 from Virtualization

1

OBS-URL: https://build.opensuse.org/request/show/510114
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/supermin?expand=0&rev=3
This commit is contained in:
Dominique Leuenberger 2017-08-24 16:38:13 +00:00 committed by Git OBS Bridge
commit 166907e50f
7 changed files with 20 additions and 418 deletions

View File

@ -1,214 +0,0 @@
From libguestfs-bounces@redhat.com Wed Aug 31 13:20:03 2016
Return-Path: <libguestfs-bounces@redhat.com>
Delivered-To: unknown
Received: from gwmail.emea.novell.com (143.186.119.90:993) by laptop.vms
with IMAP4-SSL; 31 Aug 2016 13:20:03 -0000
Received: from prv-mx.provo.novell.com (novprvlin0681.provo.novell.com
[130.57.1.19]) by prv-mh.provo.novell.com with ESMTP (NOT encrypted); Wed,
31 Aug 2016 07:09:26 -0600
Received: from mx6-phx2.redhat.com (209.132.183.39) by
prv-mx.provo.novell.com (130.57.1.10) GWAVA SMTP; Wed, 31 Aug 2016 07:10:12
-0600
X-Spam_ID:
str=0001.0A010202.57C6D706.0196:SCFSTAT2484459,ss=1,re=-4.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0
X-GWAVADAT:
<keymat><rkey>gvWn3QsGV50RMxxr</rkey><gkey>9c16c207872a47573356cfe20b727ec6b327e3bac2a6eaa5ec59d5e9d6aa8342</gkey><objectid>17boib3.17boib3.v6</objectid></keymat>
Received: from lists01.pubmisc.prod.ext.phx2.redhat.com
(lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by
mx6-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u7VD5h2P022390; Wed, 31
Aug 2016 09:05:44 -0400
Received: from int-mx09.intmail.prod.int.phx2.redhat.com
(int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22])
by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP
id u7VD5gWQ007141 for <libguestfs@listman.util.phx.redhat.com>;
Wed, 31 Aug 2016 09:05:42 -0400
Received: from thyrus.usersys.redhat.com (dhcp131-138.brq.redhat.com
[10.34.131.138])
by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP
id u7VD5eAY004091
(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256
verify=NO)
for <libguestfs@redhat.com>; Wed, 31 Aug 2016 09:05:42 -0400
From: Pino Toscano <ptoscano@redhat.com>
To: libguestfs@redhat.com
Date: Wed, 31 Aug 2016 15:05:35 +0200
Message-Id: <1472648736-5613-2-git-send-email-ptoscano@redhat.com>
In-Reply-To: <1472648736-5613-1-git-send-email-ptoscano@redhat.com>
References: <1472648736-5613-1-git-send-email-ptoscano@redhat.com>
X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22
X-loop: libguestfs@redhat.com
Subject: [Libguestfs] [PATCH 1/2] Add simple handling of /etc/os-release
X-BeenThere: libguestfs@redhat.com
X-Mailman-Version: 2.1.12
Precedence: junk
List-Id: Discussion and development of libguestfs <libguestfs.redhat.com>
List-Unsubscribe: <https://www.redhat.com/mailman/options/libguestfs>,
<mailto:libguestfs-request@redhat.com?subject=unsubscribe>
List-Archive: <https://www.redhat.com/archives/libguestfs>
List-Post: <mailto:libguestfs@redhat.com>
List-Help: <mailto:libguestfs-request@redhat.com?subject=help>
List-Subscribe: <https://www.redhat.com/mailman/listinfo/libguestfs>,
<mailto:libguestfs-request@redhat.com?subject=subscribe>
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Sender: libguestfs-bounces@redhat.com
Errors-To: libguestfs-bounces@redhat.com
X-getmail-retrieved-from-mailbox: INBOX
X-Evolution-Source: 1323246076.1957.25@linux-smhm.site
Introduce a simple module to read and cache fields of /etc/os-release
that might be needed, and there is only ID for now.
---
src/Makefile.am | 3 +++
src/os_release.ml | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
src/os_release.mli | 26 ++++++++++++++++++
3 files changed, 107 insertions(+)
create mode 100644 src/os_release.ml
create mode 100644 src/os_release.mli
diff --git a/src/Makefile.am b/src/Makefile.am
index 11adf31..767117f 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -47,6 +47,8 @@ SOURCES = \
utils.ml \
utils.mli \
types.ml \
+ os_release.ml \
+ os_release.mli \
package_handler.ml \
package_handler.mli \
rpm.ml \
@@ -71,6 +73,7 @@ SOURCES_ML = \
config.ml \
utils.ml \
types.ml \
+ os_release.ml \
package_handler.ml \
rpm.ml \
dpkg.ml \
diff --git a/src/os_release.ml b/src/os_release.ml
new file mode 100644
index 0000000..b2de259
--- /dev/null
+++ b/src/os_release.ml
@@ -0,0 +1,78 @@
+(* supermin 5
+ * Copyright (C) 2016 Red Hat Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *)
+
+open Utils
+
+let split sep str =
+ let len = String.length sep in
+ let seplen = String.length str in
+ let i = find str sep in
+ if i = -1 then str, ""
+ else (
+ String.sub str 0 i, String.sub str (i + len) (seplen - i - len)
+ )
+
+type os_release = {
+ id : string;
+}
+
+let data = ref None
+let parsed = ref false
+
+let rec get_data () =
+ if !parsed = false then (
+ data := parse ();
+ parsed := true;
+ );
+
+ !data
+
+and parse () =
+ let file = "/etc/os-release" in
+ if Sys.file_exists file then (
+ let chan = open_in file in
+ let lines = input_all_lines chan in
+ close_in chan;
+ let lines = List.filter ((<>) "") lines in
+ let lines = List.filter (fun s -> s.[0] <> '#') lines in
+
+ let id = ref "" in
+
+ List.iter (
+ fun line ->
+ let field, value = split "=" line in
+ let value =
+ let len = String.length value in
+ if len > 1 &&
+ ((value.[0] = '"' && value.[len-1] = '"') ||
+ (value.[0] = '\'' && value.[len-1] = '\'')) then
+ String.sub value 1 (len - 2)
+ else value in
+ match field with
+ | "ID" -> id := value
+ | _ -> ()
+ ) lines;
+
+ Some { id = !id; }
+ ) else
+ None
+
+let get_id () =
+ match get_data () with
+ | None -> ""
+ | Some d -> d.id
diff --git a/src/os_release.mli b/src/os_release.mli
new file mode 100644
index 0000000..2ae349b
--- /dev/null
+++ b/src/os_release.mli
@@ -0,0 +1,26 @@
+(* supermin 5
+ * Copyright (C) 2016 Red Hat Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *)
+
+(** Handling of /etc/os-release. *)
+
+val get_id : unit -> string
+(** Get the value of the "ID" field from the /etc/os-release file
+ on the current system.
+
+ An empty string is returned if the file does not exist or cannot
+ be read. *)
--
2.7.4
_______________________________________________
Libguestfs mailing list
Libguestfs@redhat.com
https://www.redhat.com/mailman/listinfo/libguestfs

View File

@ -1,112 +0,0 @@
From libguestfs-bounces@redhat.com Wed Aug 31 13:10:02 2016
From: Pino Toscano <ptoscano@redhat.com>
To: libguestfs@redhat.com
Date: Wed, 31 Aug 2016 15:05:36 +0200
Message-Id: <1472648736-5613-3-git-send-email-ptoscano@redhat.com>
In-Reply-To: <1472648736-5613-1-git-send-email-ptoscano@redhat.com>
References: <1472648736-5613-1-git-send-email-ptoscano@redhat.com>
X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22
X-loop: libguestfs@redhat.com
Subject: [Libguestfs] [PATCH 2/2] Use os-release to detect the distro
X-BeenThere: libguestfs@redhat.com
X-Mailman-Version: 2.1.12
Precedence: junk
List-Id: Discussion and development of libguestfs <libguestfs.redhat.com>
List-Unsubscribe: <https://www.redhat.com/mailman/options/libguestfs>,
<mailto:libguestfs-request@redhat.com?subject=unsubscribe>
List-Archive: <https://www.redhat.com/archives/libguestfs>
List-Post: <mailto:libguestfs@redhat.com>
List-Help: <mailto:libguestfs-request@redhat.com?subject=help>
List-Subscribe: <https://www.redhat.com/mailman/listinfo/libguestfs>,
<mailto:libguestfs-request@redhat.com?subject=subscribe>
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Sender: libguestfs-bounces@redhat.com
Errors-To: libguestfs-bounces@redhat.com
X-getmail-retrieved-from-mailbox: INBOX
X-Evolution-Source: 1323246076.1957.25@linux-smhm.site
Check the ID field in /etc/os-release on the current system, before
checking for the other old-style release-/version-like files in /etc.
Some distributions (openSUSE Thumbleweed) are starting to remove them,
breaking the supermin detection.
---
src/dpkg.ml | 3 ++-
src/pacman.ml | 5 +++--
src/rpm.ml | 15 +++++++++------
3 files changed, 14 insertions(+), 9 deletions(-)
diff --git a/src/dpkg.ml b/src/dpkg.ml
index 70acfa2..1e785de 100644
--- a/src/dpkg.ml
+++ b/src/dpkg.ml
@@ -28,7 +28,8 @@ let dpkg_detect () =
Config.dpkg_query <> "no" &&
Config.dpkg_divert <> "no" &&
Config.apt_get <> "no" &&
- try (stat "/etc/debian_version").st_kind = S_REG with Unix_error _ -> false
+ (List.mem (Os_release.get_id ()) [ "debian"; "ubuntu" ] ||
+ try (stat "/etc/debian_version").st_kind = S_REG with Unix_error _ -> false)
let dpkg_primary_arch = ref ""
let settings = ref no_settings
diff --git a/src/pacman.ml b/src/pacman.ml
index 3340fa6..c35668a 100644
--- a/src/pacman.ml
+++ b/src/pacman.ml
@@ -24,8 +24,9 @@ open Package_handler
let pacman_detect () =
Config.pacman <> "no" && Config.fakeroot <> "no" &&
- (stat "/etc/arch-release").st_kind = S_REG &&
- Config.pacman_g2 = "no" (* not Frugalware with pacman-g2 *)
+ (Os_release.get_id () = "arch" ||
+ ((stat "/etc/arch-release").st_kind = S_REG &&
+ Config.pacman_g2 = "no")) (* not Frugalware with pacman-g2 *)
let settings = ref no_settings
diff --git a/src/rpm.ml b/src/rpm.ml
index a5dc67a..e409e37 100644
--- a/src/rpm.ml
+++ b/src/rpm.ml
@@ -31,21 +31,24 @@ let stringset_of_list pkgs =
let fedora_detect () =
Config.rpm <> "no" && Config.rpm2cpio <> "no" && rpm_is_available () &&
(Config.yumdownloader <> "no" || Config.dnf <> "no") &&
- try
- (stat "/etc/redhat-release").st_kind = S_REG ||
- (stat "/etc/fedora-release").st_kind = S_REG
- with Unix_error _ -> false
+ (List.mem (Os_release.get_id ()) [ "fedora"; "rhel"; "centos" ] ||
+ try
+ (stat "/etc/redhat-release").st_kind = S_REG ||
+ (stat "/etc/fedora-release").st_kind = S_REG
+ with Unix_error _ -> false)
let opensuse_detect () =
Config.rpm <> "no" && Config.rpm2cpio <> "no" && rpm_is_available () &&
Config.zypper <> "no" &&
- try (stat "/etc/SuSE-release").st_kind = S_REG with Unix_error _ -> false
+ (List.mem (Os_release.get_id ()) [ "opensuse"; "sled"; "sles" ] ||
+ try (stat "/etc/SuSE-release").st_kind = S_REG with Unix_error _ -> false)
let mageia_detect () =
Config.rpm <> "no" && Config.rpm2cpio <> "no" && rpm_is_available () &&
Config.urpmi <> "no" &&
Config.fakeroot <> "no" &&
- try (stat "/etc/mageia-release").st_kind = S_REG with Unix_error _ -> false
+ (Os_release.get_id () = "mageia" ||
+ try (stat "/etc/mageia-release").st_kind = S_REG with Unix_error _ -> false)
let ibm_powerkvm_detect () =
Config.rpm <> "no" && Config.rpm2cpio <> "no" && rpm_is_available () &&
--
2.7.4
_______________________________________________
Libguestfs mailing list
Libguestfs@redhat.com
https://www.redhat.com/mailman/listinfo/libguestfs

View File

@ -1,76 +0,0 @@
From: Pino Toscano <ptoscano@redhat.com>
To: libguestfs@redhat.com
Date: Wed, 31 Aug 2016 15:53:03 +0200
Message-Id: <1472651583-30112-1-git-send-email-ptoscano@redhat.com>
In-Reply-To: <1472648736-5613-1-git-send-email-ptoscano@redhat.com>
References: <1472648736-5613-1-git-send-email-ptoscano@redhat.com>
X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23
X-loop: libguestfs@redhat.com
Subject: [Libguestfs] [PATCH] tests: use /etc/os-release in test-harder
X-BeenThere: libguestfs@redhat.com
X-Mailman-Version: 2.1.12
Precedence: junk
List-Id: Discussion and development of libguestfs <libguestfs.redhat.com>
List-Unsubscribe: <https://www.redhat.com/mailman/options/libguestfs>,
<mailto:libguestfs-request@redhat.com?subject=unsubscribe>
List-Archive: <https://www.redhat.com/archives/libguestfs>
List-Post: <mailto:libguestfs@redhat.com>
List-Help: <mailto:libguestfs-request@redhat.com?subject=help>
List-Subscribe: <https://www.redhat.com/mailman/listinfo/libguestfs>,
<mailto:libguestfs-request@redhat.com?subject=subscribe>
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Sender: libguestfs-bounces@redhat.com
Errors-To: libguestfs-bounces@redhat.com
X-getmail-retrieved-from-mailbox: INBOX
X-Evolution-Source: 1323246076.1957.25@linux-smhm.site
Check the ID in /etc/os-release before checking the other release files,
so it's possible to handle distros without them.
Also, make sure it is skipped if the value read from os-release is not
handled when getting the list of packages.
---
tests/test-harder.sh | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/tests/test-harder.sh b/tests/test-harder.sh
index ea5dfc8..7e1b8df 100755
--- a/tests/test-harder.sh
+++ b/tests/test-harder.sh
@@ -25,7 +25,14 @@ set -e
# NOTE: This test will only work if the $pkgs listed below
# for your distro are installed on the host. SEE LIST BELOW.
-if [ -f /etc/arch-release ]; then
+if [ -f /etc/os-release ]; then
+ distro=$(. /etc/os-release && echo $ID)
+ case "$distro" in
+ fedora|rhel|centos) distro=redhat ;;
+ opensuse|sled|sles) distro=suse ;;
+ ubuntu) distro=debian ;;
+ esac
+elif [ -f /etc/arch-release ]; then
distro=arch
elif [ -f /etc/debian_version ]; then
distro=debian
@@ -63,6 +70,10 @@ case $distro in
ibm-powerkvm)
pkgs="augeas hivex tar"
;;
+ *)
+ echo "Unhandled distro '$distro'"
+ exit 77
+ ;;
esac
test "$USE_NETWORK" = 1 || USE_INSTALLED=--use-installed
--
2.7.4
_______________________________________________
Libguestfs mailing list
Libguestfs@redhat.com
https://www.redhat.com/mailman/listinfo/libguestfs

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:e2d36a6c117528786fdc6cd8f11af3138400a967711f2b4847b1f8581799a8a2
size 340736

3
supermin-5.1.18.tar.xz Normal file
View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:792c9c6d51ff4740f94ebdc4ad0a0c20726e32dcdbdbcf81fbb15c75eaf6df9a
size 363536

View File

@ -1,3 +1,16 @@
-------------------------------------------------------------------
Thu Jul 13 14:17:07 UTC 2017 - cbosdonnat@suse.com
- Update to version 5.1.18
-------------------------------------------------------------------
Tue May 30 13:45:27 UTC 2017 - olaf@aepfle.de
- Update to version 5.1.17
remove 0001-add_simple_handling_of_os-release.patch
remove 0002-use_os-release_to_detect_the_distro.patch
remove 0003-tests_use__etc_os-release_in_test-harder.patch
-------------------------------------------------------------------
Thu Sep 8 15:01:41 UTC 2016 - cbosdonnat@suse.com

View File

@ -1,7 +1,7 @@
#
# spec file for package supermin
#
# Copyright (c) 2016 SUSE LINUX Products GmbH, Nuernberg, Germany.
# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@ -17,7 +17,7 @@
Name: supermin
Version: 5.1.13
Version: 5.1.18
Release: 0
%{ocaml_preserve_bytecode}
Url: http://libguestfs.org/
@ -30,9 +30,6 @@ Requires: xmlstarlet
Requires: zypper
BuildRoot: %{_tmppath}/%{name}-%{version}-build
Source0: supermin-%{version}.tar.xz
Patch0: 0001-add_simple_handling_of_os-release.patch
Patch1: 0002-use_os-release_to_detect_the_distro.patch
Patch2: 0003-tests_use__etc_os-release_in_test-harder.patch
%if "%{?_ignore_exclusive_arch}" == ""
ExclusiveArch: x86_64 ppc64 ppc64le s390x aarch64
%endif
@ -40,14 +37,14 @@ ExclusiveArch: x86_64 ppc64 ppc64le s390x aarch64
BuildRequires: autoconf
BuildRequires: automake
BuildRequires: e2fsprogs
%if %suse_version >= 1210
BuildRequires: glibc-devel-static
%endif
BuildRequires: gzip
BuildRequires: ncurses-devel
BuildRequires: ocaml
BuildRequires: ocaml-findlib
BuildRequires: ocaml-rpm-macros >= 4.02.1
BuildRequires: pkg-config
BuildRequires: xz
BuildRequires: xz-devel
BuildRequires: zlib-devel
BuildRequires: pkgconfig(com_err)
@ -62,9 +59,6 @@ you need to boot one of them.
%prep
%setup -q
%patch0 -p1
%patch1 -p1
%patch2 -p1
%build
export ZYPPER=zypper
@ -80,9 +74,6 @@ make \
make install DESTDIR=$RPM_BUILD_ROOT
find $RPM_BUILD_ROOT -ls
%clean
rm -rf $RPM_BUILD_ROOT
%files
%defattr (-,root,root)
%doc README