Xmessage wrappers for rpm and deb

Stuff that has yet to be sorted into a category.
Post Reply
Message
Author
User avatar
mikeb
Posts: 11297
Joined: Thu 23 Nov 2006, 13:56

Xmessage wrappers for rpm and deb

#1 Post by mikeb »

I've modified the xarchive wrappers to open/extract deb and rpm files using the busybox dpkg-deb and rpm functions.

only limitation is for rpm files no file details are available but otherise listing and partial/full extraction is possible.
Obviously the Pupzip script will still give the error message so altering file associations to directly opening with xarchive.

Tested in puppy 2 series.

mike
Attachments
wrappers.tar.gz
(2.58 KiB) Downloaded 728 times

amigo
Posts: 2629
Joined: Mon 02 Apr 2007, 06:52

#2 Post by amigo »

I recommend using the disrpm script for rpm and debian conversion or content listing. It uses od or hexdump to do the work which should be in most distros. You might alos look at using dd as a solution. The rpm2tgz program which is in slackware and other distros uses dd as an option if no rpm2cpio is available.
I use disrpm in a couple of prgrams and find that it will unpack rpm that even rpm2cpio will fail on.
It's short enough so I'll just post the code right here:

Code: Select all

#!/bin/sh

# disrpm / undeb
# small (bourne) shell script to extract/unzip/unpack/unarchive *.rpm or *.deb packages.
# uses sh, sed, hexdump|od, gzip|bzip2, dd, cpio.
# released under the Gnu General Public License (GPL)
# (c) bjdouma@xs4all.nl
######################
VER="v1.5, october 2004"
ME="${0##*/}"

# change HEADER_SIZE here or issue e.g.
# $> HEADER_SIZE=512000 disrpm -v foo.rpm
[ -z $HEADER_SIZE ] && HEADER_SIZE=256000
######################

usage()
{
	echo -e "disrpm $VER (bjdouma@xs4all.nl)

usage:	 $ME -v|-x foo.rpm
	 $ME -v|-x foo.deb

options: -v|-l  view (list) contents of foo.
	 -x     extract foo.
"
	exit 1
}

error_exit()
{
	echo $1 >&2
	exit 1
}

gzip_sieve()
{
	# gzip-magic: 0x1F,0x8B
	sed -ne '/1[fF]/{;N;/8[bB]$/{;s/1[fF]//g;s/^0*//g;P;};}'
}

bzip2_sieve()
{
	# bzip2-magic: 0x42,0x5A,0x68
	sed -ne '/42/{;N;/5[aA]$/{;N;/68$/{s/42//g;s/5[aA]//g;s/^0*//g;P;};};}'
}

probe()
{
	dd if=$FILE ibs=$O skip=1 2>/dev/null \
	| $2 -dc - 2>/dev/null \
	| cpio "$1" 2>/dev/null
}

######################

XDUMP=`type -P hexdump` || XDUMP=`type -P od` || error_exit "oops, can't find hexdump or od -- bailing out"
XDUMP="${XDUMP##*/}"

OPT=$1
[ -z $OPT ] && usage

PASS1="probe -tv"
{ [ "$OPT" = "-l" -o "$OPT" = "-v" ] && PASS2=":" ; } || { [ "$OPT" = "-x" ] && PASS2="probe -mid" ; } || usage

FILE=$2
[ x"$FILE"x == xx ] && usage
[ -e "$FILE" ] || error_exit "$FILE: No such file or directory"
 
for AR in gzip bzip2
do
	e=1

	[ "$XDUMP" = "od" ] && AR_OFFSETS=`$XDUMP -A d -N $HEADER_SIZE -v -t x1 -w1 $FILE | ${AR}_sieve`
	[ "$XDUMP" = "hexdump" ] && AR_OFFSETS=`$XDUMP -n $HEADER_SIZE -v -e '"%_ad " 1/1 "%02x" "\n"' $FILE | ${AR}_sieve`

	for O in $AR_OFFSETS
	do
		echo "--> at offset $O:" >&2
		$PASS1 $AR 2>/dev/null && $PASS2 $AR && e=0 \
		|| echo "... hmm, probably false drop" >&2
	done

	[ $e -eq 0 ] && break
done

[ $e -eq 1 ] && echo "$ME: failed to find anything -- maybe HEADER_SIZE is too small (currently $HEADER_SIZE, see line 14)" >&2

exit $e


User avatar
mikeb
Posts: 11297
Joined: Thu 23 Nov 2006, 13:56

#3 Post by mikeb »

Thanks for the script...seems to work ok in puppy 2.xx :)...certianly gives better rpm handling so will incorpotate at some point.

Sorry for the delayed response...I completely missed your message somehow :oops:

regards

mike

User avatar
BarryK
Puppy Master
Posts: 9392
Joined: Mon 09 May 2005, 09:23
Location: Perth, Western Australia
Contact:

#4 Post by BarryK »

@mikeb
Many years down the track, I have looked at those wrappers you posted.

The busybox rpm was not working with Xarchive in EasyOS, so I put in your fix, but extraction doesn't work.

I added the use of 'exploderpm' rather than busybox rpm, but still have an extraction problem:

http://bkhome.org/news/201812/fix-rpm-e ... chive.html

...put in a temporary workaround, to always extract all files.
[url]https://bkhome.org/news/[/url]

User avatar
mikeb
Posts: 11297
Joined: Thu 23 Nov 2006, 13:56

#5 Post by mikeb »

Well from rusty memory I believe the problem is they went to xz compression like debs though the index was still readable.

Since Xarchive uses scripts to handle everything, in theory with say 7zip or xz around it should be possible to workaround this.

mike

Post Reply