Pino Toscano
2018-Nov-06 12:33 UTC
[Libguestfs] [PATCH] p2v: make-disk: rely on os-release for host distro detection
Instead of assuming the latest Fedora version if /etc/redhat-release is available, or the latest Debian with /etc/debian_version, use only /etc/os-release. The possible name of the virt-builder template is created by concatenating $ID and $VERSION_ID, which is generally a better guess than what previously done, and better matches the host OS. This affects only the case when os-version is not specified as command line argument. --- p2v/virt-p2v-make-disk.in | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/p2v/virt-p2v-make-disk.in b/p2v/virt-p2v-make-disk.in index bdf7fd96e..ee65716f2 100644 --- a/p2v/virt-p2v-make-disk.in +++ b/p2v/virt-p2v-make-disk.in @@ -122,12 +122,8 @@ if [ $# -eq 1 ]; then else # If osversion was not set, then we must guess a good value # based on the host distro. - if test -f /etc/redhat-release; then - osversion="$(virt-builder -l | sort | - @AWK@ '/^fedora-[1-9]/ {print $1}' | tail -1)" - elif test -f /etc/debian_version; then - osversion="$(virt-builder -l | sort | - @AWK@ '/^debian-[1-9]/ {print $1}' | tail -1)" + if test -f /etc/os-release; then + osversion="`. /etc/os-release && echo ${ID}-${VERSION_ID}`" fi if [ "x$osversion" = "x" ]; then echo "$program: unable to guess a suitable os-version." -- 2.17.2
Richard W.M. Jones
2018-Nov-06 13:08 UTC
Re: [Libguestfs] [PATCH] p2v: make-disk: rely on os-release for host distro detection
On Tue, Nov 06, 2018 at 01:33:11PM +0100, Pino Toscano wrote:> Instead of assuming the latest Fedora version if /etc/redhat-release is > available, or the latest Debian with /etc/debian_version, use only > /etc/os-release. The possible name of the virt-builder template is > created by concatenating $ID and $VERSION_ID, which is generally a > better guess than what previously done, and better matches the host OS. > > This affects only the case when os-version is not specified as command > line argument. > --- > p2v/virt-p2v-make-disk.in | 8 ++------ > 1 file changed, 2 insertions(+), 6 deletions(-) > > diff --git a/p2v/virt-p2v-make-disk.in b/p2v/virt-p2v-make-disk.in > index bdf7fd96e..ee65716f2 100644 > --- a/p2v/virt-p2v-make-disk.in > +++ b/p2v/virt-p2v-make-disk.in > @@ -122,12 +122,8 @@ if [ $# -eq 1 ]; then > else > # If osversion was not set, then we must guess a good value > # based on the host distro. > - if test -f /etc/redhat-release; then > - osversion="$(virt-builder -l | sort | > - @AWK@ '/^fedora-[1-9]/ {print $1}' | tail -1)" > - elif test -f /etc/debian_version; then > - osversion="$(virt-builder -l | sort | > - @AWK@ '/^debian-[1-9]/ {print $1}' | tail -1)" > + if test -f /etc/os-release; then > + osversion="`. /etc/os-release && echo ${ID}-${VERSION_ID}`" > fi > if [ "x$osversion" = "x" ]; then > echo "$program: unable to guess a suitable os-version."Makes more sense, ACK. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com Fedora Windows cross-compiler. Compile Windows programs, test, and build Windows installers. Over 100 libraries supported. http://fedoraproject.org/wiki/MinGW
Seemingly Similar Threads
- [REPOST] Differentiate 'distro' and 'distrofamily' in Sys::Guestfs::Lib
- [PATCH] Differentiate 'distro' and 'distrofamily' in Sys::Guestfs::Lib
- [PATCH] Split $os->{version} into $os->{major_version} and $os->{minor_version}
- [p2v PATCH] make-disk: set p2v.local as hostname
- [PATCH] Replace 'distrofamily' with feature tags