3

I have a binary Java run.jar file, a bash script run.sh which executes run.jar via java -jar.

  • In my environment (~/rpmbuild/), where do I have to put those two files? Where do I have to put the source file? (I guess I should compress the source as .tar.gz)

How can I write the spec file to:

  • Make directory ~/bin/my-package;
  • Copy run.jar and run.sh to above directory;

That's all I want. Would you please help me a little?

Thanks for your time.

P.S: I went through this how-to. Unfortunately I'm newbie in this, I couldn't find the solution.

2 Answers2

5

Create ~/.rpmmacros to set up RPM build environment.

$ mkdir -p ~/rpmbuild/{BUILD,RPMS/{i{3,4,5,6}86,x86_64,noarch},SOURCES,SPECS,SRPMS}
$ echo "%_topdir $HOME/rpmbuild" > ~/.rpmmacros

And put run.jar/run.sh and spec file into ~/rpmbuild/SOURCES and ~/rpmbuild/SPECS/ respectively.

EDIT: In a spec file:

(skip)

Source0: run.jar
Source1: run.sh

(skip)

%install

%{__mkdir_p} ${RPM_BUILD_ROOT}/path/to/my-package

%{__install} -m0644 %{SOURCE0} ${RPM_BUILD_ROOT}/path/to/my-package
%{__install} -m0644 %{SOURCE1} ${RPM_BUILD_ROOT}/path/to/my-package

(skip)

%files
/path/to/my-package/*
Taizo Ito
  • 424
  • 2
  • 10
  • Thanks. But I commented out `%prep`, `%build` (to skip them). And `rpmbuild -ba ...` raised error with `.configure`... Could you please just do a test in your machine, only put an `example.sh` in your `SOURCES` and write the spec file to: make a dir `~/bin/test`, copy `example.sh` to `~/bin/`? –  Oct 26 '12 at 09:39
  • Thank you. I think I'm figuring it out. Commenting `# %configure` does not work. Instead I use `# configure` (no `@`)… Anyway thank you for your help. –  Oct 26 '12 at 09:50
5

I couldn't edit @Taizo Ito's answer because there are lots of changes. His answer is right, but I update to newest RPM build guidelines:

# skip

Source0: run.jar
Source1: run.sh

#skip

%install

rm -rf %{buildroot}
mkdir -p %{buildroot}%{_bindir}/my-package
cp %{SOURCE0} %{buildroot}%{_bindir}/my-package
cp %{SOURCE1} %{buildroot}%{_bindir}/my-package

# skip

%files
%{_bindir}/my-package/*

%clean
rm -rf %{buildroot}

# ...