Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/artipie/rpm-adapter
Browse files Browse the repository at this point in the history
  • Loading branch information
olenagerasimova committed Oct 21, 2021
2 parents e3531be + 14f852d commit 5c052d8
Show file tree
Hide file tree
Showing 7 changed files with 201 additions and 63 deletions.
2 changes: 1 addition & 1 deletion src/main/java/com/artipie/rpm/meta/XmlEvent.java
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ private static void addRequires(final XMLEventWriter writer, final HeaderTags ta
final XMLEventFactory events = XMLEventFactory.newFactory();
writer.add(events.createStartElement(Primary.PRFX, Primary.NS_URL, "requires"));
final List<String> names = tags.requires();
final List<HeaderTags.Version> versions = tags.providesVer();
final List<HeaderTags.Version> versions = tags.requiresVer();
for (int ind = 0; ind < names.size(); ind = ind + 1) {
if (!names.get(ind).startsWith("rpmlib(")) {
writer.add(events.createStartElement(Primary.PRFX, Primary.NS_URL, "entry"));
Expand Down
78 changes: 16 additions & 62 deletions src/test/java/com/artipie/rpm/meta/XmlEventPrimaryTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
import javax.xml.stream.XMLEventWriter;
import javax.xml.stream.XMLStreamException;
import org.hamcrest.MatcherAssert;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;
import org.xmlunit.matchers.CompareMatcher;

/**
Expand All @@ -26,9 +27,15 @@
@SuppressWarnings("PMD.AvoidDuplicateLiterals")
class XmlEventPrimaryTest {

@Test
void writesPackageInfo() throws XMLStreamException, IOException {
final Path file = new TestResource("abc-1.01-26.git20200127.fc32.ppc64le.rpm").asPath();
@ParameterizedTest
@CsvSource({
"abc-1.01-26.git20200127.fc32.ppc64le.rpm,abc_res.xml",
"libnss-mymachines2-245-1.x86_64.rpm,libnss_res.xml",
"openssh-server-7.4p1-16.h16.eulerosv2r7.x86_64.rpm,openssh_res.xml"
})
void writesPackageInfo(final String rpm, final String res) throws XMLStreamException,
IOException {
final Path file = new TestResource(rpm).asPath();
final ByteArrayOutputStream bout = new ByteArrayOutputStream();
final XMLEventWriter writer = new OutputFactoryImpl().createXMLEventWriter(bout);
final XMLEventFactory events = XMLEventFactory.newFactory();
Expand All @@ -45,68 +52,15 @@ void writesPackageInfo() throws XMLStreamException, IOException {
MatcherAssert.assertThat(
bout.toByteArray(),
CompareMatcher.isIdenticalTo(
String.join(
"\n",
//@checkstyle LineLengthCheck (80 lines)
"<?xml version='1.0' encoding='UTF-8'?>",
"<metadata xmlns=\"http://linux.duke.edu/metadata/common\" xmlns:rpm=\"http://linux.duke.edu/metadata/rpm\">",
"<package type=\"rpm\">",
" <name>abc</name>",
" <arch>ppc64le</arch>",
" <version epoch=\"0\" ver=\"1.01\" rel=\"26.git20200127.fc32\"/>",
" <checksum type=\"sha256\" pkgid=\"YES\">b9d10ae3485a5c5f71f0afb1eaf682bfbea4ea667cc3c3975057d6e3d8f2e905</checksum>",
" <summary>Sequential logic synthesis and formal verification</summary>",
" <description>ABC is a growing software system for synthesis and verification of",
" binary sequential logic circuits appearing in synchronous hardware",
" designs. ABC combines scalable logic optimization based on And-Inverter",
" Graphs (AIGs), optimal-delay DAG-based technology mapping for look-up",
" tables and standard cells, and innovative algorithms for sequential",
" synthesis and verification.",
"",
" ABC provides an experimental implementation of these algorithms and a",
" programming environment for building similar applications. Future",
" development will focus on improving the algorithms and making most of",
" the packages stand-alone. This will allow the user to customize ABC for",
" their needs as if it were a toolbox rather than a complete tool.</description>",
" <packager>Fedora Project</packager>",
" <url>http://www.eecs.berkeley.edu/~alanmi/abc/abc.htm</url>",
" <time file=\"1590055722\" build=\"1580489894\"/>",
" <size package=\"19285\" installed=\"80136\" archive=\"0\"/>",
" <location href=\"abc-1.01-26.git20200127.fc32.ppc64le.rpm\"/>",
" <format>",
" <rpm:license>MIT</rpm:license>",
" <rpm:vendor>Fedora Project</rpm:vendor>",
" <rpm:group>Unspecified</rpm:group>",
" <rpm:buildhost>buildvm-ppc64le-04.ppc.fedoraproject.org</rpm:buildhost>",
" <rpm:sourcerpm>abc-1.01-26.git20200127.fc32.src.rpm</rpm:sourcerpm>",
" <rpm:header-range start=\"4504\" end=\"10412\"/>",
" <rpm:provides>",
" <rpm:entry name=\"abc\" ver=\"1.01\" epoch=\"0\" rel=\"26.git20200127.fc32\"/>",
" <rpm:entry name=\"abc(ppc-64)\" ver=\"1.01\" epoch=\"0\" rel=\"26.git20200127.fc32\"/>",
" </rpm:provides>",
" <rpm:requires>",
" <rpm:entry name=\"abc-libs(ppc-64)\" ver=\"1.01\" epoch=\"0\" rel=\"26.git20200127.fc32\"/>",
" <rpm:entry name=\"libabc.so.0()(64bit)\" ver=\"1.01\" epoch=\"0\" rel=\"26.git20200127.fc32\"/>",
" <rpm:entry name=\"libc.so.6()(64bit)\"/>",
" <rpm:entry name=\"libc.so.6(GLIBC_2.17)(64bit)\"/>",
" <rpm:entry name=\"rtld(GNU_HASH)\"/>",
" </rpm:requires>",
" <file>/usr/bin/abc</file>",
" <file type=\"dir\">/usr/lib/.build-id/cb</file>",
" <file>/usr/lib/.build-id/cb/263ca8bdb2d581b1a12e604c0e30635e69c889</file>",
" <file type=\"dir\">/usr/share/doc/abc</file>",
" <file>/usr/share/doc/abc/README.md</file>",
" <file>/usr/share/doc/abc/readmeaig</file>",
" <file>/usr/share/man/man1/abc.1.gz</file>",
" </format>",
"</package>",
"</metadata>"
).getBytes()
new TestResource(String.format("XmlEventPrimaryTest/%s", res)).asBytes()
)
.ignoreWhitespace()
.ignoreElementContentWhitespace()
.normalizeWhitespace()
.withAttributeFilter(attr -> !"file".equals(attr.getName()))
.withNodeFilter(node -> !"file".equals(node.getLocalName()))
.withAttributeFilter(
attr -> !"flags".equals(attr.getName()) && !"pre".equals(attr.getName())
)
);
}

Expand Down
57 changes: 57 additions & 0 deletions src/test/resources-binary/XmlEventPrimaryTest/abc_res.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?xml version='1.0' encoding='UTF-8'?>
<metadata xmlns="http://linux.duke.edu/metadata/common"
xmlns:rpm="http://linux.duke.edu/metadata/rpm">
<package type="rpm">
<name>abc</name>
<arch>ppc64le</arch>
<version epoch="0" rel="26.git20200127.fc32" ver="1.01"/>
<checksum type="sha256" pkgid="YES">
b9d10ae3485a5c5f71f0afb1eaf682bfbea4ea667cc3c3975057d6e3d8f2e905
</checksum>
<summary>Sequential logic synthesis and formal verification</summary>
<description>ABC is a growing software system for synthesis and verification of
binary sequential logic circuits appearing in synchronous hardware
designs. ABC combines scalable logic optimization based on And-Inverter
Graphs (AIGs), optimal-delay DAG-based technology mapping for look-up
tables and standard cells, and innovative algorithms for sequential
synthesis and verification.

ABC provides an experimental implementation of these algorithms and a
programming environment for building similar applications. Future
development will focus on improving the algorithms and making most of
the packages stand-alone. This will allow the user to customize ABC for
their needs as if it were a toolbox rather than a complete tool.
</description>
<packager>Fedora Project</packager>
<url>http://www.eecs.berkeley.edu/~alanmi/abc/abc.htm</url>
<time build="1580489894" file="1580490025"/>
<size installed="80136" archive="0" package="19285"/>
<location href="abc-1.01-26.git20200127.fc32.ppc64le.rpm"/>
<format>
<rpm:license>MIT</rpm:license>
<rpm:vendor>Fedora Project</rpm:vendor>
<rpm:group>Unspecified</rpm:group>
<rpm:buildhost>buildvm-ppc64le-04.ppc.fedoraproject.org</rpm:buildhost>
<rpm:sourcerpm>abc-1.01-26.git20200127.fc32.src.rpm</rpm:sourcerpm>
<rpm:header-range start="4504" end="10412"/>
<rpm:provides>
<rpm:entry name="abc" ver="1.01" epoch="0" rel="26.git20200127.fc32"/>
<rpm:entry name="abc(ppc-64)" ver="1.01" epoch="0" rel="26.git20200127.fc32"/>
</rpm:provides>
<rpm:requires>
<rpm:entry name="abc-libs(ppc-64)" ver="1.01" epoch="0" rel="26.git20200127.fc32"/>
<rpm:entry name="libabc.so.0()(64bit)"/>
<rpm:entry name="libc.so.6()(64bit)"/>
<rpm:entry name="libc.so.6(GLIBC_2.17)(64bit)"/>
<rpm:entry name="rtld(GNU_HASH)"/>
</rpm:requires>
<file>/usr/bin/abc</file>
<file type="dir">/usr/lib/.build-id/cb</file>
<file>/usr/lib/.build-id/cb/263ca8bdb2d581b1a12e604c0e30635e69c889</file>
<file type="dir">/usr/share/doc/abc</file>
<file>/usr/share/doc/abc/README.md</file>
<file>/usr/share/doc/abc/readmeaig</file>
<file>/usr/share/man/man1/abc.1.gz</file>
</format>
</package>
</metadata>
38 changes: 38 additions & 0 deletions src/test/resources-binary/XmlEventPrimaryTest/libnss_res.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<metadata xmlns="http://linux.duke.edu/metadata/common" xmlns:rpm="http://linux.duke.edu/metadata/rpm">
<package type="rpm">
<name>libnss-mymachines2</name>
<arch>x86_64</arch>
<version epoch="1" ver="245" rel="1"/>
<checksum type="sha256" pkgid="YES">bbb880fcc332c846a4504a31fcda07c3f00c1a6ef2aca5bb90cb8725c905cbfa</checksum>
<summary>Systemd nss-mymachines library</summary>
<description>Systemd nss-mymachines library</description>
<packager></packager>
<url>http://www.freedesktop.org/wiki/Software/systemd</url>
<time file="1624995132" build="1624995133"/>
<size package="833818" installed="3627488" archive="0"/>
<location href="libnss-mymachines2-245-1.x86_64.rpm"/>
<format>
<rpm:license>GPLv2 &amp; LGPLv2.1</rpm:license>
<rpm:vendor/>
<rpm:group>base/shell</rpm:group>
<rpm:buildhost>bluewhale-slave-jxqvaull-5dcd6d59bf-btddj</rpm:buildhost>
<rpm:sourcerpm>systemd-245-1.src.rpm</rpm:sourcerpm>
<rpm:header-range start="280" end="2138"/>
<rpm:provides>
<rpm:entry name="libnss-mymachines" flags="EQ" epoch="0" ver="245"/>
<rpm:entry name="libnss-mymachines2" flags="EQ" epoch="1" ver="245" rel="1"/>
<rpm:entry name="libnss-mymachines2(x86-64)" flags="EQ" epoch="1" ver="245" rel="1"/>
</rpm:provides>
<rpm:requires>
<rpm:entry name="libc6" flags="GE" epoch="0" ver="2.31"/>
<rpm:entry name="libcap2" flags="GE" epoch="0" ver="2.32"/>
<rpm:entry name="libselinux1" flags="GE" epoch="0" ver="3.0" pre="1"/>
<rpm:entry name="libc6" flags="GE" epoch="0" ver="2.31" pre="1"/>
<rpm:entry name="libcap2" flags="GE" epoch="0" ver="2.32" pre="1"/>
<rpm:entry name="libselinux1" flags="GE" epoch="0" ver="3.0"/>
<rpm:entry name="/bin/sh" pre="1"/>
</rpm:requires>
</format>
</package>
</metadata>
89 changes: 89 additions & 0 deletions src/test/resources-binary/XmlEventPrimaryTest/openssh_res.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
<?xml version="1.0" encoding="UTF-8"?>
<metadata xmlns="http://linux.duke.edu/metadata/common" xmlns:rpm="http://linux.duke.edu/metadata/rpm">
<package type="rpm">
<name>openssh-server</name>
<arch>x86_64</arch>
<version epoch="0" ver="7.4p1" rel="16.h16.eulerosv2r7"/>
<checksum type="sha256" pkgid="YES">cf650356947fc0c0819b65249e4cc107eb47768ebea552bb720b42948cf433c0</checksum>
<summary>An open source SSH server daemon</summary>
<description>OpenSSH is a free version of SSH (Secure SHell), a program for logging
into and executing commands on a remote machine. This package contains
the secure shell daemon (sshd). The sshd daemon allows SSH clients to
securely connect to your SSH server.</description>
<packager>http://developer.huawei.com/ict/site-euleros</packager>
<url>http://www.openssh.com/portable.html</url>
<time file="1583906400" build="1583906400"/>
<size package="472076" installed="993908" archive="0"/>
<location href="openssh-server-7.4p1-16.h16.eulerosv2r7.x86_64.rpm"/>
<format>
<rpm:license>BSD</rpm:license>
<rpm:vendor>HUAWEI TECHNOLOGIES CO.,LTD</rpm:vendor>
<rpm:group>System Environment/Daemons</rpm:group>
<rpm:buildhost>szxrtosci10000</rpm:buildhost>
<rpm:sourcerpm>openssh-7.4p1-16.h16.eulerosv2r7.src.rpm</rpm:sourcerpm>
<rpm:header-range start="1392" end="79104"/>
<rpm:provides>
<rpm:entry name="config(openssh-server)" flags="EQ" epoch="0" ver="7.4p1" rel="16.h16.eulerosv2r7"/>
<rpm:entry name="openssh-server" flags="EQ" epoch="0" ver="7.4p1" rel="16.h16.eulerosv2r7"/>
<rpm:entry name="openssh-server(x86-64)" flags="EQ" epoch="0" ver="7.4p1" rel="16.h16.eulerosv2r7"/>
</rpm:provides>
<rpm:requires>
<rpm:entry name="/bin/bash"/>
<rpm:entry name="/bin/sh"/>
<rpm:entry name="/bin/sh"/>
<rpm:entry name="/bin/sh"/>
<rpm:entry name="/bin/sh"/>
<rpm:entry name="/usr/sbin/useradd" pre="1"/>
<rpm:entry name="config(openssh-server)" ver="7.4p1" epoch="0" rel="16.h16.eulerosv2r7"/>
<rpm:entry name="fipscheck-lib(x86-64)" flags="GE" ver="1.3.0" epoch="0"/>
<rpm:entry name="libaudit.so.1()(64bit)"/>
<rpm:entry name="libc.so.6()(64bit)"/>
<rpm:entry name="libc.so.6(GLIBC_2.14)(64bit)"/>
<rpm:entry name="libc.so.6(GLIBC_2.16)(64bit)"/>
<rpm:entry name="libc.so.6(GLIBC_2.17)(64bit)"/>
<rpm:entry name="libc.so.6(GLIBC_2.2.5)(64bit)"/>
<rpm:entry name="libc.so.6(GLIBC_2.3)(64bit)"/>
<rpm:entry name="libc.so.6(GLIBC_2.3.4)(64bit)"/>
<rpm:entry name="libc.so.6(GLIBC_2.4)(64bit)"/>
<rpm:entry name="libc.so.6(GLIBC_2.8)(64bit)"/>
<rpm:entry name="libcom_err.so.2()(64bit)"/>
<rpm:entry name="libcrypt.so.1()(64bit)"/>
<rpm:entry name="libcrypt.so.1(GLIBC_2.2.5)(64bit)"/>
<rpm:entry name="libcrypto.so.10()(64bit)"/>
<rpm:entry name="libcrypto.so.10(OPENSSL_1.0.1_EC)(64bit)"/>
<rpm:entry name="libcrypto.so.10(OPENSSL_1.0.2)(64bit)"/>
<rpm:entry name="libcrypto.so.10(libcrypto.so.10)(64bit)"/>
<rpm:entry name="libdl.so.2()(64bit)"/>
<rpm:entry name="libfipscheck.so.1()(64bit)"/>
<rpm:entry name="libgssapi_krb5.so.2()(64bit)"/>
<rpm:entry name="libgssapi_krb5.so.2(gssapi_krb5_2_MIT)(64bit)"/>
<rpm:entry name="libk5crypto.so.3()(64bit)"/>
<rpm:entry name="libkrb5.so.3()(64bit)"/>
<rpm:entry name="libkrb5.so.3(krb5_3_MIT)(64bit)"/>
<rpm:entry name="liblber-2.4.so.2()(64bit)"/>
<rpm:entry name="libldap-2.4.so.2()(64bit)"/>
<rpm:entry name="libpam.so.0()(64bit)"/>
<rpm:entry name="libpam.so.0(LIBPAM_1.0)(64bit)"/>
<rpm:entry name="libresolv.so.2()(64bit)"/>
<rpm:entry name="libselinux.so.1()(64bit)"/>
<rpm:entry name="libsystemd.so.0()(64bit)"/>
<rpm:entry name="libsystemd.so.0(LIBSYSTEMD_209)(64bit)"/>
<rpm:entry name="libutil.so.1()(64bit)"/>
<rpm:entry name="libutil.so.1(GLIBC_2.2.5)(64bit)"/>
<rpm:entry name="libwrap.so.0()(64bit)"/>
<rpm:entry name="libz.so.1()(64bit)"/>
<rpm:entry name="openssh" flags="EQ" ver="7.4p1" epoch="0" rel="16.h16.eulerosv2r7"/>
<rpm:entry name="pam" flags="GE" ver="1.0.1" epoch="0" rel="3"/>
<rpm:entry name="rtld(GNU_HASH)"/>
<rpm:entry name="systemd-units" pre="1"/>
<rpm:entry name="systemd-units"/>
<rpm:entry name="systemd-units"/>
</rpm:requires>
<file>/etc/pam.d/sshd</file>
<file>/etc/ssh/sshd_config</file>
<file>/etc/sysconfig/sshd</file>
<file>/usr/sbin/sshd</file>
<file>/usr/sbin/sshd-keygen</file>
</format>
</package>
</metadata>
Binary file not shown.
Binary file not shown.

0 comments on commit 5c052d8

Please sign in to comment.