2

I have created a debian package which I install using sudo dpkg -i package.deb. This works fine and all my files and configurations in the root of the packaged folder get extracted.

I then uninstall it using sudo dpkg -r package, the file is still there, as expected.

I then removed the entire configuration folder using rm -rf /var/package/config/, thinking I would simulate "fresh install", and tried installing it again. Now every resource is there, except the single file I have in my conffiles file which is never installed again.

There is no prompt from the install command, which makes this difficult to detect before it is too late.

This is my folder structure:

deb
├── DEBIAN
│   ├── conffiles # /home/package/app/config/application.yml is listed here
│   ├── control
│   └── postinst
├── etc
│   └── init.d
│       └── startup
└── home
    └── package
        └── app
            └── config
                └── application.yml
                |
                └── stuff
                     └── common.txt

How do I prompt the user who runs the install package that the file will be added? How is this normally handled?

jokarl
  • 187
  • 1
    Where is this conffile? Traditionally conffiles belong under /etc on Debian. If you want to really remove a package completely including conffiles you need to run dpkg --purge packagename – wurtel Jun 19 '18 at 09:53
  • @wurtel it's under a users home directory. I'm not sure why but its custom to place it here where I work. Also the configuration location is dependent on the application location in my case. Application expects config in same directory in folder config. I will try purging, thank you. – jokarl Jun 20 '18 at 08:19

1 Answers1

1

When the administrator removes a conffile (which is a configuration file controlled by dpkg), then dpkg will consider this a user change, similar to having edited it, and will preserve it across new installations and upgrades. If the package got removed, but not purged, and the file got removed by the administrator, then a subsequent installation would not restore the file.

To force getting these conffiles back, one can always use --force-confmiss, see the dpkg(1) man page, or use the more brutal approach of purging then reinstalling, but that might incur data loss if some other conffiles or configuration files had been modified.

In any case, shipping pathnames in .deb packages that are under home directories is not a great idea, as those directories are owned by the user, and they could remove them, or the user could get removed as part of normal system administration tasks.