From b08bca74b55489c15543e1e58dc2788db2956c08 Mon Sep 17 00:00:00 2001 From: Faik Uygur Date: Wed, 6 Dec 2006 12:40:30 +0000 Subject: [PATCH] Add owner and group attributes to AdditionalFile tag. example: apache.conf --- pisi/build.py | 12 ++++++++++++ pisi/specfile.py | 3 ++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/pisi/build.py b/pisi/build.py index 49e0a5ed..0db8791a 100644 --- a/pisi/build.py +++ b/pisi/build.py @@ -18,6 +18,8 @@ import glob from copy import deepcopy from os.path import basename, dirname from stat import S_IMODE +from pwd import getpwnam +from grp import getgrnam import gettext __trans = gettext.translation('pisi', fallback=True) @@ -786,6 +788,16 @@ class Builder: if afile.permission: # mode is octal! os.chmod(dest, int(afile.permission, 8)) + if afile.owner: + try: + os.chown(dest, getpwnam(afile.owner)[2], -1) + except KeyError: + ctx.ui.warning(_("No user named '%s' found on the system") % afile.owner) + if afile.group: + try: + os.chown(dest, -1, getgrnam(afile.group)[2]) + except KeyError: + ctx.ui.warning(_("No group named '%s' found on the system") % afile.group) os.chdir(c) ctx.ui.action(_("** Building package %s") % package.name); diff --git a/pisi/specfile.py b/pisi/specfile.py index d9f1053a..024fe769 100644 --- a/pisi/specfile.py +++ b/pisi/specfile.py @@ -55,6 +55,8 @@ class AdditionalFile: s_Filename = [autoxml.String, autoxml.mandatory] a_target = [autoxml.String, autoxml.mandatory] a_permission = [autoxml.String, autoxml.optional] + a_owner = [autoxml.String, autoxml.optional] + a_group = [autoxml.String, autoxml.optional] def __str__(self): s = "%s -> %s " % (self.filename, self.target) @@ -62,7 +64,6 @@ class AdditionalFile: s += '(%s)' % self.permission return s - class Patch: s_Filename = [autoxml.String, autoxml.mandatory]