Sam Hammamy
Sam Hammamy

Reputation: 11017

Missing command on Building a Node.js App's RPM

In the install directive of the .spec file, I have some commands that are only applicable to the machine on which the rpm will be installed. Mainly:

%install
pm2 stop www # problem here
rm -rf $RPM_BUILD_ROOT
cp -r * $RPM_BUILD_ROOT/
rm -rf /home/ec2-user/APP-NAME
mkdir -p /home/ec2-user/APP-NAME
cp -r * /home/ec2-user/APP-NAME/*
pm2 start /home/ec2-user/APP-NAME/bin/www

While running rpmbuild I get an error saying pm2 is not found. Since the RPM is built on a jenkins box, of course it is not found. I have a separate box on which the RPM will be installed, and it of course has pm2 installed.

My understanding is that the box on which the rpm is built doesn't have to have the libraries or binaries used in the install directive. Is that correct?

Also can anyone think of a better way to write the install directive's shell script? This is my fire node.js deployment

Upvotes: 0

Views: 150

Answers (1)

Aaron D. Marasco
Aaron D. Marasco

Reputation: 6758

%install is for installing the built files into the temporary location where RPM will bundle them up.

%post is to run commands on the target machine after installation.

It looks like you're trying to stop a service. You would do that in %pre.

Upvotes: 1

Related Questions