Extracting/RePackaging Deb Package


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Extracting/RePackaging Deb Package
# 1  
Old 12-03-2014
Extracting/RePackaging Deb Package

Here is the original absolute file paths for a working deb package called
blah-amd64.deb:
Code:
dpkg-deb -c blah-amd64.deb |less
drwxr-xr-x root/root         0 2014-12-02 09:48 ./
drwxr-xr-x root/root         0 2014-12-02 09:48 ./usr/
drwxr-xr-x root/root         0 2014-12-02 09:48 ./usr/share/
drwxr-xr-x root/root         0 2014-12-02 09:48 ./usr/share/applications/
-rw-r--r-- root/root       301 2014-12-02 09:48 ./usr/share/applications/blah.desktop
drwxr-xr-x root/root         0 2014-12-02 09:48 ./usr/share/blah/
-rw-r--r-- root/root     17408 2014-01-21 16:53 ./usr/share/blah/blah.1

I extract it via:
Code:
dpkg-deb -x blah-amd64.deb .
dpkg-deb -e blah-amd64.deb ./DEBIAN

which extracts it to the current directory called
Code:
usr/

I make my modification to my file:
Code:
usr/share/blah/blah.1

and when I repackage blah-amd64.deb via:
Code:
sudo dpkg-deb -b . blah-amd64.deb

and look at the absolute paths:
Code:
dpkg-deb -c blah-amd64.deb |less
drwxr-xr-x root/root         0 2014-12-02 09:48 ./
drwxr-xr-x root/root         0 2014-12-02 09:48 ./applications/
-rw-r--r-- root/root       301 2014-12-02 09:48 ./applications/blah.desktop
drwxr-xr-x root/root         0 2014-12-02 09:48 ./blah/
-rw-r--r-- root/root     17408 2014-01-21 16:53 ./blah/blah.1

it changes the path to "/". I want to repackage it back to its original location so when the package is installed, it will install it in the correct path which is /usr/share/blah. Can someone shed some light on what is going on?

Last edited by metallica1973; 12-03-2014 at 12:06 PM..
# 2  
Old 12-10-2014
I was able to resolve it using another method:

2 - Extract the deb package:
Code:
ac -x blah-amd64.deb

ls -ltr

-rw-r--r-- 1 root root        4 Dec  3 15:53 debian-binary
-rw-r--r-- 1 root root 92233080 Dec  3 15:58 data.tar.gz
-rw-r--r-- 1 root root      684 Dec  3 16:36 control.tar.gz

3 - Create a DEBIAN directory and extract the control file there because it is need for the rebuild:
Code:
mkdir DEBIAN
cp control.tar.gz DEBIAN
tar zcvf control.tar.gz
ls -ltr

-rwxr-xr-x 1 root root 210 Dec  2 09:49 prerm
-rwxr-xr-x 1 root root 255 Dec  2 09:49 postrm
-rwxr-xr-x 1 root root 193 Dec  2 09:49 postinst
-rw-r--r-- 1 root root 296 Dec  3 16:34 control
-rw-rw-r-- 1 root root 684 Dec  3 16:36 control.tar.gz

4 - Retar up the control file without the control.tar.gz in it:
Code:
tar cvzf data.tar.gz --exclude=control.tar.gz ./

5 - Extract your the data.tar.gz, make your changes and retar it up:
Code:
tar zxvf data.tar.gz 

ls -ltr 

usr/

vi ./usr/share/blah/blah.1
wq

tar zcvf data.tar.gz --exclude=control.tar.gz ./usr

6 - create the simple debian-binary
Code:
cat > debian-binary <<EOF
2.0\n
EOF

to repackage deb file:
Code:
ar rc blah-amd64.deb debian-binary control.tar.gz data.tar.gz

optional use
Code:
dpkg-deb -b directory blah-amd64.deb

To view contents of deb file:
Code:
ar tv blah-amd64.deb
or dpkg-deb -c blah-amd64.deb

Login or Register to Ask a Question

Previous Thread | Next Thread

7 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

> dpkg-deb to Extract and Reconstruct a Multipart Archive???

Greetings! Here's one which has been bugging me for a bit ;) As might be known, LibreOffice is available to some of us Linux folk as a large set of debs. Of course, being a curious sort, I'd like to dig in and recreate the original tree which is composed of these assorted archives. So, I... (1 Reply)
Discussion started by: LinQ
1 Replies

2. Ubuntu

Install deb from alternate usb

I installed a command-line system ubuntu 12.04 from usb and that's work. I don't have a internet connection so what I have to install must come from the alternate usb until I can let work my wireless. I mount the usb to /media/cdrom but when I do sudo apt-get install xorg , then he ask me for the... (3 Replies)
Discussion started by: thailand
3 Replies

3. Shell Programming and Scripting

Script to extract all deb files in a fldr to respective folderstructures

Hi, since half an hour I currently try to write a script that will: 1) Extract every debian file in a directory 2) Extracts it to a folder that matches the debians filename 3) Extracts it so the structure looks like that: DEBIANFILENAME | -------------- DEBIAN ... (9 Replies)
Discussion started by: pasc
9 Replies

4. UNIX for Advanced & Expert Users

How to find dependancies of .dstream package (Solaris) & .rpm package( linux)

Friends, Please let meknow, How we can find the dependancies of .dstream package & .rpm package before installation ? For AIX, We can use the inutoc . command to create the .toc file for the bff package, What about Solaris & Linux ? (0 Replies)
Discussion started by: yb4779
0 Replies

5. UNIX for Dummies Questions & Answers

Installing deb packages from Ubuntu Server CD

Hi, I have mounted the Ubuntu server edition 10.10 ISO on my server under a directory media/servercd. I would like to install some services from this. I edited the sources.list file to say: deb file:/media/servercd maverick main restricted and it's properly mounted but when I try... (1 Reply)
Discussion started by: shadowcat
1 Replies

6. UNIX for Advanced & Expert Users

binutills_2.15-4_i386.deb

Hai Friends I am using debian 2.2.19. The gcc version installed in my os is 2.95.2. I tried to update the gcc to 3.2.2. It asked me to update some packages and all the updations was success. But when i tried to update the binutills_2.15-4_i386.deb packes i encountered some error that it asked me... (3 Replies)
Discussion started by: collins
3 Replies

7. Linux

Can I let apt-get use prozilla to download deb

:thank (0 Replies)
Discussion started by: f33k4
0 Replies
Login or Register to Ask a Question