How to manage multiple package dependencies with checkinstall? - bash

I have a package that I've been building using checkinstall for a while now, and I wanted to automate it (pass the values in via command line instead of typing the selection, pasting the value in, etc...)
I am not sure if this is a checkinstall bug, or not, but how can I include multiple packages via the command line --requires option. It seems to barf if I include the minimum version of a package (for exmple --requires="libvte9 (>= 0.28.2)"), or multiple packages at once (for example --requires "libvte9, libc6")
Has anyone had better success with the command line arguments for multiple packages? Am I doing something wrong, or is this a bug.
Note: If I run the script, and choose the requires option (10), and paste my entire line with multiple packages and minimum versions (such as libvte9 (>= 0.28.2), libc6 (>= 2.13), it works fine, it just seems to be on the command line that it's having issues. Also this is with building a debian package, using the -D option.

After reading Aleks-Daniel Jakimenko-A.'s answer, Reallumpi's one and doing some tests on a real life case, here is what you should do:
use , (comma) without spaces to separate required packages ;
escape ( and ) parenthesis when specifying package's version ;
escape > (greater sign) when specifying package's version ;
Example
make && sudo -k checkinstall \
--pkgsource="https://github.com/raboof/nethogs/" \
--pkglicense="GPL2" \
--deldesc=no \
--nodoc \
--maintainer="$USER\\<$USER#$HOSTNAME\\>" \
--pkgarch=$(dpkg \
--print-architecture) \
--pkgversion="0.8.1" \
--pkgrelease="SNAPSHOT" \
--pkgname=nethogs \
--requires="libc6 \(\>= 2.4\),libgcc1 \(\>= 1:4.1.1\),libncurses5 \(\>= 5.5-5~\),libpcap0.8 \(\>= 0.9.8\),libstdc++6 \(\>= 4.1.1\),libtinfo5" \
make install
Output
*****************************************
**** Debian package creation selected ***
*****************************************
This package will be built according to these values:
0 - Maintainer: [ elopez<elopez#> ]
1 - Summary: [ Net top tool grouping bandwidth per process ]
2 - Name: [ nethogs ]
3 - Version: [ 0.8.1 ]
4 - Release: [ SNAPSHOT ]
5 - License: [ GPL2 ]
6 - Group: [ checkinstall ]
7 - Architecture: [ amd64 ]
8 - Source location: [ https://github.com/raboof/nethogs/ ]
9 - Alternate source location: [ ]
10 - Requires: [ libc6 (>= 2.4),libgcc1 (>= 1:4.1.1),libncurses5 (>= 5.5-5~),libpcap0.8 (>= 0.9.8),libstdc++6 (>= 4.1.1),libtinfo5 ]
11 - Provides: [ nethogs ]
12 - Conflicts: [ ]
13 - Replaces: [ ]

checkinstall uses , to separate multiple packages. That's it, a comma, without any spaces around it.

You need to escape brackets, e.g. --requires "package \(= 1.0\)"

This answer elaborates on how to properly format punctuation, within a shell script, to get multiple package dependencies for checkinstall to work.
PAK_USER='. , ? ! : + - ^ _ { } = $ % # [ ] / ; # & * ~ ( ) < > \ |'
PAK_NEEDS='. , ? ! : + - ^ _ { } = $ % # [ ] / ; # & * ~ ( ) < > \ |'
PAK_NEEDS=$(echo "$PAK_NEEDS" | perl -pe 's/([[:punct:]])/\\\1/g')
0 - Maintainer: [ . , ? ! : + - ^ _ { } = $ % # [ ] / ]
1 - Summary: [ This is a punctuation escape test. ]
10 - Requires: [ . , ? ! : + - ^ _ { } = $ % # [ ] / ; # & * ~ ( ) < > \ | ]
The ones that needs escaping appear to be shell operators ; # & * ~ ( ) < > \ | Some will return a value * ~ terminate the line ; # or wipe everything out ( ) < > | & while \ disappears since it's the escape character.
The regex perl -pe 's/([[:punct:]])/\\\1/g' escapes all the punctuation characters which is overkill but works quite well. Single and Double Quotes are already problematic, along with $, which will expand unless surrounded by single-quotes.
If you don't want to think about escaping, use the regex and caution with ' " $.
PAK_NEEDS="libasound2 (>= 1.0.16), libavcodec57 (>= 7:3.4.2) | libavcodec-extra57 (>= 7:3.4.2), libavformat57 (>= 7:3.4.2), libavutil55 (>= 7:3.4.2), libboost-filesystem1.65.1, libboost-system1.65.1, libc6 (>= 2.27), libcurl4 (>= 7.16.2), libexpat1 (>= 2.0.1), libgcc1 (>= 1:3.0), libgl1, libglu1-mesa | libglu1, libmad0 (>= 0.15.1b-3), libsdl2-2.0-0 (>= 2.0.8), libsdl2-image-2.0-0 (>= 2.0.2), libsdl2-net-2.0-0 (>= 2.0.1), libsdl2-ttf-2.0-0 (>= 2.0.14), libsndfile1 (>= 1.0.20), libspeex1 (>= 1.2~beta3-1), libspeexdsp1 (>= 1.2~beta3.2-1), libstdc++6 (>= 5.2), libswscale4 (>= 7:3.4.2), libvorbisfile3 (>= 1.1.2), libzzip-0-13 (>= 0.13.56), zlib1g (>= 1:1.1.4)"
PAK_NEEDS=$(echo "$PAK_NEEDS" | perl -pe 's/([[:punct:]])/\\\1/g')
10 - Requires: [ libasound2 (>= 1.0.16), libavcodec57 (>= 7:3.4.2) | libavcodec-extra57 (>= 7:3.4.2), libavformat57 (>= 7:3.4.2), libavutil55 (>= 7:3.4.2), libboost-filesystem1.65.1, libboost-system1.65.1, libc6 (>= 2.27), libcurl4 (>= 7.16.2), libexpat1 (>= 2.0.1), libgcc1 (>= 1:3.0), libgl1, libglu1-mesa | libglu1, libmad0 (>= 0.15.1b-3), libsdl2-2.0-0 (>= 2.0.8), libsdl2-image-2.0-0 (>= 2.0.2), libsdl2-net-2.0-0 (>= 2.0.1), libsdl2-ttf-2.0-0 (>= 2.0.14), libsndfile1 (>= 1.0.20), libspeex1 (>= 1.2~beta3-1), libspeexdsp1 (>= 1.2~beta3.2-1), libstdc++6 (>= 5.2), libswscale4 (>= 7:3.4.2), libvorbisfile3 (>= 1.1.2), libzzip-0-13 (>= 0.13.56), zlib1g (>= 1:1.1.4) ]

Related

Indirect reference to hashmap in bash

I am writing a script to install packages from .deb files, but first, I would like to check if each package is already installed. I have a config file that contains the information for the packages as hashmaps, like this:
declare -A package_a=(
[name]="utility-blah"
[ver]="1.2"
[arch]="amd64"
)
declare -A package_b=(
[name]="tool-bleh"
[ver]="3.4"
[arch]="all"
)
#and so on and so forth
My install script sources the config file, and I would like it to iterate over the packages, checking if they are installed, and installing them if they are not, like this:
source packages.config
declare -a packageList=("package_a" "package_b" "package_d")
for package in ${packageList[#]}; do
# Check if the specific version is installed already
if apt show ${package[name]}=${package[ver]}; then
echo ${package[name]} ${package[ver]} is already installed.
else
echo Installing ${package[name]}
sudo apt install path/to/files/${package[name]}_${package[ver]}_${package[arch]}.deb
fi
done
How can I have package point to the hashmap containing the information about the package and use it in the following commands?
I'm using Bash 4.4.20 on Ubuntu 18.04
One idea using a nameref:
source packages.config
declare -a packageList=("package_a" "package_b" "package_d")
for pkg in "${packageList[#]}"; do # change variable name
declare -n package="${pkg}" # declare nameref; rest of code remains the same ...
# Check if the specific version is installed already
if apt show ${package[name]}=${package[ver]}; then
echo ${package[name]} ${package[ver]} is already installed.
else
echo Installing ${package[name]}
sudo apt install path/to/files/${package[name]}_${package[ver]}_${package[arch]}.deb
fi
done
Or (as M. Nejat Aydin and Benjamin W. have pointed out) the declare -n can go before the while loop, eg:
declare -n package
for package in "${packageList[#]}"; do
# Check if the specific version is installed already
if apt show ${package[name]}=${package[ver]}; then
echo ${package[name]} ${package[ver]} is already installed.
else
echo Installing ${package[name]}
sudo apt install path/to/files/${package[name]}_${package[ver]}_${package[arch]}.deb
fi
done
Simple test:
declare -n package
for package in ${packageList[#]}; do
echo "${!package} : ${package[name]}"
done
This generates:
package_a : utility-blah
package_b : tool-bleh
package_d :
This kind of input data is better suited for JSON rather than using bash associative arrays and indirection.
Lets say you have a packages.json:
{
"packages": [
{
"package": "package_a",
"name": "utility-blah",
"ver": "1.2",
"arch": "amd64"
},
{
"package": "package_b",
"name": "utility-bleh",
"ver": "3.4",
"arch": "all"
},
{
"package": "apache2",
"name": "Apache2 http server",
"ver": "2.4.52-1ubuntu4.1",
"arch": "all"
}
]
}
Such simple POSIX-shell script is able to process it as you need:
#! /bin/sh
# Fields are tab-delimited, records end with newline
IFS=$(printf '\t')
# Parses json input into record lines
jq -r '.packages[]|(.package + "\t" + .name + "\t" + .ver)' packages.json |
# Iterates records, reading fields
while read -r package name ver; do
{
# Query package for installed status and version
# formatted into two fields
dpkg-query -W --showformat='${db:Status-Abbrev}\t${Version}' "${package}" || :
} 2>/dev/null | {
# Reads status and installed version
read -r status installed_ver _
# If status is installed 'ii ' and installed version matches'
if [ "${status}x" = 'ii x' ] && [ "${ver}x" = "${installed_ver}x" ]; then
printf '%s %s is already installed.\n' "${name}" "${ver}"
else
printf 'Installing %s.\n' "${name}"
fi
}
done
Example output:
nstalling utility-blah.
nstalling utility-bleh.
Apache2 http server 2.4.52-1ubuntu4.1 is already installed.

Logstash 8.0.0 triggers "insecure dependency" alerts, how do you fix it?

We're trying to build a Docker container that contains Logstash-8.0.0 (the latest version, came out yesterday), such that it can be scanned with Trivy and not have any "HIGH" or "CRITICAL" severity alerts.
It's proving very hard to do, as we're not proficient with Java, Ruby, or JRuby.
If we have a Dockerfile that has the Elastic repository in it:
$ cat /etc/apt/sources.list.d/elastic-8.x.list
deb https://artifacts.elastic.co/packages/8.x/apt stable main
And we install logstash:
$ sudo apt-get update
$ sudo apt-get install logstash
Then install and run trivy:
$ curl -sfL https://raw.githubusercontent.com/aquasecurity/trivy/main/contrib/install.sh | sh -s -- -b .
$ sudo trivy fs -s HIGH,CRITICAL /
We get one critical and two high severity alerts, concerning ruby gems listed in /usr/share/logstash/Gemfile.lock:
usr/share/logstash/Gemfile.lock (bundler)
=========================================
Total: 3 (HIGH: 2, CRITICAL: 1)
+----------+------------------+----------+-------------------+---------------+---------------------------------------+
| LIBRARY | VULNERABILITY ID | SEVERITY | INSTALLED VERSION | FIXED VERSION | TITLE |
+----------+------------------+----------+-------------------+---------------+---------------------------------------+
| json | CVE-2020-10663 | HIGH | 1.8.6-java | >= 2.3.0 | rubygem-json: Unsafe object |
| | | | | | creation vulnerability in JSON |
| | | | | | -->avd.aquasec.com/nvd/cve-2020-10663 |
+----------+------------------+----------+-------------------+ +---------------------------------------+
| kramdown | CVE-2020-14001 | CRITICAL | 1.14.0 | | rubygem-kramdown: processing template |
| | | | | | options inside documents allows |
| | | | | | unintended read access or embedded... |
| | | | | | -->avd.aquasec.com/nvd/cve-2020-14001 |
+----------+------------------+----------+-------------------+---------------+---------------------------------------+
| nokogiri | CVE-2021-41098 | HIGH | 1.12.5-java | >= 1.12.5 | rubygem-nokogiri: XEE on JRuby |
| | | | | | -->avd.aquasec.com/nvd/cve-2021-41098 |
+----------+------------------+----------+-------------------+---------------+---------------------------------------+
By changing the path to include the appropriate(?) directories, we can run ruby, jruby, gem and bundle:
$ export PATH=/usr/share/logstash/bin:/usr/share/logstash/vendor/jruby/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:.
But we're a bit at a loss as to what to try next. So far, it looks like editing /usr/share/logstash/Gemfile to have the right versions of json and nokogiri and commenting out the gems that are marked :development and then run bundle install; bundle update is the way to go:
diff --git a/Gemfile b/Gemfile
index 6e90ef4..1054cb3 100644
--- a/Gemfile
+++ b/Gemfile
## -6,7 +6,8 ## gem "logstash-core", :path => "./logstash-core"
gem "logstash-core-plugin-api", :path => "./logstash-core-plugin-api"
gem "atomic", "~> 1"
gem "builder", "~> 3"
-gem "json", "~> 1"
+gem "json", "~> 2.3.0"
+gem "nokogiri", "1.12.5"
gem "paquet", "~> 0.2"
gem "pleaserun", "~>0.0.28"
gem "rake", "~> 12"
## -18,15 +19,6 ## gem "gems", "~> 1", :group => :build
gem "octokit", "~> 4", :group => :build
gem "rubyzip", "~> 1", :group => :build
gem "stud", "~> 0.0.22", :group => :build
-# gem "belzebuth", :group => :development
-# gem "benchmark-ips", :group => :development
-# # # gem "ci_reporter_rspec", "~> 1", :group => :development
-# gem "flores", "~> 0.0.6", :group => :development
-# gem "json-schema", "~> 2", :group => :development
-# gem "logstash-devutils", "~> 1", :group => :development
-# gem "rack-test", :require => "rack/test", :group => :development
-# gem "rspec", "~> 3.5", :group => :development
-# gem "webmock", "~> 3", :group => :development
gem "logstash-codec-avro"
gem "logstash-codec-cef"
gem "logstash-codec-collectd"
But it seems that the Gemfile.lock file was created by bundler 2.3.6, which is not installed. When we installed bundler 2.3.6, it complained about an unexpected error with openssl. So, upgraded to bundler 2.3.7 (also released yesterday!), and it succeeded with bundle install. But now logstash won't run:
[FATAL] 2022-02-10 18:12:40.504 [main] Logstash - Logstash stopped
processing because of an error: (GemNotFound) Could not find
logstash-filter-elasticsearch-3.11.1,
logstash-filter-http-1.3.0,
logstash-filter-kv-4.6.0,
logstash-input-beats-6.2.6-java,
logstash-input-dead_letter_queue-1.1.10,
logstash-input-http_poller-5.2.0,
logstash-input-sqs-3.2.0,
logstash-input-tcp-6.2.7-java,
logstash-integration-elastic_enterprise_search-2.2.1,
logstash-integration-
kafka-10.10.0-java,
logstash-output-http-5.4.0,
logstash-output-tcp-6.0.1,
puma-5.6.1-java,
jruby-openssl-0.12.1-java,
i18n-1.9.1,
elasticsearch-7.17.0,
logstash-mixin-http_client-7.1.0,
json-2.6.1-java,
redis-4.6.0,
logstash-mixin-aws-5.0.0,
elastic-enterprise-search-7.16.0,
sequel-5.53.0,
elasticsearch-api-7.17.0,
elasticsearch-transport-7.17.0
in any of the sources
Edit: Figured it out!
This makes logstash find the updated ruby gems:
# cd /usr/share/logstash/vendor/jruby/lib/ruby/gems/shared
# tar c . | ( cd /usr/share/logstash/vendor/bundle/jruby/2.5.0; tar x )
This makes trivy stop complaining about snakeyaml-1.23 while letting logstash keep working:
# rm /usr/share/logstash/logstash-core/lib/jars/snakeyaml-1.23.jar
# cp /usr/share/logstash/vendor/jruby/lib/ruby/stdlib/org/yaml/snakeyaml/1.26/snakeyaml-1.26.jar /usr/share/logstash/logstash-core/lib/jars
This cleans up the other trivy jar alerts:
# rm -rf ~/.m2 # Delete maven cache
Cheers!
It was long and involved, but updating to logstash-8.0.0 allowed bundler-2.3.7 to work, and then copying the gems from one directory to another let logstash actually find the gems.
Details added to question.
Cheers!

install ipadic on Ubuntu 16.04 for mecab Japanese tokenizer

I am trying to install mecab and the ipadic dictionary as outlined here: http://taku910.github.io/mecab/#install-unix
I was able to successfully download mecab and install it and succesfully downloaded ipadic but get stuck on the second line of instruction below:
% tar zxfv mecab-ipadic-2.7.0-XXXX.tar.gz
% mecab-ipadic-2.7.0-XXXX
% ./configure
% make
% su
# make install
I am getting:
mecab-ipadic-2.7.0-20070801: command not found
I tried chmod -x on it and then tried it but same result.
Any help is appreciated.
Edit (result of cat /etc/mecabrc)
;
; Configuration file of MeCab
;
; $Id: mecabrc.in,v 1.3 2006/05/29 15:36:08 taku-ku Exp $;
;
dicdir = /usr/local/lib/mecab/dic/mecab-ipadic-neologd
; userdic = /home/foo/bar/user.dic
; output-format-type = wakati
; input-buffer-size = 8192
; node-format = %m\n
; bos-format = %S\n
; eos-format = EOS\n
There is no reason to compile from source on Ubuntu 16.04
Simple do:
$ sudo apt-get update
$ sudo apt install mecab mecab-ipadic-utf8
Then test it with
$ echo "日本語です" | mecab
日本 ニッポン ニッポン 日本 名詞-固有名詞-地名-国
語 ゴ ゴ 語 名詞-普通名詞-一般
です デス デス です 助動詞 助動詞-デス 終止形-一般
EOS
If things don't work, you may need to link /etc/mecabrc to the installed dictionary by setting dicdir=SOMEPATH_TO_IPADIC

bash script , how to server architecture from ansible setup

I have a bash script to build a rub .deb package in which I would like to use the server architecture ...
I installed ansible and run ansible localhost -m setup , which gives me the ansible facts ...
> ansible localhost -m setup
localhost | success >> {
"ansible_facts": {
"ansible_all_ipv4_addresses": [
"10.10.5.200"
],
"ansible_all_ipv6_addresses": [
"fe80::4c2:ccff:fe82:8d8c"
],
"ansible_architecture": "x86_64",
"ansible_bios_date": "06/02/2014",
..
I would like to use detected architecture "ansible_architecture": "x86_64" in my shell script within my fpm command :
currently :
fpm -s dir -t deb -n ruby$version -v $rubyversion -C $destdir \
-p ruby-VERSION_ARCH~trusty.deb -d "libstdc++6 (>= 4.4.3)" \
-d "libc6 (>= 2.6)" -d "libffi6 (>= 3.0.10)" -d "libgdbm3 (>= 1.8.3)" \
-d "libncurses5 (>= 5.7)" -d "libreadline6 (>= 6.1)" \
-d "libssl1.0.0 (>= 1.0.1)" -d "zlib1g (>= 1:1.2.2)" \
-d "libyaml-0-2 (>= 0.1.4-2)" \
usr/local/bin usr/local/lib usr/local/share/man usr/local/include
# VERSION_ARCH is giving me 'amd64' and I would like to use
# ansible_architecture ( which is detecting "x86_64"....
I may not have to use ansible facts to detect it ...
# I tried to write at the beginning of my script
$architecture=uname -m
# but it does gives me "x86_64" as a variable...
thanks for your suggestions
got it :
inserting
architecture="$(uname -m)"
echo "architecture: $architecture"
at the beginning of my script and using $architecture as a parameter

gem2rpm tool works but I can't find rpm package

I have been trying to convert a gem (chef) into rpm package using gem2rpm. Now, I 'fetched' the gem, made a 'spec' file and the used 'rpmbuild'. I get the following error:
error: Installed (but unpackaged) file(s) found:
/usr/share/gems/gems/chef-11.8.2/Rakefile
/usr/share/gems/gems/chef-11.8.2/bin/chef-apply
/usr/share/gems/gems/chef-11.8.2/bin/chef-client
/usr/share/gems/gems/chef-11.8.2/bin/chef-service-manager
/usr/share/gems/gems/chef-11.8.2/bin/chef-shell
/usr/share/gems/gems/chef-11.8.2/bin/chef-solo
/usr/share/gems/gems/chef-11.8.2/bin/knife
/usr/share/gems/gems/chef-11.8.2/bin/shef
/usr/share/gems/gems/chef-11.8.2/distro/README
/usr/share/gems/gems/chef-11.8.2/distro/arch/etc/conf.d/chef-client.conf
/usr/share/gems/gems/chef-11.8.2/distro/arch/etc/conf.d/chef-expander.conf
/usr/share/gems/gems/chef-11.8.2/distro/arch/etc/conf.d/chef-server-webui.conf
/usr/share/gems/gems/chef-11.8.2/distro/arch/etc/conf.d/chef-server.conf
/usr/share/gems/gems/chef-11.8.2/distro/arch/etc/conf.d/chef-solr.conf
/usr/share/gems/gems/chef-11.8.2/distro/arch/etc/rc.d/chef-client
/usr/share/gems/gems/chef-11.8.2/distro/arch/etc/rc.d/chef-expander
/usr/share/gems/gems/chef-11.8.2/distro/arch/etc/rc.d/chef-server
/usr/share/gems/gems/chef-11.8.2/distro/arch/etc/rc.d/chef-server-webui
/usr/share/gems/gems/chef-11.8.2/distro/arch/etc/rc.d/chef-solr
/usr/share/gems/gems/chef-11.8.2/distro/common/html/chef-client.8.html
/usr/share/gems/gems/chef-11.8.2/distro/common/html/chef-expander.8.html
/usr/share/gems/gems/chef-11.8.2/distro/common/html/chef-expanderctl.8.html
/usr/share/gems/gems/chef-11.8.2/distro/common/html/chef-server-webui.8.html
/usr/share/gems/gems/chef-11.8.2/distro/common/html/chef-server.8.html
Here is my gem spec file:
# Generated from chef-11.8.2.gem by gem2rpm -*- rpm-spec -*-
%global gem_name chef
%global rubyabi 1.9.1
Name: rubygem-%{gem_name}
Version: 11.8.2
Release: 1%{?dist}
Summary: A systems integration framework, built to bring the benefits of configuration management to your entire infrastructure
Group: Development/Languages
License: GPL
URL: http://wiki.opscode.com/display/chef
Source0: http://rubygems.org/gems/%{gem_name}-%{version}.gem
Requires: ruby(abi) = %{rubyabi}
Requires: ruby(rubygems)
Requires: rubygem(mixlib-config) => 2.0
Requires: rubygem(mixlib-config) < 3
Requires: rubygem(mixlib-cli) => 1.3
Requires: rubygem(mixlib-cli) < 2
Requires: rubygem(mixlib-log) => 1.3
Requires: rubygem(mixlib-log) < 2
Requires: rubygem(mixlib-authentication) => 1.3
Requires: rubygem(mixlib-authentication) < 2
Requires: rubygem(mixlib-shellout) => 1.2
Requires: rubygem(mixlib-shellout) < 2
Requires: rubygem(ohai) => 6.0
Requires: rubygem(ohai) < 7
Requires: rubygem(rest-client) >= 1.0.4
Requires: rubygem(rest-client) < 1.7.0
Requires: rubygem(mime-types) => 1.16
Requires: rubygem(mime-types) < 2
Requires: rubygem(json) >= 1.4.4
Requires: rubygem(json) <= 1.7.7
Requires: rubygem(yajl-ruby) => 1.1
Requires: rubygem(yajl-ruby) < 2
Requires: rubygem(net-ssh) => 2.6
Requires: rubygem(net-ssh) < 3
Requires: rubygem(net-ssh-multi) => 1.1.0
Requires: rubygem(net-ssh-multi) < 1.2
Requires: rubygem(highline) => 1.6
Requires: rubygem(highline) < 2
Requires: rubygem(highline) >= 1.6.9
Requires: rubygem(erubis) => 2.7
Requires: rubygem(erubis) < 3
Requires: rubygem(diff-lcs) => 1.2
Requires: rubygem(diff-lcs) < 2
Requires: rubygem(diff-lcs) >= 1.2.4
Requires: rubygem(chef-zero) => 1.6
Requires: rubygem(chef-zero) < 2
Requires: rubygem(chef-zero) >= 1.6.2
Requires: rubygem(puma) => 1.6
Requires: rubygem(puma) < 2
Requires: rubygem(pry) => 0.9
Requires: rubygem(pry) < 1
BuildRequires: ruby(abi) = %{rubyabi}
BuildRequires: rubygems-devel
BuildRequires: ruby
BuildArch: noarch
Provides: rubygem(%{gem_name}) = %{version}
%description
A systems integration framework, built to bring the benefits of configuration
management to your entire infrastructure.
%package doc
Summary: Documentation for %{name}
Group: Documentation
Requires: %{name} = %{version}-%{release}
BuildArch: noarch
%description doc
Documentation for %{name}
%prep
gem unpack %{SOURCE0}
%setup -q -D -T -n %{gem_name}-%{version}
gem spec %{SOURCE0} -l --ruby > %{gem_name}.gemspec
%build
mkdir -p .%{gem_dir}
# Create the gem as gem install only works on a gem file
gem build %{gem_name}.gemspec
# gem install installs into a directory. We set that to be a local
# directory so that we can move it into the buildroot in %%install
gem install --local --install-dir ./%{gem_dir} \
--bindir ./%{_bindir} \
--force --rdoc %{gem_name}-%{version}.gem
%install
mkdir -p %{buildroot}%{gem_dir}
cp -pa .%{gem_dir}/* \
%{buildroot}%{gem_dir}/
mkdir -p %{buildroot}%{_bindir}
cp -pa .%{_bindir}/* \
%{buildroot}%{_bindir}/
find %{buildroot}%{gem_instdir}/bin -type f | xargs chmod a+x
%files
%{gem_instdir}
%{_bindir}/chef-client
%{_bindir}/chef-solo
%{_bindir}/knife
%{_bindir}/chef-shell
%{_bindir}/shef
%{_bindir}/chef-apply
%{_bindir}/chef-service-manager
%{gem_instdir}/bin
%{gem_libdir}
%exclude %{gem_cache}
%{gem_spec}
%files doc
%doc %{gem_docdir}
%doc %{gem_instdir}/README.md
%doc %{gem_instdir}/CONTRIBUTING.md
%doc %{gem_instdir}/LICENSE
%changelog
* Fri Jan 10 2014 Peeyush <peeyush#localhost.localdomain> - 11.8.2-1
- Initial package
I understand that I need to change something in the %files% section. But I can't figure out what! Any pointers will be appreciated.
Ok, never mind! I just needed to %exclude %{gem_instdir}.

Resources