Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230
extract a deb file, including "control" files
extract a deb file, including "control" files
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.
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.
Last edited by cc on 2011-02-16 02:06, edited 1 time in total.
Re: extract a deb file, including "control" files
dpkg -x filename.deb target-directory will extract what is in the deb, but I'm not sure where the "control" file is.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.
ar -x filename.deb will give you the "control" file
-OR-
ar -t filename.deb to see what's in the deb.
Re: extract a deb file, including "control" files
Code: Select all
# dpkg-deb -e package.deb
Re: extract a deb file, including "control" files
Ah, there you have it.cc wrote:seems to extract "control" file into "DEBIAN" directory.Code: Select all
# dpkg-deb -e package.deb
From the dpkg man page it says;
which in turn says;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.
Which is why dpkg -h was criptic.-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.
ThanksUse dpkg -b|--build|-c|--contents|-e|--control|-I|--info|-f|--field|
-x|--extract|-X|--vextract|--fsys-tarfile on archives (type dpkg-deb --help).
Cheers
Re: extract a deb file, including "control" files
To extract deb file,including control files use this command:
Code: Select all
sudo dpkg -i package.deb *
Re: extract a deb file, including "control" files
Surely 'dpkg -i' is to install not extract? and you don't need root to extract a deb. I did read, you should use fakeroot to rebuild.
Because I always forget the syntax I keep a script to extract and rebuild. It works for me, maybe it's useful to someone. Don't run it as root.
Anyone like to test/improve it?
Because I always forget the syntax I keep a script to extract and rebuild. It works for me, maybe it's useful to someone. Don't run it as root.
Code: Select all
#!/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
Re: extract a deb file, including "control" files
It's far too complicated.dzz wrote:Anyone like to test/improve it?
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
Re: extract a deb file, including "control" files
As well as forgetting the syntax, I did a script to also pick out what might be a long-winded name and (on rebuild) to get automatically the updated version line in the control file, hopefully reducing risk of typo errors and subsequent rage
But I like:
dpkg-deb -x foo.deb some-dir
dpkg-deb -e foo.deb some-dir/DEBIAN
better than ar -x and untar/tar and will try that in future
Is it incorrect that fakeroot should be used?
But I like:
dpkg-deb -x foo.deb some-dir
dpkg-deb -e foo.deb some-dir/DEBIAN
better than ar -x and untar/tar and will try that in future
Is it incorrect that fakeroot should be used?
Re: extract a deb file, including "control" files
Debian Bits And Snips
Squeeze, Gnome, amd64, Intel Core i3-530, Geforce GT330
Squeeze, Gnome, amd64, Intel Core i3-530, Geforce GT330
Re: extract a deb file, including "control" files
Found this link per chance a few days ago:
http://blog.ksplice.com/author/spang/
seems like a nice summary.
btw: per chance means that someone (you know who, right?) gave me this perl link:
http://blog.ksplice.com/2010/05/top-10- ... er-tricks/
and i clicked around at that side. This was just a pointless extra-rant.
http://blog.ksplice.com/author/spang/
seems like a nice summary.
btw: per chance means that someone (you know who, right?) gave me this perl link:
http://blog.ksplice.com/2010/05/top-10- ... er-tricks/
and i clicked around at that side. This was just a pointless extra-rant.
"I am not fine with it, so there is nothing for me to do but stand aside." M.D.
Re: extract a deb file, including "control" files
Thanks eric1959, that's a really good method, it updates name and version change!
Thanks nadir, an excellent summary.
Thanks nadir, an excellent summary.
Re: extract a deb file, including "control" files
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).dzz wrote:Is it incorrect that fakeroot should be used?
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
Re: extract a deb file, including "control" files
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:jmtd wrote: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).dzz wrote:Is it incorrect that fakeroot should be used?
Compare:
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.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
Code: Select all
fakeroot dpkg-deb -b foo_dir
ASRock H77 Pro4-M i7 3770K - 32GB RAM - Pioneer BDR-209D
Re: extract a deb file, including "control" files
Yes.phenest 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
Re: extract a deb file, including "control" files
sorry to necro the thread, but this is simply one of the best things i have learnt.jmtd wrote:It's far too complicated.dzz wrote:Anyone like to test/improve it?
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
Desktop: A320M-A PRO MAX, AMD Ryzen 5 3600, GALAX GeForce RTX™ 2060 Super EX (1-Click OC) - Sid, Win10, Arch Linux, Gentoo, Solus
Laptop: hp 250 G8 i3 11th Gen - Sid
Kodi: AMD Athlon 5150 APU w/Radeon HD 8400 - Sid
Laptop: hp 250 G8 i3 11th Gen - Sid
Kodi: AMD Athlon 5150 APU w/Radeon HD 8400 - Sid