LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Blogs > rainbowsally
User Name
Password

Notices

Rate this Entry

Let's Go Retro Now - A RPM Extractor w/ Scripts

Posted 01-23-2012 at 08:10 PM by rainbowsally
Updated 04-05-2012 at 07:44 PM by rainbowsally (Kubuntu no longer has link to experimental/optimization forum on their main page. Can't find the link to the deb package build scripts I once uploaded there.)

[Note to myself: links to kubuntu forum re. deb extraction, rebuilding 2 places appears to be gone. It was in the Experimental section which appears to have been removed. :-( .]

Let's Go Retro Now - A RPM Extractor w/ Scripts

Especially when building retro packages from binary packages, we need to look out for old development files overwriting newer ones.

For deb packages, the process is a bit more complicated, but once you have a set of definitions for bash functions, it's not too hard to do this interactively in kubuntu too.

[To myself. Cannot edit this. Needs kubuntu forum link which appears to have been removed.]

We assume the shell has been changed to sh --> bash instead of DASH. DASH causes all kinds of problems with makefiles and many other shell programs including cmake which can't find 'libpthreads' due to DASH anomalies (or bash's required anomalies).

[To myself: Link to deb rebuild stuff here would have been nice.]

Here's the basic RPM extractor definitions. (For now a subset of a set of dynamically linked shell definition libraries, a concept we may examine in detail a bit later.)

We load these with the command
Code:
source rpm.sub
And these I have put in my HOME/bin/src/subs folder (where the dynamically linked shell libraries will live) and installed by the same method as the binaries and executable micro-programs that were in the "KDE Utils" posts in this blog, so they are immediately available for editing and/or loading.

[remember the ~/bin prefix to edit, but for running no prefix is req'd.]

file: rpm.sub (plain text, temp subset of real shell lib)
purpose: load some rpm funcs into shell environment
Code:
# type 'source rpm.sub' to load

_rpm_src_extract_one() # rpmFile [dir]
{
    local rpmdir=`echo "$1" | sed -r 's|\.rpm$||'`
    local destdir=$2
    if [ "$destdir" = "" ];then
        destdir="."
    fi
    mkdir -p "$destdir/$rpmdir" >/dev/null 2>&1
    rpm2cpio "$1" | (cd $destdir/$rpmdir; cpio -i --make-directories )
    local scriptname=`echo $1 | sed 's|\.rpm|\.scripts|'`
# echo "$destdir/$rpmdir/$scriptname"; read key
    rpm -qp --scripts "$1" > $destdir/$scriptname 2>/dev/null
}


rpm.src_extract() # rpmfile [dir]
{
  local dir="."
    if [ "$1" = "-d" ]; then
        dir=$2
        shift 2
    fi
    mkdir -p "$dir" >/dev/null 2>&1
    
    for file in $@
    do
        _rpm_src_extract_one "$file" $dir
    done
    
}

rpm.help()
{
  echo "
  commands:
    help              -- this quick ref
    rpm.src_extract   -- file1 [file2 ...] extract rpm file(s) to a tree (splats ok)
  "
}

rpm.help
Remember the dot for rpm.help or you'll get bash help instead.

This will create the directory containing all the files inside an rpm (old rpms = ok) and will generate a similarly named text file containing the configs and pre/post functions used by rpm during installation and uninstallation.

If the top dir is renamed TREE this can be used as the basis of a make-based installer/uninstaller which may be used for testing before rebuiling as SAFE rpm package.

The word "SAFE' in this context means only that we have checked it to make sure it doesn't overwrite stuff in our main file system. This can be verified by looking at the initial backup (number 01 in the backup folder).

There is always some risk when installing retro packages in your system. Approach this activity with respect, backups, and a rescue CD you can use in case your retro files overwrite sytem files required for normal booting.

--------------------------------
Notes:

re. the 'rescue CD'.

Usually if you can make it back into your folder where the make-based files are, you can copy and the backup to the correct destination and untar it there. Copying and unpacking gives you two chances to catch errors in the destination path.

'make restore' can't be used in this scenario because a different root is mounted.

re. Rescue CD v. Older Linux.

I don't use a rescue CD if I can avoid it. I prefer a persistent 'older' linux installation to do the job so I don't have to mess around with mount points, fdisk, device ids, etc. It's already set up when I go into it.

Knoppix could probably also do this (using a persistent image) but my older linux is still very usable and it boots faster -- if it boots at all!


re. "if it boots at all"

Some of the newer linuxes (including openSUSE and Kubuntu) clobber my older (single sector mbr) linux installation.

PLEASE STOP DOING THAT!! The work-arounds are quite inconvenient and my Windows installation is worthless for fixing a Linux that's temporarily in disarray.
Posted in Uncategorized
Views 577 Comments 0
« Prev     Main     Next »
Total Comments 0

Comments

 

  



All times are GMT -5. The time now is 06:42 PM.

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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration