mirror of
https://git.savannah.gnu.org/git/guix.git
synced 2026-04-06 21:20:33 +02:00
gnu: hosts: Modernize package.
* gnu/packages/admin.scm (hosts): Modernizeodernize. [build-system]: Switch to copy-build-system. [inputs]: Switch no new-style inputs. Move bats to native-inputs. Replace bash with bash-minimal. [native-inputs]: Add bats. [arguments]<#:modules><#:builder>: Remove. <#:phases>: Add patch-hosts and check phases. Change-Id: Id42e7a4c9ee533d2691009ab480a3a927dd7c83b Signed-off-by: Sharlatan Hellseher <sharlatanus@gmail.com>
This commit is contained in:
committed by
Sharlatan Hellseher
parent
2f71901c06
commit
36ac8fadc8
@@ -5603,68 +5603,60 @@ representation to stdout.")
|
|||||||
(package
|
(package
|
||||||
(name "hosts")
|
(name "hosts")
|
||||||
(version "3.6.5")
|
(version "3.6.5")
|
||||||
(source (origin
|
(source
|
||||||
(method git-fetch)
|
(origin
|
||||||
(uri (git-reference
|
(method git-fetch)
|
||||||
(url "https://github.com/xwmx/hosts")
|
(uri (git-reference
|
||||||
(commit version)))
|
(url "https://github.com/xwmx/hosts")
|
||||||
(file-name (git-file-name name version))
|
(commit version)))
|
||||||
(sha256
|
(file-name (git-file-name name version))
|
||||||
(base32
|
(sha256
|
||||||
"1kzd4lxlflam87dhbx1jx7bj6v6sa4f2024mfxj2768kp9qapraj"))))
|
(base32 "1kzd4lxlflam87dhbx1jx7bj6v6sa4f2024mfxj2768kp9qapraj"))))
|
||||||
(build-system trivial-build-system)
|
(build-system copy-build-system)
|
||||||
|
(native-inputs
|
||||||
|
(list bats)) ;for tests
|
||||||
(inputs
|
(inputs
|
||||||
`(("bats" ,bats) ;for test
|
(list gawk
|
||||||
("awk" ,gawk)
|
bash-minimal
|
||||||
("bash" ,bash)
|
coreutils
|
||||||
("coreutils" ,coreutils)
|
diffutils
|
||||||
("diffutils" ,diffutils)
|
grep
|
||||||
("grep" ,grep)
|
ncurses ;for tput
|
||||||
("ncurses" ,ncurses) ;tput
|
sed))
|
||||||
("sed" ,sed)))
|
|
||||||
(arguments
|
(arguments
|
||||||
`(#:modules ((guix build utils))
|
(list
|
||||||
#:builder
|
#:install-plan
|
||||||
(begin
|
#~'(("hosts" "bin/hosts")
|
||||||
(use-modules (guix build utils))
|
("etc/hosts-completion.bash" "/etc/bash_completion.d/hosts")
|
||||||
;; copy source
|
("etc/hosts-completion.zsh" "/share/zsh/site-functions/_hosts")
|
||||||
(copy-recursively (assoc-ref %build-inputs "source") ".")
|
("README.md"
|
||||||
;; patch-shebang phase
|
#$(string-append "/share/doc/" name "-" version "/README.md")))
|
||||||
(setenv "PATH"
|
#:phases
|
||||||
(string-append (assoc-ref %build-inputs "bash") "/bin"
|
#~(modify-phases %standard-phases
|
||||||
":" (assoc-ref %build-inputs "awk") "/bin"
|
(add-after 'unpack 'patch-hosts
|
||||||
":" (assoc-ref %build-inputs "coreutils") "/bin"
|
(lambda* (#:key inputs #:allow-other-keys)
|
||||||
":" (assoc-ref %build-inputs "diffutils") "/bin"
|
(substitute* "test/test_helper.bash"
|
||||||
":" (assoc-ref %build-inputs "grep") "/bin"
|
(("export _HOSTS=.*")
|
||||||
":" (assoc-ref %build-inputs "ncurses") "/bin"
|
(string-append "export _HOSTS=" #$output "/bin/hosts")))
|
||||||
":" (assoc-ref %build-inputs "sed") "/bin"
|
(substitute* (cons* "hosts"
|
||||||
":" "/run/privileged/bin"
|
;; *.bash and *.bats.
|
||||||
":" (getenv "PATH")))
|
(find-files "test" "\\.bat?sh?.*$"))
|
||||||
(substitute* "hosts"
|
(("\\btput\\b") (search-input-file inputs "bin/tput"))
|
||||||
(("#!/usr/bin/env bash")
|
(("\\bsed\\b") (search-input-file inputs "bin/sed"))
|
||||||
(string-append "#!" (which "bash")
|
(("\\bawk\\b") (search-input-file inputs "bin/awk"))
|
||||||
"\nPATH=" (getenv "PATH"))))
|
(("\\bgrep\\b") (search-input-file inputs "bin/grep"))
|
||||||
;; check phase
|
(("\\bdiff\\b") (search-input-file inputs "bin/diff"))
|
||||||
(setenv "TERM" "linux") ;set to tty for test
|
(("\\bcp\\b") (search-input-file inputs "bin/cp"))
|
||||||
(invoke (search-input-file %build-inputs "/bin/bats")
|
(("\\bchmod\\b") (search-input-file inputs "bin/chmod")))))
|
||||||
"test")
|
(add-after 'install 'check
|
||||||
;; install phase
|
(lambda* (#:key tests? inputs #:allow-other-keys)
|
||||||
(install-file "hosts" (string-append %output "/bin"))
|
(if tests?
|
||||||
(let ((bash-completion
|
(begin
|
||||||
(string-append %output "/etc/bash_completion.d")))
|
(delete-file "hosts") ;Ensure installed hosts is checked.
|
||||||
(mkdir-p bash-completion)
|
(setenv "PATH" "") ;Ensure substitutions were correct.
|
||||||
(copy-file "etc/hosts-completion.bash"
|
(setenv "TERM" "linux") ;Set to tty for test.
|
||||||
(string-append bash-completion "/hosts")))
|
(invoke (search-input-file inputs "/bin/bats")
|
||||||
(let ((zsh-completion
|
"test"))))))))
|
||||||
(string-append %output "/share/zsh/site-functions")))
|
|
||||||
(mkdir-p zsh-completion)
|
|
||||||
(copy-file "etc/hosts-completion.zsh"
|
|
||||||
(string-append zsh-completion "/_hosts")))
|
|
||||||
(let ((doc (string-append %output "/share/doc/" ,name "-" ,version)))
|
|
||||||
(mkdir-p doc)
|
|
||||||
(install-file "LICENSE" doc)
|
|
||||||
(install-file "README.md" doc))
|
|
||||||
#t)))
|
|
||||||
(home-page "https://github.com/xwmx/hosts/")
|
(home-page "https://github.com/xwmx/hosts/")
|
||||||
(synopsis "Script for editing a foreign distro's @file{/etc/hosts} file")
|
(synopsis "Script for editing a foreign distro's @file{/etc/hosts} file")
|
||||||
(description "Hosts is a command line program for managing
|
(description "Hosts is a command line program for managing
|
||||||
|
|||||||
Reference in New Issue
Block a user