Hello
Howto extract a deb file, including "control" file using dpkg-deb?
BTW I'd like to change one file and create back a deb file.
cc wrote:Hello
Howto extract a deb file, including "control" files using dpkg-deb?
BTW I'd like to change one file and create back a deb file.
# dpkg-deb -e package.debcc wrote:seems to extract "control" file into "DEBIAN" directory.
- Code: Select all
# dpkg-deb -e package.deb
dpkg can also be used as a front-end to dpkg-deb(1). The following are dpkg-deb
actions, and if they are encountered, dpkg just runs dpkg-deb with the parameters
given to it:
-b, --build,
-c, --contents,
-I, --info,
-f, --field,
-e, --control,
-x, --extract,
-X, --vextract, and
--fsys-tarfile.
Please refer to dpkg-deb(1) for information about these actions.
-e, --control archive [directory]
Extracts the control information files from a package archive into the speci‐
fied directory.
If no directory is specified then a subdirectory DEBIAN in the current direc‐
tory is used.
The target directory (but not its parents) will be created if necessary.
Use dpkg -b|--build|-c|--contents|-e|--control|-I|--info|-f|--field|
-x|--extract|-X|--vextract|--fsys-tarfile on archives (type dpkg-deb --help).
sudo dpkg -i package.deb *#!/bin/bash
# script name: rebuild-deb.sh
# extracts/rebuilds a deb package
# Put your deb and the script in a new directory and run it from there
#
echo "This script extracts and rebuilds a deb package. "
echo "It should called from the directory containing the original deb and run as:"
echo "./rebuild-deb.sh"
echo
ls
echo
echo "1. Extract deb?"
echo "2. Make deb?"
echo "Enter <1/2> :"
read REPLY
echo
if [ "$REPLY" = "1" ]; then
ls
DEB=$(ls *.deb 2>&1)
mkdir package
cd ./package
ar -x ../$DEB
rm debian-binary
tar xvzf data.tar.gz && rm data.tar.gz
mkdir DEBIAN && cd DEBIAN
tar xvzf ../control.tar.gz && rm ../control.tar.gz
echo "Extracted to './package'"
echo "Make your changes. Make sure to update control and md5sum files"
elif [ "$REPLY" = "2" ]; then
PACKAGE=$(cat 'package/DEBIAN/control'|grep Package|sed 's|Package: ||')
VERSION=$(cat 'package/DEBIAN/control'|grep Version|sed 's|Version: ||')
ARCH=$(cat 'package/DEBIAN/control'|grep Architecture|sed 's|Architecture: ||')
fakeroot dpkg-deb -b package $PACKAGE\_$VERSION\_$ARCH.deb
echo "Done"
fi
dzz wrote:Anyone like to test/improve it?

dzz wrote:Is it incorrect that fakeroot should be used?
jon@inoshiro:~/tmp/q$ dpkg-deb -c game-data-packager_26_all.deb |head -n 3
drwxr-xr-x root/root 0 2011-04-07 22:35 ./
drwxr-xr-x root/root 0 2011-04-07 22:35 ./etc/
-rw-r--r-- root/root 185 2011-03-23 10:00 ./etc/game-data-packager.conf
jon@inoshiro:~/tmp/q$ dpkg-deb -c foo.deb |head -n 3
drwxr-xr-x jon/jon 0 2011-04-15 14:38 ./
drwxr-xr-x jon/jon 0 2011-04-07 22:35 ./etc/
-rw-r--r-- jon/jon 185 2011-03-23 10:00 ./etc/game-data-packager.conf
jmtd wrote:dzz wrote:Is it incorrect that fakeroot should be used?
Good catch. You should generally use fakeroot for the build stage: otherwise, the files inside the deb will be owned by whichever user you used to build it (and that used should generally not be "real" root).
Compare:
- Code: Select all
jon@inoshiro:~/tmp/q$ dpkg-deb -c game-data-packager_26_all.deb |head -n 3
drwxr-xr-x root/root 0 2011-04-07 22:35 ./
drwxr-xr-x root/root 0 2011-04-07 22:35 ./etc/
-rw-r--r-- root/root 185 2011-03-23 10:00 ./etc/game-data-packager.conf
jon@inoshiro:~/tmp/q$ dpkg-deb -c foo.deb |head -n 3
drwxr-xr-x jon/jon 0 2011-04-15 14:38 ./
drwxr-xr-x jon/jon 0 2011-04-07 22:35 ./etc/
-rw-r--r-- jon/jon 185 2011-03-23 10:00 ./etc/game-data-packager.conf
In this example, 'foo.deb' is just 'game-data-packager_26_all.deb' unpacked (via -x and -e) and repacked (with -b), but not using fakeroot. As a result, all the files are owned by me (jon), not root. When installed, they'd spread jon-owned files over the filesystem. Probably not what you want.
fakeroot dpkg-deb -b foo_dirphenest wrote:Good catch indeed. I was just about to ask why fakeroot was needed until your post. I have a local repo with home made debs without using fakeroot. So far, the debs are only use on my computer, but I was going to transfer it to a web site. Can I just use:
- Code: Select all
fakeroot dpkg-deb -b foo_dir

jmtd wrote:dzz wrote:Anyone like to test/improve it?
It's far too complicated.
Extract can be achieved with just:
dpkg-deb -x foo.deb some-dir
dpkg-deb -e foo.deb some-dir/DEBIAN
Rebuild is even simpler:
dpkg-deb -b some-dir foo.deb
Users browsing this forum: No registered users and 5 guests