- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我已经按照this准备了一个构建框说明,我四处搜索并做了一个 hello world rpm 构建,但仍然不确定打包一堆 js 文件(nodejs 应用程序)的最佳方法是什么。我愿意:
我已经完成了一个非常简单的规范文件,如下所示:
Name: nodejsapp
Version: 1.0
Release: 0
Summary: API for a Platform
Group: Group
License: License
URL: somewebsite
Distribution: Linux CentOS
Source0: %{name}-%{version}.tar.gz
%description
CDR Platform is awesome product.
%prep
%install
install -m 755 -d $RPM_BUILD_ROOT/opt/cdr/api
%clean
rm -rf $RPM_BUILD_ROOT
%files
%defattr(-,root,root,-)
上面的构建但是当我安装时没有任何反应!我不确定我是否完全理解 rpmbuild 如何开展业务。
那么在这种情况下我需要使用哪个宏?我需要在 %files 下创建文件列表吗?在运行 rpmbuild 之前我需要 gzip 文件吗?或者我可以在 rpmbuild 期间对它们进行 gzip 压缩吗?
感谢任何帮助。
最佳答案
可以找到为 Fedora EPEL 存储库打包 nodejs 应用程序的指南 here .在打包您自己的 nodejs 应用程序时,它们是很好的引用。
您没有提及您使用的是什么版本或哪个发行版,但我假设它是最近的发行版,因此您要启动的服务将在 systemd 下运行。可以找到 Fedora systemd 打包指南 here .
我还假设您正在使用 github 来管理代码,并且它是一个纯 JS 应用程序。
对于没有依赖关系或仅依赖于已打包在 EPEL 中的 nodejs 模块的 nodejs 模块/应用程序,以下 SPEC 文件(保存为 SPECS/nodejs-myapp.spec)将起作用。
%define debug_package %{nil}
#
# automatically generate requires and provides from package.json
#
%{?nodejs_find_provides_and_requires}
#
# filter out any false provides created due to dependencies with native components
#
%{?nodejs_default_filter}
#
# name of zip file containing source without .zip extension
#
%define modname myapp
Summary: A nodejs app with a systemd daemon
Name: nodejs-%{modname}
Group: Applications/Tools
Version: 0.1
Release: 1
License: Unlicense
URL: https://github.com/myuser/myapp
Source0: %{modname}-%{version}.zip
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildArch: noarch
ExclusiveArch: %{nodejs_arches} noarch
BuildRequires: nodejs-packaging
BuildRequires: systemd
%description
A nodejs app that installs as a systemd service
%prep
%setup -q -n %{modname}-%{version}
%build
%{__rm} -f .gitignore
#
# Fedora guidlines do not allow bundled modules
# use nodejs_symlink_deps in the install section to generate
# links based on package.json contents
#
%{__rm} -rf node_modules
%install
rm -rf $RPM_BUILD_ROOT
#
# copy in the module source
#
%{__install} -d $RPM_BUILD_ROOT%{nodejs_sitelib}
%{__cp} -r $RPM_BUILD_DIR/%{modname}-%{version} $RPM_BUILD_ROOT%{nodejs_sitelib}/%{modname}
#
# link the daemon binaries into sbindir
#
%{__install} -d $RPM_BUILD_ROOT%{_sbindir}
%{__ln_s} %{nodejs_sitelib}/%{modname}/bin/myappd $RPM_BUILD_ROOT%{_sbindir}/myappd
#
# link in any dependent nodejs modules referenced in package.json
#
%nodejs_symlink_deps
#
# documents will be handled by %doc, so remove them from buildroot
#
%{__rm} -rf $RPM_BUILD_ROOT%{nodejs_sitelib}/%{modname}{CHANGELOG.md,LICENSE.md,README.md,docs}
#
# Create a systemd unit file
#
cat << __EOF > $RPM_BUILD_ROOT%{_unitdir}/myappd.service
[Unit]
Description=MyApp provides the best API
Documentation=man:myapp.service(8)
[Service]
Type=simple
ExecStart=/usr/sbin/myappd
[Install]
WantedBy=multi-user.target
__EOF
%clean
rm -rf $RPM_BUILD_ROOT
%files
%defattr(-,root,root)
%doc CHANGELOG.md LICENSE.md README.md docs
%{nodejs_sitelib}/%{modname}
%{_sbindir}/myappd
%{_unitdir}/myappd.service
%changelog
* Sun Mar 22 2015 BitByteDog
- Initial spec file for myapp
此规范文件还将处理具有已打包为 EPEL 一部分的依赖项的 nodejs 模块。 RPM 的自动要求/提供功能使用模块中的 package.json 文件在最终的 RPM 包中创建必要的要求依赖项。
应使用以下命令将源 zip 从 github 下载到 SOURCES 目录:
wget -O SOURCES/myapp-0.1.zip https://github.com/myuser/myapp/archive/v0.1.zip
RPM 使用以下命令构建:
rpmbuild -ba SPECS/nodejs-myapp.spec
创建的 systemd 单元文件非常简单,阅读提供的链接以及相关的 systemd 文档以根据您的要求进行自定义。您将需要使用以下命令启用并启动该服务:
systemctl enable myappd.service
systemctl start myappd.service
之后会自动启动。
如果您想在 JS 应用程序中包含捆绑模块,可以使用 npm 来完成。首先添加标签:
BuildRequires: npm
AutoReq: no
AutoProv: no
抑制自动要求/提供生成。然后删除行
%{__rm} -rf node_modules
来自 %build 部分。也换行
%nodejs_symlink_deps
在行的%install
#
# npm will bundle in all dependent modules from the npm registry
# (bundling is OK for private packages but not for EPEL packages)
#
npm -g -q --production --prefix="${RPM_BUILD_ROOT}%{_prefix}" install
应用中捆绑的所有模块和 package.json 中列出的所有依赖项都将捆绑到您的应用中,使其成为一个独立的应用。
上述命令中npm用法说明
作用是将本地目录下的nodejs app复制到${RPM_BUILD_ROOT}%{_prefix}准备打包。
关于linux - 需要一些帮助来为 nodejs 应用程序创建 rpm 包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28842740/
通过终端,您可以使用命令 - “SetFile -a B 文件名” 以编程方式,我认为我应该通过[[NSFileManager defaultManager] createDirectoryAtPat
嗨,正在尝试书中的一些示例:Practical Graph mining with R对于子图挖掘: library(subgraphMining) library(igraph) graph1 =
代码中的相同问题: class Foo { int getIntProperty () { ... } CustomObject getObjectProperty () { ... }
所以这可能是一个愚蠢的问题,但它已经困扰我一段时间了。 使用 React,我创建了两个组件(Buttons.js 和 Message.js),每个组件都有一个导出。但是,现在我希望将这两个组件用作 n
从今天早上开始,我发现我无法再从某个范围安装任何 NPM 包(或任何具有依赖项的包)。例如,如果我输入 npm i webpack 我会收到以下错误... npm ERR! code E401 npm
我在这里搜索过,Angular 2, @ngtools/webpack, AOT ,但对我不起作用。我运行了 npm install 命令。我正在做的是创建一个新的 Angular 2 项目。当我运行
情况: 我有一个 Swift 包,将其命名为 lib。 lib 位于其自己的存储库中。在lib的仓库中,有一堆本地包;也就是说,这些包是在 lib 中定义的,使用本地路径依赖格式 .package(p
我想在工作中学习和使用nodejs,但是在使用 de npm 命令安装模块/包时遇到网络问题。我是否可以使用我的家用计算机构建完整的 Node js 包,然后将其安装在另一台计算机(我的工作场所计算机
我需要将一些 .tar.bz2 格式的非 Python 包转换为 Anaconda/miniConda .egg 文件并安装它们。为此,我需要一个适用于 Windows 的 bld.bat 文件。互联
我需要共享库文件 libthrift-0.9.3.so 作为其他包的依赖项。我在构建 thrift-0.9.3 包时看到编译问题(我确实从 https://thrift.apache.org/down
我尝试在 R 版本 3.5.0 中安装“arcgisbinding”包。但是我失败了,得到以下错误和警告。 Installing package into ‘C:/Users/Lenovo/Docum
我尝试在 R 版本 3.5.0 中安装“arcgisbinding”包。但是我失败了,得到以下错误和警告。 Installing package into ‘C:/Users/Lenovo/Docum
我试图在 flutter 中测试这个应用程序,但我无法运行该应用程序,因为出现此错误“名称‘Page’在库‘package:burn_off/widgets/page.dart’和‘package’中
试图理解和学习如何编写包...用我一直使用的东西进行测试,记录... 您能帮我理解为什么“日志”变量不起作用...并且屏幕上没有日志记录吗? 谢谢! 主要文件: #!/opt/local/bin/py
我尝试运行此使用 Google 云的代码。 import signal import sys from google.cloud import language, exceptions # creat
我想知道是否有人找到了一个很好的 R 包来分析眼动追踪数据? 我遇到了 eyetrackR,但据我所知,没有可用的英文支持文档: http://read.psych.uni-potsdam.de/pm
我正在 R 上制作一个包。我有两个函数共享一个变量(全局)。 如何将其导入到包中? 例如, m<-0 f<-function() { m <- m+1 } g<-function() { m <- m
我用 C 为 Lua 编写了很多模块。每个模块都包含一个 Lua 用户数据类型,我像这样加载和使用它们: A = require("A") B = require("B") a = A.new(3,{
我正在尝试在 R 中的 Ubuntu 上安装 xlsx 包,以便使用允许在 R 中插入链接然后将它们导出到 Excel 的功能。 话虽如此,我根本无法安装该软件包。 显然它必须与 rJava 一起使用
我想在 Haskell 中做一些蒙特卡洛分析。我希望能够编写这样的代码: do n <- poisson lambda xs <- replicateM n $ normal mu sigma
我是一名优秀的程序员,十分优秀!