Skip to content

Commit 9ad31ad

Browse files
committed
packaging steps
1 parent 966d97f commit 9ad31ad

File tree

10 files changed

+361
-1
lines changed

10 files changed

+361
-1
lines changed

Makefile

+13
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
DIR_TARGET = target
44
DIR_OBJ = $(DIR_TARGET)/obj
55
DIR_BIN = $(DIR_TARGET)/bin
6+
DIR_RPM = pkg/rpm/RPMS
7+
DIR_DEB = pkg/deb/DEBS
68

79
SRC_DIRS = common index prep storage
810
OBJ_DIRS = $(SRC_DIRS:%=$(DIR_OBJ)/src/%)
@@ -52,9 +54,20 @@ act_storage: target_dir $(STORAGE_OBJECTS)
5254
echo "Linking $@"
5355
$(CC) $(LDFLAGS) -o $(STORAGE_BINARY) $(STORAGE_OBJECTS) $(LIBRARIES)
5456

57+
.PHONY: rpm
58+
rpm:
59+
$(MAKE) -f pkg/Makefile.rpm
60+
61+
.PHONY: deb
62+
deb:
63+
$(MAKE) -f pkg/Makefile.deb
64+
5565
# For now we only clean everything.
66+
.PHONY: clean
5667
clean:
5768
/bin/rm -rf $(DIR_TARGET)
69+
/bin/rm -rf $(DIR_RPM)
70+
/bin/rm -rf $(DIR_DEB)
5871

5972
-include $(ALL_DEPENDENCIES)
6073

analysis/act_latency.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/python
1+
#!/usr/bin/python3
22

33
# ------------------------------------------------
44
# act_latency.py

build/os_version

+139
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
#!/usr/bin/env bash
2+
# ------------------------------------------------------------------------------
3+
# Copyright 2012-2015 Aerospike, Inc.
4+
#
5+
# Portions may be licensed to Aerospike, Inc. under one or more contributor
6+
# license agreements.
7+
#
8+
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
9+
# use this file except in compliance with the License. You may obtain a copy of
10+
# the License at http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15+
# License for the specific language governing permissions and limitations under
16+
# the License.
17+
# ------------------------------------------------------------------------------
18+
19+
OPT_LONG=0
20+
21+
if [ "$1" = "-long" ]
22+
then
23+
OPT_LONG=1
24+
fi
25+
26+
error() {
27+
echo 'error:' $* >&2
28+
}
29+
30+
main() {
31+
32+
local kernel=''
33+
local distro_id=''
34+
local distro_version=''
35+
local distro_long=''
36+
local distro_short=''
37+
38+
# Make sure this script is running on Linux
39+
# The script is not designed to work on non-Linux
40+
# operating systems.
41+
kernel=$(uname -s | tr '[:upper:]' '[:lower:]')
42+
if [ "$kernel" != 'linux' ]
43+
then
44+
error "$kernel is not supported."
45+
exit 1
46+
fi
47+
48+
if [ -f /etc/os-release ]
49+
then
50+
. /etc/os-release
51+
distro_id=${ID,,}
52+
distro_version=${VERSION_ID}
53+
elif [ -f /etc/issue ]
54+
then
55+
issue=$(cat /etc/issue | tr '[:upper:]' '[:lower:]')
56+
case "$issue" in
57+
*'centos'* )
58+
distro_id='centos'
59+
;;
60+
*'redhat'* | *'rhel'* )
61+
distro_id='rhel'
62+
;;
63+
*'debian'* )
64+
distro_id='debian'
65+
;;
66+
* )
67+
error "/etc/issue contained an unsupported linux distibution: $issue"
68+
exit 1
69+
;;
70+
esac
71+
72+
case "$distro_id" in
73+
'centos' | 'rhel' )
74+
local release=''
75+
if [ -f /etc/centos-release ]; then
76+
release=$(cat /etc/centos-release | tr '[:upper:]' '[:lower:]')
77+
elif [ -f /etc/redhat-release ]; then
78+
release=$(cat /etc/redhat-release | tr '[:upper:]' '[:lower:]')
79+
fi
80+
release_version=${release##*release}
81+
distro_version=${release_version%.*}
82+
;;
83+
'debian' )
84+
debian_version=$(cat /etc/debian_version | tr '[:upper:]' '[:lower:]')
85+
distro_version=${debian_version%%.*}
86+
;;
87+
* )
88+
error "/etc/issue contained an unsupported linux distibution: $issue"
89+
exit 1
90+
;;
91+
esac
92+
fi
93+
94+
distro_id=${distro_id//[[:space:]]/}
95+
distro_version=${distro_version//[[:space:]]/}
96+
97+
case "$distro_id" in
98+
'centos' )
99+
distro_long="${distro_id}${distro_version%%.*}"
100+
distro_short="el${distro_version%%.*}"
101+
;;
102+
'rhel' | 'redhat' | 'red hat' )
103+
distro_long="${distro_id}${distro_version%%.*}"
104+
distro_short="el${distro_version%%.*}"
105+
;;
106+
'fedora' )
107+
if [ "$distro_version" -gt "15" ]
108+
then
109+
distro_version=7
110+
elif [ "$distro_version" -gt "10" ]
111+
then
112+
distro_version=6
113+
else
114+
error "Unsupported linux distibution: $distro_id $distro_version"
115+
exit 1
116+
fi
117+
distro_long="centos${distro_version}"
118+
distro_short="el${distro_version}"
119+
;;
120+
'amzn' )
121+
distro_long="ami"
122+
distro_short="ami"
123+
;;
124+
* )
125+
distro_long="${distro_id}${distro_version}"
126+
distro_short="${distro_id}${distro_version}"
127+
;;
128+
esac
129+
130+
if [ "$OPT_LONG" = "1" ]
131+
then
132+
echo "${distro_long}"
133+
else
134+
echo "${distro_short}"
135+
fi
136+
exit 0
137+
}
138+
139+
main

build/version

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
3+
rev=`git describe`
4+
subbuild=`echo $rev | awk -F'-' '{print $2}'`
5+
6+
if [ "$subbuild" != "" ]
7+
then
8+
rev=`echo $rev | awk -F'-' '{printf("%s-%s\n",$1,$2)}'`
9+
fi
10+
echo $rev

pkg/Makefile.deb

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Build act distribution.
2+
3+
export DEB_SOURCE_ROOT = $(shell echo `pwd`/dist)
4+
export DEB_BUILD_ROOT = $(DEB_SOURCE_ROOT)/BUILD
5+
export CL_BASE = $(DEB_BUILD_ROOT)/opt/aerospike
6+
export ETC_BASE = $(DEB_BUILD_ROOT)/etc/aerospike
7+
8+
REV = $(shell build/version)
9+
#REV = 6.2.0
10+
OS = $(shell build/os_version)
11+
MANIFEST_DIR = manifest/TEMP
12+
13+
.PHONY: default
14+
default: dist
15+
16+
.PHONY: dist
17+
dist:
18+
19+
# Build tools package.
20+
rm -rf $(DEB_BUILD_ROOT)/*
21+
mkdir -p $(DEB_BUILD_ROOT)/DEBIAN
22+
mkdir -p $(DEB_BUILD_ROOT)/usr/bin
23+
mkdir -p pkg/deb/DEBS
24+
install -m 755 pkg/deb/postinst $(DEB_BUILD_ROOT)/DEBIAN/postinst
25+
install -m 755 pkg/deb/prerm $(DEB_BUILD_ROOT)/DEBIAN/prerm
26+
install -m 644 pkg/deb/control $(DEB_BUILD_ROOT)/DEBIAN/control
27+
28+
mkdir -p $(CL_BASE)
29+
mkdir -p $(ETC_BASE)
30+
mkdir -p $(CL_BASE)/bin
31+
32+
# act
33+
install -m 755 target/bin/act_* $(CL_BASE)/bin/
34+
install -m 755 analysis/act_latency.py $(CL_BASE)/bin/
35+
install -m 755 config/act_index.conf $(ETC_BASE)/
36+
install -m 755 config/act_storage.conf $(ETC_BASE)/
37+
38+
# Create symlinks to /usr/bin
39+
mkdir -p $(DEB_BUILD_ROOT)/usr/bin
40+
ln -sf /opt/aerospike/bin/act_index $(DEB_BUILD_ROOT)/usr/bin/act_index
41+
ln -sf /opt/aerospike/bin/act_prep $(DEB_BUILD_ROOT)/usr/bin/act_prep
42+
ln -sf /opt/aerospike/bin/act_storage $(DEB_BUILD_ROOT)/usr/bin/act_storage
43+
ln -sf /opt/aerospike/bin/act_latency.py $(DEB_BUILD_ROOT)/usr/bin/act_latency.py
44+
45+
46+
sed 's/@VERSION@/'$(REV)'/g' <pkg/deb/control >$(DEB_BUILD_ROOT)/DEBIAN/control
47+
48+
fakeroot dpkg-deb --build $(DEB_BUILD_ROOT) pkg/deb/DEBS
49+
rm -rf dist
50+
51+
distclean:
52+
rm -rf $(DEB_SOURCE_ROOT)
53+
rm -rf pkg/deb/DEBS

pkg/Makefile.rpm

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Build aerospike rpm distribution.
2+
3+
export RPM_SOURCE_ROOT = $(shell echo `pwd`/dist)
4+
export RPM_BUILD_ROOT = $(RPM_SOURCE_ROOT)/BUILD
5+
export CL_BASE = $(RPM_BUILD_ROOT)/opt/aerospike
6+
export ETC_BASE = $(RPM_BUILD_ROOT)/etc/aerospike
7+
8+
MANIFEST_DIR = manifest/TEMP
9+
TOOLS_VERSION = $(shell build/version | sed 's/-/_/g')
10+
OS = $(shell build/os_version)
11+
#TOOLS_VERSION = $(shell git describe 2>/dev/null; if [ $${?} != 0 ]; then echo 'unknown'; fi)
12+
OS = el8
13+
TOOLS_VERSION = 6.2.0
14+
15+
.PHONY: default
16+
default: dist
17+
mkdir -p pkg/rpm/RPMS/x86_64
18+
mkdir -p $(RPM_BUILD_ROOT)
19+
mkdir -p $(RPM_SOURCE_ROOT)/RPMS/x86_64
20+
mkdir -p $(RPM_BUILD_ROOT)/usr/bin
21+
22+
sed 's/@VERSION@/'$(TOOLS_VERSION)'/g' <pkg/rpm/act.spec >pkg/act_v.spec
23+
sed -i 's/@RELEASE@/'$(OS)'/g' pkg/act_v.spec
24+
25+
rpmbuild -bb -vv --define "dist .$(OS)" --buildroot $(RPM_BUILD_ROOT) pkg/act_v.spec
26+
find $(RPM_SOURCE_ROOT)/RPMS -type f -exec mv {} pkg/rpm/RPMS/x86_64 \;
27+
rm -rf pkg/act_v.spec dist
28+
29+
distclean:
30+
rm -rf $(RPM_BUILD_ROOT)
31+
rm -rf pkg/rpm/RPMS/x86_64/*
32+
33+
.PHONY: dist
34+
dist:
35+
36+
mkdir -p $(CL_BASE)
37+
mkdir -p $(ETC_BASE)
38+
mkdir -p $(CL_BASE)/bin
39+
40+
# act
41+
install -m 755 target/bin/act_* $(CL_BASE)/bin/
42+
install -m 755 analysis/act_latency.py $(CL_BASE)/bin/
43+
install -m 755 config/act_index.conf $(ETC_BASE)/
44+
install -m 755 config/act_storage.conf $(ETC_BASE)/

pkg/deb/control

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Package: act
2+
Version: @VERSION@
3+
Section: Databases
4+
Priority: optional
5+
Architecture: amd64
6+
Depends: libc6 (>= 2.7)
7+
Maintainer: Aerospike, Inc. <info@aerospike.net>
8+
Description: Aerospike Certification Tool

pkg/deb/postinst

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/sh
2+
3+
set -e
4+
5+
case "$1" in
6+
configure)
7+
8+
echo Installing /opt/aerospike/bim/act
9+
10+
# create aerospike group if it isn't already there
11+
if ! getent group aerospike >/dev/null; then
12+
groupadd -r aerospike
13+
fi
14+
15+
# create aerospike user if it isn't already there
16+
if ! getent passwd aerospike >/dev/null; then
17+
useradd -r -d /opt/aerospike -c 'Aerospike server' -g aerospike aerospike
18+
fi
19+
20+
chown -R aerospike:aerospike /opt/aerospike
21+
22+
;;
23+
esac
24+
25+
exit 0

pkg/deb/prerm

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/sh
2+
3+
set -e
4+
5+
case "$1" in
6+
remove)
7+
8+
echo Removing /opt/aerospike/bin/act
9+
rm -f /opt/aerospike/bin/act_*
10+
;;
11+
esac
12+
13+
exit 0

pkg/rpm/act.spec

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
Name: act
2+
Version: @VERSION@
3+
Release: 1%{?dist}
4+
Summary: The Aerospike Certification Tool
5+
License: Apache 2.0 license
6+
Group: Application
7+
BuildArch: x86_64
8+
%description
9+
ACT provides a pair of programs for testing and certifying flash/SSD devices' performance for Aerospike Database data and index storage.
10+
%define _topdir dist
11+
%define __spec_install_post /usr/lib/rpm/brp-compress
12+
13+
%package tools
14+
Summary: The Aerospike Certification Tool
15+
Group: Applications
16+
%description tools
17+
Tools for use with the Aerospike database
18+
%files
19+
%defattr(-,aerospike,aerospike)
20+
/opt/aerospike/bin/act_index
21+
/opt/aerospike/bin/act_prep
22+
/opt/aerospike/bin/act_storage
23+
/opt/aerospike/bin/act_latency.py
24+
%defattr(-,root,root)
25+
/usr/bin/act_index
26+
/usr/bin/act_prep
27+
/usr/bin/act_storage
28+
/usr/bin/act_latency.py
29+
30+
%config(noreplace)
31+
/etc/aerospike/act_storage.conf
32+
/etc/aerospike/act_index.conf
33+
34+
%prep
35+
ln -sf /opt/aerospike/bin/act_index %{buildroot}/usr/bin/act_index
36+
ln -sf /opt/aerospike/bin/act_prep %{buildroot}/usr/bin/act_prep
37+
ln -sf /opt/aerospike/bin/act_storage %{buildroot}/usr/bin/act_storage
38+
ln -sf /opt/aerospike/bin/act_latency.py %{buildroot}/usr/bin/act_latency.py
39+
40+
%pre tools
41+
echo Installing /opt/aerospike/act
42+
if ! id -g aerospike >/dev/null 2>&1; then
43+
echo "Adding group aerospike"
44+
/usr/sbin/groupadd -r aerospike
45+
fi
46+
if ! id -u aerospike >/dev/null 2>&1; then
47+
echo "Adding user aerospike"
48+
/usr/sbin/useradd -r -d /opt/aerospike -c 'Aerospike server' -g aerospike aerospike
49+
fi
50+
51+
%preun tools
52+
if [ $1 -eq 0 ]
53+
then
54+
echo Removing /opt/aerospike/act
55+
fi

0 commit comments

Comments
 (0)