Where do temporary files go while installing a .deb package?

I am creating a .deb package that needs a MySQL database. I am building the package using dpkg-deb --build. While installing I want my post install script to execute an SQL script to set up the database like so:

cat setup.sql | mysql -u root -p

I am currently putting setup.sql into the “DEBIAN” folder of my package. What path do I need to specify in my post install script to find this SQL script?

I know I could embed the SQL contents into my post-install script but I want to keep them separate for code maintenance reasons.

Here is Solutions:

We have many solutions to this problem, But we recommend you to use the first solution because it is tested & true solution that will 100% work for you.

Solution 1

You can’t easily (if at all) access files you add to DEBIAN in a package built with dpkg-deb -b — those files end up in the control information area of the binary package, they aren’t installed as such (in fact, I’m not sure non-standard files are even included in the package; standard files end up in /var/lib/dpkg/info).

You should instead install your script in /usr/share/yourpackage (replacing yourpackage with the name of your package). Then your postinst can access it there.

Ideally, you’d use dbconfig-common instead; that supports a wide variety of use-cases and database configurations. It would involve more work up-front but would result in a much more versatile package.

Note: Use and implement solution 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply