chiark / gitweb /
dirmngr: Drop useless housekeeping.
[gnupg2.git] / tests / migrations / common.scm
1 ;; Copyright (C) 2016 g10 Code GmbH
2 ;;
3 ;; This file is part of GnuPG.
4 ;;
5 ;; GnuPG is free software; you can redistribute it and/or modify
6 ;; it under the terms of the GNU General Public License as published by
7 ;; the Free Software Foundation; either version 3 of the License, or
8 ;; (at your option) any later version.
9 ;;
10 ;; GnuPG is distributed in the hope that it will be useful,
11 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 ;; GNU General Public License for more details.
14 ;;
15 ;; You should have received a copy of the GNU General Public License
16 ;; along with this program; if not, see <http://www.gnu.org/licenses/>.
17
18 (if (string=? "" (getenv "srcdir"))
19     (error "not called from make"))
20
21 (let ((verbose (string->number (getenv "verbose"))))
22   (if (number? verbose)
23       (*set-verbose!* verbose)))
24
25 (define (qualify executable)
26   (string-append executable (getenv "EXEEXT")))
27
28 ;; We may not use a relative name for gpg-agent.
29 (define GPG-AGENT (path-join (getenv "objdir") "agent" (qualify "gpg-agent")))
30 (define GPG `(,(path-join (getenv "objdir") "g10" (qualify "gpg"))
31               --no-permission-warning --no-greeting
32               --no-secmem-warning --batch
33               ,(string-append "--agent-program=" GPG-AGENT
34                               "|--debug-quick-random")))
35 (define GPG-no-batch
36   (filter (lambda (arg) (not (equal? arg '--batch))) GPG))
37
38 (define GPGTAR (path-join (getenv "objdir") "tools" (qualify "gpgtar")))
39
40 (define (untar-armored source-name)
41   (pipe:do
42    (pipe:open source-name (logior O_RDONLY O_BINARY))
43    (pipe:spawn `(,@GPG --dearmor))
44    (pipe:spawn `(,GPGTAR --extract --directory=. -))))
45
46 (define (run-test message src-tarball test)
47   (catch (skip "gpgtar not built")
48          (call-check `(,GPGTAR --help)))
49
50   (with-temporary-working-directory
51    (info message)
52    (untar-armored src-tarball)
53    (setenv "GNUPGHOME" (getcwd) #t)
54    (test (getcwd))))