Skip to content

Instantly share code, notes, and snippets.

@johnelf
Last active August 29, 2015 14:19
Show Gist options
  • Save johnelf/e8be3fab9da22857fd09 to your computer and use it in GitHub Desktop.
Save johnelf/e8be3fab9da22857fd09 to your computer and use it in GitHub Desktop.
Spec file
Name: bbs
Summary: BBS
Version: 1.0
Release: 1
URL: example.com
Source: %{name}-%{version}-%{release}.tar.gz
License: MIT
Group: Applications/Internet
BuildArch: noarch
Requires: java-1.7.0-openjdk, java-1.7.0-openjdk-devel
%description
This is a RPM for bbs project.
%prep
%setup -q
%install
install -d $RPM_BUILD_ROOT/opt/apps
install -p $RPM_BUILD_DIR/%{name}-%{version}/%{name}.war $RPM_BUILD_ROOT/opt/apps/%{name}.war
%post
if [ -d "/usr/local/apache-tomcat-7.0.61/webapps" ]; then
mv /opt/apps/%{name}.war /usr/local/apache-tomcat-7.0.61/webapps
else
echo 'please install apache tomcat'
fi
%preun
rm -rf /usr/local/apache-tomcat-7.0.61/webapps/bbs
%postun
service tomcat restart
%files
%attr(644,root,root) /opt/apps/%{name}.war
%clean
rm -rf $RPM_BUILD_ROOT
%changelog
* Wed Apr 22 2015 Zhang Jinwen <jwzhang@thoughtworks.com>
- Build for CentOS-6.4
@darth30joker
Copy link

Several comments:

  1. You can add tomcat as a "Requires"
  2. If OS does not have tomcat installed, there will be an error calling 'service tomcat restart' in %postun
  3. Why don't you restart tomcat after installing this rpm?
  4. Another thing is, you cannot write a specific version of tomcat in SPEC
  5. in %preun, you don't do any check....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment