Merge pull request #707 from yohgaki/master
Add improved RPM package build script.
Showing
2 changed files
with
123 additions
and
0 deletions
rpm/build
0 → 100755
1 | #!/bin/bash | ||
2 | # | ||
3 | # A little helper script to build the RPM. | ||
4 | |||
5 | if [ ! -f "../package.json" ]; then | ||
6 | echo "Execute rpm build script in rpm directory" | ||
7 | exit 1 | ||
8 | fi | ||
9 | |||
10 | name="casperjs" | ||
11 | name=${name%.spec} | ||
12 | topdir=$(mktemp -d) | ||
13 | # Get version from package.json | ||
14 | version=$(grep '"version"' ../package.json | sed 's/.*"\(.*\)": "\(.*\)".*/\2/' | sed 's/[-]//') | ||
15 | builddir=${TMPDIR:-/tmp}/${name}-${version} | ||
16 | sourcedir="${topdir}/SOURCES" | ||
17 | buildroot="${topdir}/BUILD/${name}-${version}-root" | ||
18 | |||
19 | mkdir -p ${topdir}/{RPMS,SRPMS,SOURCES,BUILD} | ||
20 | mkdir -p ${buildroot} ${builddir} | ||
21 | |||
22 | echo "=> Copying sources..." | ||
23 | ( cd .. && tar cf - ./[A-Z]* ./package.json ./bin ./samples ./tests ./modules | tar xf - -C ${builddir} ) | ||
24 | |||
25 | echo "=> Creating source tarball under ${sourcedir}..." | ||
26 | ( cd ${builddir}/.. && tar zcf ${sourcedir}/${name}-${version}.tar.gz ${name}-${version} ) | ||
27 | |||
28 | echo "=> Building RPM..." | ||
29 | rpm=$(rpmbuild --define "_topdir ${topdir}" --define "_version ${version}" --buildroot ${buildroot} --clean -bb ${name}.spec | awk '/\/RPMS\// { print $2; }') | ||
30 | |||
31 | if [ $? -ne 0 ]; then | ||
32 | echo "Failed to build RPM package." | ||
33 | exit 1 | ||
34 | fi | ||
35 | |||
36 | echo ${rpm} | ||
37 | cp ${rpm} ${TMPDIR:-/tmp}/ | ||
38 | rm -fr ${topdir} | ||
39 | |||
40 | echo "RPM package build finished." | ||
41 | echo ${TMPDIR:-/tmp}/${rpm##*/} |
rpm/casperjs.spec
0 → 100644
1 | %define name casperjs | ||
2 | %if "%{_version}" | ||
3 | %define version %{_version} | ||
4 | %else | ||
5 | %define version 1.0 | ||
6 | %endif | ||
7 | %define release 1 | ||
8 | %define prefix /usr | ||
9 | |||
10 | %define mybuilddir %{_builddir}/%{name}-%{version}-root | ||
11 | |||
12 | Summary: open source navigation scripting & testing utility written in Javascript | ||
13 | Name: %{name} | ||
14 | Version: %{version} | ||
15 | License: BSD | ||
16 | Release: %{release} | ||
17 | Packager: Jan Schaumann <jschauma@etsy.com> | ||
18 | Group: Utilities/Misc | ||
19 | Source: %{name}-%{version}.tar.gz | ||
20 | BuildRoot: /tmp/%{name}-%{version}-root | ||
21 | |||
22 | Requires: phantomjs | ||
23 | |||
24 | %description | ||
25 | CasperJS is an open source navigation scripting & testing utility written | ||
26 | in Javascript and based on PhantomJS. It eases the process of defining a | ||
27 | full navigation scenario and provides useful high-level functions, methods | ||
28 | & syntactic sugar for doing common tasks | ||
29 | |||
30 | %prep | ||
31 | %setup -q | ||
32 | |||
33 | %install | ||
34 | mkdir -p %{mybuilddir}%{prefix}/bin | ||
35 | mkdir -p %{mybuilddir}%{prefix}/share/%{name}/bin | ||
36 | mkdir -p %{mybuilddir}%{prefix}/share/%{name}/modules | ||
37 | mkdir -p %{mybuilddir}%{prefix}/share/%{name}/samples | ||
38 | mkdir -p %{mybuilddir}%{prefix}/share/%{name}/tests | ||
39 | |||
40 | cp bin/%{name} %{mybuilddir}%{prefix}/share/%{name}/bin/ | ||
41 | ln -s %{prefix}/share/%{name}/bin/%{name} %{mybuilddir}%{prefix}/bin/%{name} | ||
42 | cp bin/bootstrap.js %{mybuilddir}%{prefix}/share/%{name}/bin/ | ||
43 | # Yes, this tool needs this file in the 'bin' directory. | ||
44 | cp bin/usage.txt %{mybuilddir}%{prefix}/share/%{name}/bin/ | ||
45 | cp CHANGELOG.md %{mybuilddir}%{prefix}/share/%{name}/ | ||
46 | cp CONTRIBUTING.md %{mybuilddir}%{prefix}/share/%{name}/ | ||
47 | cp CONTRIBUTORS.md %{mybuilddir}%{prefix}/share/%{name}/ | ||
48 | cp LICENSE.md %{mybuilddir}%{prefix}/share/%{name}/ | ||
49 | cp README.md %{mybuilddir}%{prefix}/share/%{name}/ | ||
50 | cp package.json %{mybuilddir}%{prefix}/share/%{name}/ | ||
51 | cp -R modules/* %{mybuilddir}%{prefix}/share/%{name}/modules/ | ||
52 | cp -R samples/* %{mybuilddir}%{prefix}/share/%{name}/samples/ | ||
53 | cp -R tests/* %{mybuilddir}%{prefix}/share/%{name}/tests/ | ||
54 | |||
55 | %files | ||
56 | %defattr(0444,root,root) | ||
57 | %attr(0555,root,root)%{prefix}/bin/%{name} | ||
58 | %attr(0555,root,root)%{prefix}/share/%{name}/bin/%{name} | ||
59 | %attr(0555,root,root)%{prefix}/share/%{name}/bin/bootstrap.js | ||
60 | %{prefix}/share/%{name}/bin/usage.txt | ||
61 | %{prefix}/share/%{name}/CHANGELOG.md | ||
62 | %{prefix}/share/%{name}/CONTRIBUTING.md | ||
63 | %{prefix}/share/%{name}/CONTRIBUTORS.md | ||
64 | %{prefix}/share/%{name}/LICENSE.md | ||
65 | %{prefix}/share/%{name}/README.md | ||
66 | %{prefix}/share/%{name}/package.json | ||
67 | %{prefix}/share/%{name}/modules/* | ||
68 | %{prefix}/share/%{name}/samples/* | ||
69 | %{prefix}/share/%{name}/tests/* | ||
70 | |||
71 | %changelog | ||
72 | * Fri Nov 15 2013 Yasuo Ohgaki <yohgaki@ohgaki.net> | ||
73 | - update spec for master and other branches | ||
74 | |||
75 | * Mon Dec 24 2012 Nicolas Perriault <nicolas@perriault.net> | ||
76 | - removed 'injector.js' module | ||
77 | |||
78 | * Mon Dec 10 2012 Jan Schaumann <jschauma@etsy.com> | ||
79 | - include 'tests' | ||
80 | |||
81 | * Mon Nov 26 2012 Jan Schaumann <jschauma@etsy.com> | ||
82 | - first rpm version |
-
Please register or sign in to post a comment