1

I have a custom binary package. I am creating the package from a Makefile . Here is the code for the same :

FIREFOX_DIR = /usr/share/mozilla/extensions/{ec8030f7-c20a-464f-9b0e-13a3a9e97384}

build:
    mkdir -p $(app_source_dir)
    mkdir -p $(app_source_dir)/opt/Sapience/config
    mkdir -p $(app_source_dir)/opt/Sapience/firefox
    mkdir -p $(app_source_dir)/$(FIREFOX_DIR)/firefox-extension@sapience
    mkdir -p $(app_source_dir)/usr/bin
    mkdir -p $(app_source_dir)/DEBIAN
    cp $(RT)/../bin/sapiencecollector $(app_source_dir)/usr/bin/.
    cp $(RT)/../DEBIAN/control $(app_source_dir)/DEBIAN/.
    cp $(RT)/../DEBIAN/postinst $(app_source_dir)/DEBIAN/.
    cp $(RT)/../DEBIAN/prerm $(app_source_dir)/DEBIAN/.
    cp $(RT)/../config/conf.ini $(app_source_dir)/opt/Sapience/config/.
    cp -r $(RT)/../external/firefox-extension/* $(app_source_dir)/$(FIREFOX_DIR)/firefox-extension@sapience/.
    dpkg --build $(app_source_dir) $(app_name)-$(version).deb

I need to create a directory named Sapience inside /opt as part of my installation. In order to do that I am creating the same directory hierarchy inside the package directory. /opt is already present in Linux & I do not want to create it again on the machine I install the package. The package gets installed properly. When I try to remove the package using the command dpkg -r <pkgname> I get the following error : dpkg:warning : while removing , /opt directory is not empty so not removed.

I do not want to remove the /opt directory but still dpkg is trying to remove it. Could anyone let me know what changes I need to make to avoid dpkg to remove the directories.

1 Answer 1

0

According to this post dpkg tries to remove a package from a directory which is not used by any other Debian package, thus it looks empty to dpkg, but if you've placed other software under /opt it's not empty on the file-system layer.

Thus, dpkg will keep going up the file system directory hierarchy until it deletes all ancestors of the installation unless there is another package that is also installed under an ancestor.

To see which packages depend on /opt:

$ dpkg -S /opt

One solution, taken from this post, is to create a "core-custom" package, which will hold the /opt, and be required by all the other custom packages. You can also use that package as a meta-package to install all the regular packages you like. Not like the warning is a big deal, but the cleaner the better.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .