[copr] master: Automatic commit of package [copr-dist-git] release [0.11-1]. (2e66e0a)
by clime@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : master
>---------------------------------------------------------------
commit 2e66e0a5654408801f903406871e44d0a4d88f17
Author: clime <clime(a)redhat.com>
Date: Thu Jan 21 11:02:53 2016 +0100
Automatic commit of package [copr-dist-git] release [0.11-1].
>---------------------------------------------------------------
.tito/packages/copr-dist-git | 1 +
dist-git/copr-dist-git.spec | 5 ++++-
2 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/.tito/packages/copr-dist-git b/.tito/packages/copr-dist-git
new file mode 100644
index 0000000..8d0dda7
--- /dev/null
+++ b/.tito/packages/copr-dist-git
@@ -0,0 +1 @@
+0.11-1 dist-git/
diff --git a/dist-git/copr-dist-git.spec b/dist-git/copr-dist-git.spec
index 529dcf3..ebe9c19 100644
--- a/dist-git/copr-dist-git.spec
+++ b/dist-git/copr-dist-git.spec
@@ -1,5 +1,5 @@
Name: copr-dist-git
-Version: 0.10
+Version: 0.11
Release: 1%{?dist}
Summary: Copr services for Dist Git server
@@ -101,6 +101,9 @@ restorecon -rv /var/lib/copr-dist-git
%ghost %{_var}/log/copr-dist-git/*.log
%changelog
+* Thu Jan 21 2016 clime <clime(a)redhat.com> 0.11-1
+- tito added to requirements
+
* Sat Jan 16 2016 clime <clime(a)redhat.com> 0.10-1
- fixed do_import test
- workaround for BZ 1283101
8 years, 4 months
[copr] master: [copr-dist-git] tito added as Requirement to .spec (74a739f)
by clime@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : master
>---------------------------------------------------------------
commit 74a739ff2e3f962e8b3f60ca6f0790d0ec45fd60
Author: clime <clime(a)redhat.com>
Date: Thu Jan 21 10:57:24 2016 +0100
[copr-dist-git] tito added as Requirement to .spec
>---------------------------------------------------------------
dist-git/copr-dist-git.spec | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/dist-git/copr-dist-git.spec b/dist-git/copr-dist-git.spec
index 63b7e1c..529dcf3 100644
--- a/dist-git/copr-dist-git.spec
+++ b/dist-git/copr-dist-git.spec
@@ -34,6 +34,7 @@ Requires: python-bunch
Requires: python-requests
Requires: pyrpkg
Requires: mock-scm
+Requires: tito
%description
COPR is lightweight build system. It allows you to create new project in WebUI
8 years, 4 months
[copr] master: [prunerepo] small man pages polishing (1c68d61)
by clime@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : master
>---------------------------------------------------------------
commit 1c68d614255a89706a03dee6b30ae10fe1681844
Author: clime <clime(a)redhat.com>
Date: Thu Jan 21 10:11:30 2016 +0100
[prunerepo] small man pages polishing
>---------------------------------------------------------------
prunerepo/man/prunerepo.1.asciidoc | 5 ++---
1 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/prunerepo/man/prunerepo.1.asciidoc b/prunerepo/man/prunerepo.1.asciidoc
index 04c6817..8ef69fb 100644
--- a/prunerepo/man/prunerepo.1.asciidoc
+++ b/prunerepo/man/prunerepo.1.asciidoc
@@ -26,6 +26,7 @@ After deletion of obsoleted packages, the command
"createrepo_c --database --update" is called
to recreate the repository metadata.
+
ARGUMENTS
---------
path::
@@ -55,9 +56,6 @@ OPTIONS
-v, --version::
print program version and exit
--h, --help::
- show this help message and exit
-
EXAMPLES
--------
@@ -73,6 +71,7 @@ prunerepo /path/to/repo --days 7::
prunerepo /path/to/repo --days 7 --nocreaterepo::
the same thing but omits call to createrepo_c at the end
+
AUTHORS
-------
Michal Novotny <clime(a)redhat.com>
8 years, 4 months
[copr] master: [prunerepo] test suite finished (3adc56d)
by clime@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : master
>---------------------------------------------------------------
commit 3adc56d0ca0ff36be1176365be9d0874b488b263
Author: clime <clime(a)redhat.com>
Date: Thu Jan 21 10:07:38 2016 +0100
[prunerepo] test suite finished
>---------------------------------------------------------------
prunerepo/tests/test.sh | 44 ++++++++++++++++++++++++++++++++++++++------
1 files changed, 38 insertions(+), 6 deletions(-)
diff --git a/prunerepo/tests/test.sh b/prunerepo/tests/test.sh
index 21cbdd4..780bf84 100755
--- a/prunerepo/tests/test.sh
+++ b/prunerepo/tests/test.sh
@@ -32,7 +32,8 @@ function run {
}
function setup {
- cp -aT $origrepo $testrepo
+ rm -r $testrepo
+ cp -r $origrepo $testrepo
cd $testrepo
}
@@ -65,22 +66,53 @@ run "ls build-3.log" || die
echo success.
-echo "============================ test --nocreaterepo ============================"; #TODO
+echo "============================ test --days ============================";
setup
-runcmd --days 7 .
+
+echo $testrepo
+oldestbuilddate=`rpm -qp --queryformat '%{BUILDTIME:date}' $testrepo/0-oldestbuild/example-1.0.1-1.fc23.x86_64.rpm 2> /dev/null`
+oldestbuilddayback=$(( (`date +'%s'` - `date -d "$oldestbuilddate" +'%s'`)/60/60/24 ))
+
+runcmd --days $oldestbuilddayback .
+
+run 'ls 0-oldestbuild/*.rpm' && die
+run '[[ `ls 2-secondlatestpkg/*.rpm | wc -l` == 3 ]]' || die
+run '[[ `ls 3-latestpkg/*.rpm | wc -l` == 3 ]]' || die
+
echo success.
-echo "============================ test --days ============================"; #TODO
+echo "============================ test --nocreaterepo ============================";
setup
-runcmd --days 7 .
+
+repomdlastmodtime1=`stat -c '%Y' $testrepo/repodata/repomd.xml`
+run '[[ `listpkgsbyfs` == `listpkgsbyrepo` ]]' || die
+
+runcmd --nocreaterepo .
+
+run '[[ `listpkgsbyfs` == `listpkgsbyrepo` ]]' && die
+run '[[ $repomdlastmodtime1 == `stat -c '%Y' $testrepo/repodata/repomd.xml` ]]' || die
+
echo success.
-echo "============================ test no dnf caching ============================"; #TODO
+echo "============================ test repo data always fresh (no dnf cache used) ============================";
setup
+
+runcmd .
+
+run 'ls 2-secondlatestpkg/*.rpm' && die
+run '[[ `ls 3-latestpkg/*.rpm | wc -l` == 3 ]]' || die
+
+setup
+
+run 'rm -r $testrepo/3-latestpkg'
+run 'createrepo_c $testrepo'
+
runcmd .
+run '[[ `ls 2-secondlatestpkg/*.rpm | wc -l` == 3 ]]' || die
+
echo success.
exit 0
8 years, 4 months
[copr] master: [prunerepo] tests added, 3 tests to finish (f0c6abb)
by clime@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : master
>---------------------------------------------------------------
commit f0c6abbff683893b1d0b0161ea407c7bbb760ed0
Author: clime <clime(a)redhat.com>
Date: Wed Jan 20 17:33:42 2016 +0100
[prunerepo] tests added, 3 tests to finish
>---------------------------------------------------------------
prunerepo/.gitignore | 2 +-
.../0-oldestbuild}/build-00149006.rsync.log | 0
.../0-oldestbuild}/build.info | 0
.../0-oldestbuild}/build.log.gz | Bin 1380 -> 1380 bytes
.../0-oldestbuild}/example-1.0.1-1.fc23.src.rpm | Bin 19729 -> 19729 bytes
.../0-oldestbuild}/example-1.0.1-1.fc23.x86_64.rpm | Bin 9750 -> 9750 bytes
.../example-debuginfo-1.0.1-1.fc23.x86_64.rpm | Bin 9462 -> 9462 bytes
.../0-oldestbuild}/mockchain.log.gz | Bin 2405 -> 2405 bytes
.../0-oldestbuild}/root.log.gz | Bin 16836 -> 16836 bytes
.../0-oldestbuild}/state.log.gz | Bin 237 -> 237 bytes
.../0-oldestbuild}/success | 0
.../1-norpmsinside}/build-00151843.rsync.log | 0
.../1-norpmsinside}/build.info | 0
.../1-norpmsinside}/build.log.gz | Bin 1023 -> 1023 bytes
.../fedora-23-x86_64-template/1-norpmsinside}/fail | 0
.../1-norpmsinside}/mockchain.log.gz | Bin 1438 -> 1438 bytes
.../1-norpmsinside}/root.log.gz | Bin 16792 -> 16792 bytes
.../1-norpmsinside}/state.log.gz | Bin 231 -> 231 bytes
.../2-secondlatestpkg}/build-00151846.rsync.log | 0
.../2-secondlatestpkg}/build.info | 0
.../2-secondlatestpkg}/build.log.gz | Bin 1381 -> 1381 bytes
.../example-1.0.2-2.fc23.src.rpm | Bin 19741 -> 19741 bytes
.../example-1.0.2-2.fc23.x86_64.rpm | Bin 9758 -> 9758 bytes
.../example-debuginfo-1.0.2-2.fc23.x86_64.rpm | Bin 9458 -> 9458 bytes
.../2-secondlatestpkg}/mockchain.log.gz | Bin 2806 -> 2806 bytes
.../2-secondlatestpkg}/root.log.gz | Bin 16815 -> 16815 bytes
.../2-secondlatestpkg}/state.log.gz | Bin 238 -> 238 bytes
.../2-secondlatestpkg}/success | 0
.../3-latestpkg}/build-00151846.rsync.log | 0
.../3-latestpkg}/build.info | 0
.../3-latestpkg}/build.log.gz | Bin 1381 -> 1381 bytes
.../3-latestpkg}/example-1.0.3-2.fc23.src.rpm | Bin 18803 -> 18803 bytes
.../3-latestpkg}/example-1.0.3-2.fc23.x86_64.rpm | Bin 9186 -> 9186 bytes
.../example-debuginfo-1.0.3-2.fc23.x86_64.rpm | Bin 8886 -> 8886 bytes
.../3-latestpkg}/mockchain.log.gz | Bin 2806 -> 2806 bytes
.../3-latestpkg}/root.log.gz | Bin 16815 -> 16815 bytes
.../3-latestpkg}/state.log.gz | Bin 238 -> 238 bytes
.../fedora-23-x86_64-template/3-latestpkg}/success | 0
.../appdata/appstream-failed.xml.gz | Bin 131 -> 131 bytes
.../appdata/appstream-ignore.xml.gz | Bin 264 -> 264 bytes
.../appdata/appstream.xml.gz | Bin 126 -> 126 bytes
.../tests/fedora-23-x86_64-template/build-0.log | 0
.../tests/fedora-23-x86_64-template/build-1.log | 0
.../tests/fedora-23-x86_64-template/build-2.log | 0
.../tests/fedora-23-x86_64-template/build-3.log | 0
...edbad50cf112d6a77a8d2ae0625845b5-primary.xml.gz | Bin 0 -> 1673 bytes
...8d1bd82847fdb6961befad2dbc9855-filelists.xml.gz | Bin 0 -> 796 bytes
...b7647458e05b14d7851bb408d71dcb-other.sqlite.bz2 | Bin 0 -> 1817 bytes
...edb15af72376bd35091beed70f92-primary.sqlite.bz2 | Bin 0 -> 3762 bytes
...044cb687492ff4b3f3c1bbb1bf-filelists.sqlite.bz2 | Bin 0 -> 2036 bytes
...8bbf78457a143ae6a9bfaf60b3dea1a272-other.xml.gz | Bin 0 -> 805 bytes
.../fedora-23-x86_64-template/repodata/repomd.xml | 55 +++++++++++++
prunerepo/tests/test.sh | 86 ++++++++++++++++++++
53 files changed, 142 insertions(+), 1 deletions(-)
diff --git a/prunerepo/.gitignore b/prunerepo/.gitignore
index 2b29f27..5f7627a 100644
--- a/prunerepo/.gitignore
+++ b/prunerepo/.gitignore
@@ -1 +1 @@
-tests
+tests/fedora-23-x86_64-test
diff --git a/copr-prune-repo/tests/fedora-23-x86_64-template/1-success1/build-00149006.rsync.log b/prunerepo/tests/fedora-23-x86_64-template/0-oldestbuild/build-00149006.rsync.log
similarity index 100%
copy from copr-prune-repo/tests/fedora-23-x86_64-template/1-success1/build-00149006.rsync.log
copy to prunerepo/tests/fedora-23-x86_64-template/0-oldestbuild/build-00149006.rsync.log
diff --git a/copr-prune-repo/tests/fedora-23-x86_64-template/1-success1/build.info b/prunerepo/tests/fedora-23-x86_64-template/0-oldestbuild/build.info
similarity index 100%
copy from copr-prune-repo/tests/fedora-23-x86_64-template/1-success1/build.info
copy to prunerepo/tests/fedora-23-x86_64-template/0-oldestbuild/build.info
diff --git a/copr-prune-repo/tests/fedora-23-x86_64-template/1-success1/build.log.gz b/prunerepo/tests/fedora-23-x86_64-template/0-oldestbuild/build.log.gz
similarity index 100%
copy from copr-prune-repo/tests/fedora-23-x86_64-template/1-success1/build.log.gz
copy to prunerepo/tests/fedora-23-x86_64-template/0-oldestbuild/build.log.gz
diff --git a/copr-prune-repo/tests/fedora-23-x86_64-template/1-success1/example-1.0.1-1.fc23.src.rpm b/prunerepo/tests/fedora-23-x86_64-template/0-oldestbuild/example-1.0.1-1.fc23.src.rpm
similarity index 100%
copy from copr-prune-repo/tests/fedora-23-x86_64-template/1-success1/example-1.0.1-1.fc23.src.rpm
copy to prunerepo/tests/fedora-23-x86_64-template/0-oldestbuild/example-1.0.1-1.fc23.src.rpm
diff --git a/copr-prune-repo/tests/fedora-23-x86_64-template/1-success1/example-1.0.1-1.fc23.x86_64.rpm b/prunerepo/tests/fedora-23-x86_64-template/0-oldestbuild/example-1.0.1-1.fc23.x86_64.rpm
similarity index 100%
copy from copr-prune-repo/tests/fedora-23-x86_64-template/1-success1/example-1.0.1-1.fc23.x86_64.rpm
copy to prunerepo/tests/fedora-23-x86_64-template/0-oldestbuild/example-1.0.1-1.fc23.x86_64.rpm
diff --git a/copr-prune-repo/tests/fedora-23-x86_64-template/1-success1/example-debuginfo-1.0.1-1.fc23.x86_64.rpm b/prunerepo/tests/fedora-23-x86_64-template/0-oldestbuild/example-debuginfo-1.0.1-1.fc23.x86_64.rpm
similarity index 100%
copy from copr-prune-repo/tests/fedora-23-x86_64-template/1-success1/example-debuginfo-1.0.1-1.fc23.x86_64.rpm
copy to prunerepo/tests/fedora-23-x86_64-template/0-oldestbuild/example-debuginfo-1.0.1-1.fc23.x86_64.rpm
diff --git a/copr-prune-repo/tests/fedora-23-x86_64-template/1-success1/mockchain.log.gz b/prunerepo/tests/fedora-23-x86_64-template/0-oldestbuild/mockchain.log.gz
similarity index 100%
copy from copr-prune-repo/tests/fedora-23-x86_64-template/1-success1/mockchain.log.gz
copy to prunerepo/tests/fedora-23-x86_64-template/0-oldestbuild/mockchain.log.gz
diff --git a/copr-prune-repo/tests/fedora-23-x86_64-template/1-success1/root.log.gz b/prunerepo/tests/fedora-23-x86_64-template/0-oldestbuild/root.log.gz
similarity index 100%
copy from copr-prune-repo/tests/fedora-23-x86_64-template/1-success1/root.log.gz
copy to prunerepo/tests/fedora-23-x86_64-template/0-oldestbuild/root.log.gz
diff --git a/copr-prune-repo/tests/fedora-23-x86_64-template/1-success1/state.log.gz b/prunerepo/tests/fedora-23-x86_64-template/0-oldestbuild/state.log.gz
similarity index 100%
copy from copr-prune-repo/tests/fedora-23-x86_64-template/1-success1/state.log.gz
copy to prunerepo/tests/fedora-23-x86_64-template/0-oldestbuild/state.log.gz
diff --git a/copr-prune-repo/tests/fedora-23-x86_64-template/1-success1/success b/prunerepo/tests/fedora-23-x86_64-template/0-oldestbuild/success
similarity index 100%
copy from copr-prune-repo/tests/fedora-23-x86_64-template/1-success1/success
copy to prunerepo/tests/fedora-23-x86_64-template/0-oldestbuild/success
diff --git a/copr-prune-repo/tests/fedora-23-x86_64-template/4-fail2/build-00151843.rsync.log b/prunerepo/tests/fedora-23-x86_64-template/1-norpmsinside/build-00151843.rsync.log
similarity index 100%
copy from copr-prune-repo/tests/fedora-23-x86_64-template/4-fail2/build-00151843.rsync.log
copy to prunerepo/tests/fedora-23-x86_64-template/1-norpmsinside/build-00151843.rsync.log
diff --git a/copr-prune-repo/tests/fedora-23-x86_64-template/4-fail2/build.info b/prunerepo/tests/fedora-23-x86_64-template/1-norpmsinside/build.info
similarity index 100%
copy from copr-prune-repo/tests/fedora-23-x86_64-template/4-fail2/build.info
copy to prunerepo/tests/fedora-23-x86_64-template/1-norpmsinside/build.info
diff --git a/copr-prune-repo/tests/fedora-23-x86_64-template/4-fail2/build.log.gz b/prunerepo/tests/fedora-23-x86_64-template/1-norpmsinside/build.log.gz
similarity index 100%
copy from copr-prune-repo/tests/fedora-23-x86_64-template/4-fail2/build.log.gz
copy to prunerepo/tests/fedora-23-x86_64-template/1-norpmsinside/build.log.gz
diff --git a/copr-prune-repo/tests/fedora-23-x86_64-template/3-fail1-baduser/fail b/prunerepo/tests/fedora-23-x86_64-template/1-norpmsinside/fail
similarity index 100%
copy from copr-prune-repo/tests/fedora-23-x86_64-template/3-fail1-baduser/fail
copy to prunerepo/tests/fedora-23-x86_64-template/1-norpmsinside/fail
diff --git a/copr-prune-repo/tests/fedora-23-x86_64-template/4-fail2/mockchain.log.gz b/prunerepo/tests/fedora-23-x86_64-template/1-norpmsinside/mockchain.log.gz
similarity index 100%
copy from copr-prune-repo/tests/fedora-23-x86_64-template/4-fail2/mockchain.log.gz
copy to prunerepo/tests/fedora-23-x86_64-template/1-norpmsinside/mockchain.log.gz
diff --git a/copr-prune-repo/tests/fedora-23-x86_64-template/4-fail2/root.log.gz b/prunerepo/tests/fedora-23-x86_64-template/1-norpmsinside/root.log.gz
similarity index 100%
copy from copr-prune-repo/tests/fedora-23-x86_64-template/4-fail2/root.log.gz
copy to prunerepo/tests/fedora-23-x86_64-template/1-norpmsinside/root.log.gz
diff --git a/copr-prune-repo/tests/fedora-23-x86_64-template/4-fail2/state.log.gz b/prunerepo/tests/fedora-23-x86_64-template/1-norpmsinside/state.log.gz
similarity index 100%
copy from copr-prune-repo/tests/fedora-23-x86_64-template/4-fail2/state.log.gz
copy to prunerepo/tests/fedora-23-x86_64-template/1-norpmsinside/state.log.gz
diff --git a/copr-prune-repo/tests/fedora-23-x86_64-template/6-success4-seclatest/build-00151846.rsync.log b/prunerepo/tests/fedora-23-x86_64-template/2-secondlatestpkg/build-00151846.rsync.log
similarity index 100%
copy from copr-prune-repo/tests/fedora-23-x86_64-template/6-success4-seclatest/build-00151846.rsync.log
copy to prunerepo/tests/fedora-23-x86_64-template/2-secondlatestpkg/build-00151846.rsync.log
diff --git a/copr-prune-repo/tests/fedora-23-x86_64-template/6-success4-seclatest/build.info b/prunerepo/tests/fedora-23-x86_64-template/2-secondlatestpkg/build.info
similarity index 100%
copy from copr-prune-repo/tests/fedora-23-x86_64-template/6-success4-seclatest/build.info
copy to prunerepo/tests/fedora-23-x86_64-template/2-secondlatestpkg/build.info
diff --git a/copr-prune-repo/tests/fedora-23-x86_64-template/6-success4-seclatest/build.log.gz b/prunerepo/tests/fedora-23-x86_64-template/2-secondlatestpkg/build.log.gz
similarity index 100%
copy from copr-prune-repo/tests/fedora-23-x86_64-template/6-success4-seclatest/build.log.gz
copy to prunerepo/tests/fedora-23-x86_64-template/2-secondlatestpkg/build.log.gz
diff --git a/copr-prune-repo/tests/fedora-23-x86_64-template/6-success4-seclatest/example-1.0.2-2.fc23.src.rpm b/prunerepo/tests/fedora-23-x86_64-template/2-secondlatestpkg/example-1.0.2-2.fc23.src.rpm
similarity index 100%
copy from copr-prune-repo/tests/fedora-23-x86_64-template/6-success4-seclatest/example-1.0.2-2.fc23.src.rpm
copy to prunerepo/tests/fedora-23-x86_64-template/2-secondlatestpkg/example-1.0.2-2.fc23.src.rpm
diff --git a/copr-prune-repo/tests/fedora-23-x86_64-template/6-success4-seclatest/example-1.0.2-2.fc23.x86_64.rpm b/prunerepo/tests/fedora-23-x86_64-template/2-secondlatestpkg/example-1.0.2-2.fc23.x86_64.rpm
similarity index 100%
copy from copr-prune-repo/tests/fedora-23-x86_64-template/6-success4-seclatest/example-1.0.2-2.fc23.x86_64.rpm
copy to prunerepo/tests/fedora-23-x86_64-template/2-secondlatestpkg/example-1.0.2-2.fc23.x86_64.rpm
diff --git a/copr-prune-repo/tests/fedora-23-x86_64-template/6-success4-seclatest/example-debuginfo-1.0.2-2.fc23.x86_64.rpm b/prunerepo/tests/fedora-23-x86_64-template/2-secondlatestpkg/example-debuginfo-1.0.2-2.fc23.x86_64.rpm
similarity index 100%
copy from copr-prune-repo/tests/fedora-23-x86_64-template/6-success4-seclatest/example-debuginfo-1.0.2-2.fc23.x86_64.rpm
copy to prunerepo/tests/fedora-23-x86_64-template/2-secondlatestpkg/example-debuginfo-1.0.2-2.fc23.x86_64.rpm
diff --git a/copr-prune-repo/tests/fedora-23-x86_64-template/6-success4-seclatest/mockchain.log.gz b/prunerepo/tests/fedora-23-x86_64-template/2-secondlatestpkg/mockchain.log.gz
similarity index 100%
copy from copr-prune-repo/tests/fedora-23-x86_64-template/6-success4-seclatest/mockchain.log.gz
copy to prunerepo/tests/fedora-23-x86_64-template/2-secondlatestpkg/mockchain.log.gz
diff --git a/copr-prune-repo/tests/fedora-23-x86_64-template/6-success4-seclatest/root.log.gz b/prunerepo/tests/fedora-23-x86_64-template/2-secondlatestpkg/root.log.gz
similarity index 100%
copy from copr-prune-repo/tests/fedora-23-x86_64-template/6-success4-seclatest/root.log.gz
copy to prunerepo/tests/fedora-23-x86_64-template/2-secondlatestpkg/root.log.gz
diff --git a/copr-prune-repo/tests/fedora-23-x86_64-template/6-success4-seclatest/state.log.gz b/prunerepo/tests/fedora-23-x86_64-template/2-secondlatestpkg/state.log.gz
similarity index 100%
copy from copr-prune-repo/tests/fedora-23-x86_64-template/6-success4-seclatest/state.log.gz
copy to prunerepo/tests/fedora-23-x86_64-template/2-secondlatestpkg/state.log.gz
diff --git a/copr-prune-repo/tests/fedora-23-x86_64-template/1-success1/success b/prunerepo/tests/fedora-23-x86_64-template/2-secondlatestpkg/success
similarity index 100%
copy from copr-prune-repo/tests/fedora-23-x86_64-template/1-success1/success
copy to prunerepo/tests/fedora-23-x86_64-template/2-secondlatestpkg/success
diff --git a/copr-prune-repo/tests/fedora-23-x86_64-template/6-success4-seclatest/build-00151846.rsync.log b/prunerepo/tests/fedora-23-x86_64-template/3-latestpkg/build-00151846.rsync.log
similarity index 100%
copy from copr-prune-repo/tests/fedora-23-x86_64-template/6-success4-seclatest/build-00151846.rsync.log
copy to prunerepo/tests/fedora-23-x86_64-template/3-latestpkg/build-00151846.rsync.log
diff --git a/copr-prune-repo/tests/fedora-23-x86_64-template/6-success4-seclatest/build.info b/prunerepo/tests/fedora-23-x86_64-template/3-latestpkg/build.info
similarity index 100%
copy from copr-prune-repo/tests/fedora-23-x86_64-template/6-success4-seclatest/build.info
copy to prunerepo/tests/fedora-23-x86_64-template/3-latestpkg/build.info
diff --git a/copr-prune-repo/tests/fedora-23-x86_64-template/6-success4-seclatest/build.log.gz b/prunerepo/tests/fedora-23-x86_64-template/3-latestpkg/build.log.gz
similarity index 100%
copy from copr-prune-repo/tests/fedora-23-x86_64-template/6-success4-seclatest/build.log.gz
copy to prunerepo/tests/fedora-23-x86_64-template/3-latestpkg/build.log.gz
diff --git a/copr-prune-repo/tests/fedora-23-x86_64-template/7-success5-latest/example-1.0.3-2.fc23.src.rpm b/prunerepo/tests/fedora-23-x86_64-template/3-latestpkg/example-1.0.3-2.fc23.src.rpm
similarity index 100%
copy from copr-prune-repo/tests/fedora-23-x86_64-template/7-success5-latest/example-1.0.3-2.fc23.src.rpm
copy to prunerepo/tests/fedora-23-x86_64-template/3-latestpkg/example-1.0.3-2.fc23.src.rpm
diff --git a/copr-prune-repo/tests/fedora-23-x86_64-template/7-success5-latest/example-1.0.3-2.fc23.x86_64.rpm b/prunerepo/tests/fedora-23-x86_64-template/3-latestpkg/example-1.0.3-2.fc23.x86_64.rpm
similarity index 100%
copy from copr-prune-repo/tests/fedora-23-x86_64-template/7-success5-latest/example-1.0.3-2.fc23.x86_64.rpm
copy to prunerepo/tests/fedora-23-x86_64-template/3-latestpkg/example-1.0.3-2.fc23.x86_64.rpm
diff --git a/copr-prune-repo/tests/fedora-23-x86_64-template/7-success5-latest/example-debuginfo-1.0.3-2.fc23.x86_64.rpm b/prunerepo/tests/fedora-23-x86_64-template/3-latestpkg/example-debuginfo-1.0.3-2.fc23.x86_64.rpm
similarity index 100%
copy from copr-prune-repo/tests/fedora-23-x86_64-template/7-success5-latest/example-debuginfo-1.0.3-2.fc23.x86_64.rpm
copy to prunerepo/tests/fedora-23-x86_64-template/3-latestpkg/example-debuginfo-1.0.3-2.fc23.x86_64.rpm
diff --git a/copr-prune-repo/tests/fedora-23-x86_64-template/6-success4-seclatest/mockchain.log.gz b/prunerepo/tests/fedora-23-x86_64-template/3-latestpkg/mockchain.log.gz
similarity index 100%
copy from copr-prune-repo/tests/fedora-23-x86_64-template/6-success4-seclatest/mockchain.log.gz
copy to prunerepo/tests/fedora-23-x86_64-template/3-latestpkg/mockchain.log.gz
diff --git a/copr-prune-repo/tests/fedora-23-x86_64-template/6-success4-seclatest/root.log.gz b/prunerepo/tests/fedora-23-x86_64-template/3-latestpkg/root.log.gz
similarity index 100%
copy from copr-prune-repo/tests/fedora-23-x86_64-template/6-success4-seclatest/root.log.gz
copy to prunerepo/tests/fedora-23-x86_64-template/3-latestpkg/root.log.gz
diff --git a/copr-prune-repo/tests/fedora-23-x86_64-template/6-success4-seclatest/state.log.gz b/prunerepo/tests/fedora-23-x86_64-template/3-latestpkg/state.log.gz
similarity index 100%
copy from copr-prune-repo/tests/fedora-23-x86_64-template/6-success4-seclatest/state.log.gz
copy to prunerepo/tests/fedora-23-x86_64-template/3-latestpkg/state.log.gz
diff --git a/copr-prune-repo/tests/fedora-23-x86_64-template/1-success1/success b/prunerepo/tests/fedora-23-x86_64-template/3-latestpkg/success
similarity index 100%
copy from copr-prune-repo/tests/fedora-23-x86_64-template/1-success1/success
copy to prunerepo/tests/fedora-23-x86_64-template/3-latestpkg/success
diff --git a/copr-prune-repo/tests/fedora-23-x86_64-template/appdata/appstream-failed.xml.gz b/prunerepo/tests/fedora-23-x86_64-template/appdata/appstream-failed.xml.gz
similarity index 100%
copy from copr-prune-repo/tests/fedora-23-x86_64-template/appdata/appstream-failed.xml.gz
copy to prunerepo/tests/fedora-23-x86_64-template/appdata/appstream-failed.xml.gz
diff --git a/copr-prune-repo/tests/fedora-23-x86_64-template/appdata/appstream-ignore.xml.gz b/prunerepo/tests/fedora-23-x86_64-template/appdata/appstream-ignore.xml.gz
similarity index 100%
copy from copr-prune-repo/tests/fedora-23-x86_64-template/appdata/appstream-ignore.xml.gz
copy to prunerepo/tests/fedora-23-x86_64-template/appdata/appstream-ignore.xml.gz
diff --git a/copr-prune-repo/tests/fedora-23-x86_64-template/appdata/appstream.xml.gz b/prunerepo/tests/fedora-23-x86_64-template/appdata/appstream.xml.gz
similarity index 100%
copy from copr-prune-repo/tests/fedora-23-x86_64-template/appdata/appstream.xml.gz
copy to prunerepo/tests/fedora-23-x86_64-template/appdata/appstream.xml.gz
diff --git a/frontend/coprs_frontend/coprs/logic/__init__.py b/prunerepo/tests/fedora-23-x86_64-template/build-0.log
similarity index 100%
copy from frontend/coprs_frontend/coprs/logic/__init__.py
copy to prunerepo/tests/fedora-23-x86_64-template/build-0.log
diff --git a/frontend/coprs_frontend/coprs/logic/__init__.py b/prunerepo/tests/fedora-23-x86_64-template/build-1.log
similarity index 100%
copy from frontend/coprs_frontend/coprs/logic/__init__.py
copy to prunerepo/tests/fedora-23-x86_64-template/build-1.log
diff --git a/frontend/coprs_frontend/coprs/logic/__init__.py b/prunerepo/tests/fedora-23-x86_64-template/build-2.log
similarity index 100%
copy from frontend/coprs_frontend/coprs/logic/__init__.py
copy to prunerepo/tests/fedora-23-x86_64-template/build-2.log
diff --git a/frontend/coprs_frontend/coprs/logic/__init__.py b/prunerepo/tests/fedora-23-x86_64-template/build-3.log
similarity index 100%
copy from frontend/coprs_frontend/coprs/logic/__init__.py
copy to prunerepo/tests/fedora-23-x86_64-template/build-3.log
diff --git a/prunerepo/tests/fedora-23-x86_64-template/repodata/02fe713968335532ea704bd45a6a68e5edbad50cf112d6a77a8d2ae0625845b5-primary.xml.gz b/prunerepo/tests/fedora-23-x86_64-template/repodata/02fe713968335532ea704bd45a6a68e5edbad50cf112d6a77a8d2ae0625845b5-primary.xml.gz
new file mode 100644
index 0000000..d184c17
Binary files /dev/null and b/prunerepo/tests/fedora-23-x86_64-template/repodata/02fe713968335532ea704bd45a6a68e5edbad50cf112d6a77a8d2ae0625845b5-primary.xml.gz differ
diff --git a/prunerepo/tests/fedora-23-x86_64-template/repodata/1dcc94eaf9b689fd633c84e729573bb35b8d1bd82847fdb6961befad2dbc9855-filelists.xml.gz b/prunerepo/tests/fedora-23-x86_64-template/repodata/1dcc94eaf9b689fd633c84e729573bb35b8d1bd82847fdb6961befad2dbc9855-filelists.xml.gz
new file mode 100644
index 0000000..3426a52
Binary files /dev/null and b/prunerepo/tests/fedora-23-x86_64-template/repodata/1dcc94eaf9b689fd633c84e729573bb35b8d1bd82847fdb6961befad2dbc9855-filelists.xml.gz differ
diff --git a/prunerepo/tests/fedora-23-x86_64-template/repodata/4b353908471ef7501182727c9e189ffe38b7647458e05b14d7851bb408d71dcb-other.sqlite.bz2 b/prunerepo/tests/fedora-23-x86_64-template/repodata/4b353908471ef7501182727c9e189ffe38b7647458e05b14d7851bb408d71dcb-other.sqlite.bz2
new file mode 100644
index 0000000..7bf25e5
Binary files /dev/null and b/prunerepo/tests/fedora-23-x86_64-template/repodata/4b353908471ef7501182727c9e189ffe38b7647458e05b14d7851bb408d71dcb-other.sqlite.bz2 differ
diff --git a/prunerepo/tests/fedora-23-x86_64-template/repodata/7432f37c5556a6e82fdb1bf7269a7f240e92edb15af72376bd35091beed70f92-primary.sqlite.bz2 b/prunerepo/tests/fedora-23-x86_64-template/repodata/7432f37c5556a6e82fdb1bf7269a7f240e92edb15af72376bd35091beed70f92-primary.sqlite.bz2
new file mode 100644
index 0000000..2f28512
Binary files /dev/null and b/prunerepo/tests/fedora-23-x86_64-template/repodata/7432f37c5556a6e82fdb1bf7269a7f240e92edb15af72376bd35091beed70f92-primary.sqlite.bz2 differ
diff --git a/prunerepo/tests/fedora-23-x86_64-template/repodata/78aadc850cc0fef1dbb7d298a93483c0cdc521044cb687492ff4b3f3c1bbb1bf-filelists.sqlite.bz2 b/prunerepo/tests/fedora-23-x86_64-template/repodata/78aadc850cc0fef1dbb7d298a93483c0cdc521044cb687492ff4b3f3c1bbb1bf-filelists.sqlite.bz2
new file mode 100644
index 0000000..14111a7
Binary files /dev/null and b/prunerepo/tests/fedora-23-x86_64-template/repodata/78aadc850cc0fef1dbb7d298a93483c0cdc521044cb687492ff4b3f3c1bbb1bf-filelists.sqlite.bz2 differ
diff --git a/prunerepo/tests/fedora-23-x86_64-template/repodata/83fbf1ec230cea6cfd514639baff018bbf78457a143ae6a9bfaf60b3dea1a272-other.xml.gz b/prunerepo/tests/fedora-23-x86_64-template/repodata/83fbf1ec230cea6cfd514639baff018bbf78457a143ae6a9bfaf60b3dea1a272-other.xml.gz
new file mode 100644
index 0000000..8212c10
Binary files /dev/null and b/prunerepo/tests/fedora-23-x86_64-template/repodata/83fbf1ec230cea6cfd514639baff018bbf78457a143ae6a9bfaf60b3dea1a272-other.xml.gz differ
diff --git a/prunerepo/tests/fedora-23-x86_64-template/repodata/repomd.xml b/prunerepo/tests/fedora-23-x86_64-template/repodata/repomd.xml
new file mode 100644
index 0000000..7c7dd93
--- /dev/null
+++ b/prunerepo/tests/fedora-23-x86_64-template/repodata/repomd.xml
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<repomd xmlns="http://linux.duke.edu/metadata/repo" xmlns:rpm="http://linux.duke.edu/metadata/rpm">
+ <revision>1453299549</revision>
+ <data type="primary">
+ <checksum type="sha256">02fe713968335532ea704bd45a6a68e5edbad50cf112d6a77a8d2ae0625845b5</checksum>
+ <open-checksum type="sha256">526788fb9bab5757396806ff9c119eb7492494d741a3730d22cad01bc10a2cac</open-checksum>
+ <location href="repodata/02fe713968335532ea704bd45a6a68e5edbad50cf112d6a77a8d2ae0625845b5-primary.xml.gz"/>
+ <timestamp>1453299549</timestamp>
+ <size>1673</size>
+ <open-size>10898</open-size>
+ </data>
+ <data type="filelists">
+ <checksum type="sha256">1dcc94eaf9b689fd633c84e729573bb35b8d1bd82847fdb6961befad2dbc9855</checksum>
+ <open-checksum type="sha256">6bbb7d3e1c9f258f0bf25f1800b0f85894989b7061b90b1fa0bc86d38855cf37</open-checksum>
+ <location href="repodata/1dcc94eaf9b689fd633c84e729573bb35b8d1bd82847fdb6961befad2dbc9855-filelists.xml.gz"/>
+ <timestamp>1453299549</timestamp>
+ <size>796</size>
+ <open-size>3350</open-size>
+ </data>
+ <data type="other">
+ <checksum type="sha256">83fbf1ec230cea6cfd514639baff018bbf78457a143ae6a9bfaf60b3dea1a272</checksum>
+ <open-checksum type="sha256">ac3dd5fb6f15d1b0b7149ed0ca622a9aa69aea6157a8fe83e4292ed65c94a038</open-checksum>
+ <location href="repodata/83fbf1ec230cea6cfd514639baff018bbf78457a143ae6a9bfaf60b3dea1a272-other.xml.gz"/>
+ <timestamp>1453299549</timestamp>
+ <size>805</size>
+ <open-size>4183</open-size>
+ </data>
+ <data type="primary_db">
+ <checksum type="sha256">7432f37c5556a6e82fdb1bf7269a7f240e92edb15af72376bd35091beed70f92</checksum>
+ <open-checksum type="sha256">eb106ffa0b315f9e09cf76a72bc8451f0bad659a62a82058983c5940dbd83141</open-checksum>
+ <location href="repodata/7432f37c5556a6e82fdb1bf7269a7f240e92edb15af72376bd35091beed70f92-primary.sqlite.bz2"/>
+ <timestamp>1453299549</timestamp>
+ <size>3762</size>
+ <open-size>36864</open-size>
+ <database_version>10</database_version>
+ </data>
+ <data type="filelists_db">
+ <checksum type="sha256">78aadc850cc0fef1dbb7d298a93483c0cdc521044cb687492ff4b3f3c1bbb1bf</checksum>
+ <open-checksum type="sha256">f74d2de41b4e4d887c09e0a826c85150929847d4df1e937ce1dfa6ffb8097faf</open-checksum>
+ <location href="repodata/78aadc850cc0fef1dbb7d298a93483c0cdc521044cb687492ff4b3f3c1bbb1bf-filelists.sqlite.bz2"/>
+ <timestamp>1453299549</timestamp>
+ <size>2036</size>
+ <open-size>9216</open-size>
+ <database_version>10</database_version>
+ </data>
+ <data type="other_db">
+ <checksum type="sha256">4b353908471ef7501182727c9e189ffe38b7647458e05b14d7851bb408d71dcb</checksum>
+ <open-checksum type="sha256">013c142d799d1e530fb2bf5c5c4b1b5fd28acdd2621c58458399a0b7bfaec3b3</open-checksum>
+ <location href="repodata/4b353908471ef7501182727c9e189ffe38b7647458e05b14d7851bb408d71dcb-other.sqlite.bz2"/>
+ <timestamp>1453299549</timestamp>
+ <size>1817</size>
+ <open-size>8192</open-size>
+ <database_version>10</database_version>
+ </data>
+</repomd>
diff --git a/prunerepo/tests/test.sh b/prunerepo/tests/test.sh
new file mode 100755
index 0000000..21cbdd4
--- /dev/null
+++ b/prunerepo/tests/test.sh
@@ -0,0 +1,86 @@
+#!/bin/bash
+
+shopt -s expand_aliases
+
+# repo build dirs:
+# 1-oldestbuild
+# 2-norpmsinside
+# 3-secondlatestpkg
+# 4-latestpkg
+
+export testdir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+export origrepo=$testdir/fedora-23-x86_64-template
+export testrepo=$testdir/fedora-23-x86_64-test
+
+die() { echo "fail."; exit 1; }
+
+function runcmd {
+ bash -c "set -x; ../../prunerepo --quiet $*;"
+}
+
+function listpkgsbyrepo {
+ dnf --disablerepo="*" repoquery --repofrompath=test_prunerepo,$testrepo --repoid=test_prunerepo --enablerepo=test_prunerepo --refresh --quiet --queryformat '%{location}' | sort
+}
+
+function listpkgsbyfs {
+ find . -name '*.rpm' | cut -c 3- | sort
+}
+
+function run {
+ echo '>' $@;
+ eval $@;
+}
+
+function setup {
+ cp -aT $origrepo $testrepo
+ cd $testrepo
+}
+
+echo "============================ test basic functionality ============================";
+
+setup
+runcmd .
+
+run 'ls 0-oldestbuild/*.rpm' && die
+run 'ls 1-norpmsinside/*.rpm' && die
+run 'ls 2-secondlatestpkg/*.rpm' && die
+run '[[ `ls 3-latestpkg/*.rpm | wc -l` == 3 ]]' || die
+run '[[ `listpkgsbyfs` == `listpkgsbyrepo` ]]' || die
+
+
+echo "============================ test --cleancopr ============================";
+
+setup
+runcmd --cleancopr .
+
+run "ls -d 0-oldestbuild" && die
+run "ls -d 1-norpmsinside" && die
+run "ls -d 2-secondlatestpkg" && die
+run "ls -d 3-latestpkg" || die
+
+run "ls build-0.log" && die
+run "ls build-1.log" && die
+run "ls build-2.log" && die
+run "ls build-3.log" || die
+
+echo success.
+
+echo "============================ test --nocreaterepo ============================"; #TODO
+
+setup
+runcmd --days 7 .
+echo success.
+
+echo "============================ test --days ============================"; #TODO
+
+setup
+runcmd --days 7 .
+echo success.
+
+echo "============================ test no dnf caching ============================"; #TODO
+
+setup
+runcmd .
+echo success.
+
+exit 0
8 years, 4 months
[copr] master: [prunerepo] --days reimplemented so that srpms are deleted only if their rpms are deleted (--days is tricky) (cb04349)
by clime@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : master
>---------------------------------------------------------------
commit cb04349ddfea910be49a314b44a282669d3109bd
Author: clime <clime(a)redhat.com>
Date: Wed Jan 20 17:14:23 2016 +0100
[prunerepo] --days reimplemented so that srpms are deleted only if their rpms are deleted (--days is tricky)
>---------------------------------------------------------------
prunerepo/man/prunerepo.1.asciidoc | 2 +-
prunerepo/prunerepo | 46 +++++++++++++++++++++++++-----------
2 files changed, 33 insertions(+), 15 deletions(-)
diff --git a/prunerepo/man/prunerepo.1.asciidoc b/prunerepo/man/prunerepo.1.asciidoc
index 2ba8e4c..04c6817 100644
--- a/prunerepo/man/prunerepo.1.asciidoc
+++ b/prunerepo/man/prunerepo.1.asciidoc
@@ -35,7 +35,7 @@ path::
OPTIONS
-------
--days DAYS::
- only remove packages older than DAYS (by their build date)
+ only remove packages older than DAYS (by their build date), does remove srpm only if associated rpm is removed
--cleancopr::
additionaly remove whole copr build dirs and logs if the associated package gets deleted
diff --git a/prunerepo/prunerepo b/prunerepo/prunerepo
index e7cbf92..671e2f7 100755
--- a/prunerepo/prunerepo
+++ b/prunerepo/prunerepo
@@ -13,7 +13,7 @@ parser = argparse.ArgumentParser(description='Remove old packages from rpm-md re
parser.add_argument('path', action='store',
help='local path to a yum repository')
parser.add_argument('--days', type=int, action='store', default=0,
- help='only remove packages older than DAYS (by their build date)')
+ help='only remove packages older than DAYS by their build date, does remove srpm only if associated rpm is removed')
parser.add_argument('--cleancopr', action='store_true',
help='additionaly remove whole copr build dirs and logs if the associated package gets deleted')
parser.add_argument('--nocreaterepo', action='store_true',
@@ -42,6 +42,18 @@ get_all_packages_cmd = [
get_latest_packages_cmd = get_all_packages_cmd + [ '--latest-limit=1' ]
+
+def is_srpm(package):
+ return re.match(r'.*\.src\.rpm$', package)
+
+
+def rm_file(path):
+ if args.verbose:
+ log_info("Removing: "+path)
+ if os.path.exists(path) and os.path.isfile(path):
+ os.remove(path)
+
+
def log_info(msg):
if not args.quiet:
print(msg)
@@ -58,10 +70,13 @@ def run_cmd(cmd, silent=False):
if process.returncode != 0:
print(stderr.decode(encoding='utf-8'), file=sys.stderr)
sys.exit(1)
- return stdout.decode(encoding='utf-8').split()
+ return [line.strip('"') for line in stdout.decode(encoding='utf-8').split()]
def get_package_build_time(package_path):
+ """
+ Get build time by reading package metadata
+ """
createrepo_cmd = ['/usr/bin/rpm', '-qp', '--queryformat', '%{BUILDTIME}'] + [ package_path ]
stdout = run_cmd(createrepo_cmd, silent=True)
return int(stdout[0])
@@ -77,6 +92,15 @@ def get_packages(repoquery_cmd):
return abs_package_paths
+def rm_srpm(package):
+ """
+ Attempt to remove srpm for the associated rpm package described by absolute fs path
+ """
+ get_srpm_cmd = get_all_packages_cmd + [ '--srpm', os.path.splitext(os.path.basename(package))[0] ]
+ srpm = run_cmd(get_srpm_cmd, silent=True)[0]
+ rm_file(os.path.abspath(os.path.join(args.path, srpm)))
+
+
def prune_packages():
"""
Remove obsoleted packages
@@ -85,15 +109,13 @@ def prune_packages():
latest_packages = get_packages(get_latest_packages_cmd)
all_packages = get_packages(get_all_packages_cmd)
to_remove_packages = set(all_packages) - set(latest_packages)
- removed_counter = 0
for package in to_remove_packages:
- if time.time() - get_package_build_time(package) <= args.days * 24 * 3600:
- continue
- os.remove(package)
- if args.verbose:
- log_info("Removing: "+package)
- removed_counter += 1
- log_info('- {} packages removed'.format(removed_counter))
+ if args.days:
+ if not is_srpm(package) and time.time() - get_package_build_time(package) > args.days * 24 * 3600:
+ rm_file(package)
+ rm_srpm(package)
+ else:
+ rm_file(package)
def recreate_repo():
@@ -110,7 +132,6 @@ def clean_copr():
Remove whole copr build dirs if they no longer contain a srpm/rpm file
"""
log_info("Cleaning COPR repository...")
- removed_counter = 0
for dir_name in os.listdir(args.path):
dir_path = os.path.abspath(os.path.join(args.path, dir_name))
@@ -124,7 +145,6 @@ def clean_copr():
if args.verbose:
log_info('Removing: '+dir_path)
shutil.rmtree(dir_path)
- removed_counter += 1
# also remove the associated log in the main dir
build_id = os.path.basename(dir_path).split('-')[0]
@@ -134,8 +154,6 @@ def clean_copr():
log_info('Removing: '+buildlog_path)
os.remove(os.path.join(args.path, buildlog_path))
- log_info('- {} build dirs (with no *.rpm inside) and build logs removed'.format(removed_counter))
-
if __name__ == '__main__':
prune_packages()
8 years, 4 months
[copr] master: [prunerepo] --quiet option added to suppress info messages (783762d)
by clime@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : master
>---------------------------------------------------------------
commit 783762d319bd1a5461348b3e16d1f32142132ff7
Author: clime <clime(a)redhat.com>
Date: Wed Jan 20 12:40:15 2016 +0100
[prunerepo] --quiet option added to suppress info messages
>---------------------------------------------------------------
prunerepo/man/prunerepo.1.asciidoc | 3 +++
prunerepo/prunerepo | 24 +++++++++++++++---------
2 files changed, 18 insertions(+), 9 deletions(-)
diff --git a/prunerepo/man/prunerepo.1.asciidoc b/prunerepo/man/prunerepo.1.asciidoc
index 2a0bccd..2ba8e4c 100644
--- a/prunerepo/man/prunerepo.1.asciidoc
+++ b/prunerepo/man/prunerepo.1.asciidoc
@@ -46,6 +46,9 @@ OPTIONS
--verbose::
print all deleted items to stdout
+--verbose::
+ do not print any info messages, just do your job
+
-h, --help::
show this help message and exit
diff --git a/prunerepo/prunerepo b/prunerepo/prunerepo
index 95c4252..e7cbf92 100755
--- a/prunerepo/prunerepo
+++ b/prunerepo/prunerepo
@@ -20,6 +20,8 @@ parser.add_argument('--nocreaterepo', action='store_true',
help='repository is not automatically recreated after deletion')
parser.add_argument('--verbose', action='store_true',
help='print all deleted items to stdout')
+parser.add_argument('--quiet', action='store_true',
+ help='do not print any info messages, just do your job')
parser.add_argument('-v', '--version', action='version', version='1.0',
help='print program version and exit')
@@ -40,13 +42,17 @@ get_all_packages_cmd = [
get_latest_packages_cmd = get_all_packages_cmd + [ '--latest-limit=1' ]
+def log_info(msg):
+ if not args.quiet:
+ print(msg)
+
def run_cmd(cmd, silent=False):
"""
Run given command in a subprocess
"""
if not silent:
- print("Executing: "+' '.join(cmd))
+ log_info("Executing: "+' '.join(cmd))
process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
(stdout, stderr) = process.communicate()
if process.returncode != 0:
@@ -75,7 +81,7 @@ def prune_packages():
"""
Remove obsoleted packages
"""
- print('Removing obsoleted packages...')
+ log_info('Removing obsoleted packages...')
latest_packages = get_packages(get_latest_packages_cmd)
all_packages = get_packages(get_all_packages_cmd)
to_remove_packages = set(all_packages) - set(latest_packages)
@@ -85,16 +91,16 @@ def prune_packages():
continue
os.remove(package)
if args.verbose:
- print("Removing: "+package)
+ log_info("Removing: "+package)
removed_counter += 1
- print('- {} packages removed'.format(removed_counter))
+ log_info('- {} packages removed'.format(removed_counter))
def recreate_repo():
"""
Recreate the repository by using createrepo_c
"""
- print("Recreating repository...")
+ log_info("Recreating repository...")
createrepo_cmd = ['/usr/bin/createrepo_c', '--database', '--update'] + [ args.path ]
return run_cmd(createrepo_cmd)
@@ -103,7 +109,7 @@ def clean_copr():
"""
Remove whole copr build dirs if they no longer contain a srpm/rpm file
"""
- print("Cleaning COPR repository...")
+ log_info("Cleaning COPR repository...")
removed_counter = 0
for dir_name in os.listdir(args.path):
dir_path = os.path.abspath(os.path.join(args.path, dir_name))
@@ -116,7 +122,7 @@ def clean_copr():
continue
if args.verbose:
- print('Removing: '+dir_path)
+ log_info('Removing: '+dir_path)
shutil.rmtree(dir_path)
removed_counter += 1
@@ -125,10 +131,10 @@ def clean_copr():
buildlog_name = 'build-' + build_id + '.log'
buildlog_path = os.path.abspath(os.path.join(args.path, buildlog_name))
if args.verbose:
- print('Removing: '+buildlog_path)
+ log_info('Removing: '+buildlog_path)
os.remove(os.path.join(args.path, buildlog_path))
- print ('- {} build dirs (with no *.rpm inside) and build logs removed'.format(removed_counter))
+ log_info('- {} build dirs (with no *.rpm inside) and build logs removed'.format(removed_counter))
if __name__ == '__main__':
8 years, 4 months
[copr] master: [prunerepo] do not read .spec file for --version and --help, fields are just hardcoded now (e8b5e97)
by clime@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : master
>---------------------------------------------------------------
commit e8b5e97ceee8ce336ffd88a955a6bd38ea2f7606
Author: clime <clime(a)redhat.com>
Date: Wed Jan 20 11:47:36 2016 +0100
[prunerepo] do not read .spec file for --version and --help, fields are just hardcoded now
>---------------------------------------------------------------
prunerepo/prunerepo | 7 ++-----
1 files changed, 2 insertions(+), 5 deletions(-)
diff --git a/prunerepo/prunerepo b/prunerepo/prunerepo
index 6a2344a..95c4252 100755
--- a/prunerepo/prunerepo
+++ b/prunerepo/prunerepo
@@ -3,15 +3,12 @@
import subprocess
import sys
import argparse
-import rpm
import os
import re
import time
import shutil
-spec_file = rpm.ts().parseSpec('prunerepo.spec')
-
-parser = argparse.ArgumentParser(description=spec_file.sourceHeader.summary.decode("utf-8"))
+parser = argparse.ArgumentParser(description='Remove old packages from rpm-md repository')
parser.add_argument('path', action='store',
help='local path to a yum repository')
@@ -23,7 +20,7 @@ parser.add_argument('--nocreaterepo', action='store_true',
help='repository is not automatically recreated after deletion')
parser.add_argument('--verbose', action='store_true',
help='print all deleted items to stdout')
-parser.add_argument('-v', '--version', action='version', version=spec_file.sourceHeader.version.decode("utf-8"),
+parser.add_argument('-v', '--version', action='version', version='1.0',
help='print program version and exit')
args = parser.parse_args()
8 years, 4 months
[copr] master: [prunerepo] man pages (2b02983)
by clime@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : master
>---------------------------------------------------------------
commit 2b029833fb6c763ebbced7296dddfae09b6e8dda
Author: clime <clime(a)redhat.com>
Date: Wed Jan 20 11:00:00 2016 +0100
[prunerepo] man pages
>---------------------------------------------------------------
prunerepo/man/prunerepo.1.asciidoc | 75 ++++++++++++++++++++++++++++++++++++
prunerepo/prunerepo | 2 +-
prunerepo/prunerepo.spec | 6 +++
3 files changed, 82 insertions(+), 1 deletions(-)
diff --git a/prunerepo/man/prunerepo.1.asciidoc b/prunerepo/man/prunerepo.1.asciidoc
new file mode 100644
index 0000000..2a0bccd
--- /dev/null
+++ b/prunerepo/man/prunerepo.1.asciidoc
@@ -0,0 +1,75 @@
+prunerepo(1)
+==========
+
+NAME
+----
+prunerepo - remove old packages from rpm-md repository
+
+
+SYNOPSIS
+--------
+prunerepo [--days DAYS] [--cleancopr] [--nocreaterepo] [--verbose] [-h] [-v] path
+
+
+DESCRIPTION
+-----------
+Removes obsoleted package versions from a yum repository. Both
+rpms and srpms, that have a newer version available in that same
+repository, are deleted from filesystem and rpm-md metadata are
+recreated afterwards.
+
+Support for specific repository structure (e.g. COPR) is also available
+making it possible to additionally remove build logs and whole build
+directories associated with a package.
+
+After deletion of obsoleted packages, the command
+"createrepo_c --database --update" is called
+to recreate the repository metadata.
+
+ARGUMENTS
+---------
+path::
+ local path to a yum repository
+
+
+OPTIONS
+-------
+--days DAYS::
+ only remove packages older than DAYS (by their build date)
+
+--cleancopr::
+ additionaly remove whole copr build dirs and logs if the associated package gets deleted
+
+--nocreaterepo::
+ repository is not automatically recreated after deletion
+
+--verbose::
+ print all deleted items to stdout
+
+-h, --help::
+ show this help message and exit
+
+-v, --version::
+ print program version and exit
+
+-h, --help::
+ show this help message and exit
+
+
+EXAMPLES
+--------
+prunerepo /path/to/repo::
+ removes all packages for which a newer version is available in the repository
+
+prunerepo /path/to/repo --cleancopr::
+ the same thing but also removes copr-specific build directories if they no longer contain any srpm/rpm package
+
+prunerepo /path/to/repo --days 7::
+ does not delete a package built in last 7 days even if a newer version is available for it
+
+prunerepo /path/to/repo --days 7 --nocreaterepo::
+ the same thing but omits call to createrepo_c at the end
+
+AUTHORS
+-------
+Michal Novotny <clime(a)redhat.com>
diff --git a/prunerepo/prunerepo b/prunerepo/prunerepo
index 61428b8..6a2344a 100755
--- a/prunerepo/prunerepo
+++ b/prunerepo/prunerepo
@@ -22,7 +22,7 @@ parser.add_argument('--cleancopr', action='store_true',
parser.add_argument('--nocreaterepo', action='store_true',
help='repository is not automatically recreated after deletion')
parser.add_argument('--verbose', action='store_true',
- help='print all deleted packages items to stdout')
+ help='print all deleted items to stdout')
parser.add_argument('-v', '--version', action='version', version=spec_file.sourceHeader.version.decode("utf-8"),
help='print program version and exit')
diff --git a/prunerepo/prunerepo.spec b/prunerepo/prunerepo.spec
index 9d7d228..829ab50 100644
--- a/prunerepo/prunerepo.spec
+++ b/prunerepo/prunerepo.spec
@@ -13,6 +13,7 @@ License: GPLv2+
BuildArch: noarch
BuildRequires: python3-devel
BuildRequires: rpm-python3
+BuildRequires: asciidoc
Requires: createrepo_c
Requires: dnf-plugins-core
Requires: rpm-python3
@@ -34,15 +35,20 @@ repository metadata.
%build
%py3_build
+a2x -d manpage -f manpage man/prunerepo.1.asciidoc
%install
%py3_install
+install -d %{buildroot}%{_mandir}/man1
+install -p -m 644 man/prunerepo.1 %{buildroot}/%{_mandir}/man1/
+
%files
%license LICENSE
%{python3_sitelib}/*
%{_bindir}/prunerepo
+%{_mandir}/man1/prunerepo.1*
%changelog
* Tue Jan 19 2016 clime <clime(a)redhat.com> 1.0-1
8 years, 4 months
[copr] master: --cleancopr and --days options implemented (91ce3c3)
by clime@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : master
>---------------------------------------------------------------
commit 91ce3c38a7ba78ce752a2a933cd7f312aad87477
Author: clime <clime(a)redhat.com>
Date: Wed Jan 20 09:57:37 2016 +0100
--cleancopr and --days options implemented
>---------------------------------------------------------------
prunerepo/prunerepo | 74 ++++++++++++++++++++++++++++++++++++++++++--------
1 files changed, 62 insertions(+), 12 deletions(-)
diff --git a/prunerepo/prunerepo b/prunerepo/prunerepo
index 053686f..61428b8 100755
--- a/prunerepo/prunerepo
+++ b/prunerepo/prunerepo
@@ -5,6 +5,9 @@ import sys
import argparse
import rpm
import os
+import re
+import time
+import shutil
spec_file = rpm.ts().parseSpec('prunerepo.spec')
@@ -12,14 +15,14 @@ parser = argparse.ArgumentParser(description=spec_file.sourceHeader.summary.deco
parser.add_argument('path', action='store',
help='local path to a yum repository')
-parser.add_argument('--days', type=int, action='store', default=0, # todo
+parser.add_argument('--days', type=int, action='store', default=0,
help='only remove packages older than DAYS (by their build date)')
-parser.add_argument('--copr', type=int, action='store', default=0, # todo
+parser.add_argument('--cleancopr', action='store_true',
help='additionaly remove whole copr build dirs and logs if the associated package gets deleted')
parser.add_argument('--nocreaterepo', action='store_true',
help='repository is not automatically recreated after deletion')
parser.add_argument('--verbose', action='store_true',
- help='print all deleted packages (*.src.rpm, *.rpm) to stdout')
+ help='print all deleted packages items to stdout')
parser.add_argument('-v', '--version', action='version', version=spec_file.sourceHeader.version.decode("utf-8"),
help='print program version and exit')
@@ -41,52 +44,99 @@ get_all_packages_cmd = [
get_latest_packages_cmd = get_all_packages_cmd + [ '--latest-limit=1' ]
-def run_cmd(cmd):
+def run_cmd(cmd, silent=False):
"""
Run given command in a subprocess
"""
- print("Executing: "+' '.join(cmd))
+ if not silent:
+ print("Executing: "+' '.join(cmd))
process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
(stdout, stderr) = process.communicate()
if process.returncode != 0:
- print(stderr, file=sys.stderr)
+ print(stderr.decode(encoding='utf-8'), file=sys.stderr)
sys.exit(1)
- return (stdout, stderr)
+ return stdout.decode(encoding='utf-8').split()
+
+
+def get_package_build_time(package_path):
+ createrepo_cmd = ['/usr/bin/rpm', '-qp', '--queryformat', '%{BUILDTIME}'] + [ package_path ]
+ stdout = run_cmd(createrepo_cmd, silent=True)
+ return int(stdout[0])
def get_packages(repoquery_cmd):
"""
Get paths to packages in the repository according to given repoquery_cmd
"""
- (stdout, stderr) = run_cmd(repoquery_cmd)
- rel_package_paths = [relpath.strip('"') for relpath in stdout.decode(encoding='utf-8').split()]
+ stdout = run_cmd(repoquery_cmd)
+ rel_package_paths = [relpath.strip('"') for relpath in stdout]
abs_package_paths = [os.path.abspath(os.path.join(args.path, relpath)) for relpath in rel_package_paths]
return abs_package_paths
def prune_packages():
- print("Removing obsoleted packages...")
+ """
+ Remove obsoleted packages
+ """
+ print('Removing obsoleted packages...')
latest_packages = get_packages(get_latest_packages_cmd)
all_packages = get_packages(get_all_packages_cmd)
to_remove_packages = set(all_packages) - set(latest_packages)
removed_counter = 0
for package in to_remove_packages:
+ if time.time() - get_package_build_time(package) <= args.days * 24 * 3600:
+ continue
os.remove(package)
if args.verbose:
- print(package)
+ print("Removing: "+package)
removed_counter += 1
- print('{} packages removed'.format(removed_counter))
+ print('- {} packages removed'.format(removed_counter))
def recreate_repo():
"""
Recreate the repository by using createrepo_c
"""
+ print("Recreating repository...")
createrepo_cmd = ['/usr/bin/createrepo_c', '--database', '--update'] + [ args.path ]
return run_cmd(createrepo_cmd)
+def clean_copr():
+ """
+ Remove whole copr build dirs if they no longer contain a srpm/rpm file
+ """
+ print("Cleaning COPR repository...")
+ removed_counter = 0
+ for dir_name in os.listdir(args.path):
+ dir_path = os.path.abspath(os.path.join(args.path, dir_name))
+
+ if not os.path.isdir(dir_path):
+ continue
+ if not os.path.isfile(os.path.join(dir_path, 'build.info')):
+ continue
+ if [item for item in os.listdir(dir_path) if re.match(r'.*\.rpm$', item)]:
+ continue
+
+ if args.verbose:
+ print('Removing: '+dir_path)
+ shutil.rmtree(dir_path)
+ removed_counter += 1
+
+ # also remove the associated log in the main dir
+ build_id = os.path.basename(dir_path).split('-')[0]
+ buildlog_name = 'build-' + build_id + '.log'
+ buildlog_path = os.path.abspath(os.path.join(args.path, buildlog_name))
+ if args.verbose:
+ print('Removing: '+buildlog_path)
+ os.remove(os.path.join(args.path, buildlog_path))
+
+ print ('- {} build dirs (with no *.rpm inside) and build logs removed'.format(removed_counter))
+
+
if __name__ == '__main__':
prune_packages()
if not args.nocreaterepo:
recreate_repo()
+ if args.cleancopr:
+ clean_copr()
8 years, 4 months