From ptoscano at redhat.com Mon Apr 1 08:32:47 2019 From: ptoscano at redhat.com (Pino Toscano) Date: Mon, 01 Apr 2019 10:32:47 +0200 Subject: [Libosinfo] [libosinfo PATCH] gitignore: remove old entries In-Reply-To: References: <20190329162642.15629-1-ptoscano@redhat.com> Message-ID: <7362134.Pr73U7K4P3@thyrus.usersys.redhat.com> On Friday, 29 March 2019 19:28:13 CEST Fabiano Fid?ncio wrote: > On Fri, Mar 29, 2019 at 5:26 PM Pino Toscano wrote: > > > > Remove patterns referring to old tests, and in general to files that do > > not exist anymore. > > --- > > .gitignore | 22 ---------------------- > > 1 file changed, 22 deletions(-) > > > > diff --git a/.gitignore b/.gitignore > > index fb80e9f..f82d734 100644 > > --- a/.gitignore > > +++ b/.gitignore > > @@ -5,7 +5,6 @@ AUTHORS > > *~ > > .deps > > .libs > > -.sc-start-sc_* > > Makefile > > Makefile.in > > aclocal.m4 > > @@ -17,7 +16,6 @@ build-aux/depcomp > > build-aux/install-sh > > build-aux/ltmain.sh > > build-aux/missing > > -build-aux/mkinstalldirs > > build-aux/config.rpath > > build-aux/test-driver > > config.cache > > @@ -30,8 +28,6 @@ libtool > > m4 > > stamp-h1 > > tags > > -tests/test-skeleton > > -tests/test-skeleton.sh > > osinfo/libosinfo.pc > > osinfo/Libosinfo-1.0.gir > > osinfo/Libosinfo-1.0.typelib > > @@ -46,13 +42,11 @@ coverage/ > > tests/test-device > > tests/test-os > > tests/test-entity > > -tests/test-hypervisor > > tests/test-list > > tests/test-db > > tests/test-devicelist > > tests/test-devicelinklist > > tests/test-filter > > -tests/test-hypervisorlist > > tests/test-install-script > > tests/test-image > > tests/test-imagelist > > @@ -60,35 +54,19 @@ tests/test-loader > > tests/test-media > > tests/test-productfilter > > tests/test-oslist > > -tests/test-os-resources > > tests/test-product > > tests/test-platform > > tests/test-platformlist > > -tests/test-isodetect > > -tests/test-mediauris > > -tests/test-treeuris > > -tests/test-imageuris > > tests/test-tree > > tests/*.log > > tests/*.trs > > build/ > > gtk-doc.make > > -data/95-osinfo.rules > > -data/*/*/*.xml > > -data/*/*/*/*.xml > > -data/pci.ids > > -data/usb.ids > > tools/osinfo-detect > > tools/osinfo-detect.1 > > -tools/osinfo-detect.exe > > Why removing this one? osinfo-query is still part of libosinfo and > osinfo-detect.exe can be generated when building using mingw. OK, I will make a general exclusion for .exe files then. I think it will be better than listing every test (it is done for Unix executables because they have no extension). -- Pino Toscano -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: This is a digitally signed message part. URL: From ptoscano at redhat.com Mon Apr 1 08:38:48 2019 From: ptoscano at redhat.com (Pino Toscano) Date: Mon, 1 Apr 2019 10:38:48 +0200 Subject: [Libosinfo] [libosinfo PATCH v2] gitignore: remove old entries, simplify existing ones Message-ID: <20190401083848.11492-1-ptoscano@redhat.com> Remove patterns referring to old tests, and in general to files that do not exist anymore. Simplify few existing patterns into more general ones. --- .gitignore | 34 +++++----------------------------- 1 file changed, 5 insertions(+), 29 deletions(-) diff --git a/.gitignore b/.gitignore index fb80e9f..553e83d 100644 --- a/.gitignore +++ b/.gitignore @@ -2,10 +2,10 @@ ChangeLog AUTHORS *.[ao] *.l[ao] +*.exe *~ .deps .libs -.sc-start-sc_* Makefile Makefile.in aclocal.m4 @@ -17,7 +17,6 @@ build-aux/depcomp build-aux/install-sh build-aux/ltmain.sh build-aux/missing -build-aux/mkinstalldirs build-aux/config.rpath build-aux/test-driver config.cache @@ -30,12 +29,9 @@ libtool m4 stamp-h1 tags -tests/test-skeleton -tests/test-skeleton.sh -osinfo/libosinfo.pc -osinfo/Libosinfo-1.0.gir -osinfo/Libosinfo-1.0.typelib -osinfo/libosinfo-1.0.vapi +*.gir +*.typelib +*.vapi osinfo/osinfo_enum_types.[ch] osinfo/osinfo_version.h *.gcno @@ -46,13 +42,11 @@ coverage/ tests/test-device tests/test-os tests/test-entity -tests/test-hypervisor tests/test-list tests/test-db tests/test-devicelist tests/test-devicelinklist tests/test-filter -tests/test-hypervisorlist tests/test-install-script tests/test-image tests/test-imagelist @@ -60,36 +54,18 @@ tests/test-loader tests/test-media tests/test-productfilter tests/test-oslist -tests/test-os-resources tests/test-product tests/test-platform tests/test-platformlist -tests/test-isodetect -tests/test-mediauris -tests/test-treeuris -tests/test-imageuris tests/test-tree tests/*.log tests/*.trs build/ gtk-doc.make -data/95-osinfo.rules -data/*/*/*.xml -data/*/*/*/*.xml -data/pci.ids -data/usb.ids +tools/*.1 tools/osinfo-detect -tools/osinfo-detect.1 -tools/osinfo-detect.exe -tools/osinfo-db-validate -tools/osinfo-db-validate.exe -tools/osinfo-db-validate.1 tools/osinfo-query -tools/osinfo-query.1 -tools/osinfo-query.exe tools/osinfo-install-script -tools/osinfo-install-script.exe -tools/osinfo-install-script.1 docs/reference/Libosinfo.types po/Makefile.in.in po/POTFILES -- 2.20.1 From crobinso at redhat.com Mon Apr 1 18:35:55 2019 From: crobinso at redhat.com (Cole Robinson) Date: Mon, 1 Apr 2019 14:35:55 -0400 Subject: [Libosinfo] [libosinfo PATCH v2 0/8] Use "all" arch as a fallback for media/tree detection In-Reply-To: <20190328212614.25589-1-fidencio@redhat.com> References: <20190328212614.25589-1-fidencio@redhat.com> Message-ID: <5f3e5a43-1f68-2666-b5fa-6ee3854937c8@redhat.com> On 3/28/19 5:26 PM, Fabiano Fid?ncio wrote: > This series has been written considering: > - https://www.redhat.com/archives/libosinfo/2019-February/msg00247.html > > Let's assume that trees and medias set with architecture "all" will be > treated as fallback, always. > > https://gitlab.com/libosinfo/libosinfo/issues/20 > > Fabiano Fid?ncio (8): > db: Rename tree to treeinfo in guess_os_from_tree() > db: Rename os_* to os_treeinfo_* in guess_os_from_tree() > db: Consider the tree arch when guessing an OS from tree > db: Deal with "all" tree architectures > test-db: Add test for guessing tree from OS > db: Consider the media arch when guess an OS from media > db: Deal with "all" media architecture > test-db: Add test to cover identifying a media with "unknown" arch > > osinfo/osinfo_db.c | 184 ++++++++++++------ > .../dbdata/os/libosinfo.org/test-db-media.xml | 14 ++ > .../dbdata/os/libosinfo.org/test-db-tree.xml | 25 +++ > tests/test-db.c | 78 ++++++++ > 4 files changed, 237 insertions(+), 64 deletions(-) > create mode 100644 tests/dbdata/os/libosinfo.org/test-db-tree.xml > Reviewed-by: Cole Robinson I tested with my rhel5 arch='unknown' patchset switched to arch='all' and things seemed to work too. Separate from this patchset I've been thinking about tree testing in general and I think before the next release we need: - A functional test to run every with through libosinfo code to ensure that our logic actually detects the correct short-id and tree arch. - Populate the osinfo-db test suite with treeinfo files similar to what we do with isoinfo output and do unit testing that way. It scares me a little that an overly liberal regex added to osinfo-db could cause tree detection regressions by matching the newly added db entry. Partly it makes me think that we should actually attempt to match against every or in osinfo-db and return the one with the most matching fields. This would let us make fedora-unknown just have a *Fedora*<... value and not need to worry about it also matching other Fedora versions since those will have more than one field. It will also reduce the chance of accidental collision with newly added . Just some ideas... Thanks, Cole From crobinso at redhat.com Mon Apr 1 18:57:46 2019 From: crobinso at redhat.com (Cole Robinson) Date: Mon, 1 Apr 2019 14:57:46 -0400 Subject: [Libosinfo] [PATCH osinfo-db v2 0/3] rhel5: add entries Message-ID: v1: https://www.redhat.com/archives/libosinfo/2019-February/msg00247.html See v1 cover letter for justification. This adds the simplest entry to make rhel5 treeinfo detection work. Changes since v1: - Use arch="all" which the libosinfo patches accomodate Cole Robinson (3): schema: rename 'archnamesorwildcard' to 'archnamesorall' schema: allow rhel5: add tree arch="all" information data/os/redhat.com/rhel-5.10.xml.in | 7 +++++++ data/os/redhat.com/rhel-5.11.xml.in | 7 +++++++ data/os/redhat.com/rhel-5.4.xml.in | 7 +++++++ data/os/redhat.com/rhel-5.5.xml.in | 7 +++++++ data/os/redhat.com/rhel-5.6.xml.in | 7 +++++++ data/os/redhat.com/rhel-5.7.xml.in | 7 +++++++ data/os/redhat.com/rhel-5.8.xml.in | 7 +++++++ data/os/redhat.com/rhel-5.9.xml.in | 7 +++++++ data/schema/osinfo.rng.in | 6 +++--- 9 files changed, 59 insertions(+), 3 deletions(-) -- 2.21.0 From crobinso at redhat.com Mon Apr 1 18:57:47 2019 From: crobinso at redhat.com (Cole Robinson) Date: Mon, 1 Apr 2019 14:57:47 -0400 Subject: [Libosinfo] [PATCH osinfo-db v2 1/3] schema: rename 'archnamesorwildcard' to 'archnamesorall' In-Reply-To: References: Message-ID: <16772e9ffbb4adc085484ddf75656e6e0292fa6c.1554144855.git.crobinso@redhat.com> The latter is a better description of what the group actually is: 'archnames' values plus the 'all' value Signed-off-by: Cole Robinson --- data/schema/osinfo.rng.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/data/schema/osinfo.rng.in b/data/schema/osinfo.rng.in index d778239..858e55b 100644 --- a/data/schema/osinfo.rng.in +++ b/data/schema/osinfo.rng.in @@ -290,7 +290,7 @@ - + @@ -774,7 +774,7 @@ - + all -- 2.21.0 From crobinso at redhat.com Mon Apr 1 18:57:48 2019 From: crobinso at redhat.com (Cole Robinson) Date: Mon, 1 Apr 2019 14:57:48 -0400 Subject: [Libosinfo] [PATCH osinfo-db v2 2/3] schema: allow In-Reply-To: References: Message-ID: <552cb11fd0a12bb8b976811c676e3bbd1d184dea.1554144855.git.crobinso@redhat.com> Signed-off-by: Cole Robinson --- data/schema/osinfo.rng.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/schema/osinfo.rng.in b/data/schema/osinfo.rng.in index 858e55b..b3760d2 100644 --- a/data/schema/osinfo.rng.in +++ b/data/schema/osinfo.rng.in @@ -467,7 +467,7 @@ - + -- 2.21.0 From crobinso at redhat.com Mon Apr 1 18:57:49 2019 From: crobinso at redhat.com (Cole Robinson) Date: Mon, 1 Apr 2019 14:57:49 -0400 Subject: [Libosinfo] [PATCH osinfo-db v2 3/3] rhel5: add entries In-Reply-To: References: Message-ID: <7ee26d97561e0ac8cbe70e8fd70d6a562c7f5d79.1554144855.git.crobinso@redhat.com> Only rhel5.4+ has .treeinfo Family here will match both rhel5 client and server trees Signed-off-by: Cole Robinson --- data/os/redhat.com/rhel-5.10.xml.in | 7 +++++++ data/os/redhat.com/rhel-5.11.xml.in | 7 +++++++ data/os/redhat.com/rhel-5.4.xml.in | 7 +++++++ data/os/redhat.com/rhel-5.5.xml.in | 7 +++++++ data/os/redhat.com/rhel-5.6.xml.in | 7 +++++++ data/os/redhat.com/rhel-5.7.xml.in | 7 +++++++ data/os/redhat.com/rhel-5.8.xml.in | 7 +++++++ data/os/redhat.com/rhel-5.9.xml.in | 7 +++++++ 8 files changed, 56 insertions(+) diff --git a/data/os/redhat.com/rhel-5.10.xml.in b/data/os/redhat.com/rhel-5.10.xml.in index 8bdf653..afe9429 100644 --- a/data/os/redhat.com/rhel-5.10.xml.in +++ b/data/os/redhat.com/rhel-5.10.xml.in @@ -27,5 +27,12 @@ .*RHEL/5.10 x86_64.* + + + + Red Hat Enterprise Linux + 5.10 + + diff --git a/data/os/redhat.com/rhel-5.11.xml.in b/data/os/redhat.com/rhel-5.11.xml.in index a8a295c..13eeca7 100644 --- a/data/os/redhat.com/rhel-5.11.xml.in +++ b/data/os/redhat.com/rhel-5.11.xml.in @@ -27,5 +27,12 @@ .*RHEL/5.11 x86_64.* + + + + Red Hat Enterprise Linux + 5.11 + + diff --git a/data/os/redhat.com/rhel-5.4.xml.in b/data/os/redhat.com/rhel-5.4.xml.in index 2806fa5..b552354 100644 --- a/data/os/redhat.com/rhel-5.4.xml.in +++ b/data/os/redhat.com/rhel-5.4.xml.in @@ -27,5 +27,12 @@ .*RHEL/5.4 x86_64.* + + + + Red Hat Enterprise Linux + 5.4 + + diff --git a/data/os/redhat.com/rhel-5.5.xml.in b/data/os/redhat.com/rhel-5.5.xml.in index 3fa31be..5b09d28 100644 --- a/data/os/redhat.com/rhel-5.5.xml.in +++ b/data/os/redhat.com/rhel-5.5.xml.in @@ -27,5 +27,12 @@ .*RHEL/5.5 x86_64.* + + + + Red Hat Enterprise Linux + 5.5 + + diff --git a/data/os/redhat.com/rhel-5.6.xml.in b/data/os/redhat.com/rhel-5.6.xml.in index d132a77..421f0df 100644 --- a/data/os/redhat.com/rhel-5.6.xml.in +++ b/data/os/redhat.com/rhel-5.6.xml.in @@ -33,5 +33,12 @@ .*RHEL/5.6 x86_64.* + + + + Red Hat Enterprise Linux + 5.6 + + diff --git a/data/os/redhat.com/rhel-5.7.xml.in b/data/os/redhat.com/rhel-5.7.xml.in index f949ef1..d990e7a 100644 --- a/data/os/redhat.com/rhel-5.7.xml.in +++ b/data/os/redhat.com/rhel-5.7.xml.in @@ -27,5 +27,12 @@ .*RHEL/5.7 x86_64.* + + + + Red Hat Enterprise Linux + 5.7 + + diff --git a/data/os/redhat.com/rhel-5.8.xml.in b/data/os/redhat.com/rhel-5.8.xml.in index 6ef0621..b1c19a7 100644 --- a/data/os/redhat.com/rhel-5.8.xml.in +++ b/data/os/redhat.com/rhel-5.8.xml.in @@ -27,5 +27,12 @@ .*RHEL/5.8 x86_64.* + + + + Red Hat Enterprise Linux + 5.8 + + diff --git a/data/os/redhat.com/rhel-5.9.xml.in b/data/os/redhat.com/rhel-5.9.xml.in index 16f6e36..44d89a1 100644 --- a/data/os/redhat.com/rhel-5.9.xml.in +++ b/data/os/redhat.com/rhel-5.9.xml.in @@ -27,5 +27,12 @@ .*RHEL/5.9 x86_64.* + + + + Red Hat Enterprise Linux + 5.9 + + -- 2.21.0 From crobinso at redhat.com Mon Apr 1 18:59:29 2019 From: crobinso at redhat.com (Cole Robinson) Date: Mon, 1 Apr 2019 14:59:29 -0400 Subject: [Libosinfo] [osinfo-db PATCH 0/2] Update debian-8 URLS In-Reply-To: <20190329181725.29823-1-fidencio@redhat.com> References: <20190329181725.29823-1-fidencio@redhat.com> Message-ID: On 3/29/19 2:17 PM, Fabiano Fid?ncio wrote: > Let's update debian-8 media URLs for the latest release and let's remove > the dead trees as those were removed from debian's website. > > Fabiano Fid?ncio (2): > debian8: Update to latest release > debian8: Remove dead trees > > data/os/debian.org/debian-8.xml.in | 22 +++++----------------- > 1 file changed, 5 insertions(+), 17 deletions(-) > Reviewed-by: Cole Robinson - Cole From crobinso at redhat.com Mon Apr 1 19:04:16 2019 From: crobinso at redhat.com (Cole Robinson) Date: Mon, 1 Apr 2019 15:04:16 -0400 Subject: [Libosinfo] [osinfo-db PATCH 0/3] Add network-install resources In-Reply-To: <20190329182254.30415-1-fidencio@redhat.com> References: <20190329182254.30415-1-fidencio@redhat.com> Message-ID: On 3/29/19 2:22 PM, Fabiano Fid?ncio wrote: > Fedora Silverblue, CentOS 7 and RHEL 7.* are the first targets for taking > advantage of network-install resources as those require more RAM during > installation time (when performing a network installation) than their > recommended amount of RAM. > > Both CentOS 7 and RHEL 7.* need their memory bumped to 1.5GB during > installation and Fedora Silverblue needs 5GB! > > I'm aware that fedora-rawhide will also need some adjustment, but I was > *not* able to successfully start an installation due to non related > issues. So, it'll be updated at some point, later on. > > Fabiano Fid?ncio (3): > rhel7*: Add network-install resources > centos7: Add network-install resources > silverblue28 & 29: Add network-install resources > > data/os/centos.org/centos-7.0.xml.in | 4 ++++ > data/os/fedoraproject.org/silverblue-28.xml.in | 4 ++++ > data/os/fedoraproject.org/silverblue-29.xml.in | 4 ++++ > data/os/redhat.com/rhel-7-unknown.xml.in | 4 ++++ > data/os/redhat.com/rhel-7.0.xml.in | 4 ++++ > data/os/redhat.com/rhel-7.1.xml.in | 4 ++++ > data/os/redhat.com/rhel-7.2.xml.in | 4 ++++ > data/os/redhat.com/rhel-7.3.xml.in | 4 ++++ > data/os/redhat.com/rhel-7.4.xml.in | 4 ++++ > data/os/redhat.com/rhel-7.5.xml.in | 4 ++++ > data/os/redhat.com/rhel-7.6.xml.in | 4 ++++ > 11 files changed, 44 insertions(+) > Reviewed-by: Cole Robinson - Cole From fidencio at redhat.com Mon Apr 1 19:13:13 2019 From: fidencio at redhat.com (=?UTF-8?Q?Fabiano_Fid=C3=AAncio?=) Date: Mon, 1 Apr 2019 21:13:13 +0200 Subject: [Libosinfo] [libosinfo PATCH v2 0/8] Use "all" arch as a fallback for media/tree detection In-Reply-To: <5f3e5a43-1f68-2666-b5fa-6ee3854937c8@redhat.com> References: <20190328212614.25589-1-fidencio@redhat.com> <5f3e5a43-1f68-2666-b5fa-6ee3854937c8@redhat.com> Message-ID: On Mon, Apr 1, 2019 at 8:36 PM Cole Robinson wrote: > > On 3/28/19 5:26 PM, Fabiano Fid?ncio wrote: > > This series has been written considering: > > - https://www.redhat.com/archives/libosinfo/2019-February/msg00247.html > > > > Let's assume that trees and medias set with architecture "all" will be > > treated as fallback, always. > > > > https://gitlab.com/libosinfo/libosinfo/issues/20 > > > > Fabiano Fid?ncio (8): > > db: Rename tree to treeinfo in guess_os_from_tree() > > db: Rename os_* to os_treeinfo_* in guess_os_from_tree() > > db: Consider the tree arch when guessing an OS from tree > > db: Deal with "all" tree architectures > > test-db: Add test for guessing tree from OS > > db: Consider the media arch when guess an OS from media > > db: Deal with "all" media architecture > > test-db: Add test to cover identifying a media with "unknown" arch > > > > osinfo/osinfo_db.c | 184 ++++++++++++------ > > .../dbdata/os/libosinfo.org/test-db-media.xml | 14 ++ > > .../dbdata/os/libosinfo.org/test-db-tree.xml | 25 +++ > > tests/test-db.c | 78 ++++++++ > > 4 files changed, 237 insertions(+), 64 deletions(-) > > create mode 100644 tests/dbdata/os/libosinfo.org/test-db-tree.xml > > > > Reviewed-by: Cole Robinson > > I tested with my rhel5 arch='unknown' patchset switched to arch='all' > and things seemed to work too. > > > Separate from this patchset I've been thinking about tree testing in > general and I think before the next release we need: > > - A functional test to run every with through > libosinfo code to ensure that our logic actually detects the correct > short-id and tree arch. Yep, a functional test could be added to our tools, using osinfo-detect tools. It can be done using python (in the same way we've done for osinfo-db). I'm currently trying to work on something similar for osinfo-db-tools and libosinfo would be my next target; > > - Populate the osinfo-db test suite with treeinfo files similar to what > we do with isoinfo output and do unit testing that way. Agreed. > > It scares me a little that an overly liberal regex added to osinfo-db > could cause tree detection regressions by matching the newly added db > entry. Partly it makes me think that we should actually attempt to match > against every or in osinfo-db and return the one with > the most matching fields. This would let us make fedora-unknown just > have a *Fedora*<... value and not need to worry about > it also matching other Fedora versions since those will have more than > one field. It will also reduce the chance of accidental collision with > newly added . Just some ideas... Hmmm. I like the idea, but it'd make things slightly slower. In order to do so we could add some weight on every match we have, sort the matches by the weight and just return the heaviest one. Do-able. Daniel, I'd like to hear from you here. Best Regards, -- Fabiano Fid?ncio From fidencio at redhat.com Mon Apr 1 20:30:34 2019 From: fidencio at redhat.com (=?UTF-8?Q?Fabiano_Fid=C3=AAncio?=) Date: Mon, 1 Apr 2019 22:30:34 +0200 Subject: [Libosinfo] [libosinfo PATCH v2 0/8] Use "all" arch as a fallback for media/tree detection In-Reply-To: References: <20190328212614.25589-1-fidencio@redhat.com> <5f3e5a43-1f68-2666-b5fa-6ee3854937c8@redhat.com> Message-ID: On Mon, Apr 1, 2019 at 9:13 PM Fabiano Fid?ncio wrote: > > On Mon, Apr 1, 2019 at 8:36 PM Cole Robinson wrote: > > > > On 3/28/19 5:26 PM, Fabiano Fid?ncio wrote: > > > This series has been written considering: > > > - https://www.redhat.com/archives/libosinfo/2019-February/msg00247.html > > > > > > Let's assume that trees and medias set with architecture "all" will be > > > treated as fallback, always. > > > > > > https://gitlab.com/libosinfo/libosinfo/issues/20 > > > > > > Fabiano Fid?ncio (8): > > > db: Rename tree to treeinfo in guess_os_from_tree() > > > db: Rename os_* to os_treeinfo_* in guess_os_from_tree() > > > db: Consider the tree arch when guessing an OS from tree > > > db: Deal with "all" tree architectures > > > test-db: Add test for guessing tree from OS > > > db: Consider the media arch when guess an OS from media > > > db: Deal with "all" media architecture > > > test-db: Add test to cover identifying a media with "unknown" arch > > > > > > osinfo/osinfo_db.c | 184 ++++++++++++------ > > > .../dbdata/os/libosinfo.org/test-db-media.xml | 14 ++ > > > .../dbdata/os/libosinfo.org/test-db-tree.xml | 25 +++ > > > tests/test-db.c | 78 ++++++++ > > > 4 files changed, 237 insertions(+), 64 deletions(-) > > > create mode 100644 tests/dbdata/os/libosinfo.org/test-db-tree.xml > > > > > > > Reviewed-by: Cole Robinson > > > > I tested with my rhel5 arch='unknown' patchset switched to arch='all' > > and things seemed to work too. > > > > > > Separate from this patchset I've been thinking about tree testing in > > general and I think before the next release we need: > > > > - A functional test to run every with through > > libosinfo code to ensure that our logic actually detects the correct > > short-id and tree arch. > > Yep, a functional test could be added to our tools, using osinfo-detect tools. > It can be done using python (in the same way we've done for osinfo-db). > > I'm currently trying to work on something similar for osinfo-db-tools > and libosinfo would be my next target; > > > > > - Populate the osinfo-db test suite with treeinfo files similar to what > > we do with isoinfo output and do unit testing that way. > > Agreed. > > > > > It scares me a little that an overly liberal regex added to osinfo-db > > could cause tree detection regressions by matching the newly added db > > entry. Partly it makes me think that we should actually attempt to match > > against every or in osinfo-db and return the one with > > the most matching fields. This would let us make fedora-unknown just > > have a *Fedora*<... value and not need to worry about > > it also matching other Fedora versions since those will have more than > > one field. It will also reduce the chance of accidental collision with > > newly added . Just some ideas... > > Hmmm. I like the idea, but it'd make things slightly slower. > In order to do so we could add some weight on every match we have, > sort the matches by the weight and just return the heaviest one. > Do-able. > > Daniel, I'd like to hear from you here. > > Best Regards, > -- > Fabiano Fid?ncio Hmm. Cole found an issue with the series, so I'll hold till it's fixed. Basically, when calling create_media_from_location(), when actually creating the media, we'd hit the following code path: ``` media = g_object_new(OSINFO_TYPE_MEDIA, "id", uri, NULL); ``` (same codepath can be seen at: https://gitlab.com/libosinfo/libosinfo/blob/master/osinfo/osinfo_media.c#L814) It means that *all* medias are created *without* having an architecture set. Which basically changes everything for the media related patches, because we *cannot* rely on comparing architectures. I'll re-work the patches taking into consideration this limitation and submit a v3. Best Regards, -- Fabiano Fid?ncio From fidencio at redhat.com Mon Apr 1 20:45:01 2019 From: fidencio at redhat.com (=?UTF-8?q?Fabiano=20Fid=C3=AAncio?=) Date: Mon, 1 Apr 2019 22:45:01 +0200 Subject: [Libosinfo] [libosinfo PATCH] media: Fix usage of application id Message-ID: <20190401204501.29470-1-fidencio@redhat.com> Christophe Fergeau pointed this issue out during the review of 6d789033e and, even though, the bogus code ended up merged (sorry, mea culpa here!). Signed-off-by: Fabiano Fid?ncio --- osinfo/osinfo_media.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osinfo/osinfo_media.c b/osinfo/osinfo_media.c index b16fcf6..4f86c2b 100644 --- a/osinfo/osinfo_media.c +++ b/osinfo/osinfo_media.c @@ -830,10 +830,10 @@ create_from_location_async_data(CreateFromLocationAsyncData *data) osinfo_entity_set_param(OSINFO_ENTITY(media), OSINFO_MEDIA_PROP_PUBLISHER_ID, data->publisher); - if (!is_str_empty(data->pvd.application)) + if (!is_str_empty(data->application)) osinfo_entity_set_param(OSINFO_ENTITY(media), OSINFO_MEDIA_PROP_APPLICATION_ID, - data->pvd.application); + data->application); index = (G_BYTE_ORDER == G_LITTLE_ENDIAN) ? 0 : 1; vol_size = ((gint64) data->pvd.volume_space_size[index]) * -- 2.20.1 From fidencio at redhat.com Tue Apr 2 09:36:04 2019 From: fidencio at redhat.com (=?UTF-8?q?Fabiano=20Fid=C3=AAncio?=) Date: Tue, 2 Apr 2019 11:36:04 +0200 Subject: [Libosinfo] [osinfo-db PATCH 0/2] Update/remove dead links Message-ID: <20190402093606.20992-1-fidencio@redhat.com> Those 2 patches have been pushed under "test breakage" rule. Fabiano Fid?ncio (2): freebsd: Remove 10.4, 11.0, and 11.1 dead links fedora27: Update dead links data/os/fedoraproject.org/fedora-27.xml.in | 12 ++++++------ data/os/freebsd.org/freebsd-10.4.xml.in | 4 ---- data/os/freebsd.org/freebsd-11.0.xml.in | 4 ---- data/os/freebsd.org/freebsd-11.1.xml.in | 4 ---- 4 files changed, 6 insertions(+), 18 deletions(-) -- 2.20.1 From fidencio at redhat.com Tue Apr 2 09:36:05 2019 From: fidencio at redhat.com (=?UTF-8?q?Fabiano=20Fid=C3=AAncio?=) Date: Tue, 2 Apr 2019 11:36:05 +0200 Subject: [Libosinfo] [osinfo-db PATCH 1/2] freebsd: Remove 10.4, 11.0, and 11.1 dead links In-Reply-To: <20190402093606.20992-1-fidencio@redhat.com> References: <20190402093606.20992-1-fidencio@redhat.com> Message-ID: <20190402093606.20992-2-fidencio@redhat.com> Those links have been from their website. Signed-off-by: Fabiano Fid?ncio --- data/os/freebsd.org/freebsd-10.4.xml.in | 4 ---- data/os/freebsd.org/freebsd-11.0.xml.in | 4 ---- data/os/freebsd.org/freebsd-11.1.xml.in | 4 ---- 3 files changed, 12 deletions(-) diff --git a/data/os/freebsd.org/freebsd-10.4.xml.in b/data/os/freebsd.org/freebsd-10.4.xml.in index d5dd711..52117cd 100644 --- a/data/os/freebsd.org/freebsd-10.4.xml.in +++ b/data/os/freebsd.org/freebsd-10.4.xml.in @@ -15,28 +15,24 @@ 2018-10-31 - https://download.freebsd.org/ftp/releases/ISO-IMAGES/10.4/FreeBSD-10.4-RELEASE-amd64-dvd1.iso FreeBSD 10_4_RELEASE_AMD64_DVD - https://download.freebsd.org/ftp/releases/ISO-IMAGES/10.4/FreeBSD-10.4-RELEASE-amd64-disc1.iso FreeBSD 10_4_RELEASE_AMD64_CD - https://download.freebsd.org/ftp/releases/ISO-IMAGES/10.4/FreeBSD-10.4-RELEASE-i386-dvd1.iso FreeBSD 10_4_RELEASE_I386_DVD - https://download.freebsd.org/ftp/releases/ISO-IMAGES/10.4/FreeBSD-10.4-RELEASE-i386-disc1.iso FreeBSD 10_4_RELEASE_I386_CD diff --git a/data/os/freebsd.org/freebsd-11.0.xml.in b/data/os/freebsd.org/freebsd-11.0.xml.in index ecd5968..4bdc30b 100644 --- a/data/os/freebsd.org/freebsd-11.0.xml.in +++ b/data/os/freebsd.org/freebsd-11.0.xml.in @@ -14,28 +14,24 @@ 2016-10-10 - https://download.freebsd.org/ftp/releases/ISO-IMAGES/11.0/FreeBSD-11.0-RELEASE-amd64-dvd1.iso FreeBSD 11_0_RELEASE_P1_AMD64_DVD - https://download.freebsd.org/ftp/releases/ISO-IMAGES/11.0/FreeBSD-11.0-RELEASE-amd64-disc1.iso FreeBSD 11_0_RELEASE_P1_AMD64_CD - https://download.freebsd.org/ftp/releases/ISO-IMAGES/11.0/FreeBSD-11.0-RELEASE-i386-dvd1.iso FreeBSD 11_0_RELEASE_P1_I386_DVD - https://download.freebsd.org/ftp/releases/ISO-IMAGES/11.0/FreeBSD-11.0-RELEASE-i386-disc1.iso FreeBSD 11_0_RELEASE_P1_I386_CD diff --git a/data/os/freebsd.org/freebsd-11.1.xml.in b/data/os/freebsd.org/freebsd-11.1.xml.in index d739432..e41799e 100644 --- a/data/os/freebsd.org/freebsd-11.1.xml.in +++ b/data/os/freebsd.org/freebsd-11.1.xml.in @@ -14,28 +14,24 @@ 2017-07-26 - https://download.freebsd.org/ftp/releases/ISO-IMAGES/11.1/FreeBSD-11.1-RELEASE-amd64-dvd1.iso FreeBSD 11_1_RELEASE_AMD64_DVD - https://download.freebsd.org/ftp/releases/ISO-IMAGES/11.1/FreeBSD-11.1-RELEASE-amd64-disc1.iso FreeBSD 11_1_RELEASE_AMD64_CD - https://download.freebsd.org/ftp/releases/ISO-IMAGES/11.1/FreeBSD-11.1-RELEASE-i386-dvd1.iso FreeBSD 11_1_RELEASE_I386_DVD - https://download.freebsd.org/ftp/releases/ISO-IMAGES/11.1/FreeBSD-11.1-RELEASE-i386-disc1.iso FreeBSD 11_1_RELEASE_I386_CD -- 2.20.1 From fidencio at redhat.com Tue Apr 2 09:36:06 2019 From: fidencio at redhat.com (=?UTF-8?q?Fabiano=20Fid=C3=AAncio?=) Date: Tue, 2 Apr 2019 11:36:06 +0200 Subject: [Libosinfo] [osinfo-db PATCH 2/2] fedora27: Update dead links In-Reply-To: <20190402093606.20992-1-fidencio@redhat.com> References: <20190402093606.20992-1-fidencio@redhat.com> Message-ID: <20190402093606.20992-3-fidencio@redhat.com> Fedora 27 links have been moved to archive. Signed-off-by: Fabiano Fid?ncio --- data/os/fedoraproject.org/fedora-27.xml.in | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/data/os/fedoraproject.org/fedora-27.xml.in b/data/os/fedoraproject.org/fedora-27.xml.in index 3d7acb1..1baa5fa 100644 --- a/data/os/fedoraproject.org/fedora-27.xml.in +++ b/data/os/fedoraproject.org/fedora-27.xml.in @@ -35,7 +35,7 @@ - https://archive.fedoraproject.org/pub/fedora/linux/releases/27/Workstation/x86_64/iso/Fedora-Workstation-Live-x86_64-27-1.6.iso + https://archive.fedoraproject.org/pub/archive/fedora/linux/releases/27/Workstation/x86_64/iso/Fedora-Workstation-Live-x86_64-27-1.6.iso Fedora-WS-Live-27.* LINUX @@ -47,7 +47,7 @@ - https://archive.fedoraproject.org/pub/fedora/linux/releases/27/WorkstationOstree/x86_64/iso/Fedora-WorkstationOstree-ostree-x86_64-27-1.6.iso + https://archive.fedoraproject.org/pub/archive/fedora/linux/releases/27/WorkstationOstree/x86_64/iso/Fedora-WorkstationOstree-ostree-x86_64-27-1.6.iso Fedora-WSOstree-ostree-x86_64-27 LINUX @@ -62,7 +62,7 @@ - https://archive.fedoraproject.org/pub/fedora/linux/releases/27/Workstation/x86_64/iso/Fedora-Workstation-netinst-x86_64-27-1.6.iso + https://archive.fedoraproject.org/pub/archive/fedora/linux/releases/27/Workstation/x86_64/iso/Fedora-Workstation-netinst-x86_64-27-1.6.iso Fedora-WS-dvd-x86_64-27 LINUX @@ -79,7 +79,7 @@ - https://archive.fedoraproject.org/pub/fedora/linux/releases/27/Server/x86_64/iso/Fedora-Server-dvd-x86_64-27-1.6.iso + https://archive.fedoraproject.org/pub/archive/fedora/linux/releases/27/Server/x86_64/iso/Fedora-Server-dvd-x86_64-27-1.6.iso Fedora-S-dvd-x86_64-27 LINUX @@ -95,7 +95,7 @@ - https://archive.fedoraproject.org/pub/fedora/linux/releases/27/Server/x86_64/iso/Fedora-Server-netinst-x86_64-27-1.6.iso + https://archive.fedoraproject.org/pub/archive/fedora/linux/releases/27/Server/x86_64/iso/Fedora-Server-netinst-x86_64-27-1.6.iso Fedora-S-dvd-x86_64-27 LINUX @@ -109,7 +109,7 @@ - https://archive.fedoraproject.org/pub/fedora/linux/releases/27/Server/x86_64/os/ + https://archive.fedoraproject.org/pub/archive/fedora/linux/releases/27/Server/x86_64/os/ Fedora -- 2.20.1 From fidencio at redhat.com Tue Apr 2 10:18:45 2019 From: fidencio at redhat.com (=?UTF-8?q?Fabiano=20Fid=C3=AAncio?=) Date: Tue, 2 Apr 2019 12:18:45 +0200 Subject: [Libosinfo] [libosinfo PATCH v3 0/6] Use "all" arch as a fallback for media/tree detection Message-ID: <20190402101851.2007-1-fidencio@redhat.com> This series has been written considering: - https://www.redhat.com/archives/libosinfo/2019-February/msg00247.html Let's assume that trees and medias set with architecture "all" will be treated as fallback, always. NOTE: In the v3 a different approach has been taken and there's no explicit check comparing architectures. The reason for this is that create_media_from_location() will always create a media with NULL arch, which would simply break the check. :-( For now, let's just leave arch out of the game, as it was before this series, and just check the arch of our DB entries in order to leave all the entries with "all" arch to be evaluated later. https://gitlab.com/libosinfo/libosinfo/issues/20 Fabiano Fid?ncio (6): db: Rename tree to treeinfo in guess_os_from_tree() db: Rename os_* to os_treeinfo_* in guess_os_from_tree() db: Deal with "all" tree architectures test-db: Add test for guessing tree from OS db: Deal with "all" media architecture test-db: Add test to cover identifying a media with "unknown" arch osinfo/osinfo_db.c | 178 +++++++++++------- .../dbdata/os/libosinfo.org/test-db-media.xml | 13 ++ .../dbdata/os/libosinfo.org/test-db-tree.xml | 26 +++ tests/test-db.c | 80 ++++++++ 4 files changed, 233 insertions(+), 64 deletions(-) create mode 100644 tests/dbdata/os/libosinfo.org/test-db-tree.xml -- 2.20.1 From fidencio at redhat.com Tue Apr 2 10:18:46 2019 From: fidencio at redhat.com (=?UTF-8?q?Fabiano=20Fid=C3=AAncio?=) Date: Tue, 2 Apr 2019 12:18:46 +0200 Subject: [Libosinfo] [libosinfo PATCH v3 1/6] db: Rename tree to treeinfo in guess_os_from_tree() In-Reply-To: <20190402101851.2007-1-fidencio@redhat.com> References: <20190402101851.2007-1-fidencio@redhat.com> Message-ID: <20190402101851.2007-2-fidencio@redhat.com> It'll make clear that we're dealing with the treeinfo attributes and not with the tree ones. https://gitlab.com/libosinfo/libosinfo/issues/20 Signed-off-by: Fabiano Fid?ncio --- osinfo/osinfo_db.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/osinfo/osinfo_db.c b/osinfo/osinfo_db.c index fa217a2..3795903 100644 --- a/osinfo/osinfo_db.c +++ b/osinfo/osinfo_db.c @@ -761,18 +761,18 @@ OsinfoOs *osinfo_db_guess_os_from_tree(OsinfoDb *db, OsinfoOs *ret = NULL; GList *oss = NULL; GList *os_iter; - const gchar *tree_family; - const gchar *tree_variant; - const gchar *tree_version; - const gchar *tree_arch; + const gchar *treeinfo_family; + const gchar *treeinfo_variant; + const gchar *treeinfo_version; + const gchar *treeinfo_arch; g_return_val_if_fail(OSINFO_IS_DB(db), NULL); g_return_val_if_fail(tree != NULL, NULL); - tree_family = osinfo_tree_get_treeinfo_family(tree); - tree_variant = osinfo_tree_get_treeinfo_variant(tree); - tree_version = osinfo_tree_get_treeinfo_version(tree); - tree_arch = osinfo_tree_get_treeinfo_arch(tree); + treeinfo_family = osinfo_tree_get_treeinfo_family(tree); + treeinfo_variant = osinfo_tree_get_treeinfo_variant(tree); + treeinfo_version = osinfo_tree_get_treeinfo_version(tree); + treeinfo_arch = osinfo_tree_get_treeinfo_arch(tree); oss = osinfo_list_get_elements(OSINFO_LIST(db->priv->oses)); for (os_iter = oss; os_iter; os_iter = os_iter->next) { @@ -798,10 +798,10 @@ OsinfoOs *osinfo_db_guess_os_from_tree(OsinfoDb *db, os_version = osinfo_tree_get_treeinfo_version(os_tree); os_arch = osinfo_tree_get_treeinfo_arch(os_tree); - if (match_regex(os_family, tree_family) && - match_regex(os_variant, tree_variant) && - match_regex(os_version, tree_version) && - match_regex(os_arch, tree_arch)) { + if (match_regex(os_family, treeinfo_family) && + match_regex(os_variant, treeinfo_variant) && + match_regex(os_version, treeinfo_version) && + match_regex(os_arch, treeinfo_arch)) { ret = os; if (matched_tree != NULL) *matched_tree = os_tree; -- 2.20.1 From fidencio at redhat.com Tue Apr 2 10:18:47 2019 From: fidencio at redhat.com (=?UTF-8?q?Fabiano=20Fid=C3=AAncio?=) Date: Tue, 2 Apr 2019 12:18:47 +0200 Subject: [Libosinfo] [libosinfo PATCH v3 2/6] db: Rename os_* to os_treeinfo_* in guess_os_from_tree() In-Reply-To: <20190402101851.2007-1-fidencio@redhat.com> References: <20190402101851.2007-1-fidencio@redhat.com> Message-ID: <20190402101851.2007-3-fidencio@redhat.com> It'll make clear that we're dealing with the treeinfo attributes and not with the tree ones. https://gitlab.com/libosinfo/libosinfo/issues/20 Signed-off-by: Fabiano Fid?ncio --- osinfo/osinfo_db.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/osinfo/osinfo_db.c b/osinfo/osinfo_db.c index 3795903..136cf79 100644 --- a/osinfo/osinfo_db.c +++ b/osinfo/osinfo_db.c @@ -785,23 +785,23 @@ OsinfoOs *osinfo_db_guess_os_from_tree(OsinfoDb *db, for (tree_iter = trees; tree_iter; tree_iter = tree_iter->next) { OsinfoTree *os_tree = OSINFO_TREE(tree_iter->data); - const gchar *os_family; - const gchar *os_variant; - const gchar *os_version; - const gchar *os_arch; + const gchar *os_treeinfo_family; + const gchar *os_treeinfo_variant; + const gchar *os_treeinfo_version; + const gchar *os_treeinfo_arch; if (!osinfo_tree_has_treeinfo(os_tree)) continue; - os_family = osinfo_tree_get_treeinfo_family(os_tree); - os_variant = osinfo_tree_get_treeinfo_variant(os_tree); - os_version = osinfo_tree_get_treeinfo_version(os_tree); - os_arch = osinfo_tree_get_treeinfo_arch(os_tree); + os_treeinfo_family = osinfo_tree_get_treeinfo_family(os_tree); + os_treeinfo_variant = osinfo_tree_get_treeinfo_variant(os_tree); + os_treeinfo_version = osinfo_tree_get_treeinfo_version(os_tree); + os_treeinfo_arch = osinfo_tree_get_treeinfo_arch(os_tree); - if (match_regex(os_family, treeinfo_family) && - match_regex(os_variant, treeinfo_variant) && - match_regex(os_version, treeinfo_version) && - match_regex(os_arch, treeinfo_arch)) { + if (match_regex(os_treeinfo_family, treeinfo_family) && + match_regex(os_treeinfo_variant, treeinfo_variant) && + match_regex(os_treeinfo_version, treeinfo_version) && + match_regex(os_treeinfo_arch, treeinfo_arch)) { ret = os; if (matched_tree != NULL) *matched_tree = os_tree; -- 2.20.1 From fidencio at redhat.com Tue Apr 2 10:18:48 2019 From: fidencio at redhat.com (=?UTF-8?q?Fabiano=20Fid=C3=AAncio?=) Date: Tue, 2 Apr 2019 12:18:48 +0200 Subject: [Libosinfo] [libosinfo PATCH v3 3/6] db: Deal with "all" tree architectures In-Reply-To: <20190402101851.2007-1-fidencio@redhat.com> References: <20190402101851.2007-1-fidencio@redhat.com> Message-ID: <20190402101851.2007-4-fidencio@redhat.com> Tree with "all" architecture are used as a fallback when guessing an OS from a tree. Knowing that, any entry with "all" architecture should not be considered when first comparing the trees, thus those are skipped and, later on, if no match has been found, those are used. https://gitlab.com/libosinfo/libosinfo/issues/20 Signed-off-by: Fabiano Fid?ncio --- osinfo/osinfo_db.c | 80 ++++++++++++++++++++++++++++++---------------- 1 file changed, 52 insertions(+), 28 deletions(-) diff --git a/osinfo/osinfo_db.c b/osinfo/osinfo_db.c index 136cf79..0c89aef 100644 --- a/osinfo/osinfo_db.c +++ b/osinfo/osinfo_db.c @@ -742,49 +742,32 @@ gboolean osinfo_db_identify_media(OsinfoDb *db, OsinfoMedia *media) return TRUE; } - -/** - * osinfo_db_guess_os_from_tree: - * @db: the database - * @tree: the installation tree - * @matched_tree: (out) (transfer none) (allow-none): the matched operating - * system tree - * - * Guess operating system given an #OsinfoTree object. - * - * Returns: (transfer none): the operating system, or NULL if guessing failed - */ -OsinfoOs *osinfo_db_guess_os_from_tree(OsinfoDb *db, - OsinfoTree *tree, - OsinfoTree **matched_tree) +static gboolean compare_tree(OsinfoTree *tree, + GList *oss, + OsinfoOs **ret_os, + OsinfoTree **matched, + GList **fallback_oss) { - OsinfoOs *ret = NULL; - GList *oss = NULL; GList *os_iter; const gchar *treeinfo_family; const gchar *treeinfo_variant; const gchar *treeinfo_version; const gchar *treeinfo_arch; - g_return_val_if_fail(OSINFO_IS_DB(db), NULL); - g_return_val_if_fail(tree != NULL, NULL); - treeinfo_family = osinfo_tree_get_treeinfo_family(tree); treeinfo_variant = osinfo_tree_get_treeinfo_variant(tree); treeinfo_version = osinfo_tree_get_treeinfo_version(tree); treeinfo_arch = osinfo_tree_get_treeinfo_arch(tree); - oss = osinfo_list_get_elements(OSINFO_LIST(db->priv->oses)); for (os_iter = oss; os_iter; os_iter = os_iter->next) { OsinfoOs *os = OSINFO_OS(os_iter->data); OsinfoTreeList *tree_list = osinfo_os_get_tree_list(os); GList *trees = osinfo_list_get_elements(OSINFO_LIST(tree_list)); GList *tree_iter; - //trees = g_list_sort(trees, tree_family_compare); - for (tree_iter = trees; tree_iter; tree_iter = tree_iter->next) { OsinfoTree *os_tree = OSINFO_TREE(tree_iter->data); + const gchar *os_tree_arch = NULL; const gchar *os_treeinfo_family; const gchar *os_treeinfo_variant; const gchar *os_treeinfo_version; @@ -793,6 +776,14 @@ OsinfoOs *osinfo_db_guess_os_from_tree(OsinfoDb *db, if (!osinfo_tree_has_treeinfo(os_tree)) continue; + os_tree_arch = osinfo_tree_get_architecture(os_tree); + if (fallback_oss != NULL) { + if (g_str_equal(os_tree_arch, "all")) { + *fallback_oss = g_list_prepend(*fallback_oss, os); + continue; + } + } + os_treeinfo_family = osinfo_tree_get_treeinfo_family(os_tree); os_treeinfo_variant = osinfo_tree_get_treeinfo_variant(os_tree); os_treeinfo_version = osinfo_tree_get_treeinfo_version(os_tree); @@ -802,9 +793,9 @@ OsinfoOs *osinfo_db_guess_os_from_tree(OsinfoDb *db, match_regex(os_treeinfo_variant, treeinfo_variant) && match_regex(os_treeinfo_version, treeinfo_version) && match_regex(os_treeinfo_arch, treeinfo_arch)) { - ret = os; - if (matched_tree != NULL) - *matched_tree = os_tree; + *ret_os = os; + if (matched != NULL) + *matched = os_tree; break; } } @@ -812,11 +803,44 @@ OsinfoOs *osinfo_db_guess_os_from_tree(OsinfoDb *db, g_list_free(trees); g_object_unref(tree_list); - if (ret) - break; + if (*ret_os != NULL) + return TRUE; } + return FALSE; +} + +/** + * osinfo_db_guess_os_from_tree: + * @db: the database + * @tree: the installation tree + * @matched_tree: (out) (transfer none) (allow-none): the matched operating + * system tree + * + * Guess operating system given an #OsinfoTree object. + * + * Returns: (transfer none): the operating system, or NULL if guessing failed + */ +OsinfoOs *osinfo_db_guess_os_from_tree(OsinfoDb *db, + OsinfoTree *tree, + OsinfoTree **matched_tree) +{ + OsinfoOs *ret = NULL; + GList *oss = NULL; + GList *fallback_oss = NULL; + + g_return_val_if_fail(OSINFO_IS_DB(db), NULL); + g_return_val_if_fail(tree != NULL, NULL); + + oss = osinfo_list_get_elements(OSINFO_LIST(db->priv->oses)); + if (compare_tree(tree, oss, &ret, matched_tree, &fallback_oss)) + goto end; + + compare_tree(tree, fallback_oss, &ret, matched_tree, NULL); + + end: g_list_free(oss); + g_list_free(fallback_oss); return ret; } -- 2.20.1 From fidencio at redhat.com Tue Apr 2 10:18:49 2019 From: fidencio at redhat.com (=?UTF-8?q?Fabiano=20Fid=C3=AAncio?=) Date: Tue, 2 Apr 2019 12:18:49 +0200 Subject: [Libosinfo] [libosinfo PATCH v3 4/6] test-db: Add test for guessing tree from OS In-Reply-To: <20190402101851.2007-1-fidencio@redhat.com> References: <20190402101851.2007-1-fidencio@redhat.com> Message-ID: <20190402101851.2007-5-fidencio@redhat.com> Signed-off-by: Fabiano Fid?ncio --- .../dbdata/os/libosinfo.org/test-db-tree.xml | 26 +++++++++ tests/test-db.c | 58 +++++++++++++++++++ 2 files changed, 84 insertions(+) create mode 100644 tests/dbdata/os/libosinfo.org/test-db-tree.xml diff --git a/tests/dbdata/os/libosinfo.org/test-db-tree.xml b/tests/dbdata/os/libosinfo.org/test-db-tree.xml new file mode 100644 index 0000000..52fb4cf --- /dev/null +++ b/tests/dbdata/os/libosinfo.org/test-db-tree.xml @@ -0,0 +1,26 @@ + + + + db-tree + DB Tree + unknown + libosinfo.org + test + + + + Tree + unknown + + + + + + Tree + unknown + i686 + + + + + diff --git a/tests/test-db.c b/tests/test-db.c index a0fa490..d1efc6c 100644 --- a/tests/test-db.c +++ b/tests/test-db.c @@ -450,6 +450,62 @@ test_identify_media(void) } +static OsinfoTree * +create_tree(const gchar *arch, gboolean set_treeinfo_arch) +{ + OsinfoTree *tree; + + tree = osinfo_tree_new("foo", arch); + osinfo_entity_set_param(OSINFO_ENTITY(tree), + OSINFO_TREE_PROP_TREEINFO_FAMILY, + "Tree"); + osinfo_entity_set_param(OSINFO_ENTITY(tree), + OSINFO_TREE_PROP_TREEINFO_VERSION, + "unknown"); + if (set_treeinfo_arch) + osinfo_entity_set_param(OSINFO_ENTITY(tree), + OSINFO_TREE_PROP_TREEINFO_ARCH, + arch); + + return tree; +} + + +static void +test_guess_os_from_tree(void) +{ + OsinfoLoader *loader = osinfo_loader_new(); + OsinfoDb *db; + OsinfoTree *tree; + OsinfoTree *matched_tree = NULL; + OsinfoOs *os; + + GError *error = NULL; + + osinfo_loader_process_path(loader, SRCDIR "/tests/dbdata", &error); + g_assert_no_error(error); + db = osinfo_loader_get_db(loader); + + /* Matching against an "all" architecture" */ + tree = create_tree("x86_64", FALSE); + os = osinfo_db_guess_os_from_tree(db, tree, &matched_tree); + g_assert_nonnull(os); + g_assert_nonnull(matched_tree); + g_assert_cmpstr(osinfo_tree_get_architecture(matched_tree), ==, "all"); + g_object_unref(tree); + matched_tree = NULL; + + /* Matching against a known architecture, which has to have precendence */ + tree = create_tree("i686", TRUE); + os = osinfo_db_guess_os_from_tree(db, tree, &matched_tree); + g_assert_nonnull(os); + g_assert_nonnull(matched_tree); + g_assert_cmpstr(osinfo_tree_get_architecture(matched_tree), ==, "i686"); + + g_object_unref(tree); + g_object_unref(loader); +} + int main(int argc, char *argv[]) @@ -465,6 +521,7 @@ main(int argc, char *argv[]) g_test_add_func("/db/prop_os", test_prop_os); g_test_add_func("/db/rel_os", test_rel_os); g_test_add_func("/db/identify_media", test_identify_media); + g_test_add_func("/db/guess_os_from_tree", test_guess_os_from_tree); /* Upfront so we don't confuse valgrind */ osinfo_entity_get_type(); @@ -480,6 +537,7 @@ main(int argc, char *argv[]) osinfo_loader_get_type(); osinfo_install_script_get_type(); osinfo_install_scriptlist_get_type(); + osinfo_tree_get_type(); return g_test_run(); } -- 2.20.1 From fidencio at redhat.com Tue Apr 2 10:18:50 2019 From: fidencio at redhat.com (=?UTF-8?q?Fabiano=20Fid=C3=AAncio?=) Date: Tue, 2 Apr 2019 12:18:50 +0200 Subject: [Libosinfo] [libosinfo PATCH v3 5/6] db: Deal with "all" media architecture In-Reply-To: <20190402101851.2007-1-fidencio@redhat.com> References: <20190402101851.2007-1-fidencio@redhat.com> Message-ID: <20190402101851.2007-6-fidencio@redhat.com> Medias with "all" architecture are used as a fallback when guessing an OS from a media. Knowing that, any entry with "all" architecture should not be considered when first comparing the medias, thus those are skipped and, later on, if no match has been found, those are used. https://gitlab.com/libosinfo/libosinfo/issues/20 Signed-off-by: Fabiano Fid?ncio --- osinfo/osinfo_db.c | 56 +++++++++++++++++++++++++++++++++------------- 1 file changed, 41 insertions(+), 15 deletions(-) diff --git a/osinfo/osinfo_db.c b/osinfo/osinfo_db.c index 0c89aef..1089644 100644 --- a/osinfo/osinfo_db.c +++ b/osinfo/osinfo_db.c @@ -537,13 +537,12 @@ static gint media_volume_compare(gconstpointer a, gconstpointer b) return 1; } -static OsinfoOs * -osinfo_db_guess_os_from_media_internal(OsinfoDb *db, - OsinfoMedia *media, - OsinfoMedia **matched_media) +static gboolean compare_media(OsinfoMedia *media, + GList *oss, + OsinfoOs **ret_os, + OsinfoMedia **matched, + GList **fallback_oss) { - OsinfoOs *ret = NULL; - GList *oss = NULL; GList *os_iter; const gchar *media_volume; const gchar *media_system; @@ -551,16 +550,12 @@ osinfo_db_guess_os_from_media_internal(OsinfoDb *db, const gchar *media_application; gint64 media_vol_size; - g_return_val_if_fail(OSINFO_IS_DB(db), NULL); - g_return_val_if_fail(media != NULL, NULL); - media_volume = osinfo_media_get_volume_id(media); media_system = osinfo_media_get_system_id(media); media_publisher = osinfo_media_get_publisher_id(media); media_application = osinfo_media_get_application_id(media); media_vol_size = osinfo_media_get_volume_size(media); - oss = osinfo_list_get_elements(OSINFO_LIST(db->priv->oses)); for (os_iter = oss; os_iter; os_iter = os_iter->next) { OsinfoOs *os = OSINFO_OS(os_iter->data); OsinfoMediaList *media_list = osinfo_os_get_media_list(os); @@ -571,6 +566,7 @@ osinfo_db_guess_os_from_media_internal(OsinfoDb *db, for (media_iter = medias; media_iter; media_iter = media_iter->next) { OsinfoMedia *os_media = OSINFO_MEDIA(media_iter->data); + const gchar *os_arch = osinfo_media_get_architecture(os_media); const gchar *os_volume = osinfo_media_get_volume_id(os_media); const gchar *os_system = osinfo_media_get_system_id(os_media); const gchar *os_publisher = osinfo_media_get_publisher_id(os_media); @@ -584,6 +580,13 @@ osinfo_db_guess_os_from_media_internal(OsinfoDb *db, os_vol_size <= 0) continue; + if (fallback_oss != NULL) { + if (g_str_equal(os_arch, "all")) { + *fallback_oss = g_list_prepend(*fallback_oss, os); + continue; + } + } + if (os_vol_size <= 0) os_vol_size = media_vol_size; @@ -592,9 +595,9 @@ osinfo_db_guess_os_from_media_internal(OsinfoDb *db, match_regex(os_system, media_system) && match_regex(os_publisher, media_publisher) && os_vol_size == media_vol_size) { - ret = os; - if (matched_media != NULL) - *matched_media = os_media; + *ret_os = os; + if (matched != NULL) + *matched = os_media; break; } } @@ -602,11 +605,34 @@ osinfo_db_guess_os_from_media_internal(OsinfoDb *db, g_list_free(medias); g_object_unref(media_list); - if (ret) - break; + if (*ret_os) + return TRUE; } + return FALSE; +} + +static OsinfoOs * +osinfo_db_guess_os_from_media_internal(OsinfoDb *db, + OsinfoMedia *media, + OsinfoMedia **matched_media) +{ + OsinfoOs *ret = NULL; + GList *oss = NULL; + GList *fallback_oss = NULL; + + g_return_val_if_fail(OSINFO_IS_DB(db), NULL); + g_return_val_if_fail(media != NULL, NULL); + + oss = osinfo_list_get_elements(OSINFO_LIST(db->priv->oses)); + if (compare_media(media, oss, &ret, matched_media, &fallback_oss)) + goto end; + + compare_media(media, fallback_oss, &ret, matched_media, NULL); + + end: g_list_free(oss); + g_list_free(fallback_oss); return ret; } -- 2.20.1 From fidencio at redhat.com Tue Apr 2 10:18:51 2019 From: fidencio at redhat.com (=?UTF-8?q?Fabiano=20Fid=C3=AAncio?=) Date: Tue, 2 Apr 2019 12:18:51 +0200 Subject: [Libosinfo] [libosinfo PATCH v3 6/6] test-db: Add test to cover identifying a media with "unknown" arch In-Reply-To: <20190402101851.2007-1-fidencio@redhat.com> References: <20190402101851.2007-1-fidencio@redhat.com> Message-ID: <20190402101851.2007-7-fidencio@redhat.com> Signed-off-by: Fabiano Fid?ncio --- .../dbdata/os/libosinfo.org/test-db-media.xml | 13 +++++++++++ tests/test-db.c | 22 +++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/tests/dbdata/os/libosinfo.org/test-db-media.xml b/tests/dbdata/os/libosinfo.org/test-db-media.xml index 04badfd..6d532d9 100644 --- a/tests/dbdata/os/libosinfo.org/test-db-media.xml +++ b/tests/dbdata/os/libosinfo.org/test-db-media.xml @@ -25,6 +25,19 @@ + + + bootimg + LINUX + + + + + + bootimg + + +