[packages/rpm-build-tools] sort-pkgs: for packages dir try evaluting %_topdir

atler atler at pld-linux.org
Wed Jan 4 22:36:21 CET 2023


commit 3fc1a82323d8ee94ff2c260e31823088422af782
Author: Jan Palus <atler at pld-linux.org>
Date:   Wed Jan 4 21:25:56 2023 +0100

    sort-pkgs: for packages dir try evaluting %_topdir

 sort-pkgs | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
---
diff --git a/sort-pkgs b/sort-pkgs
index 7b1fa41..07c1ac3 100755
--- a/sort-pkgs
+++ b/sort-pkgs
@@ -16,7 +16,15 @@ BR_PATTERN = re.compile('BuildRequires:\s+(.*?)(\s|$)')
 PACKAGE_PATTERN_WITH_N = re.compile('%package\s+-n\s+(.*)')
 PACKAGE_PATTERN = re.compile('%package\s+(.*)')
 
-DIR = os.getenv("HOME") + '/rpm/packages'
+try:
+    import rpm
+    DIR = rpm.expandMacro('%_topdir')
+except ModuleNotFoundError:
+    try:
+        import subprocess
+        DIR = subprocess.check_output(['rpm', '-E', '%_topdir']).decode('utf-8').strip()
+    except:
+        DIR = os.getenv("HOME") + '/rpm/packages'
 
 BUILD_REQUIRES = {}
 PACKAGES = {}
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/rpm-build-tools.git/commitdiff/1481cd8ea6ac35a07e8280abaa0a4fbe55941da9



More information about the pld-cvs-commit mailing list