Symlink /usr/sbin to /usr/bin if possible
/usr/local/sbin is also symlinked to /usr/local/bin if possible. 'return 0' is dropped because that causes issues with rpm: https://github.com/rpm-software-management/rpm/issues/3029
This commit is contained in:
parent
8681f7a4f3
commit
c6b64acaef
@ -176,7 +176,6 @@ end
|
||||
posix.mkdir("/var")
|
||||
posix.symlink("../run", "/var/run")
|
||||
posix.symlink("../run/lock", "/var/lock")
|
||||
return 0
|
||||
|
||||
%global sbin_filenames %{lua:
|
||||
print('{\\n')
|
||||
@ -2283,6 +2282,55 @@ while b do
|
||||
|
||||
b = rpm.next_file()
|
||||
end
|
||||
|
||||
%global merge_scriptlet %{expand:
|
||||
--# Symlink /usr/sbin→/usr/bin and /usr/local/sbin→/usr/local/bin if possible
|
||||
|
||||
for _,path in pairs({"/usr/sbin", "/usr/local/sbin"}) do
|
||||
st = posix.stat(path)
|
||||
if st and st.type ~= "link" then
|
||||
good = true
|
||||
|
||||
items = rpm.glob(path.."/*")
|
||||
for _,v in pairs(items) do
|
||||
--# rpm.glob() returns the original pattern if match fails :(((
|
||||
if v ~= path.."/*" then
|
||||
st = posix.stat(v)
|
||||
|
||||
if not st then
|
||||
print("Could not stat "..v)
|
||||
else
|
||||
if st.type ~= "link" then
|
||||
print("/usr/sbin cannot be merged, found "..v)
|
||||
good = false
|
||||
break
|
||||
end
|
||||
|
||||
target = posix.readlink(v)
|
||||
name = v:match("^.+/(.+)$")
|
||||
if target ~= "../bin/"..name then
|
||||
print("/usr/sbin cannot be merged, "..v.." points to "..target)
|
||||
good = false
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if good then
|
||||
print("All files under "..path.." are symlinks; linking to ./bin...")
|
||||
|
||||
for _,v in pairs(items) do
|
||||
os.remove(v)
|
||||
end
|
||||
os.remove(path)
|
||||
posix.symlink("bin", path)
|
||||
print("...done")
|
||||
end
|
||||
end
|
||||
end
|
||||
}
|
||||
|
||||
%posttrans -p <lua>
|
||||
--# we need to restorecon on some dirs created in %pretrans or by other packages
|
||||
if posix.access ("/usr/sbin/restorecon", "x") then
|
||||
@ -2290,6 +2338,11 @@ if posix.access ("/usr/sbin/restorecon", "x") then
|
||||
rpm.execute("/usr/sbin/restorecon", "-r", "/usr/lib/debug")
|
||||
end
|
||||
|
||||
%merge_scriptlet
|
||||
|
||||
%transfiletriggerpostun -p <lua> -- /sbin /usr/sbin
|
||||
%merge_scriptlet
|
||||
|
||||
%files content
|
||||
%dir %{_datadir}/filesystem
|
||||
%{_datadir}/filesystem/paths
|
||||
|
Loading…
Reference in New Issue
Block a user