[pacman-dev,5/7] pmdb: add option to skip populating file:// server

Message ID 20210119183010.12831-5-andrew.gregory.8@gmail.com
State New
Headers show
Series [pacman-dev,1/7] pacman: add -w to -U | expand

Commit Message

Andrew Gregory Jan. 19, 2021, 6:30 p.m. UTC
Populating a file:// Server prevents any manually registered HTTP
servers from ever being used.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
---
 test/pacman/pmdb.py   | 1 +
 test/pacman/pmtest.py | 7 ++++---
 test/pacman/util.py   | 9 ++++-----
 3 files changed, 9 insertions(+), 8 deletions(-)

Patch

diff --git a/test/pacman/pmdb.py b/test/pacman/pmdb.py
index 971e28eb..cae51b4e 100644
--- a/test/pacman/pmdb.py
+++ b/test/pacman/pmdb.py
@@ -54,6 +54,7 @@  def __init__(self, treename, root):
         self.root = root
         self.pkgs = []
         self.option = {}
+        self.syncdir = True
         if self.treename == "local":
             self.dbdir = os.path.join(root, util.PM_DBPATH, treename)
             self.dbfile = None
diff --git a/test/pacman/pmtest.py b/test/pacman/pmtest.py
index ed6eab6a..8669f31d 100644
--- a/test/pacman/pmtest.py
+++ b/test/pacman/pmtest.py
@@ -167,10 +167,11 @@  def generate(self, pacman):
                 vprint("\t%s" % os.path.join(util.PM_CACHEDIR, pkg.filename()))
                 if self.cachepkgs:
                     pkg.makepkg(cachedir)
-                else:
+                elif value.syncdir:
                     pkg.makepkg(os.path.join(syncdir, value.treename))
-                pkg.md5sum = util.getmd5sum(pkg.path)
-                pkg.csize = os.stat(pkg.path)[stat.ST_SIZE]
+                if pkg.path:
+                    pkg.md5sum = util.getmd5sum(pkg.path)
+                    pkg.csize = os.stat(pkg.path)[stat.ST_SIZE]
 
         # Creating sync database archives
         vprint("    Creating databases")
diff --git a/test/pacman/util.py b/test/pacman/util.py
index 1e0eb385..2957a020 100644
--- a/test/pacman/util.py
+++ b/test/pacman/util.py
@@ -122,11 +122,10 @@  def mkcfgfile(filename, root, option, db):
     for key in sorted(db.keys()):
         if key != "local":
             value = db[key]
-            data.append("[%s]\n" \
-                    "SigLevel = %s\n" \
-                    "Server = file://%s" \
-                     % (value.treename, value.getverify(), \
-                        os.path.join(root, SYNCREPO, value.treename)))
+            data.append("[%s]\n" % (value.treename))
+            data.append("SigLevel = %s\n" % (value.getverify()))
+            if value.syncdir:
+                data.append("Server = file://%s" % (os.path.join(root, SYNCREPO, value.treename)))
             for optkey, optval in value.option.items():
                 data.extend(["%s = %s" % (optkey, j) for j in optval])