nodejs-inherits/nodejs-inherits.spec
2020-08-20 19:47:50 +08:00

68 lines
2.2 KiB
RPMSpec

%{?nodejs_find_provides_and_requires}
Name: nodejs-inherits
Version: 2.0.3
Release: 1
Summary: A tiny simple way to do classic inheritance in js
License: WTFPL
URL: https://github.com/isaacs/inherits
Source0: https://registry.npmjs.org/inherits/-/inherits-%{version}.tgz
Source1: https://raw.github.com/isaacs/inherits/112807f2670160b6e3bafdf39e395c10ae7d0fac/LICENSE
BuildArch: noarch
ExclusiveArch: %{nodejs_arches} noarch
BuildRequires: nodejs-packaging
%description
%{summary}.
%prep
%setup -q -n package
cp -p %{SOURCE1} LICENSE
%build
%install
mkdir -p %{buildroot}%{nodejs_sitelib}/inherits@2
cp -pr inherits.js package.json %{buildroot}%{nodejs_sitelib}/inherits@2
ln -sf inherits@2 %{buildroot}%{nodejs_sitelib}/inherits
%nodejs_symlink_deps
%check
%nodejs_symlink_deps --check
%triggerun -- nodejs-inherits < 2.0.0-4
ln -sf inherits@2 %{nodejs_sitelib}/inherits
%{__python} <<EOF
import json, os, sys
for moddir in os.listdir('%{nodejs_sitelib}'):
if os.path.isdir(moddir):
md = json.load(open(os.path.join(moddir, 'package.json')))
if 'dependencies' in md and 'inherits' in md['dependencies']:
if isinstance(md['dependencies'], dict) and '1' in md['dependencies']['inherits']:
src = os.path.join('%{nodejs_sitelib}', 'inherits@1')
else:
src = os.path.join('%{nodejs_sitelib}', 'inherits@2')
dest = os.path.join('%{nodejs_sitelib}', moddir, 'node_modules/inherits')
if not os.path.realpath(dest) == src:
try:
os.unlink(dest)
except OSError:
pass
try:
os.symlink(src, dest)
except OSError, e:
sys.stderr.write(e + '\n')
EOF
%pretrans -p <lua>
if posix.stat("%{nodejs_sitelib}/inherits", "type") == "directory" then
os.rename('%{nodejs_sitelib}/inherits', '%{nodejs_sitelib}/inherits@2')
end
%files
%doc README.md
%license LICENSE
%{nodejs_sitelib}/inherits@2
%{nodejs_sitelib}/inherits
%changelog
* Thu Aug 20 2020 wangxiao <wangxiao65@huawei.com> - 2.0.3-1
- Package init