Skip to content

Commit

Permalink
Merge pull request #4 from hhovsepy/master
Browse files Browse the repository at this point in the history
Some modiications in generating erratas and in names of packages.
  • Loading branch information
mccun934 committed May 2, 2013
2 parents b76e0da + e845e67 commit 1245b35
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
6 changes: 3 additions & 3 deletions errata-template.xml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<update from="[email protected]" status="stable" type="security" version="1">
<update from="[email protected]" status="stable" type="%%TYPE%%" version="1">
<id>%%ERRATAID%%</id>
<title>%%NAME%%_Erratum</title>
<release>%%REL%%</release>
<issued date="2012-01-27 16:08:09"/>
<issued date="%%DATE%%"/>
<description>%%NAME%%_Erratum description</description>
<pkglist>
<collection short="">
<name>1</name>
<package arch="noarch" name="%%NAME%%" release="%%REL%%" src="http://www.fedoraproject.org" version="%%VER%%">
<filename>%%NAME%%-%%VER%%-%%REL%%.elfake.noarch.rpm</filename>
<filename>%%NAME%%-%%VER%%-%%REL%%.noarch.rpm</filename>
</package>
</collection>
</pkglist>
Expand Down
20 changes: 13 additions & 7 deletions generate-repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,19 @@
import os
import shutil
from optparse import OptionParser
import datetime

TYPES = ["security","bugfix","enhancement"]
FORMAT = "%Y-%m-%d %H:%M:%S"

def generate_errata(template, last_rev, name, version):
errata = template
errata = errata.replace("%%ERRATAID%%",('RHEA-2012:%s' % random.randint(1,10000)))
errata = errata.replace("%%REL%%", str(last_rev))
errata = errata.replace("%%NAME%%", name)
errata = errata.replace("%%VER%%", version)
errata = errata.replace("%%TYPE%%", TYPES[random.randint(0,2)])
errata = errata.replace("%%DATE%%", datetime.date(datetime.date.today().year - 1, random.randint(1,12), random.randint(1,28)).strftime(FORMAT))
return errata


Expand Down Expand Up @@ -105,21 +111,21 @@ def generate_repo(output, number, size, multiples, dictionary):
if multiples:
# Counter to increment revision version
last_rev = int(version[-1])
# Generate 0-3 newer versions of the package
for j in range(random.randint(0,3)):
# Generate 1-3 newer versions of the package
for j in range(random.randint(1,3)):

last_rev += 1
new_version = version[:-1] + str(last_rev)
shell_exec("./generate-package.bash %s %s %s" % (package_name, new_version, package_size))
# Generate some errata
all_errata += generate_errata(errata_template, last_rev, package_name, version)
# Generate some errata
all_errata += generate_errata(errata_template, "1", package_name, new_version)

# Generate one specific package name you know is always there with multiple revs
shell_exec("./generate-package.bash acme-package 1.0.1 1")
shell_exec("./generate-package.bash acme-package 1.0.2 1")
all_errata += generate_errata(errata_template, "1.0.1 ", "acme-package", "1.0.2")
all_errata += generate_errata(errata_template, "1", "acme-package", "1.0.2")
shell_exec("./generate-package.bash acme-package 1.1.2 1")
all_errata += generate_errata(errata_template, "1.0.2 ", "acme-package", "1.1.2")
all_errata += generate_errata(errata_template, "1", "acme-package", "1.1.2")


#bad string concats but I'm lazy
Expand All @@ -135,7 +141,7 @@ def generate_repo(output, number, size, multiples, dictionary):
sys.exit(-1)


os.system("mv ~/rpmbuild/RPMS/noarch/*elfake* %s" % output)
os.system("mv ~/rpmbuild/RPMS/noarch/* %s" % output)
os.system("createrepo %s" % output)
os.system("modifyrepo %s/updateinfo.xml %s/repodata/" % (output,output))

Expand Down
2 changes: 1 addition & 1 deletion specfile-template.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Name: %%NAME%%
Version: %%VERSION%%
Release: 1.elfake
Release: 1
Summary: %{name} package

Group: Development/Libraries
Expand Down

0 comments on commit 1245b35

Please sign in to comment.