[pacman-dev] [PATCH 3/5] Simplify the Python code that sets utime of test package files.
Allan McRae
allan at archlinux.org
Mon Dec 30 03:27:22 EST 2013
On 11/11/13 21:47, Jeremy Heiner wrote:
> Making util.mkfile responsible for calling os.utime avoids duplication
> of the code in both pmpkg and pmtest, and also the unnecessary
> repetition of the os.path.join (inside util.mkfile and again in
> pmpkg/pmtest).
>
> This change also eases the way forward for the more complicated utime
> code which is needed to support mtree testing.
>
> Signed-off-by: Jeremy Heiner <ScalaProtractor at gmail.com>
This seems fine to me. It appears dependent on changes Patch 2/5 in
this series (or at least it did not apply cleanly here...), so it will
need adjusted.
> ---
> test/pacman/pmpkg.py | 5 +----
> test/pacman/pmtest.py | 5 +----
> test/pacman/util.py | 4 +++-
> 3 files changed, 5 insertions(+), 9 deletions(-)
>
> diff --git a/test/pacman/pmpkg.py b/test/pacman/pmpkg.py
> index fd469b1..db97449 100644
> --- a/test/pacman/pmpkg.py
> +++ b/test/pacman/pmpkg.py
> @@ -192,10 +192,7 @@ def install_package(self, root):
> """Install the package in the given root."""
> self.runscript(root, "pre_install")
> for f in self.files:
> - util.mkfile(root, f, f)
> - path = os.path.join(root, f)
> - if os.path.isfile(path):
> - os.utime(path, (355, 355))
> + util.mkfile(root, f, f, True)
> self.runscript(root, "post_install")
>
> def filelist(self):
> diff --git a/test/pacman/pmtest.py b/test/pacman/pmtest.py
> index a1f3645d..9968dce 100644
> --- a/test/pacman/pmtest.py
> +++ b/test/pacman/pmtest.py
> @@ -175,10 +175,7 @@ def generate(self, pacman):
> vprint(" Populating file system")
> for f in self.filesystem:
> vprint("\t%s" % f)
> - util.mkfile(self.root, f, f)
> - path = os.path.join(self.root, f)
> - if os.path.isfile(path):
> - os.utime(path, (355, 355))
> + util.mkfile(self.root, f, f, True)
> for pkg in self.db["local"].pkgs:
> vprint("\tinstalling %s" % pkg.fullname())
> pkg.install_package(self.root)
> diff --git a/test/pacman/util.py b/test/pacman/util.py
> index ab5a6f4..beb7e3d 100644
> --- a/test/pacman/util.py
> +++ b/test/pacman/util.py
> @@ -77,7 +77,7 @@ def getfileinfo(filename):
> data["filename"] = filename
> return data
>
> -def mkfile(base, name, data=""):
> +def mkfile(base, name, data="", utime=False):
> info = getfileinfo(name)
> filename = info["filename"]
>
> @@ -95,6 +95,8 @@ def mkfile(base, name, data=""):
> os.symlink(info["link"], path)
> else:
> writedata(path, data)
> + if utime:
> + os.utime(path, (355, 355))
>
> if info["perms"]:
> os.chmod(path, info["perms"])
>
More information about the pacman-dev
mailing list