Skip to content

Instantly share code, notes, and snippets.

@penguinpowernz
Created August 31, 2020 00:47
Show Gist options
  • Save penguinpowernz/cd9657cd2ba686fc3fe3d65de477b461 to your computer and use it in GitHub Desktop.
Save penguinpowernz/cd9657cd2ba686fc3fe3d65de477b461 to your computer and use it in GitHub Desktop.
Building a Debian Package from installed files

Building a Debian Package from installed files

Recently I had a package disappear on me from the mainline repos but one of my apps had a hard dependency on that version. I managed to find a machine that still had that package installed so here's what I did.

Get the file list:

dpkg -L firefox-esr|sed 1d|grep -v "package diverts" > esrfiles.txt

Strip the list down to only the actual files:

{ for i in `cat esrfiles.txt`; do [[ -f "$i" ]] && echo $i ; done; } > esrfiles2.txt

Use tar to get the files in their folder locations into another prefix:

mkdir pkg
tar -czf - `cat esrfiles2.txt` | tar -xzf - -C pkg

Then grab the package scripts (hopefully they haven't been cleared out by some clean operation):

mkdir pkg/DEBIAN
cp /var/lib/dpkg/info/firefox-esr.* pkg/DEBIAN/

Find the package control text in the /var/lib/dpkg/status and copy it into a file called pkg/DEBIAN/control. You will then need to remove the Status: line from the copied text in the control file.

Rename the files to remove the package name:

cd pkg/DEBIAN
mv firefox-esr.postinst postinst
# etc....

Then you can build the package the quick and dirty way:

#dpkg-deb -b pkg
ian pkg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment