-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
203 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
FROM centos | ||
MAINTAINER Yegor Bugayenko <[email protected]> | ||
LABEL Description="Yum utils" Vendor="Yegor Bugayenko" Version="1.0" | ||
|
||
RUN yum install -y yum-utils | ||
RUN yum install -y createrepo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,7 @@ | ||
Turns your files into an NPM repository. | ||
|
||
Similar solutions: | ||
|
||
* [Artifactory](https://www.jfrog.com/confluence/display/RTF/RPM+Repositories) | ||
* [Pulp](https://pulp-rpm.readthedocs.io/en/latest/) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/** | ||
* The MIT License (MIT) | ||
* | ||
* Copyright (c) 2019 Yegor Bugayenko | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included | ||
* in all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
*/ | ||
package com.yegor256.rpm; | ||
|
||
import java.io.IOException; | ||
import java.nio.file.Path; | ||
|
||
/** | ||
* The RPM front. | ||
* | ||
* @author Yegor Bugayenko ([email protected]) | ||
* @version $Id$ | ||
* @since 0.1 | ||
*/ | ||
public final class Rpm { | ||
|
||
/** | ||
* The storage. | ||
*/ | ||
private final Storage storage; | ||
|
||
/** | ||
* Ctor. | ||
* @param stg The storage | ||
*/ | ||
public Rpm(final Storage stg) { | ||
this.storage = stg; | ||
} | ||
|
||
/** | ||
* Publish a single DEB artifact. | ||
* | ||
* @param path The file | ||
* @throws IOException If fails | ||
*/ | ||
public void publish(final Path path) throws IOException { | ||
this.storage.save("x.rpm", path); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
/** | ||
* The MIT License (MIT) | ||
* | ||
* Copyright (c) 2019 Yegor Bugayenko | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included | ||
* in all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
*/ | ||
package com.yegor256.rpm; | ||
|
||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.nio.file.StandardCopyOption; | ||
import org.hamcrest.MatcherAssert; | ||
import org.hamcrest.Matchers; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.junit.rules.TemporaryFolder; | ||
|
||
/** | ||
* Integration case for {@link Rpm}. | ||
* | ||
* @author Yegor Bugayenko ([email protected]) | ||
* @version $Id$ | ||
* @since 0.1 | ||
*/ | ||
public final class RpmITCase { | ||
|
||
/** | ||
* Temp folder for all tests. | ||
*/ | ||
@Rule | ||
@SuppressWarnings("PMD.BeanMembersShouldSerialize") | ||
public TemporaryFolder folder = new TemporaryFolder(); | ||
|
||
/** | ||
* RPM works. | ||
* @throws Exception If some problem inside | ||
*/ | ||
@Test | ||
public void savesAndLoads() throws Exception { | ||
final Path repo = this.folder.newFolder("repo").toPath(); | ||
final Rpm rpm = new Rpm(new Storage.Simple(repo)); | ||
final Path bin = this.folder.newFile("x.rpm").toPath(); | ||
Files.copy( | ||
RpmITCase.class.getResourceAsStream( | ||
"/nginx-module-xslt-1.16.1-1.el7.ngx.x86_64.rpm" | ||
), | ||
bin, | ||
StandardCopyOption.REPLACE_EXISTING | ||
); | ||
rpm.publish(bin); | ||
final Path stdout = this.folder.newFile("stdout.txt").toPath(); | ||
new ProcessBuilder() | ||
.command( | ||
"docker", | ||
"run", | ||
"--rm", | ||
"--volume", | ||
String.format("%s:/repo", repo), | ||
"af27e27cbf9d", | ||
"/bin/bash", | ||
"-c", | ||
String.join( | ||
";", | ||
"createrepo /repo", | ||
"yum-config-manager --add-repo file:///repo", | ||
"yum --disablerepo='*' --enablerepo='repo' list available" | ||
) | ||
) | ||
.redirectOutput(stdout.toFile()) | ||
.redirectError(stdout.toFile()) | ||
.start() | ||
.waitFor(); | ||
MatcherAssert.assertThat( | ||
new String(Files.readAllBytes(stdout)), | ||
Matchers.allOf( | ||
Matchers.containsString("nginx-module-xslt.x86_64"), | ||
Matchers.containsString("1:1.16.1-1.el7.ngx") | ||
) | ||
); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+19.2 KB
src/test/resources-binary/nginx-module-xslt-1.16.1-1.el7.ngx.x86_64.rpm
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
log4j.rootLogger=WARN, CONSOLE | ||
|
||
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender | ||
log4j.appender.CONSOLE.layout=com.jcabi.log.MulticolorLayout | ||
log4j.appender.CONSOLE.layout.ConversionPattern=[%color{%p}] %t %c: %m%n | ||
|
||
log4j.logger.com.yegor256.rpm=DEBUG |