;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2016 ng0 ;;; ;;; This file is part of GNU Guix. ;;; ;;; GNU Guix is free software; you can redistribute it and/or modify it ;;; under the terms of the GNU General Public License as published by ;;; the Free Software Foundation; either version 3 of the License, or (at ;;; your option) any later version. ;;; ;;; GNU Guix 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 General Public License for more details. ;;; ;;; You should have received a copy of the GNU General Public License ;;; along with GNU Guix. If not, see . (define-module (gnu packages pastebin) #:use-module (gnu packages) #:use-module (gnu packages bash) #:use-module (gnu packages certs) #:use-module (gnu packages curl) #:use-module (gnu packages libidn) #:use-module (gnu packages llvm) #:use-module (gnu packages tls) #:use-module (gnu packages tup) #:use-module (gnu packages pkg-config) #:use-module (gnu packages python) #:use-module (gnu packages web) #:use-module (gnu packages zsh) #:use-module (guix build-system gnu) #:use-module (guix git-download) #:use-module ((guix licenses) #:prefix license:) #:use-module (guix packages)) ;; We use this git checkout because it applies fixes needed to build ;; pbpst on Guix, essential additions to the used build system. (define-public pbpst (let ((revision "2") (commit "4aeb782cdd05251a902af427ce942f3b8a866188")) (package (name "pbpst") (version (string-append "1.2.0-" revision "." (string-take commit 7))) (source (origin ;; (method url-fetch) ;; (uri (string-append "https://github.com/HalosGhost/" ;; name "/archive/v" version ".tar.gz")) (method git-fetch) (uri (git-reference (url "https://github.com/HalosGhost/pbpst") (commit commit))) (file-name (string-append name "-" version "-checkout")) (sha256 (base32 "1w0js3z5xk4l1inxvh49w6ydahz33r7vn2mziziihn9h5qfadlhs")))) (build-system gnu-build-system) ;; XXX: "make simple" runs "make gen dist @./make.sh". make.sh is generated ;; by the primary build system, which is tup based. we can not use the ;; full tup build system as it requires to load FUSE. "make gen" runs ;; `tup generate make.sh' which is a new file, we need to apply some ;; Guix specific patching before we can continue. We therefore remove ;; "@./make.sh" from the "make simple" and run it manually, this way we can ;; patch make.sh before running it. (arguments `(#:make-flags (list (string-append "PREFIX=" (assoc-ref %outputs "out")) "simple") #:tests? #f #:phases (modify-phases %standard-phases (replace 'configure (lambda _ (substitute* "Makefile" (("@./make.sh") "") ;; XXX: Because this is a drop-in replacement build system, there are ;; some unexplainable special behaviors introduced. One of them is that ;; building pbpst binary out to ../dist/pbpst fails, but inside cwd ;; "src/" succeeds. I blame dark matter. Fix this if you feel the ;; desire for a headache. (("dist/\\$\\(PROGNM\\)") "src/$(PROGNM)") (("src/\\$\\(PROGNM\\)\\.1") "dist/$(PROGNM).1")) (substitute* "Tuprules.tup" (("`git describe --long --tags`") ,version)))) ;;(setenv "SSL_CERT_FILE" "/dev/null"))) ; I have no idea. ;;(setenv "SSL_CERT_DIR" "/etc/ssl/certs") ;;(setenv "SSL_CERT_FILE" "/etc/ssl/certs/ca-certificates.crt"))) (add-after 'build 'make-it (lambda _ (patch-shebang "make.sh") (substitute* "make.sh" (("clang -g -O3 -fPIE -pie -Weverything -Werror -std=c11 -ggdb -D_FORTIFY_SOURCE=2 -fstack-protector-strong -march=native --param=ssp-buffer-size=1 -Wl,-z,relro,-z,now -fsanitize=undefined -fsanitize-trap=undefined `pkg-config --libs-only-l libcurl jansson` callback.c main.c pb.c pbpst_db.c -o ../dist/pbpst") "clang -v -g -O3 -fPIE -pie -Weverything -Werror -std=c11 -ggdb -D_FORTIFY_SOURCE=2 -fstack-protector-strong -march=native --param=ssp-buffer-size=1 -Wl,-z,relro,-z,now -fsanitize=undefined -fsanitize-trap=undefined `pkg-config --libs-only-l libcurl jansson` callback.c main.c pb.c pbpst_db.c -o pbpst")) ;; (("gcc -g -O3 -fPIE -pie -Weverything -Werror -std=c11 -ggdb -D_FORTIFY_SOURCE=2 -fstack-protector-strong -march=native --param=ssp-buffer-size=1 -Wl,-z,relro,-z,now -fsanitize=undefined -fsanitize-trap=undefined `pkg-config --libs-only-l libcurl jansson` callback.c main.c pb.c pbpst_db.c -o ../dist/pbpst") ;; "gcc -v -g -O3 -fPIE -pie -Werror -std=c11 -ggdb -D_FORTIFY_SOURCE=2 -fstack-protector-strong -march=native --param=ssp-buffer-size=1 -Wl,-z,relro,-z,now -fsanitize=undefined `pkg-config --libs-only-l libcurl jansson` callback.c main.c pb.c pbpst_db.c -o pbpst")) ;; (("cp bash ../dist/bash") ;; "cp bash ../dist/bash ;;cd '..'")) (zero? (system* "bash" "make.sh"))))))) ;; the above fails, the one below was used with the 2.1.0 release ball: ;; (replace 'build ;; (lambda _ ;; (zero? (system* "make" "simple")) ;; (patch-shebang "make.sh") ;; (substitute* "make.sh" ;; (("`git describe --tags`") ,version)) ;; (zero? (system* "bash" "make.sh")))) ;; ;; (mkdir-p (string-append out "/dist")) ;; (mkdir-p "dist") ;; (chdir "src") ;; (zero? (system* "clang" "-g" "-O3" "-fPIE" "-pie" "-Weverything" ;; "-Werror" "-std=c11" "-ggdb" "-D_FORTIFY_SOURCE=2" ;; "-fstack-protector-strong" "-march=native" ;; "--param=ssp-buffer-size=1" "-Wl,-z,relro,-z,now" ;; "-fsanitize=undefined" "-fsanitize-trap=undefined" ;; "pkg-config" "--libs-only-l" "libcurl" "jansson" ;; "callback.c" "main.c" "pb.c" "pbpst_db.c" ;; "-o ../dist/pbpst")) ;; (chdir "../cmp") ;; (copy-file "zsh" "../dist/zsh") ;; (copy-file "bash" "../dist/bash") ;; (chdir "../doc") ;; (system* "sphinx-build" "-b man" "-Dversion=`git describe --tags`" ;; "-d doctree" "-E . ../dist pbpst.rst pbpst_db.rst") ;; (delete-file-recursively "doctree")))) (inputs `(("curl" ,curl) ("jansson" ,jansson) ("openssl" ,openssl) ("libidn" ,libidn) ;;("gnutls" ,gnutls) ;;("nss-certs" ,nss-certs) ("zsh" ,zsh) ; zsh completions ("bash" ,bash))) ; bash completions (native-inputs `(("clang" ,clang) ("clang-runtime" ,clang-runtime) ("tup" ,tup) ("pkg-config" ,pkg-config) ("python" ,python) ("python-sphinx" ,python-sphinx))) (outputs '("out" "debug")) ;; (native-search-paths ;; ;; FIXME: These two variables must designate a single file or directory ;; ;; and are not actually "search paths." In practice it works OK in ;; ;; user profiles because there's always just one item that matches the ;; ;; specification. ;; (list (search-path-specification ;; (variable "SSL_CERT_DIR") ;; (files '("etc/ssl/certs"))) ;; (search-path-specification ;; (variable "SSL_CERT_FILE") ;; (files '("etc/ssl/certs/ca-certificates.crt"))))) (synopsis "Command-line libcurl C client for pb deployments") (description "pbpst is a small tool to make interacting with pb instances as simple as possible. pb is a versatile, free and open source pastebin which has more features, is more robust, and is faster than any other pastebin with which I am familiar. You can find the reference instance (which tracks pb's master branch) at ptpb. Ideally, pbpst will support as many features of pb as possible (hopefully, nearly all) in a simple, unassuming CLI.") (home-page "https://github.com/HalosGhost/pbpst/") (license license:gpl2))))