From patchwork Thu Jul 21 17:15:51 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ross Burton X-Patchwork-Id: 72579 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp557563qga; Thu, 21 Jul 2016 10:16:07 -0700 (PDT) X-Received: by 10.98.12.18 with SMTP id u18mr74331887pfi.89.1469121367861; Thu, 21 Jul 2016 10:16:07 -0700 (PDT) Return-Path: Received: from mail.openembedded.org (mail.openembedded.org. [140.211.169.62]) by mx.google.com with ESMTP id tu5si10830075pab.149.2016.07.21.10.16.07; Thu, 21 Jul 2016 10:16:07 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of openembedded-core-bounces@lists.openembedded.org designates 140.211.169.62 as permitted sender) client-ip=140.211.169.62; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@intel-com.20150623.gappssmtp.com; spf=pass (google.com: best guess record for domain of openembedded-core-bounces@lists.openembedded.org designates 140.211.169.62 as permitted sender) smtp.mailfrom=openembedded-core-bounces@lists.openembedded.org Received: from layers.openembedded.org (localhost [127.0.0.1]) by mail.openembedded.org (Postfix) with ESMTP id F06106FFCD; Thu, 21 Jul 2016 17:16:00 +0000 (UTC) X-Original-To: openembedded-core@lists.openembedded.org Delivered-To: openembedded-core@lists.openembedded.org Received: from mail-wm0-f43.google.com (mail-wm0-f43.google.com [74.125.82.43]) by mail.openembedded.org (Postfix) with ESMTP id CE38E607A5 for ; Thu, 21 Jul 2016 17:15:58 +0000 (UTC) Received: by mail-wm0-f43.google.com with SMTP id f65so29095491wmi.0 for ; Thu, 21 Jul 2016 10:15:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel-com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id; bh=rWRwZO57f5Fy5U3BNEeXUmBWUgoq/rU/A68O4OWzuEg=; b=yZ5XICIr8q6V3+p/zufh9S51HeEFPFA81MJvOiYDPMIizZTiWKHHViWgjZ+ay4G8gs P0ewfwLYe+17WM/1PDg7BO/RbwU/WsiNLlFZ2M31rv7T+4c2BdSdI0Pv7+5yNxHTV3Ji ak4L9vOA9X2YzWV39jbIuQ8JUOQWyiBUrz2W+HoVWB2kgQeELbOgulRTPwKl7ejARJ29 CuvbrOYOZIS/0FCBuUmsY7R7P8lwyvMXf4W2ABjwzjUsK0Upd8s7kjpoFGZSYmt6EHin /T06O6g8nn5zDCocUW680cCxl223aEMJ6ywDzzsbYMsc1A8jTDQlDe4mRJN9/0gcfleZ YMzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id; bh=rWRwZO57f5Fy5U3BNEeXUmBWUgoq/rU/A68O4OWzuEg=; b=POpbqBlgIpZnZ3mup5JBX8rBue3SXdMmQDDcJ9qwFefmlTccqV314bC/gK6nur21Bq Y5ZmghKZwPHay2o9scaVMjWOQ2QtYLuClx8gYTHv0pWypdUWY7bslbMawWvwERasAtH2 eLalnCxuQRj3aawtrr15li+x7Iz6OdpGAHPJ8Sd3vmDf851DoUrGMKQ+S+c5oBnhhfNY 5fvUo17Gh5dZtwuZDxdZKIB3vcsPeczDd0xGjxf6X6TVbJ1k9XsteD9o/aDckNRbXvDg 4NQ/CGoTVfcO5ntqy8cP67z0PGgiSRdl5/vmpMhYtKWe+Vy7R5Xb8gjNghdECOMYQkbC PGTg== X-Gm-Message-State: ALyK8tIfFX28EJrIOIocmtKmSKE8YjIIPn2yXyJQYe8TKNyz4JVVBB9Ls2Kb8qvOCcF9ZX0Z X-Received: by 10.28.9.194 with SMTP id 185mr18300150wmj.37.1469121357909; Thu, 21 Jul 2016 10:15:57 -0700 (PDT) Received: from flashheart.burtonini.com (home.burtonini.com. [81.2.106.35]) by smtp.gmail.com with ESMTPSA id a194sm5552715wmd.24.2016.07.21.10.15.56 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 21 Jul 2016 10:15:57 -0700 (PDT) From: Ross Burton To: openembedded-core@lists.openembedded.org Date: Thu, 21 Jul 2016 18:15:51 +0100 Message-Id: <1469121352-29774-1-git-send-email-ross.burton@intel.com> X-Mailer: git-send-email 2.8.1 Subject: [OE-core] [PATCH 1/2] oeqa/selftest/signing: use a temporary directory for GPG home X-BeenThere: openembedded-core@lists.openembedded.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: Patches and discussions about the oe-core layer List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: openembedded-core-bounces@lists.openembedded.org Errors-To: openembedded-core-bounces@lists.openembedded.org Instead of using a directory in the layer as the GPG home and carefully deleting the right files from it, use tempfile to create a temporary directory which will be cleaned up for us. Also change the public/secret key variables to be absolute paths as they're always used as absolute paths. Signed-off-by: Ross Burton --- meta/lib/oeqa/selftest/signing.py | 32 ++++++++++---------------------- 1 file changed, 10 insertions(+), 22 deletions(-) -- 2.8.1 -- _______________________________________________ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core diff --git a/meta/lib/oeqa/selftest/signing.py b/meta/lib/oeqa/selftest/signing.py index 1babca0..beafd63 100644 --- a/meta/lib/oeqa/selftest/signing.py +++ b/meta/lib/oeqa/selftest/signing.py @@ -12,30 +12,18 @@ from oeqa.utils.ftools import write_file class Signing(oeSelfTest): gpg_dir = "" - pub_key_name = 'key.pub' - secret_key_name = 'key.secret' + pub_key_path = "" + secret_key_path = "" @classmethod def setUpClass(cls): - # Import the gpg keys + cls.gpg_home_dir = tempfile.TemporaryDirectory(prefix="oeqa-signing-") + cls.gpg_dir = cls.gpg_home_dir.name - cls.gpg_dir = os.path.join(cls.testlayer_path, 'files/signing/') + cls.pub_key_path = os.path.join(cls.testlayer_path, 'files', 'signing', "key.pub") + cls.secret_key_path = os.path.join(cls.testlayer_path, 'files', 'signing', "key.secret") - # key.secret key.pub are located in gpg_dir - pub_key_location = cls.gpg_dir + cls.pub_key_name - secret_key_location = cls.gpg_dir + cls.secret_key_name - runCmd('gpg --homedir %s --import %s %s' % (cls.gpg_dir, pub_key_location, secret_key_location)) - - @classmethod - def tearDownClass(cls): - # Delete the files generated by 'gpg --import' - - gpg_files = glob.glob(cls.gpg_dir + '*.gpg*') - random_seed_file = cls.gpg_dir + 'random_seed' - gpg_files.append(random_seed_file) - - for gpg_file in gpg_files: - runCmd('rm -f ' + gpg_file) + runCmd('gpg --homedir %s --import %s %s' % (cls.gpg_dir, cls.pub_key_path, cls.secret_key_path)) @testcase(1362) def test_signing_packages(self): @@ -57,7 +45,7 @@ class Signing(oeSelfTest): feature = 'INHERIT += "sign_rpm"\n' feature += 'RPM_GPG_PASSPHRASE = "test123"\n' feature += 'RPM_GPG_NAME = "testuser"\n' - feature += 'RPM_GPG_PUBKEY = "%s%s"\n' % (self.gpg_dir, self.pub_key_name) + feature += 'RPM_GPG_PUBKEY = "%s"\n' % self.pub_key_path feature += 'GPG_PATH = "%s"\n' % self.gpg_dir self.write_config(feature) @@ -81,8 +69,8 @@ class Signing(oeSelfTest): # Use a temporary rpmdb rpmdb = tempfile.mkdtemp(prefix='oeqa-rpmdb') - runCmd('%s/rpm --define "_dbpath %s" --import %s%s' % - (staging_bindir_native, rpmdb, self.gpg_dir, self.pub_key_name)) + runCmd('%s/rpm --define "_dbpath %s" --import %s' % + (staging_bindir_native, rpmdb, self.pub_key_path)) ret = runCmd('%s/rpm --define "_dbpath %s" --checksig %s' % (staging_bindir_native, rpmdb, pkg_deploy))