[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[MiNT] Cross Compiled LZIP RPM & Quick Docs for Building it (90% complete!)



So, I have been able to successfully cross compile an RPM AND make it so it will both cross compile and build natively. The only problem I have encountered is that when installing the cross compiled RPM, you must pass --ignoreos in the rpm install line. I have not been able to solve this issue yet, so this is about 90%. If anyone knows the secret to this, please share.

Here are the LZIP RPMs, built on my PS3:

http://www.radix.net/~atari/mint/lzip-1.5-1.m68kmint.rpm 221k
http://www.radix.net/~atari/mint/lzip-1.5-1.src.rpm 68k

This RPM will build natively with a GCC4 compiler (but not with 2.95.3, needs more patching).

I have also built the RPM with Cygwin, the only problem is that it adds cygwin into the name of the created package, and I think just renaming the package fixes that.

Anyway, here is what I did to create the cross env.

In the home directory of the user, create a .rpmmacros with the following:

%_topdir        /usr/local/cross-mint/sparemint
%_cc            /usr/local/cross-mint/rpm-bin/%{_target}-gcc

Now, create the sparemint dir listed above, and then in it create these dirs:

BUILD
RPMS
SOURCE
SPECS
SRPMS

Now, drop your spec and source files in the correct place, and then to build the package do:

rpmbuild -ba --target m68kmint lzip.spec
or
rpm -ba --target m68kmint lzip.spec

Depending on RPM version.

Now, here is the lzip spec I created, setup to cross compile. This app has a custom configure script, so it is a little different than the usual:

Version:        1.5
Release:        1
Summary:        Data compression utility using LZMA with fast decompress
Name:           lzip
Source0: http://download.savannah.gnu.org/releases/lzip/lzip-%{version}.tar.gz
Patch0:         lzip-1.5-mint.patch
License:        GPL
Group:          System Environment/Libraries
URL:            http://www.nongnu.org/lzip/lzip.html
Packager:       Keith Scroggins <kws@radix.net>
Vendor:         Sparemint
BuildRoot:      /var/tmp/%{name}-%{version}-root

# For newer versions of RPM so native strip and debuginfo are not utilized
# when cross compiling
%define __spec_install_post /usr/lib/rpm/brp-compress || :
%define debug_package %{nil}
%define is_sparemint %(test -e /etc/sparemint-release && echo 1 || echo 0)


%description
    Lzip is a lossless file compressor based on the LZMA
    (Lempel-Ziv-Markov chain-Algorithm) algorithm, designed by Igor
    Pavlov. The high compression of LZMA comes from combining two basic,
    well-proven compression ideas: sliding dictionaries (i.e. LZ77/78),
    and Markov models (i.e. the thing used by every compression
    algorithm that uses a range encoder or similar order-0 entropy coder
    as its last stage) with segregation of contexts according to what
    the bits are used for. Lzip has a user interface similar to the one
    of gzip(1) or bzip2(1).

%prep
%setup -q
%patch0 -p1
%build
./configure CFLAGS="-O2 -fomit-frame-pointer" CC=m68k-atari-mint-gcc \
        --prefix=/usr CXX=m68k-atari-mint-g++ \
        CXXFLAGS="-O2 -fomit-frame-pointer"
make

%install
rm -rf $RPM_BUILD_ROOT
make install DESTDIR="$RPM_BUILD_ROOT"
# I have no clue why this is not installed....
cp lziprecover $RPM_BUILD_ROOT/usr/bin
rm $RPM_BUILD_ROOT/usr/share/info/dir
gzip -9nf $RPM_BUILD_ROOT/usr/share/info/*
gzip -9nf $RPM_BUILD_ROOT/usr/share/man/man1/*

%if %is_sparemint
strip $RPM_BUILD_ROOT/usr/bin/lzip
strip $RPM_BUILD_ROOT/usr/bin/lziprecover
stack -S 256k $RPM_BUILD_ROOT/usr/bin/lzip
stack -S 256k $RPM_BUILD_ROOT/usr/bin/lziprecover
%else
m68k-atari-mint-strip $RPM_BUILD_ROOT/usr/bin/lzip
m68k-atari-mint-strip $RPM_BUILD_ROOT/usr/bin/lziprecover
m68k-atari-mint-stack -S 256k $RPM_BUILD_ROOT/usr/bin/lzip
m68k-atari-mint-stack -S 256k $RPM_BUILD_ROOT/usr/bin/lziprecover
%endif

%clean
rm -rf $RPM_BUILD_ROOT

%files
%defattr(0644,root,root,0755)
%doc AUTHORS COPYING NEWS README
%attr(0755,root,root) /usr/bin/lzip*
%attr(0644,root,root) /usr/share/info/*
%attr(0644,root,root) /usr/share/man/man1/*

%changelog
* Fri May 15 2009 Keith Scroggins <kws@radix.net>
- Initial build of lzip RPM using Cross Compilers!

-------------------------------------------------------------------------------------

%define __spec_install_post /usr/lib/rpm/brp-compress || :
This line disables RPMs use of native strip, and has no effect on native compile.

%define debug_package %{nil}
This line disables RPMs use of debuginfo, and has no effect on native compile.

%define is_sparemint %(test -e /etc/sparemint-release && echo 1 || echo 0)
This line determines if we are building natively, so we can differentiate between cross compile actions and native actions, in this example, I am using this for using a native strip/stack versus the cross compiled counterparts.

Anyway, this is quick and dirty, and just a start. I *THINK* the only real issue is needing to use the --ignoreos parameter when installing the RPM, but there could be other issues.

Please test, and provide lots of feedback, cross compiling RPMs will be a major step forward! I hope to try some more packages this weekend, if time permits.

Keith