Skip to content
Snippets Groups Projects
Commit 74575eb0 authored by Simon McVittie's avatar Simon McVittie
Browse files

Replace alternatives with relative symlinks, not hardlinks

parent 8213e56c
No related branches found
No related tags found
No related merge requests found
......@@ -194,9 +194,9 @@ actions:
{{ end }}
- action: run
label: hard-link-alternatives
label: symlink-alternatives
chroot: true
script: hard-link-alternatives
script: symlink-alternatives
{{ if $sdk }}
- action: run
......
#!/bin/bash
# Copyright © 2016-2017 Simon McVittie
# Copyright © 2017-2018 Collabora Ltd.
# Copyright © 2017-2019 Collabora Ltd.
#
# SPDX-License-Identifier: MIT
#
......@@ -47,9 +47,20 @@ find / -xdev '(' \
while [ $# -gt 0 ]; do
old="$(readlink "$1")"
if target="$(readlink -f "$1")"; then
echo "Making $1 a hard link to $target (was $old)"
rm -f "$1"
cp -al "$target" "$1"
rel_target="$target"
rel_link="$1"
# While the part up to the first / is equal, remove it
while [ "${rel_target%%/*}" = "${rel_link%%/*}" ]; do
rel_target="${rel_target#*/}"
rel_link="${rel_link#*/}"
done
# If the link has directories, add enough ../ to escape
while [ "${rel_link#*/}" != "${rel_link}" ]; do
rel_link="${rel_link#*/}"
rel_target="../${rel_target}"
done
echo "Making $1 a symlink to $rel_target (was $old -> ... -> $target)"
ln -fns "$rel_target" "$1"
fi
shift
done
......
......@@ -660,12 +660,12 @@ class Builder:
'clean-up-before-pack',
'collect-source-code',
'disable-services',
'hard-link-alternatives',
'make-flatpak-friendly',
'platformize',
'prepare-runtime',
'purge-conffiles',
'put-ldconfig-in-path',
'symlink-alternatives',
'usrmerge',
'write-manifest',
):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment