[Libguestfs] [PATCH] p2v: make-disk: rely on os-release for host distro detection
Richard W.M. Jones
rjones at redhat.com
Tue Nov 6 13:08:46 UTC 2018
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
More information about the Libguestfs
mailing list