LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 03-22-2014, 10:02 PM   #1
jinvii
LQ Newbie
 
Registered: Sep 2011
Posts: 2

Rep: Reputation: Disabled
How to extract a package from installed system?


Hi, just out of curiosity, consider the following situation:

If you just generate a slackware package using SlackBuilds or whatsoever, let's call it xxxx.tgz. Then you install it with "installpkg xxxx.tgz", and then remove all the source files and this package.

Now, my question is, as this package is installed in our system and we also has its log in "/var/log/packages/xxxx", is there a way/tool to directly extract this package from our system on which we installed this package of course. That means we generate this xxxx.tgz using the installed binaries and information.

Thanks.
 
Old 03-23-2014, 12:10 AM   #2
allend
LQ 5k Club
 
Registered: Oct 2003
Location: Melbourne
Distribution: Slackware-current
Posts: 5,311

Rep: Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948
You can recover the slack-desc file and the binaries that are installed, but you cannot recover the doinst.sh script that may be necessary to properly install the package.
So reverse engineering a package from the installed version will not work for all packages.
 
Old 03-23-2014, 03:03 AM   #3
ruario
Senior Member
 
Registered: Jan 2011
Location: Oslo, Norway
Distribution: Slackware
Posts: 2,484

Rep: Reputation: 1581Reputation: 1581Reputation: 1581Reputation: 1581Reputation: 1581Reputation: 1581Reputation: 1581Reputation: 1581Reputation: 1581Reputation: 1581Reputation: 1581
For many simple packages the following would work (adjust the package name as needed):

Code:
$ su -
# removepkg -copy example-1.0-x86_64-1
# cd /var/log/setup/tmp/preserved_packages/example-1.0-x86_64-1
# mkdir -p install
# grep '^example: ' /var/log/packages/example-1.0-x86_64-1 > install/slack-desc
# makepkg -l n -c n /tmp/example-1.0-x86_64-1.tgz
However for packages where config files are moved into place by doinst.sh, those original, pristine versions of the config files (.new versions) will likely not be found and you will therefore not have a complete package.

Last edited by ruario; 03-23-2014 at 05:02 PM. Reason: Added in slack-desc, thanks to Philip Lacroix for the reminder!
 
8 members found this post helpful.
Old 03-23-2014, 03:12 AM   #4
ruario
Senior Member
 
Registered: Jan 2011
Location: Oslo, Norway
Distribution: Slackware
Posts: 2,484

Rep: Reputation: 1581Reputation: 1581Reputation: 1581Reputation: 1581Reputation: 1581Reputation: 1581Reputation: 1581Reputation: 1581Reputation: 1581Reputation: 1581Reputation: 1581
If you are willing to handle a little bit of manual work you could copy the config files into their relevant locations under /var/log/setup/tmp/preserved_packages/example-1.0-x86_64-1, add back the .new extension and undoing any tweaks you made, before the makepkg step.

Inspecting the contents of doinst.sh should give you an idea of which files are affected.

Last edited by ruario; 03-23-2014 at 03:34 AM. Reason: s/Expecting/Inspecting
 
Old 03-23-2014, 04:24 AM   #5
Didier Spaier
LQ Addict
 
Registered: Nov 2008
Location: Paris, France
Distribution: Slint64-14.2.1.2 on Lenovo Thinkpad W520
Posts: 9,064

Rep: Reputation: Disabled
What's done by doinst.sh is recorded in /var/log/scripts.

Last edited by Didier Spaier; 03-23-2014 at 05:07 AM.
 
4 members found this post helpful.
Old 03-23-2014, 07:33 AM   #6
ruario
Senior Member
 
Registered: Jan 2011
Location: Oslo, Norway
Distribution: Slackware
Posts: 2,484

Rep: Reputation: 1581Reputation: 1581Reputation: 1581Reputation: 1581Reputation: 1581Reputation: 1581Reputation: 1581Reputation: 1581Reputation: 1581Reputation: 1581Reputation: 1581
Quote:
Originally Posted by Didier Spaier View Post
What's done by doinst.sh is recorded in /var/log/scripts.
Indeed and that is copied back into /var/log/setup/tmp/preserved_packages/example-1.0-x86_64-1/install/doinst.sh for you by removepkg -copy (or -preserve).
 
1 members found this post helpful.
Old 03-23-2014, 08:06 AM   #7
jinvii
LQ Newbie
 
Registered: Sep 2011
Posts: 2

Original Poster
Rep: Reputation: Disabled
I noticed that "slack-desc" is not recovered by

Code:
# removepkg -copy example-1.0-x86_64-1
And according to allend, it is logged somewhere, where does it logged? I cannot find it manually.

Thanks!
 
Old 03-23-2014, 08:51 AM   #8
Philip Lacroix
Member
 
Registered: Jun 2012
Distribution: Slackware, BSD
Posts: 422

Rep: Reputation: 539Reputation: 539Reputation: 539Reputation: 539Reputation: 539Reputation: 539
Quote:
Originally Posted by jinvii View Post
I noticed that "slack-desc" is not recovered by
# removepkg -copy example-1.0-x86_64-1
And according to allend, it is logged somewhere, where does it logged? I cannot find it manually.
It is logged in:
Code:
/var/log/packages/example-1.0-x86_64-1
You can extract it with:
Code:
grep '^example: ' /var/log/packages/example-1.0-x86_64-1 > ~/path/slack.desc
Don't forget the colon right after the program name when grepping.

Last edited by Philip Lacroix; 03-23-2014 at 06:49 PM. Reason: better pattern for grep (thanks to ruario)
 
2 members found this post helpful.
Old 03-23-2014, 09:08 AM   #9
calrogman
LQ Newbie
 
Registered: Mar 2014
Distribution: Slackware!
Posts: 13

Rep: Reputation: 3
Quote:
Originally Posted by allend View Post
You can recover the slack-desc file and the binaries that are installed, but you cannot recover the doinst.sh script that may be necessary to properly install the package.
Yes you can. It's in /var/log/scripts/.
 
Old 03-23-2014, 10:06 AM   #10
allend
LQ 5k Club
 
Registered: Oct 2003
Location: Melbourne
Distribution: Slackware-current
Posts: 5,311

Rep: Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948
Quote:
Yes you can. It's in /var/log/scripts/.
Yes, as also pointed out by Didier Spaier. My bad. I had forgotten that.
As pointed out by ruario, there is still the problem of any new config files.
 
Old 03-23-2014, 10:22 AM   #11
Philip Lacroix
Member
 
Registered: Jun 2012
Distribution: Slackware, BSD
Posts: 422

Rep: Reputation: 539Reputation: 539Reputation: 539Reputation: 539Reputation: 539Reputation: 539
Quote:
Originally Posted by ruario View Post
Inspecting the contents of doinst.sh should give you an idea of which files are affected.
Yeah, and the relevant file in /var/log/packages/ also includes a list of the files that were added to the package during its generation, with all *.new stuff in the original location.

Last edited by Philip Lacroix; 03-23-2014 at 10:27 AM.
 
Old 03-23-2014, 05:04 PM   #12
ruario
Senior Member
 
Registered: Jan 2011
Location: Oslo, Norway
Distribution: Slackware
Posts: 2,484

Rep: Reputation: 1581Reputation: 1581Reputation: 1581Reputation: 1581Reputation: 1581Reputation: 1581Reputation: 1581Reputation: 1581Reputation: 1581Reputation: 1581Reputation: 1581
Quote:
Originally Posted by Philip Lacroix View Post
You can extract it with:
Code:
grep "example:" /var/log/packages/example-1.0-x86_64-1 > ~/path/slack.desc
Don't forget the colon right after the program name when grepping.
Thanks, I new I had forgotten something!

P.S. I have updated my original reply and added a better match: '^example: '
 
Old 03-23-2014, 07:01 PM   #13
Philip Lacroix
Member
 
Registered: Jun 2012
Distribution: Slackware, BSD
Posts: 422

Rep: Reputation: 539Reputation: 539Reputation: 539Reputation: 539Reputation: 539Reputation: 539
Thanks ruario, I updated my post #8 as well. Of course in #11 it wasn't my intention to correct you: if it could be read this way, then it's my fault (i.e. my poor English).

Last edited by Philip Lacroix; 03-26-2014 at 04:54 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to find the installed version of a rpm package in a system?? Arighna Linux - Newbie 10 09-21-2011 10:22 AM
RPM package manager says package needs to be installed. But I already installed it! nick623 Linux - Software 2 05-24-2005 03:15 AM
message "Problem during installation: x package needed for (installed) x package frayed2 Linux - Newbie 1 04-24-2005 08:05 PM
RPM: How do you extract just one file from the package? Thetargos Fedora 4 07-17-2004 04:03 AM
How to extract files from an rpm package mayankjohri Linux - Networking 3 06-12-2002 01:33 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 05:59 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration