From 0367cbc75712f4be692a1ec3d37510cf2751ca3a Mon Sep 17 00:00:00 2001 From: Vivien Kraus Date: Fri, 30 Jul 2021 16:00:04 +0200 Subject: Add a command to generate the docker image --- guix/vkraus/packages/disfluid-load-image.scm | 89 ++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 guix/vkraus/packages/disfluid-load-image.scm 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 . + +(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+))) -- cgit v1.2.3