diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000..b5e4a3ad39 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +*~ +target +.repository diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000000..6cd83d42cd --- /dev/null +++ b/pom.xml @@ -0,0 +1,286 @@ + + + + 4.0.0 + + org.quattor.release + release-pom + 12.11-SNAPSHOT + Quattor Release (POM) + + http://quattor.org + + + Utilities for creating a Quattor YUM repository from maven artifacts. + + + pom + + + + Apache 2 + http://www.apache.org/licenses/LICENSE-2.0.txt + + + + + Quattor + http://quattor.org/ + + + + GitHub Issues + https://github.com/quattor/release/issues + + + + Jenkins + https://jenkins1.ugent.be/ + + + + git@github.com:quattor/release.git + git@github.com:quattor/release.git + + + + + + + true + always + fail + + + false + never + fail + + QuattorReleases + Quattor Releases + http://stratuslab-srv01.lal.in2p3.fr:8081/content/repositories/quattor-releases + default + + + + + true + always + fail + + + true + always + fail + + QuattorSnapshots + Quattor Snapshots + http://stratuslab-srv01.lal.in2p3.fr:8081/content/repositories/quattor-snapshots + default + + + + + + + quattor.releases + Releases + http://stratuslab-srv01.lal.in2p3.fr:8081/content/repositories/quattor-releases + + + quattor.snapshots + Snapshots + http://stratuslab-srv01.lal.in2p3.fr:8081/content/repositories/quattor-snapshots + + + + + + org.quattor.pan + panc-rpm + 9.2 + rpm + + + org.quattor.cfg.module + accounts + 7.0.0-SNAPSHOT + rpm + rpm + + + + + + + + + org.apache.maven.plugins + maven-clean-plugin + 2.4.1 + + + org.apache.maven.plugins + maven-deploy-plugin + 2.6 + + + + org.apache.maven.plugins + maven-dependency-plugin + 2.3 + + + false + version + false + rpm,zip,tar.gz + true + + + + + + purge-repository-copy-dependencies + prepare-package + + + copy-dependencies + + + + + + + + org.apache.maven.plugins + maven-install-plugin + 2.3.1 + + + org.apache.maven.plugins + maven-jar-plugin + 2.3.1 + + + org.apache.maven.plugins + maven-war-plugin + 2.1.1 + + + org.apache.maven.plugins + maven-resources-plugin + 2.5 + + UTF-8 + + + + org.apache.maven.plugins + maven-site-plugin + 2.3 + + + org.apache.maven.plugins + maven-surefire-plugin + 2.9 + + + org.apache.maven.plugins + maven-compiler-plugin + 2.3.2 + + UTF-8 + 1.5 + 1.5 + + + + org.apache.maven.plugins + maven-javadoc-plugin + 2.8 + + UTF-8 + + + + org.apache.maven.plugins + maven-assembly-plugin + 2.2.1 + + + + org.codehaus.mojo + exec-maven-plugin + 1.2.1 + + + create-yum-repo + package + + src/scripts/create-yum-repo.pl + + ${basedir}/target/dependency + ${basedir}/target/yum + + + + exec + + + + + + + org.codehaus.mojo + findbugs-maven-plugin + 2.3.2 + + + + org.codehaus.mojo + jdepend-maven-plugin + 2.0-beta-2 + + + + org.codehaus.mojo + versions-maven-plugin + 1.2 + + + + + + + + + + org.codehaus.mojo + versions-maven-plugin + + true + true + false + + + + + maven-dependency-plugin + + + + + + + + + diff --git a/src/scripts/create-yum-repo.pl b/src/scripts/create-yum-repo.pl new file mode 100755 index 0000000000..cbc2e83e24 --- /dev/null +++ b/src/scripts/create-yum-repo.pl @@ -0,0 +1,108 @@ +#!/usr/bin/perl -w + +use strict; + +use File::Path qw(mkpath rmtree); +use File::Find; +use File::Copy qw(mv cp); +use File::Basename; + +our %links; + +# +# Create RPM symlinks with correct names in destination. +# +sub move_and_rename_rpms { + my ($src, $dest) = @_; + + %links = (); + + find(\&treat_rpm, $src); + find(\&treat_zips_tarballs, $src); + + for my $key (sort keys %links) { + my $link = "${dest}/$key"; + if (!-l $link) { + cp($links{$key}, $link); + } + } +} + + +# +# Collect source file name and 'internal' name from RPMs. +# +sub treat_rpm { + if (/^.*\.rpm$/) { + my $n = translate_rpm_name($File::Find::name); + if ($links{$n}) { + # Ignore collisions for now. + #print "COLLISION: $n\n"; + #print "CURRENT: $File::Find::name\n"; + #print "EXISTING: $links{$n}\n"; + } else { + $links{$n} = $File::Find::name; + } + } +} + +# +# Collect zip archives and tarballs. +# +sub treat_zips_tarballs { + if (/^.*\.zip$/) { + my ($n, $path, $suffix) = fileparse($File::Find::name); + $links{$n} = $File::Find::name; + } + if (/^.*\.tar.gz$/) { + my ($n, $path, $suffix) = fileparse($File::Find::name); + $links{$n} = $File::Find::name; + } +} + +# +# Update the yum repository at the given location. +# +sub update_yum_metadata { + my ($repo) = @_; + `createrepo --update --checkts --pretty ${repo}` || + die "Failed to update yum repo metadata\n"; +} + +# +# Use internal rpm information to generate output filename. +# The filename must include the full path to the RPM package. +# +sub translate_rpm_name { + my ($filename) = @_; + return `rpm -qp --qf "%{N}-%{V}-%{R}.%{ARCH}.rpm" ${filename}`; +} + +############################################################ + +# +# Get the nexus and yum repository names. +# +my $nexus_repo_name = shift or die "must supply nexus repository name"; +my $yum_repo_name = shift or die "must supply yum repository name"; + +# +# Create the absolute paths for these repositories. +# +my $nexus_packages = "${nexus_repo_name}"; +my $externals = '/var/www/yum/externals'; +my $yum_repo = "${yum_repo_name}"; + +# +# Create the output yum repository if it doesn't exist already. +# +mkpath(${yum_repo}); + +# +# Do the actual update of the repository. +# +move_and_rename_rpms($nexus_packages, $yum_repo); + +#create_rpm_symlinks($externals, $yum_repo); + +update_yum_metadata($yum_repo);