0

I'm making a file manager system for managing my projects. My package is named filesystem. I need a config file that stores the path to the root of my file system.

I think I need to create a file /etc/filesystem/root.conf and add it to DEBIAN/conffiles. If the file doesn't exist I want to prompt the installer for a root directory. Else I want to keep the root directory the same (for example when upgrading). I think the prompt should be in postinst.

Should I add the file to conffiles?
Should I add the prompt in postinst?
How do I add an option to apt install that forces a prompt? (I have read about --force-confnew)

I need the file to be deleted in apt purge.

muru
  • 69,900
  • 13
  • 192
  • 292
  • 6
    Aside from your question, I deeply urge you to name your software something, *anything* else. – Shadur Jun 20 '23 at 11:45

1 Answers1

1

To prompt the user for a root directory, you should use debconf. This will allow you to prompt the user, while still allowing pre-configuration, and explicit re-configuration using dpkg-reconfigure. See Configuration management with debconf and man debconf-devel for details, in particular Config file handling in the latter.

Purging a configuration file handled using debconf should be done in postrm; see the relevant chapter in Debian Policy. Files which are manipulated in maintainer scripts as a result of debconf prompts or stored values shouldn’t be listed in conffiles, otherwise your users will end up with confusing questions during upgrades.

Stephen Kitt
  • 411,918
  • 54
  • 1,065
  • 1,164