Debian Codegraph @

debian/frei0r-plugins.postinst

raw
1 #!/bin/sh
2 set -e
3
4 error() {
5 echo "$*" 1>&2
6 }
7
8 old_dir=/usr/lib/frei0r-1
9 new_dir="$(dpkg -L frei0r-plugins | grep '^/usr/lib/[^/]*/frei0r-1/.*\.so$' | head -1 | sed -e 's|/[^/]*$||')"
10
11 if [ ! -L "${old_dir}" ] && [ -d "${old_dir}" ]; then
12 # /usr/lib/frei0r-1 is still a directory, but should be a symlink
13 error "frei0r-plugins: migrating '${old_dir}' to '${new_dir}'"
14
15 # if there are any left-over plugins in the directory, move them to the new destination
16 for f in "${old_dir}"/*; do
17 test -e "${f}" || continue
18 mv -v "${f}" "${new_dir}"
19 done
20
21 # remove the olddir
22 if rmdir "${old_dir}"; then
23 # and symlink it to the new one
24 ln --symbolic --verbose "${new_dir#/usr/lib/}" "${old_dir}"
25 else
26 error "FAILED to remove '${old_dir}'"
27 fi
28 fi