I have the following postint script in the dpkg package:
rm -f /SOMEDIRECTORY/current
ln -s /SOMEDIRECTORY/releases/RELEASESHA /SOMEDIRECTORY/current
ln -s /SOMEDIRECTORY/shared/config/config.json /SOMEDIRECTORY/releases/RELEASESHA/config/config.json
This is a directory tree before the install:
drwxr-xr-x 2 user user 4096 May 12 15:21 config
drwxr-xr-x 3 user user 4096 May 14 08:56 shared
drwxr-xr-x 6 user user 4096 May 14 10:06 releases
lrwxrwxrwx 1 root root 49 May 14 10:14 current -> /SOMEDIRECTORY/releases/RELEASESHA
When I try to install the deb package it is trying to remove a directory symlink is pointing to as oppose to JUST THE SYMLINK:
dpkg: warning: unable to delete old directory '/SOMEDIRECTORY/releases/OLD_RELEASESHA': Directory not empty
When I run the rm -f
command manually it works as expected but what's going on when postinst is running that it changes that command to something else what is trying to remove the directory to which the symlink points to and not just the symlink itself ?
Anyone idea ? Thanks