From b6ecde250f6d857a2346034abf64778cb1521004 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=CC=88rg=20Prante?= Date: Wed, 3 Jun 2020 16:50:54 +0200 Subject: [PATCH] update to Java named module, Gradle 6.4.1, rewrite of gradle plugin, many API simplifications, more tests --- build.gradle | 108 +- config/checkstyle/checkstyle.xml | 323 ---- gradle-plugin-rpm/NOTICE.txt | 5 - gradle-plugin-rpm/build.gradle | 46 +- .../config/checkstyle/checkstyle.xml | 323 ---- .../groovy/org/xbib/gradle/plugin/Rpm.groovy | 51 + .../xbib/gradle/plugin/RpmCopyAction.groovy | 212 +++ .../xbib/gradle/plugin/RpmExtension.groovy | 409 +++++ .../org/xbib/gradle/plugin/RpmPlugin.groovy | 43 + .../plugin/rpm/CopySpecEnhancement.groovy | 77 - .../xbib/gradle/plugin/rpm/Dependency.groovy | 55 - .../xbib/gradle/plugin/rpm/Directory.groovy | 14 - .../rpm/FromConfigurationFactory.groovy | 21 - .../org/xbib/gradle/plugin/rpm/Link.groovy | 13 - .../rpm/ProjectPackagingExtension.groovy | 257 ---- .../org/xbib/gradle/plugin/rpm/Rpm.groovy | 448 ------ .../gradle/plugin/rpm/RpmCopyAction.groovy | 318 ---- .../plugin/rpm/RpmFileVisitorStrategy.groovy | 63 - .../xbib/gradle/plugin/rpm/RpmPlugin.groovy | 65 - .../rpm/SystemPackagingExtension.groovy | 494 ------- .../RpmPackageNameAttributeValidator.groovy | 18 - .../RpmTaskPropertiesValidator.groovy | 16 - .../SystemPackagingAttributeValidator.groovy | 8 - ...temPackagingTaskPropertiesValidator.groovy | 8 - .../org.xbib.gradle.plugin.rpm.properties | 1 - .../org/xbib/gradle/plugin/RpmFullTest.groovy | 336 +++++ .../plugin/RpmPluginIntegrationTest.groovy | 57 + .../xbib/gradle/plugin/RpmScriptTest.groovy | 156 ++ .../org/xbib/gradle/plugin/RpmSignTest.groovy | 62 + .../xbib/gradle/plugin/RpmSimpleTest.groovy | 104 ++ .../plugin/rpm/CopySpecEnhancementTest.groovy | 107 -- .../plugin/rpm/RpmCopySpecVisitorTest.groovy | 51 - .../rpm/RpmPluginIntegrationTest.groovy | 28 - .../gradle/plugin/rpm/RpmPluginTest.groovy | 1316 ----------------- .../xbib/gradle/plugin/rpm/RpmReader.groovy | 131 -- .../rpm/SystemPackagingExtensionTest.groovy | 75 - ...pmPackageNameAttributeValidatorTest.groovy | 35 - ...kPropertiesValidatorIntegrationTest.groovy | 41 - .../plugin/test/AbstractProjectSpec.groovy | 52 - .../plugin/test/BaseIntegrationSpec.groovy | 192 --- .../BuildLauncherBackedGradleHandle.groovy | 96 -- .../ClasspathAddingInitScriptBuilder.groovy | 58 - ...asspathInjectingGradleHandleFactory.groovy | 35 - .../xbib/gradle/plugin/test/Coordinate.groovy | 18 - .../plugin/test/DefaultExecutionResult.groovy | 90 -- .../plugin/test/DefaultGradleRunner.groovy | 25 - .../gradle/plugin/test/DependencyGraph.groovy | 37 - .../plugin/test/DependencyGraphNode.groovy | 16 - .../gradle/plugin/test/ExecutedTask.groovy | 10 - .../gradle/plugin/test/ExecutionResult.groovy | 20 - .../test/GradleDependencyGenerator.groovy | 104 -- .../gradle/plugin/test/GradleHandle.groovy | 10 - .../test/GradleHandleBuildListener.groovy | 8 - .../plugin/test/GradleHandleFactory.groovy | 8 - .../gradle/plugin/test/GradleRunner.groovy | 78 - .../plugin/test/GradleRunnerFactory.groovy | 26 - .../gradle/plugin/test/IntegrationSpec.groovy | 185 --- .../plugin/test/MinimalExecutedTask.groovy | 22 - .../plugin/test/MultiProjectHelper.groovy | 43 - .../plugin/test/MultiProjectInfo.groovy | 14 - .../plugin/test/PreExecutionAction.groovy | 6 - .../gradle/plugin/test/ProjectSpec.groovy | 8 - .../test/ToolingApiGradleHandleFactory.groovy | 113 -- .../plugin/test/ToolingExecutionResult.groovy | 12 - .../test/resources/BaseIntegrationSpec.groovy | 119 -- .../org/xbib/gradle/plugin/changelog | 24 + .../org/xbib/gradle/plugin/preinstall.sh | 2 + .../test/resources/{pgp => }/test-secring.gpg | Bin gradle.properties | 32 +- gradle/compile/java.gradle | 35 + gradle/documentation/asciidoc.gradle | 55 + gradle/ext.gradle | 0 gradle/ide/idea.gradle | 13 + gradle/publish.gradle | 85 -- gradle/publishing/publication.gradle | 64 + gradle/publishing/sonatype.gradle | 11 + gradle/test/junit5.gradle | 28 + gradle/wrapper/gradle-wrapper.jar | Bin 55190 -> 58910 bytes gradle/wrapper/gradle-wrapper.properties | 3 +- gradlew | 53 +- gradlew.bat | 22 +- maven-plugin-rpm/build.gradle | 36 +- .../config/checkstyle/checkstyle.xml | 323 ---- .../config}/maven/repo-settings.xml | 2 +- .../org/xbib/maven/plugin/rpm/RpmPackage.java | 6 +- .../xbib/maven/plugin/rpm/RpmPackageRule.java | 4 +- .../maven/plugin/rpm/RpmBaseObjectTest.java | 5 +- .../xbib/maven/plugin/rpm/RpmLinkTest.java | 4 +- .../plugin/rpm/RpmPackageAssociationTest.java | 50 +- .../rpm/RpmPackageRuleDirectiveTest.java | 7 +- .../maven/plugin/rpm/RpmPackageRuleTest.java | 27 +- .../xbib/maven/plugin/rpm/RpmPackageTest.java | 131 +- .../rpm/RpmScriptTemplateRendererTest.java | 12 +- .../xbib/maven/plugin/rpm/RpmTriggerTest.java | 8 +- .../plugin/rpm/mojo/AbstractRpmMojoTest.java | 17 +- .../plugin/rpm/mojo/ListFilesRpmMojoTest.java | 6 +- .../plugin/rpm/mojo/PackageRpmMojoTest.java | 41 +- rpm-ant/build.gradle | 4 +- rpm-ant/config/checkstyle/checkstyle.xml | 323 ---- .../main/java/org/xbib/rpm/ant/RpmTask.java | 39 +- .../java/org/xbib/rpm/ant/RpmTaskTest.java | 136 +- rpm-core/NOTICE.txt | 2 +- rpm-core/build.gradle | 12 +- rpm-core/config/checkstyle/checkstyle.xml | 323 ---- rpm-core/src/main/java/module-info.java | 18 + .../main/java/org/xbib/rpm/Dependency.java | 39 + .../src/main/java/org/xbib/rpm/Directory.java | 64 + rpm-core/src/main/java/org/xbib/rpm/Link.java | 37 + .../main/java/org/xbib/rpm/RpmBuilder.java | 896 ++++------- .../src/main/java/org/xbib/rpm/RpmReader.java | 67 +- .../main/java/org/xbib/rpm/RpmReaderFile.java | 32 + .../java/org/xbib/rpm/RpmReaderResult.java | 11 + .../xbib/rpm/changelog/ChangelogHandler.java | 44 +- .../xbib/rpm/changelog/ChangelogParser.java | 32 +- .../main/java/org/xbib/rpm/format/Format.java | 6 +- .../org/xbib/rpm/header/AbstractHeader.java | 65 +- .../java/org/xbib/rpm/header/EntryType.java | 2 +- .../java/org/xbib/rpm/header/HeaderTag.java | 128 +- .../java/org/xbib/rpm/header/IntegerList.java | 14 + .../java/org/xbib/rpm/header/LongList.java | 14 + .../java/org/xbib/rpm/header/ShortList.java | 14 + .../java/org/xbib/rpm/header/StringList.java | 23 + .../rpm/header/entry/AbstractSpecEntry.java | 3 - .../xbib/rpm/header/entry/Int16SpecEntry.java | 9 +- .../xbib/rpm/header/entry/Int32SpecEntry.java | 18 +- .../xbib/rpm/header/entry/Int64SpecEntry.java | 9 +- ...pecEntry.java => StringListSpecEntry.java} | 4 +- .../rpm/header/entry/StringSpecEntry.java | 9 +- .../java/org/xbib/rpm/lead/Architecture.java | 50 +- .../java/org/xbib/rpm/payload/Contents.java | 582 +++----- .../java/org/xbib/rpm/payload/CpioHeader.java | 50 +- .../java/org/xbib/rpm/payload/Directive.java | 2 +- .../java/org/xbib/rpm/payload/UserGroup.java | 8 + .../xbib/rpm/security/SignatureGenerator.java | 35 +- .../org/xbib/rpm/signature/SignatureTag.java | 8 +- .../java/org/xbib/rpm/trigger/Depends.java | 35 +- .../java/org/xbib/rpm/RpmBuilderTest.java | 160 +- .../test/java/org/xbib/rpm/RpmReaderTest.java | 10 +- .../test/java/org/xbib/rpm/SimpleRpmTest.java | 4 +- .../rpm/changelog/ChangelogHandlerTest.java | 24 +- .../rpm/changelog/ChangelogParserTest.java | 95 +- .../org/xbib/rpm/changelog/ChangelogTest.java | 43 +- .../InvalidDirectiveExceptionTest.java | 6 +- .../exception/InvalidPathExceptionTest.java | 5 +- .../PathOutsideBuildPathExceptionTest.java | 5 +- .../SigningKeyNotFoundExceptionTest.java | 5 +- .../UnknownArchitectureExceptionTest.java | 6 +- .../UnknownOperatingSystemExceptionTest.java | 6 +- .../java/org/xbib/rpm/header/HeaderTest.java | 164 +- .../org/xbib/rpm/payload/ContentsTest.java | 78 +- .../xbib/rpm/security/PrintPublicKeyTest.java | 3 +- .../rpm/security/SignatureGeneratorTest.java | 20 +- .../rpm/security/SignatureReaderTest.java | 9 +- settings.gradle | 2 +- 154 files changed, 3444 insertions(+), 8774 deletions(-) delete mode 100644 config/checkstyle/checkstyle.xml delete mode 100644 gradle-plugin-rpm/NOTICE.txt delete mode 100644 gradle-plugin-rpm/config/checkstyle/checkstyle.xml create mode 100644 gradle-plugin-rpm/src/main/groovy/org/xbib/gradle/plugin/Rpm.groovy create mode 100644 gradle-plugin-rpm/src/main/groovy/org/xbib/gradle/plugin/RpmCopyAction.groovy create mode 100644 gradle-plugin-rpm/src/main/groovy/org/xbib/gradle/plugin/RpmExtension.groovy create mode 100644 gradle-plugin-rpm/src/main/groovy/org/xbib/gradle/plugin/RpmPlugin.groovy delete mode 100644 gradle-plugin-rpm/src/main/groovy/org/xbib/gradle/plugin/rpm/CopySpecEnhancement.groovy delete mode 100755 gradle-plugin-rpm/src/main/groovy/org/xbib/gradle/plugin/rpm/Dependency.groovy delete mode 100644 gradle-plugin-rpm/src/main/groovy/org/xbib/gradle/plugin/rpm/Directory.groovy delete mode 100644 gradle-plugin-rpm/src/main/groovy/org/xbib/gradle/plugin/rpm/FromConfigurationFactory.groovy delete mode 100755 gradle-plugin-rpm/src/main/groovy/org/xbib/gradle/plugin/rpm/Link.groovy delete mode 100644 gradle-plugin-rpm/src/main/groovy/org/xbib/gradle/plugin/rpm/ProjectPackagingExtension.groovy delete mode 100755 gradle-plugin-rpm/src/main/groovy/org/xbib/gradle/plugin/rpm/Rpm.groovy delete mode 100755 gradle-plugin-rpm/src/main/groovy/org/xbib/gradle/plugin/rpm/RpmCopyAction.groovy delete mode 100644 gradle-plugin-rpm/src/main/groovy/org/xbib/gradle/plugin/rpm/RpmFileVisitorStrategy.groovy delete mode 100644 gradle-plugin-rpm/src/main/groovy/org/xbib/gradle/plugin/rpm/RpmPlugin.groovy delete mode 100755 gradle-plugin-rpm/src/main/groovy/org/xbib/gradle/plugin/rpm/SystemPackagingExtension.groovy delete mode 100644 gradle-plugin-rpm/src/main/groovy/org/xbib/gradle/plugin/rpm/validation/RpmPackageNameAttributeValidator.groovy delete mode 100644 gradle-plugin-rpm/src/main/groovy/org/xbib/gradle/plugin/rpm/validation/RpmTaskPropertiesValidator.groovy delete mode 100644 gradle-plugin-rpm/src/main/groovy/org/xbib/gradle/plugin/rpm/validation/SystemPackagingAttributeValidator.groovy delete mode 100644 gradle-plugin-rpm/src/main/groovy/org/xbib/gradle/plugin/rpm/validation/SystemPackagingTaskPropertiesValidator.groovy delete mode 100644 gradle-plugin-rpm/src/main/resources/META-INF/gradle-plugins/org.xbib.gradle.plugin.rpm.properties create mode 100644 gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/RpmFullTest.groovy create mode 100644 gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/RpmPluginIntegrationTest.groovy create mode 100644 gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/RpmScriptTest.groovy create mode 100644 gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/RpmSignTest.groovy create mode 100644 gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/RpmSimpleTest.groovy delete mode 100644 gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/CopySpecEnhancementTest.groovy delete mode 100755 gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/RpmCopySpecVisitorTest.groovy delete mode 100644 gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/RpmPluginIntegrationTest.groovy delete mode 100755 gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/RpmPluginTest.groovy delete mode 100644 gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/RpmReader.groovy delete mode 100644 gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/SystemPackagingExtensionTest.groovy delete mode 100644 gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/validation/RpmPackageNameAttributeValidatorTest.groovy delete mode 100644 gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/validation/RpmTaskPropertiesValidatorIntegrationTest.groovy delete mode 100644 gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/AbstractProjectSpec.groovy delete mode 100644 gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/BaseIntegrationSpec.groovy delete mode 100644 gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/BuildLauncherBackedGradleHandle.groovy delete mode 100644 gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/ClasspathAddingInitScriptBuilder.groovy delete mode 100644 gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/ClasspathInjectingGradleHandleFactory.groovy delete mode 100644 gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/Coordinate.groovy delete mode 100644 gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/DefaultExecutionResult.groovy delete mode 100644 gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/DefaultGradleRunner.groovy delete mode 100644 gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/DependencyGraph.groovy delete mode 100644 gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/DependencyGraphNode.groovy delete mode 100644 gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/ExecutedTask.groovy delete mode 100644 gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/ExecutionResult.groovy delete mode 100644 gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/GradleDependencyGenerator.groovy delete mode 100644 gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/GradleHandle.groovy delete mode 100644 gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/GradleHandleBuildListener.groovy delete mode 100644 gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/GradleHandleFactory.groovy delete mode 100644 gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/GradleRunner.groovy delete mode 100644 gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/GradleRunnerFactory.groovy delete mode 100644 gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/IntegrationSpec.groovy delete mode 100644 gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/MinimalExecutedTask.groovy delete mode 100644 gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/MultiProjectHelper.groovy delete mode 100644 gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/MultiProjectInfo.groovy delete mode 100644 gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/PreExecutionAction.groovy delete mode 100644 gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/ProjectSpec.groovy delete mode 100644 gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/ToolingApiGradleHandleFactory.groovy delete mode 100644 gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/ToolingExecutionResult.groovy delete mode 100644 gradle-plugin-rpm/src/test/resources/BaseIntegrationSpec.groovy create mode 100644 gradle-plugin-rpm/src/test/resources/org/xbib/gradle/plugin/changelog create mode 100644 gradle-plugin-rpm/src/test/resources/org/xbib/gradle/plugin/preinstall.sh rename gradle-plugin-rpm/src/test/resources/{pgp => }/test-secring.gpg (100%) create mode 100644 gradle/compile/java.gradle create mode 100644 gradle/documentation/asciidoc.gradle delete mode 100644 gradle/ext.gradle create mode 100644 gradle/ide/idea.gradle delete mode 100644 gradle/publish.gradle create mode 100644 gradle/publishing/publication.gradle create mode 100644 gradle/publishing/sonatype.gradle create mode 100644 gradle/test/junit5.gradle delete mode 100644 maven-plugin-rpm/config/checkstyle/checkstyle.xml rename {config => maven-plugin-rpm/config}/maven/repo-settings.xml (93%) delete mode 100644 rpm-ant/config/checkstyle/checkstyle.xml delete mode 100644 rpm-core/config/checkstyle/checkstyle.xml create mode 100644 rpm-core/src/main/java/module-info.java create mode 100644 rpm-core/src/main/java/org/xbib/rpm/Dependency.java create mode 100644 rpm-core/src/main/java/org/xbib/rpm/Directory.java create mode 100644 rpm-core/src/main/java/org/xbib/rpm/Link.java create mode 100644 rpm-core/src/main/java/org/xbib/rpm/RpmReaderFile.java create mode 100644 rpm-core/src/main/java/org/xbib/rpm/RpmReaderResult.java create mode 100644 rpm-core/src/main/java/org/xbib/rpm/header/IntegerList.java create mode 100644 rpm-core/src/main/java/org/xbib/rpm/header/LongList.java create mode 100644 rpm-core/src/main/java/org/xbib/rpm/header/ShortList.java create mode 100644 rpm-core/src/main/java/org/xbib/rpm/header/StringList.java rename rpm-core/src/main/java/org/xbib/rpm/header/entry/{StringArraySpecEntry.java => StringListSpecEntry.java} (56%) create mode 100644 rpm-core/src/main/java/org/xbib/rpm/payload/UserGroup.java diff --git a/build.gradle b/build.gradle index 7891d5d..8271c6e 100644 --- a/build.gradle +++ b/build.gradle @@ -1,95 +1,33 @@ -import java.time.ZonedDateTime -import java.time.format.DateTimeFormatter - plugins { - id "org.sonarqube" version "2.6.2" - id "io.codearte.nexus-staging" version "0.11.0" + id "de.marcphilipp.nexus-publish" version "0.4.0" + id "io.codearte.nexus-staging" version "0.21.1" } -printf "Date: %s\nHost: %s\nOS: %s %s %s\nJava: %s %s %s %s\nGradle: %s Groovy: %s Java: %s\n" + - "Build: group: ${project.group} name: ${project.name} version: ${project.version}\n", - ZonedDateTime.now().format(DateTimeFormatter.ISO_DATE_TIME), - InetAddress.getLocalHost(), - System.getProperty("os.name"), - System.getProperty("os.arch"), - System.getProperty("os.version"), - System.getProperty("java.version"), - System.getProperty("java.vm.version"), - System.getProperty("java.vm.vendor"), - System.getProperty("java.vm.name"), - gradle.gradleVersion, GroovySystem.getVersion(), JavaVersion.current() +wrapper { + gradleVersion = "${project.property('gradle.wrapper.version')}" + distributionType = Wrapper.DistributionType.ALL +} ext { user = 'xbib' - projectName = 'rpm' - projectDescription = 'Java 8 RPM implementation with plugins for Ant, Maven, Gradle' - scmUrl = 'https://github.com/xbib/rpm' - scmConnection = 'scm:git:git://github.com/xbib/rpm.git' - scmDeveloperConnection = 'scm:git:git://github.com/xbib/rpm.git' + name = 'rpm' + description = 'RPM implementation in Java with plugins for Ant, Maven, Gradle' + inceptionYear = '2016' + url = 'https://github.com/' + user + '/' + name + scmUrl = 'https://github.com/' + user + '/' + name + scmConnection = 'scm:git:git://github.com/' + user + '/' + name + '.git' + scmDeveloperConnection = 'scm:git:ssh://git@github.com:' + user + '/' + name + '.git' + issueManagementSystem = 'Github' + issueManagementUrl = ext.scmUrl + '/issues' + licenseName = 'The Apache License, Version 2.0' + licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt' } subprojects { - - apply plugin: 'java' - apply plugin: 'maven' - - repositories { - mavenLocal() - mavenCentral() - } - - dependencies { - testCompile "junit:junit:${project.property('junit.version')}" - } - - compileJava { - sourceCompatibility = JavaVersion.VERSION_1_8 - targetCompatibility = JavaVersion.VERSION_1_8 - } - compileTestJava { - sourceCompatibility = JavaVersion.VERSION_1_8 - targetCompatibility = JavaVersion.VERSION_1_8 - } - - [compileJava, compileTestJava]*.options*.encoding = 'UTF-8' - - tasks.withType(JavaCompile) { - options.compilerArgs << "-Xlint:all" << "-profile" << "compact1" - } - - test { - testLogging { - showStandardStreams = false - exceptionFormat = 'full' - } - } - - clean { - delete 'out' - } - - sonarqube { - properties { - property "sonar.projectName", "xbib RPM" - property "sonar.sourceEncoding", "UTF-8" - property "sonar.tests", "src/test/java" - property "sonar.scm.provider", "git" - property "sonar.junit.reportsPath", "build/test-results/test/" - } - } - - task sourcesJar(type: Jar) { - classifier 'sources' - from sourceSets.main.allSource - } - - task javadocJar(type: Jar) { - classifier 'javadoc' - } - - artifacts { - archives sourcesJar, javadocJar - } - - apply from: "${rootProject.projectDir}/gradle/publish.gradle" + apply plugin: 'java-library' + apply from: rootProject.file('gradle/ide/idea.gradle') + apply from: rootProject.file('gradle/compile/java.gradle') + apply from: rootProject.file('gradle/test/junit5.gradle') + apply from: rootProject.file('gradle/publishing/publication.gradle') } +apply from: rootProject.file('gradle/publishing/sonatype.gradle') diff --git a/config/checkstyle/checkstyle.xml b/config/checkstyle/checkstyle.xml deleted file mode 100644 index 55e59d2..0000000 --- a/config/checkstyle/checkstyle.xml +++ /dev/null @@ -1,323 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/gradle-plugin-rpm/NOTICE.txt b/gradle-plugin-rpm/NOTICE.txt deleted file mode 100644 index f188c12..0000000 --- a/gradle-plugin-rpm/NOTICE.txt +++ /dev/null @@ -1,5 +0,0 @@ -This is a derived work of - -https://github.com/nebula-plugins/gradle-ospackage-plugin - -licensed under Apache Software License 2.0. diff --git a/gradle-plugin-rpm/build.gradle b/gradle-plugin-rpm/build.gradle index ab04047..84e910c 100644 --- a/gradle-plugin-rpm/build.gradle +++ b/gradle-plugin-rpm/build.gradle @@ -1,37 +1,41 @@ plugins { id 'java-gradle-plugin' - id 'com.gradle.plugin-publish' version '0.10.0' + id 'com.gradle.plugin-publish' version '0.11.0' } group = 'org.xbib.gradle.plugin' apply plugin: 'groovy' -apply plugin: 'maven' -apply plugin: 'signing' +apply plugin: 'java-gradle-plugin' apply plugin: 'com.gradle.plugin-publish' dependencies { - compile gradleApi() - compile project(':rpm-core') - compileOnly "org.codehaus.groovy:groovy:${project.property('groovy.version')}" - testCompile "junit:junit:${project.property('junit.version')}" - testCompile("org.spockframework:spock-core:${project.property('spock-core.version')}") { - exclude module: 'groovy' - exclude module: 'junit' - } - testCompile "org.xbib:guice:${project.property('xbib-guice.version')}" - + api gradleApi() + api project(':rpm-core') + testImplementation gradleTestKit() } compileGroovy { - sourceCompatibility = JavaVersion.VERSION_1_8 - targetCompatibility = JavaVersion.VERSION_1_8 + sourceCompatibility = JavaVersion.VERSION_11 + targetCompatibility = JavaVersion.VERSION_11 } -test { - testLogging { - showStandardStreams = true - exceptionFormat = 'full' +compileTestGroovy { + sourceCompatibility = JavaVersion.VERSION_11 + targetCompatibility = JavaVersion.VERSION_11 +} + +validatePlugins { + // disable warning as failures because gradle plugin does not recognize @Delegate tag + failOnWarning = false +} + +gradlePlugin { + plugins { + rpmPlugin { + id = 'org.xbib.gradle.plugin.rpm' + implementationClass = 'org.xbib.gradle.plugin.RpmPlugin' + } } } @@ -43,8 +47,8 @@ if (project.hasProperty('gradle.publish.key')) { rpmPlugin { id = 'org.xbib.gradle.plugin.rpm' version = project.version - description = projectDescription - displayName = projectDescription + description = rootProject.ext.description + displayName = rootProject.ext.description tags = ['gradle', 'plugin', 'rpm'] } } diff --git a/gradle-plugin-rpm/config/checkstyle/checkstyle.xml b/gradle-plugin-rpm/config/checkstyle/checkstyle.xml deleted file mode 100644 index 55e59d2..0000000 --- a/gradle-plugin-rpm/config/checkstyle/checkstyle.xml +++ /dev/null @@ -1,323 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/gradle-plugin-rpm/src/main/groovy/org/xbib/gradle/plugin/Rpm.groovy b/gradle-plugin-rpm/src/main/groovy/org/xbib/gradle/plugin/Rpm.groovy new file mode 100644 index 0000000..18274d4 --- /dev/null +++ b/gradle-plugin-rpm/src/main/groovy/org/xbib/gradle/plugin/Rpm.groovy @@ -0,0 +1,51 @@ +package org.xbib.gradle.plugin + +import org.gradle.api.internal.file.copy.CopyAction +import org.gradle.api.tasks.Nested +import org.gradle.api.tasks.bundling.AbstractArchiveTask + +import java.util.concurrent.Callable + +class Rpm extends AbstractArchiveTask { + + @Delegate + @Nested + RpmExtension rpmExtension + + Rpm() { + rpmExtension = project.extensions.findByName('rpm') as RpmExtension + getArchiveExtension().set("rpm") + Callable archiveFileNameProvider = new Callable() { + @Override + String call() throws Exception { + constructArchiveFileName() + } + } + archiveFileName.set(project.provider(archiveFileNameProvider)) + } + + @Override + protected CopyAction createCopyAction() { + new RpmCopyAction(project, rpmExtension, this) + } + + private String constructArchiveFileName() { + StringBuilder sb = new StringBuilder() + if (packageName) { + sb.append(packageName) + } + if (packageVersion) { + sb.append('-').append(packageVersion) + } + if (packageRelease) { + sb.append('-').append(packageRelease) + } + if (arch) { + sb.append('.').append(arch.name().toLowerCase(Locale.ROOT)) + } + if (archiveExtension) { + sb.append('.').append(archiveExtension.get()) + } + sb.toString() + } +} diff --git a/gradle-plugin-rpm/src/main/groovy/org/xbib/gradle/plugin/RpmCopyAction.groovy b/gradle-plugin-rpm/src/main/groovy/org/xbib/gradle/plugin/RpmCopyAction.groovy new file mode 100644 index 0000000..d0d73d7 --- /dev/null +++ b/gradle-plugin-rpm/src/main/groovy/org/xbib/gradle/plugin/RpmCopyAction.groovy @@ -0,0 +1,212 @@ +package org.xbib.gradle.plugin + +import org.gradle.api.Project +import org.gradle.api.file.DuplicatesStrategy +import org.gradle.api.file.FileCopyDetails +import org.gradle.api.internal.file.CopyActionProcessingStreamAction +import org.gradle.api.internal.file.copy.CopyAction +import org.gradle.api.internal.file.copy.CopyActionProcessingStream +import org.gradle.api.internal.file.copy.FileCopyDetailsInternal +import org.gradle.api.tasks.WorkResult +import org.gradle.api.tasks.WorkResults +import org.xbib.rpm.Dependency +import org.xbib.rpm.Directory +import org.xbib.rpm.Link +import org.xbib.rpm.RpmBuilder +import org.xbib.rpm.payload.Directive +import java.nio.file.Files +import java.nio.file.Path +import java.nio.file.StandardOpenOption + +class RpmCopyAction implements CopyAction { + + Project project + + Rpm task + + RpmExtension ext + + RpmBuilder builder + + Path tempDir + + RpmCopyAction(Project project, RpmExtension rpmExtension, Rpm task) { + this.project = project + this.task = task + this.ext = rpmExtension + } + + @Override + WorkResult execute(CopyActionProcessingStream copyActionProcessingStream) { + if (ext.enabled) { + task.setDuplicatesStrategy(DuplicatesStrategy.INCLUDE) + tempDir = task.getTemporaryDir().toPath() + this.builder = createRpm() + copyActionProcessingStream.process(new StreamAction()) + addOther() + buildRpm() + } + WorkResults.didWork(true) + } + + RpmBuilder createRpm() { + RpmBuilder builder = new RpmBuilder() + builder.setPackage ext.packageName, ext.packageVersion, ext.packageRelease, ext.epoch + builder.setType ext.packageType + builder.setPlatform ext.arch, ext.os + builder.setGroup ext.packageGroup + builder.setBuildHost ext.buildHost + builder.setSummary ext.summary + builder.setDescription ext.packageDescription + builder.setLicense ext.license + builder.setPackager ext.packager + builder.setDistribution ext.distribution + builder.setVendor ext.vendor + builder.setUrl ext.url + builder.setPrefixes task.prefixes + builder.setPrivateKeyId task.getSigningKeyId() + builder.setPrivateKeyPassphrase task.getSigningKeyPassphrase() + builder.setPrivateKeyRing task.getSigningKeyRing() + builder.setPrivateKeyHashAlgo task.getSigningKeyHashAlgo() + builder.setSourceRpm(task.sourcePackage) + builder.setPreInstall task.preInstallFile?.text ?: task.preInstall + builder.setPostInstall task.postInstallFile?.text ?: task.postInstall + builder.setPreUninstall task.preUninstallFile?.text ?: task.preUninstall + builder.setPostUninstall task.postUninstallFile?.text ?: task.postUninstall + builder.setPreTrans task.preTransFile?.text ?: task.preTrans + builder.setPostTrans task.postTransFile?.text ?: task.postTrans + builder.setPreInstall prepareScripts(task, task.preInstallCommands) + builder.setPostInstall prepareScripts(task, task.postInstallCommands) + builder.setPreUninstall prepareScripts(task, task.preUninstallCommands) + builder.setPostUninstall prepareScripts(task, task.postUninstallCommands) + builder.setPreTrans prepareScripts(task, task.preTransCommands) + builder.setPostTrans prepareScripts(task, task.postTransCommands) + if (task.changeLogFile) { + builder.addChangelog task.changeLogFile?.toPath() + } + if (task.changeLog) { + builder.addChangelog(task.changeLog) + } + builder + } + + void addOther() { + for (Link link : task.links) { + builder.addLink(link.path, link.target, link.permissions) + } + for (Dependency dep : task.dependencies) { + builder.addDependency(dep.packageName, dep.flags, dep.version) + } + for (Dependency obsolete: task.obsoletes) { + builder.addObsoletes(obsolete.packageName, obsolete.flags, obsolete.version) + } + for (Dependency conflict : task.conflicts) { + builder.addConflicts(conflict.packageName, conflict.flags, conflict.version) + } + for (Dependency provides : task.provides) { + builder.addProvides(provides.packageName, provides.flags, provides.version) + } + for (Directory directory : task.directories) { + String user = directory.user ? directory.user : task.user + String group = directory.group ? directory.group : task.group + builder.addDirectory(directory.path, directory.permissions, null, user, group, directory.addParents) + } + } + + void buildRpm() { + Path path = task.archiveFile.get().asFile.toPath() + Files.createDirectories(path.parent) + Files.newByteChannel(path, StandardOpenOption.WRITE, StandardOpenOption.CREATE, + StandardOpenOption.TRUNCATE_EXISTING).withCloseable { ch -> + builder.build(ch) + } + } + + private class StreamAction implements CopyActionProcessingStreamAction { + + @Override + void processFile(FileCopyDetailsInternal fileCopyDetailsInternal) { + boolean addParents = ext.addParentDirs != null ? ext.addParentDirs : task.addParentDirs + Path path = extractPath(tempDir, fileCopyDetailsInternal) + String p = "/${fileCopyDetailsInternal.path}" + if (Files.isSymbolicLink(path)) { + builder.addLink(p, Files.readSymbolicLink(path).toFile().path, -1) + } else if (!fileCopyDetailsInternal.isDirectory()) { + int mode = fileCopyDetailsInternal.mode + int dirmode = -1 + EnumSet directive = makeDirective(ext.fileType) + String user = ext.user ?: task.user + String group = ext.group ?: task.group + builder.addFile(p, path, mode, dirmode, directive, user, group, addParents) + } + } + } + + private static Path extractPath(Path tempDir, FileCopyDetails fileDetails) { + Path path + try { + path = fileDetails.file.toPath() + } catch (UnsupportedOperationException e) { + path = tempDir.resolve(fileDetails.path) + fileDetails.copyTo(path.toFile()) + } + path + } + + private static EnumSet makeDirective(List strings) { + EnumSet set = EnumSet.of(Directive.NONE) + for (String string : strings) { + set.add(Directive.valueOf(string.toUpperCase(Locale.ROOT))) + } + set + } + + private static String prepareScripts(Rpm task, List scripts) { + if (scripts != null && !scripts.isEmpty()) { + List list = [] + def stdDefines = standardScriptDefines(task) + if (stdDefines) { + list.add(stdDefines) + } + if (task.commonCommands) { + list.addAll(task.commonCommands) + } + list.addAll(scripts) + return concatAndRemoveShebangLines(list) + } else { + return null + } + } + + private static String standardScriptDefines(Rpm task) { + String.format(" RPM_ARCH=%s \n RPM_OS=%s \n RPM_PACKAGE_NAME=%s \n RPM_PACKAGE_VERSION=%s \n RPM_PACKAGE_RELEASE=%s \n\n", + task.arch?.toString()?.toLowerCase()?:'', + task.os?.toString()?.toLowerCase()?: '', + task.packageName, + task.packageVersion, + task.packageRelease) + } + + private static String concatAndRemoveShebangLines(Collection scripts) { + String shebang + StringBuilder result = new StringBuilder() + scripts.each { script -> + script?.eachLine { line -> + if (line.matches('^#!.*$')) { + if (!shebang) { + shebang = line + } else if (line != shebang) { + throw new IllegalArgumentException("mismatching #! script lines") + } + } else { + result.append line + result.append "\n" + } + } + } + if (shebang) { + result.insert(0, shebang + "\n") + } + result.toString() + } +} diff --git a/gradle-plugin-rpm/src/main/groovy/org/xbib/gradle/plugin/RpmExtension.groovy b/gradle-plugin-rpm/src/main/groovy/org/xbib/gradle/plugin/RpmExtension.groovy new file mode 100644 index 0000000..7fc6213 --- /dev/null +++ b/gradle-plugin-rpm/src/main/groovy/org/xbib/gradle/plugin/RpmExtension.groovy @@ -0,0 +1,409 @@ +package org.xbib.gradle.plugin + +import org.gradle.api.tasks.Input +import org.gradle.api.tasks.Optional +import org.xbib.rpm.Dependency +import org.xbib.rpm.Directory +import org.xbib.rpm.Link +import org.xbib.rpm.lead.Architecture +import org.xbib.rpm.lead.Os +import org.xbib.rpm.lead.PackageType + +class RpmExtension { + + @Optional + @Input + boolean enabled = true + + @Optional + @Input + String packageName + + @Optional + @Input + String packageVersion + + @Optional + @Input + String packageRelease + + @Optional + @Input + Integer epoch = 0 + + @Optional + @Input + String signingKeyPassphrase + + @Optional + @Input + String signingKeyRing + + @Optional + @Input + String signingKeyId + + @Optional + @Input + String signingKeyHashAlgo + + @Optional + @Input + String user + + @Optional + @Input + String group + + @Optional + @Input + String buildHost + + @Optional + @Input + String packageGroup + + @Optional + @Input + String packageDescription = '' + + @Optional + @Input + String summary + + @Optional + @Input + String license + + @Optional + @Input + String packager + + @Optional + @Input + String distribution + + @Optional + @Input + String vendor + + @Optional + @Input + String url + + @Optional + @Input + String sourcePackage + + @Optional + @Input + List fileType + + @Optional + @Input + Boolean addParentDirs = false + + @Optional + @Input + Architecture arch = Architecture.X86_64 + + @Optional + @Input + Os os = Os.LINUX + + @Optional + @Input + PackageType packageType = PackageType.BINARY + + @Input + List prefixes = new ArrayList() + + @Optional + @Input + Integer uid + + @Optional + @Input + Integer gid + + @Optional + @Input + String maintainer + + @Optional + @Input + String uploaders + + @Optional + @Input + String priority + + @Optional + @Input + String preInstall + + @Optional + @Input + File preInstallFile + + @Input + List preInstallCommands = [] + + @Optional + @Input + String postInstall + + @Optional + @Input + File postInstallFile + + @Input + List postInstallCommands = [] + + @Optional + @Input + String preUninstall + + @Optional + @Input + File preUninstallFile + + @Input + List preUninstallCommands = [] + + @Optional + @Input + String postUninstall + + @Optional + @Input + File postUninstallFile + + @Input + List postUninstallCommands = [] + + @Optional + @Input + String preTrans + + @Optional + @Input + File preTransFile + + @Input + List preTransCommands = [] + + @Optional + @Input + String postTrans + + @Optional + @Input + File postTransFile + + @Input + List postTransCommands = [] + + @Input + List commonCommands = [] + + @Input + List links = [] + + Link link(String path, String target) { + link(path, target, -1) + } + + Link link(String path, String target, int permissions) { + Link link = new Link(path, target, permissions) + links.add(link) + link + } + + @Input + List dependencies = [] + + @Input + List obsoletes = [] + + @Input + List conflicts = [] + + @Input + List recommends = [] + + @Input + List suggests = [] + + @Input + List enhances = [] + + @Input + List preDepends = [] + + @Input + List breaks = [] + + @Input + List replaces = [] + + @Input + List provides = [] + + Dependency requires(String packageName) { + requires(packageName, '') + } + + Dependency requires(String packageName, String version){ + requires(packageName, version, 0) + } + + Dependency requires(String packageName, String version, int flag) { + def dep = new Dependency(packageName, version, flag) + dependencies.add(dep) + dep + } + + Dependency obsoletes(String packageName) { + obsoletes(packageName, '') + } + + Dependency obsoletes(String packageName, String version) { + obsoletes(packageName, version, 0) + } + + Dependency obsoletes(String packageName, String version, int flag) { + def dep = new Dependency(packageName, version, flag) + obsoletes.add(dep) + dep + } + + Dependency conflicts(String packageName) { + conflicts(packageName, '') + } + + Dependency conflicts(String packageName, String version) { + conflicts(packageName, version, 0) + } + + Dependency conflicts(String packageName, String version, int flag) { + def dep = new Dependency(packageName, version, flag) + conflicts.add(dep) + dep + } + + Dependency recommends(String packageName) { + recommends(packageName, '') + } + + Dependency recommends(String packageName, String version) { + recommends(packageName, version, 0) + } + + Dependency recommends(String packageName, String version, int flag) { + def dep = new Dependency(packageName, version, flag) + recommends.add(dep) + dep + } + + Dependency suggests(String packageName) { + suggests(packageName, '') + } + + Dependency suggests(String packageName, String version) { + suggests(packageName, version, 0) + } + + Dependency suggests(String packageName, String version, int flag) { + def dep = new Dependency(packageName, version, flag) + suggests.add(dep) + dep + } + + Dependency enhances(String packageName) { + enhances(packageName, '') + } + + Dependency enhances(String packageName, String version) { + enhances(packageName, version, 0) + } + + Dependency enhances(String packageName, String version, int flag) { + def dep = new Dependency(packageName, version, flag) + enhances.add(dep) + dep + } + + Dependency preDepends(String packageName) { + preDepends(packageName, '') + } + + Dependency preDepends(String packageName, String version) { + preDepends(packageName, version, 0) + } + + Dependency preDepends(String packageName, String version, int flag) { + def dep = new Dependency(packageName, version, flag) + preDepends.add(dep) + dep + } + + Dependency breaks(String packageName) { + breaks(packageName, '') + } + + Dependency breaks(String packageName, String version) { + breaks(packageName, version, 0) + } + + Dependency breaks(String packageName, String version, int flag) { + def dep = new Dependency(packageName, version, flag) + breaks.add(dep) + dep + } + + Dependency replaces(String packageName) { + replaces(packageName, '') + } + + Dependency replaces(String packageName, String version) { + replaces(packageName, version, 0) + } + + Dependency replaces(String packageName, String version, int flag) { + def dep = new Dependency(packageName, version, flag) + replaces.add(dep) + dep + } + + Dependency provides(String packageName) { + provides(packageName, '') + } + + Dependency provides(String packageName, String version) { + provides(packageName, version, 0) + } + + Dependency provides(String packageName, String version, int flag) { + def dep = new Dependency(packageName, version, flag) + provides.add(dep) + dep + } + + @Input + List directories = [] + + Directory directory(String path) { + Directory directory = new Directory(path: path) + directories << directory + directory + } + + @Optional + @Input + File changeLogFile + + @Optional + @Input + String changeLog +} diff --git a/gradle-plugin-rpm/src/main/groovy/org/xbib/gradle/plugin/RpmPlugin.groovy b/gradle-plugin-rpm/src/main/groovy/org/xbib/gradle/plugin/RpmPlugin.groovy new file mode 100644 index 0000000..d6b082e --- /dev/null +++ b/gradle-plugin-rpm/src/main/groovy/org/xbib/gradle/plugin/RpmPlugin.groovy @@ -0,0 +1,43 @@ +package org.xbib.gradle.plugin + +import org.gradle.api.GradleException +import org.gradle.api.Plugin +import org.gradle.api.Project +import org.gradle.api.plugins.BasePlugin +import org.gradle.api.tasks.TaskProvider +import org.gradle.util.GradleVersion + +class RpmPlugin implements Plugin { + + @Override + void apply(Project project) { + checkVersion() + project.plugins.apply(BasePlugin) + project.ext.Rpm = Rpm.class + project.with { + createExtension(project) + } + /*project.afterEvaluate { + addTasks(project) + }*/ + } + + private static void checkVersion() { + String version = '6.4' + if (GradleVersion.current() < GradleVersion.version(version)) { + throw new GradleException("need Gradle ${version} or higher") + } + } + + private static void createExtension(Project project) { + project.extensions.create('rpm', RpmExtension) + } + + /*private static void addTasks(Project project) { + TaskProvider taskProvider = project.tasks.register('buildRpm', Rpm) { + group = 'rpm' + description = 'Generate RPM archive' + } + project.tasks.findByName('build').dependsOn taskProvider + }*/ +} diff --git a/gradle-plugin-rpm/src/main/groovy/org/xbib/gradle/plugin/rpm/CopySpecEnhancement.groovy b/gradle-plugin-rpm/src/main/groovy/org/xbib/gradle/plugin/rpm/CopySpecEnhancement.groovy deleted file mode 100644 index 7d3323d..0000000 --- a/gradle-plugin-rpm/src/main/groovy/org/xbib/gradle/plugin/rpm/CopySpecEnhancement.groovy +++ /dev/null @@ -1,77 +0,0 @@ -package org.xbib.gradle.plugin.rpm - -import org.gradle.api.file.CopySpec -import org.gradle.api.internal.file.copy.CopySpecWrapper -import org.gradle.internal.impldep.org.apache.commons.lang.reflect.FieldUtils - -/** - * - */ -@Category(CopySpec) -class CopySpecEnhancement { - - static void appendFieldToCopySpec(CopySpec spec, String fieldName, Object value) { - def directSpec = spec - if (spec instanceof CopySpecWrapper) { - def delegateField = FieldUtils.getField(CopySpecWrapper, 'delegate', true) - directSpec = delegateField.get(spec) - } - directSpec.metaClass["get${fieldName.capitalize()}"] = { value } - } - - static void user(CopySpec spec, String user) { - appendFieldToCopySpec(spec, 'user', user) - } - - static void setUser(CopySpec spec, String userArg) { - user(spec, userArg) - } - - static void permissionGroup(CopySpec spec, String permissionGroup) { - appendFieldToCopySpec(spec, 'permissionGroup', permissionGroup) - } - - static void setPermissionGroup(CopySpec spec, String permissionGroupArg) { - permissionGroup(spec, permissionGroupArg) - } - - static void setFileType(CopySpec spec, List fileTypeArg) { - fileType(spec, fileTypeArg) - } - - static void fileType(CopySpec spec, List fileType) { - appendFieldToCopySpec(spec, 'fileType', fileType) - } - - static void addParentDirs(CopySpec spec, boolean addParentDirs) { - appendFieldToCopySpec(spec, 'addParentDirs', addParentDirs) - } - - static void setAddParentDirs(CopySpec spec, boolean addParentDirsArg) { - addParentDirs(spec, addParentDirsArg) - } - - static void createDirectoryEntry(CopySpec spec, boolean createDirectoryEntry) { - appendFieldToCopySpec(spec, 'createDirectoryEntry', createDirectoryEntry) - } - - static void setCreateDirectoryEntry(CopySpec spec, boolean createDirectoryEntryArg) { - createDirectoryEntry(spec, createDirectoryEntryArg) - } - - static void uid(CopySpec spec, int uid) { - appendFieldToCopySpec(spec, 'uid', uid) - } - - static void setUid(CopySpec spec, int uidArg) { - uid(spec, uidArg) - } - - static void gid(CopySpec spec, int gid) { - appendFieldToCopySpec(spec, 'gid', gid) - } - - static void setGid(CopySpec spec, int gidArg) { - gid(spec, gidArg) - } -} diff --git a/gradle-plugin-rpm/src/main/groovy/org/xbib/gradle/plugin/rpm/Dependency.groovy b/gradle-plugin-rpm/src/main/groovy/org/xbib/gradle/plugin/rpm/Dependency.groovy deleted file mode 100755 index c3eaead..0000000 --- a/gradle-plugin-rpm/src/main/groovy/org/xbib/gradle/plugin/rpm/Dependency.groovy +++ /dev/null @@ -1,55 +0,0 @@ -package org.xbib.gradle.plugin.rpm - -import groovy.transform.EqualsAndHashCode -import org.xbib.rpm.format.Flags - -@EqualsAndHashCode -class Dependency implements Serializable { - - String packageName - - String version - - int flag = 0 - - Dependency alternative = null - - Dependency(String packageName, String version, int flag=0) { - if (packageName.contains(',')) { - throw new IllegalArgumentException('package name can not contain comma') - } - this.packageName = packageName - this.version = version - this.flag = flag - } - - Dependency or(String packageName, String version='', int flag=0) { - alternative = new Dependency(packageName, version, flag) - alternative - } - - String toDebString() { - def signMap = [ - (Flags.GREATER|Flags.EQUAL): '>=', - (Flags.LESS|Flags.EQUAL): '<=', - (Flags.EQUAL): '=', - (Flags.GREATER): '>>', - (Flags.LESS): '<<' - ] - - def depStr = this.packageName - if (this.flag && this.version) { - def sign = signMap[this.flag] - if (sign==null) { - throw new IllegalArgumentException() - } - depStr += " (${sign} ${this.version})" - } else if (this.version) { - depStr += " (${this.version})" - } - if (alternative) { - depStr += " | " + alternative.toDebString() - } - depStr - } -} diff --git a/gradle-plugin-rpm/src/main/groovy/org/xbib/gradle/plugin/rpm/Directory.groovy b/gradle-plugin-rpm/src/main/groovy/org/xbib/gradle/plugin/rpm/Directory.groovy deleted file mode 100644 index b3c1c1f..0000000 --- a/gradle-plugin-rpm/src/main/groovy/org/xbib/gradle/plugin/rpm/Directory.groovy +++ /dev/null @@ -1,14 +0,0 @@ -package org.xbib.gradle.plugin.rpm - -class Directory { - - String path - - int permissions = -1 - - String user = null - - String permissionGroup = null - - boolean addParents = false -} diff --git a/gradle-plugin-rpm/src/main/groovy/org/xbib/gradle/plugin/rpm/FromConfigurationFactory.groovy b/gradle-plugin-rpm/src/main/groovy/org/xbib/gradle/plugin/rpm/FromConfigurationFactory.groovy deleted file mode 100644 index b591594..0000000 --- a/gradle-plugin-rpm/src/main/groovy/org/xbib/gradle/plugin/rpm/FromConfigurationFactory.groovy +++ /dev/null @@ -1,21 +0,0 @@ -package org.xbib.gradle.plugin.rpm - -import org.gradle.api.file.FileCopyDetails -import org.gradle.api.tasks.AbstractCopyTask - -import java.nio.file.Files - -class FromConfigurationFactory { - - static Closure preserveSymlinks(delegate) { - return { - delegate.eachFile { FileCopyDetails details -> - if (Files.isSymbolicLink(details.file.toPath())) { - details.exclude() - def toFile = Files.readSymbolicLink(details.file.toPath()).toFile() - delegate.link(details.relativePath.toString(), toFile.toString()) - } - } - } - } -} diff --git a/gradle-plugin-rpm/src/main/groovy/org/xbib/gradle/plugin/rpm/Link.groovy b/gradle-plugin-rpm/src/main/groovy/org/xbib/gradle/plugin/rpm/Link.groovy deleted file mode 100755 index 93ff8a4..0000000 --- a/gradle-plugin-rpm/src/main/groovy/org/xbib/gradle/plugin/rpm/Link.groovy +++ /dev/null @@ -1,13 +0,0 @@ -package org.xbib.gradle.plugin.rpm - -import groovy.transform.EqualsAndHashCode - -@EqualsAndHashCode -class Link implements Serializable { - - String path - - String target - - int permissions = -1 -} diff --git a/gradle-plugin-rpm/src/main/groovy/org/xbib/gradle/plugin/rpm/ProjectPackagingExtension.groovy b/gradle-plugin-rpm/src/main/groovy/org/xbib/gradle/plugin/rpm/ProjectPackagingExtension.groovy deleted file mode 100644 index f78f101..0000000 --- a/gradle-plugin-rpm/src/main/groovy/org/xbib/gradle/plugin/rpm/ProjectPackagingExtension.groovy +++ /dev/null @@ -1,257 +0,0 @@ -package org.xbib.gradle.plugin.rpm - -import org.gradle.api.Action -import org.gradle.api.Project -import org.gradle.api.file.CopyProcessingSpec -import org.gradle.api.file.CopySpec -import org.gradle.api.file.DuplicatesStrategy -import org.gradle.api.file.FileCopyDetails -import org.gradle.api.file.FileTree -import org.gradle.api.file.FileTreeElement -import org.gradle.api.file.RelativePath -import org.gradle.api.internal.file.FileResolver -import org.gradle.api.internal.file.copy.CopySpecInternal -import org.gradle.api.internal.file.copy.DefaultCopySpec -import org.gradle.api.internal.project.ProjectInternal -import org.gradle.api.specs.Spec -import org.gradle.internal.reflect.Instantiator - -import java.util.regex.Pattern - -/** - * An extension which can be attached to the project. - * This is a superset of SystemPackagingExtension because we don't - * want the @Delegate to inherit the copy spec parts. - * - * We can't extends DefaultCopySpec, since it's @NotExtensible, meaning that we won't get any convention - * mappings. If we extend DelegatingCopySpec we get groovy compilation errors around the return types between - * CopySourceSpec's methods and the ones overriden in DelegatingCopySpec, even though that's perfectly valid - * Java code. The theory is that it's some bug in groovyc. - */ -class ProjectPackagingExtension extends SystemPackagingExtension { - - CopySpecInternal delegateCopySpec - - ProjectPackagingExtension(Project project) { - FileResolver resolver = ((ProjectInternal) project).getFileResolver() - Instantiator instantiator = ((ProjectInternal) project).getServices().get(Instantiator) - delegateCopySpec = new DefaultCopySpec(resolver, instantiator) - } - - /* - * Special Use cases that involve Closure's which we want to wrap. - */ - CopySpec from(Object sourcePath, Closure c) { - def preserveSymlinks = FromConfigurationFactory.preserveSymlinks(this) - use(CopySpecEnhancement) { - return getDelegateCopySpec().from(sourcePath, c << preserveSymlinks) - } - } - - CopySpec from(Object... sourcePaths) { - def spec = null - for (Object sourcePath : sourcePaths) { - spec = from(sourcePath, {}) - } - spec - } - - CopySpec into(Object destPath, Closure configureClosure) { - use(CopySpecEnhancement) { - return getDelegateCopySpec().into(destPath, configureClosure) - } - } - - CopySpec include(Closure includeSpec) { - use(CopySpecEnhancement) { - return getDelegateCopySpec().include(includeSpec) - } - } - - CopySpec exclude(Closure excludeSpec) { - use(CopySpecEnhancement) { - return getDelegateCopySpec().exclude(excludeSpec) - } - } - - CopySpec filter(Closure closure) { - use(CopySpecEnhancement) { - return getDelegateCopySpec().filter(closure) - } - } - - CopySpec rename(Closure closure) { - use(CopySpecEnhancement) { - return getDelegateCopySpec().rename(closure) - } - } - - CopySpec eachFile(Closure closure) { - use(CopySpecEnhancement) { - return getDelegateCopySpec().eachFile(closure) - } - } - - /* - * Copy and Paste from org.gradle.api.internal.file.copy.DelegatingCopySpec, since extending it causes - * compilation problems. The methods above are special cases and are commented out below. - */ - RelativePath getDestPath() { - getDelegateCopySpec().getDestPath() - } - - FileTree getSource() { - getDelegateCopySpec().getSource() - } - - boolean hasSource() { - getDelegateCopySpec().hasSource() - } - - Collection> getAllCopyActions() { - getDelegateCopySpec().getAllCopyActions() - } - - boolean isCaseSensitive() { - getDelegateCopySpec().isCaseSensitive() - } - - void setCaseSensitive(boolean caseSensitive) { - getDelegateCopySpec().setCaseSensitive(caseSensitive) - } - - boolean getIncludeEmptyDirs() { - getDelegateCopySpec().getIncludeEmptyDirs() - } - - void setIncludeEmptyDirs(boolean includeEmptyDirs) { - getDelegateCopySpec().setIncludeEmptyDirs(includeEmptyDirs) - } - - DuplicatesStrategy getDuplicatesStrategy() { - getDelegateCopySpec().getDuplicatesStrategy() - } - - void setDuplicatesStrategy(DuplicatesStrategy strategy) { - getDelegateCopySpec().setDuplicatesStrategy(strategy) - } - - CopySpec filesMatching(String pattern, Action action) { - getDelegateCopySpec().filesMatching(pattern, action) - } - - CopySpec filesNotMatching(String pattern, Action action) { - getDelegateCopySpec().filesNotMatching(pattern, action) - } - - CopySpec with(CopySpec... sourceSpecs) { - getDelegateCopySpec().with(sourceSpecs) - } - - CopySpec setIncludes(Iterable includes) { - getDelegateCopySpec().setIncludes(includes) - } - - CopySpec setExcludes(Iterable excludes) { - getDelegateCopySpec().setExcludes(excludes) - } - - CopySpec include(String... includes) { - getDelegateCopySpec().include(includes) - } - - CopySpec include(Iterable includes) { - getDelegateCopySpec().include(includes) - } - - CopySpec include(Spec includeSpec) { - getDelegateCopySpec().include(includeSpec) - } - - CopySpec exclude(String... excludes) { - getDelegateCopySpec().exclude(excludes) - } - - CopySpec exclude(Iterable excludes) { - getDelegateCopySpec().exclude(excludes) - } - - CopySpec exclude(Spec excludeSpec) { - getDelegateCopySpec().exclude(excludeSpec) - } - - CopySpec into(Object destPath) { - getDelegateCopySpec().into(destPath) - } - - CopySpec rename(String sourceRegEx, String replaceWith) { - getDelegateCopySpec().rename(sourceRegEx, replaceWith) - } - - CopyProcessingSpec rename(Pattern sourceRegEx, String replaceWith) { - getDelegateCopySpec().rename(sourceRegEx, replaceWith) - } - - CopySpec filter(Map properties, Class filterType) { - getDelegateCopySpec().filter(properties, filterType) - } - - CopySpec filter(Class filterType) { - getDelegateCopySpec().filter(filterType) - } - - CopySpec expand(Map properties) { - getDelegateCopySpec().expand(properties) - } - - CopySpec eachFile(Action action) { - getDelegateCopySpec().eachFile(action) - } - - Integer getFileMode() { - getDelegateCopySpec().getFileMode() - } - - CopyProcessingSpec setFileMode(Integer mode) { - getDelegateCopySpec().setFileMode(mode) - } - - Integer getDirMode() { - getDelegateCopySpec().getDirMode() - } - - CopyProcessingSpec setDirMode(Integer mode) { - getDelegateCopySpec().setDirMode(mode) - } - - Set getIncludes() { - getDelegateCopySpec().getIncludes() - } - - Set getExcludes() { - getDelegateCopySpec().getExcludes() - } - - Iterable getChildren() { - getDelegateCopySpec().getChildren() - } - - FileTree getAllSource() { - getDelegateCopySpec().getAllSource() - } - - DefaultCopySpec addChild() { - getDelegateCopySpec().addChild() - } - - DefaultCopySpec addFirst() { - getDelegateCopySpec().addFirst() - } - - void walk(Action action) { - action.execute(this) - for (CopySpecInternal child : getChildren()) { - child.walk(action) - } - } -} diff --git a/gradle-plugin-rpm/src/main/groovy/org/xbib/gradle/plugin/rpm/Rpm.groovy b/gradle-plugin-rpm/src/main/groovy/org/xbib/gradle/plugin/rpm/Rpm.groovy deleted file mode 100755 index f001a98..0000000 --- a/gradle-plugin-rpm/src/main/groovy/org/xbib/gradle/plugin/rpm/Rpm.groovy +++ /dev/null @@ -1,448 +0,0 @@ -package org.xbib.gradle.plugin.rpm - -import groovy.util.logging.Log4j -import org.gradle.api.file.FileCollection -import org.gradle.api.file.RegularFile -import org.gradle.api.internal.ConventionMapping -import org.gradle.api.internal.IConventionAware -import org.gradle.api.model.ObjectFactory -import org.gradle.api.provider.Property -import org.gradle.api.provider.Provider -import org.gradle.api.tasks.Input -import org.gradle.api.tasks.InputFiles -import org.gradle.api.tasks.Optional -import org.gradle.api.tasks.Nested -import org.gradle.api.tasks.SkipWhenEmpty -import org.gradle.api.tasks.TaskAction -import org.gradle.api.tasks.bundling.AbstractArchiveTask -import org.gradle.util.GUtil -import org.xbib.rpm.lead.Architecture -import org.xbib.rpm.lead.Os -import org.xbib.rpm.lead.PackageType - -import javax.annotation.Nullable -import java.nio.file.Path -import java.util.concurrent.Callable - -/** - * - */ -@Log4j -class Rpm extends AbstractArchiveTask { - - final ObjectFactory objectFactory - - @Input - @Optional - Path changeLogFile - - @Delegate - @Nested - SystemPackagingExtension systemPackagingExtension - - ProjectPackagingExtension projectPackagingExtension - - Rpm() { - super() - objectFactory = project.objects - systemPackagingExtension = new SystemPackagingExtension() - projectPackagingExtension = project.extensions.findByType(ProjectPackagingExtension) - if (projectPackagingExtension) { - getRootSpec().with(projectPackagingExtension.delegateCopySpec) - } - archiveExtension.set('rpm') - - // override archive file name provider in Gradle 5 - Callable archiveFileNameProvider = new Callable() { - @Override - String call() throws Exception { - constructArchiveFile() - } - } - getArchiveFileName().set(getProject().provider(archiveFileNameProvider)) - } - - @Override - RpmCopyAction createCopyAction() { - new RpmCopyAction(this) - } - - @Override - @TaskAction - protected void copy() { - use(CopySpecEnhancement) { - super.copy() - } - } - - @Override - Rpm from(Object... sourcePaths) { - for (Object sourcePath : sourcePaths) { - from(sourcePath, {}) - } - this - } - - @Override - Rpm from(Object sourcePath, Closure c) { - def preserveSymlinks = FromConfigurationFactory.preserveSymlinks(this) - use(CopySpecEnhancement) { - getMainSpec().from(sourcePath, c << preserveSymlinks) - } - this - } - - @Override - Rpm into(Object destPath, Closure configureClosure) { - use(CopySpecEnhancement) { - getMainSpec().into(destPath, configureClosure) - } - this - } - - @Override - Rpm exclude(Closure excludeSpec) { - use(CopySpecEnhancement) { - getMainSpec().exclude(excludeSpec) - } - this - } - - @Override - Rpm filter(Closure closure) { - use(CopySpecEnhancement) { - getMainSpec().filter(closure) - } - this - } - - @Override - Rpm rename(Closure closure) { - use(CopySpecEnhancement) { - getMainSpec().rename(closure) - } - this - } - - @Input - @Optional - List getAllConfigurationPaths() { - getConfigurationPaths() + (projectPackagingExtension?.getConfigurationPaths()?: []) - } - - @Input - @Optional - List getAllPreInstallCommands() { - getPreInstallCommands() + (projectPackagingExtension?.getPreInstallCommands() ?: []) - } - - @Input - @Optional - List getAllPostInstallCommands() { - getPostInstallCommands() + (projectPackagingExtension?.getPostInstallCommands() ?: []) - } - - @Input - @Optional - List getAllPreUninstallCommands() { - getPreUninstallCommands() + (projectPackagingExtension?.getPreUninstallCommands() ?: []) - } - - @Input - @Optional - List getAllPostUninstallCommands() { - getPostUninstallCommands() + (projectPackagingExtension?.getPostUninstallCommands() ?: []) - } - - @Input - @Optional - List getAllPreTransCommands() { - getPreTransCommands() + projectPackagingExtension?.getPreTransCommands() - } - - @Input - @Optional - List getAllPostTransCommands() { - getPostTransCommands() + projectPackagingExtension?.getPostTransCommands() - } - - @Input - @Optional - List getAllCommonCommands() { - getCommonCommands() + projectPackagingExtension?.getCommonCommands() - } - - @Input - @Optional - List getAllSupplementaryControlFiles() { - getSupplementaryControlFiles() + (projectPackagingExtension?.getSupplementaryControlFiles() ?: []) - } - - @Input - @Optional - List getAllLinks() { - if (projectPackagingExtension) { - return getLinks() + projectPackagingExtension.getLinks() - } else { - return getLinks() - } - } - - @Input - @Optional - List getAllDependencies() { - if (projectPackagingExtension) { - return getDependencies() + projectPackagingExtension.getDependencies() - } else { - return getDependencies() - } - } - - @Input - @Optional - def getAllPrefixes() { - if (projectPackagingExtension) { - return (getPrefixes() + projectPackagingExtension.getPrefixes()).unique() - } else { - return getPrefixes() - } - } - - @Input - @Optional - List getAllProvides() { - if (projectPackagingExtension) { - return projectPackagingExtension.getProvides() + getProvides() - } else { - return getProvides() - } - } - - @Input - @Optional - List getAllObsoletes() { - if (projectPackagingExtension) { - return getObsoletes() + projectPackagingExtension.getObsoletes() - } else { - return getObsoletes() - } - } - - @Input - @Optional - List getAllConflicts() { - if (projectPackagingExtension) { - return getConflicts() + projectPackagingExtension.getConflicts() - } else { - return getConflicts() - } - } - - /** - * Defines input files annotation with @SkipWhenEmpty as a workaround to force building the archive even if no - * from clause is declared. Without this method the task would be marked UP-TO-DATE - the actual archive creation - * would be skipped. - * - * The provided file collection is not supposed to be used or modified anywhere else in the task. - * - * @return Collection of files - */ - @InputFiles - @SkipWhenEmpty - private final FileCollection getFakeFiles() { - project.files('fake') - } - - void applyConventions() { - ConventionMapping mapping = ((IConventionAware) this).getConventionMapping() - - mapping.map('packageName', { - projectPackagingExtension?.getPackageName()?:getArchiveBaseName().getOrNull()?:'test' - }) - mapping.map('version', { - sanitizeVersion(projectPackagingExtension?.getVersion()?:project.getVersion().toString()) - }) - mapping.map('release', { - projectPackagingExtension?.getRelease()?:'' - }) - mapping.map('epoch', { - projectPackagingExtension?.getEpoch()?:0 - }) - mapping.map('signingKeyId', { - projectPackagingExtension?.getSigningKeyId() - }) - mapping.map('signingKeyPassphrase', { - projectPackagingExtension?.getSigningKeyPassphrase() - }) - mapping.map('signingKeyRing', { - projectPackagingExtension?.getSigningKeyRing() - }) - mapping.map('signingKeyHashAlgo', { - projectPackagingExtension?.getSigningKeyHashAlgo() - }) - mapping.map('user', { - projectPackagingExtension?.getUser()?:getPackager() - }) - mapping.map('maintainer', { - projectPackagingExtension?.getMaintainer()?:getPackager() - }) - mapping.map('uploaders', { - projectPackagingExtension?.getUploaders()?:getPackager() - }) - mapping.map('permissionGroup', { - projectPackagingExtension?.getPermissionGroup()?:'' - }) - mapping.map('packageGroup', { - projectPackagingExtension?.getPackageGroup() - }) - mapping.map('buildHost', { - projectPackagingExtension?.getBuildHost()?: getLocalHostName() - }) - mapping.map('summary', { - projectPackagingExtension?.getSummary()?:getPackageName() - }) - mapping.map('packageDescription', { - String packageDescription = projectPackagingExtension?.getPackageDescription()?:project.getDescription() - packageDescription ?: '' - }) - mapping.map('license', { - projectPackagingExtension?.getLicense()?:'' - }) - mapping.map('packager', { - projectPackagingExtension?.getPackager()?:System.getProperty('user.name', '') - }) - mapping.map('distribution', { - projectPackagingExtension?.getDistribution()?:'' - }) - mapping.map('vendor', { - projectPackagingExtension?.getVendor()?:'' - }) - mapping.map('url', { - projectPackagingExtension?.getUrl()?:'' - }) - mapping.map('sourcePackage', { - projectPackagingExtension?.getSourcePackage()?:'' - }) - mapping.map('createDirectoryEntry', { - projectPackagingExtension?.getCreateDirectoryEntry()?:false - }) - mapping.map('priority', { - projectPackagingExtension?.getPriority()?:'optional' - }) - mapping.map('preInstall', { - projectPackagingExtension?.getPreInstall() - }) - mapping.map('postInstall', { - projectPackagingExtension?.getPostInstall() - }) - mapping.map('preUninstall', { - projectPackagingExtension?.getPreUninstall() - }) - mapping.map('postUninstall', { - projectPackagingExtension?.getPostUninstall() - }) - mapping.map('fileType', { - projectPackagingExtension?.getFileType() - }) - mapping.map('addParentDirs', { - projectPackagingExtension?.getAddParentDirs()?:true - }) - mapping.map('arch', { - projectPackagingExtension?.arch?:Architecture.NOARCH - }) - mapping.map('os', { - projectPackagingExtension?.os?:Os.UNKNOWN - }) - mapping.map('type', { - projectPackagingExtension?.type?:PackageType.BINARY - }) - mapping.map('prefixes', { - projectPackagingExtension?.getPrefixes()?:[] - }) - mapping.map('archiveName', { - constructArchiveFile() - }) - mapping.map('archivePath', { - determineArchivePath() - }) - mapping.map('archiveFile', { - determineArchiveFile() - }) - } - - void prefixes(String... addPrefixes) { - systemPackagingExtension.prefixes.addAll(addPrefixes) - } - - List getPrefixes() { - systemPackagingExtension.prefixes - } - - void setChangeLogFile(Path changeLogFile) { - this.changeLogFile = changeLogFile - } - - Path getChangeLogFile() { - changeLogFile - } - - Provider determineArchiveFile() { - Property regularFile = objectFactory.fileProperty() - regularFile.set(new DestinationFile(new File(getDestinationDirectory().get().asFile.path, constructArchiveFile()))) - regularFile - } - - File determineArchivePath() { - determineArchiveFile().get().asFile - } - - String constructArchiveFile() { - String name = GUtil.elvis(getPackageName(), "") - name += maybe(name, '-', getVersion()) - name += maybe(name, '-', getRelease()) - name += maybe(name, '.', getArch().name().toLowerCase()) - String extension = archiveExtension.getOrNull() - name += GUtil.isTrue(extension) ? "." + extension : "" - name - } - - static String sanitizeVersion(String version) { - version.replaceAll(/\+.*/, '').replaceAll(/-/, '~') - } - - static String getLocalHostName() { - try { - return InetAddress.localHost.hostName - } catch (UnknownHostException ignore) { - return "unknown" - } - } - - static String maybe(@Nullable String prefix, String delimiter, @Nullable String value) { - if (GUtil.isTrue(value)) { - if (GUtil.isTrue(prefix)) { - return delimiter.concat(value) - } else { - return value - } - } - "" - } - - static class DestinationFile implements RegularFile { - private final File file - - DestinationFile(File file) { - this.file = file - } - - String toString() { - return this.file.toString() - } - - @Override - File getAsFile() { - return this.file - } - } -} diff --git a/gradle-plugin-rpm/src/main/groovy/org/xbib/gradle/plugin/rpm/RpmCopyAction.groovy b/gradle-plugin-rpm/src/main/groovy/org/xbib/gradle/plugin/rpm/RpmCopyAction.groovy deleted file mode 100755 index 760a593..0000000 --- a/gradle-plugin-rpm/src/main/groovy/org/xbib/gradle/plugin/rpm/RpmCopyAction.groovy +++ /dev/null @@ -1,318 +0,0 @@ -package org.xbib.gradle.plugin.rpm - -import org.gradle.api.internal.file.CopyActionProcessingStreamAction -import org.gradle.api.internal.file.copy.CopyAction -import org.gradle.api.internal.file.copy.CopyActionProcessingStream -import org.gradle.api.internal.file.copy.CopySpecInternal -import org.gradle.api.internal.file.copy.CopySpecResolver -import org.gradle.api.internal.file.copy.DefaultCopySpec -import org.gradle.api.internal.file.copy.DefaultFileCopyDetails -import org.gradle.api.internal.file.copy.FileCopyDetailsInternal -import org.gradle.api.logging.Logger -import org.gradle.api.logging.Logging -import org.gradle.api.tasks.WorkResult -import org.gradle.api.tasks.WorkResults -import org.gradle.internal.UncheckedException -import org.xbib.gradle.plugin.rpm.validation.RpmTaskPropertiesValidator -import org.xbib.rpm.RpmBuilder -import org.xbib.rpm.header.HeaderTag -import org.xbib.rpm.payload.Directive - -import java.lang.reflect.Field -import java.nio.file.Files -import java.nio.file.Path -import java.nio.file.StandardOpenOption - -/** - * - */ -class RpmCopyAction implements CopyAction { - - private static final Logger logger = Logging.getLogger(RpmCopyAction.class) - - Rpm task - - Path tempDir - - RpmBuilder builder - - boolean includeStandardDefines = true - - private final RpmTaskPropertiesValidator rpmTaskPropertiesValidator = new RpmTaskPropertiesValidator() - - private RpmFileVisitorStrategy rpmFileVisitorStrategy - - RpmCopyAction(Rpm task) { - this.task = task - rpmTaskPropertiesValidator.validate(task) - } - - WorkResult execute(CopyActionProcessingStream stream) { - try { - startVisit(this) - stream.process(new StreamAction()) - endVisit() - } catch (Exception e) { - UncheckedException.throwAsUncheckedException(e) - } - WorkResults.didWork(true) - } - - private class StreamAction implements CopyActionProcessingStreamAction { - - @Override - void processFile(FileCopyDetailsInternal details) { - def ourSpec = extractSpec(details) - if (details.isDirectory()) { - visitDir(details, ourSpec) - } else { - visitFile(details, ourSpec) - } - } - } - - void endVisit() { - for (Link link : task.getAllLinks()) { - logger.debug "adding link {} -> {}", link.path, link.target - addLink link - } - for (Dependency dep : task.getAllDependencies()) { - logger.debug "adding dependency on {} {}", dep.packageName, dep.version - addDependency dep - } - for (Dependency obsolete: task.getAllObsoletes()) { - logger.debug "adding obsoletes on {} {}", obsolete.packageName, obsolete.version - addObsolete obsolete - } - for (Dependency conflict : task.getAllConflicts()) { - logger.debug "adding conflicts on {} {}", conflict.packageName, conflict.version - addConflict conflict - } - for (Dependency provides : task.getAllProvides()) { - logger.debug "adding provides on {} {}", provides.packageName, provides.version - addProvides(provides) - } - task.directories.each { directory -> - logger.debug "adding directory {}", directory.path - addDirectory(directory) - } - end() - } - - static String concat(Collection scripts) { - String shebang - StringBuilder result = new StringBuilder() - scripts.each { script -> - script?.eachLine { line -> - if (line.matches('^#!.*$')) { - if (!shebang) { - shebang = line - } else if (line != shebang) { - throw new IllegalArgumentException("mismatching #! script lines") - } - } else { - result.append line - result.append "\n" - } - } - } - if (shebang) { - result.insert(0, shebang + "\n") - } - result.toString() - } - - static CopySpecInternal extractSpec(FileCopyDetailsInternal fileDetails) { - if (fileDetails instanceof DefaultFileCopyDetails) { - def startingClass = fileDetails.getClass() - while( startingClass != null && startingClass != DefaultFileCopyDetails) { - startingClass = startingClass.superclass - } - Field specField = startingClass.getDeclaredField('specResolver') - specField.setAccessible(true) - CopySpecResolver specResolver = specField.get(fileDetails) - Field field = DefaultCopySpec.DefaultCopySpecResolver.class.getDeclaredField('this$0') - field.setAccessible(true) - CopySpecInternal spec = field.get(specResolver) - return spec - } else { - return null - } - } - - Path extractPath(FileCopyDetailsInternal fileDetails) { - Path path - try { - path = fileDetails.getFile().toPath() - } catch (UnsupportedOperationException uoe) { - path = tempDir.resolve(fileDetails.path) - fileDetails.copyTo(path.toFile()) - } - path - } - - void startVisit(CopyAction action) { - tempDir = task.getTemporaryDir().toPath() - if (!task.getVersion()) { - throw new IllegalArgumentException('RPM requires a version string') - } - if ([task.preInstall, task.postInstall, task.preUninstall, task.postUninstall].any()) { - logger.warn('at least one of (preInstall|postInstall|preUninstall|postUninstall) is defined ' + - 'and will be ignored for RPM builds') - } - builder = new RpmBuilder() - builder.setPackage task.packageName, task.version, task.release, task.epoch - builder.setType task.type - builder.setPlatform task.arch, task.os - builder.setGroup task.packageGroup - builder.setBuildHost task.buildHost - builder.setSummary task.summary - builder.setDescription task.packageDescription ?: '' - builder.setLicense task.license - builder.setPackager task.packager - builder.setDistribution task.distribution - builder.setVendor task.vendor - builder.setUrl task.url - if (task.allPrefixes) { - builder.setPrefixes(task.allPrefixes as String[]) - } - if (task.getSigningKeyId() && task.getSigningKeyPassphrase() && task.getSigningKeyRing()) { - builder.setPrivateKeyId task.getSigningKeyId() - builder.setPrivateKeyPassphrase task.getSigningKeyPassphrase() - builder.setPrivateKeyRing task.getSigningKeyRing() - builder.setPrivateKeyHashAlgo task.getSigningKeyHashAlgo() - } - String sourcePackage = task.sourcePackage - if (!sourcePackage) { - sourcePackage = builder.defaultSourcePackage - } - builder.addHeaderEntry HeaderTag.SOURCERPM, sourcePackage - builder.setPreInstall task.getPreInstall() - builder.setPostInstall task.getPostInstall() - builder.setPreUninstall task.getPreUninstall() - builder.setPostUninstall task.getPostUninstall() - builder.setPreTrans task.getPreTrans() - builder.setPostTrans task.getPostTrans() - builder.setPreInstallValue(scriptWithUtils(task.allCommonCommands, task.allPreInstallCommands)) - builder.setPostInstallValue(scriptWithUtils(task.allCommonCommands, task.allPostInstallCommands)) - builder.setPreUninstallValue(scriptWithUtils(task.allCommonCommands, task.allPreUninstallCommands)) - builder.setPostUninstallValue(scriptWithUtils(task.allCommonCommands, task.allPostUninstallCommands)) - builder.setPreTransValue(scriptWithUtils(task.allCommonCommands, task.allPreTransCommands)) - builder.setPostTransValue(scriptWithUtils(task.allCommonCommands, task.allPostTransCommands)) - if (((Rpm) task).changeLogFile != null) { - builder.addChangelog(((Rpm) task).changeLogFile) - } - rpmFileVisitorStrategy = new RpmFileVisitorStrategy(builder) - } - - void visitFile(FileCopyDetailsInternal fileDetails, def specToLookAt) { - logger.debug "adding file {}", fileDetails.relativePath.pathString - def inputFile = extractPath(fileDetails) - EnumSet fileType = lookup(specToLookAt, 'fileType') - String user = lookup(specToLookAt, 'user') ?: task.user - String group = lookup(specToLookAt, 'permissionGroup') ?: task.permissionGroup - int fileMode = lookup(specToLookAt, 'fileMode') ?: fileDetails.mode - def specAddParentsDir = lookup(specToLookAt, 'addParentDirs') - boolean addParentsDir = specAddParentsDir!=null ? specAddParentsDir : task.addParentDirs - rpmFileVisitorStrategy.addFile(fileDetails, inputFile, fileMode, -1, fileType, user, group, addParentsDir) - } - - void visitDir(FileCopyDetailsInternal dirDetails, def specToLookAt) { - if (specToLookAt == null) { - logger.info("Got an empty spec from ${dirDetails.class.name} for ${dirDetails.path}/${dirDetails.name}") - return - } - // Have to take booleans specially, since they would fail an elvis operator if set to false - def specCreateDirectoryEntry = lookup(specToLookAt, 'createDirectoryEntry') - boolean createDirectoryEntry = specCreateDirectoryEntry!=null ? specCreateDirectoryEntry : task.createDirectoryEntry - def specAddParentsDir = lookup(specToLookAt, 'addParentDirs') - boolean addParentsDir = specAddParentsDir != null ? specAddParentsDir : task.addParentDirs - if (createDirectoryEntry) { - logger.debug 'adding directory {}', dirDetails.relativePath.pathString - int dirMode = lookup(specToLookAt, 'dirMode') ?: dirDetails.mode - List directiveList = (lookup(specToLookAt, 'fileType') ?: task.fileType) as List - EnumSet directive = makeDirective(directiveList) - String user = lookup(specToLookAt, 'user') ?: task.user - String group = lookup(specToLookAt, 'permissionGroup') ?: task.permissionGroup - rpmFileVisitorStrategy.addDirectory(dirDetails, dirMode, directive, user, group, addParentsDir) - } - } - - protected void addLink(Link link) { - builder.addLink link.path, link.target, link.permissions - } - - protected void addDependency(Dependency dep) { - builder.addDependency(dep.packageName, dep.flag, dep.version) - } - - protected void addConflict(Dependency dep) { - builder.addConflicts(dep.packageName, dep.flag, dep.version) - } - - protected void addObsolete(Dependency dep) { - builder.addObsoletes(dep.packageName, dep.flag, dep.version) - } - - protected void addProvides(Dependency dep) { - builder.addProvides(dep.packageName, dep.version, dep.flag) - } - - protected void addDirectory(Directory directory) { - def user = directory.user ? directory.user : task.user - def permissionGroup = directory.permissionGroup ? directory.permissionGroup : task.permissionGroup - builder.addDirectory(directory.path, directory.permissions, null, user, permissionGroup, directory.addParents) - } - - protected void end() { - Path path = task.archiveFile.get().asFile.toPath() - Files.createDirectories(path.parent) - Files.newByteChannel(path, StandardOpenOption.WRITE, StandardOpenOption.CREATE, - StandardOpenOption.TRUNCATE_EXISTING).withCloseable { ch -> - builder.build(ch) - } - logger.info 'created RPM archive {}', path - } - - String standardScriptDefines() { - includeStandardDefines ? - String.format(" RPM_ARCH=%s \n RPM_OS=%s \n RPM_PACKAGE_NAME=%s \n RPM_PACKAGE_VERSION=%s \n RPM_PACKAGE_RELEASE=%s \n\n", - task.arch?.toString()?.toLowerCase()?:'', - task.os?.toString()?.toLowerCase()?: '', - task.getPackageName(), - task.getVersion(), - task.getRelease()) : null - } - - String scriptWithUtils(List utils, List scripts) { - def list = [] - def stdDefines = standardScriptDefines() - if (stdDefines) { - list.add(stdDefines) - } - list.addAll(utils) - list.addAll(scripts) - concat(list) - } - - static T lookup(def specToLookAt, String propertyName) { - if (specToLookAt?.metaClass?.hasProperty(specToLookAt, propertyName) != null) { - def prop = specToLookAt.metaClass.getProperty(specToLookAt, propertyName) - if (prop instanceof MetaBeanProperty) { - return prop?.getProperty(specToLookAt) as T - } else { - return prop as T - } - } else { - return null - } - } - - static EnumSet makeDirective(List strings) { - EnumSet set = EnumSet.of(Directive.NONE) - for (String string : strings) { - set.add(Directive.valueOf(string)) - } - set - } -} diff --git a/gradle-plugin-rpm/src/main/groovy/org/xbib/gradle/plugin/rpm/RpmFileVisitorStrategy.groovy b/gradle-plugin-rpm/src/main/groovy/org/xbib/gradle/plugin/rpm/RpmFileVisitorStrategy.groovy deleted file mode 100644 index 43c64ce..0000000 --- a/gradle-plugin-rpm/src/main/groovy/org/xbib/gradle/plugin/rpm/RpmFileVisitorStrategy.groovy +++ /dev/null @@ -1,63 +0,0 @@ -package org.xbib.gradle.plugin.rpm - -import org.xbib.rpm.RpmBuilder -import org.xbib.rpm.payload.Directive -import org.gradle.api.file.FileCopyDetails - -import java.nio.file.Files -import java.nio.file.Path -import java.nio.file.Paths - -class RpmFileVisitorStrategy { - - protected final RpmBuilder builder - - RpmFileVisitorStrategy(RpmBuilder builder) { - this.builder = builder - } - - void addFile(FileCopyDetails details, Path source, int mode, int dirmode, EnumSet directive, String uname, String gname, boolean addParents) { - try { - if (!Files.isSymbolicLink(Paths.get(details.file.parentFile.path))) { - addFileToBuilder(details, source, mode, dirmode, directive, uname, gname, addParents) - } - } - catch (UnsupportedOperationException e) { - // For file details that have filters, accessing the file throws this exception - addFileToBuilder(details, source, mode, dirmode, directive, uname, gname, addParents) - } - } - - void addDirectory(FileCopyDetails details, int permissions, EnumSet directive, String uname, - String gname, boolean addParents) { - try { - if (Files.isSymbolicLink(Paths.get(details.file.path))) { - addLinkToBuilder(details) - } - else { - addDirectoryToBuilder(details, permissions, directive, uname, gname, addParents) - } - } catch (UnsupportedOperationException e) { - // For file details that have filters, accessing the directory throws this exception - addDirectoryToBuilder(details, permissions, directive, uname, gname, addParents) - } - } - - protected void addFileToBuilder(FileCopyDetails details, Path source, int mode, int dirmode, EnumSet directive, String uname, String gname, boolean addParents) { - builder.addFile(getRootPath(details), source, mode, dirmode, directive, uname, gname, addParents) - } - - protected void addDirectoryToBuilder(FileCopyDetails details, int permissions, EnumSet directive, String uname, String gname, boolean addParents) { - builder.addDirectory(getRootPath(details), permissions, directive, uname, gname, addParents) - } - - private void addLinkToBuilder(FileCopyDetails details) { - Path path = Paths.get(details.file.path) - Path target = Files.readSymbolicLink(path) - builder.addLink(getRootPath(details), target.toFile().path) - } - - private static String getRootPath(FileCopyDetails details) { - "/${details.path}".toString() - } -} diff --git a/gradle-plugin-rpm/src/main/groovy/org/xbib/gradle/plugin/rpm/RpmPlugin.groovy b/gradle-plugin-rpm/src/main/groovy/org/xbib/gradle/plugin/rpm/RpmPlugin.groovy deleted file mode 100644 index 3e5ba41..0000000 --- a/gradle-plugin-rpm/src/main/groovy/org/xbib/gradle/plugin/rpm/RpmPlugin.groovy +++ /dev/null @@ -1,65 +0,0 @@ -package org.xbib.gradle.plugin.rpm - -import org.gradle.api.plugins.BasePlugin -import org.xbib.rpm.RpmBuilder -import org.xbib.rpm.lead.Architecture -import org.xbib.rpm.format.Flags -import org.xbib.rpm.lead.Os -import org.xbib.rpm.lead.PackageType -import org.xbib.rpm.payload.Directive -import org.gradle.api.Plugin -import org.gradle.api.Project - -import java.lang.reflect.Field -import java.lang.reflect.Modifier - -/** - * - */ -class RpmPlugin implements Plugin { - - void apply(Project project) { - project.plugins.apply(BasePlugin) - - project.ext.Rpm = Rpm.class - - RpmBuilder.metaClass.getDefaultSourcePackage() { - format.getLead().getName() + ".src.rpm" - } - - project.tasks.withType(Rpm) { Rpm task -> - applyAliases(task) - task.applyConventions() - } - } - - def static applyAliases(def dynamicObjectAware) { - aliasEnumValues(Architecture.values(), dynamicObjectAware) - aliasEnumValues(Os.values(), dynamicObjectAware) - aliasEnumValues(PackageType.values(), dynamicObjectAware) - aliasStaticInstances(Directive.class, dynamicObjectAware) - aliasStaticInstances(Flags.class, int.class, dynamicObjectAware) - } - - private static > void aliasEnumValues(T[] values, dynAware) { - for (T value : values) { - dynAware.metaClass."${value.name()}" = value - } - } - - private static void aliasStaticInstances(Class forClass, dynAware) { - aliasStaticInstances(forClass, forClass, dynAware) - } - - private static void aliasStaticInstances(Class forClass, Class ofClass, dynAware) { - for (Field field : forClass.fields) { - if (field.type == ofClass && hasModifier(field, Modifier.STATIC)) { - dynAware.metaClass."${field.name}" = field.get(null) - } - } - } - - private static boolean hasModifier(Field field, int modifier) { - (field.modifiers & modifier) == modifier - } -} diff --git a/gradle-plugin-rpm/src/main/groovy/org/xbib/gradle/plugin/rpm/SystemPackagingExtension.groovy b/gradle-plugin-rpm/src/main/groovy/org/xbib/gradle/plugin/rpm/SystemPackagingExtension.groovy deleted file mode 100755 index 4fc99a2..0000000 --- a/gradle-plugin-rpm/src/main/groovy/org/xbib/gradle/plugin/rpm/SystemPackagingExtension.groovy +++ /dev/null @@ -1,494 +0,0 @@ -package org.xbib.gradle.plugin.rpm - -import org.gradle.api.tasks.Input -import org.gradle.api.tasks.Optional -import org.xbib.rpm.lead.Architecture -import org.xbib.rpm.lead.Os -import org.xbib.rpm.lead.PackageType - -import java.nio.file.Files -import java.nio.file.Path -import java.nio.file.Paths - -/** - * Extension that can be used to configure RPM. - */ -class SystemPackagingExtension { - - @Input @Optional - String packageName - - @Input @Optional - String release - - @Input @Optional - String version - - @Input @Optional - Integer epoch - - @Input @Optional - String signingKeyPassphrase - - @Input @Optional - String signingKeyRing - - @Input @Optional - String signingKeyId - - @Input @Optional - String signingKeyHashAlgo - - @Input @Optional - String user - - @Input @Optional - String permissionGroup - - @Input @Optional - String packageGroup - - @Input @Optional - String buildHost - - @Input @Optional - String summary - - @Input @Optional - String packageDescription - - @Input @Optional - String license - - @Input @Optional - String packager - - @Input @Optional - String distribution - - @Input @Optional - String vendor - - @Input @Optional - String url - - @Input @Optional - String sourcePackage - - @Input @Optional - List fileType - - @Input @Optional - Boolean createDirectoryEntry - - @Input @Optional - Boolean addParentDirs - - //String archStr - - @Input @Optional - Architecture arch - //void setArch(Object arch) { - // archStr = (arch instanceof Architecture) ? arch.name() : arch.toString() - //} - - @Input @Optional - Os os - - @Input @Optional - PackageType type - - List prefixes = new ArrayList() - - def prefix(String prefixStr) { - prefixes << prefixStr - return this - } - - @Input @Optional - Integer uid - - @Input @Optional - Integer gid - - @Input @Optional - String maintainer - - @Input @Optional - String uploaders - - @Input @Optional - String priority - - @Input @Optional - final List supplementaryControlFiles = [] - - def supplementaryControl(Object file) { - supplementaryControlFiles << file - return this - } - - @Input @Optional - String preInstall - - @Input @Optional - String postInstall - - @Input @Optional - String preUninstall - - @Input @Optional - String postUninstall - - @Input @Optional - String preTrans - - @Input @Optional - String postTrans - - final List configurationPaths = [] - - final List preInstallCommands = [] - - final List postInstallCommands = [] - - final List preUninstallCommands = [] - - final List postUninstallCommands = [] - - final List preTransCommands = [] - - final List postTransCommands = [] - - final List commonCommands = [] - - def setInstallUtils(Path script) { - installUtils(script) - } - - def installUtils(String script) { - commonCommands << script - return this - } - - def installUtils(Path script) { - commonCommands << script - return this - } - - def setConfigurationPath(String script) { - configurationPath(script) - } - - def configurationPath(String path) { - configurationPaths << path - this - } - - def setPreInstall(String script) { - preInstall(script) - } - def setPreInstall(Path script) { - preInstall(script) - } - def preInstall(String script) { - preInstall(Paths.get(script)) - } - def preInstall(Path script) { - if (Files.exists(script)) { - preInstallValue(script.text) - } - this - } - def preInstallValue(String content) { - preInstallCommands << content - this - } - - def setPostInstall(String script) { - postInstall(script) - } - def setPostInstall(Path script) { - postInstall(script) - } - def postInstall(String script) { - postInstall(Paths.get(script)) - } - def postInstall(Path script) { - if (Files.exists(script)) { - postInstallValue(script.text) - } - this - } - def postInstallValue(String content) { - postInstallCommands << content - this - } - - def setPreUninstall(String script) { - preUninstall(script) - } - def setPreUninstall(Path script) { - preUninstall(script) - } - def preUninstall(String script) { - preUninstall(Paths.get(script)) - } - def preUninstall(Path script) { - if (Files.exists(script)) { - preUninstallValue(script.text) - } - this - } - def preUninstallValue(String script) { - preUninstallCommands << script - this - } - - def setPostUninstall(String script) { - postUninstall(script) - } - def setPostUninstall(Path script) { - postUninstall(script) - } - def postUninstall(String script) { - postUninstall(Paths.get(script)) - } - def postUninstall(Path script) { - if (Files.exists(script)) { - postUninstallValue(script.text) - } - this - } - def postUninstallValue(String content) { - postUninstallCommands << content - this - } - - def setPreTrans(String script) { - preTrans(script) - } - def setPreTrans(Path script) { - preTrans(script) - } - def preTrans(String script) { - preTrans(Paths.get(script)) - } - def preTrans(Path script) { - if (Files.exists(script)) { - preTransValue(script.text) - } - this - } - def preTransValue(String script) { - preTransCommands << script - this - } - - def setPostTrans(String script) { - postTrans(script) - } - def setPostTrans(Path script) { - postTrans(script) - } - def postTrans(String script) { - postTrans(Paths.get(script)) - } - def postTrans(Path script) { - if (Files.exists(script)) { - postTransValue(script.text) - } - return this - } - def postTransValue(String script) { - postTransCommands << script - return this - } - - List links = [] - - Link link(String path, String target) { - link(path, target, -1) - } - - Link link(String path, String target, int permissions) { - Link link = new Link() - link.path = path - link.target = target - link.permissions = permissions - links.add(link) - link - } - - List dependencies = [] - - List obsoletes = [] - - List conflicts = [] - - List recommends = [] - - List suggests = [] - - List enhances = [] - - List preDepends = [] - - List breaks = [] - - List replaces = [] - - List provides = [] - - Dependency requires(String packageName, String version, int flag) { - def dep = new Dependency(packageName, version, flag) - dependencies.add(dep) - dep - } - - Dependency requires(String packageName, String version){ - requires(packageName, version, 0) - } - - Dependency requires(String packageName) { - requires(packageName, '', 0) - } - - Dependency obsoletes(String packageName, String version, int flag) { - def dep = new Dependency(packageName, version, flag) - obsoletes.add(dep) - dep - } - - Dependency obsoletes(String packageName) { - obsoletes(packageName, '', 0) - } - - Dependency conflicts(String packageName, String version, int flag) { - def dep = new Dependency(packageName, version, flag) - conflicts.add(dep) - dep - } - - Dependency conflicts(String packageName) { - conflicts(packageName, '', 0) - } - - Dependency recommends(String packageName, String version, int flag) { - def dep = new Dependency(packageName, version, flag) - recommends.add(dep) - dep - } - - Dependency recommends(String packageName) { - recommends(packageName, '', 0) - } - - Dependency suggests(String packageName, String version, int flag) { - def dep = new Dependency(packageName, version, flag) - suggests.add(dep) - dep - } - - Dependency suggests(String packageName) { - suggests(packageName, '', 0) - } - - Dependency enhances(String packageName, String version, int flag) { - def dep = new Dependency(packageName, version, flag) - enhances.add(dep) - dep - } - - Dependency enhances(String packageName) { - enhances(packageName, '', 0) - } - - Dependency preDepends(String packageName, String version, int flag) { - def dep = new Dependency(packageName, version, flag) - preDepends.add(dep) - dep - } - - Dependency preDepends(String packageName) { - preDepends(packageName, '', 0) - } - - Dependency breaks(String packageName, String version, int flag) { - def dep = new Dependency(packageName, version, flag) - breaks.add(dep) - dep - } - - Dependency breaks(String packageName) { - breaks(packageName, '', 0) - } - - Dependency replaces(String packageName, String version, int flag) { - def dep = new Dependency(packageName, version, flag) - replaces.add(dep) - dep - } - - Dependency replaces(String packageName) { - replaces(packageName, '', 0) - } - - Dependency provides(String packageName, String version, int flag) { - def dep = new Dependency(packageName, version, flag) - provides.add(dep) - dep - } - - Dependency provides(String packageName) { - provides(packageName, '', 0) - } - - List directories = [] - - Directory directory(String path) { - Directory directory = directory(path, -1) - directories << directory - directory - } - - Directory directory(String path, boolean addParents) { - Directory directory = new Directory(path: path, addParents: addParents) - directories << directory - directory - } - - Directory directory(String path, int permissions) { - Directory directory = new Directory(path: path, permissions: permissions) - directories << directory - directory - } - - Directory directory(String path, int permissions, boolean addParents) { - Directory directory = new Directory(path: path, permissions: permissions, addParents: addParents) - directories << directory - directory - } - - Directory directory(String path, int permissions, String user, String permissionGroup) { - Directory directory = new Directory(path: path, permissions: permissions, user: user, - permissionGroup: permissionGroup) - directories << directory - directory - } - - Directory directory(String path, int permissions, String user, String permissionGroup, boolean addParents) { - Directory directory = new Directory(path: path, permissions: permissions, user: user, - permissionGroup: permissionGroup, addParents: addParents) - directories << directory - directory - } - - private static IllegalStateException multipleFilesDefined(String fileName) { - new IllegalStateException("Cannot specify more than one $fileName File") - } - - private static IllegalStateException conflictingDefinitions(String type) { - new IllegalStateException("Cannot specify $type File and $type Commands") - } -} diff --git a/gradle-plugin-rpm/src/main/groovy/org/xbib/gradle/plugin/rpm/validation/RpmPackageNameAttributeValidator.groovy b/gradle-plugin-rpm/src/main/groovy/org/xbib/gradle/plugin/rpm/validation/RpmPackageNameAttributeValidator.groovy deleted file mode 100644 index f06c09e..0000000 --- a/gradle-plugin-rpm/src/main/groovy/org/xbib/gradle/plugin/rpm/validation/RpmPackageNameAttributeValidator.groovy +++ /dev/null @@ -1,18 +0,0 @@ -package org.xbib.gradle.plugin.rpm.validation - -class RpmPackageNameAttributeValidator implements SystemPackagingAttributeValidator { - - @Override - boolean validate(String packageName) { - matchesExpectedCharacters(packageName) - } - - private static boolean matchesExpectedCharacters(String packageName) { - packageName ==~ /[a-zA-Z0-9-._+]+/ - } - - @Override - String getErrorMessage(String attribute) { - "Invalid package name '$attribute' - a valid package name must only contain [a-zA-Z0-9-._+]" - } -} diff --git a/gradle-plugin-rpm/src/main/groovy/org/xbib/gradle/plugin/rpm/validation/RpmTaskPropertiesValidator.groovy b/gradle-plugin-rpm/src/main/groovy/org/xbib/gradle/plugin/rpm/validation/RpmTaskPropertiesValidator.groovy deleted file mode 100644 index f756523..0000000 --- a/gradle-plugin-rpm/src/main/groovy/org/xbib/gradle/plugin/rpm/validation/RpmTaskPropertiesValidator.groovy +++ /dev/null @@ -1,16 +0,0 @@ -package org.xbib.gradle.plugin.rpm.validation - -import org.xbib.gradle.plugin.rpm.Rpm -import org.gradle.api.InvalidUserDataException - -class RpmTaskPropertiesValidator implements SystemPackagingTaskPropertiesValidator { - - private final SystemPackagingAttributeValidator packageNameValidator = new RpmPackageNameAttributeValidator() - - @Override - void validate(Rpm task) { - if (!packageNameValidator.validate(task.getPackageName())) { - throw new InvalidUserDataException(packageNameValidator.getErrorMessage(task.getPackageName())) - } - } -} diff --git a/gradle-plugin-rpm/src/main/groovy/org/xbib/gradle/plugin/rpm/validation/SystemPackagingAttributeValidator.groovy b/gradle-plugin-rpm/src/main/groovy/org/xbib/gradle/plugin/rpm/validation/SystemPackagingAttributeValidator.groovy deleted file mode 100644 index e5d3909..0000000 --- a/gradle-plugin-rpm/src/main/groovy/org/xbib/gradle/plugin/rpm/validation/SystemPackagingAttributeValidator.groovy +++ /dev/null @@ -1,8 +0,0 @@ -package org.xbib.gradle.plugin.rpm.validation - -interface SystemPackagingAttributeValidator { - - boolean validate(String attribute) - - String getErrorMessage(String attribute) -} diff --git a/gradle-plugin-rpm/src/main/groovy/org/xbib/gradle/plugin/rpm/validation/SystemPackagingTaskPropertiesValidator.groovy b/gradle-plugin-rpm/src/main/groovy/org/xbib/gradle/plugin/rpm/validation/SystemPackagingTaskPropertiesValidator.groovy deleted file mode 100644 index 0f3cea3..0000000 --- a/gradle-plugin-rpm/src/main/groovy/org/xbib/gradle/plugin/rpm/validation/SystemPackagingTaskPropertiesValidator.groovy +++ /dev/null @@ -1,8 +0,0 @@ -package org.xbib.gradle.plugin.rpm.validation - -import org.gradle.api.Task - -interface SystemPackagingTaskPropertiesValidator { - - void validate(T task) -} diff --git a/gradle-plugin-rpm/src/main/resources/META-INF/gradle-plugins/org.xbib.gradle.plugin.rpm.properties b/gradle-plugin-rpm/src/main/resources/META-INF/gradle-plugins/org.xbib.gradle.plugin.rpm.properties deleted file mode 100644 index 677797c..0000000 --- a/gradle-plugin-rpm/src/main/resources/META-INF/gradle-plugins/org.xbib.gradle.plugin.rpm.properties +++ /dev/null @@ -1 +0,0 @@ -implementation-class=org.xbib.gradle.plugin.rpm.RpmPlugin \ No newline at end of file diff --git a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/RpmFullTest.groovy b/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/RpmFullTest.groovy new file mode 100644 index 0000000..f49e012 --- /dev/null +++ b/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/RpmFullTest.groovy @@ -0,0 +1,336 @@ +package org.xbib.gradle.plugin + +import org.gradle.api.Project +import org.gradle.testfixtures.ProjectBuilder +import org.junit.jupiter.api.BeforeEach +import org.junit.jupiter.api.Test +import org.xbib.rpm.RpmReader +import org.xbib.rpm.RpmReaderResult +import org.xbib.rpm.format.Format +import org.xbib.rpm.header.IntegerList +import org.xbib.rpm.header.StringList + +import java.nio.charset.StandardCharsets +import java.nio.file.Paths + +import static org.hamcrest.CoreMatchers.is +import static org.hamcrest.MatcherAssert.assertThat +import static org.junit.jupiter.api.Assertions.assertEquals +import static org.junit.jupiter.api.Assertions.assertNotNull +import static org.xbib.rpm.format.Flags.EQUAL +import static org.xbib.rpm.format.Flags.GREATER +import static org.xbib.rpm.format.Flags.LESS +import static org.xbib.rpm.header.HeaderTag.CONFLICTFLAGS +import static org.xbib.rpm.header.HeaderTag.CONFLICTNAME +import static org.xbib.rpm.header.HeaderTag.CONFLICTVERSION +import static org.xbib.rpm.header.HeaderTag.DISTRIBUTION +import static org.xbib.rpm.header.HeaderTag.FILEGROUPNAME +import static org.xbib.rpm.header.HeaderTag.FILEMODES +import static org.xbib.rpm.header.HeaderTag.FILEUSERNAME +import static org.xbib.rpm.header.HeaderTag.OBSOLETEFLAGS +import static org.xbib.rpm.header.HeaderTag.OBSOLETENAME +import static org.xbib.rpm.header.HeaderTag.OBSOLETEVERSION +import static org.xbib.rpm.header.HeaderTag.PREFIXES +import static org.xbib.rpm.lead.Architecture.I386 +import static org.xbib.rpm.lead.Os.LINUX +import static org.xbib.rpm.lead.PackageType.BINARY +import static org.xbib.rpm.payload.CpioHeader.DIR +import static org.xbib.rpm.payload.CpioHeader.FILE + +class RpmFullTest { + + File projectDir + + @BeforeEach + void setup() { + projectDir = new File("build/testrpm") + projectDir.mkdirs() + } + + + @Test + void testCopySpec() { + File bananaFile = new File(projectDir, 'test/banana') + bananaFile.parentFile.mkdirs() + bananaFile.withWriter { + out -> out.write('banana') + } + File srcDir = new File(projectDir, 'src') + srcDir.mkdirs() + String fruit = 'apple' + File appleFile = new File(srcDir, fruit) + appleFile.withWriter { + out -> out.write(fruit) + } + Project project = ProjectBuilder.builder() + .withProjectDir(projectDir) + .build() + project.apply plugin: 'org.xbib.gradle.plugin.rpm' + project.task([type: Rpm], 'buildRpm', { + packageName = 'test' + packageVersion = '1.0.0' + packageRelease = '1' + addParentDirs = true + from(bananaFile.absoluteFile.parent) { + into '/usr/share/myproduct/etc' + } + from(appleFile.absoluteFile.parent) { + into '/usr/local/myproduct/bin' + } + }) + project.tasks.buildRpm.copy() + RpmReader rpmReader = new RpmReader() + RpmReaderResult result = rpmReader.read(project.tasks.buildRpm.outputs.files.first().toPath()) + assertEquals([ + './usr/local/myproduct', + './usr/local/myproduct/bin', + './usr/local/myproduct/bin/apple', + './usr/share/myproduct', + './usr/share/myproduct/etc', + './usr/share/myproduct/etc/banana'], result.files*.name) + assertEquals([DIR, DIR, FILE, DIR, DIR, FILE], result.files*.type) + } + + @Test + void testExplicitDirectory() { + Project project = ProjectBuilder.builder() + .withProjectDir(projectDir) + .build() + project.apply plugin: 'org.xbib.gradle.plugin.rpm' + project.task([type: Rpm], 'buildRpm', { + packageName = 'test' + packageVersion = '1.0.0' + packageRelease = '1' + directory '/lib' + }) + project.tasks.buildRpm.copy() + RpmReader rpmReader = new RpmReader() + RpmReaderResult result = rpmReader.read(project.tasks.buildRpm.outputs.files.first().toPath()) + assertNotNull(result.files.find { it.name == './lib' }) + } + + @Test + void testFilter() { + File appleFile = new File(projectDir, 'src/apple') + appleFile.mkdirs() + appleFile.withWriter { + out -> out.write('{{BASE}}/apple') + } + Project project = ProjectBuilder.builder() + .withProjectDir(projectDir) + .build() + project.apply plugin: 'org.xbib.gradle.plugin.rpm' + project.task([type: Rpm], 'buildRpm', { + packageName = 'test' + packageVersion = '1.0.0' + packageRelease = '1' + from(appleFile.absoluteFile.parent) { + into '/usr/local/myproduct/bin' + filter({ line -> + return line.replaceAll(/\{\{BASE\}\}/, '/usr/local/myproduct') + }) + } + }) + project.tasks.buildRpm.copy() + RpmReader rpmReader = new RpmReader() + RpmReaderResult result = rpmReader.read(project.tasks.buildRpm.outputs.files.first().toPath()) + def scannerApple = result.files.find { it.name == './usr/local/myproduct/bin/apple' } + assertEquals(StandardCharsets.UTF_8.decode(scannerApple.contents).toString(), '/usr/local/myproduct/apple') + } + + @Test + void testCustomCopySpec() { + File srcDir = new File(projectDir, 'src') + srcDir.mkdirs() + String fruit = 'apple' + File appleFile = new File(srcDir, fruit) + appleFile.withWriter { + out -> out.write(fruit) + } + Project project = ProjectBuilder.builder() + .withProjectDir(projectDir) + .build() + project.apply plugin: 'org.xbib.gradle.plugin.rpm' + def customCopySpec = project.copySpec { + into('lib') { + from 'src' + } + } + project.task([type: Rpm], 'buildRpm', { + packageName = 'copyspec' + packageVersion = '1.0.0' + packageRelease = '1' + with customCopySpec + }) + project.tasks.buildRpm.copy() + RpmReader rpmReader = new RpmReader() + RpmReaderResult result = rpmReader.read(project.tasks.buildRpm.outputs.files.first().toPath()) + assertThat(result.files*.name, is(['./lib/apple'])) + } + + @Test + void testFileMode() { + File srcDir1 = new File(projectDir, 'src1') + srcDir1.mkdirs() + new File(srcDir1, 'apple').withWriter { out -> out.write('apple') } + File srcDir2 = new File(projectDir, 'src2') + srcDir2.mkdirs() + new File(srcDir2, 'banana').withWriter { out -> out.write('banana') } + File srcDir3 = new File(projectDir, 'src3') + srcDir3.mkdirs() + new File(srcDir3, 'cherry').withWriter { out -> out.write('cherry') } + Project project = ProjectBuilder.builder() + .withProjectDir(projectDir) + .build() + project.apply plugin: 'org.xbib.gradle.plugin.rpm' + project.task([type: Rpm], 'buildRpm', { + packageName = 'fileMode' + packageVersion = '2.0' + packageRelease = '2' + into '/tiny' + fileMode 0555 + from(srcDir1.absoluteFile) { + // should be default group + } + from(srcDir2.absoluteFile) { + fileMode 0666 + } + from(srcDir3.absoluteFile) { + fileMode 0555 + } + }) + project.tasks.buildRpm.copy() + RpmReader rpmReader = new RpmReader() + RpmReaderResult result = rpmReader.read(project.tasks.buildRpm.outputs.files.first().toPath()) + assertEquals([FILE, FILE, FILE], result.files*.type) + assertEquals(['./tiny/apple', './tiny/banana', './tiny/cherry'], result.files*.name) + assertThat([(short)0100555, (short)0100666, (short)0100555], is(result.format.header.getEntry(FILEMODES).values)) + } + + @Test + void testUserGroup() { + File srcDir = new File(projectDir, 'src') + srcDir.mkdirs() + new File(srcDir, 'apple').withWriter { out -> out.write('apple') } + Project project = ProjectBuilder.builder() + .withProjectDir(projectDir) + .build() + project.apply plugin: 'org.xbib.gradle.plugin.rpm' + project.task([type: Rpm], 'buildRpm', { + packageName = 'userTest' + packageVersion = '2.0' + packageRelease = '2' + user = 'joerg' + group = 'users' + from srcDir.absoluteFile + }) + project.tasks.buildRpm.copy() + RpmReader rpmReader = new RpmReader() + RpmReaderResult result = rpmReader.read(project.tasks.buildRpm.outputs.files.first().toPath()) + assertEquals([FILE], result.files*.type) + StringList users = result.format.header.getEntry(FILEUSERNAME)?.values as StringList + assertThat(['joerg'], is(users)) + StringList groups = result.format.header.getEntry(FILEGROUPNAME)?.values as StringList + assertThat(['users'], is(groups)) + } + + @Test + void testPrefix() { + Project project = ProjectBuilder.builder() + .withProjectDir(projectDir) + .build() + project.apply plugin: 'org.xbib.gradle.plugin.rpm' + project.task([type: Rpm], 'buildRpm', { + packageName = 'prefixes' + packageVersion = '1.0.0' + packageRelease = '1' + prefixes = ['/opt'] + }) + project.tasks.buildRpm.copy() + RpmReader rpmReader = new RpmReader() + RpmReaderResult result = rpmReader.read(project.tasks.buildRpm.outputs.files.first().toPath()) + assertThat(StringList.of('/opt') as StringList, is(result.format.header.getEntry(PREFIXES).values)) + } + + @Test + void testConflictsAndObsoletes() { + Project project = ProjectBuilder.builder() + .withProjectDir(projectDir) + .build() + File srcDir = new File(projectDir, 'src') + srcDir.mkdirs() + project.apply plugin: 'org.xbib.gradle.plugin.rpm' + project.task([type: Rpm], 'buildRpm', { + packageName = 'testing' + packageVersion = '1.2' + packageRelease = '3' + packageType = BINARY + arch = I386 + os = LINUX + license = 'Free' + distribution = 'SuperSystem' + vendor = 'Super Associates, LLC' + url = 'http://www.example.com/' + obsoletes('blarg', '1.0', GREATER | EQUAL) + conflicts('blech') + conflicts('packageA', '1.0', LESS) + obsoletes('packageB', '2.2', GREATER) + obsoletes('packageC') + from(srcDir) + into '/opt/bleah' + }) + project.tasks.buildRpm.copy() + RpmReader rpmReader = new RpmReader() + def result = rpmReader.read(Paths.get(projectDir.toString(), 'build', 'distributions', 'testing-1.2-3.i386.rpm')) + Format format = result.format + StringList obsoletes = format.header.getEntry(OBSOLETENAME).values as StringList + StringList obsoleteVersions = format.header.getEntry(OBSOLETEVERSION).values as StringList + IntegerList obsoleteComparisons = format.header.getEntry(OBSOLETEFLAGS).values as IntegerList + StringList conflicts = format.header.getEntry(CONFLICTNAME).values as StringList + StringList conflictVersions = format.header.getEntry(CONFLICTVERSION).values as StringList + IntegerList conflictComparisons = format.header.getEntry(CONFLICTFLAGS).values as IntegerList + StringList distribution = format.header.getEntry(DISTRIBUTION).values as StringList + assertThat(StringList.of('SuperSystem') as StringList, is(distribution)) + assertThat('blarg', is(obsoletes.get(0))) + assertThat(GREATER | EQUAL, is(obsoleteComparisons.get(0))) + assertThat('blech', is(conflicts.get(0))) + assertThat('', is(conflictVersions.get(0))) + assertThat(0, is(conflictComparisons.get(0))) + assertThat('packageA', is(conflicts.get(1))) + assertThat('1.0', is(conflictVersions.get(1))) + assertThat(LESS, is(conflictComparisons.get(1))) + assertThat('packageB', is(obsoletes.get(1))) + assertThat('2.2', is(obsoleteVersions.get(1))) + assertThat(GREATER, is(obsoleteComparisons.get(1))) + assertThat('packageC', is(obsoletes.get(2))) + } + + @Test + void testFilesFromConfiguration() { + Project project = ProjectBuilder.builder() + .withProjectDir(projectDir) + .build() + project.apply plugin: 'org.xbib.gradle.plugin.rpm' + project.repositories { + mavenCentral() + } + project.configurations { + myconf + } + project.dependencies { + myconf "junit:junit:4.12" + } + project.task([type: Rpm], 'buildRpm', { + packageName = 'fromconfiguration' + packageVersion = '1.0.0' + packageRelease = '1' + into('/tmp') { + from project.configurations.myconf + } + }) + project.tasks.buildRpm.copy() + RpmReader rpmReader = new RpmReader() + RpmReaderResult result = rpmReader.read(project.tasks.buildRpm.outputs.files.first().toPath()) + assertThat(['./tmp/hamcrest-core-1.3.jar', './tmp/junit-4.12.jar'], is(result.files*.name)) + } +} diff --git a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/RpmPluginIntegrationTest.groovy b/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/RpmPluginIntegrationTest.groovy new file mode 100644 index 0000000..575175a --- /dev/null +++ b/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/RpmPluginIntegrationTest.groovy @@ -0,0 +1,57 @@ +package org.xbib.gradle.plugin + +import org.gradle.testkit.runner.BuildResult +import org.gradle.testkit.runner.GradleRunner +import org.gradle.testkit.runner.TaskOutcome +import org.junit.jupiter.api.BeforeEach +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.io.TempDir + +import static org.junit.jupiter.api.Assertions.assertEquals + +class RpmPluginIntegrationTest { + + private File projectDir + + private File settingsFile + + private File buildFile + + @BeforeEach + void setup(@TempDir File testProjectDir) throws IOException { + this.projectDir = testProjectDir + this.settingsFile = new File(testProjectDir, "settings.gradle") + this.buildFile = new File(testProjectDir, "build.gradle") + } + + @Test + void testPlugin() { + String settingsFileContent = ''' +rootProject.name = 'rpm-test' +''' + settingsFile.write(settingsFileContent) + String buildFileContent = ''' +plugins { + id 'org.xbib.gradle.plugin.rpm' +} + +rpm { + enabled = true +} + +task myRpm(type: Rpm) { + packageName = 'rpmIsUpToDate' + arch = org.xbib.rpm.lead.Architecture.NOARCH + os = org.xbib.rpm.lead.Os.LINUX +} +''' + buildFile.write(buildFileContent) + BuildResult result = GradleRunner.create() + .withProjectDir(projectDir) + .withArguments(":build", "--info") + .withPluginClasspath() + .forwardOutput() + .build() + assertEquals(TaskOutcome.UP_TO_DATE, result.task(":build").getOutcome()) + } +} diff --git a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/RpmScriptTest.groovy b/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/RpmScriptTest.groovy new file mode 100644 index 0000000..6fe77d3 --- /dev/null +++ b/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/RpmScriptTest.groovy @@ -0,0 +1,156 @@ +package org.xbib.gradle.plugin + +import org.gradle.api.Project +import org.gradle.testfixtures.ProjectBuilder +import org.junit.jupiter.api.BeforeEach +import org.junit.jupiter.api.Test +import org.xbib.rpm.RpmReader +import org.xbib.rpm.changelog.ChangelogParser +import org.xbib.rpm.format.Format +import org.xbib.rpm.header.EntryType +import org.xbib.rpm.header.IntegerList +import org.xbib.rpm.header.StringList +import org.xbib.rpm.header.entry.SpecEntry +import java.time.LocalDateTime +import java.time.ZoneOffset +import static org.hamcrest.MatcherAssert.assertThat +import static org.hamcrest.CoreMatchers.* +import static org.junit.jupiter.api.Assertions.assertEquals +import static org.junit.jupiter.api.Assertions.assertNotNull +import static org.xbib.rpm.header.HeaderTag.POSTINSCRIPT +import static org.xbib.rpm.header.HeaderTag.POSTTRANSSCRIPT +import static org.xbib.rpm.header.HeaderTag.POSTUNSCRIPT +import static org.xbib.rpm.header.HeaderTag.PREINSCRIPT +import static org.xbib.rpm.header.HeaderTag.PRETRANSSCRIPT +import static org.xbib.rpm.header.HeaderTag.PREUNSCRIPT +import static org.xbib.rpm.header.HeaderTag.CHANGELOGNAME +import static org.xbib.rpm.header.HeaderTag.CHANGELOGTEXT +import static org.xbib.rpm.header.HeaderTag.CHANGELOGTIME + +class RpmScriptTest { + + File projectDir + + @BeforeEach + void setup() { + projectDir = new File("build/testrpm") + projectDir.mkdirs() + } + + @Test + void testInstallScripts() { + Project project = ProjectBuilder.builder() + .withProjectDir(projectDir) + .build() + project.apply plugin: 'org.xbib.gradle.plugin.rpm' + project.task([type: Rpm], 'buildRpm', { + packageName = 'installscripts' + packageVersion = '1.0' + packageRelease = '1' + preInstall = "echo 'Hello Pre World'" + postInstall = "echo 'Hello Post World'" + preUninstall = "echo 'Hello PreUn World'" + postUninstall = "echo 'Hello PostUn World'" + preTrans = "echo 'Hello PreTrans World'" + postTrans = "echo 'Hello PostTrans World'" + }) + project.tasks.buildRpm.copy() + RpmReader rpmReader = new RpmReader() + def result = rpmReader.read(project.tasks.buildRpm.outputs.files.first().toPath()) + Format format = result.format + assertThat(["echo 'Hello Pre World'"], is(format.header.getEntry(PREINSCRIPT)?.values)) + assertThat(["echo 'Hello Post World'"], is(format.header.getEntry(POSTINSCRIPT)?.values)) + assertThat(["echo 'Hello PreUn World'"], is(format.header.getEntry(PREUNSCRIPT)?.values)) + assertThat(["echo 'Hello PostUn World'"], is(format.header.getEntry(POSTUNSCRIPT)?.values)) + assertThat(["echo 'Hello PreTrans World'"], is(format.header.getEntry(PRETRANSSCRIPT)?.values)) + assertThat(["echo 'Hello PostTrans World'"], is(format.header.getEntry(POSTTRANSSCRIPT)?.values)) + } + + + @Test + void testInstallScriptFiles() { + String preinstall = getClass().getResource('preinstall.sh').text + File scriptDir = new File(projectDir, 'scripts') + scriptDir.mkdirs() + new File(scriptDir, 'preinstall.sh').withWriter { out -> out.write(preinstall) } + Project project = ProjectBuilder.builder() + .withProjectDir(projectDir) + .build() + project.apply plugin: 'org.xbib.gradle.plugin.rpm' + project.task([type: Rpm], 'buildRpm', { + packageName = 'installscripts' + packageVersion = '1.0' + packageRelease = '1' + preInstallFile = project.file('scripts/preinstall.sh') + postInstall = "echo 'Hello Post World'" + preUninstall = "echo 'Hello PreUn World'" + postUninstall = "echo 'Hello PostUn World'" + preTrans = "echo 'Hello PreTrans World'" + postTrans = "echo 'Hello PostTrans World'" + }) + project.tasks.buildRpm.copy() + RpmReader rpmReader = new RpmReader() + def result = rpmReader.read(project.tasks.buildRpm.outputs.files.first().toPath()) + Format format = result.format + assertThat(["#!/usr/bin/env bash\necho 'Hello from file'\n"], is(format.header.getEntry(PREINSCRIPT)?.values)) + assertThat(["echo 'Hello Post World'"], is(format.header.getEntry(POSTINSCRIPT)?.values)) + assertThat(["echo 'Hello PreUn World'"], is(format.header.getEntry(PREUNSCRIPT)?.values)) + assertThat(["echo 'Hello PostUn World'"], is(format.header.getEntry(POSTUNSCRIPT)?.values)) + assertThat(["echo 'Hello PreTrans World'"], is(format.header.getEntry(PRETRANSSCRIPT)?.values)) + assertThat(["echo 'Hello PostTrans World'"], is(format.header.getEntry(POSTTRANSSCRIPT)?.values)) + } + + @Test + void testChangeLog() { + Project project = ProjectBuilder.builder() + .withProjectDir(projectDir) + .build() + String changelog = getClass().getResource('changelog').text + File changelogDir = new File(projectDir, 'changelog') + changelogDir.mkdirs() + new File(changelogDir, 'changelog').withWriter { out -> out.write(changelog) } + project.apply plugin: 'org.xbib.gradle.plugin.rpm' + project.task([type: Rpm], 'buildRpm', { + packageName = 'changelog' + packageVersion = '1.0' + packageRelease = '1' + changeLogFile = project.file('changelog/changelog') + }) + project.tasks.buildRpm.copy() + RpmReader rpmReader = new RpmReader() + def result = rpmReader.read(project.tasks.buildRpm.outputs.files.first().toPath()) + Format format = result.format + assertDateEntryHeaderEqualsAt("Tue Feb 24 2015", format, + CHANGELOGTIME, 10, 0) + assertHeaderEqualsAt("Thomas Jefferson", format, + CHANGELOGNAME, 10, 4) + assertHeaderEqualsAt("- Initial rpm for this package", format, + CHANGELOGTEXT, 10, 9) + assertHeaderEqualsAt("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod \n" + + "tempor incididunt ut labore et dolore magna aliqua", format, + CHANGELOGTEXT, 10, 0) + } + + private static void assertDateEntryHeaderEqualsAt(String expected, Format format, EntryType entryType, int size, int pos) { + assertNotNull(format, "null format") + SpecEntry entry = format.getHeader().getEntry(entryType) + assertNotNull(entry, "Entry not found : " + entryType.getName()) + assertEquals(4, entry.getType(), "Entry type : " + entryType.getName()) + IntegerList values = (IntegerList) entry.getValues() + assertNotNull(values, "null values") + assertEquals(size, values.size(), "Entry size : " + entryType.getName()) + LocalDateTime localDate = LocalDateTime.ofEpochSecond(values.get(pos), 0, ZoneOffset.UTC) + assertEquals(expected, ChangelogParser.CHANGELOG_FORMAT.format(localDate), "Entry value : " + entryType.getName()) + } + + private static void assertHeaderEqualsAt(String expected, Format format, EntryType entryType, int size, int pos) { + assertNotNull(format, "null format") + SpecEntry entry = format.getHeader().getEntry(entryType) + assertNotNull(entry, "Entry not found : " + entryType.getName()) + assertEquals(8, entry.getType(), "Entry type : " + entryType.getName()) + StringList values = (StringList) entry.getValues() + assertNotNull(values, "null values") + assertEquals(size, values.size(), "Entry size : " + entryType.getName()) + assertEquals(expected, values.get(pos), "Entry value : " + entryType.getName()) + } +} diff --git a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/RpmSignTest.groovy b/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/RpmSignTest.groovy new file mode 100644 index 0000000..907e823 --- /dev/null +++ b/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/RpmSignTest.groovy @@ -0,0 +1,62 @@ +package org.xbib.gradle.plugin + +import org.gradle.api.Project +import org.gradle.testfixtures.ProjectBuilder +import org.junit.jupiter.api.BeforeEach +import org.junit.jupiter.api.Test +import org.xbib.rpm.RpmReader +import org.xbib.rpm.signature.SignatureTag +import java.nio.file.Paths +import static org.junit.jupiter.api.Assertions.assertNotNull +import static org.junit.jupiter.api.Assertions.assertNull +import static org.xbib.rpm.lead.Architecture.I386 + +class RpmSignTest { + + File projectDir + + @BeforeEach + void setup() { + projectDir = new File("build/testrpm") + projectDir.mkdirs() + } + + @Test + void testUnsigned() { + Project project = ProjectBuilder.builder() + .withProjectDir(projectDir) + .build() + project.apply plugin: 'org.xbib.gradle.plugin.rpm' + project.task([type: Rpm], 'buildRpm', { + packageName = 'bleah' + packageVersion = '1.0' + packageRelease = '1' + arch = I386 + }) + project.tasks.buildRpm.copy() + RpmReader rpmReader = new RpmReader() + def res = rpmReader.read(Paths.get(projectDir.toString(), 'build', 'distributions', 'bleah-1.0-1.i386.rpm')) + assertNull(res.format.signatureHeader.getEntry(SignatureTag.LEGACY_PGP)) + } + + @Test + void testSign() { + Project project = ProjectBuilder.builder() + .withProjectDir(projectDir) + .build() + project.apply plugin: 'org.xbib.gradle.plugin.rpm' + project.task([type: Rpm], 'buildRpm', { + packageName = 'bleah' + packageVersion = '1.0' + packageRelease = '1' + arch = I386 + signingKeyId = 'F02C6D2C' + signingKeyPassphrase = 'test' + signingKeyRing = 'src/test/resources/test-secring.gpg' + }) + project.tasks.buildRpm.copy() + RpmReader rpmReader = new RpmReader() + def res = rpmReader.read(Paths.get(projectDir.toString(), 'build', 'distributions', 'bleah-1.0-1.i386.rpm')) + assertNotNull(res.format.signatureHeader.getEntry(SignatureTag.LEGACY_PGP)) + } +} diff --git a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/RpmSimpleTest.groovy b/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/RpmSimpleTest.groovy new file mode 100644 index 0000000..450bfae --- /dev/null +++ b/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/RpmSimpleTest.groovy @@ -0,0 +1,104 @@ +package org.xbib.gradle.plugin + +import org.gradle.api.Project +import org.gradle.testfixtures.ProjectBuilder +import org.junit.jupiter.api.BeforeEach +import org.junit.jupiter.api.Test +import org.xbib.rpm.RpmReaderResult +import org.xbib.rpm.RpmReader +import org.xbib.rpm.format.Format +import java.nio.file.Paths +import static org.hamcrest.MatcherAssert.assertThat +import static org.hamcrest.CoreMatchers.* +import static org.junit.jupiter.api.Assertions.assertTrue +import static org.xbib.rpm.format.Flags.EQUAL +import static org.xbib.rpm.format.Flags.GREATER +import static org.xbib.rpm.header.HeaderTag.ARCH +import static org.xbib.rpm.header.HeaderTag.DISTRIBUTION +import static org.xbib.rpm.header.HeaderTag.EPOCH +import static org.xbib.rpm.header.HeaderTag.NAME +import static org.xbib.rpm.header.HeaderTag.OS +import static org.xbib.rpm.header.HeaderTag.RELEASE +import static org.xbib.rpm.header.HeaderTag.VERSION +import static org.xbib.rpm.lead.Architecture.I386 +import static org.xbib.rpm.lead.Os.LINUX +import static org.xbib.rpm.lead.PackageType.BINARY + +class RpmSimpleTest { + + File projectDir + + @BeforeEach + void setup() { + projectDir = new File("build/testrpm") + projectDir.mkdirs() + } + + @Test + void simpleRpm() { + File srcDir = new File(projectDir, 'src') + srcDir.mkdirs() + new File(srcDir, 'apple').withWriter { out -> + out.write('apple') + } + File noParentsDir = new File(projectDir, 'noParentsDir') + noParentsDir.mkdirs() + new File(noParentsDir, 'alone').withWriter { out -> + out.write('alone') + } + Project project = ProjectBuilder.builder() + .withProjectDir(projectDir) + .build() + project.apply plugin: 'org.xbib.gradle.plugin.rpm' + project.task([type: Rpm], 'buildRpm', { + packageName = 'bleah' + packageVersion = '1.0' + packageRelease = '1' + packageType = BINARY + arch = I386 + os = LINUX + packageGroup = 'Development/Libraries' + packageDescription = 'Not a very interesting library.' + summary = 'Bleah blarg' + license = 'Free' + distribution = 'SuperSystem' + vendor = 'Super Associates, LLC' + url = 'http://www.example.com/' + requires('blarg', '1.0', GREATER | EQUAL) + requires('blech') + into '/opt/bleah' + from('src') { + fileType = ['config', 'noreplace'] + } + from('noParentsDir') { + into '/a/path/not/to/create' + } + link('/opt/bleah/banana', '/opt/bleah/apple') + }) + project.tasks.buildRpm.copy() + RpmReader rpmReader = new RpmReader() + RpmReaderResult result = rpmReader.read(Paths.get(projectDir.toString(), 'build', 'distributions', 'bleah-1.0-1.i386.rpm')) + Format format = result.format + assertThat(['bleah'], is(format.header.getEntry(NAME)?.values)) + assertThat(['1.0'], is(format.header.getEntry(VERSION)?.values)) + assertThat(['1'], is(format.header.getEntry(RELEASE)?.values)) + assertThat([0], is(format.header.getEntry(EPOCH)?.values)) + assertThat(['i386'], is(format.header.getEntry(ARCH)?.values)) + assertThat(['linux'], is(format.header.getEntry(OS)?.values)) + assertThat(['SuperSystem'], is(format.header.getEntry(DISTRIBUTION)?.values)) + assertTrue(result.files*.name.every { fileName -> + ['./a/path/not/to/create/alone', + './opt/bleah', + './opt/bleah/apple', + './opt/bleah/banana' + ].any { path -> + path.startsWith(fileName) + } + }) + assertTrue(result.files*.name.every { fileName -> + ['./a/path/not/to/create'].every { path -> + !path.startsWith(fileName) + } + }) + } +} diff --git a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/CopySpecEnhancementTest.groovy b/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/CopySpecEnhancementTest.groovy deleted file mode 100644 index da40f2e..0000000 --- a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/CopySpecEnhancementTest.groovy +++ /dev/null @@ -1,107 +0,0 @@ -package org.xbib.gradle.plugin.rpm - -import org.gradle.api.internal.file.DefaultFileLookup -import org.gradle.api.internal.file.FileResolver -import org.gradle.api.internal.file.copy.DefaultCopySpec -import org.gradle.api.tasks.util.PatternSet -import org.gradle.api.tasks.util.internal.PatternSets -import org.gradle.internal.Factory -import org.gradle.internal.nativeintegration.filesystem.FileSystem -import org.gradle.internal.nativeintegration.services.NativeServices -import org.gradle.internal.reflect.DirectInstantiator -import org.gradle.internal.reflect.Instantiator -import org.junit.Test - -import static org.junit.Assert.assertEquals -import static org.junit.Assert.assertNull - -class CopySpecEnhancementTest { - private final FileResolver fileResolver = [resolve: { it as File }, getPatternSetFactory: { - TestFiles.getPatternSetFactory() - }] as FileResolver - private final Instantiator instantiator = DirectInstantiator.INSTANCE - - def spec = new DefaultCopySpec(fileResolver, instantiator) - - @Test - public void addUser() { - assertNull(spec.metaClass.hasProperty('user')) - - CopySpecEnhancement.user(spec, 'USER') - - assertEquals('USER', spec.user) - } - - @Test - public void addAddParentDirs() { - CopySpecEnhancement.setAddParentDirs(spec, true) - - assertEquals(true, spec.addParentDirs) - } - - @Test - public void addCreateDirectoryEntry() { - use(CopySpecEnhancement) { - spec.createDirectoryEntry false - } - - assertEquals(false, spec.createDirectoryEntry) - - use(CopySpecEnhancement) { - spec.createDirectoryEntry true - } - - assertEquals(true, spec.createDirectoryEntry) - - use(CopySpecEnhancement) { - spec.setCreateDirectoryEntry(false) - } - - assertEquals(false, spec.createDirectoryEntry) - - use(CopySpecEnhancement) { - spec.setCreateDirectoryEntry(true) - } - - assertEquals(true, spec.createDirectoryEntry) - } -} - -// Copied from Gradle core as DefaultCopySpec can no longer have null arguments - -class TestFiles { - private static final FileSystem FILE_SYSTEM = NativeServicesTestFixture.getInstance().get(FileSystem.class); - private static final DefaultFileLookup FILE_LOOKUP = new DefaultFileLookup(FILE_SYSTEM, PatternSets.getNonCachingPatternSetFactory()); - - /** - * Returns a resolver with no base directory. - */ - static FileResolver resolver() { - return FILE_LOOKUP.getFileResolver() - } - - static Factory getPatternSetFactory() { - return resolver().getPatternSetFactory() - } -} - -class NativeServicesTestFixture { - static NativeServices nativeServices - static boolean initialized - - static void initialize() { - if (!initialized) { - File nativeDir = new File("build/native-libs") - NativeServices.initialize(nativeDir) - initialized = true - } - } - - static synchronized NativeServices getInstance() { - if (nativeServices == null) { - initialize() - nativeServices = NativeServices.getInstance() - } - nativeServices - } -} diff --git a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/RpmCopySpecVisitorTest.groovy b/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/RpmCopySpecVisitorTest.groovy deleted file mode 100755 index 131e6f1..0000000 --- a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/RpmCopySpecVisitorTest.groovy +++ /dev/null @@ -1,51 +0,0 @@ -package org.xbib.gradle.plugin.rpm - -import org.junit.Before -import org.junit.Test -import org.xbib.gradle.plugin.test.ProjectSpec - -import static org.junit.Assert.assertEquals -import static org.junit.Assert.assertTrue - -class RpmCopySpecVisitorTest extends ProjectSpec { - - RpmCopyAction visitor - - @Before - void setup() { - project.apply plugin: 'org.xbib.gradle.plugin.rpm' - - Rpm rpmTask = project.task('buildRpm', type: Rpm) { - packageName = 'can-execute-rpm-task-with-valid-version' - } - visitor = new RpmCopyAction(rpmTask) - } - - @Test - void withoutUtils() { - visitor.includeStandardDefines = false - File script = resourceFile("script.sh") - Object result = visitor.scriptWithUtils([], [script]) - assertTrue result instanceof String - assertEquals( - "#!/bin/bash\n" + - "hello\n", result) - } - - @Test - void withUtils() { - visitor.includeStandardDefines = false - Object result = visitor.scriptWithUtils([resourceFile("utils.sh")], [resourceFile("script.sh")]) - assertTrue result instanceof String - assertEquals( - "#!/bin/bash\n" + - "function hello() {\n" + - " echo 'Hello, world.'\n" + - "}\n" + - "hello\n", result) - } - - File resourceFile(String name) { - new File(getClass().getResource(name).getPath()) - } -} diff --git a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/RpmPluginIntegrationTest.groovy b/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/RpmPluginIntegrationTest.groovy deleted file mode 100644 index 9a00c81..0000000 --- a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/RpmPluginIntegrationTest.groovy +++ /dev/null @@ -1,28 +0,0 @@ -package org.xbib.gradle.plugin.rpm - -import org.xbib.gradle.plugin.test.IntegrationSpec - -class RpmPluginIntegrationTest extends IntegrationSpec { - - def "rpm task is marked up-to-date when setting arch or os property"() { - - given: - buildFile << ''' -apply plugin: 'org.xbib.gradle.plugin.rpm' - -task buildRpm(type: Rpm) { - packageName = 'rpmIsUpToDate' - arch = org.xbib.rpm.lead.Architecture.NOARCH - os = org.xbib.rpm.lead.Os.LINUX -} -''' - when: - runTasksSuccessfully('buildRpm') - - and: - def result = runTasksSuccessfully('buildRpm') - - then: - result.wasUpToDate('buildRpm') - } -} diff --git a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/RpmPluginTest.groovy b/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/RpmPluginTest.groovy deleted file mode 100755 index 91fbff7..0000000 --- a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/RpmPluginTest.groovy +++ /dev/null @@ -1,1316 +0,0 @@ -package org.xbib.gradle.plugin.rpm - -import org.gradle.api.Project -import org.gradle.api.Task -import org.gradle.api.plugins.BasePlugin -import org.gradle.testfixtures.ProjectBuilder -import org.xbib.gradle.plugin.test.DependencyGraph -import org.xbib.gradle.plugin.test.GradleDependencyGenerator -import org.xbib.gradle.plugin.test.ProjectSpec -import org.xbib.rpm.format.Flags -import org.xbib.rpm.header.Header -import org.xbib.rpm.signature.SignatureTag -import spock.lang.Ignore -import spock.lang.Unroll - -import java.nio.file.Files -import java.nio.file.Path -import java.nio.file.Paths - -import static org.xbib.rpm.format.Flags.* -import static org.xbib.rpm.header.HeaderTag.* -import static org.xbib.rpm.payload.CpioHeader.* - -/** - * - */ -class RpmPluginTest extends ProjectSpec { - def 'files'() { - Project project = ProjectBuilder.builder().build() - - File srcDir = new File(projectDir, 'src') - srcDir.mkdirs() - String fruit = 'apple' - new File(srcDir, fruit).withWriter { out -> - out.write(fruit) - } - - File noParentsDir = new File(projectDir, 'noParentsDir') - noParentsDir.mkdirs() - new File(noParentsDir, 'alone').withWriter { out -> - out.write('alone') - } - - project.apply plugin: 'org.xbib.gradle.plugin.rpm' - - project.task([type: Rpm], 'buildRpm', { - destinationDir = project.file('build/tmp/RpmPluginTest') - destinationDir.mkdirs() - - packageName = 'bleah' - version = '1.0' - release = '1' - type = org.xbib.rpm.lead.PackageType.BINARY - arch = org.xbib.rpm.lead.Architecture.I386 - os = org.xbib.rpm.lead.Os.LINUX - permissionGroup = 'Development/Libraries' - summary = 'Bleah blarg' - packageDescription = 'Not a very interesting library.' - license = 'Free' - distribution = 'SuperSystem' - vendor = 'Super Associates, LLC' - url = 'http://www.example.com/' - - requires('blarg', '1.0', Flags.GREATER | Flags.EQUAL) - requires('blech') - - into '/opt/bleah' - from(srcDir) - - from(srcDir.toString() + '/main/groovy') { - createDirectoryEntry true - fileType = ['config', 'noreplace'] - } - - from(noParentsDir) { - addParentDirs false - into '/a/path/not/to/create' - } - - link('/opt/bleah/banana', '/opt/bleah/apple') - }) - - when: - project.tasks.buildRpm.copy() - - then: - def result = RpmReader.read(project.file('build/tmp/RpmPluginTest/bleah-1.0-1.i386.rpm').toPath()) - 'bleah' == RpmReader.getHeaderEntryString(result, NAME) - '1.0' == RpmReader.getHeaderEntryString(result, VERSION) - '1' == RpmReader.getHeaderEntryString(result, RELEASE) - 0 == RpmReader.getHeaderEntry(result, EPOCH).values[0] - 'i386' == RpmReader.getHeaderEntryString(result, ARCH) - 'linux' == RpmReader.getHeaderEntryString(result, OS) - ['SuperSystem'] == RpmReader.getHeaderEntry(result, DISTRIBUTION).values - result.files*.name.every { fileName -> - ['./a/path/not/to/create/alone', './opt/bleah', - './opt/bleah/apple', './opt/bleah/banana'].any { path -> - path.startsWith(fileName) - } - } - result.files*.name.every { fileName -> - ['./a/path/not/to/create'].every { path -> - ! path.startsWith(fileName) - } - } - } - - def 'obsoletesAndConflicts'() { - - Project project = ProjectBuilder.builder().build() - File buildDir = project.buildDir - File srcDir = new File(buildDir, 'src') - srcDir.mkdirs() - String fruit = 'apple' - new File(srcDir, fruit).withWriter { out -> - out.write(fruit) - } - - project.apply plugin: 'org.xbib.gradle.plugin.rpm' - - project.task([type: Rpm], 'buildRpm', { - destinationDir = project.file('build/tmp/ObsoletesConflictsTest') - destinationDir.mkdirs() - - packageName = 'testing' - version = '1.2' - release = '3' - type = BINARY - arch = I386 - os = LINUX - license = 'Free' - distribution = 'SuperSystem' - vendor = 'Super Associates, LLC' - url = 'http://www.example.com/' - - obsoletes('blarg', '1.0', GREATER | EQUAL) - conflicts('blech') - conflicts('packageA', '1.0', LESS) - obsoletes('packageB', '2.2', GREATER) - - from(srcDir) - into '/opt/bleah' - }) - - when: - project.tasks.buildRpm.copy() - - then: - def result = RpmReader.read(project.file('build/tmp/ObsoletesConflictsTest/testing-1.2-3.i386.rpm').toPath()) - def obsoletes = RpmReader.getHeaderEntry(result, OBSOLETENAME) - def obsoleteVersions = RpmReader.getHeaderEntry(result, OBSOLETEVERSION) - def obsoleteComparisons = RpmReader.getHeaderEntry(result, OBSOLETEFLAGS) - def conflicts = RpmReader.getHeaderEntry(result, CONFLICTNAME) - def conflictVersions = RpmReader.getHeaderEntry(result, CONFLICTVERSION) - def conflictComparisons = RpmReader.getHeaderEntry(result, CONFLICTFLAGS) - def distribution = RpmReader.getHeaderEntry(result, DISTRIBUTION) - - 'blarg' == obsoletes.values[0] - '1.0' == obsoleteVersions.values[0] - (GREATER | EQUAL) == obsoleteComparisons.values[0] - - 'blech' == conflicts.values[0] - '' == conflictVersions.values[0] - 0 == conflictComparisons.values[0] - - 'packageA' == conflicts.values[1] - '1.0' ==conflictVersions.values[1] - LESS == conflictComparisons.values[1] - - 'packageB' == obsoletes.values[1] - '2.2' == obsoleteVersions.values[1] - GREATER == obsoleteComparisons.values[1] - - ['SuperSystem'] == distribution.values - } - - - def 'projectNameDefault'() { - - File srcDir = new File(projectDir, 'src') - srcDir.mkdirs() - String fruit = 'apple' - new File(srcDir, fruit).withWriter { out -> - out.write(fruit) - } - - when: - project.apply plugin: 'org.xbib.gradle.plugin.rpm' - - project.task([type: Rpm], 'buildRpm', {}) - - then: - 'projectNameDefault' == project.buildRpm.packageName - - when: - project.tasks.buildRpm.copy() - - then: - noExceptionThrown() - } - - def 'file handle closed'() { - - when: - project.apply plugin: 'org.xbib.gradle.plugin.rpm' - project.task([type: Rpm], 'buildRpm', {}) - project.tasks.buildRpm.copy() - //project.tasks.clean.execute() - then: - noExceptionThrown() - } - - def 'category_on_spec'() { - project.version = '1.0.0' - - File bananaFile = new File(projectDir, 'test/banana') - bananaFile.parentFile.mkdirs() - bananaFile.withWriter { out -> out.write('banana') } - - File srcDir = new File(projectDir, 'src') - srcDir.mkdirs() - String fruit = 'apple' - File appleFile = new File(srcDir, fruit) - appleFile.withWriter { out -> out.write(fruit) } - - project.apply plugin: 'org.xbib.gradle.plugin.rpm' - - def rpmTask = (Rpm) project.task([type: Rpm], 'buildRpm', { - addParentDirs = true - from(bananaFile.getParentFile()) { - into '/usr/share/myproduct/etc' - createDirectoryEntry false - } - from(appleFile.getParentFile()) { - into '/usr/local/myproduct/bin' - createDirectoryEntry true - } - }) - - when: - rpmTask.copy() - - then: - def files = RpmReader.read(rpmTask.getArchivePath().toPath()).files - ['./usr/local/myproduct', './usr/local/myproduct/bin', './usr/local/myproduct/bin/apple', './usr/share/myproduct', './usr/share/myproduct/etc', './usr/share/myproduct/etc/banana'] == files*.name - [ DIR, DIR, FILE, DIR, DIR, FILE] == files*.type - - } - - def 'filter_expression'() { - - project.version = '1.0.0' - File appleFile = new File(projectDir, 'src/apple') - appleFile.parentFile.mkdirs() - appleFile.withWriter { out -> out.write('{{BASE}}/apple') } - - project.apply plugin: 'org.xbib.gradle.plugin.rpm' - - def rpmTask = (Rpm) project.task([type: Rpm], 'buildRpm') { - from(appleFile.getParentFile()) { - into '/usr/local/myproduct/bin' - filter({ line -> - return line.replaceAll(/\{\{BASE\}\}/, '/usr/local/myproduct') - }) - } - } - - when: - rpmTask.copy() - - then: - def res = RpmReader.read(rpmTask.getArchivePath().toPath()) - def scannerApple = res.files.find { it.name =='./usr/local/myproduct/bin/apple'} - scannerApple.asString() == '/usr/local/myproduct/apple' - } - - def 'usesArchivesBaseName'() { - - // archivesBaseName is an artifact of the BasePlugin, and won't exist until it's applied. - project.apply plugin: BasePlugin - project.archivesBaseName = 'foo' - - File srcDir = new File(projectDir, 'src') - srcDir.mkdirs() - String fruit = 'apple' - new File(srcDir, fruit).withWriter { out -> - out.write(fruit) - } - project.apply plugin: 'org.xbib.gradle.plugin.rpm' - - when: - project.task([type: Rpm], 'buildRpm', {}) - - then: - 'foo' == project.buildRpm.packageName - - when: - project.tasks.buildRpm.copy() - - then: - noExceptionThrown() - } - - def 'verifyValuesCanComeFromExtension'() { - - File srcDir = new File(projectDir, 'src') - srcDir.mkdirs() - String fruit = 'apple' - new File(srcDir, fruit).withWriter { out -> - out.write(fruit) - } - - project.apply plugin: 'org.xbib.gradle.plugin.rpm' - def parentExten = project.extensions.create('rpmParent', ProjectPackagingExtension, project) - - Rpm rpmTask = project.task([type: Rpm], 'buildRpm') - rpmTask.permissionGroup = 'GROUP' - rpmTask.requires('openjdk') - rpmTask.link('/dev/null', '/dev/random') - - when: - parentExten.user = 'USER' - parentExten.permissionGroup = 'GROUP2' - parentExten.requires('java') - parentExten.link('/tmp', '/var/tmp') - - project.description = 'DESCRIPTION' - - then: - 'USER' == rpmTask.user // From Extension - 'GROUP' == rpmTask.permissionGroup // From task, overriding extension - 'DESCRIPTION' == rpmTask.packageDescription // From Project, even though extension could have a value - 2 == rpmTask.getAllLinks().size() - 2 == rpmTask.getAllDependencies().size() - } - - def 'verifyCopySpecCanComeFromExtension'() { - setup: - - File srcDir = new File(projectDir, 'src') - srcDir.mkdirs() - String fruit = 'apple' - new File(srcDir, fruit).withWriter { out -> - out.write(fruit) - } - - File etcDir = new File(projectDir, 'etc') - etcDir.mkdirs() - new File(etcDir, 'banana.conf').text = 'banana=true' - - // Simulate SystemPackagingBasePlugin - project.apply plugin: 'org.xbib.gradle.plugin.rpm' - ProjectPackagingExtension parentExten = project.extensions.create('rpmParent', ProjectPackagingExtension, project) - - // Configure - Rpm rpmTask = (Rpm) project.task([type: Rpm, name:'buildRpm']) { - release 3 - } - project.version = '1.0' - - rpmTask.from(srcDir) { - into('/usr/local/src') - } - parentExten.from(etcDir) { - createDirectoryEntry true - into('/conf/defaults') - } - - when: - rpmTask.copy() - - then: - // Evaluate response - rpmTask.getArchivePath().exists() - def res = RpmReader.read(rpmTask.getArchivePath().toPath()) - // Parent will come first - ['./conf', './conf/defaults', './conf/defaults/banana.conf', './usr/local/src', './usr/local/src/apple'] == res.files*.name - [DIR, DIR, FILE, DIR, FILE] == res.files*.type - } - - def 'differentUsersBetweenCopySpecs'() { - - def srcDir = [new File(projectDir, 'src1'), - new File(projectDir, 'src2'), - new File(projectDir, 'src3')] - def fruits = ['apple', 'banana', 'cherry'] - srcDir.eachWithIndex { file, idx -> - file.mkdirs() - String fruit = fruits[idx] - new File(file, fruit).withWriter { out -> - out.write(fruit) - } - } - - project.apply plugin: 'org.xbib.gradle.plugin.rpm' - - project.task([type: Rpm], 'buildRpm', { - destinationDir = project.file('build/tmp/RpmPluginTest') - destinationDir.mkdirs() - - packageName = 'userTest' - version = '2.0' - release = '2' - type = BINARY - arch = I386 - os = LINUX - - into '/tiny' - user = 'default' - - from(srcDir[0]) { - user 'user1' - // user = 'user1' // Won't work, since setter via Categories won't pass hasProperty - } - - from(srcDir[1]) { - // should be default user - } - - from(srcDir[2]) { - user 'user2' - } - }) - - when: - project.tasks.buildRpm.copy() - - then: - def res = RpmReader.read(project.file('build/tmp/RpmPluginTest/userTest-2.0-2.i386.rpm').toPath()) - [DIR, FILE, FILE, FILE] == res.files*.type - ['./tiny', './tiny/apple', './tiny/banana', './tiny/cherry'] == res.files*.name - ['user1', 'user1', 'default', 'user2'] == res.format.header.getEntry(FILEUSERNAME).values.toList() - } - - def 'differentGroupsBetweenCopySpecs'() { - Project project = ProjectBuilder.builder().build() - - File buildDir = project.buildDir - - def fruits = ['apple', 'banana', 'cherry'] - def srcDir = [new File(buildDir, 'src1'), new File(buildDir, 'src2'), new File(buildDir, 'src3')] - srcDir.eachWithIndex { file, idx -> - file.mkdirs() - String word = fruits[idx] - new File(file, word).withWriter { out -> - out.write(word) - } - } - - project.apply plugin: 'org.xbib.gradle.plugin.rpm' - - project.task([type: Rpm], 'buildRpm', { - destinationDir = project.file('build/tmp/RpmPluginTest') - destinationDir.mkdirs() - - packageName = 'userTest' - version = '2.0' - release = '2' - type = BINARY - arch = I386 - os = LINUX - - into '/tiny' - permissionGroup 'default' - - from(srcDir[0]) { - // should be default group - } - - from(srcDir[1]) { - //setPermissionGroup 'group2' // works - //permissionGroup = 'group2' // Does not work - permissionGroup 'group2' // Does not work - } - - from(srcDir[2]) { - // should be default group - } - }) - - when: - project.tasks.buildRpm.copy() - - then: - def res = RpmReader.read(project.file('build/tmp/RpmPluginTest/userTest-2.0-2.i386.rpm').toPath()) - [DIR, FILE, FILE, FILE] == res.files*.type - ['./tiny', './tiny/apple', './tiny/banana', './tiny/cherry'] == res.files*.name - def allFiles = res.files - def groups = res.format.header.getEntry(FILEGROUPNAME).values - ['default', 'default', 'group2', 'default'] == res.format.header.getEntry(FILEGROUPNAME).values.toList() - } - - def 'differentPermissionsBetweenCopySpecs'() { - File srcDir1 = new File(projectDir, 'src1') - File srcDir2 = new File(projectDir, 'src2') - File srcDir3 = new File(projectDir, 'src3') - - srcDir1.mkdirs() - srcDir2.mkdirs() - srcDir3.mkdirs() - - new File(srcDir1, 'apple').withWriter { out -> out.write('apple') } - new File(srcDir2, 'banana').withWriter { out -> out.write('banana') } - new File(srcDir3, 'cherry').withWriter { out -> out.write('cherry') } - - project.apply plugin: 'org.xbib.gradle.plugin.rpm' - - project.task([type: Rpm], 'buildRpm', { - destinationDir = project.file('build/tmp/RpmPluginTest') - destinationDir.mkdirs() - - packageName = 'userTest' - version = '2.0' - release = '2' - type = BINARY - arch = I386 - os = LINUX - - into '/tiny' - fileMode 0555 - - from(srcDir1) { - // should be default group - } - - from(srcDir2) { - fileMode 0666 - } - - from(srcDir3) { - fileMode 0555 - } - }) - - when: - project.tasks.buildRpm.copy() - - then: - def res = RpmReader.read(project.file('build/tmp/RpmPluginTest/userTest-2.0-2.i386.rpm').toPath()) - [DIR, FILE, FILE, FILE] == res.files*.type - ['./tiny', './tiny/apple', './tiny/banana', './tiny/cherry'] == res.files*.name - - // #define S_IFIFO 0010000 /* named pipe (fifo) */ - // #define S_IFCHR 0020000 /* character special */ - // #define S_IFDIR 0040000 /* directory */ - // #define S_IFBLK 0060000 /* block special */ - // #define S_IFREG 0100000 /* regular */ - // #define S_IFLNK 0120000 /* symbolic link */ - // #define S_IFSOCK 0140000 /* socket */ - // #define S_ISUID 0004000 /* set user id on execution */ - // #define S_ISGID 0002000 /* set group id on execution */ - // #define S_ISTXT 0001000 /* sticky bit */ - // #define S_IRWXU 0000700 /* RWX mask for owner */ - // #define S_IRUSR 0000400 /* R for owner */ - // #define S_IWUSR 0000200 /* W for owner */ - // #define S_IXUSR 0000100 /* X for owner */ - // #define S_IRWXG 0000070 /* RWX mask for group */ - // #define S_IRGRP 0000040 /* R for group */ - // #define S_IWGRP 0000020 /* W for group */ - // #define S_IXGRP 0000010 /* X for group */ - // #define S_IRWXO 0000007 /* RWX mask for other */ - // #define S_IROTH 0000004 /* R for other */ - // #define S_IWOTH 0000002 /* W for other */ - // #define S_IXOTH 0000001 /* X for other */ - // #define S_ISVTX 0001000 /* save swapped text even after use */ - - // drwxr-xr-x is 0040755 - // NOTE: Not sure why directory is getting user write permission - [(short)0040755, (short)0100555, (short)0100666, (short)0100555] == res.format.header.getEntry(FILEMODES).values.toList() - } - - def 'no Prefix Value'() { - given: - Project project = ProjectBuilder.builder().build() - File srcDir = new File(projectDir, 'src') - srcDir.mkdirs() - new File(srcDir, 'apple').withWriter { out -> out.write('apple') } - - project.apply plugin: 'org.xbib.gradle.plugin.rpm' - - def rpmTask = project.task([type: Rpm], 'buildRpm', { - destinationDir = project.file('build/tmp/RpmPluginTest') - destinationDir.mkdirs() - - packageName = 'one-prefix' - version = '1.0' - release = '1' - arch = I386 - os = LINUX - - into '/opt/myprefix' - from (srcDir) - }) - - when: - rpmTask.copy() - - then: - def scan = RpmReader.read(project.file('build/tmp/RpmPluginTest/one-prefix-1.0-1.i386.rpm').toPath()) - null == RpmReader.getHeaderEntry(scan, PREFIXES) - } - - def 'one Prefix Value'() { - given: - Project project = ProjectBuilder.builder().build() - File srcDir = new File(projectDir, 'src') - srcDir.mkdirs() - new File(srcDir, 'apple').withWriter { out -> out.write('apple') } - - project.apply plugin: 'org.xbib.gradle.plugin.rpm' - - def rpmTask = project.task([type: Rpm], 'buildRpm', { - destinationDir = project.file('build/tmp/RpmPluginTest') - destinationDir.mkdirs() - - packageName = 'one-prefix' - version = '1.0' - release = '1' - arch = I386 - os = LINUX - - into '/opt/myprefix' - from (srcDir) - - prefixes '/opt/myprefix' - }) - - when: - rpmTask.copy() - - then: - def scan = RpmReader.read(project.file('build/tmp/RpmPluginTest/one-prefix-1.0-1.i386.rpm').toPath()) - '/opt/myprefix' == RpmReader.getHeaderEntryString(scan, PREFIXES) - } - - def 'multiple Prefix Values'() { - given: - Project project = ProjectBuilder.builder().build() - File srcDir = new File(projectDir, 'src') - srcDir.mkdirs() - new File(srcDir, 'apple').withWriter { out -> out.write('apple') } - - project.apply plugin: 'org.xbib.gradle.plugin.rpm' - - def rpmTask = project.task([type: Rpm], 'buildRpm', { - destinationDir = project.file('build/tmp/RpmPluginTest') - destinationDir.mkdirs() - - packageName = 'one-prefix' - version = '1.0' - release = '1' - arch = I386 - os = LINUX - - into '/opt/myprefix' - from (srcDir) - - prefixes '/opt/myprefix', '/etc/init.d' - }) - - when: - rpmTask.copy() - - then: - def scan = RpmReader.read(project.file('build/tmp/RpmPluginTest/one-prefix-1.0-1.i386.rpm').toPath()) - // NOTE: Scanner just jams things together as one string - '/opt/myprefix/etc/init.d' == RpmReader.getHeaderEntryString(scan, PREFIXES) - } - - def 'multiple Added then cleared Prefix Values'() { - given: - Project project = ProjectBuilder.builder().build() - File srcDir = new File(projectDir, 'src') - srcDir.mkdirs() - new File(srcDir, 'apple').withWriter { out -> out.write('apple') } - - project.apply plugin: 'org.xbib.gradle.plugin.rpm' - - def rpmTask = project.task([type: Rpm], 'buildRpm', { - destinationDir = project.file('build/tmp/RpmPluginTest') - destinationDir.mkdirs() - - packageName = 'one-prefix' - version = '1.0' - release = '1' - arch = I386 - os = LINUX - - into '/opt/myprefix' - from (srcDir) - - prefixes '/opt/myprefix', '/etc/init.d' - prefixes.clear() - }) - - when: - rpmTask.copy() - - then: - def scan = RpmReader.read(project.file('build/tmp/RpmPluginTest/one-prefix-1.0-1.i386.rpm').toPath()) - null == RpmReader.getHeaderEntry(scan, PREFIXES) - } - - def 'direct assignment of Prefix Values'() { - given: - Project project = ProjectBuilder.builder().build() - File srcDir = new File(projectDir, 'src') - srcDir.mkdirs() - new File(srcDir, 'apple').withWriter { out -> out.write('apple') } - - project.apply plugin: 'org.xbib.gradle.plugin.rpm' - - def rpmTask = project.task([type: Rpm], 'buildRpm', { - destinationDir = project.file('build/tmp/RpmPluginTest') - destinationDir.mkdirs() - - packageName = 'multi-prefix' - version = '1.0' - release = '1' - arch = I386 - os = LINUX - - into '/opt/myprefix' - from (srcDir) - - prefixes = ['/opt/myprefix', '/etc/init.d'] - }) - - when: - rpmTask.copy() - - then: - def scan = RpmReader.read(project.file('build/tmp/RpmPluginTest/multi-prefix-1.0-1.i386.rpm').toPath()) - // NOTE: Scanner just jams things together as one string - '/opt/myprefix/etc/init.d' == RpmReader.getHeaderEntryString(scan, PREFIXES) - } - - def 'ospackage assignment of Prefix Values'() { - given: - Project project = ProjectBuilder.builder().build() - File srcDir = new File(projectDir, 'src') - srcDir.mkdirs() - new File(srcDir, 'apple').withWriter { out -> out.write('apple') } - - project.apply plugin: 'org.xbib.gradle.plugin.rpm' - //project.ospackage { prefixes = ['/opt/ospackage', '/etc/maybe'] } - - def rpmTask = project.task([type: Rpm], 'buildRpm', { - destinationDir = project.file('build/tmp/RpmPluginTest') - destinationDir.mkdirs() - - packageName = 'multi-prefix' - version = '1.0' - release = '1' - arch = I386 - os = LINUX - prefix '/apps' - - into '/opt/myprefix' - from (srcDir) - }) - - when: - rpmTask.copy() - - then: - def scan = RpmReader.read(project.file('build/tmp/RpmPluginTest/multi-prefix-1.0-1.i386.rpm').toPath()) - // NOTE: Scanner just jams things together as one string - def foundPrefixes = RpmReader.getHeaderEntry(scan, PREFIXES) - foundPrefixes.values.contains('/apps') - //foundPrefixes.values.contains('/opt/ospackage') - //foundPrefixes.values.contains('/etc/maybe') - } - - def 'Avoids including empty directories'() { - Project project = ProjectBuilder.builder().build() - - File myDir = new File(projectDir, 'my') - File contentDir = new File(myDir, 'own/content') - contentDir.mkdirs() - new File(contentDir, 'myfile.txt').withWriter { out -> out.write('test') } - - File emptyDir = new File(myDir, 'own/empty') - emptyDir.mkdirs() - - project.apply plugin: 'org.xbib.gradle.plugin.rpm' - - project.task([type: Rpm], 'buildRpm', { - destinationDir = project.file('build/tmp/RpmPluginTest') - destinationDir.mkdirs() - - packageName = 'bleah' - version = '1.0' - release = '1' - arch = I386 - - from(myDir) { - addParentDirs false - } - includeEmptyDirs false - }) - - when: - project.tasks.buildRpm.copy() - - then: - def res = RpmReader.read(project.file('build/tmp/RpmPluginTest/bleah-1.0-1.i386.rpm').toPath()) - res.files*.name.every { './own/content/myfile.txt'.startsWith(it) } - } - - def 'Can create empty directories'() { - Project project = ProjectBuilder.builder().build() - - File myDir = new File(projectDir, 'my') - File contentDir = new File(myDir, 'own/content') - contentDir.mkdirs() - new File(contentDir, 'myfile.txt').withWriter { out -> out.write('test') } - - File otherDir = new File(projectDir, 'other') - otherDir.mkdirs() - File someDir = new File(otherDir, 'some') - someDir.mkdirs() - File emptyDir = new File(someDir, 'empty') - emptyDir.mkdirs() - - project.apply plugin: 'org.xbib.gradle.plugin.rpm' - - project.task([type: Rpm], 'buildRpm', { - destinationDir = project.file('build/tmp/RpmPluginTest') - destinationDir.mkdirs() - - packageName = 'bleah' - version = '1.0' - release = '1' - arch = I386 - - from(myDir) { - addParentDirs false - } - - from(someDir) { - into '/inside/the/archive' - addParentDirs false - createDirectoryEntry true - } - - directory('/using/the/dsl') - }) - - when: - project.tasks.buildRpm.copy() - - then: - def res = RpmReader.read(project.file('build/tmp/RpmPluginTest/bleah-1.0-1.i386.rpm').toPath()) - res.files*.name.containsAll(['./inside/the/archive/empty', './own/content/myfile.txt', './using/the/dsl']) - res.files*.type.containsAll([DIR, FILE]) - } - - def 'Sets owner and group for directory DSL'() { - Project project = ProjectBuilder.builder().build() - - project.apply plugin: 'org.xbib.gradle.plugin.rpm' - - project.task([type: Rpm], 'buildRpm', { - destinationDir = project.file('build/tmp/RpmPluginTest') - destinationDir.mkdirs() - - packageName = 'bleah' - version = '1.0' - release = '1' - arch = I386 - - user 'test' - permissionGroup 'test' - - directory('/using/the/dsl') - }) - - when: - project.tasks.buildRpm.copy() - - then: - def res = RpmReader.read(project.file('build/tmp/RpmPluginTest/bleah-1.0-1.i386.rpm').toPath()) - res.files*.name == ['./using/the/dsl'] - res.files*.type == [DIR] - res.format.header.getEntry(FILEGROUPNAME).values.toList() == ['test'] - } - - def 'has epoch value'() { - given: - Project project = ProjectBuilder.builder().build() - File srcDir = new File(projectDir, 'src') - srcDir.mkdirs() - new File(srcDir, 'apple').withWriter { out -> out.write('apple') } - - project.apply plugin: 'org.xbib.gradle.plugin.rpm' - - def rpmTask = project.task([type: Rpm], 'buildRpm', { - destinationDir = project.file('build/tmp/RpmPluginTest') - destinationDir.mkdirs() - - packageName = 'has-epoch' - version = '1.0' - release = '1' - epoch = 2 - arch = I386 - os = LINUX - - into '/opt/bleah' - from (srcDir) - }) - - when: - rpmTask.copy() - - then: - def res = RpmReader.read(project.file('build/tmp/RpmPluginTest/has-epoch-1.0-1.i386.rpm').toPath()) - 2 == RpmReader.getHeaderEntry(res, EPOCH).values[0] - } - - def 'Does not include signature header if signing is not fully configured'() { - given: - Project project = ProjectBuilder.builder().build() - - project.apply plugin: 'org.xbib.gradle.plugin.rpm' - - project.task([type: Rpm], 'buildRpm', { - destinationDir = project.file('build/tmp/RpmPluginTest') - destinationDir.mkdirs() - - packageName = 'bleah' - version = '1.0' - release = '1' - arch = I386 - }) - - when: - project.tasks.buildRpm.copy() - - then: - def res = RpmReader.read(project.file('build/tmp/RpmPluginTest/bleah-1.0-1.i386.rpm').toPath()) - res.format.signatureHeader.getEntry(SignatureTag.LEGACY_PGP) == null - } - - def 'Does include signature header'() { - given: - Project project = ProjectBuilder.builder().build() - - project.apply plugin: 'org.xbib.gradle.plugin.rpm' - - project.task([type: Rpm], 'buildRpm', { - destinationDir = project.file('build/tmp/RpmPluginTest') - destinationDir.mkdirs() - - packageName = 'bleah' - version = '1.0' - release = '1' - arch = I386 - - signingKeyId = 'F02C6D2C' - signingKeyPassphrase = 'test' - signingKeyRing = 'src/test/resources/pgp/test-secring.gpg' - }) - - when: - project.tasks.buildRpm.copy() - - then: - def res = RpmReader.read(project.file('build/tmp/RpmPluginTest/bleah-1.0-1.i386.rpm').toPath()) - res.format.signatureHeader.getEntry(SignatureTag.LEGACY_PGP) != null - } - - /** - * Verifies that a symlink can be preserved. - * - * The following directory structure is assumed: - * - * . - * └── usr - * └── bin - * ├── foo -> foo-1.2 - * └── foo-1.2 - * └── foo.txt - */ - def 'Preserves symlinks'() { - setup: - File symlinkDir = new File(projectDir, 'symlink') - File binDir = new File(symlinkDir, 'usr/bin') - File fooDir = new File(binDir, 'foo-1.2') - binDir.mkdirs() - fooDir.mkdirs() - new File(fooDir, 'foo.txt').withWriter { out -> out.write('foo') } - Files.createSymbolicLink(binDir.toPath().resolve('foo'), fooDir.toPath()) - - when: - project.apply plugin: 'org.xbib.gradle.plugin.rpm' - - Task task = project.task('buildRpm', type: Rpm) { - destinationDir = project.file('build/tmp/RpmPluginTest') - destinationDir.mkdirs() - - packageName = 'bleah' - version = '1.0' - release = '1' - type = BINARY - arch = I386 - - from(symlinkDir) { - createDirectoryEntry true - } - } - - task.copy() - - then: - def res = RpmReader.read(project.file('build/tmp/RpmPluginTest/bleah-1.0-1.i386.rpm').toPath()) - res.files*.name == ['./usr', './usr/bin', './usr/bin/foo', './usr/bin/foo-1.2', './usr/bin/foo-1.2/foo.txt'] - res.files*.type == [DIR, DIR, SYMLINK, DIR, FILE] - } - - @Ignore - def "Does not throw UnsupportedOperationException when copying external artifact with createDirectoryEntry option"() { - given: - String testCoordinates = 'org.xbib:foobar:1.0.0' - DependencyGraph graph = new DependencyGraph([testCoordinates]) - File reposRootDir = new File(project.buildDir, 'repos') - GradleDependencyGenerator generator = new GradleDependencyGenerator(graph, reposRootDir.absolutePath) - generator.generateTestMavenRepo() - - project.apply plugin: 'org.xbib.gradle.plugin.rpm' - - project.configurations { - myConf - } - - project.dependencies { - myConf testCoordinates - } - - project.repositories { - maven { - url { - "file://$reposRootDir/mavenrepo" - } - } - } - - Rpm rpmTask = project.task('buildRpm', type: Rpm) { - packageName = 'bleah' - - from(project.configurations.myConf) { - createDirectoryEntry = true - into('root/lib') - } - } - - when: - rpmTask.copy() - - then: - noExceptionThrown() - } - - @Unroll - def "Translates package description '#description' to header entry"() { - given: - project.apply plugin: 'org.xbib.gradle.plugin.rpm' - - Rpm rpmTask = project.task('buildRpm', type: Rpm) { - destinationDir = project.file('build/tmp/RpmPluginTest') - destinationDir.mkdirs() - - version = '1.0' - packageName = 'bleah' - packageDescription = description - } - - when: - rpmTask.copy() - - then: - def res = RpmReader.read(project.file('build/tmp/RpmPluginTest/bleah-1.0.noarch.rpm').toPath()) - RpmReader.getHeaderEntryString(res, DESCRIPTION) == headerEntry - - where: - description | headerEntry - 'This is a description' | 'This is a description' - '' | '' - null | '' - } - - @Unroll - def "Translates project description '#description' to header entry"() { - given: - project.apply plugin: 'org.xbib.gradle.plugin.rpm' - project.description = description - - Rpm rpmTask = project.task('buildRpm', type: Rpm) { - destinationDir = project.file('build/tmp/RpmPluginTest') - destinationDir.mkdirs() - - version = '1.0' - packageName = 'bleah' - } - - when: - rpmTask.copy() - - then: - def res = RpmReader.read(project.file('build/tmp/RpmPluginTest/bleah-1.0.noarch.rpm').toPath()) - RpmReader.getHeaderEntryString(res, DESCRIPTION) == headerEntry - - where: - description | headerEntry - 'This is a description' | 'This is a description' - '' | '' - null | '' - } - - def "Can set user and group for packaged files"() { - given: - File srcDir = new File(projectDir, 'src') - srcDir.mkdirs() - new File(srcDir, 'apple').withWriter { out -> out.write('apple') } - - project.apply plugin: 'org.xbib.gradle.plugin.rpm' - - Rpm rpmTask = project.task('buildRpm', type: Rpm) { - destinationDir = project.file('build/tmp/RpmPluginTest') - destinationDir.mkdirs() - - version = '1.0' - packageName = 'bleah' - - from(srcDir) { - user = 'me' - permissionGroup = 'awesome' - } - } - - when: - rpmTask.copy() - - then: - Header header = RpmReader.read(project.file('build/tmp/RpmPluginTest/bleah-1.0.noarch.rpm').toPath()).format.header - ['awesome'] == header.getEntry(FILEGROUPNAME).values.toList() - ['me'] == header.getEntry(FILEUSERNAME).values.toList() - } - - def "Can set multiple users and groups for packaged files"() { - given: - File srcDir = new File(projectDir, 'src') - File scriptDir = new File(projectDir, 'script') - srcDir.mkdirs() - scriptDir.mkdirs() - new File(srcDir, 'apple').withWriter { out -> out.write('apple') } - new File(scriptDir, 'orange').withWriter { out -> out.write('orange') } - new File(scriptDir, 'banana').withWriter { out -> out.write('banana') } - - project.apply plugin: 'org.xbib.gradle.plugin.rpm' - - Rpm rpmTask = project.task('buildRpm', type: Rpm) { - destinationDir = project.file('build/tmp/RpmPluginTest') - destinationDir.mkdirs() - - version = '1.0' - packageName = 'bleah' - - user 'defaultUser' - permissionGroup 'defaultGroup' - - from(srcDir) { - user 'me' - permissionGroup 'awesome' - } - - from(scriptDir) { - into '/etc' - } - } - - when: - rpmTask.copy() - - then: - Header header = RpmReader.read(project.file('build/tmp/RpmPluginTest/bleah-1.0.noarch.rpm').toPath()).format.header - ['awesome', 'defaultGroup', 'defaultGroup'] == header.getEntry(FILEGROUPNAME).values.toList() - ['me', 'defaultUser', 'defaultUser'] == header.getEntry(FILEUSERNAME).values.toList() - } - - @Unroll - def 'handle semantic versions with dashes and metadata (+) expect #version to be #expected'() { - given: - project.apply plugin: 'org.xbib.gradle.plugin.rpm' - project.version = version - - project.task([type: Rpm], 'buildRpm', { - destinationDir = project.file('build/tmp/RpmPluginTest') - destinationDir.mkdirs() - packageName = 'semvertest' - }) - - project.tasks.buildRpm.copy() - - expect: - project.file("build/tmp/RpmPluginTest/semvertest-${expected}.noarch.rpm").exists() - - where: - version | expected - '1.0' | '1.0' - '1.0.0' | '1.0.0' - '1.0.0-rc.1' | '1.0.0~rc.1' - '1.0.0-dev.3+abc219' | '1.0.0~dev.3' - } - - def 'handles multiple provides'() { - given: - project.apply plugin: 'org.xbib.gradle.plugin.rpm' - project.version = '1.0' - - project.task([type: Rpm], 'buildRpm', { - destinationDir = project.file('build/tmp/RpmPluginTest') - destinationDir.mkdirs() - packageName = 'providesTest' - provides 'foo' - provides 'bar' - }) - - when: - project.tasks.buildRpm.copy() - - then: - def res = RpmReader.read(project.file('build/tmp/RpmPluginTest/providesTest-1.0.noarch.rpm').toPath()) - def provides = RpmReader.getHeaderEntry(res, PROVIDENAME) - ['foo', 'bar'].every { it in provides.values } - } - - def 'Add preTrans and postTrans scripts'() { - given: - Path prescript = Paths.get(projectDir.toString(), 'prescript') - Path postscript = Paths.get(projectDir.toString(), 'postscript') - prescript.withWriter { out -> out.write('MyPreTransScript') } - postscript.withWriter { out -> out.write('MyPostTransScript') } - - Project project = ProjectBuilder.builder().build() - - project.apply plugin: 'org.xbib.gradle.plugin.rpm' - - project.task([type: Rpm], 'buildRpm', { - destinationDir = project.file('build/tmp/RpmPluginTest') - destinationDir.mkdirs() - - packageName = 'bleah' - version = '1.0' - release = '1' - arch = I386 - - preTrans prescript - postTrans postscript - }) - - when: - project.tasks.buildRpm.copy() - - then: - def res = RpmReader.read(project.file('build/tmp/RpmPluginTest/bleah-1.0-1.i386.rpm').toPath()) - def PRE_TRANS_HEADER_INDEX = 1151 - def POST_TRANS_HEADER_INDEX = 1152 - res.format.header.entries[PRE_TRANS_HEADER_INDEX].values[0].contains('MyPreTransScript') - res.format.header.entries[POST_TRANS_HEADER_INDEX].values[0].contains('MyPostTransScript') - } - - def 'preserve symlinks without closure'() { - given: - Path target = Files.createTempFile("file-to-symlink-to", "sh") - File file = project.file('bin/my-symlink') - file.parentFile.mkdirs() - Files.createSymbolicLink(Paths.get(file.path), target) - - when: - project.apply plugin: 'org.xbib.gradle.plugin.rpm' - - Rpm rpmTask = project.task([type: Rpm], 'buildRpm', { - from 'bin' - }) - rpmTask.copy() - - then: - def res = RpmReader.read(rpmTask.getArchivePath().toPath()) - def symlink = res.files.find { it.name == 'my-symlink' } - symlink.header.type == SYMLINK - } - - def 'preserve symlinks with closure'() { - given: - Path target = Files.createTempFile("file-to-symlink-to", "sh") - File file = project.file('bin/my-symlink') - file.parentFile.mkdirs() - Files.createSymbolicLink(file.toPath(), target) - - when: - project.apply plugin: 'org.xbib.gradle.plugin.rpm' - - Rpm rpmTask = project.task([type: Rpm], 'buildRpm', { - from('bin') { - into 'lib' - } - }) - rpmTask.copy() - - then: - def res = RpmReader.read(rpmTask.getArchivePath().toPath()) - def symlink = res.files.find { it.name == 'lib/my-symlink' } - symlink.header.type == SYMLINK - } -} diff --git a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/RpmReader.groovy b/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/RpmReader.groovy deleted file mode 100644 index 64ea920..0000000 --- a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/RpmReader.groovy +++ /dev/null @@ -1,131 +0,0 @@ -package org.xbib.gradle.plugin.rpm - -import groovy.transform.Canonical -import org.xbib.io.compress.bzip2.Bzip2InputStream -import org.xbib.io.compress.xz.XZInputStream -import org.xbib.rpm.header.Header -import org.xbib.rpm.header.HeaderTag -import org.xbib.rpm.header.entry.SpecEntry -import org.xbib.rpm.io.ChannelWrapper -import org.xbib.rpm.io.ReadableChannelWrapper -import org.xbib.rpm.format.Format -import org.xbib.rpm.payload.CompressionType -import org.xbib.rpm.payload.CpioHeader -import org.spockframework.util.Nullable - -import java.nio.ByteBuffer -import java.nio.CharBuffer -import java.nio.channels.Channels -import java.nio.charset.Charset -import java.nio.charset.StandardCharsets -import java.nio.file.Path -import java.util.zip.GZIPInputStream - -import static org.xbib.rpm.header.HeaderTag.HEADERIMMUTABLE -import static org.xbib.rpm.signature.SignatureTag.SIGNATURES -import static org.junit.Assert.assertEquals - -/** - * - */ -class RpmReader { - - @Canonical - static class ReaderResult { - Format format - List files - } - - @Canonical - static class ReaderFile { - @Delegate - CpioHeader header - - @Nullable - ByteBuffer contents - - String asString() { - if (contents == null ) { - return null - } - Charset charset = StandardCharsets.UTF_8 - CharBuffer buffer = charset.decode(contents) - return buffer.toString() - } - } - - static ReaderResult read(Path path) throws Exception { - ReaderResult readerResult = null - path.withInputStream { InputStream inputStream -> - readerResult = read(inputStream) - } - readerResult - } - - static ReaderResult read(InputStream inputStream, boolean includeContents = true) { - ReadableChannelWrapper wrapper = new ReadableChannelWrapper(Channels.newChannel(inputStream)) - Format format = readHeader(wrapper) - InputStream uncompressed = createUncompressedStream(format.getHeader(), inputStream) - wrapper = new ReadableChannelWrapper(Channels.newChannel(uncompressed)) - CpioHeader header = null - def files = [] - int total = 0 - while (header == null || !header.isLast()) { - header = new CpioHeader() - total = header.read(wrapper, total) - final int fileSize = header.getFileSize() - boolean includingContents = includeContents && header.type == CpioHeader.FILE - if (!header.isLast()) { - ByteBuffer descriptor = includingContents ? ChannelWrapper.fill(wrapper, fileSize) : null - files += new ReaderFile(header, descriptor) - } - if (!includingContents) { - assertEquals(fileSize, uncompressed.skip(fileSize)) - } - total += fileSize - } - return new ReaderResult(format,files) - } - - static InputStream createUncompressedStream(Header header, InputStream inputStream) { - InputStream compressedInput = inputStream - SpecEntry pcEntry = header.getEntry(HeaderTag.PAYLOADCOMPRESSOR) - String[] pc = (String[]) pcEntry.getValues() - CompressionType compressionType = CompressionType.valueOf(pc[0].toUpperCase()) - switch (compressionType) { - case CompressionType.NONE: - break - case CompressionType.GZIP: - compressedInput = new GZIPInputStream(inputStream) - break - case CompressionType.BZIP2: - compressedInput = new Bzip2InputStream(inputStream) - break - case CompressionType.XZ: - compressedInput = new XZInputStream(inputStream) - break - } - compressedInput - } - - static Format readHeader(ReadableChannelWrapper wrapper) throws Exception { - Format format = new Format() - format.getLead().read(wrapper) - int count = format.signatureHeader.read(wrapper) - int expected = ByteBuffer.wrap(format.signatureHeader.getEntry(SIGNATURES).values, 8, 4).getInt() / -16 - assertEquals(expected, count) - count = format.getHeader().read(wrapper) - expected = ByteBuffer.wrap(format.getHeader().getEntry(HEADERIMMUTABLE).values, 8, 4).getInt() / -16 - assertEquals(expected, count) - return format - } - - def static getHeaderEntry(ReaderResult res, tag) { - def header = res.format.header - header.getEntry(tag.code) - } - - def static getHeaderEntryString(ReaderResult res, tag) { - getHeaderEntry(res, tag)?.values?.join('') - } -} diff --git a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/SystemPackagingExtensionTest.groovy b/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/SystemPackagingExtensionTest.groovy deleted file mode 100644 index e415a9f..0000000 --- a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/SystemPackagingExtensionTest.groovy +++ /dev/null @@ -1,75 +0,0 @@ -package org.xbib.gradle.plugin.rpm - -import spock.lang.Specification - -class SystemPackagingExtensionTest extends Specification { - - SystemPackagingExtension extension = new SystemPackagingExtension() - - def "Can define required package name without version and flag"() { - given: - String packageName = 'myPackage' - - when: - extension.requires(packageName) - - then: - extension.dependencies.size() == 1 - Dependency dep = extension.dependencies[0] - dep.packageName == packageName - dep.version == '' - dep.flag == 0 - } - - def "Can define required package name with version and without flag"(){ - given: - String packageName = 'myPackage' - - when: - extension.requires(packageName, '1.0.0') - - then: - extension.dependencies.size() == 1 - Dependency dep = extension.dependencies[0] - dep.packageName == packageName - dep.version == '1.0.0' - dep.flag == 0 - } - - def "Can define required package name with version and flag"() { - given: - String packageName = 'myPackage' - - when: - extension.requires(packageName, '1.0.0', 5) - - then: - extension.dependencies.size() == 1 - Dependency dep = extension.dependencies[0] - dep.packageName == packageName - dep.version == '1.0.0' - dep.flag == 5 - } - - def "Cannot define required package name containing comma without version and flag"() { - given: - String packageName = 'myPackage,something' - - when: - extension.requires(packageName) - - then: - Throwable t = thrown(IllegalArgumentException) - } - - def "Cannot define required package name containing comma with version and flag"() { - given: - String packageName = 'myPackage,something' - - when: - extension.requires(packageName, '1.0.0', 5) - - then: - Throwable t = thrown(IllegalArgumentException) - } -} diff --git a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/validation/RpmPackageNameAttributeValidatorTest.groovy b/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/validation/RpmPackageNameAttributeValidatorTest.groovy deleted file mode 100644 index bd99d6c..0000000 --- a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/validation/RpmPackageNameAttributeValidatorTest.groovy +++ /dev/null @@ -1,35 +0,0 @@ -package org.xbib.gradle.plugin.rpm.validation - -import spock.lang.Specification -import spock.lang.Unroll - -class RpmPackageNameAttributeValidatorTest extends Specification { - - RpmPackageNameAttributeValidator validator = new RpmPackageNameAttributeValidator() - - @Unroll - def "verifies #description: '#attribute'"() { - when: - boolean valid = validator.validate(attribute) - - then: - valid == result - - where: - attribute | result | description - 'a25b' | true | 'valid package name with mixed alphanumeric characters' - 'my.awesome.package' | true | 'package with dot characters' - 'my-awesome-package' | true | 'package with dash characters' - 'my_awesome_package' | true | 'package with underscore characters' - 'My-Awesome-Package' | true | 'package with upper case characters' - 'abc^' | false | 'package name with an invalid character' - } - - def "provide error message"() { - when: - String errorMessage = validator.getErrorMessage('abc^') - - then: - errorMessage == "Invalid package name 'abc^' - a valid package name must only contain [a-zA-Z0-9-._+]" - } -} diff --git a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/validation/RpmTaskPropertiesValidatorIntegrationTest.groovy b/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/validation/RpmTaskPropertiesValidatorIntegrationTest.groovy deleted file mode 100644 index a9997a1..0000000 --- a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/validation/RpmTaskPropertiesValidatorIntegrationTest.groovy +++ /dev/null @@ -1,41 +0,0 @@ -package org.xbib.gradle.plugin.rpm.validation - -import org.gradle.api.InvalidUserDataException -import org.xbib.gradle.plugin.test.ProjectSpec -import org.xbib.gradle.plugin.rpm.Rpm - -class RpmTaskPropertiesValidatorIntegrationTest extends ProjectSpec { - - RpmTaskPropertiesValidator validator = new RpmTaskPropertiesValidator() - - def setup() { - project.apply plugin: 'org.xbib.gradle.plugin.rpm' - } - - def 'can execute Rpm task with valid version and package name'() { - given: - Rpm rpmTask = project.task('buildRpm', type: Rpm) { - packageName = 'can-execute-rpm-task-with-valid-version' - } - - when: - validator.validate(rpmTask) - - then: - noExceptionThrown() - } - - def 'executing a Rpm task with invalid package name throws exception'() { - given: - Rpm rpmTask = project.task('buildRpm', type: Rpm) { - packageName = 'abc^' - } - - when: - validator.validate(rpmTask) - - then: - Throwable t = thrown(InvalidUserDataException) - t.message == "Invalid package name 'abc^' - a valid package name must only contain [a-zA-Z0-9-._+]" - } -} diff --git a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/AbstractProjectSpec.groovy b/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/AbstractProjectSpec.groovy deleted file mode 100644 index 4c37a41..0000000 --- a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/AbstractProjectSpec.groovy +++ /dev/null @@ -1,52 +0,0 @@ -package org.xbib.gradle.plugin.test - -import org.gradle.api.Project -import org.gradle.testfixtures.ProjectBuilder -import org.junit.Rule -import org.junit.rules.TestName -import spock.lang.Specification - -abstract class AbstractProjectSpec extends Specification { - - static final String CLEAN_PROJECT_DIR_SYS_PROP = 'cleanProjectDir' - - File ourProjectDir - - @Rule TestName testName = new TestName() - - String canonicalName - - Project project - - MultiProjectHelper helper - - void setup() { - ourProjectDir = new File("build/xbibtest/${this.class.canonicalName}/${testName.methodName.replaceAll(/\W+/, '-')}").absoluteFile - if (ourProjectDir.exists()) { - ourProjectDir.deleteDir() - } - ourProjectDir.mkdirs() - canonicalName = testName.getMethodName().replaceAll(' ', '-') - project = ProjectBuilder.builder().withName(canonicalName).withProjectDir(ourProjectDir).build() - helper = new MultiProjectHelper(project) - } - - void cleanup() { - if (deleteProjectDir()) { - ourProjectDir.deleteDir() - } - } - - boolean deleteProjectDir() { - String cleanProjectDirSystemProperty = System.getProperty(CLEAN_PROJECT_DIR_SYS_PROP) - cleanProjectDirSystemProperty ? cleanProjectDirSystemProperty.toBoolean() : true - } - - Project addSubproject(String subprojectName) { - helper.addSubproject(subprojectName) - } - - Project addSubprojectWithDirectory(String subprojectName) { - helper.addSubprojectWithDirectory(subprojectName) - } -} diff --git a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/BaseIntegrationSpec.groovy b/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/BaseIntegrationSpec.groovy deleted file mode 100644 index efbe583..0000000 --- a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/BaseIntegrationSpec.groovy +++ /dev/null @@ -1,192 +0,0 @@ -package org.xbib.gradle.plugin.test - -import groovy.transform.CompileStatic -import groovy.transform.TypeCheckingMode -import org.gradle.api.logging.LogLevel -import org.junit.Rule -import org.junit.rules.TestName -import spock.lang.Specification - -abstract class BaseIntegrationSpec extends Specification { - @Rule - TestName testName = new TestName() - File projectDir - protected String moduleName - protected LogLevel logLevel = LogLevel.LIFECYCLE - protected List initScripts = [] - - private static final LOGGING_LEVEL_ENV_VARIABLE = "TEST_LOGGING_LEVEL" - - def setup() { - projectDir = new File("build/xbibtest/${this.class.canonicalName}/${testName.methodName.replaceAll(/\W+/, '-')}").absoluteFile - if (projectDir.exists()) { - projectDir.deleteDir() - } - projectDir.mkdirs() - moduleName = findModuleName() - } - - /** - * Override to alter its value - * @return - */ - protected LogLevel getLogLevel() { - String levelFromEnv = System.getenv(LOGGING_LEVEL_ENV_VARIABLE) - if(!levelFromEnv) { - return logLevel - } - return LogLevel.valueOf(levelFromEnv.toUpperCase()) - } - - /* Setup */ - - protected File directory(String path, File baseDir = getProjectDir()) { - new File(baseDir, path).with { - mkdirs() - it - } - } - - protected File file(String path, File baseDir = getProjectDir()) { - def splitted = path.split('/') - def directory = splitted.size() > 1 ? directory(splitted[0..-2].join('/'), baseDir) : baseDir - def file = new File(directory, splitted[-1]) - file.createNewFile() - file - } - - @CompileStatic(TypeCheckingMode.SKIP) - protected File createFile(String path, File baseDir = getProjectDir()) { - File file = file(path, baseDir) - if (!file.exists()) { - assert file.parentFile.mkdirs() || file.parentFile.exists() - file.createNewFile() - } - file - } - - protected static void checkForDeprecations(String output) { - def deprecations = output.readLines().findAll { - it.contains("has been deprecated and is scheduled to be removed in Gradle") || - it.contains("Deprecated Gradle features were used in this build") || - it.contains("has been deprecated. This is scheduled to be removed in Gradle") || - it.contains("This behaviour has been deprecated and is scheduled to be removed in Gradle") - } - // temporary for known issue with overwriting task - // overridden task expected to not be needed in future version - if (deprecations.size() == 1 && deprecations.first().contains("Creating a custom task named 'dependencyInsight' has been deprecated and is scheduled to be removed in Gradle 5.0.")) { - return - } - if (!System.getProperty("ignoreDeprecations") && !deprecations.isEmpty()) { - throw new IllegalArgumentException("Deprecation warnings were found (Set the ignoreDeprecations system property during the test to ignore):\n" + deprecations.collect { - " - $it" - }.join("\n")) - } - } - - protected static void checkForMutableProjectState(String output) { - def mutableProjectStateWarnings = output.readLines().findAll { - it.contains("was resolved without accessing the project in a safe manner") || - it.contains("This may happen when a configuration is resolved from a thread not managed by Gradle or from a different project") - - } - - if (!System.getProperty("ignoreMutableProjectStateWarnings") && !mutableProjectStateWarnings.isEmpty()) { - throw new IllegalArgumentException("Mutable Project State warnings were found (Set the ignoreMutableProjectStateWarnings system property during the test to ignore):\n" + mutableProjectStateWarnings.collect { - " - $it" - }.join("\n")) - } - } - - protected void writeHelloWorld(String packageDotted, File baseDir = getProjectDir()) { - def path = 'src/main/java/' + packageDotted.replace('.', '/') + '/HelloWorld.java' - def javaFile = createFile(path, baseDir) - javaFile << """\ - package ${packageDotted}; - - public class HelloWorld { - public static void main(String[] args) { - System.out.println("Hello Integration Test"); - } - } - """.stripIndent() - } - - /** - * Creates a unit test for testing your plugin. - * @param failTest true if you want the test to fail, false if the test should pass - * @param baseDir the directory to begin creation from, defaults to projectDir - */ - protected void writeUnitTest(boolean failTest, File baseDir = getProjectDir()) { - writeTest('src/test/java/', 'xbib', failTest, baseDir) - } - - /** - * - * Creates a unit test for testing your plugin. - * @param srcDir the directory in the project where the source file should be created. - * @param packageDotted the package for the unit test class, written in dot notation - * @param failTest true if you want the test to fail, false if the test should pass - * @param baseDir the directory to begin creation from, defaults to projectDir - */ - protected void writeTest(String srcDir, String packageDotted, boolean failTest, File baseDir = getProjectDir()) { - def path = srcDir + packageDotted.replace('.', '/') + '/HelloWorldTest.java' - def javaFile = createFile(path, baseDir) - javaFile << """\ - package ${packageDotted}; - import org.junit.Test; - import static org.junit.Assert.assertFalse; - - public class HelloWorldTest { - @Test public void doesSomething() { - assertFalse( $failTest ); - } - } - """.stripIndent() - } - - /** - * Creates a properties file to included as project resource. - * @param srcDir the directory in the project where the source file should be created. - * @param fileName to be used for the file, sans extension. The .properties extension will be added to the name. - * @param baseDir the directory to begin creation from, defaults to projectDir - */ - protected void writeResource(String srcDir, String fileName, File baseDir = getProjectDir()) { - def path = "$srcDir/${fileName}.properties" - def resourceFile = createFile(path, baseDir) - resourceFile.text = "firstProperty=foo.bar" - } - - protected void addResource(String srcDir, String filename, String contents, File baseDir = getProjectDir()) { - def resourceFile = createFile("${srcDir}/${filename}", baseDir) - resourceFile.text = contents - } - - protected String findModuleName() { - getProjectDir().getName().replaceAll(/_\d+/, '') - } - - protected List calculateArguments(String... args) { - List arguments = [] - // Gradle will use these files name from the PWD, instead of the project directory. It's easier to just leave - // them out and let the default find them, since we're not changing their default names. - //arguments += '--build-file' - //arguments += (buildFile.canonicalPath - projectDir.canonicalPath).substring(1) - //arguments += '--settings-file' - //arguments += (settingsFile.canonicalPath - projectDir.canonicalPath).substring(1) - //arguments += '--no-daemon' - switch (getLogLevel()) { - case LogLevel.INFO: - arguments += '--info' - break - case LogLevel.DEBUG: - arguments += '--debug' - break - } - arguments += '--stacktrace' - arguments += '-Dorg.gradle.warning.mode=all' - arguments.addAll(args) - arguments.addAll(initScripts.collect { file -> '-I' + file.absolutePath }) - arguments - } -} \ No newline at end of file diff --git a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/BuildLauncherBackedGradleHandle.groovy b/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/BuildLauncherBackedGradleHandle.groovy deleted file mode 100644 index 636f420..0000000 --- a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/BuildLauncherBackedGradleHandle.groovy +++ /dev/null @@ -1,96 +0,0 @@ -package org.xbib.gradle.plugin.test - -import org.gradle.tooling.BuildException -import org.gradle.tooling.BuildLauncher -import org.gradle.tooling.ProgressEvent -import org.gradle.tooling.ProgressListener - -class BuildLauncherBackedGradleHandle implements GradleHandle { - - final private ByteArrayOutputStream standardOutput = new ByteArrayOutputStream() - - final private ByteArrayOutputStream standardError = new ByteArrayOutputStream() - - final private BuildLauncher launcher - - final private boolean forkedProcess - - final private List tasksExecuted - - public static final String PROGRESS_TASK_PREFIX = "Task :" - - private GradleHandleBuildListener buildListener - - BuildLauncherBackedGradleHandle(BuildLauncher launcher, boolean forkedProcess) { - this.forkedProcess = forkedProcess - launcher.setStandardOutput(standardOutput) - launcher.setStandardError(standardError) - tasksExecuted = new ArrayList() - launcher.addProgressListener(new ProgressListener() { - @Override - void statusChanged(ProgressEvent event) { - // These are free form strings, :-( - if (event.description.startsWith(PROGRESS_TASK_PREFIX)) { // E.g. "Task :echo" - String taskName = event.description.substring(PROGRESS_TASK_PREFIX.length() - 1) - tasksExecuted.add(taskName) - } - } - }) - this.launcher = launcher - } - - @Override - void registerBuildListener(GradleHandleBuildListener buildListener) { - this.buildListener = buildListener - } - - @Override - boolean isForkedProcess() { - forkedProcess - } - - private String getStandardOutput() { - return standardOutput.toString() - } - - private String getStandardError() { - return standardError.toString() - } - - @Override - ExecutionResult run() { - Throwable failure = null - try { - buildListener?.buildStarted() - launcher.run() - } catch(BuildException e) { - failure = e.getCause() - } catch(Exception e) { - failure = e - } - finally { - buildListener?.buildFinished() - } - String stdout = getStandardOutput() - List tasks = new ArrayList<>() - for (String taskName: tasksExecuted) { - boolean upToDate = isTaskUpToDate(stdout, taskName) - boolean skipped = isTaskSkipped(stdout, taskName) - tasks.add(new MinimalExecutedTask(taskName, upToDate, skipped)) - } - boolean success = failure == null - new ToolingExecutionResult(success, stdout, getStandardError(), tasks, failure) - } - - private isTaskUpToDate(String stdout, String taskName) { - containsOutput(stdout, taskName, 'UP-TO-DATE') - } - - private isTaskSkipped(String stdout, String taskName) { - containsOutput(stdout, taskName, 'SKIPPED') - } - - private boolean containsOutput(String stdout, String taskName, String stateIdentifier) { - stdout.contains("$taskName $stateIdentifier".toString()) - } -} diff --git a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/ClasspathAddingInitScriptBuilder.groovy b/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/ClasspathAddingInitScriptBuilder.groovy deleted file mode 100644 index e90cc00..0000000 --- a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/ClasspathAddingInitScriptBuilder.groovy +++ /dev/null @@ -1,58 +0,0 @@ -package org.xbib.gradle.plugin.test - -import com.google.common.base.Function -import com.google.common.base.Predicate -import com.google.common.collect.FluentIterable -import org.gradle.internal.ErroringAction -import org.gradle.internal.IoActions -import org.gradle.internal.classloader.ClasspathUtil -import org.gradle.internal.classpath.ClassPath -import org.gradle.util.TextUtil - -class ClasspathAddingInitScriptBuilder { - - private ClasspathAddingInitScriptBuilder() { - } - - static void build(File initScriptFile, final ClassLoader classLoader, Predicate classpathFilter) { - build(initScriptFile, getClasspathAsFiles(classLoader, classpathFilter)) - } - - static void build(File initScriptFile, final List classpath) { - IoActions.writeTextFile(initScriptFile, new ErroringAction() { - @Override - protected void doExecute(Writer writer) throws Exception { - writer.write("allprojects {\n") - writer.write(" buildscript {\n") - writer.write(" dependencies {\n") - for (File file : classpath) { - writer.write(String.format(" classpath files('%s')\n", TextUtil.escapeString(file.getAbsolutePath()))) - } - writer.write(" }\n") - writer.write(" }\n") - writer.write("}\n") - } - }) - } - - static List getClasspathAsFiles(ClassLoader classLoader, Predicate classpathFilter) { - List classpathUrls = getClasspathUrls(classLoader) - return FluentIterable.from(classpathUrls).filter(classpathFilter).transform(new Function() { - @Override - File apply(URL url) { - return new File(url.toURI()) - } - }).toList() - } - - private static List getClasspathUrls(ClassLoader classLoader) { - Object cp = ClasspathUtil.getClasspath(classLoader) - if (cp instanceof List) { - return (List) cp - } - if (cp instanceof ClassPath) { - return ((ClassPath) cp).asURLs - } - throw new IllegalStateException("Unable to extract classpath urls from type ${cp.class.canonicalName}") - } -} \ No newline at end of file diff --git a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/ClasspathInjectingGradleHandleFactory.groovy b/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/ClasspathInjectingGradleHandleFactory.groovy deleted file mode 100644 index b514b68..0000000 --- a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/ClasspathInjectingGradleHandleFactory.groovy +++ /dev/null @@ -1,35 +0,0 @@ -package org.xbib.gradle.plugin.test; - -import com.google.common.base.Predicate -import org.gradle.util.GFileUtils - -class ClasspathInjectingGradleHandleFactory implements GradleHandleFactory { - - private final ClassLoader classLoader - - private final GradleHandleFactory delegateFactory - - private Predicate classpathFilter - - ClasspathInjectingGradleHandleFactory(ClassLoader classLoader, GradleHandleFactory delegateFactory, - Predicate classpathFilter) { - this.classpathFilter = classpathFilter - this.classLoader = classLoader - this.delegateFactory = delegateFactory - } - - @Override - GradleHandle start(File projectDir, List arguments, List jvmArguments = []) { - File testKitDir = new File(projectDir, ".gradle-test-kit") - if (!testKitDir.exists()) { - GFileUtils.mkdirs(testKitDir) - } - File initScript = new File(testKitDir, "init.gradle"); - ClasspathAddingInitScriptBuilder.build(initScript, classLoader, classpathFilter) - List ammendedArguments = new ArrayList(arguments.size() + 2) - ammendedArguments.add("--init-script") - ammendedArguments.add(initScript.getAbsolutePath()) - ammendedArguments.addAll(arguments) - return delegateFactory.start(projectDir, ammendedArguments, jvmArguments) - } -} diff --git a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/Coordinate.groovy b/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/Coordinate.groovy deleted file mode 100644 index 565f6b2..0000000 --- a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/Coordinate.groovy +++ /dev/null @@ -1,18 +0,0 @@ -package org.xbib.gradle.plugin.test - -import groovy.transform.Immutable - -@Immutable -class Coordinate { - - String group - - String artifact - - String version - - @Override - String toString() { - "${group}:${artifact}:${version}" - } -} diff --git a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/DefaultExecutionResult.groovy b/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/DefaultExecutionResult.groovy deleted file mode 100644 index 1210059..0000000 --- a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/DefaultExecutionResult.groovy +++ /dev/null @@ -1,90 +0,0 @@ -package org.xbib.gradle.plugin.test; - -import org.gradle.api.GradleException - -abstract class DefaultExecutionResult implements ExecutionResult { - - private final Boolean success - - private final String standardOutput - - private final String standardError - - private final List executedTasks - - private final Throwable failure - - DefaultExecutionResult(Boolean success, String standardOutput, String standardError, - List executedTasks, Throwable failure) { - this.success = success - this.standardOutput = standardOutput - this.standardError = standardError - this.executedTasks = executedTasks - this.failure = failure - } - - @Override - Boolean getSuccess() { - success - } - - @Override - String getStandardOutput() { - standardOutput - } - - @Override - String getStandardError() { - standardError - } - - @Override - boolean wasExecuted(String taskPath) { - executedTasks.any { ExecutedTask task -> - taskPath = normalizeTaskPath(taskPath) - def match = task.path == taskPath - return match - } - } - - @Override - boolean wasUpToDate(String taskPath) { - getExecutedTaskByPath(taskPath).upToDate - } - - @Override - boolean wasSkipped(String taskPath) { - getExecutedTaskByPath(taskPath).skipped - } - - String normalizeTaskPath(String taskPath) { - taskPath.startsWith(':') ? taskPath : ":$taskPath" - } - - private ExecutedTask getExecutedTaskByPath(String taskPath) { - taskPath = normalizeTaskPath(taskPath) - def task = executedTasks.find { ExecutedTask task -> - task.path == taskPath - } - if (task == null) { - throw new RuntimeException("Task with path $taskPath was not found") - } - task - } - - @Override - Throwable getFailure() { - failure - } - - @Override - ExecutionResult rethrowFailure() { - if (failure instanceof GradleException) { - throw (GradleException) failure - } - if (failure != null) { - throw new GradleException("Build aborted because of an internal error.", failure) - } - this - } -} diff --git a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/DefaultGradleRunner.groovy b/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/DefaultGradleRunner.groovy deleted file mode 100644 index 3d7dcc5..0000000 --- a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/DefaultGradleRunner.groovy +++ /dev/null @@ -1,25 +0,0 @@ -package org.xbib.gradle.plugin.test - -class DefaultGradleRunner implements GradleRunner { - - private final GradleHandleFactory handleFactory - - DefaultGradleRunner(GradleHandleFactory handleFactory) { - this.handleFactory = handleFactory - } - - @Override - ExecutionResult run(File projectDir, List arguments, List jvmArguments = [], - List preExecutionActions = []) { - handle(projectDir, arguments, jvmArguments, preExecutionActions).run() - } - - @Override - GradleHandle handle(File projectDir, List arguments, List jvmArguments = [], - List preExecutionActions = []) { - preExecutionActions?.each { - it.execute(projectDir, arguments, jvmArguments) - } - handleFactory.start(projectDir, arguments, jvmArguments) - } -} diff --git a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/DependencyGraph.groovy b/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/DependencyGraph.groovy deleted file mode 100644 index f659676..0000000 --- a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/DependencyGraph.groovy +++ /dev/null @@ -1,37 +0,0 @@ -package org.xbib.gradle.plugin.test - -class DependencyGraph { - - Collection nodes = [] - - DependencyGraph(List graph) { - graph.each { nodes << parseNode(it) } - } - - DependencyGraph(String... graph) { - this(graph as List) - } - - DependencyGraph(Map tuple) { - nodes = tuple.nodes - } - - private DependencyGraphNode parseNode(String s) { - // Don't use tokenize, it'll make each character a possible delimeter, e.g. \t\n would tokenize on both - // \t OR \n, not the combination of \t\n. - def parts = s.split('->') - def (group, artifact, version) = parts[0].trim().tokenize(':') - def coordinate = new Coordinate(group: group, artifact: artifact, version: version) - def dependencies = (parts.size() > 1) ? parseDependencies(parts[1]) : [] - new DependencyGraphNode(coordinate: coordinate, dependencies: dependencies) - } - - private List parseDependencies(String s) { - List dependencies = [] - s.tokenize('|').each { String dependency -> - def (group, artifact, version) = dependency.trim().tokenize(':') - dependencies << new Coordinate(group: group, artifact: artifact, version: version) - } - dependencies - } -} diff --git a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/DependencyGraphNode.groovy b/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/DependencyGraphNode.groovy deleted file mode 100644 index ee3fcc8..0000000 --- a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/DependencyGraphNode.groovy +++ /dev/null @@ -1,16 +0,0 @@ -package org.xbib.gradle.plugin.test - -import groovy.transform.Immutable - -@Immutable -class DependencyGraphNode { - - @Delegate Coordinate coordinate - - List dependencies = [] - - @Override - String toString() { - "${group}:${artifact}:${version}" - } -} diff --git a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/ExecutedTask.groovy b/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/ExecutedTask.groovy deleted file mode 100644 index 986ae72..0000000 --- a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/ExecutedTask.groovy +++ /dev/null @@ -1,10 +0,0 @@ -package org.xbib.gradle.plugin.test - -interface ExecutedTask { - - String getPath() - - boolean isUpToDate() - - boolean isSkipped() -} diff --git a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/ExecutionResult.groovy b/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/ExecutionResult.groovy deleted file mode 100644 index 75df990..0000000 --- a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/ExecutionResult.groovy +++ /dev/null @@ -1,20 +0,0 @@ -package org.xbib.gradle.plugin.test; - -interface ExecutionResult { - - Boolean getSuccess() - - String getStandardOutput() - - String getStandardError() - - boolean wasExecuted(String taskPath) - - boolean wasUpToDate(String taskPath) - - boolean wasSkipped(String taskPath) - - Throwable getFailure() - - ExecutionResult rethrowFailure() -} diff --git a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/GradleDependencyGenerator.groovy b/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/GradleDependencyGenerator.groovy deleted file mode 100644 index d15d343..0000000 --- a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/GradleDependencyGenerator.groovy +++ /dev/null @@ -1,104 +0,0 @@ -package org.xbib.gradle.plugin.test - -class GradleDependencyGenerator { - - static final String STANDARD_SUBPROJECT_BLOCK = '''\ - subprojects { - apply plugin: 'maven-publish' - apply plugin: 'java' - - publishing { - repositories { - maven { - url "../mavenrepo" - } - } - publications { - maven(MavenPublication) { - from components.java - } - } - } - } - '''.stripIndent() - static final String BUILD_GRADLE = 'build.gradle' - - private boolean generated = false - - DependencyGraph graph - File gradleRoot - File mavenRepoDir - - GradleDependencyGenerator(DependencyGraph graph, String directory = 'build/testrepogen') { - this.graph = graph - this.gradleRoot = new File(directory) - this.mavenRepoDir = new File(directory, 'mavenrepo') - generateGradleFiles() - } - - File generateTestMavenRepo() { - runTasks('publishMavenPublicationToMavenRepository') - - mavenRepoDir - } - - String getMavenRepoDirPath() { - mavenRepoDir.absolutePath - } - - String getMavenRepoUrl() { - mavenRepoDir.toURI().toURL() - } - - String getMavenRepositoryBlock() { - """\ - maven { url '${getMavenRepoUrl()}' } - """.stripIndent() - } - - private void generateGradleFiles() { - if (generated) { - return - } else { - generated = true - } - - gradleRoot.mkdirs() - def rootBuildGradle = new File(gradleRoot, BUILD_GRADLE) - rootBuildGradle.text = STANDARD_SUBPROJECT_BLOCK - def includes = [] - graph.nodes.each { DependencyGraphNode n -> - String subName = "${n.group}.${n.artifact}_${n.version.replaceAll(/\./, '_')}" - includes << subName - def subfolder = new File(gradleRoot, subName) - subfolder.mkdir() - def subBuildGradle = new File(subfolder, BUILD_GRADLE) - subBuildGradle.text = generateSubBuildGradle(n) - } - def settingsGradle = new File(gradleRoot, 'settings.gradle') - settingsGradle.text = 'include ' + includes.collect { "'${it}'"}.join(', ') - } - - private String generateSubBuildGradle(DependencyGraphNode node) { - - StringWriter block = new StringWriter() - if (node.dependencies) { - block.withPrintWriter { writer -> - writer.println 'dependencies {' - node.dependencies.each { writer.println " compile '${it}'" } - writer.println '}' - } - } - - """\ - group = '${node.group}' - version = '${node.version}' - ext { artifactName = '${node.artifact}' } - """.stripIndent() + block.toString() - } - - private void runTasks(String tasks) { - def runner = GradleRunnerFactory.createTooling() - runner.run(gradleRoot, tasks.tokenize()).rethrowFailure() - } -} \ No newline at end of file diff --git a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/GradleHandle.groovy b/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/GradleHandle.groovy deleted file mode 100644 index e42bc3a..0000000 --- a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/GradleHandle.groovy +++ /dev/null @@ -1,10 +0,0 @@ -package org.xbib.gradle.plugin.test - -interface GradleHandle { - - ExecutionResult run() - - void registerBuildListener(GradleHandleBuildListener buildListener) - - boolean isForkedProcess() -} diff --git a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/GradleHandleBuildListener.groovy b/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/GradleHandleBuildListener.groovy deleted file mode 100644 index 619fc21..0000000 --- a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/GradleHandleBuildListener.groovy +++ /dev/null @@ -1,8 +0,0 @@ -package org.xbib.gradle.plugin.test - -interface GradleHandleBuildListener { - - void buildStarted() - - void buildFinished() -} diff --git a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/GradleHandleFactory.groovy b/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/GradleHandleFactory.groovy deleted file mode 100644 index 3a5851a..0000000 --- a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/GradleHandleFactory.groovy +++ /dev/null @@ -1,8 +0,0 @@ -package org.xbib.gradle.plugin.test - -interface GradleHandleFactory { - - GradleHandle start(File dir, List arguments) - - GradleHandle start(File dir, List arguments, List jvmArguments) -} diff --git a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/GradleRunner.groovy b/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/GradleRunner.groovy deleted file mode 100644 index 64eb3a8..0000000 --- a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/GradleRunner.groovy +++ /dev/null @@ -1,78 +0,0 @@ -package org.xbib.gradle.plugin.test - -import com.google.common.base.Predicate -import com.google.common.base.Predicates -import com.google.common.base.StandardSystemProperty - -interface GradleRunner { - // These predicates are here, instead of on GradleRunnerFactory due to a Groovy static compiler bug - // https://issues.apache.org/jira/browse/GROOVY-7159 - - static final Predicate CLASSPATH_GRADLE_CACHE = new Predicate() { - @Override - boolean apply(URL url) { - return url.path.contains('/caches/modules-') - } - } - - static final Predicate CLASSPATH_PROJECT_DIR = new Predicate() { - @Override - boolean apply(URL url) { - File userDir = new File(StandardSystemProperty.USER_DIR.value()) - return url.path.startsWith(userDir.toURI().toURL().path) - } - } - - static final Predicate CLASSPATH_PROJECT_DEPENDENCIES = new Predicate() { - @Override - boolean apply(URL url) { - return url.path.contains('/build/classes') || - url.path.contains('/build/resources') || - url.path.contains('/build/libs') || - url.path.contains('/out/') - } - } - - /** - * Attempts to provide a classpath that approximates the 'normal' Gradle runtime classpath. Use {@link #CLASSPATH_ALL} - * to default to pre-2.2.2 behaviour. - */ - static final Predicate CLASSPATH_DEFAULT = - Predicates.or(CLASSPATH_PROJECT_DIR, CLASSPATH_GRADLE_CACHE, CLASSPATH_PROJECT_DEPENDENCIES) - - /** - * Accept all URLs. Provides pre-2.2.2 behaviour. - */ - static final Predicate CLASSPATH_ALL = new Predicate() { - @Override - boolean apply(URL url) { - return true - } - } - - /** - * Create handle and run build - * @param directory - * @param args - * @return results from execution - */ - ExecutionResult run(File directory, List args) - - ExecutionResult run(File directory, List args, List jvmArgs) - - ExecutionResult run(File directory, List args, List jvmArgs, - List preExecutionActions) - - /** - * Handle on instance of Gradle that can be run. - * @param directory - * @param args - * @return handle - */ - GradleHandle handle(File directory, List args) - - GradleHandle handle(File directory, List args, List jvmArgs) - - GradleHandle handle(File directory, List args, List jvmArgs, - List preExecutionActions) -} \ No newline at end of file diff --git a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/GradleRunnerFactory.groovy b/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/GradleRunnerFactory.groovy deleted file mode 100644 index c86e9db..0000000 --- a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/GradleRunnerFactory.groovy +++ /dev/null @@ -1,26 +0,0 @@ -package org.xbib.gradle.plugin.test - -import com.google.common.base.Predicate - -class GradleRunnerFactory { - - static GradleRunner createTooling(boolean fork = false, String version = null, - Integer daemonMaxIdleTimeInSeconds = null, - Predicate classpathFilter = null) { - GradleHandleFactory toolingApiHandleFactory = - new ToolingApiGradleHandleFactory(fork, version, daemonMaxIdleTimeInSeconds) - return create(toolingApiHandleFactory, classpathFilter ?: GradleRunner.CLASSPATH_DEFAULT) - } - - static GradleRunner create(GradleHandleFactory handleFactory, Predicate classpathFilter = null) { - ClassLoader sourceClassLoader = GradleRunnerFactory.class.getClassLoader() - create(handleFactory, sourceClassLoader, classpathFilter ?: GradleRunner.CLASSPATH_DEFAULT) - } - - static GradleRunner create(GradleHandleFactory handleFactory, ClassLoader sourceClassLoader, - Predicate classpathFilter) { - GradleHandleFactory classpathInjectingHandleFactory = - new ClasspathInjectingGradleHandleFactory(sourceClassLoader, handleFactory, classpathFilter) - return new DefaultGradleRunner(classpathInjectingHandleFactory) - } -} diff --git a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/IntegrationSpec.groovy b/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/IntegrationSpec.groovy deleted file mode 100644 index eb9b509..0000000 --- a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/IntegrationSpec.groovy +++ /dev/null @@ -1,185 +0,0 @@ -package org.xbib.gradle.plugin.test - -import com.google.common.base.Predicate -import org.gradle.api.logging.LogLevel - -abstract class IntegrationSpec extends BaseIntegrationSpec { - - private static final String DEFAULT_REMOTE_DEBUG_JVM_ARGUMENTS = "-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005" - - private static final Integer DEFAULT_DAEMON_MAX_IDLE_TIME_IN_SECONDS_IN_MEMORY_SAFE_MODE = 15; - - private ExecutionResult result - - protected String gradleVersion - - protected LogLevel logLevel = LogLevel.INFO - - protected String moduleName - - protected File settingsFile - - protected File buildFile - - protected boolean fork = false - - protected boolean remoteDebug = false - - protected List jvmArguments = [] - - protected Predicate classpathFilter - - protected List initScripts = [] - - protected List preExecutionActions = [] - - //Shutdown Gradle daemon after a few seconds to release memory. Useful for testing with multiple Gradle versions on shared CI server - protected boolean memorySafeMode = false - - protected Integer daemonMaxIdleTimeInSecondsInMemorySafeMode = DEFAULT_DAEMON_MAX_IDLE_TIME_IN_SECONDS_IN_MEMORY_SAFE_MODE - - String findModuleName() { - getProjectDir().getName().replaceAll(/_\d+/, '') - } - - def setup() { - moduleName = findModuleName() - if (!settingsFile) { - settingsFile = new File(getProjectDir(), 'settings.gradle') - settingsFile.text = "rootProject.name='${moduleName}'\n" - } - if (!buildFile) { - buildFile = new File(getProjectDir(), 'build.gradle') - } - buildFile << "// Running test for ${moduleName}\n" - } - - protected GradleHandle launcher(String... args) { - List arguments = calculateArguments(args) - List jvmArguments = calculateJvmArguments() - Integer daemonMaxIdleTimeInSeconds = calculateMaxIdleDaemonTimeoutInSeconds() - GradleRunner runner = GradleRunnerFactory.createTooling(fork, gradleVersion, daemonMaxIdleTimeInSeconds, classpathFilter) - runner.handle(getProjectDir(), arguments, jvmArguments, preExecutionActions) - } - - List calculateArguments(String... args) { - List arguments = [] - // Gradle will use these files name from the PWD, instead of the project directory. It's easier to just leave - // them out and let the default find them, since we're not changing their default names. - //arguments += '--build-file' - //arguments += (buildFile.canonicalPath - projectDir.canonicalPath).substring(1) - //arguments += '--settings-file' - //arguments += (settingsFile.canonicalPath - projectDir.canonicalPath).substring(1) - //arguments += '--no-daemon' - - switch (getLogLevel()) { - case LogLevel.INFO: - arguments += '--info' - break - case LogLevel.DEBUG: - arguments += '--debug' - break - } - arguments += '--stacktrace' - arguments.addAll(args) - arguments.addAll(initScripts.collect { file -> '-I' + file.absolutePath }) - arguments - } - - private List calculateJvmArguments() { - return jvmArguments + (remoteDebug ? [DEFAULT_REMOTE_DEBUG_JVM_ARGUMENTS] : [] as List) as List - } - - private Integer calculateMaxIdleDaemonTimeoutInSeconds() { - return memorySafeMode ? daemonMaxIdleTimeInSecondsInMemorySafeMode : null - } - - protected void addInitScript(File initFile) { - initScripts.add(initFile) - } - - protected void addPreExecute(PreExecutionAction preExecutionAction) { - preExecutionActions.add(preExecutionAction) - } - - /** - * Override to alter its value - * @return - */ - protected LogLevel getLogLevel() { - return logLevel - } - - /*protected void copyResources(String srcDir, String destination) { - ClassLoader classLoader = getClass().getClassLoader(); - URL resource = classLoader.getResource(srcDir); - if (resource == null) { - throw new RuntimeException("Could not find classpath resource: $srcDir") - } - File destinationFile = file(destination) - File resourceFile = new File(resource.toURI()) - if (resourceFile.file) { - FileUtils.copyFile(resourceFile, destinationFile) - } else { - FileUtils.copyDirectory(resourceFile, destinationFile) - } - }*/ - - protected String applyPlugin(Class pluginClass) { - "apply plugin: $pluginClass.name" - } - - /* Checks */ - protected boolean fileExists(String path) { - new File(projectDir, path).exists() - } - - @Deprecated - protected boolean wasExecuted(String taskPath) { - result.wasExecuted(taskPath) - } - - @Deprecated - protected boolean wasUpToDate(String taskPath) { - result.wasUpToDate(taskPath) - } - - @Deprecated - protected String getStandardError() { - result.standardError - } - - @Deprecated - protected String getStandardOutput() { - result.standardOutput - } - - protected ExecutionResult runTasksSuccessfully(String... tasks) { - ExecutionResult result = runTasks(tasks) - if (result.failure) { - result.rethrowFailure() - } - result - } - - protected ExecutionResult runTasksWithFailure(String... tasks) { - ExecutionResult result = runTasks(tasks) - assert result.failure - result - } - - protected ExecutionResult runTasks(String... tasks) { - ExecutionResult result = launcher(tasks).run() - this.result = result - return checkForDeprecations(result) - } - - protected ExecutionResult checkForDeprecations(ExecutionResult result) { - checkForDeprecations(result.standardOutput) - return result - } - - File getSettingsFile() { - return settingsFile - } -} diff --git a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/MinimalExecutedTask.groovy b/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/MinimalExecutedTask.groovy deleted file mode 100644 index f4d95b2..0000000 --- a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/MinimalExecutedTask.groovy +++ /dev/null @@ -1,22 +0,0 @@ -package org.xbib.gradle.plugin.test - -import org.xbib.gradle.plugin.test.ExecutedTask - -class MinimalExecutedTask implements ExecutedTask { - - String path - - boolean upToDate - - boolean skipped - - MinimalExecutedTask(String path, boolean upToDate, boolean skipped) { - this.path = path - this.upToDate = upToDate - this.skipped = skipped - } - - String toString() { - "executed $path" - } -} diff --git a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/MultiProjectHelper.groovy b/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/MultiProjectHelper.groovy deleted file mode 100644 index 25cb884..0000000 --- a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/MultiProjectHelper.groovy +++ /dev/null @@ -1,43 +0,0 @@ -package org.xbib.gradle.plugin.test - -import org.gradle.api.Project -import org.gradle.testfixtures.ProjectBuilder - -class MultiProjectHelper { - - Project parent - - MultiProjectHelper(Project parent) { - this.parent = parent - } - - Map create(Collection projectNames) { - Map info = [:] - projectNames.each { - def subproject = ProjectBuilder.builder().withName(it).withParent(parent).build() - info[it] = new MultiProjectInfo(name: it, project: subproject, parent: parent) - } - info - } - - Map createWithDirectories(Collection projectNames) { - Map info = [:] - projectNames.each { - def subDirectory = new File(parent.projectDir, it) - subDirectory.mkdirs() - def subproject = ProjectBuilder.builder().withName(it).withProjectDir(subDirectory).withParent(parent).build() - info[it] = new MultiProjectInfo(name: it, project: subproject, parent: parent, directory: subDirectory) - } - info - } - - Project addSubproject(String name) { - ProjectBuilder.builder().withName(name).withParent(parent).build() - } - - Project addSubprojectWithDirectory(String name) { - def dir = new File(parent.projectDir, name) - dir.mkdirs() - ProjectBuilder.builder().withName(name).withProjectDir(dir).withParent(parent).build() - } -} diff --git a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/MultiProjectInfo.groovy b/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/MultiProjectInfo.groovy deleted file mode 100644 index 1877291..0000000 --- a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/MultiProjectInfo.groovy +++ /dev/null @@ -1,14 +0,0 @@ -package org.xbib.gradle.plugin.test - -import org.gradle.api.Project - -class MultiProjectInfo { - - String name - - Project parent - - Project project - - File directory -} diff --git a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/PreExecutionAction.groovy b/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/PreExecutionAction.groovy deleted file mode 100644 index 6af4086..0000000 --- a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/PreExecutionAction.groovy +++ /dev/null @@ -1,6 +0,0 @@ -package org.xbib.gradle.plugin.test - -interface PreExecutionAction { - - void execute(File projectDir, List arguments, List jvmArguments) -} diff --git a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/ProjectSpec.groovy b/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/ProjectSpec.groovy deleted file mode 100644 index aff1cdf..0000000 --- a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/ProjectSpec.groovy +++ /dev/null @@ -1,8 +0,0 @@ -package org.xbib.gradle.plugin.test - -class ProjectSpec extends AbstractProjectSpec { - - File getProjectDir() { - ourProjectDir - } -} diff --git a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/ToolingApiGradleHandleFactory.groovy b/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/ToolingApiGradleHandleFactory.groovy deleted file mode 100644 index a750bfd..0000000 --- a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/ToolingApiGradleHandleFactory.groovy +++ /dev/null @@ -1,113 +0,0 @@ -package org.xbib.gradle.plugin.test - -import org.gradle.tooling.BuildLauncher -import org.gradle.tooling.GradleConnector -import org.gradle.tooling.ProjectConnection - -import java.util.concurrent.TimeUnit - -class ToolingApiGradleHandleFactory implements GradleHandleFactory { - - private final boolean fork - - private final String version - - private final Integer daemonMaxIdleTimeInSeconds - - ToolingApiGradleHandleFactory(boolean fork, String version, Integer daemonMaxIdleTimeInSeconds = null) { - this.fork = fork - this.version = version - this.daemonMaxIdleTimeInSeconds = daemonMaxIdleTimeInSeconds - } - - @Override - GradleHandle start(File projectDir, List arguments, List jvmArguments = []) { - GradleConnector connector = createGradleConnector(projectDir) - boolean forkedProcess = isForkedProcess() - connector.embedded(!forkedProcess) - if (daemonMaxIdleTimeInSeconds != null) { - connector.daemonMaxIdleTime(daemonMaxIdleTimeInSeconds, TimeUnit.SECONDS) - } - ProjectConnection connection = connector.connect(); - BuildLauncher launcher = createBuildLauncher(connection, arguments, jvmArguments) - createGradleHandle(connection, launcher, forkedProcess) - } - - private GradleConnector createGradleConnector(File projectDir) { - GradleConnector connector = GradleConnector.newConnector(); - connector.forProjectDirectory(projectDir); - configureGradleVersion(connector, projectDir) - connector - } - - private void configureGradleVersion(GradleConnector connector, File projectDir) { - if (version != null) { - connector.useGradleVersion(version) - } else { - configureWrapperDistributionIfUsed(connector, projectDir) - } - } - - private static void configureWrapperDistributionIfUsed(GradleConnector connector, File projectDir) { - File target = projectDir.absoluteFile - while (target != null) { - URI distribution = prepareDistributionURI(target) - if (distribution) { - connector.useDistribution(distribution) - return - } - target = target.parentFile - } - } - - private static URI prepareDistributionURI(File target) { - File propertiesFile = new File(target, "gradle/wrapper/gradle-wrapper.properties") - if (propertiesFile.exists()) { - Properties properties = new Properties() - propertiesFile.withInputStream { - properties.load(it) - } - URI source = new URI(properties.getProperty("distributionUrl")) - return source.getScheme() == null ? (new File(propertiesFile.getParentFile(), source.getSchemeSpecificPart())).toURI() : source; - } - return null - } - - private boolean isForkedProcess() { - fork - } - - private static BuildLauncher createBuildLauncher(ProjectConnection connection, List arguments, - List jvmArguments) { - BuildLauncher launcher = connection.newBuild(); - launcher.withArguments(arguments as String[]); - launcher.setJvmArguments(jvmArguments as String[]) - launcher - } - - private GradleHandle createGradleHandle(ProjectConnection connection, BuildLauncher launcher, boolean forkedProcess) { - GradleHandleBuildListener toolingApiBuildListener = - new ToolingApiBuildListener(connection) - BuildLauncherBackedGradleHandle buildLauncherBackedGradleHandle = - new BuildLauncherBackedGradleHandle(launcher, forkedProcess) - buildLauncherBackedGradleHandle.registerBuildListener(toolingApiBuildListener) - buildLauncherBackedGradleHandle - } - - private class ToolingApiBuildListener implements GradleHandleBuildListener { - private final ProjectConnection connection - - ToolingApiBuildListener(ProjectConnection connection) { - this.connection = connection - } - - @Override - void buildStarted() { - } - - @Override - void buildFinished() { - connection.close() - } - } -} \ No newline at end of file diff --git a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/ToolingExecutionResult.groovy b/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/ToolingExecutionResult.groovy deleted file mode 100644 index 1219641..0000000 --- a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/ToolingExecutionResult.groovy +++ /dev/null @@ -1,12 +0,0 @@ -package org.xbib.gradle.plugin.test - -/** - * Hold additional response data, that is only available - */ -class ToolingExecutionResult extends DefaultExecutionResult { - - ToolingExecutionResult(Boolean success, String standardOutput, String standardError, - List executedTasks, Throwable failure) { - super(success, standardOutput, standardError, executedTasks, failure) - } -} diff --git a/gradle-plugin-rpm/src/test/resources/BaseIntegrationSpec.groovy b/gradle-plugin-rpm/src/test/resources/BaseIntegrationSpec.groovy deleted file mode 100644 index 604d1be..0000000 --- a/gradle-plugin-rpm/src/test/resources/BaseIntegrationSpec.groovy +++ /dev/null @@ -1,119 +0,0 @@ - -import org.junit.Rule -import org.junit.rules.TestName -import spock.lang.Specification - -abstract class BaseIntegrationSpec extends Specification { - - @Rule - TestName testName = new TestName() - - File projectDir - - def setup() { - projectDir = new File("build/xbibtest/${this.class.canonicalName}/${testName.methodName.replaceAll(/\W+/, '-')}").absoluteFile - if (projectDir.exists()) { - projectDir.deleteDir() - } - projectDir.mkdirs() - } - - protected File directory(String path, File baseDir = getProjectDir()) { - new File(baseDir, path).with { - mkdirs() - it - } - } - - protected File file(String path, File baseDir = getProjectDir()) { - def splitted = path.split('/') - def directory = splitted.size() > 1 ? directory(splitted[0..-2].join('/'), baseDir) : baseDir - def file = new File(directory, splitted[-1]) - file.createNewFile() - file - } - - protected File createFile(String path, File baseDir = getProjectDir()) { - File file = file(path, baseDir) - if (!file.exists()) { - assert file.parentFile.mkdirs() || file.parentFile.exists() - file.createNewFile() - } - file - } - - protected static void checkForDeprecations(String output) { - def deprecations = output.readLines().findAll { - it.contains("has been deprecated and is scheduled to be removed in Gradle") - } - if (!System.getProperty("ignoreDeprecations") && !deprecations.isEmpty()) { - throw new IllegalArgumentException("Deprecation warnings were found (Set the ignoreDeprecations system property during the test to ignore):\n" + deprecations.collect { - " - $it" - }.join("\n")) - } - } - - protected void writeHelloWorld(String packageDotted, File baseDir = getProjectDir()) { - def path = 'src/main/java/' + packageDotted.replace('.', '/') + '/HelloWorld.java' - def javaFile = createFile(path, baseDir) - javaFile << """\ - package ${packageDotted}; - - public class HelloWorld { - public static void main(String[] args) { - System.out.println("Hello Integration Test"); - } - } - """.stripIndent() - } - - /** - * Creates a unit test for testing your plugin. - * @param failTest true if you want the test to fail, false if the test should pass - * @param baseDir the directory to begin creation from, defaults to projectDir - */ - protected void writeUnitTest(boolean failTest, File baseDir = getProjectDir()) { - writeTest('src/test/java/', 'nebula', failTest, baseDir) - } - - /** - * - * Creates a unit test for testing your plugin. - * @param srcDir the directory in the project where the source file should be created. - * @param packageDotted the package for the unit test class, written in dot notation (ex. - nebula.integration) - * @param failTest true if you want the test to fail, false if the test should pass - * @param baseDir the directory to begin creation from, defaults to projectDir - */ - protected void writeTest(String srcDir, String packageDotted, boolean failTest, File baseDir = getProjectDir()) { - def path = srcDir + packageDotted.replace('.', '/') + '/HelloWorldTest.java' - def javaFile = createFile(path, baseDir) - javaFile << """\ - package ${packageDotted}; - import org.junit.Test; - import static org.junit.Assert.assertFalse; - - public class HelloWorldTest { - @Test public void doesSomething() { - assertFalse( $failTest ); - } - } - """.stripIndent() - } - - /** - * Creates a properties file to included as project resource. - * @param srcDir the directory in the project where the source file should be created. - * @param fileName to be used for the file, sans extension. The .properties extension will be added to the name. - * @param baseDir the directory to begin creation from, defaults to projectDir - */ - protected void writeResource(String srcDir, String fileName, File baseDir = getProjectDir()) { - def path = "$srcDir/${fileName}.properties" - def resourceFile = createFile(path, baseDir) - resourceFile.text = "firstProperty=foo.bar" - } - - protected void addResource(String srcDir, String filename, String contents, File baseDir = getProjectDir()) { - def resourceFile = createFile("${srcDir}/${filename}", baseDir) - resourceFile.text = contents - } -} diff --git a/gradle-plugin-rpm/src/test/resources/org/xbib/gradle/plugin/changelog b/gradle-plugin-rpm/src/test/resources/org/xbib/gradle/plugin/changelog new file mode 100644 index 0000000..6c3ab5b --- /dev/null +++ b/gradle-plugin-rpm/src/test/resources/org/xbib/gradle/plugin/changelog @@ -0,0 +1,24 @@ +* Tue Feb 24 2015 George Washington +Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod +tempor incididunt ut labore et dolore magna aliqua +* Tue Feb 10 2015 George Washington +quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. +* Mon Nov 17 2014 George Washington + consectetur, adipisci velit, sed quia non numquam eius modi + sunt explicabo. Nemo enim ipsam voluptatem quia vol + eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat + Excepteur sint occaecat cupidatat non proident, sunt +* Fri Mar 06 2009 John Adams +- nostrum exercitationem ullam corporis suscipit +* Thu Oct 16 2008 Thomas Jefferson +- Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, +* Thu Aug 23 2007 James Madison +eaque ipsa quae ab illo inventore veritatis et quasi architecto +* Mon Jun 04 2007 James Monroe +- adipisci velit, sed q +* Tue May 08 2007 James Madison +- dolore eu fugiat nulla pariatur +* Tue Apr 10 2007 James Monroe +-+// quis nostrum exercitationem ullam corporis +* Wed Nov 08 2006 James Madison +- Initial rpm for this package diff --git a/gradle-plugin-rpm/src/test/resources/org/xbib/gradle/plugin/preinstall.sh b/gradle-plugin-rpm/src/test/resources/org/xbib/gradle/plugin/preinstall.sh new file mode 100644 index 0000000..10b58f4 --- /dev/null +++ b/gradle-plugin-rpm/src/test/resources/org/xbib/gradle/plugin/preinstall.sh @@ -0,0 +1,2 @@ +#!/usr/bin/env bash +echo 'Hello from file' diff --git a/gradle-plugin-rpm/src/test/resources/pgp/test-secring.gpg b/gradle-plugin-rpm/src/test/resources/test-secring.gpg similarity index 100% rename from gradle-plugin-rpm/src/test/resources/pgp/test-secring.gpg rename to gradle-plugin-rpm/src/test/resources/test-secring.gpg diff --git a/gradle.properties b/gradle.properties index e8628cf..c21d618 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,21 +1,17 @@ group = org.xbib name = rpm -version = 1.1.0 +version = 2.0.0 -bouncycastle.version = 1.60 -xbib-archive.version = 0.0.1 -ant.version = 1.10.5 -log4j.version = 2.11.1 -# must match groovy version in gradle -groovy.version = 2.5.4 -spock-core.version = 1.2-groovy-2.5 -xbib-guice.version = 4.0.4 -maven.version = 3.5.0 -maven-plugin-annotations.version = 3.5 -maven-plugin-plugin.version = 3.5 -mvel.version = 2.4.0.Final - -junit.version = 4.12 -wagon.version = 3.0.0 - -org.gradle.warning.mode=all +gradle.wrapper.version = 6.4.1 +gradle.publish.plugin.version = 0.11.0 +bouncycastle.version = 1.64 +xbib-archive.version = 1.0.0 +ant.version = 1.10.8 +maven.version = 3.6.3 +maven-plugin-annotations.version = 3.6.0 +maven-plugin-plugin.version = 3.6.0 +maven-wagon.version = 3.3.4 +aether-connector-basic.version = 1.1.0 +aether-transport-wagon.version = 1.1.0 +slf4j.version = 1.7.25 +mvel.version = 2.4.5.Final diff --git a/gradle/compile/java.gradle b/gradle/compile/java.gradle new file mode 100644 index 0000000..a9d76ce --- /dev/null +++ b/gradle/compile/java.gradle @@ -0,0 +1,35 @@ + +apply plugin: 'java-library' + +java { + modularity.inferModulePath.set(true) +} + +compileJava { + sourceCompatibility = JavaVersion.VERSION_11 + targetCompatibility = JavaVersion.VERSION_11 +} + +compileTestJava { + sourceCompatibility = JavaVersion.VERSION_11 + targetCompatibility = JavaVersion.VERSION_11 +} + +jar { + manifest { + attributes('Implementation-Version': project.version) + } +} + +task sourcesJar(type: Jar, dependsOn: classes) { + classifier 'sources' + from sourceSets.main.allSource +} + +task javadocJar(type: Jar, dependsOn: javadoc) { + classifier 'javadoc' +} + +artifacts { + archives sourcesJar, javadocJar +} \ No newline at end of file diff --git a/gradle/documentation/asciidoc.gradle b/gradle/documentation/asciidoc.gradle new file mode 100644 index 0000000..87ba22e --- /dev/null +++ b/gradle/documentation/asciidoc.gradle @@ -0,0 +1,55 @@ +apply plugin: 'org.xbib.gradle.plugin.asciidoctor' + +configurations { + asciidoclet +} + +dependencies { + asciidoclet "org.asciidoctor:asciidoclet:${project.property('asciidoclet.version')}" +} + + +asciidoctor { + backends 'html5' + outputDir = file("${rootProject.projectDir}/docs") + separateOutputDirs = false + attributes 'source-highlighter': 'coderay', + idprefix: '', + idseparator: '-', + toc: 'left', + doctype: 'book', + icons: 'font', + encoding: 'utf-8', + sectlink: true, + sectanchors: true, + linkattrs: true, + imagesdir: 'img', + stylesheet: "${projectDir}/src/docs/asciidoc/css/foundation.css" +} + + +/*javadoc { +options.docletpath = configurations.asciidoclet.files.asType(List) +options.doclet = 'org.asciidoctor.Asciidoclet' +//options.overview = "src/docs/asciidoclet/overview.adoc" +options.addStringOption "-base-dir", "${projectDir}" +options.addStringOption "-attribute", + "name=${project.name},version=${project.version},title-link=https://github.com/xbib/${project.name}" +configure(options) { + noTimestamp = true +} +}*/ + + +/*javadoc { + options.docletpath = configurations.asciidoclet.files.asType(List) + options.doclet = 'org.asciidoctor.Asciidoclet' + options.overview = "${rootProject.projectDir}/src/docs/asciidoclet/overview.adoc" + options.addStringOption "-base-dir", "${projectDir}" + options.addStringOption "-attribute", + "name=${project.name},version=${project.version},title-link=https://github.com/xbib/${project.name}" + options.destinationDirectory(file("${projectDir}/docs/javadoc")) + configure(options) { + noTimestamp = true + } +}*/ diff --git a/gradle/ext.gradle b/gradle/ext.gradle deleted file mode 100644 index e69de29..0000000 diff --git a/gradle/ide/idea.gradle b/gradle/ide/idea.gradle new file mode 100644 index 0000000..64e2167 --- /dev/null +++ b/gradle/ide/idea.gradle @@ -0,0 +1,13 @@ +apply plugin: 'idea' + +idea { + module { + outputDir file('build/classes/java/main') + testOutputDir file('build/classes/java/test') + } +} + +if (project.convention.findPlugin(JavaPluginConvention)) { + //sourceSets.main.output.classesDirs = file("build/classes/java/main") + //sourceSets.test.output.classesDirs = file("build/classes/java/test") +} diff --git a/gradle/publish.gradle b/gradle/publish.gradle deleted file mode 100644 index 2f13ee0..0000000 --- a/gradle/publish.gradle +++ /dev/null @@ -1,85 +0,0 @@ - -apply plugin: 'signing' - -configurations { - wagon -} - -dependencies { - wagon "org.apache.maven.wagon:wagon-ssh:${project.property('wagon.version')}" -} - -if (project.hasProperty('signing.keyId')) { - signing { - sign configurations.archives - } -} - -task xbibUpload(type: Upload) { - group = 'publish' - configuration = configurations.archives - uploadDescriptor = true - repositories { - if (project.hasProperty('xbibUsername')) { - mavenDeployer { - configuration = configurations.wagon - repository(url: uri('sftp://xbib.org/repository')) { - authentication(userName: xbibUsername, privateKey: xbibPrivateKey) - } - } - } - } -} - -task sonatypeUpload(type: Upload) { - group = 'publish' - configuration = configurations.archives - uploadDescriptor = true - repositories { - if (project.hasProperty('ossrhUsername')) { - mavenDeployer { - beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) } - repository(url: uri(ossrhReleaseUrl)) { - authentication(userName: ossrhUsername, password: ossrhPassword) - } - snapshotRepository(url: uri(ossrhSnapshotUrl)) { - authentication(userName: ossrhUsername, password: ossrhPassword) - } - pom.project { - name projectName - description projectDescription - packaging 'jar' - inceptionYear '2017' - url scmUrl - organization { - name 'xbib' - url 'http://xbib.org' - } - developers { - developer { - id user - name 'Jörg Prante' - email 'joergprante@gmail.com' - url 'https://github.com/jprante' - } - } - scm { - url scmUrl - connection scmConnection - developerConnection scmDeveloperConnection - } - licenses { - license { - name 'The Apache License, Version 2.0' - url 'http://www.apache.org/licenses/LICENSE-2.0.txt' - } - } - } - } - } - } -} - -nexusStaging { - packageGroup = "org.xbib" -} diff --git a/gradle/publishing/publication.gradle b/gradle/publishing/publication.gradle new file mode 100644 index 0000000..c35fcb9 --- /dev/null +++ b/gradle/publishing/publication.gradle @@ -0,0 +1,64 @@ + +apply plugin: "de.marcphilipp.nexus-publish" + +publishing { + publications { + mavenJava(MavenPublication) { + from components.java + artifact sourcesJar + artifact javadocJar + pom { + name = project.name + description = rootProject.ext.description + url = rootProject.ext.url + inceptionYear = rootProject.ext.inceptionYear + packaging = 'jar' + organization { + name = 'xbib' + url = 'https://xbib.org' + } + developers { + developer { + id = 'jprante' + name = 'Jörg Prante' + email = 'joergprante@gmail.com' + url = 'https://github.com/jprante' + } + } + scm { + url = rootProject.ext.scmUrl + connection = rootProject.ext.scmConnection + developerConnection = rootProject.ext.scmDeveloperConnection + } + issueManagement { + system = rootProject.ext.issueManagementSystem + url = rootProject.ext.issueManagementUrl + } + licenses { + license { + name = rootProject.ext.licenseName + url = rootProject.ext.licenseUrl + distribution = 'repo' + } + } + } + } + } +} + +if (project.hasProperty("signing.keyId")) { + apply plugin: 'signing' + signing { + sign publishing.publications.mavenJava + } +} + +nexusPublishing { + repositories { + sonatype { + username = project.property('ossrhUsername') + password = project.property('ossrhPassword') + packageGroup = "org.xbib" + } + } +} diff --git a/gradle/publishing/sonatype.gradle b/gradle/publishing/sonatype.gradle new file mode 100644 index 0000000..e1813f3 --- /dev/null +++ b/gradle/publishing/sonatype.gradle @@ -0,0 +1,11 @@ + +if (project.hasProperty('ossrhUsername') && project.hasProperty('ossrhPassword')) { + + apply plugin: 'io.codearte.nexus-staging' + + nexusStaging { + username = project.property('ossrhUsername') + password = project.property('ossrhPassword') + packageGroup = "org.xbib" + } +} diff --git a/gradle/test/junit5.gradle b/gradle/test/junit5.gradle new file mode 100644 index 0000000..7c6d4cc --- /dev/null +++ b/gradle/test/junit5.gradle @@ -0,0 +1,28 @@ + +def junitVersion = project.hasProperty('junit.version')?project.property('junit.version'):'5.6.2' +def hamcrestVersion = project.hasProperty('hamcrest.version')?project.property('hamcrest.version'):'2.2' + +dependencies { + testImplementation "org.junit.jupiter:junit-jupiter-api:${junitVersion}" + testImplementation "org.junit.jupiter:junit-jupiter-params:${junitVersion}" + testImplementation "org.hamcrest:hamcrest-library:${hamcrestVersion}" + testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:${junitVersion}" +} + +test { + useJUnitPlatform() + failFast = true + testLogging { + showStandardStreams = true + events 'STARTED', 'PASSED', 'FAILED', 'SKIPPED' + } + afterSuite { desc, result -> + if (!desc.parent) { + println "\nTest result: ${result.resultType}" + println "Test summary: ${result.testCount} tests, " + + "${result.successfulTestCount} succeeded, " + + "${result.failedTestCount} failed, " + + "${result.skippedTestCount} skipped" + } + } +} diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 87b738cbd051603d91cc39de6cb000dd98fe6b02..62d4c053550b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a27qlQ#kk45`2R9KZp&ReO+n*e!l^RTTPv!#NBL>A$cSh+7bPfCreaaf6KFZr#c? zC6Hm_tx24Z1CZoWqwkUe3hNM%Y4U%<)W8sm6evZ9T+?nt3`I1+^*T4mDdX0yLJ!tQ7PbJniL@0f`Alyf$?$4e_ZIl{}`H#@h?K^ejs^^l@c50pQs@E Nq$R_^uaqX; diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 0066aae..21e622d 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,5 @@ -#Thu Jan 10 23:25:32 CET 2019 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-6.4.1-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.1-all.zip diff --git a/gradlew b/gradlew index af6708f..fbd7c51 100755 --- a/gradlew +++ b/gradlew @@ -1,5 +1,21 @@ #!/usr/bin/env sh +# +# Copyright 2015 the original author or authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + ############################################################################## ## ## Gradle start up script for UN*X @@ -28,7 +44,7 @@ APP_NAME="Gradle" APP_BASE_NAME=`basename "$0"` # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m"' +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD="maximum" @@ -66,6 +82,7 @@ esac CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + # Determine the Java command to use to start the JVM. if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then @@ -109,10 +126,11 @@ if $darwin; then GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" fi -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then +# For Cygwin or MSYS, switch paths to Windows format before running java +if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then APP_HOME=`cygpath --path --mixed "$APP_HOME"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` # We build the pattern for arguments to be converted via cygpath @@ -138,19 +156,19 @@ if $cygwin ; then else eval `echo args$i`="\"$arg\"" fi - i=$((i+1)) + i=`expr $i + 1` done case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + 0) set -- ;; + 1) set -- "$args0" ;; + 2) set -- "$args0" "$args1" ;; + 3) set -- "$args0" "$args1" "$args2" ;; + 4) set -- "$args0" "$args1" "$args2" "$args3" ;; + 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; esac fi @@ -159,14 +177,9 @@ save () { for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done echo " " } -APP_ARGS=$(save "$@") +APP_ARGS=`save "$@"` # Collect all arguments for the java command, following the shell quoting and substitution rules eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" -fi - exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat index 0f8d593..a9f778a 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -1,3 +1,19 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + @if "%DEBUG%" == "" @echo off @rem ########################################################################## @rem @@ -13,8 +29,11 @@ if "%DIRNAME%" == "" set DIRNAME=. set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" @rem Find java.exe if defined JAVA_HOME goto findJavaFromJavaHome @@ -65,6 +84,7 @@ set CMD_LINE_ARGS=%* set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + @rem Execute Gradle "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% diff --git a/maven-plugin-rpm/build.gradle b/maven-plugin-rpm/build.gradle index 3d06e44..0e7ed97 100644 --- a/maven-plugin-rpm/build.gradle +++ b/maven-plugin-rpm/build.gradle @@ -1,33 +1,31 @@ +apply plugin: 'maven' + +// for this script, see https://gist.github.com/fikovnik/ffc1fed1867bc7fa679aaf8e48f00c21 + configurations { mavenEmbedder } dependencies { - compile project(':rpm-core') - compile "org.mvel:mvel2:${project.property('mvel.version')}" - compile "org.apache.ant:ant:${project.property('ant.version')}" - + api project(':rpm-core') + api "org.apache.ant:ant:${project.property('ant.version')}" + implementation "org.mvel:mvel2:${project.property('mvel.version')}" compileOnly "org.apache.maven:maven-core:${project.property('maven.version')}" compileOnly "org.apache.maven:maven-plugin-api:${project.property('maven.version')}" compileOnly "org.apache.maven.plugin-tools:maven-plugin-annotations:${project.property('maven-plugin-annotations.version')}" - - testCompile "org.apache.maven:maven-core:${project.property('maven.version')}" - testCompile "org.apache.maven:maven-plugin-api:${project.property('maven.version')}" - testCompile "org.apache.maven.plugin-tools:maven-plugin-annotations:${project.property('maven-plugin-annotations.version')}" - + testImplementation "org.apache.maven:maven-core:${project.property('maven.version')}" + testImplementation "org.apache.maven:maven-plugin-api:${project.property('maven.version')}" + testImplementation "org.apache.maven.plugin-tools:maven-plugin-annotations:${project.property('maven-plugin-annotations.version')}" mavenEmbedder "org.apache.maven:maven-embedder:${project.property('maven.version')}" - mavenEmbedder "org.slf4j:slf4j-simple:1.7.25" - mavenEmbedder "org.apache.maven.wagon:wagon-http:3.1.0:shaded" - mavenEmbedder "org.apache.maven.wagon:wagon-provider-api:3.1.0" - mavenEmbedder "org.eclipse.aether:aether-connector-basic:1.1.0" - mavenEmbedder "org.eclipse.aether:aether-transport-wagon:1.1.0" + mavenEmbedder "org.apache.maven:maven-compat:${project.property('maven.version')}" + mavenEmbedder "org.slf4j:slf4j-simple:${project.property('slf4j.version')}" + mavenEmbedder "org.apache.maven.wagon:wagon-http:${project.property('maven-wagon.version')}:shaded" + mavenEmbedder "org.apache.maven.wagon:wagon-provider-api:${project.property('maven-wagon.version')}" + mavenEmbedder "org.eclipse.aether:aether-connector-basic:${project.property('aether-connector-basic.version')}" + mavenEmbedder "org.eclipse.aether:aether-transport-wagon:${project.property('aether-transport-wagon.version')}" } test { - testLogging { - showStandardStreams = false - exceptionFormat = 'full' - } systemProperty 'project.build.testOutputDirectory', project.buildDir.path + "/resources/test" } @@ -52,7 +50,7 @@ task generatePluginDescriptor(type: JavaExec, dependsOn: compileJava) { '--update-snapshots', '--errors', '--batch-mode', - '--settings', '../config/maven/repo-settings.xml', + '--settings', "${project.projectDir}/config/maven/repo-settings.xml", '--file', "${buildDir}/pom.xml", "org.apache.maven.plugins:maven-plugin-plugin:${project.property('maven-plugin-plugin.version')}:descriptor" ] diff --git a/maven-plugin-rpm/config/checkstyle/checkstyle.xml b/maven-plugin-rpm/config/checkstyle/checkstyle.xml deleted file mode 100644 index 55e59d2..0000000 --- a/maven-plugin-rpm/config/checkstyle/checkstyle.xml +++ /dev/null @@ -1,323 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/config/maven/repo-settings.xml b/maven-plugin-rpm/config/maven/repo-settings.xml similarity index 93% rename from config/maven/repo-settings.xml rename to maven-plugin-rpm/config/maven/repo-settings.xml index 5968882..6e83096 100644 --- a/config/maven/repo-settings.xml +++ b/maven-plugin-rpm/config/maven/repo-settings.xml @@ -9,7 +9,7 @@ xbib - http://xbib.org/repository + https://xbib.org/repository true always diff --git a/maven-plugin-rpm/src/main/java/org/xbib/maven/plugin/rpm/RpmPackage.java b/maven-plugin-rpm/src/main/java/org/xbib/maven/plugin/rpm/RpmPackage.java index cacdffa..d4aa5eb 100644 --- a/maven-plugin-rpm/src/main/java/org/xbib/maven/plugin/rpm/RpmPackage.java +++ b/maven-plugin-rpm/src/main/java/org/xbib/maven/plugin/rpm/RpmPackage.java @@ -1120,7 +1120,7 @@ public class RpmPackage { builder.setBuildHost(getBuildHostName()); builder.setPackager(getPackager()); builder.setUrl(getUrl()); - builder.setPrefixes(getPrefixes().toArray(new String[0])); + builder.setPrefixes(getPrefixes()); builder.setSourceRpm(getSourceRpm()); for (String builtin : getBuiltins()) { builder.addBuiltinDirectory(builtin); @@ -1183,7 +1183,9 @@ public class RpmPackage { } for (RpmLink link : getLinks()) { builder.addLink(link.getPath(), link.getTarget(), - link.getPermissionsOrDefault(), link.getOwnerOrDefault(), link.getGroupOrDefault()); + link.getPermissionsOrDefault(), + link.getOwnerOrDefault(), + link.getGroupOrDefault()); } getLog().debug("Setting trigger scripts"); RpmScriptTemplateRenderer scriptTemplateRenderer = getMojo().getTemplateRenderer(); diff --git a/maven-plugin-rpm/src/main/java/org/xbib/maven/plugin/rpm/RpmPackageRule.java b/maven-plugin-rpm/src/main/java/org/xbib/maven/plugin/rpm/RpmPackageRule.java index 94d7c5e..b93e3be 100644 --- a/maven-plugin-rpm/src/main/java/org/xbib/maven/plugin/rpm/RpmPackageRule.java +++ b/maven-plugin-rpm/src/main/java/org/xbib/maven/plugin/rpm/RpmPackageRule.java @@ -251,8 +251,8 @@ public class RpmPackageRule extends RpmBaseObject { getLog().debug(String.format("Adding file: %s to path %s with owner '%s', " + "group '%s', with file mode %o.", sourcePath, destinationPath, owner, group, fileMode)); - builder.addFile(destinationPath, Paths.get(sourcePath), fileMode, - getDirectives(), owner, group); + builder.addFile(destinationPath, Paths.get(sourcePath), fileMode, -1, + getDirectives(), owner, group, true); } return includedFiles; } diff --git a/maven-plugin-rpm/src/test/java/org/xbib/maven/plugin/rpm/RpmBaseObjectTest.java b/maven-plugin-rpm/src/test/java/org/xbib/maven/plugin/rpm/RpmBaseObjectTest.java index baaf5fd..05971f7 100644 --- a/maven-plugin-rpm/src/test/java/org/xbib/maven/plugin/rpm/RpmBaseObjectTest.java +++ b/maven-plugin-rpm/src/test/java/org/xbib/maven/plugin/rpm/RpmBaseObjectTest.java @@ -1,8 +1,7 @@ package org.xbib.maven.plugin.rpm; -import static org.junit.Assert.assertEquals; - -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.Test; /** * diff --git a/maven-plugin-rpm/src/test/java/org/xbib/maven/plugin/rpm/RpmLinkTest.java b/maven-plugin-rpm/src/test/java/org/xbib/maven/plugin/rpm/RpmLinkTest.java index b306983..a142cf6 100644 --- a/maven-plugin-rpm/src/test/java/org/xbib/maven/plugin/rpm/RpmLinkTest.java +++ b/maven-plugin-rpm/src/test/java/org/xbib/maven/plugin/rpm/RpmLinkTest.java @@ -4,7 +4,7 @@ import org.apache.maven.monitor.logging.DefaultLog; import org.apache.maven.plugin.logging.Log; import org.apache.maven.project.MavenProject; import org.codehaus.plexus.logging.console.ConsoleLogger; -import org.junit.Before; +import org.junit.jupiter.api.BeforeEach; import org.xbib.maven.plugin.rpm.mojo.PackageRpmMojo; import java.io.File; @@ -16,7 +16,7 @@ public class RpmLinkTest extends RpmBaseObjectTest { private RpmLink rpmLink; - @Before + @BeforeEach public void setUp() throws Exception { String testOutputPath = System.getProperty("project.build.testOutputDirectory"); PackageRpmMojo mojo = new PackageRpmMojo(); diff --git a/maven-plugin-rpm/src/test/java/org/xbib/maven/plugin/rpm/RpmPackageAssociationTest.java b/maven-plugin-rpm/src/test/java/org/xbib/maven/plugin/rpm/RpmPackageAssociationTest.java index 9a1c36a..2f4dc3e 100644 --- a/maven-plugin-rpm/src/test/java/org/xbib/maven/plugin/rpm/RpmPackageAssociationTest.java +++ b/maven-plugin-rpm/src/test/java/org/xbib/maven/plugin/rpm/RpmPackageAssociationTest.java @@ -1,9 +1,9 @@ package org.xbib.maven.plugin.rpm; -import static org.junit.Assert.assertEquals; - -import org.junit.Before; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; /** * @@ -12,69 +12,69 @@ public class RpmPackageAssociationTest { private RpmPackageAssociation association; - @Before + @BeforeEach public void setUp() { association = new RpmPackageAssociation(); } @Test public void nameAccessors() { - assertEquals(null, association.getName()); + assertNull(association.getName()); association.setName("testname"); assertEquals("testname", association.getName()); } @Test public void unassignedVersion() { - assertEquals(null, association.getVersion()); - assertEquals(null, association.getMinVersion()); - assertEquals(null, association.getMaxVersion()); + assertNull(association.getVersion()); + assertNull(association.getMinVersion()); + assertNull(association.getMaxVersion()); } @Test public void latestVersion() { association.setVersion(null); - assertEquals(null, association.getVersion()); - assertEquals(null, association.getMinVersion()); - assertEquals(null, association.getMaxVersion()); + assertNull(association.getVersion()); + assertNull(association.getMinVersion()); + assertNull(association.getMaxVersion()); association.setVersion(""); - assertEquals(null, association.getVersion()); - assertEquals(null, association.getMinVersion()); - assertEquals(null, association.getMaxVersion()); + assertNull(association.getVersion()); + assertNull(association.getMinVersion()); + assertNull(association.getMaxVersion()); association.setVersion("RELEASE"); - assertEquals(null, association.getVersion()); - assertEquals(null, association.getMinVersion()); - assertEquals(null, association.getMaxVersion()); + assertNull(association.getVersion()); + assertNull(association.getMinVersion()); + assertNull(association.getMaxVersion()); } @Test public void specificVersion() { association.setVersion("1.2.3"); assertEquals("1.2.3", association.getVersion()); - assertEquals(null, association.getMinVersion()); - assertEquals(null, association.getMaxVersion()); + assertNull(association.getMinVersion()); + assertNull(association.getMaxVersion()); } @Test public void minVersionRange() { association.setVersion("[1.2.3,)"); - assertEquals(null, association.getVersion()); + assertNull(association.getVersion()); assertEquals("1.2.3", association.getMinVersion()); - assertEquals(null, association.getMaxVersion()); + assertNull(association.getMaxVersion()); } @Test public void maxVersionRange() { association.setVersion("[,1.2.3)"); - assertEquals(null, association.getVersion()); - assertEquals(null, association.getMinVersion()); + assertNull(association.getVersion()); + assertNull(association.getMinVersion()); assertEquals("1.2.3", association.getMaxVersion()); } @Test public void minMaxVersionRange() { association.setVersion("[1.2.3,1.2.5)"); - assertEquals(null, association.getVersion()); + assertNull(association.getVersion()); assertEquals("1.2.3", association.getMinVersion()); assertEquals("1.2.5", association.getMaxVersion()); } diff --git a/maven-plugin-rpm/src/test/java/org/xbib/maven/plugin/rpm/RpmPackageRuleDirectiveTest.java b/maven-plugin-rpm/src/test/java/org/xbib/maven/plugin/rpm/RpmPackageRuleDirectiveTest.java index 1bb601e..dac8b54 100644 --- a/maven-plugin-rpm/src/test/java/org/xbib/maven/plugin/rpm/RpmPackageRuleDirectiveTest.java +++ b/maven-plugin-rpm/src/test/java/org/xbib/maven/plugin/rpm/RpmPackageRuleDirectiveTest.java @@ -1,9 +1,8 @@ package org.xbib.maven.plugin.rpm; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; +import org.junit.jupiter.api.Test; import org.xbib.rpm.exception.InvalidDirectiveException; import org.xbib.rpm.payload.Directive; diff --git a/maven-plugin-rpm/src/test/java/org/xbib/maven/plugin/rpm/RpmPackageRuleTest.java b/maven-plugin-rpm/src/test/java/org/xbib/maven/plugin/rpm/RpmPackageRuleTest.java index f3b6162..e3b1293 100644 --- a/maven-plugin-rpm/src/test/java/org/xbib/maven/plugin/rpm/RpmPackageRuleTest.java +++ b/maven-plugin-rpm/src/test/java/org/xbib/maven/plugin/rpm/RpmPackageRuleTest.java @@ -1,14 +1,15 @@ package org.xbib.maven.plugin.rpm; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; import org.apache.maven.monitor.logging.DefaultLog; import org.apache.maven.plugin.logging.Log; import org.apache.maven.project.MavenProject; import org.codehaus.plexus.logging.console.ConsoleLogger; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.xbib.maven.plugin.rpm.mojo.PackageRpmMojo; import org.xbib.rpm.exception.InvalidDirectiveException; import org.xbib.rpm.exception.InvalidPathException; @@ -33,8 +34,8 @@ public class RpmPackageRuleTest extends RpmBaseObjectTest { private RpmPackage rpmPackage; - @Before - public void setUp() throws Exception { + @BeforeEach + public void setUp() { testOutputPath = System.getProperty("project.build.testOutputDirectory"); PackageRpmMojo mojo = new PackageRpmMojo(); mojo.setDefaultFileMode(0644); @@ -84,9 +85,9 @@ public class RpmPackageRuleTest extends RpmBaseObjectTest { @Test public void destinationAccessors() { rpmFileRule.setDestination(""); - assertEquals(null, rpmFileRule.getDestination()); + assertNull(rpmFileRule.getDestination()); rpmFileRule.setDestination(null); - assertEquals(null, rpmFileRule.getDestination()); + assertNull(rpmFileRule.getDestination()); assertEquals(String.format("%svar%swww%stest", File.separator, File.separator, File.separator), rpmFileRule.getDestinationOrDefault()); rpmFileRule.setDestination(String.format("%sfoo", File.separator)); @@ -131,10 +132,12 @@ public class RpmPackageRuleTest extends RpmBaseObjectTest { assertEquals(62, files.length); } - @Test(expected = PathOutsideBuildPathException.class) + @Test public void testListFilesOutsideBuildPath() throws RpmException { - rpmFileRule.setBase(String.format("..%s", File.separator)); - rpmFileRule.listFiles(); + Assertions.assertThrows(PathOutsideBuildPathException.class, () -> { + rpmFileRule.setBase(String.format("..%s", File.separator)); + rpmFileRule.listFiles(); + }); } @Test diff --git a/maven-plugin-rpm/src/test/java/org/xbib/maven/plugin/rpm/RpmPackageTest.java b/maven-plugin-rpm/src/test/java/org/xbib/maven/plugin/rpm/RpmPackageTest.java index e92efdf..3161e83 100644 --- a/maven-plugin-rpm/src/test/java/org/xbib/maven/plugin/rpm/RpmPackageTest.java +++ b/maven-plugin-rpm/src/test/java/org/xbib/maven/plugin/rpm/RpmPackageTest.java @@ -1,21 +1,21 @@ package org.xbib.maven.plugin.rpm; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; import org.apache.maven.model.Build; import org.apache.maven.project.MavenProject; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.xbib.maven.plugin.rpm.mojo.PackageRpmMojo; import org.xbib.rpm.exception.RpmException; import org.xbib.rpm.exception.UnknownArchitectureException; import org.xbib.rpm.exception.UnknownOperatingSystemException; import org.xbib.rpm.lead.Architecture; import org.xbib.rpm.lead.Os; - import java.io.File; import java.io.IOException; import java.nio.file.Path; @@ -34,7 +34,7 @@ public class RpmPackageTest { private MavenProject project; - @Before + @BeforeEach public void setUp() { testOutputPath = System.getProperty("project.build.testOutputDirectory"); Build projectBuild = new Build(); @@ -119,42 +119,42 @@ public class RpmPackageTest { @Test public void urlAccessors() { - assertEquals(null, rpmPackage.getUrl()); + assertNull(rpmPackage.getUrl()); rpmPackage.setUrl("http://www.example.com/foo"); assertEquals("http://www.example.com/foo", rpmPackage.getUrl()); } @Test public void groupAccessors() { - assertEquals(null, rpmPackage.getGroup()); + assertNull(rpmPackage.getGroup()); rpmPackage.setGroup("group/subgroup"); assertEquals("group/subgroup", rpmPackage.getGroup()); } @Test public void licenseAccessors() { - assertEquals(null, rpmPackage.getLicense()); + assertNull(rpmPackage.getLicense()); rpmPackage.setLicense("license"); assertEquals("license", rpmPackage.getLicense()); } @Test public void summaryAccessors() { - assertEquals(null, rpmPackage.getSummary()); + assertNull(rpmPackage.getSummary()); rpmPackage.setSummary("summary"); assertEquals("summary", rpmPackage.getSummary()); } @Test public void descriptionAccessors() { - assertEquals(null, rpmPackage.getDescription()); + assertNull(rpmPackage.getDescription()); rpmPackage.setDescription("description"); assertEquals("description", rpmPackage.getDescription()); } @Test public void distributionAccessors() { - assertEquals(null, rpmPackage.getDistribution()); + assertNull(rpmPackage.getDistribution()); rpmPackage.setDistribution("distribution"); assertEquals("distribution", rpmPackage.getDistribution()); } @@ -166,19 +166,22 @@ public class RpmPackageTest { assertEquals(Architecture.SPARC, rpmPackage.getArchitecture()); } - @Test(expected = UnknownArchitectureException.class) - public void architectureInvalidException() throws UnknownArchitectureException { - rpmPackage.setArchitecture("NONEXISTENT"); + @Test + public void architectureInvalidException() { + Assertions.assertThrows(UnknownArchitectureException.class, () -> + rpmPackage.setArchitecture("NONEXISTENT")); } - @Test(expected = UnknownArchitectureException.class) - public void architectureBlankException() throws UnknownArchitectureException { - rpmPackage.setArchitecture(""); + @Test + public void architectureBlankException() { + Assertions.assertThrows(UnknownArchitectureException.class, () -> + rpmPackage.setArchitecture("")); } - @Test(expected = UnknownArchitectureException.class) - public void architectureNullException() throws UnknownArchitectureException { - rpmPackage.setArchitecture(null); + @Test + public void architectureNullException() { + Assertions.assertThrows(UnknownArchitectureException.class, () -> + rpmPackage.setArchitecture(null)); } @Test @@ -188,19 +191,22 @@ public class RpmPackageTest { assertEquals(Os.LINUX390, rpmPackage.getOperatingSystem()); } - @Test(expected = UnknownOperatingSystemException.class) - public void operatingSystemInvalidException() throws UnknownOperatingSystemException { - rpmPackage.setOperatingSystem("NONEXISTENT"); + @Test + public void operatingSystemInvalidException() { + Assertions.assertThrows(UnknownOperatingSystemException.class, () -> + rpmPackage.setOperatingSystem("NONEXISTENT")); } - @Test(expected = UnknownOperatingSystemException.class) - public void operatingSystemBlankException() throws UnknownOperatingSystemException { - rpmPackage.setOperatingSystem(""); + @Test + public void operatingSystemBlankException() { + Assertions.assertThrows(UnknownOperatingSystemException.class, () -> + rpmPackage.setOperatingSystem("")); } - @Test(expected = UnknownOperatingSystemException.class) - public void operatingSystemNullException() throws UnknownOperatingSystemException { - rpmPackage.setOperatingSystem(null); + @Test + public void operatingSystemNullException() { + Assertions.assertThrows(UnknownOperatingSystemException.class, () -> + rpmPackage.setOperatingSystem(null)); } @Test @@ -212,21 +218,21 @@ public class RpmPackageTest { @Test public void packagerAccessors() { - assertEquals(null, rpmPackage.getPackager()); + assertNull(rpmPackage.getPackager()); rpmPackage.setPackager("packager"); assertEquals("packager", rpmPackage.getPackager()); } @Test public void attachAccessors() { - assertEquals(true, rpmPackage.isAttach()); + assertTrue(rpmPackage.isAttach()); rpmPackage.setAttach(false); - assertEquals(false, rpmPackage.isAttach()); + assertFalse(rpmPackage.isAttach()); } @Test public void classifierAccessors() { - assertEquals(null, rpmPackage.getClassifier()); + assertNull(rpmPackage.getClassifier()); rpmPackage.setClassifier("classifier"); assertEquals("classifier", rpmPackage.getClassifier()); } @@ -236,10 +242,8 @@ public class RpmPackageTest { List rules = new ArrayList<>(); rules.add(new RpmPackageRule()); rules.add(new RpmPackageRule()); - rpmPackage.setRules(rules); assertEquals(rules, rpmPackage.getRules()); - rpmPackage.setRules(null); assertNull(rpmPackage.getRules()); } @@ -247,47 +251,40 @@ public class RpmPackageTest { @Test public void eventHookAccessors() { Path scriptFile = Paths.get("samplescript.sh"); - - // pre transaction - assertEquals(null, rpmPackage.getPreTransactionScriptPath()); + assertNull(rpmPackage.getPreTransactionScriptPath()); rpmPackage.setPreTransactionScriptPath(scriptFile); assertEquals(scriptFile, rpmPackage.getPreTransactionScriptPath()); - - assertEquals(null, rpmPackage.getPreTransactionProgram()); + assertNull(rpmPackage.getPreTransactionProgram()); rpmPackage.setPreTransactionProgram("/bin/sh"); assertEquals("/bin/sh", rpmPackage.getPreTransactionProgram()); - - - // pre install - assertEquals(null, rpmPackage.getPreInstallScriptPath()); + assertNull(rpmPackage.getPreInstallScriptPath()); rpmPackage.setPreInstallScriptPath(scriptFile); assertEquals(scriptFile, rpmPackage.getPreInstallScriptPath()); - - assertEquals(null, rpmPackage.getPreInstallProgram()); + assertNull(rpmPackage.getPreInstallProgram()); rpmPackage.setPreInstallProgram("/bin/sh"); assertEquals("/bin/sh", rpmPackage.getPreInstallProgram()); - assertEquals(null, rpmPackage.getPostInstallScriptPath()); + assertNull(rpmPackage.getPostInstallScriptPath()); rpmPackage.setPostInstallScriptPath(scriptFile); assertEquals(scriptFile, rpmPackage.getPostInstallScriptPath()); - assertEquals(null, rpmPackage.getPostInstallProgram()); + assertNull(rpmPackage.getPostInstallProgram()); rpmPackage.setPostInstallProgram("/bin/sh"); assertEquals("/bin/sh", rpmPackage.getPostInstallProgram()); - assertEquals(null, rpmPackage.getPreUninstallScriptPath()); + assertNull(rpmPackage.getPreUninstallScriptPath()); rpmPackage.setPreUninstallScriptPath(scriptFile); assertEquals(scriptFile, rpmPackage.getPreUninstallScriptPath()); - assertEquals(null, rpmPackage.getPreUninstallProgram()); + assertNull(rpmPackage.getPreUninstallProgram()); rpmPackage.setPreUninstallProgram("/bin/sh"); assertEquals("/bin/sh", rpmPackage.getPreUninstallProgram()); - assertEquals(null, rpmPackage.getPostUninstallScriptPath()); + assertNull(rpmPackage.getPostUninstallScriptPath()); rpmPackage.setPostUninstallScriptPath(scriptFile); assertEquals(scriptFile, rpmPackage.getPostUninstallScriptPath()); - assertEquals(null, rpmPackage.getPostUninstallProgram()); + assertNull(rpmPackage.getPostUninstallProgram()); rpmPackage.setPostUninstallProgram("/bin/sh"); assertEquals("/bin/sh", rpmPackage.getPostUninstallProgram()); - assertEquals(null, rpmPackage.getPostTransactionScriptPath()); + assertNull(rpmPackage.getPostTransactionScriptPath()); rpmPackage.setPostTransactionScriptPath(scriptFile); assertEquals(scriptFile, rpmPackage.getPostTransactionScriptPath()); - assertEquals(null, rpmPackage.getPostTransactionProgram()); + assertNull(rpmPackage.getPostTransactionProgram()); rpmPackage.setPostTransactionProgram("/bin/sh"); assertEquals("/bin/sh", rpmPackage.getPostTransactionProgram()); } @@ -302,13 +299,13 @@ public class RpmPackageTest { @Test public void signingKeyAccessors() { - assertEquals(null, rpmPackage.getSigningKey()); + assertNull(rpmPackage.getSigningKey()); rpmPackage.setSigningKey("key"); assertEquals("key", rpmPackage.getSigningKey()); - assertEquals(null, rpmPackage.getSigningKeyId()); + assertNull(rpmPackage.getSigningKeyId()); rpmPackage.setSigningKeyId(0L); - assertEquals(new Long(0L), rpmPackage.getSigningKeyId()); - assertEquals(null, rpmPackage.getSigningKeyPassPhrase()); + assertEquals(Long.valueOf(0L), rpmPackage.getSigningKeyId()); + assertNull(rpmPackage.getSigningKeyPassPhrase()); rpmPackage.setSigningKeyPassPhrase("passphrase"); assertEquals("passphrase", rpmPackage.getSigningKeyPassPhrase()); } @@ -371,7 +368,7 @@ public class RpmPackageTest { rpmPackage.setPostTransactionProgram("/bin/sh"); rpmPackage.build(); String rpmFileName = String.format("%s%s%s", testOutputPath, File.separator, rpmPackage.getFinalName()); - assertEquals(true, new File(rpmFileName).exists()); + assertTrue(new File(rpmFileName).exists()); } @Test @@ -379,7 +376,7 @@ public class RpmPackageTest { rpmPackage.setName("buildSecondaryAttachment"); rpmPackage.build(); String rpmFileName = String.format("%s%s%s", testOutputPath, File.separator, rpmPackage.getFinalName()); - assertEquals(true, new File(rpmFileName).exists()); + assertTrue(new File(rpmFileName).exists()); } @Test @@ -387,7 +384,7 @@ public class RpmPackageTest { rpmPackage.setVersion("2.0"); rpmPackage.build(); String rpmFileName = String.format("%s%s%s", testOutputPath, File.separator, rpmPackage.getFinalName()); - assertEquals(true, new File(rpmFileName).exists()); + assertTrue(new File(rpmFileName).exists()); } @Test @@ -396,7 +393,7 @@ public class RpmPackageTest { rpmPackage.setVersion("2.0"); rpmPackage.build(); String rpmFileName = String.format("%s%s%s", testOutputPath, File.separator, rpmPackage.getFinalName()); - assertEquals(true, new File(rpmFileName).exists()); + assertTrue(new File(rpmFileName).exists()); } @Test @@ -405,6 +402,6 @@ public class RpmPackageTest { rpmPackage.setAttach(false); rpmPackage.build(); String rpmFileName = String.format("%s%s%s", testOutputPath, File.separator, rpmPackage.getFinalName()); - assertEquals(true, new File(rpmFileName).exists()); + assertTrue(new File(rpmFileName).exists()); } } diff --git a/maven-plugin-rpm/src/test/java/org/xbib/maven/plugin/rpm/RpmScriptTemplateRendererTest.java b/maven-plugin-rpm/src/test/java/org/xbib/maven/plugin/rpm/RpmScriptTemplateRendererTest.java index f621706..c130d99 100644 --- a/maven-plugin-rpm/src/test/java/org/xbib/maven/plugin/rpm/RpmScriptTemplateRendererTest.java +++ b/maven-plugin-rpm/src/test/java/org/xbib/maven/plugin/rpm/RpmScriptTemplateRendererTest.java @@ -1,11 +1,9 @@ package org.xbib.maven.plugin.rpm; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import org.junit.Before; -import org.junit.Test; - +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.io.Reader; import java.nio.file.Files; import java.nio.file.Path; @@ -17,7 +15,7 @@ import java.nio.file.Paths; public class RpmScriptTemplateRendererTest { private String testOutputPath; - @Before + @BeforeEach public void setUp() { this.testOutputPath = System.getProperty("project.build.testOutputDirectory"); } diff --git a/maven-plugin-rpm/src/test/java/org/xbib/maven/plugin/rpm/RpmTriggerTest.java b/maven-plugin-rpm/src/test/java/org/xbib/maven/plugin/rpm/RpmTriggerTest.java index 80ee706..8fdbbe6 100644 --- a/maven-plugin-rpm/src/test/java/org/xbib/maven/plugin/rpm/RpmTriggerTest.java +++ b/maven-plugin-rpm/src/test/java/org/xbib/maven/plugin/rpm/RpmTriggerTest.java @@ -1,10 +1,8 @@ package org.xbib.maven.plugin.rpm; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; - -import org.junit.Test; - +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; +import org.junit.jupiter.api.Test; import java.nio.file.Path; import java.nio.file.Paths; import java.util.ArrayList; diff --git a/maven-plugin-rpm/src/test/java/org/xbib/maven/plugin/rpm/mojo/AbstractRpmMojoTest.java b/maven-plugin-rpm/src/test/java/org/xbib/maven/plugin/rpm/mojo/AbstractRpmMojoTest.java index f631e03..e2ecfe5 100644 --- a/maven-plugin-rpm/src/test/java/org/xbib/maven/plugin/rpm/mojo/AbstractRpmMojoTest.java +++ b/maven-plugin-rpm/src/test/java/org/xbib/maven/plugin/rpm/mojo/AbstractRpmMojoTest.java @@ -1,16 +1,15 @@ package org.xbib.maven.plugin.rpm.mojo; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; import org.apache.maven.model.Build; import org.apache.maven.model.License; import org.apache.maven.project.MavenProject; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.xbib.maven.plugin.rpm.MockMojo; import org.xbib.maven.plugin.rpm.RpmPackage; import org.xbib.maven.plugin.rpm.RpmScriptTemplateRenderer; @@ -36,7 +35,7 @@ public class AbstractRpmMojoTest { private MockMojo mojo; private MavenProject project; - @Before + @BeforeEach public void setUp() { testOutputPath = System.getProperty("project.build.testOutputDirectory"); Build projectBuild = new Build(); diff --git a/maven-plugin-rpm/src/test/java/org/xbib/maven/plugin/rpm/mojo/ListFilesRpmMojoTest.java b/maven-plugin-rpm/src/test/java/org/xbib/maven/plugin/rpm/mojo/ListFilesRpmMojoTest.java index cf9b250..d4fe56c 100644 --- a/maven-plugin-rpm/src/test/java/org/xbib/maven/plugin/rpm/mojo/ListFilesRpmMojoTest.java +++ b/maven-plugin-rpm/src/test/java/org/xbib/maven/plugin/rpm/mojo/ListFilesRpmMojoTest.java @@ -3,8 +3,8 @@ package org.xbib.maven.plugin.rpm.mojo; import org.apache.maven.model.Build; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.project.MavenProject; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.xbib.maven.plugin.rpm.RpmPackage; import org.xbib.maven.plugin.rpm.RpmPackageRule; @@ -21,7 +21,7 @@ public class ListFilesRpmMojoTest { private ListFilesRpmMojo mojo; private RpmPackageRule packageRule; - @Before + @BeforeEach public void setUp() { this.testOutputPath = System.getProperty("project.build.testOutputDirectory"); Build projectBuild = new Build(); diff --git a/maven-plugin-rpm/src/test/java/org/xbib/maven/plugin/rpm/mojo/PackageRpmMojoTest.java b/maven-plugin-rpm/src/test/java/org/xbib/maven/plugin/rpm/mojo/PackageRpmMojoTest.java index 96571fc..d3ab0a8 100644 --- a/maven-plugin-rpm/src/test/java/org/xbib/maven/plugin/rpm/mojo/PackageRpmMojoTest.java +++ b/maven-plugin-rpm/src/test/java/org/xbib/maven/plugin/rpm/mojo/PackageRpmMojoTest.java @@ -1,16 +1,15 @@ package org.xbib.maven.plugin.rpm.mojo; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; - +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; import org.apache.maven.model.Build; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.project.MavenProject; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.xbib.maven.plugin.rpm.RpmPackage; import org.xbib.maven.plugin.rpm.RpmPackageRule; - import java.io.File; import java.util.ArrayList; import java.util.List; @@ -26,7 +25,7 @@ public class PackageRpmMojoTest { private RpmPackageRule packageRule; - @Before + @BeforeEach public void setUp() { // Test output path String testOutputPath = System.getProperty("project.build.testOutputDirectory"); @@ -59,7 +58,7 @@ public class PackageRpmMojoTest { includes.add("**"); packageRule.setIncludes(includes); mojo.execute(); - assertEquals(true, project.getArtifact().getFile().exists()); + assertTrue(project.getArtifact().getFile().exists()); } @Test @@ -73,12 +72,14 @@ public class PackageRpmMojoTest { assertNull(project.getArtifact()); } - @Test(expected = MojoExecutionException.class) + @Test public void packageRpmMissedFiles() throws MojoExecutionException { - project.setVersion("2.0-SNAPSHOT"); - List includes = new ArrayList<>(); - packageRule.setIncludes(includes); - mojo.execute(); + Assertions.assertThrows(MojoExecutionException.class, () -> { + project.setVersion("2.0-SNAPSHOT"); + List includes = new ArrayList<>(); + packageRule.setIncludes(includes); + mojo.execute(); + }); } @Test @@ -91,13 +92,15 @@ public class PackageRpmMojoTest { mojo.execute(); } - @Test(expected = MojoExecutionException.class) + @Test public void packageRpmNoFilesPackaged() throws MojoExecutionException { - mojo.setPerformCheckingForExtraFiles(false); - project.setVersion("4.0-SNAPSHOT"); - List includes = new ArrayList<>(); - packageRule.setIncludes(includes); - mojo.execute(); + Assertions.assertThrows(MojoExecutionException.class, () -> { + mojo.setPerformCheckingForExtraFiles(false); + project.setVersion("4.0-SNAPSHOT"); + List includes = new ArrayList<>(); + packageRule.setIncludes(includes); + mojo.execute(); + }); } @Test diff --git a/rpm-ant/build.gradle b/rpm-ant/build.gradle index 319054e..38cb3e2 100644 --- a/rpm-ant/build.gradle +++ b/rpm-ant/build.gradle @@ -1,4 +1,4 @@ dependencies { - compile project(':rpm-core') - compile "org.apache.ant:ant:${project.property('ant.version')}" + api project(':rpm-core') + implementation "org.apache.ant:ant:${project.property('ant.version')}" } diff --git a/rpm-ant/config/checkstyle/checkstyle.xml b/rpm-ant/config/checkstyle/checkstyle.xml deleted file mode 100644 index 55e59d2..0000000 --- a/rpm-ant/config/checkstyle/checkstyle.xml +++ /dev/null @@ -1,323 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/rpm-ant/src/main/java/org/xbib/rpm/ant/RpmTask.java b/rpm-ant/src/main/java/org/xbib/rpm/ant/RpmTask.java index 589a9be..f73e7d5 100644 --- a/rpm-ant/src/main/java/org/xbib/rpm/ant/RpmTask.java +++ b/rpm-ant/src/main/java/org/xbib/rpm/ant/RpmTask.java @@ -30,6 +30,7 @@ import java.net.UnknownHostException; import java.nio.file.Files; import java.nio.file.Path; import java.util.ArrayList; +import java.util.Arrays; import java.util.EnumSet; import java.util.List; @@ -78,31 +79,31 @@ public class RpmTask extends Task { private Path destination; - private List filesets = new ArrayList<>(); + private final List filesets = new ArrayList<>(); - private List emptyDirs = new ArrayList<>(); + private final List emptyDirs = new ArrayList<>(); - private List ghosts = new ArrayList<>(); + private final List ghosts = new ArrayList<>(); - private List links = new ArrayList<>(); + private final List links = new ArrayList<>(); List depends = new ArrayList<>(); - private List moreProvides = new ArrayList<>(); + private final List moreProvides = new ArrayList<>(); - private List conflicts = new ArrayList<>(); + private final List conflicts = new ArrayList<>(); - private List obsoletes = new ArrayList<>(); + private final List obsoletes = new ArrayList<>(); - private List triggersPreIn = new ArrayList<>(); + private final List triggersPreIn = new ArrayList<>(); - private List triggersIn = new ArrayList<>(); + private final List triggersIn = new ArrayList<>(); - private List triggersUn = new ArrayList<>(); + private final List triggersUn = new ArrayList<>(); - private List triggersPostUn = new ArrayList<>(); + private final List triggersPostUn = new ArrayList<>(); - private List builtIns = new ArrayList<>(); + private final List builtIns = new ArrayList<>(); private Path preTransScript; @@ -143,7 +144,7 @@ public class RpmTask extends Task { if (group == null) { throw new BuildException("attribute 'group' is required"); } - Integer numEpoch; + int numEpoch; try { numEpoch = Integer.parseInt(epoch); } catch (Exception e) { @@ -165,7 +166,9 @@ public class RpmTask extends Task { if (provides != null) { rpmBuilder.setProvides(provides); } - rpmBuilder.setPrefixes(prefixes == null ? null : prefixes.split(",")); + if (prefixes != null) { + rpmBuilder.setPrefixes(Arrays.asList(prefixes.split(","))); + } rpmBuilder.setPrivateKeyRing(privateKeyRing); rpmBuilder.setPrivateKeyId(privateKeyId); rpmBuilder.setPrivateKeyPassphrase(privateKeyPassphrase); @@ -212,8 +215,8 @@ public class RpmTask extends Task { prefix += "/"; } DirectoryScanner directoryScanner = fileset.getDirectoryScanner(getProject()); - Integer filemode = fileset.getFileMode(getProject()) & 4095; - Integer dirmode = fileset.getDirMode(getProject()) & 4095; + int filemode = fileset.getFileMode(getProject()) & 4095; + int dirmode = fileset.getDirMode(getProject()) & 4095; String username = null; String group = null; EnumSet directive = null; @@ -238,13 +241,13 @@ public class RpmTask extends Task { rpmBuilder.addURL(prefix + entry, url, filemode, dirmode, directive, username, group); } else { Path path = directoryScanner.getBasedir().toPath().resolve(entry); - rpmBuilder.addFile(prefix + entry, path, filemode, dirmode, directive, username, group); + rpmBuilder.addFile(prefix + entry, path, filemode, dirmode, directive, username, group, true); } } } for (Ghost ghost : ghosts) { rpmBuilder.addFile(ghost.getPath(), null, ghost.getFilemode(), ghost.getDirmode(), - ghost.getDirectives(), ghost.getUsername(), ghost.getGroup()); + ghost.getDirectives(), ghost.getUsername(), ghost.getGroup(), true); } for (Link link : links) { rpmBuilder.addLink(link.getPath(), link.getTarget(), link.getPermissions()); diff --git a/rpm-ant/src/test/java/org/xbib/rpm/ant/RpmTaskTest.java b/rpm-ant/src/test/java/org/xbib/rpm/ant/RpmTaskTest.java index 30b7bc4..9b5baa4 100644 --- a/rpm-ant/src/test/java/org/xbib/rpm/ant/RpmTaskTest.java +++ b/rpm-ant/src/test/java/org/xbib/rpm/ant/RpmTaskTest.java @@ -1,20 +1,22 @@ package org.xbib.rpm.ant; -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.fail; - +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.fail; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.Project; import org.apache.tools.ant.types.EnumeratedAttribute; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.xbib.rpm.RpmReader; import org.xbib.rpm.changelog.ChangelogParser; import org.xbib.rpm.format.Flags; import org.xbib.rpm.format.Format; import org.xbib.rpm.header.EntryType; import org.xbib.rpm.header.HeaderTag; +import org.xbib.rpm.header.IntegerList; +import org.xbib.rpm.header.StringList; import org.xbib.rpm.header.entry.SpecEntry; import org.xbib.rpm.payload.Directive; import org.xbib.rpm.signature.SignatureTag; @@ -24,7 +26,6 @@ import java.nio.file.Path; import java.nio.file.Paths; import java.time.LocalDateTime; import java.time.ZoneOffset; -import java.util.Arrays; import java.util.EnumSet; /** @@ -237,33 +238,30 @@ public class RpmTaskTest { } task.execute(); Format format = getFormat(filename); - String[] require = (String[]) format.getHeader().getEntry(HeaderTag.REQUIRENAME).getValues(); - Integer[] requireflags = (Integer[]) format.getHeader().getEntry(HeaderTag.REQUIREFLAGS).getValues(); - String[] requireversion = (String[]) format.getHeader().getEntry(HeaderTag.REQUIREVERSION).getValues(); - assertArrayEquals(new String[]{"depone", "deptwo", "depthree"}, - Arrays.copyOfRange(require, require.length - 3, require.length)); - assertArrayEquals(new Integer[]{Flags.EQUAL | Flags.GREATER, Flags.LESS, 0}, - Arrays.copyOfRange(requireflags, requireflags.length - 3, require.length)); - assertArrayEquals(new String[]{"1.0", "2.0", ""}, - Arrays.copyOfRange(requireversion, requireversion.length - 3, require.length)); - String[] provide = (String[]) format.getHeader().getEntry(HeaderTag.PROVIDENAME).getValues(); - Integer[] provideflags = (Integer[]) format.getHeader().getEntry(HeaderTag.PROVIDEFLAGS).getValues(); - String[] provideversion = (String[]) format.getHeader().getEntry(HeaderTag.PROVIDEVERSION).getValues(); - assertArrayEquals(new String[]{"rpmtest", "provone", "provtwo", "provthree"}, provide); - assertArrayEquals(new Integer[]{Flags.EQUAL, Flags.EQUAL, Flags.EQUAL, 0}, provideflags); - assertArrayEquals(new String[]{"0:1.0-1", "1.1", "2.1", ""}, provideversion); - String[] conflict = (String[]) format.getHeader().getEntry(HeaderTag.CONFLICTNAME).getValues(); - Integer[] conflictflags = (Integer[]) format.getHeader().getEntry(HeaderTag.CONFLICTFLAGS).getValues(); - String[] conflictversion = (String[]) format.getHeader().getEntry(HeaderTag.CONFLICTVERSION).getValues(); - assertArrayEquals(new String[]{"conone", "contwo", "conthree"}, conflict); - assertArrayEquals(new Integer[]{Flags.EQUAL | Flags.GREATER, Flags.LESS, 0}, conflictflags); - assertArrayEquals(new String[]{"1.2", "2.2", ""}, conflictversion); - String[] obsolete = (String[]) format.getHeader().getEntry(HeaderTag.OBSOLETENAME).getValues(); - Integer[] obsoleteflags = (Integer[]) format.getHeader().getEntry(HeaderTag.OBSOLETEFLAGS).getValues(); - String[] obsoleteversion = (String[]) format.getHeader().getEntry(HeaderTag.OBSOLETEVERSION).getValues(); - assertArrayEquals(new String[]{"obsone", "obstwo", "obsthree"}, obsolete); - assertArrayEquals(new Integer[]{Flags.EQUAL | Flags.GREATER, Flags.LESS, 0}, obsoleteflags); - assertArrayEquals(new String[]{"1.3", "2.3", ""}, obsoleteversion); + StringList require = (StringList) format.getHeader().getEntry(HeaderTag.REQUIRENAME).getValues(); + IntegerList requireflags = (IntegerList) format.getHeader().getEntry(HeaderTag.REQUIREFLAGS).getValues(); + StringList requireversion = (StringList) format.getHeader().getEntry(HeaderTag.REQUIREVERSION).getValues(); + assertThat(StringList.of("depone", "deptwo", "depthree"), is(require.subList(require.size() - 3, require.size()))); + assertThat(IntegerList.of(Flags.EQUAL | Flags.GREATER, Flags.LESS, 0), is(requireflags.subList(requireflags.size() - 3, requireflags.size()))); + assertThat(StringList.of("1.0", "2.0", ""), is(requireversion.subList(requireversion.size() - 3, requireversion.size()))); + StringList provide = (StringList) format.getHeader().getEntry(HeaderTag.PROVIDENAME).getValues(); + IntegerList provideflags = (IntegerList) format.getHeader().getEntry(HeaderTag.PROVIDEFLAGS).getValues(); + StringList provideversion = (StringList) format.getHeader().getEntry(HeaderTag.PROVIDEVERSION).getValues(); + assertThat(StringList.of("rpmtest", "provone", "provtwo", "provthree"), is(provide)); + assertThat(IntegerList.of(Flags.EQUAL, Flags.EQUAL, Flags.EQUAL, 0), is(provideflags)); + assertThat(StringList.of("0:1.0-1", "1.1", "2.1", ""), is(provideversion)); + StringList conflict = (StringList) format.getHeader().getEntry(HeaderTag.CONFLICTNAME).getValues(); + IntegerList conflictflags = (IntegerList) format.getHeader().getEntry(HeaderTag.CONFLICTFLAGS).getValues(); + StringList conflictversion = (StringList) format.getHeader().getEntry(HeaderTag.CONFLICTVERSION).getValues(); + assertThat(StringList.of("conone", "contwo", "conthree"), is(conflict)); + assertThat(IntegerList.of(Flags.EQUAL | Flags.GREATER, Flags.LESS, 0), is(conflictflags)); + assertThat(StringList.of("1.2", "2.2", ""), is(conflictversion)); + StringList obsolete = (StringList) format.getHeader().getEntry(HeaderTag.OBSOLETENAME).getValues(); + IntegerList obsoleteflags = (IntegerList) format.getHeader().getEntry(HeaderTag.OBSOLETEFLAGS).getValues(); + StringList obsoleteversion = (StringList) format.getHeader().getEntry(HeaderTag.OBSOLETEVERSION).getValues(); + assertThat(StringList.of("obsone", "obstwo", "obsthree"), is(obsolete)); + assertThat(IntegerList.of(Flags.EQUAL | Flags.GREATER, Flags.LESS, 0), is(obsoleteflags)); + assertThat(StringList.of("1.3", "2.3", ""), is(obsoleteversion)); } @Test @@ -342,16 +340,14 @@ public class RpmTaskTest { task.addRpmfileset(fs); task.execute(); Format format = getFormat(filename); - assertArrayEquals(new String[]{"jabberwocky"}, - (String[]) format.getHeader().getEntry(HeaderTag.FILEUSERNAME).getValues()); - assertArrayEquals(new String[]{"vorpal"}, - (String[]) format.getHeader().getEntry(HeaderTag.FILEGROUPNAME).getValues()); + assertThat(StringList.of("jabberwocky"), is(format.getHeader().getEntry(HeaderTag.FILEUSERNAME).getValues())); + assertThat(StringList.of("vorpal"), is(format.getHeader().getEntry(HeaderTag.FILEGROUPNAME).getValues())); EnumSet directives = EnumSet.of(Directive.CONFIG, Directive.DOC, Directive.NOREPLACE); - Integer expectedFlags = 0; + int expectedFlags = 0; for (Directive d : directives) { expectedFlags |= d.flag(); } - assertInt32EntryHeaderEquals(new Integer[]{expectedFlags}, format, HeaderTag.FILEFLAGS); + assertInt32EntryHeaderEquals(IntegerList.of(expectedFlags), format, HeaderTag.FILEFLAGS); } @Test @@ -428,47 +424,47 @@ public class RpmTaskTest { } private void assertHeaderEquals(String expected, Format format, EntryType entryType) { - assertNotNull("null format", format); + assertNotNull(format, "null format"); SpecEntry entry = format.getHeader().getEntry(entryType); - assertNotNull("Entry not found : " + entryType.getName(), entry); - assertEquals("Entry type : " + entryType.getName(), 6, entry.getType()); - String[] values = (String[]) entry.getValues(); - assertNotNull("null values", values); - assertEquals("Entry size : " + entryType.getName(), 1, values.length); - assertEquals("Entry value : " + entryType.getName(), expected, values[0]); + assertNotNull(entry, "Entry not found : " + entryType.getName()); + assertEquals(6, entry.getType(), "Entry type : " + entryType.getName()); + StringList values = (StringList) entry.getValues(); + assertNotNull(values, "null values"); + assertEquals(1, values.size(), "Entry size : " + entryType.getName()); + assertEquals(expected, values.get(0), "Entry value : " + entryType.getName()); } private void assertHeaderEqualsAt(String expected, Format format, EntryType entryType, int size, int pos) { - assertNotNull("null format", format); + assertNotNull(format, "null format"); SpecEntry entry = format.getHeader().getEntry(entryType); - assertNotNull("Entry not found : " + entryType.getName(), entry); - assertEquals("Entry type : " + entryType.getName(), 8, entry.getType()); - String[] values = (String[]) entry.getValues(); - assertNotNull("null values", values); - assertEquals("Entry size : " + entryType.getName(), size, values.length); - assertEquals("Entry value : " + entryType.getName(), expected, values[pos]); + assertNotNull(entry, "Entry not found : " + entryType.getName()); + assertEquals(8, entry.getType(), "Entry type : " + entryType.getName()); + StringList values = (StringList) entry.getValues(); + assertNotNull(values, "null values"); + assertEquals(size, values.size(), "Entry size : " + entryType.getName()); + assertEquals(expected, values.get(pos), "Entry value : " + entryType.getName()); } - private void assertInt32EntryHeaderEquals(Integer[] expected, Format format, EntryType entryType) { - assertNotNull("null format", format); + private void assertInt32EntryHeaderEquals(IntegerList expected, Format format, EntryType entryType) { + assertNotNull(format, "null format"); SpecEntry entry = format.getHeader().getEntry(entryType); - assertNotNull("Entry not found : " + entryType.getName(), entry); - assertEquals("Entry type : " + entryType.getName(), 4, entry.getType()); - Integer[] values = (Integer[]) entry.getValues(); - assertNotNull("null values", values); - assertEquals("Entry size : " + entryType.getName(), 1, values.length); - assertArrayEquals("Entry value : " + entryType.getName(), expected, values); + assertNotNull(entry, "Entry not found : " + entryType.getName()); + assertEquals(4, entry.getType(), "Entry type : " + entryType.getName()); + IntegerList values = (IntegerList) entry.getValues(); + assertNotNull(values, "null values"); + assertEquals(1, values.size(), "Entry size : " + entryType.getName()); + assertThat("Entry value : " + entryType.getName(), expected, is(values)); } private void assertDateEntryHeaderEqualsAt(String expected, Format format, EntryType entryType, int size, int pos) { - assertNotNull("null format", format); + assertNotNull(format, "null format"); SpecEntry entry = format.getHeader().getEntry(entryType); - assertNotNull("Entry not found : " + entryType.getName(), entry); - assertEquals("Entry type : " + entryType.getName(), 4, entry.getType()); - Integer[] values = (Integer[]) entry.getValues(); - assertNotNull("null values", values); - assertEquals("Entry size : " + entryType.getName(), size, values.length); - LocalDateTime localDate = LocalDateTime.ofEpochSecond(values[pos], 0, ZoneOffset.UTC); - assertEquals("Entry value : " + entryType.getName(), expected, ChangelogParser.CHANGELOG_FORMAT.format(localDate)); + assertNotNull(entry, "Entry not found : " + entryType.getName()); + assertEquals(4, entry.getType(), "Entry type : " + entryType.getName()); + IntegerList values = (IntegerList) entry.getValues(); + assertNotNull(values, "null values"); + assertEquals(size, values.size(), "Entry size : " + entryType.getName()); + LocalDateTime localDate = LocalDateTime.ofEpochSecond(values.get(pos), 0, ZoneOffset.UTC); + assertEquals(expected, ChangelogParser.CHANGELOG_FORMAT.format(localDate), "Entry value : " + entryType.getName()); } } diff --git a/rpm-core/NOTICE.txt b/rpm-core/NOTICE.txt index c474885..216486b 100644 --- a/rpm-core/NOTICE.txt +++ b/rpm-core/NOTICE.txt @@ -1,6 +1,6 @@ This is a derived work of -http://redline-rpm.org/index.html +Redline RPM http://redline-rpm.org/index.html licensed under MIT License: diff --git a/rpm-core/build.gradle b/rpm-core/build.gradle index 783aa60..fdf2a51 100644 --- a/rpm-core/build.gradle +++ b/rpm-core/build.gradle @@ -1,11 +1,5 @@ dependencies { - compile "org.bouncycastle:bcpg-jdk15on:${project.property('bouncycastle.version')}" - compile "org.xbib:archive:${project.property('xbib-archive.version')}" + api "org.bouncycastle:bcpg-jdk15on:${project.property('bouncycastle.version')}" + api "org.xbib:io-compress-bzip2:${project.property('xbib-archive.version')}" + api "org.xbib:io-compress-xz:${project.property('xbib-archive.version')}" } - -test { - testLogging { - showStandardStreams = true - exceptionFormat = 'full' - } -} \ No newline at end of file diff --git a/rpm-core/config/checkstyle/checkstyle.xml b/rpm-core/config/checkstyle/checkstyle.xml deleted file mode 100644 index 55e59d2..0000000 --- a/rpm-core/config/checkstyle/checkstyle.xml +++ /dev/null @@ -1,323 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/rpm-core/src/main/java/module-info.java b/rpm-core/src/main/java/module-info.java new file mode 100644 index 0000000..7d20df5 --- /dev/null +++ b/rpm-core/src/main/java/module-info.java @@ -0,0 +1,18 @@ +module org.xbib.rpm { + exports org.xbib.rpm; + exports org.xbib.rpm.changelog; + exports org.xbib.rpm.exception; + exports org.xbib.rpm.format; + exports org.xbib.rpm.header; + exports org.xbib.rpm.header.entry; + exports org.xbib.rpm.io; + exports org.xbib.rpm.lead; + exports org.xbib.rpm.payload; + exports org.xbib.rpm.security; + exports org.xbib.rpm.signature; + exports org.xbib.rpm.trigger; + requires org.bouncycastle.pg; + requires org.bouncycastle.provider; + requires org.xbib.io.compress.bzip; + requires org.xbib.io.compress.xz; +} diff --git a/rpm-core/src/main/java/org/xbib/rpm/Dependency.java b/rpm-core/src/main/java/org/xbib/rpm/Dependency.java new file mode 100644 index 0000000..49f331a --- /dev/null +++ b/rpm-core/src/main/java/org/xbib/rpm/Dependency.java @@ -0,0 +1,39 @@ +package org.xbib.rpm; + +/** + * + */ +public class Dependency { + + private final String packageName; + + private final String version; + + private final Integer flags; + + /** + * Creates a new dependency. + * + * @param packageName Name (e.g. "httpd") + * @param version Version (e.g. "1.0") + * @param flags Flags (e.g. "GREATER | Flags.EQUAL") + */ + public Dependency(String packageName, String version, Integer flags) { + this.packageName = packageName; + this.version = version; + this.flags = flags; + } + + public String getPackageName() { + return packageName; + } + + public String getVersion() { + return version; + } + + public Integer getFlags() { + return flags; + } + +} diff --git a/rpm-core/src/main/java/org/xbib/rpm/Directory.java b/rpm-core/src/main/java/org/xbib/rpm/Directory.java new file mode 100644 index 0000000..bc0c23b --- /dev/null +++ b/rpm-core/src/main/java/org/xbib/rpm/Directory.java @@ -0,0 +1,64 @@ +package org.xbib.rpm; + +public class Directory implements Comparable { + + private String path; + + private int permissions = -1; + + private String user = null; + + private String group = null; + + private boolean addParents = false; + + public Directory setPath(String path) { + this.path = path; + return this; + } + + public String getPath() { + return path; + } + + public Directory setPermissions(int permissions) { + this.permissions = permissions; + return this; + } + + public int getPermissions() { + return permissions; + } + + public Directory setUser(String user) { + this.user = user; + return this; + } + + public String getUser() { + return user; + } + + public Directory setGroup(String group) { + this.group = group; + return this; + } + + public String getGroup() { + return group; + } + + public Directory setAddParents(boolean addParents) { + this.addParents = addParents; + return this; + } + + public boolean isAddParents() { + return addParents; + } + + @Override + public int compareTo(Directory o) { + return path.compareTo(o.path); + } +} diff --git a/rpm-core/src/main/java/org/xbib/rpm/Link.java b/rpm-core/src/main/java/org/xbib/rpm/Link.java new file mode 100644 index 0000000..a87a55c --- /dev/null +++ b/rpm-core/src/main/java/org/xbib/rpm/Link.java @@ -0,0 +1,37 @@ +package org.xbib.rpm; + +public class Link implements Comparable { + + private final String path; + + private final String target; + + private int permissions = -1; + + public Link(String path, String target) { + this(path, target, -1); + } + + public Link(String path, String target, int permissions) { + this.path = path; + this.target = target; + this.permissions = permissions; + } + + public String getPath() { + return path; + } + + public String getTarget() { + return target; + } + + public int getPermissions() { + return permissions; + } + + @Override + public int compareTo(Link o) { + return (path + "->" + target).compareTo(o.path + "->" + o.target); + } +} diff --git a/rpm-core/src/main/java/org/xbib/rpm/RpmBuilder.java b/rpm-core/src/main/java/org/xbib/rpm/RpmBuilder.java index 9d8b7bc..9046748 100644 --- a/rpm-core/src/main/java/org/xbib/rpm/RpmBuilder.java +++ b/rpm-core/src/main/java/org/xbib/rpm/RpmBuilder.java @@ -12,6 +12,10 @@ import org.xbib.rpm.format.Flags; import org.xbib.rpm.format.Format; import org.xbib.rpm.header.EntryType; import org.xbib.rpm.header.HeaderTag; +import org.xbib.rpm.header.IntegerList; +import org.xbib.rpm.header.LongList; +import org.xbib.rpm.header.ShortList; +import org.xbib.rpm.header.StringList; import org.xbib.rpm.header.entry.SpecEntry; import org.xbib.rpm.io.ChannelWrapper; import org.xbib.rpm.io.WritableChannelWrapper; @@ -26,10 +30,10 @@ import org.xbib.rpm.security.HashAlgo; import org.xbib.rpm.security.SignatureGenerator; import org.xbib.rpm.signature.SignatureTag; import org.xbib.rpm.trigger.Trigger; - import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; +import java.io.InputStreamReader; import java.io.OutputStream; import java.net.URL; import java.nio.ByteBuffer; @@ -99,7 +103,7 @@ public class RpmBuilder { private int triggerCounter = 0; - private CompressionType compressionType; + private final CompressionType compressionType; private String packageName; @@ -110,7 +114,7 @@ public class RpmBuilder { /** * Initializes the builder and sets some required fields to known values. * @param privateKeyHashAlgo the hash algo - * @param compressionType compression type + * @param compressionType compression type */ public RpmBuilder(HashAlgo privateKeyHashAlgo, CompressionType compressionType) { this.privateKeyHashAlgo = privateKeyHashAlgo; @@ -129,102 +133,6 @@ public class RpmBuilder { addDependencyLess("rpmlib(PayloadIsXz)", "5.2-1"); } - /** - * Returns an array of String with the name of every dependency from a list of dependencies. - * - * @param dependencyList List of dependencies - * @return String[] with all names of the dependencies - */ - private static String[] getArrayOfNames(List dependencyList) { - List list = new ArrayList<>(); - for (Dependency dependency : dependencyList) { - list.add(dependency.getName()); - } - return list.toArray(new String[list.size()]); - } - - /** - * Returns an array of String with the version of every dependency from a list of dependencies. - * - * @param dependencyList List of dependencies - * @return String[] with all versions of the dependencies - */ - private static String[] getArrayOfVersions(List dependencyList) { - List versionList = new ArrayList<>(); - for (Dependency dependency : dependencyList) { - versionList.add(dependency.getVersion()); - } - return versionList.toArray(new String[versionList.size()]); - } - - /** - * Returns an array of Integer with the flags of every dependency from a list of dependencies. - * - * @param dependencyList List of dependencies - * @return Integer[] with all flags of the dependencies - */ - private static Integer[] getArrayOfFlags(List dependencyList) { - List flagsList = new ArrayList<>(); - for (Dependency dependency : dependencyList) { - flagsList.add(dependency.getFlags()); - } - return flagsList.toArray(new Integer[flagsList.size()]); - } - - /** - * Returns an array of String with the name of every dependency from a list of dependencies. - * - * @param dependencies List of dependencies - * @return String[] with all names of the dependencies - */ - private static String[] getArrayOfNames(Map dependencies) { - List nameList = new ArrayList<>(); - for (Dependency dependency : dependencies.values()) { - nameList.add(dependency.getName()); - } - return nameList.toArray(new String[nameList.size()]); - } - - /** - * Returns an array of String with the version of every dependency from a list of dependencies. - * - * @param dependencies List of dependencies - * @return String[] with all versions of the dependencies - */ - private static String[] getArrayOfVersions(Map dependencies) { - List versionList = new ArrayList<>(); - for (Dependency dependency : dependencies.values()) { - versionList.add(dependency.getVersion()); - } - return versionList.toArray(new String[versionList.size()]); - } - - /** - * Returns an array of Integer with the flags of every dependency from a list of dependencies. - * - * @param dependencies List of dependencies - * @return Integer[] with all flags of the dependencies - */ - private static Integer[] getArrayOfFlags(Map dependencies) { - List flagsList = new ArrayList<>(); - for (Dependency dependency : dependencies.values()) { - flagsList.add(dependency.getFlags()); - } - return flagsList.toArray(new Integer[flagsList.size()]); - } - - private static int difference(int start, int boundary) { - return ((boundary + 1) - (start & boundary)) & boundary; - } - - private static String hex(byte[] bytes) { - StringBuilder sb = new StringBuilder(); - for (byte aByte : bytes) { - sb.append(hex.charAt(((int) aByte & 0xf0) >> 4)).append(hex.charAt((int) aByte & 0x0f)); - } - return sb.toString(); - } - public void addBuiltinDirectory(String builtinDirectory) { contents.addLocalBuiltinDirectory(builtinDirectory); } @@ -233,44 +141,44 @@ public class RpmBuilder { obsoletes.add(new Dependency(name, version, comparison)); } - public void addObsoletesLess(CharSequence name, CharSequence version) { + public void addObsoletesLess(String name, String version) { int flag = Flags.LESS | Flags.EQUAL; addObsoletes(name, version, flag); } - public void addObsoletesMore(CharSequence name, CharSequence version) { + public void addObsoletesMore(String name, String version) { int flag = Flags.GREATER | Flags.EQUAL; addObsoletes(name, version, flag); } - public void addObsoletes(CharSequence name, CharSequence version, int flag) { - obsoletes.add(new Dependency(name.toString(), version.toString(), flag)); + public void addObsoletes(String name, String version, int flag) { + obsoletes.add(new Dependency(name, version, flag)); } public void addConflicts(String name, int comparison, String version) { conflicts.add(new Dependency(name, version, comparison)); } - public void addConflictsLess(CharSequence name, CharSequence version) { + public void addConflictsLess(String name, String version) { int flag = Flags.LESS | Flags.EQUAL; addConflicts(name, version, flag); } - public void addConflictsMore(CharSequence name, CharSequence version) { + public void addConflictsMore(String name, String version) { int flag = Flags.GREATER | Flags.EQUAL; addConflicts(name, version, flag); } - public void addConflicts(CharSequence name, CharSequence version, int flag) { - conflicts.add(new Dependency(name.toString(), version.toString(), flag)); + public void addConflicts(String name, String version, int flag) { + conflicts.add(new Dependency(name, version, flag)); } public void addProvides(String name, String version) { provides.put(name, new Dependency(name, version, version.length() > 0 ? Flags.EQUAL : 0)); } - public void addProvides(CharSequence name, CharSequence version, int flag) { - provides.put(name.toString(), new Dependency(name.toString(), version.toString(), flag)); + public void addProvides(String name, int flag, String version) { + provides.put(name, new Dependency(name, version, flag)); } /** @@ -279,11 +187,11 @@ public class RpmBuilder { * install time. * * @param name the name of the dependency - * @param comparison the comparison flag + * @param flags the comparison flag * @param version the version identifier */ - public void addDependency(String name, int comparison, String version) { - requires.add(new Dependency(name, version, comparison)); + public void addDependency(String name, int flags, String version) { + requires.add(new Dependency(name, version, flags)); } /** @@ -294,12 +202,12 @@ public class RpmBuilder { * @param name the name of the dependency * @param version the version identifier */ - public void addDependencyLess(CharSequence name, CharSequence version) { + public void addDependencyLess(String name, String version) { int flag = Flags.LESS | Flags.EQUAL; - if (name.toString().startsWith("rpmlib(")) { + if (name.startsWith("rpmlib(")) { flag = flag | Flags.RPMLIB; } - addDependency(name, version, flag); + addDependency(name, flag, version); } /** @@ -310,21 +218,12 @@ public class RpmBuilder { * @param name the name of the dependency. * @param version the version identifier. */ - public void addDependencyMore(CharSequence name, CharSequence version) { - addDependency(name, version, Flags.GREATER | Flags.EQUAL); - } - - /** - * Adds a dependency to the RPM package. This dependency version will be marked as the exact - * requirement, and the package will require the named dependency with exactly this version at - * install time. - * - * @param name the name of the dependency. - * @param version the version identifier. - * @param flag the file flags - */ - public void addDependency(CharSequence name, CharSequence version, int flag) { - requires.add(new Dependency(name.toString(), version.toString(), flag)); + public void addDependencyMore(String name, String version) { + int flag = Flags.GREATER | Flags.EQUAL; + if (name.startsWith("rpmlib(")) { + flag = flag | Flags.RPMLIB; + } + addDependency(name, flag, version); } /** @@ -368,7 +267,7 @@ public class RpmBuilder { * @throws ClassCastException - if the type required by tag.type() is not short[] */ public void addHeaderEntry(EntryType entryType, short value) { - format.getHeader().createEntry(entryType, new short[]{value}); + format.getHeader().createEntry(entryType, ShortList.of(value)); } /** @@ -376,10 +275,10 @@ public class RpmBuilder { * * @param entryType the header tag to set * @param value the value to set the header entry with - * @throws ClassCastException if the type required by tag.type() is not Integer[] + * @throws ClassCastException if the type required by tag.type() is not IntegerList */ public void addHeaderEntry(EntryType entryType, Integer value) { - format.getHeader().createEntry(entryType, new Integer[]{value}); + format.getHeader().createEntry(entryType, IntegerList.of(value)); } /** @@ -387,10 +286,10 @@ public class RpmBuilder { * * @param entryType the header tag to set * @param value the value to set the header entry with - * @throws ClassCastException - if the type required by tag.type() is not long[] + * @throws ClassCastException - if the type required by tag.type() is not LongList */ public void addHeaderEntry(EntryType entryType, long value) { - format.getHeader().createEntry(entryType, new long[]{value}); + format.getHeader().createEntry(entryType, LongList.of(value)); } /** @@ -409,9 +308,9 @@ public class RpmBuilder { * * @param entryType the header tag to set * @param value the value to set the header entry with - * @throws ClassCastException - if the type required by tag.type() is not short[] + * @throws ClassCastException - if the type required by tag.type() is not ShortList */ - public void addHeaderEntry(EntryType entryType, short[] value) { + public void addHeaderEntry(EntryType entryType, ShortList value) { format.getHeader().createEntry(entryType, value); } @@ -420,9 +319,9 @@ public class RpmBuilder { * * @param entryType the header tag to set * @param value the value to set the header entry with - * @throws ClassCastException - if the type required by tag.type() is not int[] + * @throws ClassCastException - if the type required by tag.type() is not IntegerList */ - public void addHeaderEntry(EntryType entryType, Integer[] value) { + public void addHeaderEntry(EntryType entryType, IntegerList value) { format.getHeader().createEntry(entryType, value); } @@ -431,9 +330,9 @@ public class RpmBuilder { * * @param entryType the header tag to set * @param value the value to set the header entry with - * @throws ClassCastException - if the type required by tag.type() is not long[] + * @throws ClassCastException - if the type required by tag.type() is not LongList */ - public void addHeaderEntry(EntryType entryType, long[] value) { + public void addHeaderEntry(EntryType entryType, LongList value) { format.getHeader().createEntry(entryType, value); } @@ -443,7 +342,7 @@ public class RpmBuilder { * @param variableName the name to include in IllegalArgumentException * @throws IllegalArgumentException if passed in character sequence contains dashes. */ - private void checkVariableContainsIllegalChars(char[] illegalChars, CharSequence variable, String variableName) { + private void checkVariableContainsIllegalChars(char[] illegalChars, String variable, String variableName) { if (variable != null) { for (int i = 0; i < variable.length(); i++) { char currChar = variable.charAt(i); @@ -467,7 +366,7 @@ public class RpmBuilder { * @throws IllegalArgumentException if version or release contain * dashes, as they are explicitly disallowed by RPM file format. */ - public void setPackage(CharSequence name, CharSequence version, CharSequence release, Integer epoch) { + public void setPackage(String name, String version, String release, Integer epoch) { checkVariableContainsIllegalChars(ILLEGAL_CHARS_NAME, name, "name"); checkVariableContainsIllegalChars(ILLEGAL_CHARS_VARIABLE, version, "version"); checkVariableContainsIllegalChars(ILLEGAL_CHARS_VARIABLE, release, "release"); @@ -480,7 +379,7 @@ public class RpmBuilder { addProvides(String.valueOf(name), "" + epoch + ":" + version + "-" + release); } - public void setPackage(CharSequence name, CharSequence version, CharSequence release) { + public void setPackage(String name, String version, String release) { setPackage(name, version, release, 0); } @@ -503,8 +402,8 @@ public class RpmBuilder { public void setPlatform(Architecture arch, Os os) { format.getLead().setArch(arch); format.getLead().setOs(os); - CharSequence archName = arch.toString().toLowerCase(); - CharSequence osName = os.toString().toLowerCase(); + String archName = arch.toString().toLowerCase(); + String osName = os.toString().toLowerCase(); format.getHeader().createEntry(HeaderTag.ARCH, archName); format.getHeader().createEntry(HeaderTag.OS, osName); format.getHeader().createEntry(HeaderTag.PLATFORM, archName + "-" + osName); @@ -518,10 +417,10 @@ public class RpmBuilder { * @param arch the target architecture. * @param osName the non-standard target operating system. */ - public void setPlatform(Architecture arch, CharSequence osName) { + public void setPlatform(Architecture arch, String osName) { format.getLead().setArch(arch); format.getLead().setOs(Os.UNKNOWN); - CharSequence archName = arch.toString().toLowerCase(); + String archName = arch.toString().toLowerCase(); format.getHeader().createEntry(HeaderTag.ARCH, archName); format.getHeader().createEntry(HeaderTag.OS, osName); format.getHeader().createEntry(HeaderTag.PLATFORM, archName + "-" + osName); @@ -534,7 +433,7 @@ public class RpmBuilder { * * @param summary summary text. */ - public void setSummary(CharSequence summary) { + public void setSummary(String summary) { if (summary != null) { format.getHeader().createEntry(HeaderTag.SUMMARY, summary); } @@ -546,7 +445,7 @@ public class RpmBuilder { * * @param description description text. */ - public void setDescription(CharSequence description) { + public void setDescription(String description) { if (description != null) { format.getHeader().createEntry(HeaderTag.DESCRIPTION, description); } @@ -557,7 +456,7 @@ public class RpmBuilder { * * @param host hostname of the build machine. */ - public void setBuildHost(CharSequence host) { + public void setBuildHost(String host) { if (host != null) { format.getHeader().createEntry(HeaderTag.BUILDHOST, host); } @@ -569,7 +468,7 @@ public class RpmBuilder { * * @param license the chosen distribution license. */ - public void setLicense(CharSequence license) { + public void setLicense(String license) { if (license != null) { format.getHeader().createEntry(HeaderTag.LICENSE, license); } @@ -581,7 +480,7 @@ public class RpmBuilder { * * @param group target group. */ - public void setGroup(CharSequence group) { + public void setGroup(String group) { if (group != null) { format.getHeader().createEntry(HeaderTag.GROUP, group); } @@ -592,7 +491,7 @@ public class RpmBuilder { * * @param distribution the distribution. */ - public void setDistribution(CharSequence distribution) { + public void setDistribution(String distribution) { if (distribution != null) { format.getHeader().createEntry(HeaderTag.DISTRIBUTION, distribution); } @@ -603,7 +502,7 @@ public class RpmBuilder { * * @param vendor software vendor. */ - public void setVendor(CharSequence vendor) { + public void setVendor(String vendor) { if (vendor != null) { format.getHeader().createEntry(HeaderTag.VENDOR, vendor); } @@ -614,7 +513,7 @@ public class RpmBuilder { * * @param packager packager name. */ - public void setPackager(CharSequence packager) { + public void setPackager(String packager) { if (packager != null) { format.getHeader().createEntry(HeaderTag.PACKAGER, packager); } @@ -625,7 +524,7 @@ public class RpmBuilder { * * @param url the URL */ - public void setUrl(CharSequence url) { + public void setUrl(String url) { if (url != null) { format.getHeader().createEntry(HeaderTag.URL, url); } @@ -640,10 +539,10 @@ public class RpmBuilder { * * @param provides dependency provided by this package. */ - public void setProvides(CharSequence provides) { + public void setProvides(String provides) { if (provides != null) { this.provides.clear(); - addProvides(provides, "", Flags.EQUAL); + addProvides(provides, Flags.EQUAL, ""); } } @@ -658,6 +557,11 @@ public class RpmBuilder { this.contents = contents; } + /** + * Get the contents. + * + * @return the contents + */ public Contents getContents() { return contents; } @@ -665,11 +569,11 @@ public class RpmBuilder { /** * Adds a source rpm. * - * @param rpm name of rpm source file + * @param sourceRpm name of rpm source file */ - public void setSourceRpm(String rpm) { - if (rpm != null) { - format.getHeader().createEntry(HeaderTag.SOURCERPM, rpm); + public void setSourceRpm(String sourceRpm) { + if (sourceRpm != null && !sourceRpm.isEmpty()) { + format.getHeader().createEntry(HeaderTag.SOURCERPM, sourceRpm); } } @@ -679,24 +583,12 @@ public class RpmBuilder { * * @param prefixes Path prefixes which may be relocated */ - public void setPrefixes(String... prefixes) { - if (prefixes != null && 0 < prefixes.length) { - format.getHeader().createEntry(HeaderTag.PREFIXES, prefixes); + public void setPrefixes(List prefixes) { + if (prefixes != null && !prefixes.isEmpty()) { + format.getHeader().createEntry(HeaderTag.PREFIXES, new StringList(prefixes)); } } - /** - * Declares a script file to be run as part of the RPM pre-transaction. The - * script will be run using the interpreter declared with the - * {@link #setPreTransProgram(String)} method. - * - * @param path Script to run (i.e. shell commands) - * @throws IOException there was an IO error - */ - public void setPreTrans(String path) throws IOException { - setPreTrans(Paths.get(path)); - } - /** * Declares a script file to be run as part of the RPM pre-transaction. The * script will be run using the interpreter declared with the @@ -706,7 +598,7 @@ public class RpmBuilder { * @throws IOException there was an IO error */ public void setPreTrans(Path path) throws IOException { - setPreTransValue(readScript(path)); + setPreTrans(readScript(path)); } /** @@ -716,7 +608,7 @@ public class RpmBuilder { * * @param content Script contents to run (i.e. shell commands) */ - public void setPreTransValue(String content) { + public void setPreTrans(String content) { setPreTransProgram(readProgram(content)); if (content != null) { format.getHeader().createEntry(HeaderTag.PRETRANSSCRIPT, content); @@ -726,7 +618,7 @@ public class RpmBuilder { /** * Declares the interpreter to be used when invoking the RPM * pre-transaction script that can be set with the - * {@link #setPreTransValue(String)} method. + * {@link #setPreTrans(String)} method. * * @param program Path to the interpreter */ @@ -740,18 +632,6 @@ public class RpmBuilder { } } - /** - * Declares a script file to be run as part of the RPM pre-installation. The - * script will be run using the interpreter declared with the - * {@link #setPreInstallProgram(String)} method. - * - * @param path Script to run (i.e. shell commands) - * @throws IOException there was an IO error - */ - public void setPreInstall(String path) throws IOException { - setPreInstall(Paths.get(path)); - } - /** * Declares a script file to be run as part of the RPM pre-installation. The * script will be run using the interpreter declared with the @@ -761,7 +641,7 @@ public class RpmBuilder { * @throws IOException there was an IO error */ public void setPreInstall(Path path) throws IOException { - setPreInstallValue(readScript(path)); + setPreInstall(readScript(path)); } /** @@ -771,9 +651,9 @@ public class RpmBuilder { * * @param content Script contents to run (i.e. shell commands) */ - public void setPreInstallValue(String content) { + public void setPreInstall(String content) { setPreInstallProgram(readProgram(content)); - if (content != null) { + if (content != null && !content.isEmpty()) { format.getHeader().createEntry(HeaderTag.PREINSCRIPT, content); } } @@ -781,33 +661,18 @@ public class RpmBuilder { /** * Declares the interpreter to be used when invoking the RPM * pre-installation script that can be set with the - * {@link #setPreInstallValue(String)} method. + * {@link #setPreInstall(String)} method. * * @param program Path to the interpretter */ public void setPreInstallProgram(String program) { - if (program == null) { - format.getHeader().createEntry(HeaderTag.PREINPROG, DEFAULTSCRIPTPROG); - } else if (0 == program.length()) { + if (program == null || program.length() == 0) { format.getHeader().createEntry(HeaderTag.PREINPROG, DEFAULTSCRIPTPROG); } else { format.getHeader().createEntry(HeaderTag.PREINPROG, program); } } - - /** - * Declares a script file to be run as part of the RPM post-installation. The - * script will be run using the interpreter declared with the - * {@link #setPostInstallProgram(String)} method. - * - * @param path Script to run (i.e. shell commands) - * @throws IOException there was an IO error - */ - public void setPostInstall(String path) throws IOException { - setPostInstall(Paths.get(path)); - } - /** * Declares a script file to be run as part of the RPM post-installation. The * script will be run using the interpreter declared with the @@ -817,7 +682,7 @@ public class RpmBuilder { * @throws IOException there was an IO error */ public void setPostInstall(Path path) throws IOException { - setPostInstallValue(readScript(path)); + setPostInstall(readScript(path)); } /** @@ -827,9 +692,9 @@ public class RpmBuilder { * * @param script Script contents to run (i.e. shell commands) */ - public void setPostInstallValue(String script) { + public void setPostInstall(String script) { setPostInstallProgram(readProgram(script)); - if (script != null) { + if (script != null && !script.isEmpty()) { format.getHeader().createEntry(HeaderTag.POSTINSCRIPT, script); } } @@ -837,7 +702,7 @@ public class RpmBuilder { /** * Declares the interpreter to be used when invoking the RPM * post-installation script that can be set with the - * {@link #setPostInstallValue(String)} method. + * {@link #setPostInstall(String)} method. * * @param program Path to the interpreter */ @@ -851,18 +716,6 @@ public class RpmBuilder { } } - /** - * Declares a script file to be run as part of the RPM pre-uninstallation. The - * script will be run using the interpreter declared with the - * {@link #setPreUninstallProgram(String)} method. - * - * @param path Script to run (i.e. shell commands) - * @throws IOException there was an IO error - */ - public void setPreUninstall(String path) throws IOException { - setPreUninstall(Paths.get(path)); - } - /** * Declares a script file to be run as part of the RPM pre-uninstallation. The * script will be run using the interpreter declared with the @@ -872,7 +725,7 @@ public class RpmBuilder { * @throws IOException there was an IO error */ public void setPreUninstall(Path path) throws IOException { - setPreUninstallValue(readScript(path)); + setPreUninstall(readScript(path)); } /** @@ -882,9 +735,9 @@ public class RpmBuilder { * * @param script Script contents to run (i.e. shell commands) */ - public void setPreUninstallValue(String script) { - setPreUninstallProgram(readProgram(script)); - if (script != null) { + public void setPreUninstall(String script) { + if (script != null && !script.isEmpty()) { + setPreUninstallProgram(readProgram(script)); format.getHeader().createEntry(HeaderTag.PREUNSCRIPT, script); } } @@ -892,33 +745,18 @@ public class RpmBuilder { /** * Declares the interpreter to be used when invoking the RPM * pre-uninstallation script that can be set with the - * {@link #setPreUninstallValue(String)} method. + * {@link #setPreUninstall(String)} method. * * @param program Path to the interpreter */ public void setPreUninstallProgram(String program) { - if (program == null) { - format.getHeader().createEntry(HeaderTag.PREUNPROG, DEFAULTSCRIPTPROG); - } else if (0 == program.length()) { + if (program == null || program.length() == 0) { format.getHeader().createEntry(HeaderTag.PREUNPROG, DEFAULTSCRIPTPROG); } else { format.getHeader().createEntry(HeaderTag.PREUNPROG, program); } } - - /** - * Declares a script file to be run as part of the RPM post-uninstallation. The - * script will be run using the interpreter declared with the - * {@link #setPostUninstallProgram(String)} method. - * - * @param path Script contents to run (i.e. shell commands) - * @throws IOException there was an IO error - */ - public void setPostUninstall(String path) throws IOException { - setPostUninstall(Paths.get(path)); - } - /** * Declares a script file to be run as part of the RPM post-uninstallation. The * script will be run using the interpreter declared with the @@ -928,7 +766,7 @@ public class RpmBuilder { * @throws IOException there was an IO error */ public void setPostUninstall(Path path) throws IOException { - setPostUninstallValue(readScript(path)); + setPostUninstall(readScript(path)); } /** @@ -938,7 +776,7 @@ public class RpmBuilder { * * @param content Script contents to run (i.e. shell commands) */ - public void setPostUninstallValue(String content) { + public void setPostUninstall(String content) { setPostUninstallProgram(readProgram(content)); if (content != null) { format.getHeader().createEntry(HeaderTag.POSTUNSCRIPT, content); @@ -948,7 +786,7 @@ public class RpmBuilder { /** * Declares the interpreter to be used when invoking the RPM * post-uninstallation script that can be set with the - * {@link #setPostUninstallValue(String)} method. + * {@link #setPostUninstall(String)} method. * * @param program Path to the interpreter */ @@ -962,18 +800,6 @@ public class RpmBuilder { } } - /** - * Declares a script file to be run as part of the RPM post-transaction. The - * script will be run using the interpreter declared with the - * {@link #setPostTransProgram(String)} method. - * - * @param path Script contents to run (i.e. shell commands) - * @throws IOException there was an IO error - */ - public void setPostTrans(String path) throws IOException { - setPostTrans(Paths.get(path)); - } - /** * Declares a script file to be run as part of the RPM post-transaction. The * script will be run using the interpreter declared with the @@ -983,7 +809,7 @@ public class RpmBuilder { * @throws IOException there was an IO error */ public void setPostTrans(Path path) throws IOException { - setPostTransValue(readScript(path)); + setPostTrans(readScript(path)); } /** @@ -993,7 +819,7 @@ public class RpmBuilder { * * @param content Script contents to run (i.e. shell commands) */ - public void setPostTransValue(String content) { + public void setPostTrans(String content) { setPostTransProgram(readProgram(content)); if (content != null) { format.getHeader().createEntry(HeaderTag.POSTTRANSSCRIPT, content); @@ -1003,14 +829,12 @@ public class RpmBuilder { /** * Declares the interpreter to be used when invoking the RPM * post-transaction script that can be set with the - * {@link #setPostTransValue(String)} method. + * {@link #setPostTrans(String)} method. * * @param program Path to the interpreter */ public void setPostTransProgram(String program) { - if (program == null) { - format.getHeader().createEntry(HeaderTag.POSTTRANSPROG, DEFAULTSCRIPTPROG); - } else if (0 == program.length()) { + if (program == null || program.length() == 0) { format.getHeader().createEntry(HeaderTag.POSTTRANSPROG, DEFAULTSCRIPTPROG); } else { format.getHeader().createEntry(HeaderTag.POSTTRANSPROG, program); @@ -1045,76 +869,6 @@ public class RpmBuilder { triggerCounter++; } - /** - * Add the specified file to the repository payload in order. - * The required header entries will automatically be generated - * to record the directory names and file names, as well as their - * digests. - * - * @param path the absolute path at which this file will be installed. - * @param source the path content to include in this rpm. - * @param mode the mode of the target file in standard three octet notation - * @throws IOException there was an IO error - */ - public void addFile(String path, Path source, int mode) throws IOException { - contents.addFile(path, source, mode); - } - - /** - * Add the specified file to the repository payload in order. - * The required header entries will automatically be generated - * to record the directory names and file names, as well as their - * digests. - * - * @param path the absolute path at which this file will be installed. - * @param source the file to include in this archive. - * @param mode the mode of the target file in standard three octet notation - * @param dirmode the mode of the parent directories in standard three octet notation, or -1 for default. - * @throws IOException there was an IO error - */ - public void addFile(String path, Path source, int mode, int dirmode) throws IOException { - contents.addFile(path, source, mode, dirmode); - } - - /** - * Add the specified file to the repository payload in order. - * The required header entries will automatically be generated - * to record the directory names and file names, as well as their - * digests. - * - * @param path the absolute path at which this file will be installed. - * @param source the file to include in this archive. - * @param mode the mode of the target file in standard three octet notation - * @param dirmode the mode of the parent directories in standard three octet notation, or -1 for default. - * @param uname user owner for the given file - * @param gname group owner for the given file - * @throws IOException there was an IO error - */ - public void addFile(String path, Path source, int mode, int dirmode, String uname, String gname) - throws IOException { - contents.addFile(path, source, mode, null, uname, gname, dirmode); - } - - /** - * Add the specified file to the repository payload in order. - * The required header entries will automatically be generated - * to record the directory names and file names, as well as their - * digests. - * - * @param path the absolute path at which this file will be installed. - * @param source the file to include in this rpm. - * @param mode the mode of the target file in standard three octet notation - * @param dirmode the mode of the parent directories in standard three octet notation, or -1 for default. - * @param directive directive indicating special handling for this file. - * @param uname user owner for the given file - * @param gname group owner for the given file - * @throws IOException there was an IO error - */ - public void addFile(String path, Path source, int mode, int dirmode, EnumSet directive, String uname, - String gname) throws IOException { - contents.addFile(path, source, mode, directive, uname, gname, dirmode); - } - /** * Add the specified file to the repository payload in order. * The required header entries will automatically be generated @@ -1126,14 +880,15 @@ public class RpmBuilder { * @param mode the mode of the target file in standard three octet notation, or -1 for default. * @param dirmode the mode of the parent directories in standard three octet notation, or -1 for default. * @param directive directive indicating special handling for this file. - * @param uname user owner for the given file, or null for default user. - * @param gname group owner for the given file, or null for default group. + * @param uname user owner of the file + * @param gname group owner of the file * @param addParents whether to create parent directories for the file, defaults to true for other methods. * @throws IOException there was an IO error */ - public void addFile(String path, Path source, int mode, int dirmode, EnumSet directive, String uname, - String gname, boolean addParents) throws IOException { - contents.addFile(path, source, mode, directive, uname, gname, dirmode, addParents); + public void addFile(String path, Path source, int mode, int dirmode, + EnumSet directive, + String uname, String gname, boolean addParents) throws IOException { + addFile(path, source, mode, dirmode, directive, uname, gname, addParents, -1); } /** @@ -1147,143 +902,16 @@ public class RpmBuilder { * @param mode the mode of the target file in standard three octet notation, or -1 for default. * @param dirmode the mode of the parent directories in standard three octet notation, or -1 for default. * @param directive directive indicating special handling for this file. - * @param uname user owner for the given file, or null for default user. - * @param gname group owner for the given file, or null for default group. - * @param addParents whether to create parent directories for the file, defaults to true for other methods. - * @param verifyFlags verify flags - * @throws IOException there was an IO error - */ - public void addFile(String path, Path source, int mode, int dirmode, EnumSet directive, String uname, - String gname, boolean addParents, int verifyFlags) throws IOException { - contents.addFile(path, source, mode, directive, uname, gname, dirmode, addParents, verifyFlags); - } - - /** - * Add the specified file to the repository payload in order. - * The required header entries will automatically be generated - * to record the directory names and file names, as well as their - * digests. - * - * @param path the absolute path at which this file will be installed. - * @param source the file to include in this rpm. - * @param mode the mode of the target file in standard three octet notation - * @param directive directive indicating special handling for this file. - * @param uname user owner for the given file - * @param gname group owner for the given file - * @throws IOException there was an IO error - */ - public void addFile(String path, Path source, int mode, EnumSet directive, String uname, String gname) - throws IOException { - contents.addFile(path, source, mode, directive, uname, gname); - } - - /** - * Add the specified file to the repository payload in order. - * The required header entries will automatically be generated - * to record the directory names and file names, as well as their - * digests. - * - * @param path the absolute path at which this file will be installed. - * @param source the file content to include in this rpm. - * @param mode the mode of the target file in standard three octet notation - * @param directive directive indicating special handling for this file. - * @throws IOException there was an IO error - */ - public void addFile(String path, Path source, int mode, EnumSet directive) - throws IOException { - contents.addFile(path, source, mode, directive); - } - - /** - * Adds the file to the repository with the default mode of 644. - * - * @param path the absolute path at which this file will be installed. - * @param source the file content to include in this archive. - * @throws IOException there was an IO error - */ - public void addFile(String path, Path source) - throws IOException { - contents.addFile(path, source); - } - - /** - * Add the specified file to the repository payload in order by URL. - * The required header entries will automatically be generated - * to record the directory names and file names, as well as their - * digests. - * - * @param path the absolute path at which this file will be installed. - * @param source the file content to include in this rpm. - * @param mode the mode of the target file in standard three octet notation - * @param dirmode the mode of the parent directories in standard three octet notation, or -1 for default. - * @throws IOException there was an IO error - */ - public void addURL(String path, URL source, int mode, int dirmode) throws IOException { - contents.addURL(path, source, mode, null, null, null, dirmode); - } - - /** - * Add the specified file to the repository payload in order by URL. - * The required header entries will automatically be generated - * to record the directory names and file names, as well as their - * digests. - * - * @param path the absolute path at which this file will be installed. - * @param source the file content to include in this rpm. - * @param mode the mode of the target file in standard three octet notation - * @param dirmode the mode of the parent directories in standard three octet notation, or -1 for default. - * @param username ownership of added file - * @param group ownership of added file - * @throws IOException there was an IO error - */ - public void addURL(String path, URL source, int mode, int dirmode, String username, String group) - throws IOException { - contents.addURL(path, source, mode, null, username, group, dirmode); - } - - /** - * Add the specified file to the repository payload in order by URL. - * The required header entries will automatically be generated - * to record the directory names and file names, as well as their - * digests. - * - * @param path the absolute path at which this file will be installed. - * @param source the file content to include in this rpm. - * @param mode the mode of the target file in standard three octet notation - * @param dirmode the mode of the parent directories in standard three octet notation, or -1 for default. - * @param directives directive indicating special handling for this file. - * @param username ownership of added file - * @param group ownership of added file - * @throws IOException there was an IO error - */ - public void addURL(String path, URL source, int mode, int dirmode, EnumSet directives, String username, - String group) throws IOException { - contents.addURL(path, source, mode, directives, username, group, dirmode); - } - - /** - * Adds the directory to the repository with the default mode of 644. - * - * @param path the absolute path to add as a directory. - * @throws IOException there was an IO error - */ - public void addDirectory(String path) throws IOException { - contents.addDirectory(path); - } - - /** - * Adds the directory to the repository. - * - * @param path the absolute path to add as a directory. - * @param permissions the mode of the directory in standard three octet notation. - * @param directives directive indicating special handling for this file. * @param uname user owner of the directory * @param gname group owner of the directory - * @throws IOException there was an IO error + * @param addParents whether to create parent directories for the file, defaults to true for other methods. + * @param verifyFlags verify flags + * @throws IOException there was an IO error */ - public void addDirectory(String path, int permissions, EnumSet directives, String uname, String gname) - throws IOException { - contents.addDirectory(path, permissions, directives, uname, gname); + public void addFile(String path, Path source, int mode, int dirmode, + EnumSet directive, + String uname, String gname, boolean addParents, int verifyFlags) throws IOException { + contents.addFile(path, source, mode, dirmode, directive, uname, gname, -1, -1, addParents, verifyFlags); } /** @@ -1295,33 +923,28 @@ public class RpmBuilder { * @param uname user owner of the directory * @param gname group owner of the directory * @param addParents whether to add parent directories to the rpm - * @throws IOException there was an IO error */ - public void addDirectory(String path, int permissions, EnumSet directives, String uname, String gname, - boolean addParents) throws IOException { - contents.addDirectory(path, permissions, directives, uname, gname, addParents); + public void addDirectory(String path, int permissions, EnumSet directives, + String uname, String gname, + boolean addParents) { + contents.addDirectory(path, permissions, directives, uname, gname,-1, -1, addParents); } /** - * Adds the directory to the repository with the default mode of 644. + * Adds an URL (from a jar) to the repository. * - * @param path the absolute path to add as a directory. - * @param directive directive indicating special handling for this file. - * @throws IOException there was an IO error + * @param path the absolute path + * @param source the URL source + * @param permissions the file mode + * @param dirmode the directory mode + * @param directives directives indicating special handling for this file + * @param uname user owner of the entry + * @param gname group owner of the entry */ - public void addDirectory(String path, EnumSet directive) throws IOException { - contents.addDirectory(path, directive); - } - - /** - * Adds a symbolic link to the repository. - * - * @param path the absolute path at which this link will be installed. - * @param target the path of the file this link will point to. - * @throws IOException there was an IO error - */ - public void addLink(String path, String target) throws IOException { - contents.addLink(path, target); + public void addURL(String path, URL source, int permissions, int dirmode, + EnumSet directives, + String uname, String gname) { + contents.addURL(path, source, permissions, directives, uname, gname, -1, -1, dirmode); } /** @@ -1330,11 +953,9 @@ public class RpmBuilder { * @param path the absolute path at which this link will be installed. * @param target the path of the file this link will point to. * @param permissions the permissions flags - * @throws IOException there was an IO error */ - public void addLink(String path, String target, int permissions) - throws IOException { - contents.addLink(path, target, permissions); + public void addLink(String path, String target, int permissions) { + addLink(path, target, permissions, null, null); } /** @@ -1345,22 +966,23 @@ public class RpmBuilder { * @param permissions the permissions flags * @param username user owner of the link * @param groupname group owner of the link - * @throws IOException there was an IO error */ - public void addLink(String path, String target, int permissions, String username, String groupname) - throws IOException { - contents.addLink(path, target, permissions, username, groupname); + public void addLink(String path, String target, int permissions, + String username, String groupname) { + contents.addLink(path, target, permissions, username, groupname, -1, -1, true); } /** * Adds the supplied Changelog path as a Changelog to the header. * - * @param changelogFile File containing the Changelog information + * @param changelogContents File containing the Changelog information * @throws IOException if file does not exist or cannot be read * @throws ChangelogParseException if file is not of the correct format. */ - public void addChangelog(String changelogFile) throws IOException, ChangelogParseException { - new ChangelogHandler(format.getHeader()).addChangeLog(Paths.get(changelogFile)); + public void addChangelog(String changelogContents) throws IOException, ChangelogParseException { + if (changelogContents != null) { + new ChangelogHandler(format.getHeader()).addChangeLog(changelogContents); + } } /** @@ -1371,29 +993,23 @@ public class RpmBuilder { * @throws ChangelogParseException if file is not of the correct format. */ public void addChangelog(Path changelogFile) throws IOException, ChangelogParseException { - new ChangelogHandler(format.getHeader()).addChangeLog(changelogFile); + if (changelogFile != null) { + new ChangelogHandler(format.getHeader()).addChangeLog(changelogFile); + } } /** * Adds the supplied Changelog file as a Changelog to the header. * - * @param changelogFile URL containing the Changelog information + * @param changelogInputStream input stream containing the Changelog information * @throws IOException if file does not exist or cannot be read * @throws ChangelogParseException if file is not of the correct format. */ - public void addChangelog(URL changelogFile) throws IOException, ChangelogParseException { - new ChangelogHandler(format.getHeader()).addChangeLog(changelogFile); - } - - /** - * Adds the supplied Changelog file as a Changelog to the header. - * - * @param changelogFile URL containing the Changelog information - * @throws IOException if file does not exist or cannot be read - * @throws ChangelogParseException if file is not of the correct format. - */ - public void addChangelog(InputStream changelogFile) throws IOException, ChangelogParseException { - new ChangelogHandler(format.getHeader()).addChangeLog(changelogFile); + public void addChangelog(InputStream changelogInputStream) throws IOException, ChangelogParseException { + if (changelogInputStream != null) { + new ChangelogHandler(format.getHeader()) + .addChangeLog(new InputStreamReader(changelogInputStream, StandardCharsets.UTF_8)); + } } /** @@ -1403,7 +1019,9 @@ public class RpmBuilder { * @throws IOException if file does not exist or cannot be read */ public void setPrivateKeyRing(String privateKeyRing) throws IOException { - setPrivateKeyRing(Paths.get(privateKeyRing)); + if (privateKeyRing != null) { + setPrivateKeyRing(Paths.get(privateKeyRing)); + } } /** @@ -1413,7 +1031,10 @@ public class RpmBuilder { * @throws IOException if file does not exist or cannot be read */ public void setPrivateKeyRing(Path privateKeyRing) throws IOException { - setPrivateKeyRing(Files.newInputStream(privateKeyRing)); + if (privateKeyRing != null && Files.exists(privateKeyRing)) { + // will be closed in the SignatureGeneratur + setPrivateKeyRing(Files.newInputStream(privateKeyRing)); + } } /** @@ -1422,7 +1043,9 @@ public class RpmBuilder { * @param privateKeyRing the private key ring input stream */ public void setPrivateKeyRing(InputStream privateKeyRing) { - this.privateKeyRing = privateKeyRing; + if (privateKeyRing != null) { + this.privateKeyRing = privateKeyRing; + } } /** @@ -1432,7 +1055,9 @@ public class RpmBuilder { * @param privateKeyId long value from hex key id */ public void setPrivateKeyId(String privateKeyId) { - setPrivateKeyId(Long.decode("0x" + privateKeyId)); + if (privateKeyId != null && !privateKeyId.isEmpty()) { + setPrivateKeyId(Long.decode("0x" + privateKeyId)); + } } /** @@ -1451,7 +1076,9 @@ public class RpmBuilder { * @param privateKeyPassphrase the private key pass phrase */ public void setPrivateKeyPassphrase(String privateKeyPassphrase) { - this.privateKeyPassphrase = privateKeyPassphrase; + if (privateKeyPassphrase != null && !privateKeyPassphrase.isEmpty()) { + this.privateKeyPassphrase = privateKeyPassphrase; + } } /** @@ -1460,7 +1087,7 @@ public class RpmBuilder { * @param privateKeyHashAlgo the private key hash algo */ public void setPrivateKeyHashAlgo(String privateKeyHashAlgo) { - if (privateKeyHashAlgo != null) { + if (privateKeyHashAlgo != null && !privateKeyHashAlgo.isEmpty()) { this.privateKeyHashAlgo = HashAlgo.valueOf(privateKeyHashAlgo); } } @@ -1512,23 +1139,23 @@ public class RpmBuilder { @SuppressWarnings("unchecked") public void build(SeekableByteChannel channel) throws RpmException, IOException { WritableChannelWrapper output = new WritableChannelWrapper(channel); - format.getHeader().createEntry(HeaderTag.REQUIRENAME, getArrayOfNames(requires)); - format.getHeader().createEntry(HeaderTag.REQUIREVERSION, getArrayOfVersions(requires)); - format.getHeader().createEntry(HeaderTag.REQUIREFLAGS, getArrayOfFlags(requires)); + format.getHeader().createEntry(HeaderTag.REQUIRENAME, getStringList(requires)); + format.getHeader().createEntry(HeaderTag.REQUIREVERSION, getVersions(requires)); + format.getHeader().createEntry(HeaderTag.REQUIREFLAGS, getFlags(requires)); if (obsoletes.size() > 0) { - format.getHeader().createEntry(HeaderTag.OBSOLETENAME, getArrayOfNames(obsoletes)); - format.getHeader().createEntry(HeaderTag.OBSOLETEVERSION, getArrayOfVersions(obsoletes)); - format.getHeader().createEntry(HeaderTag.OBSOLETEFLAGS, getArrayOfFlags(obsoletes)); + format.getHeader().createEntry(HeaderTag.OBSOLETENAME, getStringList(obsoletes)); + format.getHeader().createEntry(HeaderTag.OBSOLETEVERSION, getVersions(obsoletes)); + format.getHeader().createEntry(HeaderTag.OBSOLETEFLAGS, getFlags(obsoletes)); } if (conflicts.size() > 0) { - format.getHeader().createEntry(HeaderTag.CONFLICTNAME, getArrayOfNames(conflicts)); - format.getHeader().createEntry(HeaderTag.CONFLICTVERSION, getArrayOfVersions(conflicts)); - format.getHeader().createEntry(HeaderTag.CONFLICTFLAGS, getArrayOfFlags(conflicts)); + format.getHeader().createEntry(HeaderTag.CONFLICTNAME, getStringList(conflicts)); + format.getHeader().createEntry(HeaderTag.CONFLICTVERSION, getVersions(conflicts)); + format.getHeader().createEntry(HeaderTag.CONFLICTFLAGS, getFlags(conflicts)); } if (provides.size() > 0) { - format.getHeader().createEntry(HeaderTag.PROVIDENAME, getArrayOfNames(provides)); - format.getHeader().createEntry(HeaderTag.PROVIDEVERSION, getArrayOfVersions(provides)); - format.getHeader().createEntry(HeaderTag.PROVIDEFLAGS, getArrayOfFlags(provides)); + format.getHeader().createEntry(HeaderTag.PROVIDENAME, getStringList(provides)); + format.getHeader().createEntry(HeaderTag.PROVIDEVERSION, getVersions(provides)); + format.getHeader().createEntry(HeaderTag.PROVIDEFLAGS, getFlags(provides)); } format.getHeader().createEntry(HeaderTag.SIZE, contents.getTotalSize()); if (contents.size() > 0) { @@ -1538,17 +1165,17 @@ public class RpmBuilder { } if (triggerCounter > 0) { format.getHeader().createEntry(HeaderTag.TRIGGERSCRIPTS, - triggerscripts.toArray(new String[triggerscripts.size()])); + triggerscripts.toArray(new String[0])); format.getHeader().createEntry(HeaderTag.TRIGGERNAME, - triggernames.toArray(new String[triggernames.size()])); + triggernames.toArray(new String[0])); format.getHeader().createEntry(HeaderTag.TRIGGERVERSION, - triggerversions.toArray(new String[triggerversions.size()])); + triggerversions.toArray(new String[0])); format.getHeader().createEntry(HeaderTag.TRIGGERFLAGS, - triggerflags.toArray(new Integer[triggerflags.size()])); + triggerflags.toArray(new Integer[0])); format.getHeader().createEntry(HeaderTag.TRIGGERINDEX, - triggerindexes.toArray(new Integer[triggerindexes.size()])); + triggerindexes.toArray(new Integer[0])); format.getHeader().createEntry(HeaderTag.TRIGGERSCRIPTPROG, - triggerscriptprogs.toArray(new String[triggerscriptprogs.size()])); + triggerscriptprogs.toArray(new String[0])); } if (contents.size() > 0) { format.getHeader().createEntry(HeaderTag.FILEDIGESTALGOS, HashAlgo.MD5.num()); @@ -1568,16 +1195,15 @@ public class RpmBuilder { format.getHeader().createEntry(HeaderTag.FILECONTEXTS, contents.getContexts()); } format.getHeader().createEntry(HeaderTag.PAYLOADFLAGS, "9"); - SpecEntry sigsize = - (SpecEntry) format.getSignatureHeader().addEntry(SignatureTag.LEGACY_SIGSIZE, 1); - SpecEntry signaturHeaderPayloadEntry = - (SpecEntry) format.getSignatureHeader().addEntry(SignatureTag.PAYLOADSIZE, 1); + SpecEntry sigsize = + (SpecEntry) format.getSignatureHeader().addEntry(SignatureTag.LEGACY_SIGSIZE, 1); + SpecEntry signaturHeaderPayloadEntry = + (SpecEntry) format.getSignatureHeader().addEntry(SignatureTag.PAYLOADSIZE, 1); SpecEntry md5Entry = (SpecEntry) format.getSignatureHeader().addEntry(SignatureTag.LEGACY_MD5, 16); - SpecEntry shaEntry = - (SpecEntry) format.getSignatureHeader().addEntry(SignatureTag.SHA1HEADER, 1); + SpecEntry shaEntry = + (SpecEntry) format.getSignatureHeader().addEntry(SignatureTag.SHA1HEADER, 1); shaEntry.setSize(SHASIZE); - SignatureGenerator signatureGenerator = new SignatureGenerator(privateKeyRing, privateKeyId, privateKeyPassphrase); signatureGenerator.prepare(format.getSignatureHeader(), privateKeyHashAlgo); format.getLead().write(channel); @@ -1585,7 +1211,6 @@ public class RpmBuilder { (SpecEntry) format.getSignatureHeader().addEntry(SignatureTag.SIGNATURES, 16); signatureEntry.setValues(createHeaderIndex(HeaderTag.SIGNATURES.getCode(), format.getSignatureHeader().count())); ChannelWrapper.empty(output, ByteBuffer.allocate(format.getSignatureHeader().write(channel))); - ChannelWrapper.Key sigsizekey = output.start(); ChannelWrapper.Key shakey = signatureGenerator.startDigest(output, "SHA"); ChannelWrapper.Key md5key = signatureGenerator.startDigest(output, "MD5"); @@ -1597,7 +1222,7 @@ public class RpmBuilder { (SpecEntry) format.getHeader().addEntry(HeaderTag.HEADERIMMUTABLE, 16); immutable.setValues(createHeaderIndex(HeaderTag.IMMUTABLE.getCode(), format.getHeader().count())); format.getHeader().write(output); - shaEntry.setValues(new String[]{hex(output.finish(shakey))}); + shaEntry.setValues(StringList.of(hex(output.finish(shakey)))); signatureGenerator.finishAfterHeader(output); OutputStream compressedOutputStream = createCompressedStream(Channels.newOutputStream(output)); WritableChannelWrapper compressedOutput = @@ -1617,24 +1242,32 @@ public class RpmBuilder { Object object = contents.getSource(header); if (object instanceof Path) { try (ReadableByteChannel readableByteChannel = Files.newByteChannel((Path) object)) { - while (readableByteChannel.read((ByteBuffer) buffer.rewind()) > 0) { - total += compressedOutput.write((ByteBuffer) buffer.flip()); + while (readableByteChannel.read(buffer.rewind()) > 0) { + total += compressedOutput.write(buffer.flip()); + buffer.compact(); + } + total += header.skip(compressedOutput, total); + } + } else if (object instanceof InputStream) { + try (ReadableByteChannel in = Channels.newChannel(((InputStream) object))) { + while (in.read(buffer.rewind()) > 0) { + total += compressedOutput.write(buffer.flip()); buffer.compact(); } total += header.skip(compressedOutput, total); } } else if (object instanceof URL) { try (ReadableByteChannel in = Channels.newChannel(((URL) object).openConnection().getInputStream())) { - while (in.read((ByteBuffer) buffer.rewind()) > 0) { - total += compressedOutput.write((ByteBuffer) buffer.flip()); + while (in.read(buffer.rewind()) > 0) { + total += compressedOutput.write(buffer.flip()); buffer.compact(); } total += header.skip(compressedOutput, total); } - } else if (object instanceof CharSequence) { - CharSequence target = (CharSequence) object; - total += compressedOutput.write(ByteBuffer.wrap(String.valueOf(target).getBytes(StandardCharsets.UTF_8))); - total += header.skip(compressedOutput, target.length()); + } else if (object != null) { + String string = object.toString(); + total += compressedOutput.write(ByteBuffer.wrap(string.getBytes(StandardCharsets.UTF_8))); + total += header.skip(compressedOutput, string.length()); } } CpioHeader trailer = new CpioHeader(); @@ -1645,11 +1278,11 @@ public class RpmBuilder { int pad = difference(length, 3); ChannelWrapper.empty(compressedOutput, ByteBuffer.allocate(pad)); length += pad; - signaturHeaderPayloadEntry.setValues(new Integer[]{length}); + signaturHeaderPayloadEntry.setValues(IntegerList.of(length)); // flush compressed stream here compressedOutputStream.flush(); md5Entry.setValues(output.finish(md5key)); - sigsize.setValues(new Integer[]{output.finish(sigsizekey)}); + sigsize.setValues(IntegerList.of(output.finish(sigsizekey))); signatureGenerator.finishAfterPayload(output); format.getSignatureHeader().writePending(channel); } @@ -1688,7 +1321,6 @@ public class RpmBuilder { return outputStream; } - /** * Return the content of the specified script file as a String. * @@ -1728,40 +1360,100 @@ public class RpmBuilder { /** + * Returns an list of String with the name of every dependency from a list of dependencies. * + * @param dependencyList List of dependencies + * @return list of strings with all names of the dependencies */ - static class Dependency { - - private String name; - - private String version; - - private Integer flags; - - /** - * Creates a new dependency. - * - * @param name Name (e.g. "httpd") - * @param version Version (e.g. "1.0") - * @param flags Flags (e.g. "GREATER | Flags.EQUAL") - */ - Dependency(String name, String version, Integer flags) { - this.name = name; - this.version = version; - this.flags = flags; - } - - public String getName() { - return name; - } - - public String getVersion() { - return version; - } - - public Integer getFlags() { - return flags; + private static StringList getStringList(List dependencyList) { + StringList list = new StringList(); + for (Dependency dependency : dependencyList) { + list.add(dependency.getPackageName()); } + return list; } + /** + * Returns an list of String with the version of every dependency from a list of dependencies. + * + * @param dependencyList List of dependencies + * @return list of strings with all versions of the dependencies + */ + private static StringList getVersions(List dependencyList) { + StringList versionList = new StringList(); + for (Dependency dependency : dependencyList) { + versionList.add(dependency.getVersion()); + } + return versionList; + } + + /** + * Returns an list of Integer with the flags of every dependency from a list of dependencies. + * + * @param dependencyList List of dependencies + * @return IntegerList with all flags of the dependencies + */ + private static IntegerList getFlags(List dependencyList) { + IntegerList flagsList = new IntegerList(); + for (Dependency dependency : dependencyList) { + flagsList.add(dependency.getFlags()); + } + return flagsList; + } + + /** + * Returns an list of String with the name of every dependency from a list of dependencies. + * + * @param dependencies List of dependencies + * @return list of strings with all names of the dependencies + */ + private static StringList getStringList(Map dependencies) { + StringList nameList = new StringList(); + for (Dependency dependency : dependencies.values()) { + nameList.add(dependency.getPackageName()); + } + return nameList; + } + + /** + * Returns an list of String with the version of every dependency from a list of dependencies. + * + * @param dependencies List of dependencies + * @return list of strings with all versions of the dependencies + */ + private static StringList getVersions(Map dependencies) { + StringList versionList = new StringList(); + for (Dependency dependency : dependencies.values()) { + versionList.add(dependency.getVersion()); + } + return versionList; + } + + /** + * Returns an list of Integer with the flags of every dependency from a list of dependencies. + * + * @param dependencies List of dependencies + * @return IntegerList with all flags of the dependencies + */ + private static IntegerList getFlags(Map dependencies) { + IntegerList flagsList = new IntegerList(); + for (Dependency dependency : dependencies.values()) { + flagsList.add(dependency.getFlags()); + } + return flagsList; + } + + private static int difference(int start, int boundary) { + return ((boundary + 1) - (start & boundary)) & boundary; + } + + private static String hex(byte[] bytes) { + StringBuilder sb = new StringBuilder(); + for (byte aByte : bytes) { + sb.append(hex.charAt(((int) aByte & 0xf0) >> 4)).append(hex.charAt((int) aByte & 0x0f)); + } + return sb.toString(); + } + + } diff --git a/rpm-core/src/main/java/org/xbib/rpm/RpmReader.java b/rpm-core/src/main/java/org/xbib/rpm/RpmReader.java index 392914c..57b095e 100644 --- a/rpm-core/src/main/java/org/xbib/rpm/RpmReader.java +++ b/rpm-core/src/main/java/org/xbib/rpm/RpmReader.java @@ -5,6 +5,7 @@ import org.xbib.io.compress.xz.XZInputStream; import org.xbib.rpm.format.Format; import org.xbib.rpm.header.Header; import org.xbib.rpm.header.HeaderTag; +import org.xbib.rpm.header.StringList; import org.xbib.rpm.header.entry.SpecEntry; import org.xbib.rpm.io.ChannelWrapper; import org.xbib.rpm.io.ReadableChannelWrapper; @@ -18,11 +19,13 @@ import java.nio.ByteBuffer; import java.nio.channels.Channels; import java.nio.file.Files; import java.nio.file.Path; +import java.util.ArrayList; +import java.util.List; import java.util.zip.GZIPInputStream; /** * The RPM reader reads an archive and outputs useful information about its contents. The reader will - * output the headers of the RPM format itself, aswell as the individual headers for the particular + * output the headers of the RPM format itself, as well as the individual headers for the particular * packaged content. * In addition, the reader will read through the payload and output information about each file * contained in the embedded CPIO payload. @@ -32,17 +35,17 @@ public class RpmReader { public RpmReader() { } - public Format read(Path path) throws IOException { - return read(Files.newInputStream((path))); + public Format readFormat(Path path) throws IOException { + return readFormat(Files.newInputStream((path))); } - public Format read(InputStream inputStream) throws IOException { + public Format readFormat(InputStream inputStream) throws IOException { try (InputStream thisInputStream = inputStream) { - return read(new ReadableChannelWrapper(Channels.newChannel(thisInputStream)), thisInputStream); + return readFormat(new ReadableChannelWrapper(Channels.newChannel(thisInputStream)), thisInputStream); } } - public Format read(ReadableChannelWrapper readableChannelWrapper, InputStream inputStream) throws IOException { + public Format readFormat(ReadableChannelWrapper readableChannelWrapper, InputStream inputStream) throws IOException { Format format = readHeader(readableChannelWrapper); Header rpmHeader = format.getHeader(); try (InputStream uncompressed = createUncompressedStream(rpmHeader, inputStream)) { @@ -62,6 +65,54 @@ public class RpmReader { return format; } + public RpmReaderResult read(Path path) throws IOException { + return read(Files.newInputStream((path))); + } + + public RpmReaderResult read(InputStream inputStream) throws IOException { + try (InputStream thisInputStream = inputStream) { + return read(new ReadableChannelWrapper(Channels.newChannel(thisInputStream)), thisInputStream); + } + } + + public RpmReaderResult read(ReadableChannelWrapper wrapper, InputStream inputStream) throws IOException { + final Format format = readHeader(wrapper); + final List list = new ArrayList<>(); + try (InputStream uncompressed = createUncompressedStream(format.getHeader(), inputStream)) { + wrapper = new ReadableChannelWrapper(Channels.newChannel(uncompressed)); + CpioHeader header; + int total = 0; + do { + header = new CpioHeader(); + total = header.read(wrapper, total); + int fileSize = header.getFileSize(); + boolean includingContents = header.getType() == CpioHeader.FILE; + if (!header.isLast()) { + ByteBuffer byteBuffer = includingContents ? ChannelWrapper.fill(wrapper, fileSize) : null; + list.add(new RpmReaderFile(header, byteBuffer)); + } + if (!includingContents) { + if (uncompressed.skip(fileSize) != fileSize) { + throw new RuntimeException(); + } + } + total += fileSize; + } while (!header.isLast()); + } + + + return new RpmReaderResult() { + @Override + public Format getFormat() { + return format; + } + + @Override + public List getFiles() { + return list; + } + }; + } public Format readHeader(Path path) throws IOException { return readHeader(Files.newInputStream((path))); @@ -114,8 +165,8 @@ public class RpmReader { private static InputStream createUncompressedStream(Header header, InputStream inputStream) throws IOException { InputStream compressedInput = inputStream; SpecEntry pcEntry = header.getEntry(HeaderTag.PAYLOADCOMPRESSOR); - String[] pc = (String[]) pcEntry.getValues(); - CompressionType compressionType = CompressionType.valueOf(pc[0].toUpperCase()); + StringList pc = (StringList) pcEntry.getValues(); + CompressionType compressionType = CompressionType.valueOf(pc.get(0).toUpperCase()); switch (compressionType) { case NONE: break; diff --git a/rpm-core/src/main/java/org/xbib/rpm/RpmReaderFile.java b/rpm-core/src/main/java/org/xbib/rpm/RpmReaderFile.java new file mode 100644 index 0000000..3fb0185 --- /dev/null +++ b/rpm-core/src/main/java/org/xbib/rpm/RpmReaderFile.java @@ -0,0 +1,32 @@ +package org.xbib.rpm; + +import org.xbib.rpm.payload.CpioHeader; +import java.nio.ByteBuffer; + +public class RpmReaderFile { + + private final CpioHeader header; + + private final ByteBuffer contents; + + public RpmReaderFile(CpioHeader header, ByteBuffer contents) { + this.header = header; + this.contents = contents; + } + + public CpioHeader getHeader() { + return header; + } + + public String getName() { + return header.getName(); + } + + public int getType() { + return header.getType(); + } + + public ByteBuffer getContents() { + return contents; + } +} diff --git a/rpm-core/src/main/java/org/xbib/rpm/RpmReaderResult.java b/rpm-core/src/main/java/org/xbib/rpm/RpmReaderResult.java new file mode 100644 index 0000000..c80f803 --- /dev/null +++ b/rpm-core/src/main/java/org/xbib/rpm/RpmReaderResult.java @@ -0,0 +1,11 @@ +package org.xbib.rpm; + +import org.xbib.rpm.format.Format; +import java.util.List; + +public interface RpmReaderResult { + + Format getFormat(); + + List getFiles(); +} diff --git a/rpm-core/src/main/java/org/xbib/rpm/changelog/ChangelogHandler.java b/rpm-core/src/main/java/org/xbib/rpm/changelog/ChangelogHandler.java index 15c70ca..c4f4722 100644 --- a/rpm-core/src/main/java/org/xbib/rpm/changelog/ChangelogHandler.java +++ b/rpm-core/src/main/java/org/xbib/rpm/changelog/ChangelogHandler.java @@ -3,10 +3,12 @@ package org.xbib.rpm.changelog; import org.xbib.rpm.exception.ChangelogParseException; import org.xbib.rpm.header.Header; import org.xbib.rpm.header.HeaderTag; +import org.xbib.rpm.header.IntegerList; +import org.xbib.rpm.header.StringList; import java.io.IOException; -import java.io.InputStream; -import java.net.URL; +import java.io.Reader; +import java.io.StringReader; import java.nio.file.Files; import java.nio.file.Path; import java.util.List; @@ -15,6 +17,7 @@ import java.util.List; * This class manages the process of adding a Changelog to the header. */ public class ChangelogHandler { + private final Header header; public ChangelogHandler(Header header) { @@ -22,48 +25,45 @@ public class ChangelogHandler { } /** - * Adds the specified file to the archive. + * Adds the specified changelog file to the archive. * * @param changelogFile the Changelog file to be added * @throws IOException if the specified file cannot be read * @throws ChangelogParseException if the file violates the requirements of a Changelog */ public void addChangeLog(Path changelogFile) throws IOException, ChangelogParseException { - addChangeLog(Files.newInputStream(changelogFile)); + addChangeLog(Files.newBufferedReader(changelogFile)); } /** - * Adds the specified file to the archive. + * Adds the specified changelog contents to the archive. * - * @param changelogFile the Changelog URL to be added + * @param string the changelog contents to be added * @throws IOException if the specified file cannot be read * @throws ChangelogParseException if the file violates the requirements of a Changelog - */ - public void addChangeLog(URL changelogFile) throws IOException, ChangelogParseException { - addChangeLog(changelogFile.openStream()); + */ public void addChangeLog(String string) throws IOException, ChangelogParseException { + addChangeLog(new StringReader(string)); } /** - * Adds the specified file to the archive. + * Adds the specified changelod to the archive. * - * @param changelogStream the changelog stream to be added + * @param reader the changelog reader to be added * @throws IOException if the specified file cannot be read * @throws ChangelogParseException if the file violates the requirements of a Changelog */ - public void addChangeLog(InputStream changelogStream) throws IOException, ChangelogParseException { - try (InputStream changelog = changelogStream) { - ChangelogParser parser = new ChangelogParser(); - List entries = parser.parse(changelog); - for (ChangelogEntry entry : entries) { - addChangeLogEntry(entry); - } + public void addChangeLog(Reader reader) throws IOException, ChangelogParseException { + ChangelogParser parser = new ChangelogParser(); + List entries = parser.parse(reader); + for (ChangelogEntry entry : entries) { + addChangeLogEntry(entry); } } private void addChangeLogEntry(ChangelogEntry entry) { - Long epochSecs = entry.getChangeLogTime().toEpochMilli() / 1000L; - header.addOrAppendEntry(HeaderTag.CHANGELOGTIME, new Integer[]{epochSecs.intValue()}); - header.addOrAppendEntry(HeaderTag.CHANGELOGNAME, new String[]{entry.getUserMakingChange()}); - header.addOrAppendEntry(HeaderTag.CHANGELOGTEXT, new String[]{entry.getDescription()}); + int epochSecs = (int) (entry.getChangeLogTime().toEpochMilli() / 1000L); + header.addOrAppendEntry(HeaderTag.CHANGELOGTIME, IntegerList.of(epochSecs)); + header.addOrAppendEntry(HeaderTag.CHANGELOGNAME, StringList.of(entry.getUserMakingChange())); + header.addOrAppendEntry(HeaderTag.CHANGELOGTEXT, StringList.of(entry.getDescription())); } } diff --git a/rpm-core/src/main/java/org/xbib/rpm/changelog/ChangelogParser.java b/rpm-core/src/main/java/org/xbib/rpm/changelog/ChangelogParser.java index e9420b5..8b98712 100644 --- a/rpm-core/src/main/java/org/xbib/rpm/changelog/ChangelogParser.java +++ b/rpm-core/src/main/java/org/xbib/rpm/changelog/ChangelogParser.java @@ -10,7 +10,8 @@ import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; -import java.nio.charset.StandardCharsets; +import java.io.Reader; +import java.nio.charset.Charset; import java.time.Instant; import java.time.LocalDate; import java.time.LocalTime; @@ -36,10 +37,10 @@ public class ChangelogParser { * @throws DateTimeParseException if date could not be parsed * @throws ChangelogParseException if any of the rules of a Changelog is violated by the input */ - public List parse(String[] lines) throws DateTimeParseException, ChangelogParseException { + public List parse(List lines) throws DateTimeParseException, ChangelogParseException { final int timeLen = 15; List result = new ArrayList<>(); - if (lines.length == 0) { + if (lines.size() == 0) { return result; } ParsingState state = ParsingState.NEW; @@ -48,14 +49,14 @@ public class ChangelogParser { String restOfLine = null; StringBuilder descr = new StringBuilder(); int index = 0; - String line = lines[index]; + String line = lines.get(index); lineloop: while (true) { switch (state) { case NEW: if (line.startsWith("#")) { - if (++index < lines.length) { - line = lines[index]; + if (++index < lines.size()) { + line = lines.get(index); continue; } else { return result; @@ -93,8 +94,8 @@ public class ChangelogParser { break; case TEXT: index++; - if (index < lines.length) { - line = lines[index]; + if (index < lines.size()) { + line = lines.get(index); if (line.startsWith("*")) { if (descr.length() > 1) { entry.setDescription(descr.toString().substring(0, descr.length() - 1)); @@ -127,22 +128,27 @@ public class ChangelogParser { } /** - * @param stream stream read from the Changelog file + * @param stream stream read from the Changelog file + * @param charset the charset of the stream * @return a List of ChangeLogEntry objects * @throws IOException if the input stream cannot be read * @throws ChangelogParseException if any of the rules of a Changelog is * violated by the input */ - public List parse(InputStream stream) throws IOException, ChangelogParseException { + public List parse(InputStream stream, Charset charset) throws IOException, ChangelogParseException { + return parse(new InputStreamReader(stream, charset)); + } + + public List parse(Reader reader) throws IOException, ChangelogParseException { String line; List lines = new ArrayList<>(); - try (BufferedReader reader = new BufferedReader(new InputStreamReader(stream, StandardCharsets.UTF_8))) { - while ((line = reader.readLine()) != null) { + try (BufferedReader bufferedReader = new BufferedReader(reader)) { + while ((line = bufferedReader.readLine()) != null) { if (!line.startsWith("#")) { lines.add(line); } } } - return parse(lines.toArray(new String[0])); + return parse(lines); } } diff --git a/rpm-core/src/main/java/org/xbib/rpm/format/Format.java b/rpm-core/src/main/java/org/xbib/rpm/format/Format.java index c4ac71b..0ac7b04 100644 --- a/rpm-core/src/main/java/org/xbib/rpm/format/Format.java +++ b/rpm-core/src/main/java/org/xbib/rpm/format/Format.java @@ -13,11 +13,11 @@ import java.nio.channels.ReadableByteChannel; */ public class Format { - private Lead lead = new Lead(); + private final Lead lead = new Lead(); - private Header header = new Header(); + private final Header header = new Header(); - private SignatureHeader signatureHeader = new SignatureHeader(); + private final SignatureHeader signatureHeader = new SignatureHeader(); public Lead getLead() { return lead; diff --git a/rpm-core/src/main/java/org/xbib/rpm/header/AbstractHeader.java b/rpm-core/src/main/java/org/xbib/rpm/header/AbstractHeader.java index f9f152d..0760208 100644 --- a/rpm-core/src/main/java/org/xbib/rpm/header/AbstractHeader.java +++ b/rpm-core/src/main/java/org/xbib/rpm/header/AbstractHeader.java @@ -7,11 +7,10 @@ import org.xbib.rpm.header.entry.Int32SpecEntry; import org.xbib.rpm.header.entry.Int64SpecEntry; import org.xbib.rpm.header.entry.Int8SpecEntry; import org.xbib.rpm.header.entry.SpecEntry; -import org.xbib.rpm.header.entry.StringArraySpecEntry; +import org.xbib.rpm.header.entry.StringListSpecEntry; import org.xbib.rpm.header.entry.StringSpecEntry; import org.xbib.rpm.io.ChannelWrapper; import org.xbib.rpm.lead.Lead; - import java.io.IOException; import java.lang.reflect.Array; import java.nio.ByteBuffer; @@ -98,8 +97,8 @@ public abstract class AbstractHeader { data.flip(); int pad = pad() ? ((data.remaining() + 7) & ~7) - data.remaining() : 0; header.putInt(data.remaining()); - ChannelWrapper.empty(out, (ByteBuffer) header.flip()); - ChannelWrapper.empty(out, (ByteBuffer) index.flip()); + ChannelWrapper.empty(out, header.flip()); + ChannelWrapper.empty(out, index.flip()); ChannelWrapper.empty(out, data); return pad; } @@ -122,14 +121,22 @@ public abstract class AbstractHeader { @SuppressWarnings("unchecked") public void createEntry(EntryType entryType, CharSequence value) { - SpecEntry entry = (SpecEntry) makeEntry(entryType, 1); - entry.setValues(new String[]{value.toString()}); + if (value == null) { + throw new IllegalArgumentException("unable to accept null value for entry " + + entryType.getName() + " " + entryType.getType()); + } + SpecEntry entry = (SpecEntry) makeEntry(entryType, 1); + entry.setValues(StringList.of(value.toString())); } @SuppressWarnings("unchecked") public void createEntry(EntryType entryType, Integer value) { - SpecEntry entry = (SpecEntry) makeEntry(entryType, 1); - entry.setValues(new Integer[]{value}); + if (value == null) { + throw new IllegalArgumentException("unable to accept null value for entry " + + entryType.getName() + " " + entryType.getType()); + } + SpecEntry entry = (SpecEntry) makeEntry(entryType, 1); + entry.setValues(IntegerList.of(value)); } public void writePending(SeekableByteChannel channel) { @@ -138,7 +145,7 @@ public abstract class AbstractHeader { ByteBuffer data = ByteBuffer.allocate(entry.getKey().size()); entry.getKey().write(data); channel.position(Lead.LEAD_SIZE + HEADER_SIZE + count() * ENTRY_SIZE + entry.getValue()); - ChannelWrapper.empty(channel, (ByteBuffer) data.flip()); + ChannelWrapper.empty(channel, data.flip()); } catch (Exception e) { throw new RuntimeException("Error writing pending entry '" + entry.getKey().getEntryType() + "'.", e); } @@ -155,9 +162,16 @@ public abstract class AbstractHeader { * @throws ClassCastException - if the type of values is not compatible with the type * required by tag */ - @SuppressWarnings("unchecked") + @SuppressWarnings({"unchecked", "raw"}) public void createEntry(EntryType entryType, T values) { - SpecEntry entry = (SpecEntry) makeEntry(entryType, values.getClass().isArray() ? Array.getLength(values) : 1); + int len = 1; + if (values.getClass().isArray()) { + len = Array.getLength(values); + } + if (Collection.class.isAssignableFrom(values.getClass())) { + len = ((Collection) values).size(); + } + SpecEntry entry = (SpecEntry) makeEntry(entryType, len); if (entryType instanceof HeaderTag) { Class cl = ((HeaderTag) entryType).getTypeClass(); if (cl.isAssignableFrom(values.getClass())) { @@ -181,21 +195,29 @@ public abstract class AbstractHeader { * @throws ClassCastException - if the type of values is not compatible with the * type required by tag */ - @SuppressWarnings({"unchecked"}) + @SuppressWarnings({"unchecked", "raw"}) public void addOrAppendEntry(EntryType entryType, T values) { SpecEntry entry = (SpecEntry) addOrAppendEntry(entryType, values.getClass().isArray() ? Array.getLength(values) : 1); T existingValues = entry.getValues(); if (existingValues == null) { entry.setValues(values); - } else { - int oldSize = java.lang.reflect.Array.getLength(existingValues); + } else if (existingValues instanceof Collection) { + Collection collection = (Collection) existingValues; + if (values instanceof Collection) { + Collection valuesCollection = (Collection) values; + collection.addAll(valuesCollection); + } else { + collection.add(values); + } + entry.setValues((T) collection); + /*int oldSize = java.lang.reflect.Array.getLength(existingValues); int newSize = values.getClass().isArray() ? Array.getLength(values) : 1; Class elementType = existingValues.getClass().getComponentType(); T newValues = (T) Array.newInstance(elementType, oldSize + newSize); System.arraycopy(existingValues, 0, newValues, 0, oldSize); System.arraycopy(values, 0, newValues, oldSize, newSize); - entry.setValues(newValues); + entry.setValues(newValues);*/ } } @@ -236,9 +258,8 @@ public abstract class AbstractHeader { * This method must be invoked before mapping the index or data sections. * * @return a buffer containing the header - * @throws IOException there was an IO error */ - protected ByteBuffer getHeader() throws IOException { + protected ByteBuffer getHeader() { ByteBuffer buffer = ByteBuffer.allocate(HEADER_SIZE); buffer.putInt(MAGIC_WORD); buffer.putInt(0); @@ -266,9 +287,8 @@ public abstract class AbstractHeader { * * @param index ByteBuffer of the index * @return the total number of bytes written to the data section of the file. - * @throws IOException there was an IO error */ - private ByteBuffer getData(final ByteBuffer index) throws IOException { + private ByteBuffer getData(final ByteBuffer index) { int offset = 0; List buffers = new ArrayList<>(); Iterator i = entries.keySet().iterator(); @@ -300,6 +320,9 @@ public abstract class AbstractHeader { } offset += shift; int size = entry.size(); + if (size == 0) { + throw new IllegalStateException("entry size is 0"); + } ByteBuffer buffer = ByteBuffer.allocate(size); entry.index(index, offset); if (entry.ready()) { @@ -358,8 +381,8 @@ public abstract class AbstractHeader { return new StringSpecEntry(); case EntryType.BIN_ENTRY: return new BinSpecEntry(); - case EntryType.STRING_ARRAY_ENTRY: - return new StringArraySpecEntry(); + case EntryType.STRING_LIST_ENTRY: + return new StringListSpecEntry(); case EntryType.I18NSTRING_ENTRY: return new I18NStringSpecEntry(); default: diff --git a/rpm-core/src/main/java/org/xbib/rpm/header/EntryType.java b/rpm-core/src/main/java/org/xbib/rpm/header/EntryType.java index c8662d1..48ac9e7 100644 --- a/rpm-core/src/main/java/org/xbib/rpm/header/EntryType.java +++ b/rpm-core/src/main/java/org/xbib/rpm/header/EntryType.java @@ -17,7 +17,7 @@ public interface EntryType { int BIN_ENTRY = 7; - int STRING_ARRAY_ENTRY = 8; + int STRING_LIST_ENTRY = 8; int I18NSTRING_ENTRY = 9; diff --git a/rpm-core/src/main/java/org/xbib/rpm/header/HeaderTag.java b/rpm-core/src/main/java/org/xbib/rpm/header/HeaderTag.java index c77bf56..0e21fb5 100644 --- a/rpm-core/src/main/java/org/xbib/rpm/header/HeaderTag.java +++ b/rpm-core/src/main/java/org/xbib/rpm/header/HeaderTag.java @@ -8,28 +8,28 @@ public enum HeaderTag implements EntryType { NAME(1000, STRING_ENTRY, String.class, "name"), VERSION(1001, STRING_ENTRY, String.class, "version"), RELEASE(1002, STRING_ENTRY, String.class, "release"), - EPOCH(1003, INT32_ENTRY, Integer[].class, "epoch"), + EPOCH(1003, INT32_ENTRY, StringList.class, "epoch"), SUMMARY(1004, I18NSTRING_ENTRY, String.class, "summary"), DESCRIPTION(1005, I18NSTRING_ENTRY, String.class, "description"), - BUILDTIME(1006, INT32_ENTRY, Integer[].class, "buildtime"), + BUILDTIME(1006, INT32_ENTRY, IntegerList.class, "buildtime"), BUILDHOST(1007, STRING_ENTRY, String.class, "buildhost"), - SIZE(1009, INT32_ENTRY, Integer[].class, "size"), + SIZE(1009, INT32_ENTRY, IntegerList.class, "size"), DISTRIBUTION(1010, STRING_ENTRY, String.class, "distribution"), VENDOR(1011, STRING_ENTRY, String.class, "vendor"), LICENSE(1014, STRING_ENTRY, String.class, "license"), PACKAGER(1015, STRING_ENTRY, String.class, "packager"), GROUP(1016, I18NSTRING_ENTRY, String.class, "group"), - CHANGELOG(1017, STRING_ARRAY_ENTRY, String[].class, "changelog"), + CHANGELOG(1017, STRING_LIST_ENTRY, StringList.class, "changelog"), URL(1020, STRING_ENTRY, String.class, "url"), OS(1021, STRING_ENTRY, String.class, "os"), ARCH(1022, STRING_ENTRY, String.class, "arch"), SOURCERPM(1044, STRING_ENTRY, String.class, "sourcerpm"), - FILEVERIFYFLAGS(1045, INT32_ENTRY, Integer[].class, "fileverifyflags"), - ARCHIVESIZE(1046, INT32_ENTRY, Integer[].class, "archivesize"), + FILEVERIFYFLAGS(1045, INT32_ENTRY, IntegerList.class, "fileverifyflags"), + ARCHIVESIZE(1046, INT32_ENTRY, IntegerList.class, "archivesize"), RPMVERSION(1064, STRING_ENTRY, String.class, "rpmversion"), - CHANGELOGTIME(1080, INT32_ENTRY, Integer[].class, "changelogtime"), - CHANGELOGNAME(1081, STRING_ARRAY_ENTRY, String[].class, "changelogname"), - CHANGELOGTEXT(1082, STRING_ARRAY_ENTRY, String[].class, "changelogtext"), + CHANGELOGTIME(1080, INT32_ENTRY, IntegerList.class, "changelogtime"), + CHANGELOGNAME(1081, STRING_LIST_ENTRY, StringList.class, "changelogname"), + CHANGELOGTEXT(1082, STRING_LIST_ENTRY, StringList.class, "changelogtext"), COOKIE(1094, STRING_ENTRY, String.class, "cookie"), OPTFLAGS(1122, STRING_ENTRY, String.class, "optflags"), PAYLOADFORMAT(1124, STRING_ENTRY, String.class, "payloadformat"), @@ -37,18 +37,16 @@ public enum HeaderTag implements EntryType { PAYLOADFLAGS(1126, STRING_ENTRY, String.class, "payloadflags"), RHNPLATFORM(1131, STRING_ENTRY, String.class, "rhnplatform"), PLATFORM(1132, STRING_ENTRY, String.class, "platform"), - FILECOLORS(1140, INT32_ENTRY, Integer[].class, "filecolors"), - FILECLASS(1141, INT32_ENTRY, Integer[].class, "fileclass"), - CLASSDICT(1142, STRING_ARRAY_ENTRY, String[].class, "classdict"), - FILEDEPENDSX(1143, INT32_ENTRY, Integer[].class, "filedependsx"), - FILEDEPENDSN(1144, INT32_ENTRY, Integer[].class, "filedependsn"), - DEPENDSDICT(1145, INT32_ENTRY, Integer[].class, "dependsdict"), + FILECOLORS(1140, INT32_ENTRY, IntegerList.class, "filecolors"), + FILECLASS(1141, INT32_ENTRY, IntegerList.class, "fileclass"), + CLASSDICT(1142, STRING_LIST_ENTRY, StringList.class, "classdict"), + FILEDEPENDSX(1143, INT32_ENTRY, IntegerList.class, "filedependsx"), + FILEDEPENDSN(1144, INT32_ENTRY, IntegerList.class, "filedependsn"), + DEPENDSDICT(1145, INT32_ENTRY, IntegerList.class, "dependsdict"), SOURCEPKGID(1146, BIN_ENTRY, Object.class, "sourcepkgid"), - FILECONTEXTS(1147, STRING_ARRAY_ENTRY, String[].class, "filecontexts"), - + FILECONTEXTS(1147, STRING_LIST_ENTRY, StringList.class, "filecontexts"), HEADERIMMUTABLE(63, BIN_ENTRY, Object.class, "headerimmutable"), - HEADERI18NTABLE(100, STRING_ARRAY_ENTRY, String[].class, "headeri18ntable"), - + HEADERI18NTABLE(100, STRING_LIST_ENTRY, StringList.class, "headeri18ntable"), PREINSCRIPT(1023, STRING_ENTRY, String.class, "prein"), POSTINSCRIPT(1024, STRING_ENTRY, String.class, "postin"), PREUNSCRIPT(1025, STRING_ENTRY, String.class, "preun"), @@ -57,64 +55,56 @@ public enum HeaderTag implements EntryType { POSTINPROG(1086, STRING_ENTRY, String.class, "postinprog"), PREUNPROG(1087, STRING_ENTRY, String.class, "preunprog"), POSTUNPROG(1088, STRING_ENTRY, String.class, "postunprog"), - PRETRANSSCRIPT(1151, STRING_ENTRY, String.class, "pretrans"), POSTTRANSSCRIPT(1152, STRING_ENTRY, String.class, "posttrans"), PRETRANSPROG(1153, STRING_ENTRY, String.class, "pretransprog"), POSTTRANSPROG(1154, STRING_ENTRY, String.class, "pretransprog"), + TRIGGERSCRIPTS(1065, STRING_LIST_ENTRY, StringList.class, "triggerscripts"), + TRIGGERNAME(1066, STRING_LIST_ENTRY, StringList.class, "triggername"), + TRIGGERVERSION(1067, STRING_LIST_ENTRY, StringList.class, "triggerversion"), + TRIGGERFLAGS(1068, INT32_ENTRY, IntegerList.class, "triggerflags"), + TRIGGERINDEX(1069, INT32_ENTRY, IntegerList.class, "triggerindex"), + TRIGGERSCRIPTPROG(1092, STRING_LIST_ENTRY, StringList.class, "triggerscriptprog"), + OLDFILENAMES(1027, STRING_LIST_ENTRY, StringList.class, "oldfilenames"), + FILESIZES(1028, INT32_ENTRY, IntegerList.class, "filesizes"), + FILEMODES(1030, INT16_ENTRY, ShortList.class, "filemodes"), + FILERDEVS(1033, INT16_ENTRY, ShortList.class, "filerdevs"), + FILEMTIMES(1034, INT32_ENTRY, IntegerList.class, "filemtimes"), + FILEDIGESTS(1035, STRING_LIST_ENTRY, StringList.class, "filedigests"), + FILELINKTOS(1036, STRING_LIST_ENTRY, StringList.class, "filelinktos"), + FILEFLAGS(1037, INT32_ENTRY, IntegerList.class, "fileflags"), + FILEGROUPNAME(1040, STRING_LIST_ENTRY, StringList.class, "filegroupname"), + FILEUSERNAME(1039, STRING_LIST_ENTRY, StringList.class, "fileusername"), + FILEDEVICES(1095, INT32_ENTRY, IntegerList.class, "filedevices"), + FILEINODES(1096, INT32_ENTRY, IntegerList.class, "fileinodes"), + FILELANGS(1097, STRING_LIST_ENTRY, StringList.class, "filelangs"), + PREFIXES(1098, STRING_LIST_ENTRY, StringList.class, "prefixes"), + DIRINDEXES(1116, INT32_ENTRY, IntegerList.class, "dirindexes"), + BASENAMES(1117, STRING_LIST_ENTRY, StringList.class, "basenames"), + DIRNAMES(1118, STRING_LIST_ENTRY, StringList.class, "dirnames"), + PROVIDENAME(1047, STRING_LIST_ENTRY, StringList.class, "providename"), + REQUIREFLAGS(1048, INT32_ENTRY, IntegerList.class, "requireflags"), + REQUIRENAME(1049, STRING_LIST_ENTRY, StringList.class, "requirename"), + REQUIREVERSION(1050, STRING_LIST_ENTRY, StringList.class, "requireversion"), + CONFLICTFLAGS(1053, INT32_ENTRY, IntegerList.class, "conflictflags"), + CONFLICTNAME(1054, STRING_LIST_ENTRY, StringList.class, "conflictname"), + CONFLICTVERSION(1055, STRING_LIST_ENTRY, StringList.class, "conflictversion"), + OBSOLETENAME(1090, STRING_LIST_ENTRY, StringList.class, "obsoletename"), + PROVIDEFLAGS(1112, INT32_ENTRY, IntegerList.class, "provideflags"), + PROVIDEVERSION(1113, STRING_LIST_ENTRY, StringList.class, "provideversion"), + OBSOLETEFLAGS(1114, INT32_ENTRY, IntegerList.class, "obsoleteflags"), + OBSOLETEVERSION(1115, STRING_LIST_ENTRY, StringList.class, "obsoleteversion"), + FILEDIGESTALGOS(1177, INT32_ENTRY, IntegerList.class, "filedigestalgos"), + SIGNATURES(0x0000003e, INT32_ENTRY, IntegerList.class, "_signatures"), + IMMUTABLE(0x0000003f, INT32_ENTRY, IntegerList.class, "_immutable"); - TRIGGERSCRIPTS(1065, STRING_ARRAY_ENTRY, String[].class, "triggerscripts"), - TRIGGERNAME(1066, STRING_ARRAY_ENTRY, String[].class, "triggername"), - TRIGGERVERSION(1067, STRING_ARRAY_ENTRY, String[].class, "triggerversion"), - TRIGGERFLAGS(1068, INT32_ENTRY, Integer[].class, "triggerflags"), - TRIGGERINDEX(1069, INT32_ENTRY, Integer[].class, "triggerindex"), - TRIGGERSCRIPTPROG(1092, STRING_ARRAY_ENTRY, String[].class, "triggerscriptprog"), + private final int code; - OLDFILENAMES(1027, STRING_ARRAY_ENTRY, String[].class, "oldfilenames"), - FILESIZES(1028, INT32_ENTRY, Integer[].class, "filesizes"), - FILEMODES(1030, INT16_ENTRY, short[].class, "filemodes"), - FILERDEVS(1033, INT16_ENTRY, short[].class, "filerdevs"), - FILEMTIMES(1034, INT32_ENTRY, Integer[].class, "filemtimes"), - FILEDIGESTS(1035, STRING_ARRAY_ENTRY, String[].class, "filedigests"), - FILELINKTOS(1036, STRING_ARRAY_ENTRY, String[].class, "filelinktos"), - FILEFLAGS(1037, INT32_ENTRY, Integer[].class, "fileflags"), - FILEUSERNAME(1039, STRING_ARRAY_ENTRY, String[].class, "fileusername"), - FILEGROUPNAME(1040, STRING_ARRAY_ENTRY, String[].class, "filegroupname"), - FILEDEVICES(1095, INT32_ENTRY, Integer[].class, "filedevices"), - FILEINODES(1096, INT32_ENTRY, Integer[].class, "fileinodes"), - FILELANGS(1097, STRING_ARRAY_ENTRY, String[].class, "filelangs"), - PREFIXES(1098, STRING_ARRAY_ENTRY, String[].class, "prefixes"), - DIRINDEXES(1116, INT32_ENTRY, Integer[].class, "dirindexes"), - BASENAMES(1117, STRING_ARRAY_ENTRY, String[].class, "basenames"), - DIRNAMES(1118, STRING_ARRAY_ENTRY, String[].class, "dirnames"), + private final int type; - PROVIDENAME(1047, STRING_ARRAY_ENTRY, String[].class, "providename"), - REQUIREFLAGS(1048, INT32_ENTRY, Integer[].class, "requireflags"), - REQUIRENAME(1049, STRING_ARRAY_ENTRY, String[].class, "requirename"), - REQUIREVERSION(1050, STRING_ARRAY_ENTRY, String[].class, "requireversion"), - CONFLICTFLAGS(1053, INT32_ENTRY, Integer[].class, "conflictflags"), - CONFLICTNAME(1054, STRING_ARRAY_ENTRY, String[].class, "conflictname"), - CONFLICTVERSION(1055, STRING_ARRAY_ENTRY, String[].class, "conflictversion"), - OBSOLETENAME(1090, STRING_ARRAY_ENTRY, String[].class, "obsoletename"), - PROVIDEFLAGS(1112, INT32_ENTRY, Integer[].class, "provideflags"), - PROVIDEVERSION(1113, STRING_ARRAY_ENTRY, String[].class, "provideversion"), - OBSOLETEFLAGS(1114, INT32_ENTRY, Integer[].class, "obsoleteflags"), - OBSOLETEVERSION(1115, STRING_ARRAY_ENTRY, String[].class, "obsoleteversion"), + private final Class typeClass; - FILEDIGESTALGOS(1177, INT32_ENTRY, Integer[].class, "filedigestalgos"), - - /* private header tags */ - - SIGNATURES(0x0000003e, INT32_ENTRY, Integer[].class, "_signatures"), - IMMUTABLE(0x0000003f, INT32_ENTRY, Integer[].class, "_immutable"); - - private int code; - - private int type; - - private Class typeClass; - - private String name; + private final String name; HeaderTag(int code, int type, Class typeClass, String name) { this.code = code; diff --git a/rpm-core/src/main/java/org/xbib/rpm/header/IntegerList.java b/rpm-core/src/main/java/org/xbib/rpm/header/IntegerList.java new file mode 100644 index 0000000..6a9096c --- /dev/null +++ b/rpm-core/src/main/java/org/xbib/rpm/header/IntegerList.java @@ -0,0 +1,14 @@ +package org.xbib.rpm.header; + +import java.util.ArrayList; +import java.util.Arrays; + +@SuppressWarnings("serial") +public class IntegerList extends ArrayList { + + public static IntegerList of(Integer... integers) { + IntegerList list = new IntegerList(); + list.addAll(Arrays.asList(integers)); + return list; + } +} diff --git a/rpm-core/src/main/java/org/xbib/rpm/header/LongList.java b/rpm-core/src/main/java/org/xbib/rpm/header/LongList.java new file mode 100644 index 0000000..c1bec1d --- /dev/null +++ b/rpm-core/src/main/java/org/xbib/rpm/header/LongList.java @@ -0,0 +1,14 @@ +package org.xbib.rpm.header; + +import java.util.ArrayList; +import java.util.Arrays; + +@SuppressWarnings("serial") +public class LongList extends ArrayList { + + public static LongList of(Long... values) { + LongList list = new LongList(); + list.addAll(Arrays.asList(values)); + return list; + } +} diff --git a/rpm-core/src/main/java/org/xbib/rpm/header/ShortList.java b/rpm-core/src/main/java/org/xbib/rpm/header/ShortList.java new file mode 100644 index 0000000..ede4d50 --- /dev/null +++ b/rpm-core/src/main/java/org/xbib/rpm/header/ShortList.java @@ -0,0 +1,14 @@ +package org.xbib.rpm.header; + +import java.util.ArrayList; +import java.util.Arrays; + +@SuppressWarnings("serial") +public class ShortList extends ArrayList { + + public static ShortList of(Short... values) { + ShortList list = new ShortList(); + list.addAll(Arrays.asList(values)); + return list; + } +} diff --git a/rpm-core/src/main/java/org/xbib/rpm/header/StringList.java b/rpm-core/src/main/java/org/xbib/rpm/header/StringList.java new file mode 100644 index 0000000..45da719 --- /dev/null +++ b/rpm-core/src/main/java/org/xbib/rpm/header/StringList.java @@ -0,0 +1,23 @@ +package org.xbib.rpm.header; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; + +@SuppressWarnings("serial") +public class StringList extends ArrayList { + + public StringList() { + super(); + } + + public StringList(Collection collection) { + super(collection); + } + + public static StringList of(String... values) { + StringList list = new StringList(); + list.addAll(Arrays.asList(values)); + return list; + } +} diff --git a/rpm-core/src/main/java/org/xbib/rpm/header/entry/AbstractSpecEntry.java b/rpm-core/src/main/java/org/xbib/rpm/header/entry/AbstractSpecEntry.java index 3e72bea..3952334 100644 --- a/rpm-core/src/main/java/org/xbib/rpm/header/entry/AbstractSpecEntry.java +++ b/rpm-core/src/main/java/org/xbib/rpm/header/entry/AbstractSpecEntry.java @@ -62,9 +62,6 @@ public abstract class AbstractSpecEntry implements SpecEntry { public abstract int getType(); - public void typeCheck() { - } - /** * Returns the size this entry will need in the provided data buffer to write * it's contents, corrected for any trailing zeros to fill to a boundary. diff --git a/rpm-core/src/main/java/org/xbib/rpm/header/entry/Int16SpecEntry.java b/rpm-core/src/main/java/org/xbib/rpm/header/entry/Int16SpecEntry.java index a3b9293..d05486f 100644 --- a/rpm-core/src/main/java/org/xbib/rpm/header/entry/Int16SpecEntry.java +++ b/rpm-core/src/main/java/org/xbib/rpm/header/entry/Int16SpecEntry.java @@ -1,13 +1,14 @@ package org.xbib.rpm.header.entry; import org.xbib.rpm.header.EntryType; +import org.xbib.rpm.header.ShortList; import java.nio.ByteBuffer; /** * */ -public class Int16SpecEntry extends AbstractSpecEntry { +public class Int16SpecEntry extends AbstractSpecEntry { @Override public int getOffset(int offset) { @@ -26,9 +27,9 @@ public class Int16SpecEntry extends AbstractSpecEntry { @Override public void read(ByteBuffer buffer) { - short[] values = new short[count]; - for (int x = 0; x < count; x++) { - values[x] = buffer.getShort(); + ShortList values = new ShortList(); + for (int i = 0; i < count; i++) { + values.add(buffer.getShort()); } setValues(values); } diff --git a/rpm-core/src/main/java/org/xbib/rpm/header/entry/Int32SpecEntry.java b/rpm-core/src/main/java/org/xbib/rpm/header/entry/Int32SpecEntry.java index f970eef..5a83c56 100644 --- a/rpm-core/src/main/java/org/xbib/rpm/header/entry/Int32SpecEntry.java +++ b/rpm-core/src/main/java/org/xbib/rpm/header/entry/Int32SpecEntry.java @@ -1,13 +1,14 @@ package org.xbib.rpm.header.entry; import org.xbib.rpm.header.EntryType; +import org.xbib.rpm.header.IntegerList; import java.nio.ByteBuffer; /** * */ -public class Int32SpecEntry extends AbstractSpecEntry { +public class Int32SpecEntry extends AbstractSpecEntry { @Override public int getOffset(int offset) { @@ -26,18 +27,21 @@ public class Int32SpecEntry extends AbstractSpecEntry { @Override public void read(ByteBuffer buffer) { - Integer[] values = new Integer[count]; + IntegerList values = new IntegerList(); for (int x = 0; x < count; x++) { - values[x] = buffer.getInt(); + values.add(buffer.getInt()); } setValues(values); } @Override public void write(ByteBuffer buffer) { - for (int x = 0; x < count; x++) { - Integer i = values[x]; - buffer.putInt(i); + for (int i = 0; i < count; i++) { + Integer integer = values.get(i); + if (integer == null) { + throw new NullPointerException(); + } + buffer.putInt(integer); } } @@ -48,7 +52,7 @@ public class Int32SpecEntry extends AbstractSpecEntry { if (values != null) { for (Integer i : values) { builder.append(i); - if (values.length > 1) { + if (values.size() > 1) { builder.append(", "); } } diff --git a/rpm-core/src/main/java/org/xbib/rpm/header/entry/Int64SpecEntry.java b/rpm-core/src/main/java/org/xbib/rpm/header/entry/Int64SpecEntry.java index f38f8d6..ccc9273 100644 --- a/rpm-core/src/main/java/org/xbib/rpm/header/entry/Int64SpecEntry.java +++ b/rpm-core/src/main/java/org/xbib/rpm/header/entry/Int64SpecEntry.java @@ -1,13 +1,14 @@ package org.xbib.rpm.header.entry; import org.xbib.rpm.header.EntryType; +import org.xbib.rpm.header.LongList; import java.nio.ByteBuffer; /** * */ -public class Int64SpecEntry extends AbstractSpecEntry { +public class Int64SpecEntry extends AbstractSpecEntry { @Override public int getOffset(int offset) { @@ -26,16 +27,16 @@ public class Int64SpecEntry extends AbstractSpecEntry { @Override public void read(ByteBuffer buffer) { - long[] values = new long[count]; + LongList values = new LongList(); for (int x = 0; x < count; x++) { - values[x] = buffer.getLong(); + values.add(buffer.getLong()); } setValues(values); } @Override public void write(ByteBuffer data) { - for (long l : values) { + for (Long l : values) { data.putLong(l); } } diff --git a/rpm-core/src/main/java/org/xbib/rpm/header/entry/StringArraySpecEntry.java b/rpm-core/src/main/java/org/xbib/rpm/header/entry/StringListSpecEntry.java similarity index 56% rename from rpm-core/src/main/java/org/xbib/rpm/header/entry/StringArraySpecEntry.java rename to rpm-core/src/main/java/org/xbib/rpm/header/entry/StringListSpecEntry.java index ffe8427..c6ff5cb 100644 --- a/rpm-core/src/main/java/org/xbib/rpm/header/entry/StringArraySpecEntry.java +++ b/rpm-core/src/main/java/org/xbib/rpm/header/entry/StringListSpecEntry.java @@ -5,10 +5,10 @@ import org.xbib.rpm.header.EntryType; /** * */ -public class StringArraySpecEntry extends StringSpecEntry { +public class StringListSpecEntry extends StringSpecEntry { @Override public int getType() { - return EntryType.STRING_ARRAY_ENTRY; + return EntryType.STRING_LIST_ENTRY; } } diff --git a/rpm-core/src/main/java/org/xbib/rpm/header/entry/StringSpecEntry.java b/rpm-core/src/main/java/org/xbib/rpm/header/entry/StringSpecEntry.java index 2c6c245..b0bcbb1 100644 --- a/rpm-core/src/main/java/org/xbib/rpm/header/entry/StringSpecEntry.java +++ b/rpm-core/src/main/java/org/xbib/rpm/header/entry/StringSpecEntry.java @@ -1,6 +1,7 @@ package org.xbib.rpm.header.entry; import org.xbib.rpm.header.EntryType; +import org.xbib.rpm.header.StringList; import java.nio.ByteBuffer; import java.nio.charset.StandardCharsets; @@ -8,7 +9,7 @@ import java.nio.charset.StandardCharsets; /** * */ -public class StringSpecEntry extends AbstractSpecEntry { +public class StringSpecEntry extends AbstractSpecEntry { @Override public int getType() { @@ -28,8 +29,8 @@ public class StringSpecEntry extends AbstractSpecEntry { @Override public void read(ByteBuffer buffer) { - String[] values = new String[count]; - for (int x = 0; x < count; x++) { + StringList values = new StringList(); + for (int i = 0; i < count; i++) { int length = 0; while (buffer.get(buffer.position() + length) != 0) { length++; @@ -37,7 +38,7 @@ public class StringSpecEntry extends AbstractSpecEntry { ByteBuffer slice = buffer.slice(); buffer.position(buffer.position() + length + 1); slice.limit(length); - values[x] = StandardCharsets.UTF_8.decode(slice).toString(); + values.add(StandardCharsets.UTF_8.decode(slice).toString()); } setValues(values); } diff --git a/rpm-core/src/main/java/org/xbib/rpm/lead/Architecture.java b/rpm-core/src/main/java/org/xbib/rpm/lead/Architecture.java index b2ee91a..92d8ab5 100644 --- a/rpm-core/src/main/java/org/xbib/rpm/lead/Architecture.java +++ b/rpm-core/src/main/java/org/xbib/rpm/lead/Architecture.java @@ -7,23 +7,51 @@ public enum Architecture { NOARCH, I386, + I486, + I586, + I686, ALPHA, + ALPHAEV5, + ALPHAEV6, SPARC, - MIPS, - PPC, - M68K, - IP, - RS6000, - IA64, + SPARCV8, + SPARCV9, SPARC64, - MIPSEL, + PPC, + PPC64, + PPC64LE, ARM, + ARMV3L, + ARMV4B, + ARMV4L, + ARMV4TL, + ARMV5TL, + ARMV5TEL, + ARMV5TEJL, + ARMV6L, + ARMV6HL, + ARMV7L, + ARMV7HL, + ARMV7HNL, + ARMV8L, + ARMV8HNL, + MIPS, + MIPSEL, + MIPS64, + MIPS64EL, + MIPSR6, + MIPSR6EL, + MIPS64R6, + MIPS64R6EL, + M68K, MK68KMINT, S390, S390X, - PPC64, - SH, - XTENSA, + IA64, X86_64, - PPC64LE + AMD64, + SH3, + SH4, + AARCH64, + RISCV64 } diff --git a/rpm-core/src/main/java/org/xbib/rpm/payload/Contents.java b/rpm-core/src/main/java/org/xbib/rpm/payload/Contents.java index 2132025..abf6cbf 100644 --- a/rpm-core/src/main/java/org/xbib/rpm/payload/Contents.java +++ b/rpm-core/src/main/java/org/xbib/rpm/payload/Contents.java @@ -1,11 +1,13 @@ package org.xbib.rpm.payload; import org.xbib.rpm.exception.RpmException; +import org.xbib.rpm.header.IntegerList; +import org.xbib.rpm.header.ShortList; +import org.xbib.rpm.header.StringList; import org.xbib.rpm.io.ChannelWrapper; import org.xbib.rpm.io.ChannelWrapper.Key; import org.xbib.rpm.io.ReadableChannelWrapper; import org.xbib.rpm.security.HashAlgo; - import java.io.IOException; import java.io.InputStream; import java.io.UncheckedIOException; @@ -21,7 +23,6 @@ import java.nio.file.Paths; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.util.ArrayList; -import java.util.Arrays; import java.util.Comparator; import java.util.EnumSet; import java.util.LinkedHashMap; @@ -30,8 +31,6 @@ import java.util.List; import java.util.Map; import java.util.Set; import java.util.TreeSet; -import java.util.logging.Level; -import java.util.logging.Logger; /** * The contents of an RPM archive. These entries define the files and links that @@ -40,7 +39,19 @@ import java.util.logging.Logger; */ public class Contents { - private static final Logger logger = Logger.getLogger(Contents.class.getName()); + private static final String DEFAULT_USERNAME = "root"; + + private static final int DEFAULT_UID = 0; + + private static final String DEFAULT_GROUP = "root"; + + private static final int DEFAULT_GID = 0; + + private static final int DEFAULT_FILE_PERMISSION = 0644; + + private static final int DEFAULT_DIRECTORY_PERMISSION = 0755; + + private static final int DEFAULT_LINK_PERMISSION = 0755; private static final Set BUILTIN = new LinkedHashSet<>(); @@ -82,14 +93,6 @@ public class Contents { BUILTIN.add("/var/log"); BUILTIN.add("/var/run"); BUILTIN.add("/var/spool"); - /* - DOC_DIRS.add("/usr/doc"); - DOC_DIRS.add("/usr/man"); - DOC_DIRS.add("/usr/X11R6/man"); - DOC_DIRS.add("/usr/share/doc"); - DOC_DIRS.add("/usr/share/man"); - DOC_DIRS.add("/usr/share/info"); - */ } private final Set headers = @@ -99,6 +102,8 @@ public class Contents { private final Map sources = new LinkedHashMap<>(); + private final Map usergroups = new LinkedHashMap<>(); + private final Set builtins = new LinkedHashSet<>(); private int inode = 1; @@ -107,153 +112,75 @@ public class Contents { builtins.addAll(BUILTIN); } - private static String hex(byte[] bytes) { - StringBuilder sb = new StringBuilder(); - for (byte aByte : bytes) { - sb.append(hex.charAt(((int) aByte & 0xf0) >> 4)).append(hex.charAt((int) aByte & 0x0f)); - } - return sb.toString(); - } - /** - * Adds a directory entry to the archive with the default permissions of 644. - * - * @param path the destination path for the installed file. - * @param target the target string - */ - public void addLink(String path, String target) { - addLink(path, target, -1); - } - - /** - * Adds a directory entry to the archive with the specified permissions. - * - * @param path the destination path for the installed file. - * @param target the target string - * @param permissions the permissions flags. - */ - public void addLink(String path, String target, int permissions) { - addLink(path, target, permissions, null, null); - } - - /** - * Adds a directory entry to the archive with the specified permissions. + * Adds a link to the archive with the specified permissions. * * @param path the destination path for the installed file. * @param target the target string * @param permissions the permissions flags. * @param uname user owner for the given link * @param gname group owner for the given link + * @param uid the user id or -1 for the default value + * @param gid the group id or -1 for the default value + * @param addParents whether to add parent directories */ - public void addLink(String path, String target, int permissions, String uname, String gname) { - if (files.contains(path)) { - return; - } - files.add(path); - logger.log(Level.FINE, "adding link ''{0}''.", path); - CpioHeader header = new CpioHeader(path); - header.setType(CpioHeader.SYMLINK); - header.setFileSize(target.length()); - header.setMtime(System.currentTimeMillis()); - header.setUname(getDefaultIfMissing(uname, CpioHeader.DEFAULT_USERNAME)); - header.setGname(getDefaultIfMissing(gname, CpioHeader.DEFAULT_GROUP)); - if (permissions != -1) { - header.setPermissions(permissions); - } - headers.add(header); - sources.put(header, target); - } - - private String getDefaultIfMissing(String value, String defaultValue) { - return value == null || value.isEmpty() ? defaultValue : value; - } - - /** - * Adds a directory entry to the archive with the default permissions of 644. - * - * @param path the destination path for the installed file. - */ - public void addDirectory(String path) { - addDirectory(path, -1); - } - - /** - * Adds a directory entry to the archive with the default permissions of 644. - * - * @param path the destination path for the installed file. - * @param directive directive indicating special handling for this directory. - */ - public void addDirectory(String path, EnumSet directive) { - addDirectory(path, -1, directive, null, null); - } - - /** - * Adds a directory entry to the archive with the specified permissions. - * - * @param path the destination path for the installed file. - * @param permissions the permissions flags. - */ - public void addDirectory(String path, int permissions) { - addDirectory(path, permissions, null, null, null); - } - - /** - * Adds a directory entry to the archive with the specified permissions. - * - * @param path the destination path for the installed file. - * @param permissions the permissions flags. - * @param directive directive indicating special handling for this directory. - * @param uname user owner for the given file - * @param gname group owner for the given file - */ - public void addDirectory(String path, int permissions, EnumSet directive, String uname, String gname) { - addDirectory(path, permissions, directive, uname, gname, true); - } - - /** - * Adds a directory entry to the archive with the specified permissions. - * - * @param path the destination path for the installed file. - * @param permissions the permissions flags. - * @param directive directive indicating special handling for this directory. - * @param uname user owner for the given file - * @param gname group owner for the given file - * @param addParents whether to add parent directories to the rpm - */ - public void addDirectory(String path, int permissions, EnumSet directive, String uname, - String gname, boolean addParents) { + public void addLink(String path, String target, int permissions, + String uname, String gname, int uid, int gid, boolean addParents) { if (files.contains(path)) { return; } if (addParents) { - addParents(Paths.get(path), permissions, uname, gname); + addParents(Paths.get(path), permissions, uname, gname, uid, gid); + } + files.add(path); + CpioHeader header = new CpioHeader(path); + header.setType(CpioHeader.SYMLINK); + header.setFileSize(target.length()); + header.setMtime(System.currentTimeMillis()); + header.setUid(uid == -1 ? DEFAULT_UID : uid); + header.setGid(gid == -1 ? DEFAULT_GID : gid); + header.setPermissions(permissions == -1 ? DEFAULT_LINK_PERMISSION : permissions); + headers.add(header); + UserGroup userGroup = new UserGroup(); + userGroup.user = getDefaultIfMissing(uname, DEFAULT_USERNAME); + userGroup.group = getDefaultIfMissing(gname, DEFAULT_GROUP); + usergroups.put(header, userGroup); + sources.put(header, target); + } + + /** + * Adds a directory entry to the archive with the specified permissions. + * + * @param path the destination path for the installed file. + * @param permissions the permissions flags. + * @param directive directive indicating special handling for this directory. + * @param uname user owner of the directory + * @param gname group owner of the directory + * @param uid user owner for the given file + * @param gid group owner for the given file + * @param addParents whether to add parent directories + */ + public void addDirectory(String path, int permissions, EnumSet directive, + String uname, String gname, int uid, int gid, boolean addParents) { + if (files.contains(path)) { + return; + } + if (addParents) { + addParents(Paths.get(path), permissions, uname, gname, uid, gid); } files.add(path); - logger.log(Level.FINE, "adding directory ''{0}''.", path); CpioHeader header = new CpioHeader(path); header.setType(CpioHeader.DIR); header.setInode(inode++); - if (uname == null) { - header.setUname(CpioHeader.DEFAULT_USERNAME); - } else if (0 == uname.length()) { - header.setUname(CpioHeader.DEFAULT_USERNAME); - } else { - header.setUname(uname); - } - if (gname == null) { - header.setGname(CpioHeader.DEFAULT_GROUP); - } else if (0 == gname.length()) { - header.setGname(CpioHeader.DEFAULT_GROUP); - } else { - header.setGname(gname); - } + header.setUid(uid == -1 ? DEFAULT_UID : uid); + header.setGid(gid == -1 ? DEFAULT_GID : gid); header.setMtime(System.currentTimeMillis()); - if (-1 == permissions) { - header.setPermissions(CpioHeader.DEFAULT_DIRECTORY_PERMISSION); - } else { - header.setPermissions(permissions); - } + header.setPermissions(permissions == -1 ? DEFAULT_DIRECTORY_PERMISSION : permissions); headers.add(header); + UserGroup userGroup = new UserGroup(); + userGroup.user = getDefaultIfMissing(uname, DEFAULT_USERNAME); + userGroup.group = getDefaultIfMissing(gname, DEFAULT_GROUP); + usergroups.put(header, userGroup); sources.put(header, ""); if (directive != null) { int flag = Directive.NONE.flag(); @@ -264,89 +191,6 @@ public class Contents { } } - /** - * Adds a file entry to the archive with the default permissions of 644. - * - * @param path the destination path for the installed file. - * @param source the local file to be included in the package. - * @throws IOException file wasn't found - */ - public void addFile(String path, Path source) throws IOException { - addFile(path, source, -1); - } - - /** - * Adds a file entry to the archive with the specified permissions. - * - * @param path the destination path for the installed file. - * @param source the local file to be included in the package. - * @param permissions the permissions flags. - * @throws IOException file wasn't found - */ - public void addFile(String path, Path source, int permissions) throws IOException { - addFile(path, source, permissions, null, null, null); - } - - /** - * Adds a file entry to the archive with the specified permissions. - * - * @param path the destination path for the installed file. - * @param source the local file to be included in the package. - * @param permissions the permissions flags. - * @param dirmode permission flags for parent directories, use -1 to leave as default. - * @throws IOException file wasn't found - */ - public void addFile(String path, Path source, int permissions, int dirmode) throws IOException { - addFile(path, source, permissions, null, null, null, dirmode); - } - - /** - * Adds a file entry to the archive with the specified permissions. - * - * @param path the destination path for the installed file. - * @param source the local file to be included in the package. - * @param permissions the permissions flags. - * @param directive directive indicating special handling for this file. - * @throws IOException file wasn't found - */ - public void addFile(String path, Path source, int permissions, EnumSet directive) - throws IOException { - addFile(path, source, permissions, directive, null, null); - } - - /** - * Adds a file entry to the archive with the specified permissions. - * - * @param path the destination path for the installed file. - * @param source the local file to be included in the package. - * @param permissions the permissions flags. - * @param directive directive indicating special handling for this file. - * @param uname user owner for the given file - * @param gname group owner for the given file - * @throws IOException file wasn't found - */ - public void addFile(String path, Path source, int permissions, EnumSet directive, String uname, - String gname) throws IOException { - addFile(path, source, permissions, directive, uname, gname, -1); - } - - /** - * Adds a file entry to the archive with the specified permissions. - * - * @param path the destination path for the installed file. - * @param source the local file to be included in the package. - * @param permissions the permissions flags. - * @param directives directives indicating special handling for this file. - * @param uname user owner for the given file - * @param gname group owner for the given file - * @param dirmode permission flags for parent directories, use -1 to leave as default. - * @throws IOException file wasn't found - */ - public void addFile(String path, Path source, int permissions, EnumSet directives, String uname, - String gname, int dirmode) throws IOException { - addFile(path, source, permissions, directives, uname, gname, dirmode, true); - } - /** * Adds a file entry to the archive with the specified permissions. * @@ -354,41 +198,26 @@ public class Contents { * @param source the local file to be included in the package. * @param permissions the permissions flags, use -1 to leave as default. * @param directives directives indicating special handling for this file, use null to ignore. - * @param uname user owner for the given file, use null for default user. - * @param gname group owner for the given file, use null for default group. - * @param dirmode permission flags for parent directories, use -1 to leave as default. - * @param addParents whether to create parent directories for the file, defaults to true for other methods. - * @throws IOException file wasn't found - */ - public void addFile(String path, Path source, int permissions, EnumSet directives, String uname, - String gname, int dirmode, boolean addParents) throws IOException { - addFile(path, source, permissions, directives, uname, gname, dirmode, addParents, -1); - } - - /** - * Adds a file entry to the archive with the specified permissions. - * - * @param path the destination path for the installed file. - * @param source the local file to be included in the package. - * @param permissions the permissions flags, use -1 to leave as default. - * @param directives directives indicating special handling for this file, use null to ignore. - * @param uname user owner for the given file, use null for default user. - * @param gname group owner for the given file, use null for default group. + * @param uname user owner of the file + * @param gname group owner of the file + * @param uid user owner for the given file, use null for default user. + * @param gid group owner for the given file, use null for default group. * @param dirmode permission flags for parent directories, use -1 to leave as default. * @param addParents whether to create parent directories for the file, defaults to true for other methods. * @param verifyFlags verify flags * @throws java.io.FileNotFoundException file wasn't found */ - public void addFile(String path, Path source, int permissions, EnumSet directives, String uname, - String gname, int dirmode, boolean addParents, int verifyFlags) throws IOException { + public void addFile(String path, Path source, int permissions, int dirmode, + EnumSet directives, + String uname, String gname, int uid, int gid, + boolean addParents, int verifyFlags) throws IOException { if (files.contains(path)) { return; } if (addParents) { - addParents(Paths.get(path), dirmode, uname, gname); + addParents(Paths.get(path), dirmode, uname, gname, uid, gid); } files.add(path); - logger.log(Level.FINE, "adding file ''{0}''.", path); CpioHeader header; if (directives != null && directives.contains(Directive.GHOST)) { header = new CpioHeader(path); @@ -397,27 +226,15 @@ public class Contents { } header.setType(CpioHeader.FILE); header.setInode(inode++); - if (uname == null) { - header.setUname(CpioHeader.DEFAULT_USERNAME); - } else if (0 == uname.length()) { - header.setUname(CpioHeader.DEFAULT_USERNAME); - } else { - header.setUname(uname); - } - if (gname == null) { - header.setGname(CpioHeader.DEFAULT_GROUP); - } else if (0 == gname.length()) { - header.setGname(CpioHeader.DEFAULT_GROUP); - } else { - header.setGname(gname); - } - if (-1 == permissions) { - header.setPermissions(CpioHeader.DEFAULT_FILE_PERMISSION); - } else { - header.setPermissions(permissions); - } + header.setUid(uid == -1 ? (int) Files.getAttribute(source, "unix:uid") : uid); + header.setGid(gid == -1 ? (int) Files.getAttribute(source, "unix:gid") : gid); + header.setPermissions(permissions == -1 ? DEFAULT_FILE_PERMISSION : permissions); header.setVerifyFlags(verifyFlags); headers.add(header); + UserGroup userGroup = new UserGroup(); + userGroup.user = getDefaultIfMissing(uname, DEFAULT_USERNAME); + userGroup.group = getDefaultIfMissing(gname, DEFAULT_GROUP); + usergroups.put(header, userGroup); sources.put(header, source); if (directives != null) { int flag = Directive.NONE.flag(); @@ -435,32 +252,30 @@ public class Contents { * @param source the URL with the data to be added * @param permissions the permissions flags. * @param directive directive indicating special handling for this file. - * @param uname user owner for the given file - * @param gname group owner for the given file + * @param uname user owner of the URL + * @param gname group owner of the URL + * @param uid user owner for the given file + * @param gid group owner for the given file * @param dirmode permission flags for parent directories, use -1 to leave as default. - * @throws IOException file wasn't found */ - public void addURL(String path, URL source, int permissions, EnumSet directive, String uname, - String gname, int dirmode) throws IOException { + public void addURL(String path, URL source, int permissions, EnumSet directive, + String uname, String gname, int uid, int gid, int dirmode) { if (files.contains(path)) { return; } - addParents(Paths.get(path), dirmode, uname, gname); + addParents(Paths.get(path), dirmode, uname, gname, uid, gid); files.add(path); - logger.log(Level.FINE, "adding file ''{0}''.", path); CpioHeader header = new CpioHeader(path, source); header.setType(CpioHeader.FILE); header.setInode(inode++); - if (uname != null) { - header.setUname(uname); - } - if (gname != null) { - header.setGname(gname); - } - if (permissions != -1) { - header.setPermissions(permissions); - } + header.setUid(uid == -1 ? DEFAULT_UID : uid); + header.setGid(gid == -1 ? DEFAULT_GID : gid); + header.setPermissions(permissions == -1 ? DEFAULT_FILE_PERMISSION : permissions); headers.add(header); + UserGroup userGroup = new UserGroup(); + userGroup.user = getDefaultIfMissing(uname, DEFAULT_USERNAME); + userGroup.group = getDefaultIfMissing(gname, DEFAULT_GROUP); + usergroups.put(header, userGroup); sources.put(header, source); if (directive != null) { int flag = Directive.NONE.flag(); @@ -477,21 +292,20 @@ public class Contents { * * @param path the file to add parent directories of * @param permissions the permissions flags - * @param uname user owner for the given file - * @param gname group owner for the given file + * @param uid user owner for the given file + * @param gid group owner for the given file */ - private void addParents(Path path, int permissions, String uname, String gname) { + private void addParents(Path path, int permissions, String uname, String gname, int uid, int gid) { List parents = new ArrayList<>(); listParents(parents, path); for (String parent : parents) { - addDirectory(parent, permissions, null, uname, gname); + addDirectory(parent, permissions, null, uname, gname, uid, gid, true); } } /** * Add additional directory that is assumed to already exist on system where the RPM will be installed * (e.g. /etc) and should not have an entry in the RPM. - *

* The builtin will only be added to this instance of Contents. * * @param directory the directory to add @@ -571,7 +385,7 @@ public class Contents { * * @return the dirnames headers values */ - public String[] getDirNames() { + public StringList getDirNames() { Set set = new LinkedHashSet<>(); for (CpioHeader header : headers) { Path path = Paths.get(header.getName()).getParent(); @@ -584,7 +398,7 @@ public class Contents { } set.add(parent); } - return set.toArray(new String[set.size()]); + return new StringList(set); } /** @@ -592,21 +406,20 @@ public class Contents { * * @return the dirindexes */ - public Integer[] getDirIndexes() { - List dirs = Arrays.asList(getDirNames()); - Integer[] array = new Integer[headers.size()]; - int x = 0; + public IntegerList getDirIndexes() { + StringList dirs = getDirNames(); + IntegerList array = new IntegerList(); for (CpioHeader header : headers) { Path path = Paths.get(header.getName()).getParent(); if (path == null) { - array[x++] = 0; // dummy value, required when including non-existent directories + array.add(0); continue; } String parent = CpioHeader.normalizePath(path.toString()); if (!parent.endsWith("/")) { parent += "/"; } - array[x++] = dirs.indexOf(parent); + array.add(dirs.indexOf(parent)); } return array; } @@ -616,12 +429,11 @@ public class Contents { * * @return the basename header values */ - public String[] getBaseNames() { - String[] array = new String[headers.size()]; - int x = 0; + public StringList getBaseNames() { + StringList array = new StringList(); for (CpioHeader header : headers) { Path path = Paths.get(header.getName()).getFileName(); - array[x++] = path != null ? CpioHeader.normalizePath(path.toString()) : ""; + array.add(path != null ? CpioHeader.normalizePath(path.toString()) : ""); } return array; } @@ -631,22 +443,20 @@ public class Contents { * * @return the sizes header values */ - public Integer[] getSizes() { - Integer[] array = new Integer[headers.size()]; - int x = 0; + public IntegerList getSizes() { + IntegerList array = new IntegerList(); try { for (CpioHeader header : headers) { Object object = sources.get(header); if (object instanceof Path) { - array[x] = (int) Files.size((Path) object); + array.add((int) Files.size((Path) object)); } else if (object instanceof URL) { - array[x] = ((URL) object).openConnection().getContentLength(); + array.add(((URL) object).openConnection().getContentLength()); } else if (header.getType() == CpioHeader.DIR) { - array[x] = 4096; + array.add(4096); } else if (header.getType() == CpioHeader.SYMLINK) { - array[x] = ((String) object).length(); + array.add(((String) object).length()); } - ++x; } } catch (IOException e) { throw new UncheckedIOException(e); @@ -659,11 +469,10 @@ public class Contents { * * @return the modes header values */ - public short[] getModes() { - short[] array = new short[headers.size()]; - int x = 0; + public ShortList getModes() { + ShortList array = new ShortList(); for (CpioHeader header : headers) { - array[x++] = (short) header.getMode(); + array.add((short) header.getMode()); } return array; } @@ -673,11 +482,10 @@ public class Contents { * * @return the rdevs header values */ - public short[] getRdevs() { - short[] array = new short[headers.size()]; - int x = 0; + public ShortList getRdevs() { + ShortList array = new ShortList(); for (CpioHeader header : headers) { - array[x++] = (short) ((header.getRdevMajor() << 8) + header.getRdevMinor()); + array.add((short) ((header.getRdevMajor() << 8) + header.getRdevMinor())); } return array; } @@ -687,11 +495,10 @@ public class Contents { * * @return the mtimes header values */ - public Integer[] getMtimes() { - Integer[] array = new Integer[headers.size()]; - int x = 0; + public IntegerList getMtimes() { + IntegerList array = new IntegerList(); for (CpioHeader header : headers) { - array[x++] = header.getMtime(); + array.add(header.getMtime()); } return array; } @@ -704,10 +511,9 @@ public class Contents { * @throws RpmException if the algorithm isn't supported * @throws IOException there was an IO error */ - public String[] getDigests(HashAlgo hashAlgo) throws IOException, RpmException { + public StringList getDigests(HashAlgo hashAlgo) throws IOException, RpmException { ByteBuffer buffer = ByteBuffer.allocate(4096); - String[] array = new String[headers.size()]; - int x = 0; + StringList array = new StringList(); for (CpioHeader header : headers) { Object object = sources.get(header); String value = ""; @@ -739,7 +545,7 @@ public class Contents { } } } - array[x++] = value; + array.add(value); } return array; } @@ -751,7 +557,7 @@ public class Contents { * @return reference to the new key added to the consumers */ private ChannelWrapper.Key startDigest(ReadableChannelWrapper input, MessageDigest digest) { - ChannelWrapper.Consumer consumer = new ChannelWrapper.Consumer() { + ChannelWrapper.Consumer consumer = new ChannelWrapper.Consumer<>() { @Override public void consume(ByteBuffer buffer) { try { @@ -778,16 +584,15 @@ public class Contents { * * @return the linktos header */ - public String[] getLinkTos() { - String[] array = new String[headers.size()]; - int x = 0; + public StringList getLinkTos() { + StringList array = new StringList(); for (CpioHeader header : headers) { Object object = sources.get(header); String value = ""; if (object instanceof String) { value = String.valueOf(object); } - array[x++] = value; + array.add(value); } return array; } @@ -797,50 +602,40 @@ public class Contents { * * @return the flags header values */ - public Integer[] getFlags() { - Integer[] array = new Integer[headers.size()]; - int x = 0; + public IntegerList getFlags() { + IntegerList array = new IntegerList(); for (CpioHeader header : headers) { - array[x++] = header.getFlags(); + array.add(header.getFlags()); } return array; } /** - * Gets the users header values. + * Gets the users. * - * @return the users header values + * @return the users */ - public String[] getUsers() { - String[] array = new String[headers.size()]; - int x = 0; + public StringList getUsers() { + StringList list = new StringList(); for (CpioHeader header : headers) { - array[x++] = header.getUname() == null ? "root" : header.getUname(); + UserGroup userGroup = usergroups.get(header); + list.add(userGroup.user); } - return array; + return list; } /** - * Gets the groups header values. + * Gets the groups. * - * @return the groups header values + * @return the groups */ - public String[] getGroups() { - String[] array = new String[headers.size()]; - int x = 0; + public StringList getGroups() { + StringList list = new StringList(); for (CpioHeader header : headers) { - array[x++] = header.getGname() == null ? "root" : header.getGname(); + UserGroup userGroup = usergroups.get(header); + list.add(userGroup.group); } - return array; - } - - /** - * Gets the colors header values. - * - * @return the colors header values - */ - public Integer[] getColors() { - return new Integer[headers.size()]; + return list; } /** @@ -848,11 +643,10 @@ public class Contents { * * @return the verifyflags header values */ - public Integer[] getVerifyFlags() { - Integer[] array = new Integer[headers.size()]; - int x = 0; + public IntegerList getVerifyFlags() { + IntegerList array = new IntegerList(); for (CpioHeader header : headers) { - array[x++] = header.getVerifyFlags(); + array.add(header.getVerifyFlags()); } return array; } @@ -862,9 +656,11 @@ public class Contents { * * @return the classes header values */ - public Integer[] getClasses() { - Integer[] array = new Integer[headers.size()]; - Arrays.fill(array, 1); + public IntegerList getClasses() { + IntegerList array = new IntegerList(); + for (int i = 0; i < headers.size(); i++) { + array.add(1); + } return array; } @@ -873,11 +669,10 @@ public class Contents { * * @return the devices header values */ - public Integer[] getDevices() { - Integer[] array = new Integer[headers.size()]; - int x = 0; + public IntegerList getDevices() { + IntegerList array = new IntegerList(); for (CpioHeader header : headers) { - array[x++] = (header.getDevMajor() << 8) + header.getDevMinor(); + array.add((header.getDevMajor() << 8) + header.getDevMinor()); } return array; } @@ -887,11 +682,10 @@ public class Contents { * * @return the iNodes header values */ - public Integer[] getInodes() { - Integer[] array = new Integer[headers.size()]; - int x = 0; + public IntegerList getInodes() { + IntegerList array = new IntegerList(); for (CpioHeader header : headers) { - array[x++] = header.getInode(); + array.add(header.getInode()); } return array; } @@ -901,38 +695,24 @@ public class Contents { * * @return the langs header values */ - public String[] getLangs() { - String[] array = new String[headers.size()]; - Arrays.fill(array, ""); + public StringList getLangs() { + StringList array = new StringList(); + for (int i =0; i < headers.size(); i++) { + array.add(""); + } return array; } - /** - * Gets the dependsx header values. - * - * @return the dependsx header values - */ - public Integer[] getDependsX() { - return new Integer[headers.size()]; - } - - /** - * Gets the dependsn header values. - * - * @return the dependsn header values - */ - public Integer[] getDependsN() { - return new Integer[headers.size()]; - } - /** * Gets the contexts header values. * * @return the contexts header values */ - public String[] getContexts() { - String[] array = new String[headers.size()]; - Arrays.fill(array, "<>"); + public StringList getContexts() { + StringList array = new StringList(); + for (int i = 0; i< headers.size(); i++) { + array.add("<>"); + } return array; } @@ -954,4 +734,16 @@ public class Contents { parents.add(s); listParents(parents, parent); } + + private String getDefaultIfMissing(String value, String defaultValue) { + return value == null || value.isEmpty() ? defaultValue : value; + } + + private static String hex(byte[] bytes) { + StringBuilder sb = new StringBuilder(); + for (byte aByte : bytes) { + sb.append(hex.charAt(((int) aByte & 0xf0) >> 4)).append(hex.charAt((int) aByte & 0x0f)); + } + return sb.toString(); + } } diff --git a/rpm-core/src/main/java/org/xbib/rpm/payload/CpioHeader.java b/rpm-core/src/main/java/org/xbib/rpm/payload/CpioHeader.java index 78750bd..7947611 100644 --- a/rpm-core/src/main/java/org/xbib/rpm/payload/CpioHeader.java +++ b/rpm-core/src/main/java/org/xbib/rpm/payload/CpioHeader.java @@ -23,14 +23,6 @@ import java.util.Date; */ public class CpioHeader { - public static final int DEFAULT_FILE_PERMISSION = 0644; - - public static final int DEFAULT_DIRECTORY_PERMISSION = 0755; - - public static final String DEFAULT_USERNAME = "root"; - - public static final String DEFAULT_GROUP = "root"; - public static final int FIFO = 1; public static final int CDEV = 2; @@ -51,22 +43,18 @@ public class CpioHeader { private static final String TRAILER = "TRAILER!!!"; - private Charset charset = StandardCharsets.UTF_8; + private final Charset charset = StandardCharsets.UTF_8; private int inode; protected int type; - protected int permissions = DEFAULT_FILE_PERMISSION; + protected int permissions = 0644; private int uid; - private String uname; - private int gid; - private String gname; - private int nlink = 1; private long mtime; @@ -171,48 +159,48 @@ public class CpioHeader { this.inode = inode; } - public String getName() { - return name; - } - public void setName(String name) { this.name = name; } - public int getFlags() { - return flags; + public String getName() { + return name; } public void setFlags(int flags) { this.flags = flags; } - public int getVerifyFlags() { - return verifyFlags; + public int getFlags() { + return flags; } public void setVerifyFlags(int verifyFlags) { this.verifyFlags = verifyFlags; } + public int getVerifyFlags() { + return verifyFlags; + } + public int getMode() { return (type << 12) | (permissions & 07777); } - public String getUname() { - return this.uname; + public void setUid(int uid) { + this.uid = uid; } - public void setUname(String uname) { - this.uname = uname; + public int getUid() { + return uid; } - public String getGname() { - return this.gname; + public void setGid(int gid) { + this.gid = gid; } - public void setGname(String gname) { - this.gname = gname; + public int getGid() { + return gid; } /** @@ -358,8 +346,6 @@ public class CpioHeader { "Type: " + type + "\n" + "UID: " + uid + "\n" + "GID: " + gid + "\n" + - "UserName: " + uname + "\n" + - "GroupName: " + gname + "\n" + "Nlink: " + nlink + "\n" + "MTime: " + new Date(mtime) + "\n" + "FileSize: " + filesize + "\n" + diff --git a/rpm-core/src/main/java/org/xbib/rpm/payload/Directive.java b/rpm-core/src/main/java/org/xbib/rpm/payload/Directive.java index e1352a8..b5c122e 100644 --- a/rpm-core/src/main/java/org/xbib/rpm/payload/Directive.java +++ b/rpm-core/src/main/java/org/xbib/rpm/payload/Directive.java @@ -38,7 +38,7 @@ public enum Directive { POLICY(1 << 12); - private int flag; + private final int flag; Directive(final int flag) { this.flag = flag; diff --git a/rpm-core/src/main/java/org/xbib/rpm/payload/UserGroup.java b/rpm-core/src/main/java/org/xbib/rpm/payload/UserGroup.java new file mode 100644 index 0000000..290320d --- /dev/null +++ b/rpm-core/src/main/java/org/xbib/rpm/payload/UserGroup.java @@ -0,0 +1,8 @@ +package org.xbib.rpm.payload; + +class UserGroup { + + String user; + + String group; +} diff --git a/rpm-core/src/main/java/org/xbib/rpm/security/SignatureGenerator.java b/rpm-core/src/main/java/org/xbib/rpm/security/SignatureGenerator.java index 15464d7..8d83b8a 100644 --- a/rpm-core/src/main/java/org/xbib/rpm/security/SignatureGenerator.java +++ b/rpm-core/src/main/java/org/xbib/rpm/security/SignatureGenerator.java @@ -28,7 +28,6 @@ import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.security.SignatureException; import java.util.Iterator; -import java.util.logging.Logger; /** * To verify the authenticity of the package, the SIGTAG_PGP tag holds a @@ -41,8 +40,6 @@ import java.util.logging.Logger; */ public class SignatureGenerator { - private static final Logger logger = Logger.getLogger(SignatureGenerator.class.getName()); - private final boolean enabled; private PGPPrivateKey privateKey; @@ -66,26 +63,12 @@ public class SignatureGenerator { } } - public PGPPrivateKey getPrivateKey() { - return privateKey; - } - @SuppressWarnings("unchecked") public void prepare(SignatureHeader signature, HashAlgo algo) { if (enabled) { int count = 287; - switch (algo) { - case SHA256: - // V3 RSA/SHA256 signature - headerOnlyEntry = (SpecEntry) signature.addEntry(SignatureTag.RSAHEADER, count); - headerAndPayloadEntry = (SpecEntry) signature.addEntry(SignatureTag.LEGACY_PGP, count); - break; - default: - // RSA/SHA1 signature - headerOnlyEntry = (SpecEntry) signature.addEntry(SignatureTag.RSAHEADER, count); - headerAndPayloadEntry = (SpecEntry) signature.addEntry(SignatureTag.LEGACY_PGP, count); - break; - } + headerOnlyEntry = (SpecEntry) signature.addEntry(SignatureTag.RSAHEADER, count); + headerAndPayloadEntry = (SpecEntry) signature.addEntry(SignatureTag.LEGACY_PGP, count); } } @@ -111,7 +94,7 @@ public class SignatureGenerator { public ChannelWrapper.Key startDigest(WritableChannelWrapper output, String digest) throws RpmException { try { MessageDigest messageDigest = MessageDigest.getInstance(digest); - ChannelWrapper.Consumer consumer = new ChannelWrapper.Consumer() { + ChannelWrapper.Consumer consumer = new ChannelWrapper.Consumer<>() { @Override public void consume(ByteBuffer buffer) { try { @@ -154,8 +137,7 @@ public class SignatureGenerator { private PGPSecretKeyRingCollection readKeyRing(InputStream privateKeyRing) { try { - InputStream keyInputStream = new BufferedInputStream(privateKeyRing); - try (InputStream decoderStream = PGPUtil.getDecoderStream(keyInputStream)) { + try (InputStream decoderStream = PGPUtil.getDecoderStream(new BufferedInputStream(privateKeyRing))) { return new PGPSecretKeyRingCollection(decoderStream, new JcaKeyFingerprintCalculator()); } } catch (IOException e) { @@ -169,7 +151,6 @@ public class SignatureGenerator { Iterator iter = keyRings.getKeyRings(); while (iter.hasNext()) { PGPSecretKeyRing keyRing = iter.next(); - @SuppressWarnings("unchecked") Iterator keyIter = keyRing.getSecretKeys(); while (keyIter.hasNext()) { PGPSecretKey key = keyIter.next(); @@ -227,14 +208,10 @@ public class SignatureGenerator { if (!buffer.hasRemaining()) { return; } - try { - write(buffer); - } catch (SignatureException e) { - throw new RuntimeException("could not update signature generator", e); - } + write(buffer); } - private void write(ByteBuffer buffer) throws SignatureException { + private void write(ByteBuffer buffer) { if (buffer.hasArray()) { byte[] bufferBytes = buffer.array(); int offset = buffer.arrayOffset(); diff --git a/rpm-core/src/main/java/org/xbib/rpm/signature/SignatureTag.java b/rpm-core/src/main/java/org/xbib/rpm/signature/SignatureTag.java index db87bef..a6e8cff 100644 --- a/rpm-core/src/main/java/org/xbib/rpm/signature/SignatureTag.java +++ b/rpm-core/src/main/java/org/xbib/rpm/signature/SignatureTag.java @@ -16,7 +16,7 @@ public enum SignatureTag implements EntryType { MD5(261, BIN_ENTRY, "md5"), GPG(262, BIN_ENTRY, "gpg"), // 263, 264, 265 are obsolete - PUBKEYS(266, STRING_ARRAY_ENTRY, "pubkeys"), + PUBKEYS(266, STRING_LIST_ENTRY, "pubkeys"), DSAHEADER(267, BIN_ENTRY, "dsaheader"), RSAHEADER(268, BIN_ENTRY, "rsaheader"), SHA1HEADER(269, STRING_ENTRY, "sha1header"), @@ -36,11 +36,11 @@ public enum SignatureTag implements EntryType { ; - private int code; + private final int code; - private int type; + private final int type; - private String name; + private final String name; SignatureTag(final int code, final int type, final String name) { this.code = code; diff --git a/rpm-core/src/main/java/org/xbib/rpm/trigger/Depends.java b/rpm-core/src/main/java/org/xbib/rpm/trigger/Depends.java index 470bd62..7fadb55 100644 --- a/rpm-core/src/main/java/org/xbib/rpm/trigger/Depends.java +++ b/rpm-core/src/main/java/org/xbib/rpm/trigger/Depends.java @@ -11,32 +11,45 @@ public class Depends { protected String version = ""; - private int comparison = 0; + protected int comparison = 0; + + public void setName( String name) { + this.name = name; + } public String getName() { return name; } - public void setName(String name) { - this.name = name; + public void setComparison(String comparisonValue) { + if ("equal".equals(comparisonValue)) { + this.comparison = Flags.EQUAL; + } else if ("greater".equals(comparisonValue)) { + this.comparison = Flags.GREATER; + } else if ("greater|equal".equals(comparisonValue)) { + this.comparison = Flags.GREATER | Flags.EQUAL; + } else if ("less".equals(comparisonValue)) { + this.comparison = Flags.LESS; + } else { + this.comparison = Flags.LESS | Flags.EQUAL; + } } public int getComparison() { - if (0 == comparison && 0 < version.length()) { + if ( 0 == comparison && 0 < version.length()) { return Flags.GREATER | Flags.EQUAL; } - if (0 == version.length()) { + if ( 0 == version.length()) { return 0; } - return comparison; + return this.comparison; + } + + public void setVersion( String version) { + this.version = version; } public String getVersion() { return version; } - - public void setVersion(String version) { - this.version = version; - } - } diff --git a/rpm-core/src/test/java/org/xbib/rpm/RpmBuilderTest.java b/rpm-core/src/test/java/org/xbib/rpm/RpmBuilderTest.java index 2e69d13..4a6f145 100644 --- a/rpm-core/src/test/java/org/xbib/rpm/RpmBuilderTest.java +++ b/rpm-core/src/test/java/org/xbib/rpm/RpmBuilderTest.java @@ -1,25 +1,25 @@ package org.xbib.rpm; -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; - -import org.junit.Ignore; -import org.junit.Test; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import static org.hamcrest.CoreMatchers.*; import org.xbib.rpm.format.Flags; import org.xbib.rpm.format.Format; import org.xbib.rpm.header.HeaderTag; +import org.xbib.rpm.header.IntegerList; +import org.xbib.rpm.header.StringList; import org.xbib.rpm.lead.Architecture; import org.xbib.rpm.lead.Os; import org.xbib.rpm.lead.PackageType; import org.xbib.rpm.payload.CompressionType; import org.xbib.rpm.payload.Directive; import org.xbib.rpm.security.HashAlgo; - import java.nio.file.Path; import java.nio.file.Paths; -import java.util.Arrays; import java.util.EnumSet; +import java.util.List; /** * @@ -53,20 +53,17 @@ public class RpmBuilderTest { rpmBuilder.setType(PackageType.BINARY); EnumSet directives = EnumSet.of(Directive.CONFIG, Directive.DOC, Directive.NOREPLACE); rpmBuilder.addFile("/etc", Paths.get("src/test/resources/prein.sh"), 493, 493, - directives, "jabberwocky", "vorpal"); + directives, "jabberwocky", "vorpal", true); rpmBuilder.build(getTargetDir()); Path path = getTargetDir().resolve("filestest-1.0-1.noarch.rpm"); Format format = new RpmReader().readHeader(path); - assertArrayEquals(new String[]{"jabberwocky"}, - (String[]) format.getHeader().getEntry(HeaderTag.FILEUSERNAME).getValues()); - assertArrayEquals(new String[]{"vorpal"}, - (String[]) format.getHeader().getEntry(HeaderTag.FILEGROUPNAME).getValues()); - Integer expectedFlags = 0; + assertThat(List.of("jabberwocky"), is(format.getHeader().getEntry(HeaderTag.FILEUSERNAME).getValues())); + assertThat(List.of("vorpal"), is(format.getHeader().getEntry(HeaderTag.FILEGROUPNAME).getValues())); + int expectedFlags = 0; for (Directive d : directives) { expectedFlags |= d.flag(); } - assertArrayEquals(new Integer[]{expectedFlags}, - (Integer[]) format.getHeader().getEntry(HeaderTag.FILEFLAGS).getValues()); + assertThat(List.of(expectedFlags), is(format.getHeader().getEntry(HeaderTag.FILEFLAGS).getValues())); } @Test @@ -119,30 +116,30 @@ public class RpmBuilderTest { rpmBuilder.build(getTargetDir()); Path path = getTargetDir().resolve("testCapabilities-1.0-1.noarch.rpm"); Format format = new RpmReader().readHeader(path); - String[] require = (String[]) format.getHeader().getEntry(HeaderTag.REQUIRENAME).getValues(); - Integer[] requireflags = (Integer[]) format.getHeader().getEntry(HeaderTag.REQUIREFLAGS).getValues(); - String[] requireversion = (String[]) format.getHeader().getEntry(HeaderTag.REQUIREVERSION).getValues(); - assertArrayEquals(new String[]{"httpd"}, Arrays.copyOfRange(require, require.length - 1, require.length)); - assertArrayEquals(new Integer[]{0}, Arrays.copyOfRange(requireflags, requireflags.length - 1, require.length)); - assertArrayEquals(new String[]{""}, Arrays.copyOfRange(requireversion, requireversion.length - 1, require.length)); - String[] provide = (String[]) format.getHeader().getEntry(HeaderTag.PROVIDENAME).getValues(); - Integer[] provideflags = (Integer[]) format.getHeader().getEntry(HeaderTag.PROVIDEFLAGS).getValues(); - String[] provideversion = (String[]) format.getHeader().getEntry(HeaderTag.PROVIDEVERSION).getValues(); - assertArrayEquals(new String[]{"testCapabilities", "frobnicator", "barnacle"}, provide); - assertArrayEquals(new Integer[]{Flags.EQUAL, 0, Flags.EQUAL}, provideflags); - assertArrayEquals(new String[]{"0:1.0-1", "", "3.89"}, provideversion); - String[] conflict = (String[]) format.getHeader().getEntry(HeaderTag.CONFLICTNAME).getValues(); - Integer[] conflictflags = (Integer[]) format.getHeader().getEntry(HeaderTag.CONFLICTFLAGS).getValues(); - String[] conflictversion = (String[]) format.getHeader().getEntry(HeaderTag.CONFLICTVERSION).getValues(); - assertArrayEquals(new String[]{"fooberry"}, conflict); - assertArrayEquals(new Integer[]{Flags.GREATER | Flags.EQUAL}, conflictflags); - assertArrayEquals(new String[]{"1a"}, conflictversion); - String[] obsolete = (String[]) format.getHeader().getEntry(HeaderTag.OBSOLETENAME).getValues(); - Integer[] obsoleteflags = (Integer[]) format.getHeader().getEntry(HeaderTag.OBSOLETEFLAGS).getValues(); - String[] obsoleteversion = (String[]) format.getHeader().getEntry(HeaderTag.OBSOLETEVERSION).getValues(); - assertArrayEquals(new String[]{"testCappypkg"}, obsolete); - assertArrayEquals(new Integer[]{0}, obsoleteflags); - assertArrayEquals(new String[]{""}, obsoleteversion); + StringList require = (StringList) format.getHeader().getEntry(HeaderTag.REQUIRENAME).getValues(); + IntegerList requireflags = (IntegerList) format.getHeader().getEntry(HeaderTag.REQUIREFLAGS).getValues(); + StringList requireversion = (StringList) format.getHeader().getEntry(HeaderTag.REQUIREVERSION).getValues(); + assertThat(List.of("httpd"), is(require.subList(require.size() - 1, require.size()))); + assertThat(IntegerList.of(0), is(requireflags.subList(requireflags.size() - 1, requireflags.size()))); + assertThat(StringList.of(""), is(requireversion.subList(requireversion.size() - 1, requireversion.size()))); + StringList provide = (StringList) format.getHeader().getEntry(HeaderTag.PROVIDENAME).getValues(); + IntegerList provideflags = (IntegerList) format.getHeader().getEntry(HeaderTag.PROVIDEFLAGS).getValues(); + StringList provideversion = (StringList) format.getHeader().getEntry(HeaderTag.PROVIDEVERSION).getValues(); + assertThat(StringList.of("testCapabilities", "frobnicator", "barnacle"), is(provide)); + assertThat(IntegerList.of(Flags.EQUAL, 0, Flags.EQUAL), is(provideflags)); + assertThat(StringList.of("0:1.0-1", "", "3.89"), is(provideversion)); + StringList conflict = (StringList) format.getHeader().getEntry(HeaderTag.CONFLICTNAME).getValues(); + IntegerList conflictflags = (IntegerList) format.getHeader().getEntry(HeaderTag.CONFLICTFLAGS).getValues(); + StringList conflictversion = (StringList) format.getHeader().getEntry(HeaderTag.CONFLICTVERSION).getValues(); + assertThat(StringList.of("fooberry"), is(conflict)); + assertThat(IntegerList.of(Flags.GREATER | Flags.EQUAL), is(conflictflags)); + assertThat(StringList.of("1a"), is(conflictversion)); + StringList obsolete = (StringList) format.getHeader().getEntry(HeaderTag.OBSOLETENAME).getValues(); + IntegerList obsoleteflags = (IntegerList) format.getHeader().getEntry(HeaderTag.OBSOLETEFLAGS).getValues(); + StringList obsoleteversion = (StringList) format.getHeader().getEntry(HeaderTag.OBSOLETEVERSION).getValues(); + assertThat(StringList.of("testCappypkg"), is(obsolete)); + assertThat(IntegerList.of(0), is(obsoleteflags)); + assertThat(StringList.of(""), is(obsoleteversion)); } @Test @@ -157,21 +154,15 @@ public class RpmBuilderTest { rpmBuilder.build(getTargetDir()); Path path = getTargetDir().resolve("testMultipleCapabilities-1.0-1.noarch.rpm"); Format format = new RpmReader().readHeader(path); - String[] require = (String[]) format.getHeader().getEntry(HeaderTag.REQUIRENAME).getValues(); - Integer[] requireflags = (Integer[]) format.getHeader().getEntry(HeaderTag.REQUIREFLAGS).getValues(); - String[] requireversion = (String[]) format.getHeader().getEntry(HeaderTag.REQUIREVERSION).getValues(); - assertArrayEquals(new String[]{"httpd"}, - Arrays.copyOfRange(require, require.length - 2, require.length - 1)); - assertArrayEquals(new Integer[]{Flags.GREATER | Flags.EQUAL}, - Arrays.copyOfRange(requireflags, requireflags.length - 2, require.length - 1)); - assertArrayEquals(new String[]{"1.0"}, - Arrays.copyOfRange(requireversion, requireversion.length - 2, require.length - 1)); - assertArrayEquals(new String[]{"httpd"}, - Arrays.copyOfRange(require, require.length - 1, require.length)); - assertArrayEquals(new Integer[]{Flags.LESS}, - Arrays.copyOfRange(requireflags, requireflags.length - 1, require.length)); - assertArrayEquals(new String[]{"2.0"}, - Arrays.copyOfRange(requireversion, requireversion.length - 1, require.length)); + StringList require = (StringList) format.getHeader().getEntry(HeaderTag.REQUIRENAME).getValues(); + IntegerList requireflags = (IntegerList) format.getHeader().getEntry(HeaderTag.REQUIREFLAGS).getValues(); + StringList requireversion = (StringList) format.getHeader().getEntry(HeaderTag.REQUIREVERSION).getValues(); + assertThat(StringList.of("httpd"), is(require.subList(require.size() - 2, require.size() - 1))); + assertThat(IntegerList.of(Flags.GREATER | Flags.EQUAL), is(requireflags.subList(requireflags.size() - 2, requireflags.size() - 1))); + assertThat(StringList.of("1.0"), is(requireversion.subList(require.size() - 2, require.size() - 1))); + assertThat(StringList.of("httpd"), is(require.subList(require.size() - 1, require.size()))); + assertThat(IntegerList.of(Flags.LESS), is(requireflags.subList(requireflags.size() - 1, requireflags.size()))); + assertThat(StringList.of("2.0"), is(requireversion.subList(require.size() - 1, require.size()))); } @Test @@ -186,51 +177,32 @@ public class RpmBuilderTest { rpmBuilder.build(getTargetDir()); Path path = getTargetDir().resolve("testProvideOverride-1.0-1.noarch.rpm"); Format format = new RpmReader().readHeader(path); - String[] provide = (String[]) format.getHeader().getEntry(HeaderTag.PROVIDENAME).getValues(); - Integer[] provideflags = (Integer[]) format.getHeader().getEntry(HeaderTag.PROVIDEFLAGS).getValues(); - String[] provideversion = (String[]) format.getHeader().getEntry(HeaderTag.PROVIDEVERSION).getValues(); - assertEquals(1, provide.length); - assertArrayEquals(new String[]{"testProvideOverride"}, Arrays.copyOfRange(provide, 0, provide.length)); - assertArrayEquals(new Integer[]{Flags.EQUAL}, Arrays.copyOfRange(provideflags, 0, provide.length)); - assertArrayEquals(new String[]{"1.0"}, Arrays.copyOfRange(provideversion, 0, provide.length)); + StringList provide = (StringList) format.getHeader().getEntry(HeaderTag.PROVIDENAME).getValues(); + IntegerList provideflags = (IntegerList) format.getHeader().getEntry(HeaderTag.PROVIDEFLAGS).getValues(); + StringList provideversion = (StringList) format.getHeader().getEntry(HeaderTag.PROVIDEVERSION).getValues(); + assertEquals(1, provide.size()); + assertThat(StringList.of("testProvideOverride"), is(provide)); + assertThat(IntegerList.of(Flags.EQUAL), is(provideflags)); + assertThat(StringList.of("1.0"), is(provideversion)); } @Test - @Ignore public void testAddHeaderEntry() { RpmBuilder rpmBuilder = new RpmBuilder(); - rpmBuilder.addHeaderEntry(HeaderTag.CHANGELOGTIME, new Integer(1)); - try { - rpmBuilder.addHeaderEntry(HeaderTag.CHANGELOGNAME, 1L); - } catch (ClassCastException e) { - // - } - try { - rpmBuilder.addHeaderEntry(HeaderTag.CHANGELOGTIME, "Mon Jan 01 2016"); - fail("ClassCastException expected on setting header String value where int expected."); - } catch (ClassCastException e) { - // - } - try { - rpmBuilder.addHeaderEntry(HeaderTag.CHANGELOGTIME, 1L); - fail("ClassCastException expected on setting header long value where int expected."); - } catch (ClassCastException e) { - // - } - try { + rpmBuilder.addHeaderEntry(HeaderTag.CHANGELOGTIME, Integer.valueOf(1)); + Assertions.assertThrows(ClassCastException.class, () -> + rpmBuilder.addHeaderEntry(HeaderTag.CHANGELOGNAME, 1L)); + rpmBuilder.addHeaderEntry(HeaderTag.CHANGELOGTIME, "Mon Jan 01 2016"); + Assertions.assertThrows(ClassCastException.class, () -> + rpmBuilder.addHeaderEntry(HeaderTag.CHANGELOGTIME, 1L)); + Assertions.assertThrows(ClassCastException.class, () -> { short s = (short) 1; rpmBuilder.addHeaderEntry(HeaderTag.CHANGELOGTIME, s); - fail("ClassCastException expected on setting header short value where int expected."); - } catch (ClassCastException e) { - // - } - try { - Character c = 'c'; + }); + Assertions.assertThrows(ClassCastException.class, () -> { + char c = 'c'; rpmBuilder.addHeaderEntry(HeaderTag.CHANGELOGTIME, c); - fail("ClassCastException expected on setting header char value where int expected."); - } catch (ClassCastException e) { - // - } + }); } @Test @@ -243,10 +215,10 @@ public class RpmBuilderTest { rpmBuilder.setType(PackageType.BINARY); EnumSet directives = EnumSet.of(Directive.CONFIG, Directive.DOC, Directive.NOREPLACE); rpmBuilder.addFile("/etc", Paths.get("src/test/resources/prein.sh"), 493, 493, - directives, "jabberwocky", "vorpal"); + directives, "jabberwocky", "vorpal", true); rpmBuilder.build(getTargetDir()); Path path = getTargetDir().resolve("test-compressed-1.0-1.noarch.rpm"); - Format format = new RpmReader().readHeader(path); + new RpmReader().readHeader(path); } private Path getTargetDir() { diff --git a/rpm-core/src/test/java/org/xbib/rpm/RpmReaderTest.java b/rpm-core/src/test/java/org/xbib/rpm/RpmReaderTest.java index 0b65004..86caa18 100644 --- a/rpm-core/src/test/java/org/xbib/rpm/RpmReaderTest.java +++ b/rpm-core/src/test/java/org/xbib/rpm/RpmReaderTest.java @@ -1,12 +1,10 @@ package org.xbib.rpm; -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; - -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; +import org.junit.jupiter.api.Test; import org.xbib.rpm.format.Format; - import java.nio.file.Paths; import java.util.regex.Matcher; import java.util.regex.Pattern; diff --git a/rpm-core/src/test/java/org/xbib/rpm/SimpleRpmTest.java b/rpm-core/src/test/java/org/xbib/rpm/SimpleRpmTest.java index b4c301a..933cdd5 100644 --- a/rpm-core/src/test/java/org/xbib/rpm/SimpleRpmTest.java +++ b/rpm-core/src/test/java/org/xbib/rpm/SimpleRpmTest.java @@ -1,6 +1,6 @@ package org.xbib.rpm; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.xbib.rpm.lead.Architecture; import org.xbib.rpm.lead.Os; import org.xbib.rpm.lead.PackageType; @@ -13,7 +13,7 @@ import java.nio.file.Paths; public class SimpleRpmTest { @Test - public void testRpm() throws Exception { + public void testRpmBuild() throws Exception { RpmBuilder rpmBuilder = new RpmBuilder(); rpmBuilder.setPackage("test", "0.0.1", "1"); rpmBuilder.setType(PackageType.BINARY); diff --git a/rpm-core/src/test/java/org/xbib/rpm/changelog/ChangelogHandlerTest.java b/rpm-core/src/test/java/org/xbib/rpm/changelog/ChangelogHandlerTest.java index 603f689..297559a 100644 --- a/rpm-core/src/test/java/org/xbib/rpm/changelog/ChangelogHandlerTest.java +++ b/rpm-core/src/test/java/org/xbib/rpm/changelog/ChangelogHandlerTest.java @@ -1,10 +1,9 @@ package org.xbib.rpm.changelog; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import org.junit.Before; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.xbib.rpm.RpmBuilder; import org.xbib.rpm.exception.ChangelogParseException; import org.xbib.rpm.exception.NoInitialAsteriskException; @@ -12,6 +11,7 @@ import org.xbib.rpm.exception.NoInitialAsteriskException; import java.io.IOException; import java.nio.file.NoSuchFileException; import java.nio.file.Paths; +import java.util.List; /** * @@ -20,8 +20,8 @@ public class ChangelogHandlerTest { private RpmBuilder rpmBuilder; - @Before - public void setUp() throws Exception { + @BeforeEach + public void setUp() { rpmBuilder = new RpmBuilder(); } @@ -31,7 +31,7 @@ public class ChangelogHandlerTest { rpmBuilder.addChangelog(Paths.get("non.existent.file")); fail("non-existent file throws FileNotFoundException: not thrown"); } catch (IOException e) { - assertTrue("non-existent file exception", e instanceof NoSuchFileException); + assertTrue(e instanceof NoSuchFileException, "non-existent file exception"); } catch (ChangelogParseException e) { fail("non-existent file throws FileNotFoundException: ChangelogParseException thrown instead"); } @@ -40,22 +40,22 @@ public class ChangelogHandlerTest { @Test public void testBadChangeLog() { try { - rpmBuilder.addChangelog(getClass().getResource("bad.changelog")); + rpmBuilder.addChangelog(getClass().getResource("bad.changelog").openStream()); fail("bad Changelog file throws ChangelogParseException: not thrown"); } catch (IOException e) { fail("bad Changelog file throws ChangelogParseException: IOException thrown instead"); } catch (ChangelogParseException e) { - assertTrue("bad Changelog file throws ChangelogParseException", e instanceof NoInitialAsteriskException); + assertTrue(e instanceof NoInitialAsteriskException, "bad Changelog file throws ChangelogParseException"); } } /** - * Test method for {@link org.xbib.rpm.changelog.ChangelogParser#parse(java.lang.String[])}. + * Test method for {@link org.xbib.rpm.changelog.ChangelogParser#parse(List)}. */ @Test public void commentsIgnored() { try { - rpmBuilder.addChangelog(getClass().getResource("changelog.with.comments")); + rpmBuilder.addChangelog(getClass().getResource("changelog.with.comments").openStream()); } catch (IOException e) { fail("comments_ignored: IOException thrown instead"); } catch (ChangelogParseException e) { diff --git a/rpm-core/src/test/java/org/xbib/rpm/changelog/ChangelogParserTest.java b/rpm-core/src/test/java/org/xbib/rpm/changelog/ChangelogParserTest.java index 05cc1fa..5bb5543 100644 --- a/rpm-core/src/test/java/org/xbib/rpm/changelog/ChangelogParserTest.java +++ b/rpm-core/src/test/java/org/xbib/rpm/changelog/ChangelogParserTest.java @@ -1,11 +1,10 @@ package org.xbib.rpm.changelog; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import org.junit.Before; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.xbib.rpm.exception.ChangelogParseException; import org.xbib.rpm.exception.DatesOutOfSequenceException; import org.xbib.rpm.exception.IncompleteChangelogEntryException; @@ -13,6 +12,8 @@ import org.xbib.rpm.exception.InvalidChangelogDateException; import org.xbib.rpm.exception.NoInitialAsteriskException; import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.util.Arrays; import java.util.List; /** @@ -24,22 +25,21 @@ public class ChangelogParserTest { private List changelogs; - @Before - public void setUp() throws Exception { + @BeforeEach + public void setUp() { parser = new ChangelogParser(); } @Test public void testParsesCorrectlyFormattedChangelog() { - String[] lines = { + List lines = Arrays.asList( "* Tue Feb 24 2015 George Washington", "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt", "* Tue Feb 10 2015 George Washington", - "quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.", - }; + "quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat."); try { changelogs = parser.parse(lines); - assertEquals("parses correctly formatted Changelog", 2, changelogs.size()); + assertEquals(2, changelogs.size(), "parses correctly formatted Changelog"); } catch (ChangelogParseException e) { fail("parses correctly formatted Changelog"); } @@ -47,35 +47,31 @@ public class ChangelogParserTest { @Test public void commentsIgnored() { - String[] lines = { + List lines = Arrays.asList( "# ORDER MUST BE DESCENDING (most recent change at top)", "* Tue Feb 24 2015 George Washington", "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt", "* Tue Feb 10 2015 George Washington", "# a random comment", - "quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.", - }; - + "quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat."); try { changelogs = parser.parse(lines); - assertEquals("comments_ignored", 2, changelogs.size()); + assertEquals(2, changelogs.size(), "comments_ignored"); } catch (ChangelogParseException e) { fail("comments_ignored: failed"); } } /** - * Test method for {@link org.xbib.rpm.changelog.ChangelogParser#parse(java.lang.String[])}. + * Test method for {@link org.xbib.rpm.changelog.ChangelogParser#parse(java.util.List)}. */ @Test public void error_thrown_if_dates_out_of_order() { - String[] lines = { + List lines = Arrays.asList( "* Tue Feb 10 2015 George Washington", "quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.", "* Tue Feb 24 2015 George Washington", - "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt" - }; - + "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt"); try { changelogs = parser.parse(lines); fail("error thrown if dates out of order"); @@ -85,16 +81,14 @@ public class ChangelogParserTest { } /** - * Test method for {@link org.xbib.rpm.changelog.ChangelogParser#parse(java.lang.String[])}. + * Test method for {@link org.xbib.rpm.changelog.ChangelogParser#parse(java.util.List)}. */ @Test public void errorThrownOnWrongDateFormat() { // 2/24/2015 was a Tuesday - String[] lines = { + List lines = Arrays.asList( "* 02/24/2015 George Washington", - "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt" - }; - + "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt"); try { changelogs = parser.parse(lines); fail("error thrown on wrong date format"); @@ -104,16 +98,14 @@ public class ChangelogParserTest { } /** - * Test method for {@link org.xbib.rpm.changelog.ChangelogParser#parse(java.lang.String[])}. + * Test method for {@link org.xbib.rpm.changelog.ChangelogParser#parse(java.util.List)}. */ @Test public void errorThrownOnIncorrectDayOfWeek() { // 2/24/2015 was a Tuesday - String[] lines = { + List lines = Arrays.asList( "* Wed Feb 24 2015 George Washington", - "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt" - }; - + "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt"); try { changelogs = parser.parse(lines); fail("error thrown on incorrect day of week"); @@ -123,15 +115,13 @@ public class ChangelogParserTest { } /** - * Test method for {@link org.xbib.rpm.changelog.ChangelogParser#parse(java.lang.String[])}. + * Test method for {@link org.xbib.rpm.changelog.ChangelogParser#parse(java.util.List)}. */ @Test public void errorThrownOnNoDescription() { - String[] lines = { + List lines = Arrays.asList( "* Tue Feb 24 2015 George Washington", - "* Tue Feb 10 2015 George Washington", - }; - + "* Tue Feb 10 2015 George Washington"); try { changelogs = parser.parse(lines); fail("error thrown on no description"); @@ -141,15 +131,13 @@ public class ChangelogParserTest { } /** - * Test method for {@link org.xbib.rpm.changelog.ChangelogParser#parse(java.lang.String[])}. + * Test method for {@link org.xbib.rpm.changelog.ChangelogParser#parse(List)}. */ @Test public void errorThrownOnNoInitialAsterisk() { - String[] lines = { + List lines = Arrays.asList( "Tue Feb 24 2015 George Washington", - "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt" - }; - + "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt"); try { changelogs = parser.parse(lines); fail("error thrown on no initial asterisk"); @@ -160,15 +148,13 @@ public class ChangelogParserTest { /** - * Test method for {@link org.xbib.rpm.changelog.ChangelogParser#parse(java.lang.String[])}. + * Test method for {@link org.xbib.rpm.changelog.ChangelogParser#parse(List)}. */ @Test public void errorThrownOnNoUserName() { - String[] lines = { + List lines = Arrays.asList( "* Tue Feb 24 2015", - "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt" - }; - + "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt"); try { changelogs = parser.parse(lines); fail("error thrown on no user name"); @@ -178,16 +164,14 @@ public class ChangelogParserTest { } /** - * Test method for {@link org.xbib.rpm.changelog.ChangelogParser#parse(java.lang.String[])}. + * Test method for {@link org.xbib.rpm.changelog.ChangelogParser#parse(List)}. */ @Test public void errorThrownOnNoUserNameOnFirstLine() { - String[] lines = { + List lines = Arrays.asList( "* Tue Feb 24 2015", "George Washington", - "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt" - }; - + "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt"); try { changelogs = parser.parse(lines); fail("error thrown on no user name on first line"); @@ -197,18 +181,17 @@ public class ChangelogParserTest { } /** - * Test method for {@link org.xbib.rpm.changelog.ChangelogParser#parse(java.io.InputStream)}. + * Test method for {@link org.xbib.rpm.changelog.ChangelogParser#parse(java.io.InputStream, java.nio.charset.Charset)}. */ @Test public void parsesFileCorrectly() { try { - changelogs = parser.parse(getClass().getResourceAsStream("changelog")); - assertEquals("parses file correctly", 10, changelogs.size()); + changelogs = parser.parse(getClass().getResourceAsStream("changelog"), StandardCharsets.UTF_8); + assertEquals(10, changelogs.size(), "parses file correctly"); } catch (ChangelogParseException e) { fail("parses file correctly"); } catch (IOException e) { fail("parses file correctly: " + e.getMessage()); } - } } diff --git a/rpm-core/src/test/java/org/xbib/rpm/changelog/ChangelogTest.java b/rpm-core/src/test/java/org/xbib/rpm/changelog/ChangelogTest.java index 013d4cf..27e063a 100644 --- a/rpm-core/src/test/java/org/xbib/rpm/changelog/ChangelogTest.java +++ b/rpm-core/src/test/java/org/xbib/rpm/changelog/ChangelogTest.java @@ -1,14 +1,15 @@ package org.xbib.rpm.changelog; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import org.junit.jupiter.api.Test; import org.xbib.rpm.RpmBuilder; import org.xbib.rpm.RpmReader; import org.xbib.rpm.format.Format; import org.xbib.rpm.header.EntryType; import org.xbib.rpm.header.HeaderTag; +import org.xbib.rpm.header.IntegerList; +import org.xbib.rpm.header.StringList; import org.xbib.rpm.header.entry.SpecEntry; import java.nio.file.Path; @@ -24,11 +25,11 @@ public class ChangelogTest { @Test public void testChangelog() throws Exception { RpmBuilder rpmBuilder = new RpmBuilder(); - rpmBuilder.addChangelog(getClass().getResource("changelog")); + rpmBuilder.addChangelog(getClass().getResource("changelog").openStream()); Path path = Paths.get("build"); rpmBuilder.build(path); RpmReader rpmReader = new RpmReader(); - Format format = rpmReader.read(path.resolve(rpmBuilder.getPackageName())); + Format format = rpmReader.readFormat(path.resolve(rpmBuilder.getPackageName())); assertDateEntryHeaderEqualsAt("Tue Feb 24 2015", format, HeaderTag.CHANGELOGTIME, 10, 0); assertHeaderEqualsAt("Thomas Jefferson", format, @@ -42,25 +43,25 @@ public class ChangelogTest { } private void assertDateEntryHeaderEqualsAt(String expected, Format format, EntryType entryType, int size, int pos) { - assertNotNull("null format", format); + assertNotNull(format, "null format"); SpecEntry entry = format.getHeader().getEntry(entryType); - assertNotNull("Entry not found : " + entryType.getName(), entry); - assertEquals("Entry type : " + entryType.getName(), 4, entry.getType()); - Integer[] values = (Integer[]) entry.getValues(); - assertNotNull("null values", values); - assertEquals("Entry size : " + entryType.getName(), size, values.length); - LocalDateTime localDate = LocalDateTime.ofEpochSecond(values[pos], 0, ZoneOffset.UTC); - assertEquals("Entry value : " + entryType.getName(), expected, ChangelogParser.CHANGELOG_FORMAT.format(localDate)); + assertNotNull(entry, "Entry not found : " + entryType.getName()); + assertEquals(4, entry.getType(), "Entry type : " + entryType.getName()); + IntegerList values = (IntegerList) entry.getValues(); + assertNotNull(values, "null values"); + assertEquals(size, values.size(), "Entry size : " + entryType.getName()); + LocalDateTime localDate = LocalDateTime.ofEpochSecond(values.get(pos), 0, ZoneOffset.UTC); + assertEquals(expected, ChangelogParser.CHANGELOG_FORMAT.format(localDate), "Entry value : " + entryType.getName()); } private void assertHeaderEqualsAt(String expected, Format format, EntryType entryType, int size, int pos) { - assertNotNull("null format", format); + assertNotNull(format, "null format"); SpecEntry entry = format.getHeader().getEntry(entryType); - assertNotNull("Entry not found : " + entryType.getName(), entry); - assertEquals("Entry type : " + entryType.getName(), 8, entry.getType()); - String[] values = (String[]) entry.getValues(); - assertNotNull("null values", values); - assertEquals("Entry size : " + entryType.getName(), size, values.length); - assertEquals("Entry value : " + entryType.getName(), expected, values[pos]); + assertNotNull(entry, "Entry not found : " + entryType.getName()); + assertEquals(8, entry.getType(), "Entry type : " + entryType.getName()); + StringList values = (StringList) entry.getValues(); + assertNotNull(values, "null values"); + assertEquals(size, values.size(), "Entry size : " + entryType.getName()); + assertEquals(expected, values.get(pos), "Entry value : " + entryType.getName()); } } diff --git a/rpm-core/src/test/java/org/xbib/rpm/exception/InvalidDirectiveExceptionTest.java b/rpm-core/src/test/java/org/xbib/rpm/exception/InvalidDirectiveExceptionTest.java index 3813eda..2948276 100644 --- a/rpm-core/src/test/java/org/xbib/rpm/exception/InvalidDirectiveExceptionTest.java +++ b/rpm-core/src/test/java/org/xbib/rpm/exception/InvalidDirectiveExceptionTest.java @@ -1,13 +1,13 @@ package org.xbib.rpm.exception; -import static org.junit.Assert.assertEquals; - -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.Test; /** * */ public class InvalidDirectiveExceptionTest { + @Test public void exception() { InvalidDirectiveException ex diff --git a/rpm-core/src/test/java/org/xbib/rpm/exception/InvalidPathExceptionTest.java b/rpm-core/src/test/java/org/xbib/rpm/exception/InvalidPathExceptionTest.java index 603d870..335d469 100644 --- a/rpm-core/src/test/java/org/xbib/rpm/exception/InvalidPathExceptionTest.java +++ b/rpm-core/src/test/java/org/xbib/rpm/exception/InvalidPathExceptionTest.java @@ -1,8 +1,7 @@ package org.xbib.rpm.exception; -import static org.junit.Assert.assertEquals; - -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.Test; /** * diff --git a/rpm-core/src/test/java/org/xbib/rpm/exception/PathOutsideBuildPathExceptionTest.java b/rpm-core/src/test/java/org/xbib/rpm/exception/PathOutsideBuildPathExceptionTest.java index 431c41f..169bb4d 100644 --- a/rpm-core/src/test/java/org/xbib/rpm/exception/PathOutsideBuildPathExceptionTest.java +++ b/rpm-core/src/test/java/org/xbib/rpm/exception/PathOutsideBuildPathExceptionTest.java @@ -1,8 +1,7 @@ package org.xbib.rpm.exception; -import static org.junit.Assert.assertEquals; - -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.Test; /** * diff --git a/rpm-core/src/test/java/org/xbib/rpm/exception/SigningKeyNotFoundExceptionTest.java b/rpm-core/src/test/java/org/xbib/rpm/exception/SigningKeyNotFoundExceptionTest.java index 47617ad..e5a12c5 100644 --- a/rpm-core/src/test/java/org/xbib/rpm/exception/SigningKeyNotFoundExceptionTest.java +++ b/rpm-core/src/test/java/org/xbib/rpm/exception/SigningKeyNotFoundExceptionTest.java @@ -1,8 +1,7 @@ package org.xbib.rpm.exception; -import static org.junit.Assert.assertEquals; - -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.Test; /** * diff --git a/rpm-core/src/test/java/org/xbib/rpm/exception/UnknownArchitectureExceptionTest.java b/rpm-core/src/test/java/org/xbib/rpm/exception/UnknownArchitectureExceptionTest.java index a602716..94d735a 100644 --- a/rpm-core/src/test/java/org/xbib/rpm/exception/UnknownArchitectureExceptionTest.java +++ b/rpm-core/src/test/java/org/xbib/rpm/exception/UnknownArchitectureExceptionTest.java @@ -1,13 +1,13 @@ package org.xbib.rpm.exception; -import static org.junit.Assert.assertEquals; - -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.Test; /** * */ public class UnknownArchitectureExceptionTest { + @Test public void exception() { UnknownArchitectureException ex diff --git a/rpm-core/src/test/java/org/xbib/rpm/exception/UnknownOperatingSystemExceptionTest.java b/rpm-core/src/test/java/org/xbib/rpm/exception/UnknownOperatingSystemExceptionTest.java index 5c0df56..1f8be00 100644 --- a/rpm-core/src/test/java/org/xbib/rpm/exception/UnknownOperatingSystemExceptionTest.java +++ b/rpm-core/src/test/java/org/xbib/rpm/exception/UnknownOperatingSystemExceptionTest.java @@ -1,13 +1,13 @@ package org.xbib.rpm.exception; -import static org.junit.Assert.assertEquals; - -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.Test; /** * */ public class UnknownOperatingSystemExceptionTest { + @Test public void exception() { UnknownOperatingSystemException ex diff --git a/rpm-core/src/test/java/org/xbib/rpm/header/HeaderTest.java b/rpm-core/src/test/java/org/xbib/rpm/header/HeaderTest.java index 882403f..0e0138c 100644 --- a/rpm-core/src/test/java/org/xbib/rpm/header/HeaderTest.java +++ b/rpm-core/src/test/java/org/xbib/rpm/header/HeaderTest.java @@ -1,9 +1,7 @@ package org.xbib.rpm.header; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.Test; import org.xbib.rpm.header.entry.BinSpecEntry; import org.xbib.rpm.header.entry.I18NStringSpecEntry; import org.xbib.rpm.header.entry.Int16SpecEntry; @@ -11,11 +9,10 @@ import org.xbib.rpm.header.entry.Int32SpecEntry; import org.xbib.rpm.header.entry.Int64SpecEntry; import org.xbib.rpm.header.entry.Int8SpecEntry; import org.xbib.rpm.header.entry.SpecEntry; -import org.xbib.rpm.header.entry.StringArraySpecEntry; +import org.xbib.rpm.header.entry.StringListSpecEntry; import org.xbib.rpm.header.entry.StringSpecEntry; - import java.nio.ByteBuffer; -import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; /** * @@ -23,8 +20,7 @@ import java.nio.charset.Charset; public class HeaderTest { @Test - @SuppressWarnings("unchecked") - public void testInt8Single() throws Exception { + public void testInt8Single() { ByteBuffer buffer = ByteBuffer.allocate(1); buffer.put((byte) 1); buffer.flip(); @@ -36,12 +32,11 @@ public class HeaderTest { entry.write(data); data.flip(); buffer.flip(); - assertTrue(buffer.equals(data)); + assertEquals(buffer, data); } @Test - @SuppressWarnings("unchecked") - public void testInt8Multiple() throws Exception { + public void testInt8Multiple() { ByteBuffer buffer = ByteBuffer.allocate(2); buffer.put((byte) 1); buffer.put((byte) 2); @@ -55,238 +50,225 @@ public class HeaderTest { entry.write(data); data.flip(); buffer.flip(); - assertTrue(buffer.equals(data)); + assertEquals(buffer, data); } @Test - @SuppressWarnings("unchecked") - public void testInt16Single() throws Exception { + public void testInt16Single() { ByteBuffer buffer = ByteBuffer.allocate(2); buffer.putShort((short) 1); buffer.flip(); - SpecEntry entry = new Int16SpecEntry(); + SpecEntry entry = new Int16SpecEntry(); entry.setCount(1); entry.read(buffer); - assertEquals(1, entry.getValues()[0]); + assertEquals((short) 1, entry.getValues().get(0)); ByteBuffer data = ByteBuffer.allocate(2); entry.write(data); data.flip(); buffer.flip(); - assertTrue(buffer.equals(data)); + assertEquals(buffer, data); } @Test - @SuppressWarnings("unchecked") - public void testInt16Multiple() throws Exception { + public void testInt16Multiple() { ByteBuffer buffer = ByteBuffer.allocate(4); buffer.putShort((short) 1); buffer.putShort((short) 2); buffer.flip(); - SpecEntry entry = new Int16SpecEntry(); + SpecEntry entry = new Int16SpecEntry(); entry.setCount(2); entry.read(buffer); - assertEquals(1, entry.getValues()[0]); - assertEquals(2, entry.getValues()[1]); + assertEquals((short) 1, entry.getValues().get(0)); + assertEquals((short) 2, entry.getValues().get(1)); ByteBuffer data = ByteBuffer.allocate(4); entry.write(data); data.flip(); buffer.flip(); - assertTrue(buffer.equals(data)); + assertEquals(buffer, data); } @Test - @SuppressWarnings("unchecked") - public void testInt32Single() throws Exception { + public void testInt32Single() { ByteBuffer buffer = ByteBuffer.allocate(4); buffer.putInt(1); buffer.flip(); - SpecEntry entry = new Int32SpecEntry(); + SpecEntry entry = new Int32SpecEntry(); entry.setCount(1); entry.read(buffer); - assertEquals(1, entry.getValues()[0].intValue()); + assertEquals(1, entry.getValues().get(0)); ByteBuffer data = ByteBuffer.allocate(4); entry.write(data); data.flip(); buffer.flip(); - assertTrue(buffer.equals(data)); + assertEquals(buffer, data); } @Test - @SuppressWarnings("unchecked") - public void testInt32Multiple() throws Exception { + public void testInt32Multiple() { ByteBuffer buffer = ByteBuffer.allocate(8); buffer.putInt(1); buffer.putInt(2); buffer.flip(); - SpecEntry entry = new Int32SpecEntry(); + SpecEntry entry = new Int32SpecEntry(); entry.setCount(2); entry.read(buffer); - assertEquals(1, entry.getValues()[0].intValue()); - assertEquals(2, entry.getValues()[1].intValue()); + assertEquals(1, entry.getValues().get(0)); + assertEquals(2, entry.getValues().get(1)); ByteBuffer data = ByteBuffer.allocate(8); entry.write(data); data.flip(); buffer.flip(); - assertTrue(buffer.equals(data)); + assertEquals(buffer, data); } @Test - @SuppressWarnings("unchecked") - public void testInt64Single() throws Exception { + public void testInt64Single() { ByteBuffer buffer = ByteBuffer.allocate(8); buffer.putLong(1); buffer.flip(); - SpecEntry entry = new Int64SpecEntry(); + SpecEntry entry = new Int64SpecEntry(); entry.setCount(1); entry.read(buffer); - assertEquals(1, entry.getValues()[0]); + assertEquals(1, entry.getValues().get(0)); ByteBuffer data = ByteBuffer.allocate(8); entry.write(data); data.flip(); buffer.flip(); - assertTrue(buffer.equals(data)); + assertEquals(buffer, data); } @Test - @SuppressWarnings("unchecked") - public void testInt64Multiple() throws Exception { + public void testInt64Multiple() { ByteBuffer buffer = ByteBuffer.allocate(16); buffer.putLong(1); buffer.putLong(2); buffer.flip(); - SpecEntry entry = new Int64SpecEntry(); + SpecEntry entry = new Int64SpecEntry(); entry.setCount(2); entry.read(buffer); - assertEquals(1, entry.getValues()[0]); - assertEquals(2, entry.getValues()[1]); + assertEquals(1, entry.getValues().get(0)); + assertEquals(2, entry.getValues().get(1)); ByteBuffer data = ByteBuffer.allocate(16); entry.write(data); data.flip(); buffer.flip(); - assertTrue(buffer.equals(data)); + assertEquals(buffer, data); } @Test - @SuppressWarnings("unchecked") - public void testStringSingle() throws Exception { + public void testStringSingle() { ByteBuffer buffer = ByteBuffer.allocate(8); - buffer.put(Charset.forName("US-ASCII").encode("1234567\000")); + buffer.put(StandardCharsets.US_ASCII.encode("1234567\000")); buffer.flip(); - SpecEntry entry = new StringSpecEntry(); + SpecEntry entry = new StringSpecEntry(); entry.setCount(1); entry.read(buffer); - assertEquals("1234567", entry.getValues()[0]); + assertEquals("1234567", entry.getValues().get(0)); ByteBuffer data = ByteBuffer.allocate(8); entry.write(data); data.flip(); buffer.flip(); - assertTrue(buffer.equals(data)); + assertEquals(buffer, data); } @Test - @SuppressWarnings("unchecked") - public void testStringMultiple() throws Exception { + public void testStringMultiple() { ByteBuffer buffer = ByteBuffer.allocate(16); - buffer.put(Charset.forName("US-ASCII").encode("1234567\0007654321\000")); + buffer.put(StandardCharsets.US_ASCII.encode("1234567\0007654321\000")); buffer.flip(); - SpecEntry entry = new StringSpecEntry(); + SpecEntry entry = new StringSpecEntry(); entry.setCount(2); entry.read(buffer); - assertEquals("1234567", entry.getValues()[0]); - assertEquals("7654321", entry.getValues()[1]); + assertEquals("1234567", entry.getValues().get(0)); + assertEquals("7654321", entry.getValues().get(1)); ByteBuffer data = ByteBuffer.allocate(16); entry.write(data); data.flip(); buffer.flip(); - assertTrue(buffer.equals(data)); + assertEquals(buffer, data); } @Test - @SuppressWarnings("unchecked") - public void testBinary() throws Exception { + public void testBinary() { ByteBuffer buffer = ByteBuffer.allocate(8); buffer.put("12345678".getBytes()); buffer.flip(); SpecEntry entry = new BinSpecEntry(); entry.setCount(8); entry.read(buffer); - assertTrue(ByteBuffer.wrap("12345678".getBytes()).equals(ByteBuffer.wrap(entry.getValues()))); + assertEquals(ByteBuffer.wrap("12345678".getBytes()), ByteBuffer.wrap(entry.getValues())); ByteBuffer data = ByteBuffer.allocate(8); entry.write(data); data.flip(); buffer.flip(); - assertTrue(buffer.equals(data)); + assertEquals(buffer, data); } @Test - @SuppressWarnings("unchecked") - public void testStringArraySingle() throws Exception { + public void testStringArraySingle() { ByteBuffer buffer = ByteBuffer.allocate(8); - buffer.put(Charset.forName("US-ASCII").encode("1234567\000")); + buffer.put(StandardCharsets.US_ASCII.encode("1234567\000")); buffer.flip(); - SpecEntry entry = new StringArraySpecEntry(); + SpecEntry entry = new StringListSpecEntry(); entry.setCount(1); entry.read(buffer); - assertEquals("1234567", entry.getValues()[0]); + assertEquals("1234567", entry.getValues().get(0)); ByteBuffer data = ByteBuffer.allocate(8); entry.write(data); data.flip(); buffer.flip(); - assertTrue(buffer.equals(data)); + assertEquals(buffer, data); } @Test - @SuppressWarnings("unchecked") - public void testStringArrayMultiple() throws Exception { + public void testStringArrayMultiple() { ByteBuffer buffer = ByteBuffer.allocate(16); - buffer.put(Charset.forName("US-ASCII").encode("1234567\000")); - buffer.put(Charset.forName("US-ASCII").encode("7654321\000")); + buffer.put(StandardCharsets.US_ASCII.encode("1234567\000")); + buffer.put(StandardCharsets.US_ASCII.encode("7654321\000")); buffer.flip(); - SpecEntry entry = new StringArraySpecEntry(); + SpecEntry entry = new StringListSpecEntry(); entry.setCount(2); entry.read(buffer); - assertEquals("1234567", entry.getValues()[0]); - assertEquals("7654321", entry.getValues()[1]); + assertEquals("1234567", entry.getValues().get(0)); + assertEquals("7654321", entry.getValues().get(1)); ByteBuffer data = ByteBuffer.allocate(16); entry.write(data); data.flip(); buffer.flip(); - assertTrue(buffer.equals(data)); + assertEquals(buffer, data); } @Test - @SuppressWarnings("unchecked") - public void testI18NStringSingle() throws Exception { + public void testI18NStringSingle() { ByteBuffer buffer = ByteBuffer.allocate(8); - buffer.put(Charset.forName("US-ASCII").encode("1234567\000")); + buffer.put(StandardCharsets.US_ASCII.encode("1234567\000")); buffer.flip(); - SpecEntry entry = new I18NStringSpecEntry(); + SpecEntry entry = new I18NStringSpecEntry(); entry.setCount(1); entry.read(buffer); - assertEquals("1234567", entry.getValues()[0]); + assertEquals("1234567", entry.getValues().get(0)); ByteBuffer data = ByteBuffer.allocate(8); entry.write(data); data.flip(); buffer.flip(); - assertTrue(buffer.equals(data)); + assertEquals(buffer, data); } @Test - @SuppressWarnings("unchecked") - public void testI18NStringMultiple() throws Exception { + public void testI18NStringMultiple() { ByteBuffer buffer = ByteBuffer.allocate(16); - buffer.put(Charset.forName("US-ASCII").encode("1234567\000")); - buffer.put(Charset.forName("US-ASCII").encode("7654321\000")); + buffer.put(StandardCharsets.US_ASCII.encode("1234567\000")); + buffer.put(StandardCharsets.US_ASCII.encode("7654321\000")); buffer.flip(); - SpecEntry entry = new I18NStringSpecEntry(); + SpecEntry entry = new I18NStringSpecEntry(); entry.setCount(2); entry.read(buffer); - assertEquals("1234567", entry.getValues()[0]); - assertEquals("7654321", entry.getValues()[1]); + assertEquals("1234567", entry.getValues().get(0)); + assertEquals("7654321", entry.getValues().get(1)); ByteBuffer data = ByteBuffer.allocate(16); entry.write(data); data.flip(); buffer.flip(); - assertTrue(buffer.equals(data)); + assertEquals(buffer, data); } } diff --git a/rpm-core/src/test/java/org/xbib/rpm/payload/ContentsTest.java b/rpm-core/src/test/java/org/xbib/rpm/payload/ContentsTest.java index fd84129..cfa6db2 100644 --- a/rpm-core/src/test/java/org/xbib/rpm/payload/ContentsTest.java +++ b/rpm-core/src/test/java/org/xbib/rpm/payload/ContentsTest.java @@ -1,14 +1,17 @@ package org.xbib.rpm.payload; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.Is.is; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThat; - -import org.junit.Test; - +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.xbib.rpm.payload.CpioHeader.DIR; +import org.junit.jupiter.api.Test; +import java.io.IOException; import java.nio.file.Paths; import java.util.ArrayList; +import java.util.EnumSet; import java.util.HashMap; +import java.util.Iterator; +import java.util.List; import java.util.Map; /** @@ -17,8 +20,8 @@ import java.util.Map; public class ContentsTest { @Test - public void testListParents() throws Exception { - ArrayList list = new ArrayList<>(); + public void testListParents() { + List list = new ArrayList<>(); new Contents().listParents(list, Paths.get("/one/two/three/four")); assertEquals(3, list.size()); assertEquals("/one/two/three", list.get(0)); @@ -27,8 +30,8 @@ public class ContentsTest { } @Test - public void testListParentsBuiltin() throws Exception { - ArrayList list = new ArrayList<>(); + public void testListParentsBuiltin() { + List list = new ArrayList<>(); new Contents().listParents(list, Paths.get("/bin/one/two/three/four")); assertEquals(3, list.size()); assertEquals("/bin/one/two/three", list.get(0)); @@ -37,8 +40,8 @@ public class ContentsTest { } @Test - public void testListParentsNewLocalBuiltin() throws Exception { - ArrayList list = new ArrayList<>(); + public void testListParentsNewLocalBuiltin() { + List list = new ArrayList<>(); Contents contents = new Contents(); contents.addLocalBuiltinDirectory("/home"); contents.listParents(list, Paths.get("/home/one/two/three/four")); @@ -49,10 +52,11 @@ public class ContentsTest { } @Test - public void testAddFileSetsDirModeOnHeader() throws Exception { + public void testAddFileSetsDirModeOnHeader() throws IOException { Contents contents = new Contents(); contents.addFile("/test/file.txt", Paths.get("src/test/resources/test.txt"), - 511, null, "testuser", "testgroup", 73); + 511, 73,null, + "testuser", "testgroup", 0, 0, true, -1); Iterable headers = contents.headers(); Map filemodes = new HashMap<>(); for (CpioHeader header : headers) { @@ -61,4 +65,52 @@ public class ContentsTest { assertThat(filemodes.get("/test"), is(73)); assertThat(filemodes.get("/test/file.txt"), is(511)); } + + @Test + public void testAddDirectory() { + Contents contents = new Contents(); + addDirectoryWithParents(contents, "test"); + Iterable headers = contents.headers(); + CpioHeader header = headers.iterator().next(); + assertThat("test", is(header.name)); + assertThat(DIR, is(header.type)); + } + + @Test + public void testAddNestedDirectory() { + Contents contents = new Contents(); + addDirectoryWithParents(contents, "test1/test2/test3"); + Iterable headers = contents.headers(); + Iterator iterator = headers.iterator(); + CpioHeader header = iterator.next(); + assertThat("test1", is(header.name)); + assertThat(DIR, is(header.type)); + header = iterator.next(); + assertThat("test1/test2", is(header.name)); + assertThat(DIR, is(header.type)); + header = iterator.next(); + assertThat("test1/test2/test3", is(header.name)); + assertThat(DIR, is(header.type)); + } + + @Test + public void testAddNestedDirectoryWithoutParents() { + Contents contents = new Contents(); + addDirectoryWithoutParents(contents, "test1/test2/test3"); + Iterable headers = contents.headers(); + Iterator iterator = headers.iterator(); + CpioHeader header = iterator.next(); + assertThat("test1/test2/test3", is(header.name)); + assertThat(DIR, is(header.type)); + } + + private void addDirectoryWithParents(Contents contents, String path) { + contents.addDirectory(path, 0, + EnumSet.of(Directive.NONE), null, null, 0,0, true); + } + + private void addDirectoryWithoutParents(Contents contents, String path) { + contents.addDirectory(path, 0, + EnumSet.of(Directive.NONE), null, null, 0,0, false); + } } diff --git a/rpm-core/src/test/java/org/xbib/rpm/security/PrintPublicKeyTest.java b/rpm-core/src/test/java/org/xbib/rpm/security/PrintPublicKeyTest.java index 97cebe7..a5941db 100644 --- a/rpm-core/src/test/java/org/xbib/rpm/security/PrintPublicKeyTest.java +++ b/rpm-core/src/test/java/org/xbib/rpm/security/PrintPublicKeyTest.java @@ -1,8 +1,7 @@ package org.xbib.rpm.security; import org.bouncycastle.openpgp.PGPException; -import org.junit.Test; - +import org.junit.jupiter.api.Test; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; diff --git a/rpm-core/src/test/java/org/xbib/rpm/security/SignatureGeneratorTest.java b/rpm-core/src/test/java/org/xbib/rpm/security/SignatureGeneratorTest.java index 7174f0e..78da06c 100644 --- a/rpm-core/src/test/java/org/xbib/rpm/security/SignatureGeneratorTest.java +++ b/rpm-core/src/test/java/org/xbib/rpm/security/SignatureGeneratorTest.java @@ -1,14 +1,15 @@ package org.xbib.rpm.security; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertTrue; +import org.bouncycastle.openpgp.PGPException; +import org.junit.jupiter.api.Test; import org.xbib.rpm.RpmBuilder; +import org.xbib.rpm.exception.RpmException; import org.xbib.rpm.lead.Architecture; import org.xbib.rpm.lead.Os; import org.xbib.rpm.lead.PackageType; import org.xbib.rpm.payload.Directive; - +import java.io.IOException; import java.nio.file.Files; import java.nio.file.Paths; import java.util.EnumSet; @@ -19,7 +20,7 @@ import java.util.EnumSet; public class SignatureGeneratorTest { @Test - public void testReadingFirstKey() throws Exception { + public void testReadingFirstKey() { SignatureGenerator generator = new SignatureGenerator(getClass().getResourceAsStream("/pgp/test-secring.gpg"), null, "test"); @@ -27,7 +28,7 @@ public class SignatureGeneratorTest { } @Test - public void testFindByKey() throws Exception { + public void testFindByKey() { SignatureGenerator generator = new SignatureGenerator(getClass().getResourceAsStream("/pgp/test-secring.gpg"), 0xF02C6D2CL, "test"); @@ -35,7 +36,7 @@ public class SignatureGeneratorTest { } @Test - public void testBuildWithTestSignature() throws Exception { + public void testBuildWithTestSignature() throws IOException, PGPException, RpmException { String pubRing = "build/test-pubring.gpg"; String secRing = "build/test-secring.gpg"; String id = "test@example.com"; @@ -65,12 +66,12 @@ public class SignatureGeneratorTest { rpmBuilder.setPrivateKeyPassphrase(pass); EnumSet directives = EnumSet.of(Directive.CONFIG, Directive.DOC, Directive.NOREPLACE); rpmBuilder.addFile("/etc", Paths.get("src/test/resources/prein.sh"), 493, 493, - directives, "jabberwocky", "vorpal"); + directives, "jabberwocky", "vorpal", true); rpmBuilder.build(Paths.get("build")); } @Test - public void testBuildWithSignature() throws Exception { + public void testBuildWithSignature() throws IOException, RpmException { String secRing = "src/test/resources/pgp/test-secring.gpg"; String pass = "test"; RpmBuilder rpmBuilder = new RpmBuilder(); @@ -83,5 +84,4 @@ public class SignatureGeneratorTest { rpmBuilder.setPrivateKeyPassphrase(pass); rpmBuilder.build(Paths.get("build")); } - } diff --git a/rpm-core/src/test/java/org/xbib/rpm/security/SignatureReaderTest.java b/rpm-core/src/test/java/org/xbib/rpm/security/SignatureReaderTest.java index 28e940f..9e28ab5 100644 --- a/rpm-core/src/test/java/org/xbib/rpm/security/SignatureReaderTest.java +++ b/rpm-core/src/test/java/org/xbib/rpm/security/SignatureReaderTest.java @@ -1,8 +1,7 @@ package org.xbib.rpm.security; -import static org.junit.Assert.assertNotNull; - -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import org.junit.jupiter.api.Test; import org.xbib.rpm.RpmReader; import org.xbib.rpm.format.Format; import org.xbib.rpm.signature.SignatureHeader; @@ -18,7 +17,7 @@ public class SignatureReaderTest { @Test public void readBadSignedRpm() throws Exception { RpmReader rpmReader = new RpmReader(); - Format format = rpmReader.read(Paths.get("src/test/resources/signature-my-ring-test-1.0-1.noarch.rpm")); + Format format = rpmReader.readFormat(Paths.get("src/test/resources/signature-my-ring-test-1.0-1.noarch.rpm")); SignatureHeader signatureHeader = format.getSignatureHeader(); assertNotNull(signatureHeader.getEntry(SignatureTag.RSAHEADER)); assertNotNull(signatureHeader.getEntry(SignatureTag.LEGACY_PGP)); @@ -27,7 +26,7 @@ public class SignatureReaderTest { @Test public void readGoodSignedRpm() throws Exception { RpmReader rpmReader = new RpmReader(); - Format format = rpmReader.read(Paths.get("src/test/resources/signing-test-1.0-1.noarch.rpm")); + Format format = rpmReader.readFormat(Paths.get("src/test/resources/signing-test-1.0-1.noarch.rpm")); SignatureHeader signatureHeader = format.getSignatureHeader(); assertNotNull(signatureHeader.getEntry(SignatureTag.RSAHEADER)); assertNotNull(signatureHeader.getEntry(SignatureTag.LEGACY_PGP)); diff --git a/settings.gradle b/settings.gradle index 6b0001a..a47167e 100644 --- a/settings.gradle +++ b/settings.gradle @@ -2,5 +2,5 @@ rootProject.name = name include 'rpm-core' include 'rpm-ant' -include 'gradle-plugin-rpm' include 'maven-plugin-rpm' +include 'gradle-plugin-rpm'