├── getrpmtype.tar.gz ├── patches └── 0005-gzip-man-info-pages.patch.gz ├── slack-desc ├── rpmoffset.c ├── rpm2targz.README ├── rpm2tgz.SlackBuild └── rpm2targz /getrpmtype.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GArik/rpm2txz/master/getrpmtype.tar.gz -------------------------------------------------------------------------------- /patches/0005-gzip-man-info-pages.patch.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GArik/rpm2txz/master/patches/0005-gzip-man-info-pages.patch.gz -------------------------------------------------------------------------------- /slack-desc: -------------------------------------------------------------------------------- 1 | # HOW TO EDIT THIS FILE: 2 | # The "handy ruler" below makes it easier to edit a package description. Line 3 | # up the first '|' above the ':' following the base package name, and the '|' 4 | # on the right side marks the last column you can put a character in. You must 5 | # make exactly 11 lines for the formatting to be correct. It's also 6 | # customary to leave one space after the ':'. 7 | 8 | |-----handy-ruler------------------------------------------------------| 9 | rpm2tgz: rpm2tgz (a tool for converting an RPM archive into a tar+gz one) 10 | rpm2tgz: 11 | rpm2tgz: Converts RPM format to Slackware's GNU tar + GNU zip format. (view 12 | rpm2tgz: converted packages with "less", install and remove with "installpkg", 13 | rpm2tgz: "removepkg", "pkgtool", or manually with "tar"). 14 | rpm2tgz: 15 | rpm2tgz: Converted packages come with no warranty. ;-) 16 | rpm2tgz: 17 | rpm2tgz: 18 | rpm2tgz: 19 | rpm2tgz: 20 | -------------------------------------------------------------------------------- /rpmoffset.c: -------------------------------------------------------------------------------- 1 | 2 | /* Find how deeply inside an .RPM the real data is */ 3 | /* kept, and report the offset in bytes */ 4 | 5 | /* Wouldn't it be a lot more sane if we could just untar these things? */ 6 | 7 | #include 8 | #include 9 | 10 | /* These offsets keep getting bigger, so we're going to just bite a 2MB */ 11 | /* chunk of RAM right away so that we have enough. Yeah, horrible */ 12 | /* quick and dirty implementation, but hey -- it gets the job done. */ 13 | 14 | #define RPMBUFSIZ 2097152 15 | 16 | main() 17 | { 18 | char *buff = malloc(RPMBUFSIZ),*eb,*p; 19 | for (p = buff, eb = buff + read(0,buff,RPMBUFSIZ); p < eb; p++) 20 | if ((*p == '\037' && p[1] == '\213' && p[2] == '\010') || 21 | (*p == 'B' && p[1] == 'Z' && p[2] == 'h' && '1' <= p[3] && p[3] <= '9' )) 22 | printf("%d\n",p - buff), 23 | exit(0); 24 | exit(1); 25 | } 26 | -------------------------------------------------------------------------------- /rpm2targz.README: -------------------------------------------------------------------------------- 1 | 2 | This package contains 'rpm2targz', a simple utility to convert Red Hat-style 3 | RPM packages into standard tar.gz archives. Converted binary packages can then 4 | be installed/removed using the 'installpkg/removepkg' commands, or 'pkgtool'. 5 | 6 | It's advisable to at least examine the converted package with 'less' to make 7 | sure it won't do anything too crazy to your system. If it does, Patrick 8 | Volkerding and David Cantrell are not responsible, so use this at your own 9 | risk. :-) 10 | 11 | By default, rpm2targz will attempt to use "file" to detect source RPMS, and will 12 | put the contents into a subdirectory in the resulting package. This may not be 13 | portable to other operating systems -- if you're trying to run rpm2targz on an 14 | OS that doesn't have a file that knows RPM types, and you care about this source 15 | RPM feature, you can compile and install David Cantrell's standalone getrpmtype 16 | utility. The getrpmtype.tar.gz source archive can be found in Slackware's 17 | source tree in source/a/rpm2tgz/. 18 | 19 | -------------------------------------------------------------------------------- /rpm2tgz.SlackBuild: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Copyright 2008, 2009, 2010 Patrick J. Volkerding, Sebeka, Minnesota, USA 4 | # All rights reserved. 5 | # 6 | # Redistribution and use of this script, with or without modification, is 7 | # permitted provided that the following conditions are met: 8 | # 9 | # 1. Redistributions of this script must retain the above copyright 10 | # notice, this list of conditions and the following disclaimer. 11 | # 12 | # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 13 | # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 14 | # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 15 | # EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 16 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 17 | # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 18 | # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 19 | # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 20 | # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 21 | # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 22 | 23 | VERSION=1.2.1 24 | BUILD=${BUILD:-1} 25 | 26 | # Automatically determine the architecture we're building on: 27 | if [ -z "$ARCH" ]; then 28 | case "$( uname -m )" in 29 | i?86) export ARCH=i486 ;; 30 | arm*) export ARCH=arm ;; 31 | # Unless $ARCH is already set, use uname -m for all other archs: 32 | *) export ARCH=$( uname -m ) ;; 33 | esac 34 | fi 35 | 36 | CWD=$(pwd) 37 | TMP=${TMP:-/tmp} 38 | PKG=$TMP/package-rpm2tgz 39 | 40 | rm -rf $PKG 41 | mkdir -p $TMP $PKG 42 | 43 | echo "+===========+" 44 | echo "| rpm2targz |" 45 | echo "+===========+" 46 | cd $TMP 47 | mkdir -p $PKG/usr/bin 48 | cc -o $PKG/usr/bin/rpmoffset $CWD/rpmoffset.c 49 | cat $CWD/rpm2targz > $PKG/usr/bin/rpm2targz 50 | 51 | # Apply some patches: 52 | ( cd $PKG/usr/bin 53 | # These are all against "rpm2tgz", so we should point to the right file to patch explicitly 54 | # Not applied. Rationale: We do not want to alter the files in the RPM. 55 | #zcat $CWD/patches/0005-gzip-man-info-pages.patch.gz | patch -p1 rpm2targz || exit 1 56 | # Not applied. Rationale: .tgz works with all versions of Slackware. 57 | # Translated RPMs may be targeting systems with no .txz support. 58 | #zcat $CWD/patches/0006-should-we-use-.txz-format-in-slackware-current.patch.gz | patch -p1 rpm2targz || exit 1 59 | ) || exit 1 60 | 61 | ( cd $PKG/usr/bin ; ln -sf rpm2targz rpm2tgz ) 62 | ( cd $PKG/usr/bin ; ln -sf rpm2targz rpm2txz ) 63 | chmod 755 $PKG/usr/bin/{rpmoffset,rpm2targz} 64 | mkdir -p $PKG/usr/doc/rpm2targz 65 | cp -a $CWD/rpm2targz.README $PKG/usr/doc/rpm2targz/rpm2targz.README 66 | chown root:root $PKG/usr/doc/rpm2targz/rpm2targz.README 67 | chmod 644 $PKG/usr/doc/rpm2targz/rpm2targz.README 68 | ( cd $PKG 69 | find . | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null 70 | find . | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null 71 | ) 72 | 73 | mkdir -p $PKG/install 74 | cat $CWD/slack-desc > $PKG/install/slack-desc 75 | 76 | # Build the package: 77 | cd $PKG 78 | makepkg -l y -c n $TMP/rpm2tgz-$VERSION-$ARCH-$BUILD.txz 79 | 80 | -------------------------------------------------------------------------------- /rpm2targz: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Copyright 1997, 1998 Patrick Volkerding, Moorhead, MN USA 3 | # Copyright 2002, 2004 Slackware Linux, Inc., Concord, CA USA 4 | # Copyright 2006, 2009 Patrick Volkerding, Sebeka, MN USA 5 | # All rights reserved. 6 | # 7 | # Redistribution and use of this script, with or without modification, is 8 | # permitted provided that the following conditions are met: 9 | # 10 | # 1. Redistributions of this script must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # 13 | # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 14 | # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 15 | # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 16 | # EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 17 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 18 | # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 19 | # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 20 | # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 21 | # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 22 | # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 | # 24 | 25 | CWD=$(pwd) 26 | NAME="$(basename $0)" 27 | 28 | # Breaking the help out into it's own deal 29 | usage() { 30 | echo "$0: Converts RPM format to standard GNU tar + GNU zip format." 31 | echo " (view converted packages with \"less\", install and remove" 32 | echo " with \"installpkg\", \"removepkg\", \"pkgtool\", or manually" 33 | echo " with \"tar\")" 34 | echo 35 | if [ "$NAME" = "rpm2tgz" -o "$NAME" = "rpm2txz" ]; then 36 | echo "Usage: $0 [OPTION] " 37 | if [ "$NAME" = "rpm2tgz" ]; then 38 | echo " (Outputs \"file.tgz\")" 39 | else 40 | echo " (Outputs \"file.txz\")" 41 | fi 42 | echo 43 | echo " -s extract the install scripts to /usr/doc/\$PRGNAM-\$VERSION/" 44 | echo " for review." 45 | echo " -S extracts the install scripts to be executed on package installation" 46 | echo " (only pre-install and post-install scripts used)" 47 | echo " USE WITH CAUTION! " 48 | echo " -n name the output package using the rpm's metadata" 49 | echo " -r extract what the rpm's \"requires\" (dependencies)" 50 | echo " as documention to /usr/doc/\$PRGNAM-\$VERSION/" 51 | echo " -d attempt a wellformed slack-desc from the rpm meta data" 52 | echo " -c reset all directory permissions to 755 and ownership to root:root." 53 | echo 54 | else 55 | echo "Usage: $0 " 56 | echo " (Outputs \"file.tar.gz\")" 57 | fi 58 | exit 1; 59 | } 60 | 61 | # Create a new temporary directory with a secure filename: 62 | make_temp_dir() { 63 | if [ -x "$(which mcookie)" ]; then 64 | tempd=/tmp/tmp.$(mcookie) 65 | mkdir -p -m 0755 $tempd 66 | elif [ -x "$(which openssl)" ]; then 67 | tempd=/tmp/tmp.$(dd if=/dev/urandom bs=1k count=1 2> /dev/null | openssl dgst -md5) 68 | mkdir -p -m 0755 $tempd 69 | elif [ -x "$(which md5)" ]; then 70 | tempd=/tmp/tmp.$(dd if=/dev/urandom bs=1k count=1 2> /dev/null | md5) 71 | mkdir -p -m 0755 $tempd 72 | elif [ -x "$(which mktemp)" ]; then 73 | tempd=$(mktemp -d) 74 | chmod 755 $tempd 75 | ## Uncomment for insecure use, but don't blame me: 76 | #else 77 | # tempd=/tmp/tmp.$$ 78 | # mkdir -p -m 0755 $tempd 79 | fi 80 | if [ -d $tempd ]; then # success, return the name of the directory: 81 | echo $tempd 82 | else 83 | echo "ERROR: Could not find mcookie, openssl, or md5." 84 | echo " Exiting since a secure temporary directory could not be made." 85 | exit 1 86 | fi 87 | } 88 | 89 | # Get the meta data off of the rpm 90 | get_meta_data() { 91 | RPM=$1 92 | PRGNAM=$(rpm -qp --qf %{NAME} $RPM ) 93 | ARCH=$(rpm -qp --qf %{ARCH} $RPM ) 94 | VERSION=$(rpm -qp --qf %{VERSION} $RPM ) 95 | BUILD=$(rpm -qp --qf %{RELEASE} $RPM ) 96 | } 97 | 98 | if [ "$1" = "" ]; then 99 | usage 100 | fi 101 | 102 | ARGS=$(getopt "hsSndrc" $* ) 103 | set -- ${ARGS} 104 | for i; do 105 | case "$1" in 106 | -s) 107 | DOC_SCRIPTS="true" 108 | shift 109 | ;; 110 | -S) 111 | INSTALL_SCRIPTS="true" 112 | shift 113 | ;; 114 | -r) 115 | DOC_REQUIRES="true" 116 | shift 117 | ;; 118 | -d) 119 | DESC="true" 120 | shift 121 | ;; 122 | -n) 123 | META_NAME="true" 124 | shift 125 | ;; 126 | -c) 127 | CHOWN="true" 128 | shift 129 | ;; 130 | --) 131 | shift 132 | break 133 | ;; 134 | esac 135 | done 136 | 137 | 138 | for i in $* ; do 139 | 140 | # Determine if this is a source or binary RPM. 141 | # If we have getrpmtype, use that. Otherwise, try "file". 142 | if which getrpmtype 1> /dev/null 2> /dev/null; then 143 | if getrpmtype -n $i | grep source 1> /dev/null 2> /dev/null ; then 144 | isSource=1 145 | else 146 | isSource=0 147 | fi 148 | else # use file. This works fine on Slackware, and is the default. 149 | if file $i | grep RPM | grep -w src 1> /dev/null 2> /dev/null ; then 150 | isSource=1 151 | else 152 | isSource=0 153 | fi 154 | fi 155 | 156 | # Create a temporary directory: 157 | TMPDIR=$(make_temp_dir) 158 | 159 | # Extract the RPM: 160 | ofn=$TMPDIR/$(basename $i .rpm).cpio 161 | if which rpm2cpio 1> /dev/null 2> /dev/null ; then 162 | rpm2cpio $i > $ofn 2> /dev/null 163 | if [ ! $? = 0 ]; then 164 | echo "ERROR: rpm2cpio failed. (maybe $i is not an RPM?)" 165 | rm -rf $TMPDIR 166 | continue 167 | fi 168 | else # less reliable than rpm2cpio... 169 | ( dd ibs=$(rpmoffset < $i) skip=1 if=$i 2> /dev/null | gzip -dc > $ofn 2>/dev/null ) || \ 170 | ( dd ibs=$(rpmoffset < $i) skip=1 if=$i 2> /dev/null | bzip2 -dc > $ofn 2>/dev/null ) 171 | fi 172 | DEST=$TMPDIR 173 | if [ "$isSource" = "1" ]; then 174 | DEST=$DEST/$(basename $(basename $i .rpm) .src) 175 | fi 176 | mkdir -p $DEST 177 | ( cd $DEST 178 | cpio -i -m -d < $ofn 1> /dev/null 2> /dev/null 179 | rm -f $ofn 180 | find . -type d -perm 700 -exec chmod 755 {} \; 181 | ) 182 | 183 | # Save the scripts in the rpm as documentation 184 | if [ "$DOC_SCRIPTS" = "true" ]; then 185 | get_meta_data $i 186 | mkdir -p $TMPDIR/usr/doc/$PRGNAM-$VERSION/ 187 | for state in PREIN POSTIN PREUN POSTUN ; do 188 | if [ "$(rpm -qp --qf %{$state} $i )" != '(none)' ] ; then 189 | rpm -qp --qf %{$state} $i > $TMPDIR/usr/doc/$PRGNAM-$VERSION/$state.script 190 | fi 191 | done 192 | fi 193 | 194 | # Save the scripts in the rpm to be installed 195 | if [ "$INSTALL_SCRIPTS" = "true" ]; then 196 | mkdir -p $TMPDIR/install 197 | echo '#!/bin/sh' > $TMPDIR/install/doinst.sh 198 | for state in PREIN POSTIN ; do 199 | if [ "$(rpm -qp --qf %{$state} $i )" != '(none)' ] ; then 200 | rpm -qp --qf %{$state} $i > $TMPDIR/install/doinst.sh 201 | echo "" >> $TMPDIR/install/doinst.sh 202 | fi 203 | done 204 | fi 205 | 206 | # Save the rpm's requires (dependencies) as documentation 207 | if [ "$DOC_REQUIRES" = "true" ]; then 208 | get_meta_data $i 209 | mkdir -p $TMPDIR/usr/doc/$PRGNAM-$VERSION/ 210 | rpm -qp --qf %{REQUIRES} $i > $TMPDIR/usr/doc/$PRGNAM-$VERSION/README-$PRGNAM-rpm-dependencies.txt 211 | fi 212 | 213 | # Save the rpm's summary and description as the slack-desc 214 | if [ "$DESC" = "true" ]; then 215 | get_meta_data $i 216 | mkdir -p $TMPDIR/install 217 | if [ "$(rpm -qp --qf %{SUMMARY} $i )" != '(none)' ] ; then 218 | rpm -qp --qf "$PRGNAM (%{SUMMARY})\n\n" $i > $TMPDIR/install/slack-desc 219 | else 220 | echo -en "$PRGNAM\n\n" > $TMPDIR/install/slack-desc 221 | fi 222 | if [ "$(rpm -qp --qf %{DESCRIPTION} $i )" != '(none)' ] ; then 223 | rpm -qp --qf "%{DESCRIPTION}\n\n" $i >> $TMPDIR/install/slack-desc 224 | fi 225 | if [ "$(rpm -qp --qf %{URL} $i )" != '(none)' ] ; then 226 | rpm -qp --qf " %{URL}\n" $i >> $TMPDIR/install/slack-desc 227 | fi 228 | sed -ri "s/^/$PRGNAM: /;11q" $TMPDIR/install/slack-desc 229 | fi 230 | 231 | # Supply -c y to makepkg if asked 232 | COPT="n" 233 | if [ "$CHOWN" = "true" ]; then 234 | COPT="y" 235 | fi 236 | 237 | # If this program was called as "rpm2targz", then repack as a plain 238 | # tar+gz archive. If it was called as "rpm2tgz", use Slackware's 239 | # makepkg to produce the .tgz: 240 | if [ "$NAME" = "rpm2tgz" -o "$NAME" = "rpm2txz" ]; then 241 | if [ "$NAME" = "rpm2tgz" ]; then 242 | EXT=tgz 243 | else 244 | EXT=txz 245 | fi 246 | ( 247 | if [ "$META_NAME" = "true" ]; then 248 | get_meta_data $i 249 | cd $TMPDIR 250 | /sbin/makepkg -l y -c $COPT "$CWD/$PRGNAM-$VERSION-$ARCH-${BUILD}.$EXT" 251 | else 252 | cd $TMPDIR 253 | /sbin/makepkg -l y -c $COPT "$CWD/$(basename $i .rpm).$EXT" 254 | fi 255 | ) 256 | else 257 | ( cd $TMPDIR ; tar cf - . ) > $(basename $i .rpm).tar 258 | gzip -9 $(basename $i .rpm).tar 259 | fi 260 | 261 | # Remove temporary directory: 262 | rm -rf $TMPDIR 263 | 264 | done 265 | 266 | --------------------------------------------------------------------------------