|
| 1 | +%define _prefix_path opt/axsh |
| 2 | +%define _tiny_web_example_git_uri git://github.com/axsh/tiny_web_example.git |
| 3 | +%define oname tiny-web-example |
| 4 | + |
| 5 | +%define release_id 1.daily |
| 6 | +%{?build_id:%define release_id %{build_id}} |
| 7 | +%{?repo_uri:%define _tiny_web_example_git_uri %{repo_uri}} |
| 8 | + |
| 9 | +Summary: Tiny Web Example. |
| 10 | +Name: %{oname} |
| 11 | +Version: 0.0.1 |
| 12 | +Release: %{release_id}%{?dist} |
| 13 | +License: see https://github.com/axsh/tiny_web_example/blob/master/README.md |
| 14 | +Group: Development/Languages |
| 15 | +URL: http://example.jp/ |
| 16 | +Source0: %{_vdc_git_uri} |
| 17 | +Prefix: /%{_prefix_path} |
| 18 | + |
| 19 | +BuildRequires: mysql-devel |
| 20 | + |
| 21 | +Requires: nginx |
| 22 | +Requires: mysql-server |
| 23 | + |
| 24 | + |
| 25 | +%description |
| 26 | +Tiny Web Example |
| 27 | + |
| 28 | +%prep |
| 29 | +[ -d %{name}-%{version} ] && rm -rf [ -d %{name}-%{version} ] |
| 30 | +git clone %{_tiny_web_example_git_uri} %{name}-%{version} |
| 31 | +cd %{name}-%{version} |
| 32 | +[ -z "%{build_id}" ] || { |
| 33 | + build_id=%{build_id} |
| 34 | + git checkout ${build_id##*git} |
| 35 | + unset build_id |
| 36 | +} && : |
| 37 | + |
| 38 | +%setup -T -D |
| 39 | + |
| 40 | +%build |
| 41 | +RUBYDIR=/usr/bin/ruby rpmbuild/rules build |
| 42 | + |
| 43 | +%install |
| 44 | +[ -d ${RPM_BUILD_ROOT} ] && rm -rf ${RPM_BUILD_ROOT} |
| 45 | +mkdir -p ${RPM_BUILD_ROOT}/%{prefix}/%{oname} |
| 46 | + |
| 47 | +components=" |
| 48 | + frontend |
| 49 | + webapi |
| 50 | +" |
| 51 | +for component in ${components}; do |
| 52 | + rsync -aHA --exclude=".git/*" --exclude="*~" --exclude="*/cache/*.gem" --exclude="*/cache/bundler/git/*" `pwd`/${component} ${RPM_BUILD_ROOT}/%{prefix}/%{oname}/ |
| 53 | +done |
| 54 | +unset components |
| 55 | + |
| 56 | +[ -d ${RPM_BUILD_ROOT}/etc ] || mkdir -p ${RPM_BUILD_ROOT}/etc |
| 57 | +rsync -aHA `pwd`/contrib/etc/default ${RPM_BUILD_ROOT}/etc |
| 58 | +rsync -aHA `pwd`/contrib/etc/init ${RPM_BUILD_ROOT}/etc |
| 59 | +rsync -aHA `pwd`/contrib/etc/%{oname} ${RPM_BUILD_ROOT}/etc |
| 60 | + |
| 61 | +mkdir -p ${RPM_BUILD_ROOT}/var/log/%{oname} |
| 62 | + |
| 63 | +%clean |
| 64 | +RUBYDIR=/usr/bin/ruby rpmbuild/rules clean |
| 65 | +rm -rf $RPM_BUILD_ROOT |
| 66 | + |
| 67 | +%post |
| 68 | +/sbin/chkconfig mysqld on |
| 69 | + |
| 70 | +%files |
| 71 | +%defattr(-,root,root,-) |
| 72 | +%{prefix}/%{oname} |
| 73 | +%dir /etc/%{oname} |
| 74 | +%dir /var/log/%{oname} |
| 75 | +%config(noreplace) /etc/default/tiny-web-example-webapi |
| 76 | +%config(noreplace) /etc/default/tiny-web-example-webapp |
| 77 | +%config(noreplace) /etc/init/tiny-web-example-webapi.conf |
| 78 | +%config(noreplace) /etc/init/tiny-web-example-webapp.conf |
| 79 | +%config(noreplace) /etc/tiny-web-example/unicorn-common.conf |
| 80 | +%config(noreplace) /etc/tiny-web-example/webapi.conf |
| 81 | +%config(noreplace) /etc/tiny-web-example/webapp.yml |
0 commit comments