Operating System - Linux
1819743 Members
3081 Online
109606 Solutions
New Discussion юеВ

Re: Trying to build a custom RPM

 
SOLVED
Go to solution
Ian Dennison_1
Honored Contributor

Trying to build a custom RPM

Hi all, I am trying to build a custom RPM, based on 2 shell scripts I wrote. The problems I have are 2-fold

1. rpmbuild wants a "patch" entry in the spec file. Unfortunately I build my scripts properly the first time so don't need patches - how do I get "rpmbuild" to recognise this?

2. Self-extraction / installation
According to the documentation I found on rpmbuild on www.rom.org, , anything in the "%build" or "%install" are just script commands, so when I fake out the Patch problem above, nothing gets created in the destination directory nor in the $RPM_BUILD_ROOT directory.

Belows is my spec file. I create a tar and gziped it with the 2 scripts in. Any advice on what is going wrong here?

Share and Enjoy! Ian
---------------------------------
Summary: A set of programs to build a LINUX System via FTP
Name: linux_ftp_build
Version: 0.9.0
Release: 1
Copyright: GPL
Group: Applications/System
Source: linux_ftp_build.tar.gz
Patch:
BuildRoot: /var/tmp/${name}-buildroot

%description
A set of scripts designed for BOBBOBBOBBOBBOBBOBOBBOBOBOB for taking a
base install of RH Enterprise 3 Linux and allowing selection of a standard
set of patches / tools to be ftp'ed down and implemented. Also contains
useful scripts for setting up networking etc post-install.

%prep
%setup -c
%patch

%build
cp -rp $RPM_BUILD_ROOT/* /home
ll $RPM_BUILD_ROOT

%install
# install -m 755 linux_ftp_build.sh $RPM_BUILD_ROOT/linux_ftp_build.sh
# install -m 755 master_post_implement.sh $RPM_BUILD_ROOT/master_post_implement.sh
ll $RPM_BUILD_ROOT

%clean
# :rm -rf $RPM_BUILD_ROOT/${name}-buildroot

%files
%defattr(-,root,root)
%doc
/home/linux_ftp_build.sh
/home/master_post_implement.sh

%changelog
* Fri Jun 10 2005 Ian Dennison
Initial build and rollout
Building a dumber user
3 REPLIES 3
Stuart Browne
Honored Contributor
Solution

Re: Trying to build a custom RPM

Wow, it's been a while since I tried doing this without a source-tree that needs to be built!

A few things.. ${name} should be %{name}.

As you have no patches, get rid of the Patch and %patch lines.

Do you actually have a 'linux_ftp_build.tar.gz' with these two scripts in it? Or are the scripts in '/home/...' ?

RPM first extracts the files in 'Source' to '/usr/src/redhat/BUILD/'. It then does the %prep section (nicely done), followed by the %build section. As there are no Makefile's involved, yea, you have to do fun things.

In %build, you want to copy the two files to '$RPM_BUILD_ROOT/' so that %files can grab them from there.

After that, you're all set!

I made a few quick modifications to your spec file, and this is how it looks:
Summary: A set of programs to build a LINUX System via FTP
Name: linux_ftp_build
Version: 0.9.0
Release: 1
Copyright: GPL
Group: Applications/System
Source: linux_ftp_build.tar.gz
BuildRoot: /var/tmp/%{name}-buildroot

%description
A set of scripts designed for BOBBOBBOBBOBBOBBOBOBBOBOBOB for taking a
base install of RH Enterprise 3 Linux and allowing selection of a standard
set of patches / tools to be ftp'ed down and implemented. Also contains
useful scripts for setting up networking etc post-install.

%prep
%setup -c

%build
pwd
mkdir -p $RPM_BUILD_ROOT/home/
cp -rp /* $RPM_BUILD_ROOT/home/
ls -l $RPM_BUILD_ROOT

%install
# install -m 755 linux_ftp_build.sh $RPM_BUILD_ROOT/linux_ftp_build.sh
# install -m 755 master_post_implement.sh $RPM_BUILD_ROOT/master_post_implement.sh
ls -l $RPM_BUILD_ROOT

%clean
# :rm -rf $RPM_BUILD_ROOT/${name}-buildroot

%files
%defattr(-,root,root)
%doc
/home/linux_ftp_build.sh
/home/master_post_implement.sh

%changelog
* Fri Jun 10 2005 Ian Dennison
Initial build and rollout
One long-haired git at your service...
Ross Minkov
Esteemed Contributor

Re: Trying to build a custom RPM

Just delete the %patch line. And one more thing -- the 2 scripts /home/linux_ftp_build.sh and /home/master_post_implement.sh should be under %files not under %doc.

-Ross
Ian Dennison_1
Honored Contributor

Re: Trying to build a custom RPM

Thanks for the assistance.

I have corrected the Spec file (and found a bug where the files are copied to /var/tmp/%{name}/home/%{name}-%{version} rather than /var/tmp/%{name}/home/) and generated and installed the files.

Share and Enjoy! Ian Dennison
Building a dumber user