diff --git a/libguestfs.spec b/libguestfs.spec index f80376726ae9ec80acd5fffc7b435d4ee633ff8a..d8b529821fe87f1b3fae46a60ef11d279d760d7c 100644 --- a/libguestfs.spec +++ b/libguestfs.spec @@ -4,7 +4,7 @@ Name: libguestfs Version: 1.40.2 -Release: 19 +Release: 20 Epoch: 1 Summary: A set of tools for accessing and modifying virtual machine (VM) disk images License: LGPLv2+ @@ -20,6 +20,7 @@ Patch0004: Fix-defaut-function-compare-error.patch Patch0005: Fix-verbose-error.patch Patch0006: 0001-tests-Use-explicit-backing-format-for-all-backing-di.patch Patch0007: add-some-package-to-fix-run-error.patch +Patch0008: oe-template.patch BuildRequires: gcc-c++, rpcgen, libtirpc-devel, supermin-devel >= 5.1.18, hivex-devel >= 1.2.7-7, ocaml-hivex-devel, perl(Pod::Simple), perl(Pod::Man) BuildRequires: /usr/bin/pod2text, po4a, augeas-devel >= 1.7.0, readline-devel, genisoimage, libxml2-devel, createrepo, glibc-static, libselinux-utils @@ -378,6 +379,9 @@ chmod 644 %{buildroot}%{_libdir}/perl5/vendor_perl/auto/Sys/Guestfs/Guestfs.so %exclude %{_mandir}/man1/virt-tar.1* %changelog +* Wed Sep 27 2023 wangguoquan - 1:1.40.2-20 +- Add openeuler vm template support + * Mon Aug 14 2023 suwei - - 1.40.2-19 - Add loongarch64 and sw_64 support diff --git a/oe-template.patch b/oe-template.patch new file mode 100644 index 0000000000000000000000000000000000000000..aadf172c59f11a3df007009982297b6038f5d8c6 --- /dev/null +++ b/oe-template.patch @@ -0,0 +1,406 @@ +diff -Nur libguestfs-1.40.2-clean/builder/Makefile.am libguestfs-1.40.2/builder/Makefile.am +--- libguestfs-1.40.2-clean/builder/Makefile.am 2019-02-07 22:45:56.477955541 +0800 ++++ libguestfs-1.40.2/builder/Makefile.am 2023-10-31 16:17:45.197896415 +0800 +@@ -19,10 +19,13 @@ + + AM_YFLAGS = -d + ++CFLAGS += -fPIE ++ + EXTRA_DIST = \ + $(SOURCES_MLI) $(SOURCES_ML) $(SOURCES_C) \ + $(REPOSITORY_SOURCES_ML) \ + $(REPOSITORY_SOURCES_MLI) \ ++ $(TEMPLATE_SOURCES_ML) \ + index_parser_tests.ml \ + libguestfs.gpg \ + opensuse.gpg \ +@@ -45,6 +48,7 @@ + test-virt-index-validate-good-4 \ + virt-builder.pod \ + virt-builder-repository.pod \ ++ virt-builder-template.pod \ + virt-index-validate.pod + + SOURCES_MLI = \ +@@ -125,13 +129,22 @@ + index-parse.c \ + index-parser-c.c + ++TEMPLATE_SOURCES_ML = \ ++ template.ml ++ ++TEMPLATE_SOURCES_C = \ ++ index-scan.c \ ++ index-struct.c \ ++ index-parse.c \ ++ index-parser-c.c ++ + man_MANS = + noinst_DATA = + bin_PROGRAMS = + + if HAVE_OCAML + +-bin_PROGRAMS += virt-builder virt-builder-repository ++bin_PROGRAMS += virt-builder virt-builder-repository virt-builder-template + + virt_builder_SOURCES = $(SOURCES_C) + virt_builder_CPPFLAGS = \ +@@ -171,6 +184,23 @@ + REPOSITORY_BOBJECTS = $(REPOSITORY_SOURCES_ML:.ml=.cmo) + REPOSITORY_XOBJECTS = $(REPOSITORY_BOBJECTS:.cmo=.cmx) + ++virt_builder_template_SOURCES = $(TEMPLATE_SOURCES_C) ++virt_builder_template_CPPFLAGS = \ ++ -I$(builddir) -I$(srcdir) \ ++ -I$(top_builddir) \ ++ -I$(top_srcdir)/gnulib/lib -I$(top_builddir)/gnulib/lib \ ++ -I$(shell $(OCAMLC) -where) \ ++ -I$(top_srcdir)/gnulib/lib \ ++ -I$(top_srcdir)/lib ++virt_builder_template_CFLAGS = \ ++ -pthread \ ++ $(WARN_CFLAGS) $(WERROR_CFLAGS) \ ++ -Wno-unused-macros \ ++ $(LIBTINFO_CFLAGS) \ ++ $(LIBXML2_CFLAGS) ++TEMPLATE_BOBJECTS = $(TEMPLATE_SOURCES_ML:.ml=.cmo) ++TEMPLATE_XOBJECTS = $(TEMPLATE_BOBJECTS:.cmo=.cmx) ++ + # -I $(top_builddir)/lib/.libs is a hack which forces corresponding -L + # option to be passed to gcc, so we don't try linking against an + # installed copy of libguestfs. +@@ -211,9 +241,11 @@ + if !HAVE_OCAMLOPT + OBJECTS = $(BOBJECTS) + REPOSITORY_OBJECTS = $(REPOSITORY_BOBJECTS) ++TEMPLATE_OBJECTS = $(TEMPLATE_BOBJECTS) + else + OBJECTS = $(XOBJECTS) + REPOSITORY_OBJECTS = $(REPOSITORY_XOBJECTS) ++TEMPLATE_OBJECTS = $(TEMPLATE_XOBJECTS) + endif + + OCAMLLINKFLAGS = \ +@@ -251,6 +283,16 @@ + $(OCAMLFIND) $(BEST) $(OCAMLFLAGS) $(OCAMLPACKAGES) $(OCAMLLINKFLAGS) \ + $(REPOSITORY_OBJECTS) -o $@ + ++virt_builder_template_DEPENDENCIES = \ ++ $(TEMPLATE_OBJECTS) \ ++ ../common/mltools/mltools.$(MLARCHIVE) \ ++ ../common/mlxml/mlxml.$(MLARCHIVE) \ ++ $(top_srcdir)/ocaml-link.sh ++virt_builder_template_LINK = \ ++ $(top_srcdir)/ocaml-link.sh -cclib '$(OCAMLCLIBS)' -- \ ++ $(OCAMLFIND) $(BEST) $(OCAMLFLAGS) $(OCAMLPACKAGES) $(OCAMLLINKFLAGS) \ ++ $(TEMPLATE_OBJECTS) -o $@ ++ + # Manual pages and HTML files for the website. + + man_MANS += virt-builder.1 +@@ -299,6 +341,14 @@ + echo 'let libosinfo_db_path = "$(datadir)/libosinfo/db"' > $@-t + mv $@-t $@ + ++template.ml: Makefile ++ @cp templates/make-template.ml template.ml ++ @sed -i '1,35 { /^#/d }' template.ml ++ @sed -i '/Check we are being run from the correct directory/,/system is NOT set/ { { /system is NOT set/! d } }' template.ml ++ @sed -i 's/..\/..\/run .\/make-template.ml/virt-builder-template/g' template.ml ++ ++CLEANFILES += template.ml ++ + fedora.qcow2: ../test-data/phony-guests/fedora.img + rm -f $@ $@-t + qemu-img convert -f raw -O qcow2 $< $@-t +diff -Nur libguestfs-1.40.2-clean/builder/templates/make-template.ml libguestfs-1.40.2/builder/templates/make-template.ml +--- libguestfs-1.40.2-clean/builder/templates/make-template.ml 2019-02-07 22:45:56.498955572 +0800 ++++ libguestfs-1.40.2/builder/templates/make-template.ml 2023-10-31 16:29:27.890271296 +0800 +@@ -80,6 +80,7 @@ + | RHEL of int * int + | Debian of int * string (* version, dist name like "wheezy" *) + | Ubuntu of string * string ++ | OpenEuler of string (* 22.03-LTS *) + | Fedora of int (* version number *) + | FreeBSD of int * int (* major, minor *) + | Windows of int * int * windows_variant (* major, minor, variant *) +@@ -93,6 +94,8 @@ + let quote = Filename.quote + let (//) = Filename.concat + ++let isofile = ref "" ++ + let rec main () = + assert (Sys.word_size = 64); + Random.self_init (); +@@ -321,6 +324,7 @@ + Examples: + ../../run ./make-template.ml fedora 25 + ../../run ./make-template.ml rhel 7.3 ppc64le ++ ../../run ./make-template.ml -f /var/openEuler-22.03-LTS-x86_64-dvd.iso openeuler 22.03-LTS + + The arch defaults to x86_64. Note that i686 is treated as a + separate arch. +@@ -328,6 +332,7 @@ + Options: + " in + let spec = Arg.align [ ++ ("-f", Arg.Set_string isofile, "\tSpecify iso file") + ] in + + Arg.parse spec (fun s -> anon := s :: !anon) usage; +@@ -357,6 +362,7 @@ + | "ubuntu", "14.04" -> Ubuntu (ver, "trusty") + | "ubuntu", "16.04" -> Ubuntu (ver, "xenial") + | "ubuntu", "18.04" -> Ubuntu (ver, "bionic") ++ | "openeuler", ver -> OpenEuler(ver) + | "fedora", ver -> Fedora (int_of_string ver) + | "freebsd", ver -> let maj, min = parse_major_minor ver in FreeBSD (maj, min) + | "windows", ver -> parse_windows_version ver +@@ -435,6 +441,9 @@ + | Ubuntu (ver, _) -> + if arch = X86_64 then sprintf "ubuntu-%s%s" ver ext + else sprintf "ubuntu-%s-%s%s" ver (string_of_arch arch) ext ++ | OpenEuler ver -> ++ if arch = X86_64 then sprintf "openeuler-%s%s" ver ext ++ else sprintf "openeuler-%s-%s%s" ver (string_of_arch arch) ext + | FreeBSD (major, minor) -> + if arch = X86_64 then sprintf "freebsd-%d.%d%s" major minor ext + else sprintf "freebsd-%d.%d-%s%s" major minor (string_of_arch arch) ext +@@ -457,18 +466,19 @@ + | RHEL (major, minor) -> sprintf "rhel-%d.%d" major minor + | Debian (ver, _) -> sprintf "debian-%d" ver + | Ubuntu (ver, _) -> sprintf "ubuntu-%s" ver ++ | OpenEuler ver -> sprintf "openeuler-%s" ver + | FreeBSD (major, minor) -> sprintf "freebsd-%d.%d" major minor + | Windows (major, minor, Client) -> sprintf "windows-%d.%d-client" major minor + | Windows (major, minor, Server) -> sprintf "windows-%d.%d-server" major minor + + (* Does virt-sysprep know how to sysprep this OS? *) + and can_sysprep_os = function +- | RHEL _ | CentOS _ | Fedora _ | Debian _ | Ubuntu _ -> true ++ | RHEL _ | CentOS _ | Fedora _ | Debian _ | Ubuntu _ | OpenEuler _ -> true + | FreeBSD _ | Windows _ -> false + + and is_selinux_os = function + | RHEL _ | CentOS _ | Fedora _ -> true +- | Debian _ | Ubuntu _ ++ | Debian _ | Ubuntu _ | OpenEuler _ + | FreeBSD _ | Windows _ -> false + + and needs_uefi os arch = +@@ -476,13 +486,13 @@ + | Fedora _, Aarch64 + | RHEL _, Aarch64 -> true + | RHEL _, _ | CentOS _, _ | Fedora _, _ +- | Debian _, _ | Ubuntu _, _ ++ | Debian _, _ | Ubuntu _, _ | OpenEuler _, _ + | FreeBSD _, _ | Windows _, _ -> false + + and get_virtual_size_gb os arch = + match os with + | RHEL _ | CentOS _ | Fedora _ +- | Debian _ | Ubuntu _ ++ | Debian _ | Ubuntu _ | OpenEuler _ + | FreeBSD _ -> 6 + | Windows (10, _, _) -> 40 (* Windows 10 *) + | Windows (6, _, _) -> 10 (* Windows from 2008 - 2012 *) +@@ -492,7 +502,7 @@ + and make_kickstart os arch = + match os with + (* Kickstart. *) +- | Fedora _ | CentOS _ | RHEL _ -> ++ | Fedora _ | CentOS _ | RHEL _ | OpenEuler _ -> + let ks_filename = filename_of_os os arch ".ks" in + Some (make_kickstart_common ks_filename os arch) + +@@ -513,17 +523,27 @@ + bpf "\ + # Kickstart file for %s + # Generated by libguestfs.git/builder/templates/make-template.ml ++" (string_of_os os arch); + ++ (match os with ++ | OpenEuler _ -> bpf "text\n"; ++ | _ -> ++ bpf "\ + install + text + reboot ++"; ++ ); ++ bpf "\n"; ++ ++ bpf "\ + lang en_US.UTF-8 + keyboard us + network --bootproto dhcp + rootpw builder + firewall --enabled --ssh + timezone --utc America/New_York +-" (string_of_os os arch); ++"; + + (match os with + | RHEL (ver, _) when ver <= 4 -> +@@ -561,7 +581,7 @@ + part swap --size=1024 --asprimary + part / --fstype=%s --size=1024 --grow --asprimary + " bootfs rootfs; +- | CentOS _ | RHEL _ | Fedora _ -> ++ | CentOS _ | RHEL _ | Fedora _ | OpenEuler _ -> + bpf "\ + zerombr + clearpart --all --initlabel --disklabel=gpt +@@ -581,10 +601,18 @@ + ); + bpf "\n"; + ++ (match os with ++ | OpenEuler _ -> ++ bpf "\ ++%%packages ++@^minimal-environment ++"; ++ | _ -> + bpf "\ + %%packages + @core + "; ++ ); + + (match os with + | RHEL ((3|4|5), _) -> () +@@ -917,6 +945,16 @@ + | Ubuntu (_, dist), PPC64le -> + Location (sprintf "http://ports.ubuntu.com/ubuntu-ports/dists/%s/main/installer-ppc64el" dist) + ++ | OpenEuler ver, arch -> ++ if String.length !isofile = 0 then ++ let iso = sprintf "openEuler-%s-%s-dvd.iso" ver (string_of_arch arch) in ++ let iso_xz = sprintf "https://mirrors.nju.edu.cn/openeuler/openEuler-%s/ISO/%s/%s" ver (string_of_arch arch) iso in ++ let cmd = sprintf "wget -nc %s" (quote iso_xz) in ++ if Sys.command cmd <> 0 then exit 1; ++ Location (sprintf "%s//%s" (Sys.getcwd ()) iso) ++ else ++ Location (sprintf "%s" !isofile) ++ + | FreeBSD (major, minor), X86_64 -> + let iso = sprintf "FreeBSD-%d.%d-RELEASE-amd64-disc1.iso" + major minor in +@@ -969,7 +1007,7 @@ + + (* If the install is not automated and we need a graphical console. *) + and needs_graphics = function +- | CentOS _ | RHEL _ | Debian _ | Ubuntu _ | Fedora _ -> false ++ | CentOS _ | RHEL _ | Debian _ | Ubuntu _ | OpenEuler _ | Fedora _ -> false + | FreeBSD _ | Windows _ -> true + + (* NB: Arguments do not need to be quoted, because we pass them +@@ -1042,7 +1080,7 @@ + + (* --initrd-inject and --extra-args flags for Linux only. *) + (match os with +- | Debian _ | Ubuntu _ ++ | Debian _ | Ubuntu _ | OpenEuler _ + | Fedora _ | RHEL _ | CentOS _ -> + let ks = + match ks with None -> assert false | Some ks -> ks in +@@ -1053,19 +1091,21 @@ + | Debian _ | Ubuntu _ -> "auto" + | Fedora _ | RHEL _ | CentOS _ -> + sprintf "ks=file:/%s" (Filename.basename ks) ++ | OpenEuler _ -> ++ sprintf "inst.ks=file:/%s" (Filename.basename ks) + | FreeBSD _ | Windows _ -> assert false in + let proxy = + let p = try Some (Sys.getenv "http_proxy") with Not_found -> None in + match p with + | None -> + (match os with +- | Fedora _ | RHEL _ | CentOS _ | Ubuntu _ -> "" ++ | Fedora _ | RHEL _ | CentOS _ | Ubuntu _ | OpenEuler _-> "" + | Debian _ -> "mirror/http/proxy=" + | FreeBSD _ | Windows _ -> assert false + ) + | Some p -> + match os with +- | Fedora _ | RHEL _ | CentOS _ -> "proxy=" ^ p ++ | Fedora _ | RHEL _ | CentOS _ | OpenEuler _ -> "proxy=" ^ p + | Debian _ | Ubuntu _ -> "mirror/http/proxy=" ^ p + | FreeBSD _ | Windows _ -> assert false in + +@@ -1097,6 +1137,14 @@ + ); + + add "--serial=pty"; ++ ++ (match arch with ++ | Aarch64 _ -> ++ (*Fix Error: unsupported configuration: ACPI requires UEFI on this architecture *) ++ add ("--noacpi") ++ | _ -> () ++ ); ++ + if not (needs_graphics os) then add "--nographics"; + + (* Return the command line (list of arguments). *) +@@ -1126,6 +1174,7 @@ + | RHEL (major, minor) -> sprintf "rhel%d.%d" major minor + | Debian (ver, _) -> sprintf "debian%d" ver + | Ubuntu (ver, _) -> sprintf "ubuntu%s" ver ++ | OpenEuler ver -> sprintf "voidlinux" + | FreeBSD (major, minor) -> sprintf "freebsd%d.%d" major minor + + | Windows (6, 1, Client) -> "win7" +@@ -1166,6 +1215,8 @@ + | Ubuntu ("18.04", _), _ -> "ubuntu17.04" + | Ubuntu _, _ -> assert false + ++ | OpenEuler ver, _ -> sprintf "voidlinux" ++ + | FreeBSD (major, minor), _ -> sprintf "freebsd%d.%d" major minor + + | Windows (6, 1, Client), _ -> "win7" +@@ -1188,10 +1239,9 @@ + "console=tty0 console=ttyAMA0,115200 rd_NO_PLYMOUTH" + | (Debian _|Fedora _|Ubuntu _), (PPC64|PPC64le) -> + "console=tty0 console=hvc0 rd_NO_PLYMOUTH" +- | (RHEL _|CentOS _), PPC64 +- | (RHEL _|CentOS _), PPC64le -> ++ | (RHEL _|CentOS _|OpenEuler _), PPC64 ++ | (RHEL _|CentOS _|OpenEuler _), PPC64le -> + "console=tty0 console=ttyS0,115200 rd_NO_PLYMOUTH" +- + | FreeBSD _, _ | Windows _, _ -> assert false + + and make_postinstall os arch = +@@ -1214,7 +1264,7 @@ + g#write "/etc/yum.repos.d/download.devel.redhat.com.repo" yum_conf + ) + +- | RHEL _ | Fedora _ | CentOS _ | FreeBSD _ | Windows _ -> None ++ | RHEL _ | Fedora _ | CentOS _ | FreeBSD _ | Windows _ | OpenEuler _ -> None + + and make_rhel_yum_conf major minor arch = + let buf = Buffer.create 4096 in +@@ -1391,6 +1441,8 @@ + sprintf "Ubuntu %s (%s)" ver dist + | Ubuntu (ver, dist), arch -> + sprintf "Ubuntu %s (%s) (%s)" ver dist (string_of_arch arch) ++ | OpenEuler ver, arch -> ++ sprintf "OpenEuler %s" ver + | FreeBSD (major, minor), X86_64 -> + sprintf "FreeBSD %d.%d" major minor + | FreeBSD (major, minor), arch -> +@@ -1428,6 +1480,8 @@ + | RHEL _ -> assert false (* cannot happen, see caller *) + | Ubuntu _ -> + add "This is a minimal Ubuntu install." ++ | OpenEuler _ -> ++ add "This is a minimal OpenEuler install." + | FreeBSD _ -> + add "This is an all-default FreeBSD install." + | Windows _ ->