Skip to content

Commit 0082a71

Browse files
committed
moving procps-ng amd proj from Base-plan to Core-plan
Signed-off-by: Sangameshwar Mandakanalli <[email protected]>
1 parent 13821f9 commit 0082a71

12 files changed

+582
-0
lines changed

procps-ng/README.md

+112
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
[![Build Status](https://dev.azure.com/chefcorp-partnerengineering/Chef%20Base%20Plans/_apis/build/status/chef-base-plans.procps-ng?branchName=master)](https://dev.azure.com/chefcorp-partnerengineering/Chef%20Base%20Plans/_build/latest?definitionId=132&branchName=master)
2+
3+
# procps-ng
4+
5+
procps is the package that has a bunch of small useful utilities that give information about processes using the /proc filesystem. The package includes the programs ps, top, vmstat, w, kill, free, slabtop, and skill. See [documentation](https://gitlab.com/procps-ng/procps)
6+
7+
## Maintainers
8+
9+
* The Core Planners: <[email protected]>
10+
11+
## Type of Package
12+
13+
Binary package
14+
15+
### Use as Dependency
16+
17+
Binary packages can be set as runtime or build time dependencies. See [Defining your dependencies](https://www.habitat.sh/docs/developing-packages/developing-packages/#sts=Define%20Your%20Dependencies) for more information.
18+
19+
To add core/procps-ng as a dependency, you can add one of the following to your plan file.
20+
21+
##### Buildtime Dependency
22+
23+
> pkg_build_deps=(core/procps-ng)
24+
25+
##### Runtime dependency
26+
27+
> pkg_deps=(core/procps-ng)
28+
29+
### Use as Tool
30+
31+
#### Installation
32+
33+
To install this plan, you should run the following commands to first install, and then link the binaries this plan creates.
34+
35+
``hab pkg install core/procps-ng --binlink``
36+
37+
will add the following binaries to the PATH:
38+
39+
* /bin/free
40+
* /bin/pgrep
41+
* /bin/pidof
42+
* /bin/pkill
43+
* /bin/pmap
44+
* /bin/ps
45+
* /bin/pwdx
46+
* /bin/slabtop
47+
* /bin/sysctl
48+
* /bin/tload
49+
* /bin/top
50+
* /bin/uptime
51+
* /bin/vmstat
52+
* /bin/w
53+
* /bin/watch
54+
55+
For example:
56+
57+
```bash
58+
$ hab pkg install core/procps-ng --binlink
59+
» Installing core/procps-ng
60+
☁ Determining latest version of core/procps-ng in the 'stable' channel
61+
→ Found newer installed version (core/procps-ng/3.3.15/20200702121715) than remote version (core/procps-ng/3.3.15/20200305231457)
62+
→ Using core/procps-ng/3.3.15/20200702121715
63+
★ Install of core/procps-ng/3.3.15/20200702121715 complete with 0 new packages installed.
64+
» Binlinking pwdx from core/procps-ng/3.3.15/20200702121715 into /bin
65+
★ Binlinked pwdx from core/procps-ng/3.3.15/20200702121715 to /bin/pwdx
66+
» Binlinking watch from core/procps-ng/3.3.15/20200702121715 into /bin
67+
★ Binlinked watch from core/procps-ng/3.3.15/20200702121715 to /bin/watch
68+
» Binlinking free from core/procps-ng/3.3.15/20200702121715 into /bin
69+
★ Binlinked free from core/procps-ng/3.3.15/20200702121715 to /bin/free
70+
» Binlinking uptime from core/procps-ng/3.3.15/20200702121715 into /bin
71+
★ Binlinked uptime from core/procps-ng/3.3.15/20200702121715 to /bin/uptime
72+
» Binlinking pkill from core/procps-ng/3.3.15/20200702121715 into /bin
73+
★ Binlinked pkill from core/procps-ng/3.3.15/20200702121715 to /bin/pkill
74+
» Binlinking tload from core/procps-ng/3.3.15/20200702121715 into /bin
75+
★ Binlinked tload from core/procps-ng/3.3.15/20200702121715 to /bin/tload
76+
» Binlinking vmstat from core/procps-ng/3.3.15/20200702121715 into /bin
77+
★ Binlinked vmstat from core/procps-ng/3.3.15/20200702121715 to /bin/vmstat
78+
» Binlinking ps from core/procps-ng/3.3.15/20200702121715 into /bin
79+
★ Binlinked ps from core/procps-ng/3.3.15/20200702121715 to /bin/ps
80+
» Binlinking top from core/procps-ng/3.3.15/20200702121715 into /bin
81+
★ Binlinked top from core/procps-ng/3.3.15/20200702121715 to /bin/top
82+
» Binlinking sysctl from core/procps-ng/3.3.15/20200702121715 into /bin
83+
★ Binlinked sysctl from core/procps-ng/3.3.15/20200702121715 to /bin/sysctl
84+
» Binlinking pgrep from core/procps-ng/3.3.15/20200702121715 into /bin
85+
★ Binlinked pgrep from core/procps-ng/3.3.15/20200702121715 to /bin/pgrep
86+
» Binlinking pmap from core/procps-ng/3.3.15/20200702121715 into /bin
87+
★ Binlinked pmap from core/procps-ng/3.3.15/20200702121715 to /bin/pmap
88+
» Binlinking pidof from core/procps-ng/3.3.15/20200702121715 into /bin
89+
★ Binlinked pidof from core/procps-ng/3.3.15/20200702121715 to /bin/pidof
90+
» Binlinking w from core/procps-ng/3.3.15/20200702121715 into /bin
91+
★ Binlinked w from core/procps-ng/3.3.15/20200702121715 to /bin/w
92+
» Binlinking slabtop from core/procps-ng/3.3.15/20200702121715 into /bin
93+
★ Binlinked slabtop from core/procps-ng/3.3.15/20200702121715 to /bin/slabtop
94+
```
95+
96+
#### Using an example binary
97+
98+
You can now use the binary as normal. For example:
99+
100+
``/bin/free --help`` or ``free --help``
101+
102+
```bash
103+
$ free --help
104+
105+
Usage:
106+
free [options]
107+
108+
Options:
109+
-b, --bytes show output in bytes
110+
...
111+
...
112+
```
+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
title 'Tests to confirm procps-ng exists'
2+
3+
plan_origin = ENV['HAB_ORIGIN']
4+
plan_name = input('plan_name', value: 'procps-ng')
5+
6+
control 'core-plans-procps-ng-exists' do
7+
impact 1.0
8+
title 'Ensure procps-ng exists'
9+
desc '
10+
Verify procps-ng by ensuring all binaries
11+
(1) exist and
12+
(2) are executable'
13+
14+
plan_installation_directory = command("hab pkg path #{plan_origin}/#{plan_name}")
15+
describe plan_installation_directory do
16+
its('exit_status') { should eq 0 }
17+
its('stdout') { should_not be_empty }
18+
#its('stderr') { should be_empty }
19+
end
20+
21+
[
22+
"free",
23+
"pgrep",
24+
"pidof",
25+
"pkill",
26+
"pmap",
27+
"ps",
28+
"pwdx",
29+
"slabtop",
30+
"sysctl",
31+
"tload",
32+
"top",
33+
"uptime",
34+
"vmstat",
35+
"w",
36+
"watch",
37+
].each do |binary_name|
38+
command_full_path = File.join(plan_installation_directory.stdout.strip, "bin", binary_name)
39+
describe file(command_full_path) do
40+
it { should exist }
41+
it { should be_executable }
42+
end
43+
end
44+
end

procps-ng/controls/procps-ng_works.rb

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
title 'Tests to confirm procps-ng works as expected'
2+
3+
plan_origin = ENV['HAB_ORIGIN']
4+
plan_name = input('plan_name', value: 'procps-ng')
5+
6+
control 'core-plans-procps-ng-works' do
7+
impact 1.0
8+
title 'Ensure procps-ng works as expected'
9+
desc '
10+
Verify procps-ng by ensuring that
11+
(1) its installation directory exists
12+
(2) all binaries return the expected version
13+
'
14+
15+
plan_installation_directory = command("hab pkg path #{plan_origin}/#{plan_name}")
16+
describe plan_installation_directory do
17+
its('exit_status') { should eq 0 }
18+
its('stdout') { should_not be_empty }
19+
#its('stderr') { should be_empty }
20+
end
21+
22+
plan_pkg_version = plan_installation_directory.stdout.split("/")[5]
23+
# check version on all binaries apart from 'top'
24+
[
25+
"free",
26+
"pgrep",
27+
"pidof",
28+
"pkill",
29+
"pmap",
30+
"ps",
31+
"pwdx",
32+
"slabtop",
33+
"sysctl",
34+
"tload",
35+
"uptime",
36+
"vmstat",
37+
"w",
38+
"watch",
39+
].each do |binary_name|
40+
command_full_path = File.join(plan_installation_directory.stdout.strip, "bin", binary_name)
41+
describe command("#{command_full_path} --version") do
42+
its('exit_status') { should eq 0 }
43+
its('stdout') { should_not be_empty }
44+
its('stdout') { should match /#{binary_name} from procps-ng #{plan_pkg_version}/ }
45+
#its('stderr') { should be_empty }
46+
end
47+
end
48+
49+
# check 'top' separately because it works differently from the others
50+
command_full_path = File.join(plan_installation_directory.stdout.strip, "bin", "top")
51+
describe command("#{command_full_path} -v") do
52+
its('exit_status') { should eq 0 }
53+
its('stdout') { should_not be_empty }
54+
its('stdout') { should match /procps-ng #{plan_pkg_version}/ }
55+
#its('stderr') { should be_empty }
56+
end
57+
end

procps-ng/disable-test.patch

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
diff -ru procps-ng-3.3.12.orig/testsuite/ps.test/ps_output.exp procps-ng-3.3.12/testsuite/ps.test/ps_output.exp
2+
--- procps-ng-3.3.12.orig/testsuite/ps.test/ps_output.exp 2018-03-22 14:45:04.313321296 +0000
3+
+++ procps-ng-3.3.12/testsuite/ps.test/ps_output.exp 2018-03-22 14:46:11.196206443 +0000
4+
@@ -22,10 +22,7 @@
5+
set ps_class "\[A-Z?-\]\\s*"
6+
7+
set flag_match {
8+
- "%cpu,pcpu,%mem,pmem" "%CPU\\s+%CPU\\s+%MEM\\s+%MEM\\s+\(\\d+\.\\d+\\s*\){4}$"
9+
- "blocked,sig_block,sigmask,caught,sigcatch,sig_catch" "\(BLOCKED\\s+\){3}\(CAUGHT\\s+\){2}CATCHED\\s+\(<?\[0-9a-f\]+\\s*\){6}$"
10+
"bsdstart,start,lstart" "\\s*START\\s+STARTED\\s+STARTED\\s+\(\\s*\(\[A-Z\]\[a-z\]{2} \\d+|\\d+:\\d{2}\)\\s+\(\[A-Z\]\[a-z\]{2} \\d+|\\d+:\\d{2}:\\d{2}\)\\s+\[A-Z\]\[a-z\]{2} \[A-Z\]\[a-z\]{2}\\s+\\d+ \\d{2}:\\d{2}:\\d{2} \\d{4}\\s*\)+$"
11+
- "bsdtime,cputime,etime,etimes" "\\s*TIME\\s+TIME\\s+ELAPSED\\s+ELAPSED\\s*\(\\s*\\d+:\\d{2}\\s+\\d{2}:\\d{2}:\\d{2}\\s+\(\\d{2}:\)?\\d{2}:\\d{2}\\s+\\d+\\s*\)$"
12+
"user,ruser,group,rgroup,uid,ruid,gid,rgid" "\\s*USER\\s+RUSER\\s+GROUP\\s+RGROUP\\s+UID\\s+RUID\\s+GID\\s+RGID\\s+\(\(\\s*\[A-Za-z0-9_+-\]+\\s+\){4}\(\\d+\\s+\){4}\\s*\)+$"
13+
}
14+

procps-ng/inspec.yml

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
name: procps-ng
2+
title: Habitat Core Plan procps-ng
3+
maintainer: "The Core Planners <[email protected]>"
4+
summary: InSpec controls for testing Habitat Core Plan procps-ng
5+
version: 0.1.0
6+
license: Apache-2.0
7+
inspec_version: '>= 4.18.108'

procps-ng/plan.sh

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
pkg_name=procps-ng
2+
pkg_origin=core
3+
pkg_version=3.3.17
4+
pkg_maintainer="The Habitat Maintainers <[email protected]>"
5+
pkg_description="\
6+
Command line and full screen utilities for browsing procfs, a pseudo file \
7+
system dynamically generated by the kernel to provide information about the \
8+
status of entries in its process table.\
9+
"
10+
pkg_upstream_url="https://gitlab.com/procps-ng/procps"
11+
pkg_license=('GPL-2.0-or-later')
12+
pkg_source="https://downloads.sourceforge.net/project/${pkg_name}/Production/${pkg_name}-${pkg_version}.tar.xz"
13+
pkg_shasum="4518b3e7aafd34ec07d0063d250fd474999b20b200218c3ae56f5d2113f141b4"
14+
pkg_dirname="${pkg_name}-${pkg_version}"
15+
pkg_deps=(
16+
core/glibc
17+
core/ncurses
18+
)
19+
pkg_build_deps=(
20+
core/file
21+
core/gcc
22+
core/make
23+
core/patch
24+
core/pkg-config
25+
)
26+
pkg_bin_dirs=(bin)
27+
pkg_include_dirs=(include)
28+
pkg_lib_dirs=(lib)
29+
pkg_pconfig_dirs=(lib/pkgconfig)
30+
31+
do_unpack() {
32+
mkdir -p "$HAB_CACHE_SRC_PATH/$pkg_dirname"
33+
pushd "$HAB_CACHE_SRC_PATH/$pkg_dirname" > /dev/null
34+
tar xf "$HAB_CACHE_SRC_PATH/$pkg_filename" --strip-components=1
35+
popd > /dev/null
36+
}
37+
38+
do_build() {
39+
# The Util-linux package will provide the `kill` command
40+
./configure \
41+
--prefix="$pkg_prefix" \
42+
--sbindir="$pkg_prefix/bin" \
43+
--disable-kill
44+
make
45+
}
46+
47+
do_check() {
48+
make check
49+
}
50+
51+
52+
# ----------------------------------------------------------------------------
53+
# **NOTICE:** What follows are implementation details required for building a
54+
# first-pass, "stage1" toolchain and environment. It is only used when running
55+
# in a "stage1" Studio and can be safely ignored by almost everyone. Having
56+
# said that, it performs a vital bootstrapping process and cannot be removed or
57+
# significantly altered. Thank you!
58+
# ----------------------------------------------------------------------------
59+
if [[ "$STUDIO_TYPE" = "stage1" ]]; then
60+
pkg_build_deps=(
61+
core/gcc
62+
)
63+
fi

procps-ng/tests/test.bats

+81
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
expected_version="$(echo $TEST_PKG_IDENT | cut -d/ -f 3)"
2+
3+
@test "free version is $expected_version" {
4+
run hab pkg exec $TEST_PKG_IDENT free --version
5+
[ "$output" = "free from procps-ng $expected_version" ]
6+
}
7+
8+
@test "free runs" {
9+
run hab pkg exec $TEST_PKG_IDENT free
10+
[ $status -eq 0 ]
11+
}
12+
13+
@test "pgrep runs" {
14+
run hab pkg exec $TEST_PKG_IDENT pgrep -v no_such_pids
15+
[ $status -eq 0 ]
16+
}
17+
18+
@test "pidof runs" {
19+
run hab pkg exec $TEST_PKG_IDENT pidof pidof
20+
[ $status -eq 0 ]
21+
}
22+
23+
@test "pkill runs" {
24+
run hab pkg exec $TEST_PKG_IDENT pkill -h
25+
[ $status -eq 0 ]
26+
}
27+
28+
@test "pmap runs" {
29+
run hab pkg exec $TEST_PKG_IDENT pmap -h
30+
[ $status -eq 0 ]
31+
}
32+
33+
@test "ps runs" {
34+
run hab pkg exec $TEST_PKG_IDENT ps
35+
[ $status -eq 0 ]
36+
}
37+
38+
@test "pwdx runs" {
39+
run hab pkg exec $TEST_PKG_IDENT pwdx -h
40+
[ $status -eq 0 ]
41+
}
42+
43+
@test "slaptop runs" {
44+
run hab pkg exec $TEST_PKG_IDENT slabtop -o
45+
[ $status -eq 0 ]
46+
}
47+
48+
@test "sysctl runs" {
49+
run hab pkg exec $TEST_PKG_IDENT sysctl -a
50+
[ $status -eq 0 ]
51+
}
52+
53+
@test "tload runs" {
54+
run hab pkg exec $TEST_PKG_IDENT tload -h
55+
[ $status -eq 0 ]
56+
}
57+
58+
@test "top runs" {
59+
run hab pkg exec $TEST_PKG_IDENT top -h
60+
[ $status -eq 0 ]
61+
}
62+
63+
@test "uptime runs" {
64+
run hab pkg exec $TEST_PKG_IDENT uptime
65+
[ $status -eq 0 ]
66+
}
67+
68+
@test "vmstat runs" {
69+
run hab pkg exec $TEST_PKG_IDENT vmstat
70+
[ $status -eq 0 ]
71+
}
72+
73+
@test "w runs" {
74+
run hab pkg exec $TEST_PKG_IDENT w
75+
[ $status -eq 0 ]
76+
}
77+
78+
@test "watch runs" {
79+
run hab pkg exec $TEST_PKG_IDENT watch -h
80+
[ $status -eq 0 ]
81+
}

0 commit comments

Comments
 (0)