mirror of
https://git.FreeBSD.org/ports.git
synced 2024-12-29 05:38:00 +00:00
d3e58fed85
This makes @shell rootdir friendly and cross install friendly as well as capsicumized. Bonus: the /etc/shells is now only touched when needed Reviewed by: manu, mat Approved by: portmgr (mat) Differential Revision: D26640
48 lines
1001 B
Plaintext
48 lines
1001 B
Plaintext
# $FreeBSD$
|
|
#
|
|
# MAINTAINER: portmgr@FreeBSD.org
|
|
#
|
|
# @shell bin/shell
|
|
#
|
|
# Handle adding and remove a path to a shell binary into /etc/shells
|
|
#
|
|
|
|
actions: [file]
|
|
post-install-lua: <<EOD
|
|
shell_path = pkg.prefixed_path("%@")
|
|
shell = io.open("/etc/shells", "r+")
|
|
while true do
|
|
line = shell:read()
|
|
if line == nil then break end
|
|
if line == shell_path then
|
|
-- the shell path is already in the shell file
|
|
shell:close()
|
|
return
|
|
end
|
|
end
|
|
shell:write(shell_path .. "\n")
|
|
shell:close()
|
|
EOD
|
|
pre-deinstall-lua: <<EOD
|
|
shell_path = pkg.prefixed_path("%@")
|
|
shellsbuf = ""
|
|
shells_path = "/etc/shells"
|
|
shell = io.open(shells_path, "r+")
|
|
found = false
|
|
while true do
|
|
line = shell:read()
|
|
if line == nil then break end
|
|
if line == shell_path then
|
|
found = true
|
|
else
|
|
shellsbuf = shellsbuf .. line .. "\n"
|
|
end
|
|
end
|
|
shell:close()
|
|
if found then
|
|
shell = io.open(shells_path, "w+")
|
|
shell:write(shellsbuf)
|
|
shell:close()
|
|
end
|
|
EOD
|