I would like to rebuild/recompile all Debian packages of a machine with specific flags.
How can I do that with less command as possible?
I have found that https://debian-administration.org/article/20/Rebuilding_Debian_packages but it does not explain how to do that for all the packages installed on a system.
dpkg-buildpackage is a program that automates the process of building a Debian package. It consists of the following steps: 1. It prepares the build environment by setting various environment variables (see ENVIRONMENT), runs the init hook, and calls dpkg-source --before-build (unless -T or --target has been used).
Debian already comes with pre-approved sources to get packages from and this is how it installs all the base packages you see on your system (if a user did a net-install). On a Debian system, this sources file is the "/etc/apt/sources.
Debhelper is used to help you build a Debian package. The philosophy behind debhelper is to provide a collection of small, simple, and easily understood tools that are used in debian/rules to automate various common aspects of building a package. This means less work for you, the packager.
dh_make is a tool to convert a regular source code package into one formatted according to the requirements of the Debian Policy. dh_make must be invoked within a directory containing the source code, which must be named <packagename>-<version>. The <packagename> must be all lowercase, digits and dashes.
You can write a script that does something like this:
for each $pkg in dpkg-query -W -f '${status} ${package}\n' | sed -n 's/^install ok installed //p'
:
This will go through all of your installed packages and generate .deb files for each of them. Probably there are some edge cases etc. that will have to be handled. You could also leave out packages that are not built from C code etc.
Info taken from these questions:
https://unix.stackexchange.com/questions/184812/how-to-update-all-debian-packages-from-source-code
How to override dpkg-buildflags CFLAGS?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With