Showing posts with label rpmbuild. Show all posts
Showing posts with label rpmbuild. Show all posts

rpm spec macros

 https://docs.fedoraproject.org/en-US/packaging-guidelines/RPMMacros/

rpmbuild with rpmrc

RPM_DIR=`pwd`/rpm
echo "%_topdir $RPM_DIR" > rpmmacros
echo "macrofiles:     /usr/lib/rpm/macros:/usr/lib/rpm/%{_target}/macros:/usr/lib/rpm/redhat/macros:/etc/rpm/macros.*:/etc/rpm/macros:/etc/rpm/%{_target}/macros:~/.rpmmacros:rpmmacros" > rpmrc

mkdir -p $RPM_DIR/{BUILD,RPMS,SOURCES,SPECS,SRPMS}

rpmbuild --rcfile rpmrc --rebuild some.source.rpm

rpmbuild --rcfile rpmrc --define 'dist .el5' -without java -without python \
 --target=x86_64 -ba rpm/SPECS/protobuf.spec
or redefine topdir as
rpmbuild --define "_topdir /home/user/rpmdir" --define 'dist .el5' \
 -without java -without python  --target=x86_64 -ba rpm/SPECS/protobuf.spec

use one thread to build for easy debugging
$ cat ~/.rpmmacros 
%_smp_mflags  -j1

custom kernel with rpmbuild

make targets:
make
make modules
make modules_install

Generate patch:
diff -Naurp old new > my.patch

Modify kernel steps
put the following in .rpmmacros:
cat ~/.rpmmacros
%_topdir %(echo /home/user/mypath)/rpm
%_tmppath %(echo /home/user/mypath)/rpm/tmp
%debug_package %{nil}
  • install the src package
    rpm -i kernel*.src.rpm
  • generate patches and put in SOURCES
  • modified kernel*.config in SOURCES
  • modified SPEC/kernel*.spec to pickup the patches
    Patch3000: my.patch
    %patch3000 -p1
apply the patch (cd to SPECS)
rpmbuild -bp --target=i686 kernel-2.6.spec


build:
rpmbuild -bb --with baseonly --without debug --without debuginfo --without kabichk --target=i686 kernel-2.6.spec
use buildid to change buildname
build without rpm
rpmbuild -bp kernelsrc.rpm
cd rpm/kernel/sourcedir
cp favor_config to .config
make menuconfig # set prefix
make -j8
make modules_install
make install