From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id BE753138D19 for ; Tue, 14 Jul 2015 23:37:39 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 69AFDE0880; Tue, 14 Jul 2015 23:37:37 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id F23ADE0880 for ; Tue, 14 Jul 2015 23:37:36 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id EA760340A99 for ; Tue, 14 Jul 2015 23:37:35 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 7898F74B for ; Tue, 14 Jul 2015 23:37:32 +0000 (UTC) From: "Anthony G. Basile" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Anthony G. Basile" Message-ID: <1436917183.02b84c23ce71cfc1d26d86967b95fde9d892ffe1.blueness@gentoo> Subject: [gentoo-commits] proj/grss:master commit in: grs/ X-VCS-Repository: proj/grss X-VCS-Files: grs/TarIt.py X-VCS-Directories: grs/ X-VCS-Committer: blueness X-VCS-Committer-Name: Anthony G. Basile X-VCS-Revision: 02b84c23ce71cfc1d26d86967b95fde9d892ffe1 X-VCS-Branch: master Date: Tue, 14 Jul 2015 23:37:32 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: c0edf3ef-333e-4cfa-b327-dec31fdd40a5 X-Archives-Hash: 65ed018e22f3625583051f20173997d1 commit: 02b84c23ce71cfc1d26d86967b95fde9d892ffe1 Author: Anthony G. Basile gentoo org> AuthorDate: Tue Jul 14 23:39:43 2015 +0000 Commit: Anthony G. Basile gentoo org> CommitDate: Tue Jul 14 23:39:43 2015 +0000 URL: https://gitweb.gentoo.org/proj/grss.git/commit/?id=02b84c23 grs/TarIt.py: add documentation. grs/TarIt.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/grs/TarIt.py b/grs/TarIt.py index b0b18e5..a8b21b3 100644 --- a/grs/TarIt.py +++ b/grs/TarIt.py @@ -6,31 +6,42 @@ from grs.Constants import CONST from grs.Execute import Execute class TarIt(): + """ Create a tarball of the system and generate the hash values. """ def __init__(self, name, portage_configroot = CONST.PORTAGE_CONFIGROOT, logfile = CONST.LOGFILE): self.portage_configroot = portage_configroot self.logfile = logfile - + # Prepare a year, month and day for a tarball name timestamp. self.year = str(datetime.now().year).zfill(4) self.month = str(datetime.now().month).zfill(2) self.day = str(datetime.now().day).zfill(2) self.tarball_name = '%s-%s%s%s.tar.xz' % (name, self.year, self.month, self.day) self.digest_name = '%s.DIGESTS' % self.tarball_name + def tarit(self, alt_name = None): + # Create the tarball with the default name unless an alt_name is given. if alt_name: self.tarball_name = '%s-%s%s%s.tar.xz' % (alt_name, self.year, self.month, self.day) self.digest_name = '%s.DIGESTS' % self.tarball_name + # We have to cd into the system's portage configroot and then out again. cwd = os.getcwd() os.chdir(self.portage_configroot) tarball_path = os.path.join('..', self.tarball_name) - # This needs to be generalized for systems that don't support xattrs + # TODO: This needs to be generalized for systems that don't support xattrs xattr_opts = '--xattrs --xattrs-include=security.capability --xattrs-include=user.pax.flags' cmd = 'tar %s -Jcf %s .' % (xattr_opts, tarball_path) Execute(cmd, timeout=None, logfile=self.logfile) os.chdir(cwd) + def hashit(self): + """ Generate various hash values. We hijack the 'logfile' which will + actually be the file containing the hashes. + """ + # We need to be in the parent of the system's portage configroot because + # that's where we created the above tarball. This should be the workdir, + # but its probably safer to be pedantic here. cwd = os.getcwd() os.chdir(os.path.join(self.portage_configroot, '..'))