aurelien
aurelien

Reputation: 423

How to rebuild all Debian packages of a system with specific flag?

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.

Upvotes: 6

Views: 2616

Answers (2)

kjyv
kjyv

Reputation: 616

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':

  • run apt-get source $pkg
  • run apt-get build-dep $pkg
  • cd $pkg-version/
  • run DEB_CPPFLAGS_SET="-I/foo/bar/baz" DEB_CFLAGS_SET="-g -O3" DEB_LDFLAGS_SET="-L/fruzzel/frazzel/" dpkg-buildpackage
  • install package with dpkg -i deb-file
  • cd ..

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?

Upvotes: 1

VTodorov
VTodorov

Reputation: 973

Try this approach:

dpkg --get-selections > selections
sudo dpkg --clear-selections
sudo dpkg --set-selections < selections
sudo apt-get --reinstall dselect-upgrade

Source: https://www.linuxquestions.org/questions/linux-software-2/force-apt-get-to-redownload-and-reinstall-dependencies-as-well-873038/

Upvotes: -1

Related Questions