summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVivien Kraus <vivien@planete-kraus.eu>2021-07-30 16:00:04 +0200
committerVivien Kraus <vivien@planete-kraus.eu>2021-08-01 15:25:08 +0200
commit0367cbc75712f4be692a1ec3d37510cf2751ca3a (patch)
tree31eadd80bf7a7c94ae1047298f57dead559f6b4a
parented64c545c4723dc0efdb1265b05d682e11e4c1f6 (diff)
Add a command to generate the docker image
-rw-r--r--guix/vkraus/packages/disfluid-load-image.scm89
1 files changed, 89 insertions, 0 deletions
diff --git a/guix/vkraus/packages/disfluid-load-image.scm b/guix/vkraus/packages/disfluid-load-image.scm
new file mode 100644
index 0000000..90a6ff3
--- /dev/null
+++ b/guix/vkraus/packages/disfluid-load-image.scm
@@ -0,0 +1,89 @@
+;; disfluid, implementation of the Solid specification
+;; Copyright (C) 2020, 2021 Vivien Kraus
+
+;; This program is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU Affero General Public License as
+;; published by the Free Software Foundation, either version 3 of the
+;; License, or (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU Affero General Public License for more details.
+
+;; You should have received a copy of the GNU Affero General Public License
+;; along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+(define-module (vkraus packages disfluid-load-image)
+ #:use-module (guix packages)
+ #:use-module (guix gexp)
+ #:use-module ((guix licenses) #:prefix license:)
+ #:use-module (guix download)
+ #:use-module (guix git-download)
+ #:use-module (guix build-system trivial)
+ #:use-module (gnu packages)
+ #:use-module (gnu packages admin)
+ #:use-module (gnu packages base)
+ #:use-module (gnu packages bash)
+ #:use-module (gnu packages docker))
+
+(define builder
+ '(let ((out (assoc-ref %outputs "out"))
+ (bash-in (assoc-ref %build-inputs "bash"))
+ (coreutils-in (assoc-ref %build-inputs "coreutils"))
+ (grep-in (assoc-ref %build-inputs "grep"))
+ (docker-in (assoc-ref %build-inputs "docker-cli")))
+ (mkdir out)
+ (mkdir (string-append out "/bin"))
+ (call-with-output-file (string-append out "/bin/disfluid-load-image")
+ (lambda (port)
+ (format port "#!~a/bin/bash
+if ! VERSION=$(guix show disfluid | ~a/bin/grep '^version:' | ~a/bin/cut -d ' ' -f 2)
+then
+ >&2 echo \"Failed to get disfluid version.\"
+ exit 1
+fi
+
+if ! TARBALL=$(guix pack -c 16 -f docker -Sbin=/bin gnutls nss-certs disfluid)
+then
+ >&2 echo \"Failed to put disfluid in a pack.\"
+ exit 1
+fi
+
+if ! IMAGE=$(sudo ~a/bin/docker load -i $TARBALL | ~a/bin/tail -n 1 | ~a/bin/cut -b 15-)
+then
+ >&2 echo \"Failed to load the image.\"
+ exit 1
+fi
+
+sudo ~a/bin/docker tag $IMAGE vivienkraus/disfluid:$VERSION \
+ || (>&2 echo \"Failed to tag the image.\" ; exit 1)
+
+sudo ~a/bin/docker tag vivienkraus/disfluid:$VERSION vivienkraus/disfluid:latest \
+ || (>&2 echo \"Failed to tag the image.\" ; exit 1)
+
+echo vivienkraus/disfluid:$VERSION
+"
+ bash-in
+ grep-in coreutils-in
+ docker-in coreutils-in coreutils-in
+ docker-in
+ docker-in)))
+ (chmod (string-append out "/bin/disfluid-load-image") #o755)
+ #t))
+
+(define-public disfluid-load-image
+ (package
+ (name "disfluid-load-image")
+ (version "0.0.0")
+ (source (plain-file "empty" ""))
+ (build-system trivial-build-system)
+ (arguments `(#:builder ,builder))
+ (inputs `(("bash" ,bash)
+ ("coreutils" ,coreutils)
+ ("grep" ,grep)
+ ("docker-cli" ,docker-cli)))
+ (synopsis "Generate a docker image for disfluid")
+ (description "Some people like to have disfluid in a docker image, but the guix pack invocation is not trivial.")
+ (home-page "https://labo.planete-kraus.eu/webid-oidc.git")
+ (license license:gpl3+)))