add rpmoffset with lzma support

This commit is contained in:
geos_one
2009-01-16 12:24:00 +00:00
parent 3f498e197d
commit 347f2cdc8b
7 changed files with 115 additions and 11 deletions

View File

@@ -0,0 +1,2 @@
AUX rpmoffset.c 1964 RMD160 acea626f5080b7ea47863cf9e3bc2ab3b381c61e SHA1 5ec35b3d37773ca4a09443c6ea687c7d3a739f34 SHA256 e1e18d68009bd4541d6c65b43f45b58d720b9c87eba612d7616e244142f80dfe
EBUILD rpm5offset-9.0.ebuild 628 RMD160 cf664dc26a5305e9d85b29ef89f9a1faf26bbae2 SHA1 c08ecbb217ffa829d134544c78fbbeb451510193 SHA256 5b9561a70c0dece76fb9e4f94690e8b8cf143dd98edf08d13938a922ce0eaef5

View File

@@ -0,0 +1,72 @@
/* Find how deeply inside an .RPM the real data is */
/* kept, and report the offset in bytes */
/* Wouldn't it be a lot more sane if we could just untar these things? */
#include <stdlib.h>
#include <stdio.h>
/* These offsets keep getting bigger, so we're going to just bite a 2MB */
/* chunk of RAM right away so that we have enough. Yeah, horrible */
/* quick and dirty implementation, but hey -- it gets the job done. */
#define RPMBUFSIZ 3145728
main()
{
char *buff = malloc(RPMBUFSIZ),*eb,*p;
for (p = buff, eb = buff + read(0,buff,RPMBUFSIZ); p < eb; p++)
{
/* gzip format */
if (*p == '\037' && p[1] == '\213' && p[2] == '\010')
{
printf("%ld\n",p - buff);
exit(0);
}
/* bzip2 format */
else if (*p == 'B' && p[1] == 'Z' && p[2] == 'h' )
{
printf("%ld\n",p - buff);
exit(0);
}
/* LZMA files; both LZMA_Alone and LZMA utils formats. The LZMA_Alone
* format is used by the LZMA_Alone tool from LZMA SDK. The LZMA utils
* format is the default format of LZMA utils 4.32.1 and later. */
/* LZMA utils format */
else if (*p == '\377' && p[1] == 'L' &&
p[2] == 'Z' && p[3] == 'M' &&
p[4] == 'A' && p[5] == '\000')
{
printf("%ld\n",p - buff);
exit(0);
}
/* The LZMA_Alone format has no magic bytes, thus we
* need to play a wizard. This can give false positives,
* thus the detection below should be removed when
* the newer LZMA utils format has got popular. */
// else if (*p == 0x5D && p[1] == 0x00 &&
else if (*p == '\135' &&
p[5] == '\377' && p[6] == '\377' &&
p[7] == '\377' && p[8] == '\377' &&
p[9] == '\377' && p[10] == '\377' &&
p[11] == '\377' && p[12] == '\377')
/* ((p[10] == 0x00 && p[11] == 0x00 &&
p[12] == 0x00) ||
(p[5] == 0xFF && p[6] == 0xFF &&
p[7] == 0xFF && p[8] == 0xFF &&
p[9] == 0xFF && p[10] == 0xFF &&
p[11] == 0xFF && p[12] == 0xFF)))
*/ {
printf("%ld\n",p - buff);
exit(0);
}
}
exit(1);
}

View File

@@ -0,0 +1,26 @@
# Copyright 1999-2008 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $
inherit toolchain-funcs
DESCRIPTION="Find how deeply inside an .RPM the real data is"
HOMEPAGE="http://www.slackware.com/config/packages.php"
SRC_URI=""
LICENSE="as-is"
SLOT="0"
KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~x86-fbsd"
IUSE="userland_GNU"
RDEPEND="app-arch/cpio
app-arch/lzma-utils"
DEPEND="${DEPEND}"
src_compile() {
"$(tc-getCC)" ${CFLAGS} ${LDFLAGS} ${FILESDIR}/rpmoffset.c -o rpm5offset || die
}
src_install() {
dobin rpm5offset || die
}