[projects/pld-ftp-admin] wwwbin: drop clean-dups-old.py and clean-dups-archive.py

arekm arekm at pld-linux.org
Sat Oct 24 11:47:09 CEST 2026


commit 428f0a750f1bfbea6fe589e5ad3fef190ab9ed1a
Author: Arkadiusz Miśkiewicz <arekm at maven.pl>
Date:   Tue Oct 20 17:10:42 2026 +0200

    wwwbin: drop clean-dups-old.py and clean-dups-archive.py
    
    Python 2 code calling scripts/remove.py, which is not in this
    repository; clean-dups.py replaces them.

 wwwbin/clean-dups-archive.py | 98 --------------------------------------------
 wwwbin/clean-dups-old.py     | 77 ----------------------------------
 2 files changed, 175 deletions(-)
---
diff --git a/wwwbin/clean-dups-archive.py b/wwwbin/clean-dups-archive.py
deleted file mode 100755
index c04e867..0000000
--- a/wwwbin/clean-dups-archive.py
+++ /dev/null
@@ -1,98 +0,0 @@
-#!/usr/bin/python3
-# arekm, 2008
-# remove 
-
-from __future__ import print_function
-
-import os
-import re
-import time
-import rpm
-import sys
-
-re_rpm = re.compile(r'.*\.rpm$')
-re_nvr = re.compile('^(.*)-([^-]*)-([^-]*)\.rpm$')
-dir = '/home/pld/admins/th/ftp/.archive/PLD/SRPMS/RPMS'
-
-ts = rpm.TransactionSet("", (rpm.RPMVSF_NOHDRCHK or rpm.RPMVSF_NEEDPAYLOAD))
-
-def compare(f1, f2):
-	try:
-		fd1 = os.open(os.path.join(dir, f1), os.O_RDONLY)
-	except Exception as e:
-		print(e)
-		# ignore non-files
-		return 0
-	try:
-		fd2 = os.open(os.path.join(dir, f2), os.O_RDONLY)
-	except Exception as e:
-		print(e)
-		# ignore non-files
-		return 0
-	try:
-		h1 = ts.hdrFromFdno(fd1)
-	except Exception as e:
-		print("hdrFromFdno for %s failed: %s" % (f1, e))
-		os.close(fd1)
-		os.close(fd2)
-		return 0
-	try:
-		h2 = ts.hdrFromFdno(fd2)
-	except Exception as e:
-		print("hdrFromFdno for %s failed: %s" % (f1, e))
-		os.close(fd1)
-		os.close(fd2)
-		return 0
-	os.close(fd1)
-	os.close(fd2)
-
-	try:
-		l1 = rpm.versionCompare(h1, h2)
-	except ValueError:
-		l1 = -1
-	try:
-		l2 = rpm.versionCompare(h2, h1)
-	except ValueError:
-		l2 = -1
-
-	if l1 > 0 and l2 > 0:
-		return 0
-
-	return -l1
-
-
-def find_old(files):
-	return sorted(files, compare)
-
-files = {}
-dupes = {}
-
-for file in os.listdir(dir):
-	if not re_rpm.match(file):
-		continue
-
-	m = re_nvr.match(file)
-	if not m:
-		print("problem with: %s" % file)
-		sys.exit(1)
-
-	if len(sys.argv) == 0:
-		p = os.path.join(dir, file)
-		mtime = os.stat(p).st_mtime
-		if mtime > time.time() - 3*86400:
-			continue
-
-	name = m.group(1)
-
-	if files.has_key(name):
-		if dupes.has_key(name):
-			dupes[name].append(file)
-		else:
-			dupes[name] = [ files[name] ]
-			dupes[name].append(file)
-	else:
-		files[name] = file
-
-for i in iter(dupes.keys()):
-	for old in find_old(dupes[i])[1:]:
-		os.system("/home/pld/admins/th/pld-ftp-admin/scripts/remove.py .archive/PLD %s" % old)
diff --git a/wwwbin/clean-dups-old.py b/wwwbin/clean-dups-old.py
deleted file mode 100755
index b7e5256..0000000
--- a/wwwbin/clean-dups-old.py
+++ /dev/null
@@ -1,77 +0,0 @@
-#!/usr/bin/python3
-# arekm, 2008
-# remove 
-
-from __future__ import print_function
-
-import os
-import re
-import time
-import rpm
-import sys
-
-re_info = re.compile(r'.*\.info$')
-re_nvr = re.compile('^(.*)-([^-]*)-([^-]*)\.info$')
-dir = '/home/pld/admins/th/ftp/test/SRPMS/.metadata'
-
-def compare(f1, f2):
-	m1 = re_nvr.match(f1)
-	n1 = m1.group(1)
-	v1 = m1.group(2)
-	r1 = m1.group(3)
-
-	m2 = re_nvr.match(f2)
-	n2 = m2.group(1)
-	v2 = m2.group(2)
-	r2 = m2.group(3)
-
-	try:
-		l1 = rpm.labelCompare((n1, v1, r1), (n2, v2, r2))
-	except ValueError:
-		l1 = -1
-	try:
-		l2 = rpm.labelCompare((n2, v2, r2), (n1, v1, r1))
-	except ValueError:
-		l2 = -1
-
-	if l1 > 0 and l2 > 0:
-		return 0
-
-	return -l1
-
-
-def find_old(files):
-	return sorted(files, compare)
-
-files = {}
-dupes = {}
-
-for file in os.listdir(dir):
-	if not re_info.match(file):
-		continue
-
-	m = re_nvr.match(file)
-	if not m:
-		print("problem with: %s" % file)
-		sys.exit(1)
-
-	if len(sys.argv) == 0:
-		p = os.path.join(dir, file)
-		mtime = os.stat(p).st_mtime
-		if mtime > time.time() - 3*86400:
-			continue
-
-	name = m.group(1)
-
-	if files.has_key(name):
-		if dupes.has_key(name):
-			dupes[name].append(file)
-		else:
-			dupes[name] = [ files[name] ]
-			dupes[name].append(file)
-	else:
-		files[name] = file
-
-for i in iter(dupes.keys()):
-	for old in find_old(dupes[i])[1:]:
-		os.system("/home/pld/admins/th/pld-ftp-admin/scripts/remove.py test %s" % old)
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/projects/pld-ftp-admin.git/commitdiff/e14cb7d4d74f8bdd9368d9645ecaf49593cf6335



More information about the pld-cvs-commit mailing list