Skip to content

Commit bf23328

Browse files
committed
build: add rpmbuild .spec file
Add a .spec file and a rpmbuild(1) driver script. Useful for people on RHEL-based systems that want to compile and package from source. PR-URL: node-forward/node#10 Reviewed-By: Rod Vagg <rod@vagg.org>
1 parent e13663d commit bf23328

File tree

2 files changed

+148
-0
lines changed

2 files changed

+148
-0
lines changed

tools/rpm/node.spec

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
# Copyright (c) 2013, StrongLoop, Inc. <callback@strongloop.com>
2+
#
3+
# Permission to use, copy, modify, and/or distribute this software for any
4+
# purpose with or without fee is hereby granted, provided that the above
5+
# copyright notice and this permission notice appear in all copies.
6+
#
7+
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
8+
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
9+
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
10+
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
11+
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
12+
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
13+
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
14+
15+
# This is updated by rpmbuild.sh.
16+
%define _version 0.10.12
17+
18+
Name: node
19+
Version: %{_version}
20+
Release: 1
21+
Summary: Node.js is a platform for building fast, scalable network applications.
22+
Group: Development/Languages
23+
License: MIT
24+
URL: http://nodejs.org/
25+
Source0: http://nodejs.org/dist/v%{_version}/node-v%{_version}.tar.gz
26+
BuildRequires: gcc
27+
BuildRequires: gcc-c++
28+
BuildRequires: glibc-devel
29+
BuildRequires: make
30+
BuildRequires: python
31+
32+
# Conflicts with the HAM radio package.
33+
Conflicts: node <= 0.3.2-11
34+
35+
# Conflicts with the Fedora node.js package.
36+
Conflicts: nodejs
37+
38+
39+
%description
40+
Node.js is a platform built on Chrome's JavaScript runtime for easily
41+
building fast, scalable network applications.
42+
43+
Node.js uses an event-driven, non-blocking I/O model that makes it
44+
lightweight and efficient, perfect for data-intensive real-time
45+
applications that run across distributed devices.
46+
47+
48+
%prep
49+
%setup -q
50+
51+
52+
%build
53+
%ifarch arm
54+
%define _dest_cpu arm
55+
%endif
56+
57+
%ifarch i386 i686
58+
%define _dest_cpu ia32
59+
%endif
60+
61+
%ifarch x86_64
62+
%define _dest_cpu x64
63+
%endif
64+
65+
./configure --prefix=/usr --dest-cpu=%{_dest_cpu}
66+
make %{?_smp_mflags}
67+
68+
69+
%check
70+
#make test
71+
72+
73+
# Use mildly hard-coded paths in the install and files targets for now.
74+
# _libdir is /usr/lib64 on some systems but the node.js installer always
75+
# installs to /usr/lib. I have commits sitting in a branch that add --libdir
76+
# and --mandir configure switches to the node.js configure script but it's
77+
# debatable if it's worth the extra complexity.
78+
%install
79+
export DONT_STRIP=1 # Don't strip debug symbols for now.
80+
make install DESTDIR=%{buildroot}
81+
rm -fr %{buildroot}/usr/lib/dtrace/ # No systemtap support.
82+
install -m 755 -d %{buildroot}/usr/lib/node_modules/
83+
install -m 755 -d %{buildroot}%{_datadir}/%{name}
84+
85+
# Remove junk files from node_modules/ - we should probably take care of
86+
# this in the installer.
87+
for FILE in .gitmodules .gitignore .npmignore .travis.yml \*.py[co]; do
88+
find %{buildroot}/usr/lib/node_modules/ -name "$FILE" -delete
89+
done
90+
91+
92+
%files
93+
/usr/bin/*
94+
/usr/include/*
95+
/usr/lib/node_modules/
96+
/usr/share/man/man1/node.1.gz
97+
/usr/share/systemtap/tapset/node.stp
98+
%{_datadir}/%{name}/
99+
%doc ChangeLog LICENSE README.md
100+
101+
102+
%changelog
103+
* Fri Jul 5 2013 Ben Noordhuis <info@bnoordhuis.nl>
104+
- Initial release.

tools/rpm/rpmbuild.sh

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/bin/sh
2+
3+
# Copyright (c) 2013, StrongLoop, Inc. <callback@strongloop.com>
4+
#
5+
# Permission to use, copy, modify, and/or distribute this software for any
6+
# purpose with or without fee is hereby granted, provided that the above
7+
# copyright notice and this permission notice appear in all copies.
8+
#
9+
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10+
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11+
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12+
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13+
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14+
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15+
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16+
17+
set -e
18+
19+
TOOLSDIR=`dirname $0`
20+
TOPLEVELDIR="$TOOLSDIR/../.."
21+
22+
RPMBUILD_PATH="${RPMBUILD_PATH:-$HOME/rpmbuild}"
23+
if [ ! -d "$RPMBUILD_PATH" ]; then
24+
echo "Run rpmdev-setuptree first."
25+
exit 1
26+
fi
27+
28+
if [ $# -ge 1 ]; then
29+
VERSION=$1
30+
else
31+
FILE="$TOPLEVELDIR/src/node_version.h"
32+
MAJOR=`sed -nre 's/#define NODE_MAJOR_VERSION ([0-9]+)/\1/p' "$FILE"`
33+
MINOR=`sed -nre 's/#define NODE_MINOR_VERSION ([0-9]+)/\1/p' "$FILE"`
34+
PATCH=`sed -nre 's/#define NODE_PATCH_VERSION ([0-9]+)/\1/p' "$FILE"`
35+
VERSION="$MAJOR.$MINOR.$PATCH"
36+
fi
37+
38+
set -x
39+
40+
sed -re "s/%define _version .+/%define _version ${VERSION}/" \
41+
"$TOOLSDIR/node.spec" > $RPMBUILD_PATH/SPECS/node.spec
42+
tar --exclude-vcs --transform="s|^|node-${VERSION}/|" \
43+
-czf $RPMBUILD_PATH/SOURCES/node-v${VERSION}.tar.gz .
44+
rpmbuild $* -ba $RPMBUILD_PATH/SPECS/node.spec

0 commit comments

Comments
 (0)