minor bugfixes to RPM magic

- nodejs-symlink-deps: don't create an empty node_modules dir when a module
    has no dependencies
  - nodes-fixdep: support adding deps when none exist
- use libexecdir for RPM helper scripts (per packaging guidelines discussion)
- Add the full set of headers usually bundled with node as deps to nodejs-devel.
  This way `npm install` for native modules that assume the stuff bundled with
  node exists will usually "just work".
This commit is contained in:
T.C. Hollingsworth 2013-01-22 13:46:01 -07:00
parent 7c60b0defb
commit 4e5a2f6e67
4 changed files with 27 additions and 17 deletions

View File

@ -14,11 +14,11 @@
# symlink dependencies so `npm link` works
# this should be run in every module's %%install section
# pass the module name if the npm metadata is incorrect (e.g. multiple versions)
%nodejs_symlink_deps %{_rpmconfigdir}/nodejs-symlink-deps %{nodejs_sitelib}
%nodejs_symlink_deps %{_libexecdir}/nodejs/nodejs-symlink-deps %{nodejs_sitelib}
# patch package.json to fix a dependency
# see `man npm-json` for details on writing dependencies for package.json files
# e.g. `%%nodejs_fixdep frobber` makes any version of frobber do
# `%%nodejs_fixdep frobber '>1.0'` requires frobber > 1.0
# `%%nodejs_fixdep -r frobber removes the frobber dep
%nodejs_fixdep %{_rpmconfigdir}/nodejs-fixdep
%nodejs_fixdep %{_libexecdir}/nodejs/nodejs-fixdep

View File

@ -27,14 +27,13 @@ import os
import shutil
import sys
if not os.path.exists('package.json'):
if not os.path.exists('package.json~'):
shutil.copy2('package.json', 'package.json~')
md = json.load(open('package.json'))
if not 'dependencies':
sys.stderr.write("No dependencies listed in this module's package.json\n")
sys.exit(2)
if not md['dependencies']:
md['dependencies'] = {}
if sys.argv[1] == '-r':
dep = sys.argv[2]

View File

@ -39,14 +39,14 @@ else:
os.chdir(os.path.join(os.environ['RPM_BUILD_ROOT'], sitelib.lstrip('/'), name))
try:
os.mkdir('node_modules')
except OSError:
sys.stderr.write('WARNING: node_modules already exists. Make sure you have' +
'no bundled dependencies.\n')
os.chdir('node_modules')
if 'dependencies' in metadata:
try:
os.mkdir('node_modules')
except OSError:
sys.stderr.write('WARNING: node_modules already exists. Make sure you have ' +
'no bundled dependencies.\n')
os.chdir('node_modules')
for dep in metadata['dependencies'].iterkeys():
os.symlink(os.path.join(sitelib, dep), dep)

View File

@ -1,6 +1,6 @@
Name: nodejs
Version: 0.9.5
Release: 9%{?dist}
Release: 10%{?dist}
Summary: JavaScript runtime
License: MIT and ASL 2.0 and ISC and BSD
Group: Development/Languages
@ -52,6 +52,7 @@ real-time applications that run across distributed devices.
Summary: JavaScript runtime - development headers
Group: Development/Languages
Requires: %{name} == %{version}-%{release}
Requires: libuv-devel http-parser-devel openssl-devel c-ares-devel zlib-devel
%description devel
Development headers for the Node.js JavaScript runtime.
@ -131,8 +132,8 @@ install -Dpm0644 %{SOURCE1} %{buildroot}%{_sysconfdir}/rpm/macros.nodejs
install -Dpm0644 %{SOURCE2} %{buildroot}%{_rpmconfigdir}/fileattrs/nodejs.attr
install -pm0755 %{SOURCE3} %{buildroot}%{_rpmconfigdir}/nodejs.prov
install -pm0755 %{SOURCE4} %{buildroot}%{_rpmconfigdir}/nodejs.req
install -pm0755 %{SOURCE5} %{buildroot}%{_rpmconfigdir}/nodejs-symlink-deps
install -pm0755 %{SOURCE6} %{buildroot}%{_rpmconfigdir}/nodejs-fixdep
install -Dpm0755 %{SOURCE5} %{buildroot}%{_libexecdir}/nodejs/nodejs-symlink-deps
install -pm0755 %{SOURCE6} %{buildroot}%{_libexecdir}/nodejs/nodejs-fixdep
#install documentation
mkdir -p %{buildroot}%{_defaultdocdir}/%{name}-docs-%{version}/html
@ -168,6 +169,16 @@ cp -p common.gypi %{buildroot}%{_datadir}/node
%doc LICENSE
%changelog
* Tue Jan 22 2013 T.C. Hollingsworth <tchollingsworth@gmail.com> - 0.9.5-10
- minor bugfixes to RPM magic
- nodejs-symlink-deps: don't create an empty node_modules dir when a module
has no dependencies
- nodes-fixdep: support adding deps when none exist
- use libexecdir for RPM helper scripts (per packaging guidelines discussion)
- Add the full set of headers usually bundled with node as deps to nodejs-devel.
This way `npm install` for native modules that assume the stuff bundled with
node exists will usually "just work".
* Sat Jan 12 2013 T.C. Hollingsworth <tchollingsworth@gmail.com> - 0.9.5-9
- fix brown paper bag bug in requires generation script