Skip to content

Commit e08bc7e

Browse files
committed
extract functions from environement.sh into separate file; prepare RPM directories on first run of RPM build scripts.
1 parent 39ef147 commit e08bc7e

File tree

2 files changed

+178
-174
lines changed

2 files changed

+178
-174
lines changed

Packaging/environment.sh

Lines changed: 30 additions & 174 deletions
Original file line numberDiff line numberDiff line change
@@ -26,28 +26,6 @@ fi
2626
OS_NAME=$NAME
2727
${ECHO} "OS:\t\t${OS_ID}-${OS_VERSION}"
2828

29-
# Package dependencies for Debian/Ubuntu
30-
if [ ${OS_ID} = "debian" ] || [ ${OS_ID} = "ubuntu" ]; then
31-
. ./${OS_ID}-${OS_VERSION}.deps.sh || exit 1
32-
fi
33-
34-
#----------------------------------------
35-
# Library versions
36-
#----------------------------------------
37-
libdispatch_version=5.9.2
38-
libcorefoundation_version=5.9.2
39-
libcfnetwork_version=129.20
40-
libobjc2_version=2.2.1
41-
gnustep_make_version=2_9_2
42-
gnustep_base_version=1_30_0
43-
gnustep_gui_version=0_31_0
44-
45-
gorm_version=1_4_0
46-
projectcenter_version=0_7_0
47-
48-
roboto_mono_version=0.2020.05.08
49-
roboto_mono_checkout=master
50-
5129
#----------------------------------------
5230
# Paths
5331
#----------------------------------------
@@ -71,6 +49,7 @@ if [ -z $BUILD_RPM ]; then
7149
DEST_DIR=""
7250
fi
7351
else
52+
print_H2 "===== Create rpmbuild directories..."
7453
RELEASE_USR="$_PWD/$OS_ID-$OS_VERSION/NSUser"
7554
RELEASE_DEV="$_PWD/$OS_ID-$OS_VERSION/NSDeveloper"
7655
mkdir -p ${RELEASE_USR}
@@ -79,10 +58,39 @@ else
7958
RPM_SOURCES_DIR=~/rpmbuild/SOURCES
8059
RPM_SPECS_DIR=~/rpmbuild/SPECS
8160
RPMS_DIR=~/rpmbuild/RPMS/`uname -m`
61+
mkdir -p $RPM_SOURCES_DIR
62+
mkdir -p $RPM_SPECS_DIR
8263

8364
${ECHO} "RPMs directory:\t$RPMS_DIR"
8465
fi
8566

67+
. ../functions.sh
68+
#----------------------------------------
69+
# Package dependencies
70+
#----------------------------------------
71+
if [ ${OS_ID} = "debian" ] || [ ${OS_ID} = "ubuntu" ]; then
72+
. ./${OS_ID}-${OS_VERSION}.deps.sh || exit 1
73+
else
74+
prepare_environment
75+
fi
76+
77+
#----------------------------------------
78+
# Library versions
79+
#----------------------------------------
80+
libdispatch_version=5.9.2
81+
libcorefoundation_version=5.9.2
82+
libcfnetwork_version=129.20
83+
libobjc2_version=2.2.1
84+
gnustep_make_version=2_9_2
85+
gnustep_base_version=1_30_0
86+
gnustep_gui_version=0_31_0
87+
88+
gorm_version=1_4_0
89+
projectcenter_version=0_7_0
90+
91+
roboto_mono_version=0.2020.05.08
92+
roboto_mono_checkout=master
93+
8694
#----------------------------------------
8795
# Tools
8896
#----------------------------------------
@@ -137,155 +145,3 @@ if [ "$OS_ID" = "fedora" ] || [ "$OS_LIKE" = "rhel" ] || [ "$OS_ID" = "debian" ]
137145
which clang++ 2>&1 > /dev/null || `echo "No clang++ compiler found. Please install clang++ package."; exit 1`
138146
CXX_COMPILER=`which clang++`
139147
fi
140-
141-
###############################################################################
142-
# Functions
143-
###############################################################################
144-
145-
git_remote_archive() {
146-
local url="$1"
147-
local dest="$2"
148-
local branch="$3"
149-
150-
cd ${BUILD_ROOT}
151-
152-
if [ -d "$dest" ];then
153-
echo "$dest exists, skipping"
154-
else
155-
git clone --recurse-submodules "$url" "$dest"
156-
cd "$dest"
157-
if [ "$branch" != "master" ];then
158-
git checkout $branch
159-
fi
160-
fi
161-
}
162-
163-
install_packages() {
164-
apt-get install -y $@ || exit 1
165-
}
166-
167-
uninstall_packages() {
168-
apt-get purge -y $@ || exit 1
169-
}
170-
171-
prepare_environment()
172-
{
173-
print_H1 " Prepare build environment"
174-
print_H2 "===== Create rpmbuild directories..."
175-
mkdir -p $RPM_SOURCES_DIR
176-
mkdir -p $RPM_SPECS_DIR
177-
178-
print_H2 "===== Install RPM build tools..."
179-
rpm -q rpm-build 2>&1 > /dev/null
180-
if [ $? -eq 1 ]; then BUILD_TOOLS+=" rpm-build"; fi
181-
rpm -q rpmdevtools 2>&1 > /dev/null
182-
if [ $? -eq 1 ]; then BUILD_TOOLS+=" rpmdevtools"; fi
183-
rpm -q make 2>&1 > /dev/null
184-
if [ $? -eq 1 ]; then BUILD_TOOLS+=" make"; fi
185-
rpm -q patch 2>&1 > /dev/null
186-
if [ $? -eq 1 ]; then BUILD_TOOLS+=" patch"; fi
187-
188-
if [ -f /etc/os-release ]; then
189-
if [ "${OS_LIKE}" = "rhel" ] && [ "${OS_VERSION}" = "9" ];then
190-
dnf -y install epel-release
191-
dnf config-manager --set-enabled crb
192-
dnf -y install clang
193-
else
194-
if [ "$OS_ID" = "fedora" ];then
195-
dnf -y install clang
196-
else
197-
print_H2 ">>>>> Can't find /etc/os-release - this OS is unsupported."
198-
return 1
199-
fi
200-
fi
201-
fi
202-
203-
if [ "${BUILD_TOOLS}" != "" ]; then
204-
sudo yum -y install ${BUILD_TOOLS}
205-
fi
206-
}
207-
208-
rpm_version()
209-
{
210-
echo `rpmspec -q --qf "%{version}-%{release}.%{arch}:" $1 | awk -F: '{print $1}'`
211-
}
212-
213-
# $1 - path to spec file
214-
build_rpm()
215-
{
216-
SPEC_FILE=$1
217-
spectool -g -R ${SPEC_FILE}
218-
DEPS=`rpmspec -q --buildrequires ${SPEC_FILE} | awk -c '{print $1}'`
219-
sudo yum -y install ${DEPS}
220-
rpmbuild -bb ${SPEC_FILE}
221-
}
222-
223-
# $1 - package name, $2 - rpm file path
224-
install_rpm()
225-
{
226-
rpm -q $1 2>&1 > /dev/null
227-
if [ $? -eq 1 ]; then
228-
INST_CMD=install
229-
else
230-
INST_CMD=reinstall
231-
fi
232-
sudo yum -y $INST_CMD $2
233-
}
234-
235-
# Bold
236-
print_H1()
237-
{
238-
echo -e -n "\e[1m"
239-
echo "================================================================================"
240-
echo -e -n "\e[1m"
241-
echo -e "$1"
242-
echo -e -n "\e[1m"
243-
echo "================================================================================"
244-
echo -e -n "\e[0m"
245-
}
246-
247-
# Brown
248-
print_H2()
249-
{
250-
echo -e -n "\e[33m"
251-
echo -e "$1"
252-
echo -e -n "\e[0m"
253-
}
254-
255-
# Green
256-
print_OK()
257-
{
258-
echo -e -n "\e[32m"
259-
echo "================================================================================"
260-
echo -e -n "\e[32m"
261-
echo -e "$1"
262-
echo -e -n "\e[32m"
263-
echo "================================================================================"
264-
echo -e -n "\e[0m"
265-
}
266-
267-
# Red
268-
print_ERR()
269-
{
270-
echo -e -n "\e[31m"
271-
echo "================================================================================"
272-
echo -e -n "\e[31m"
273-
echo -e "$1"
274-
echo -e -n "\e[31m"
275-
echo "================================================================================"
276-
echo -e -n "\e[0m"
277-
}
278-
279-
print_help()
280-
{
281-
SCRIPT_NAME=`basename $0`
282-
print_ERR " ERROR: No NEXTSPACE directory specified."
283-
printf "\n"
284-
print_H2 "You have to specify directory where NEXTSPACE git clone resides."
285-
print_H2 "For example, consider this scenario:"
286-
printf "\n"
287-
print_H2 "$ git clone https://github.com/trunkmaster/nextspace"
288-
print_H2 "$ cd nextspace"
289-
print_H2 "$ ./scripts/$SCRIPT_NAME ~/nextspace"
290-
printf "\n"
291-
}

Packaging/functions.sh

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
###############################################################################
2+
# Functions
3+
###############################################################################
4+
5+
git_remote_archive() {
6+
local url="$1"
7+
local dest="$2"
8+
local branch="$3"
9+
10+
cd ${BUILD_ROOT}
11+
12+
if [ -d "$dest" ];then
13+
echo "$dest exists, skipping"
14+
else
15+
git clone --recurse-submodules "$url" "$dest"
16+
cd "$dest"
17+
if [ "$branch" != "master" ];then
18+
git checkout $branch
19+
fi
20+
fi
21+
}
22+
23+
install_packages() {
24+
apt-get install -y $@ || exit 1
25+
}
26+
27+
uninstall_packages() {
28+
apt-get purge -y $@ || exit 1
29+
}
30+
31+
rpm_version()
32+
{
33+
echo `rpmspec -q --qf "%{version}-%{release}.%{arch}:" $1 | awk -F: '{print $1}'`
34+
}
35+
36+
# $1 - path to spec file
37+
build_rpm()
38+
{
39+
SPEC_FILE=$1
40+
spectool -g -R ${SPEC_FILE}
41+
DEPS=`rpmspec -q --buildrequires ${SPEC_FILE} | awk -c '{print $1}'`
42+
sudo yum -y install ${DEPS}
43+
rpmbuild -bb ${SPEC_FILE}
44+
}
45+
46+
# $1 - package name, $2 - rpm file path
47+
install_rpm()
48+
{
49+
rpm -q $1 2>&1 > /dev/null
50+
if [ $? -eq 1 ]; then
51+
INST_CMD=install
52+
else
53+
INST_CMD=reinstall
54+
fi
55+
sudo yum -y $INST_CMD $2
56+
}
57+
58+
# Bold
59+
print_H1()
60+
{
61+
echo -e -n "\e[1m"
62+
echo "================================================================================"
63+
echo -e -n "\e[1m"
64+
echo -e "$1"
65+
echo -e -n "\e[1m"
66+
echo "================================================================================"
67+
echo -e -n "\e[0m"
68+
}
69+
70+
# Brown
71+
print_H2()
72+
{
73+
echo -e -n "\e[33m"
74+
echo -e "$1"
75+
echo -e -n "\e[0m"
76+
}
77+
78+
# Green
79+
print_OK()
80+
{
81+
echo -e -n "\e[32m"
82+
echo "================================================================================"
83+
echo -e -n "\e[32m"
84+
echo -e "$1"
85+
echo -e -n "\e[32m"
86+
echo "================================================================================"
87+
echo -e -n "\e[0m"
88+
}
89+
90+
# Red
91+
print_ERR()
92+
{
93+
echo -e -n "\e[31m"
94+
echo "================================================================================"
95+
echo -e -n "\e[31m"
96+
echo -e "$1"
97+
echo -e -n "\e[31m"
98+
echo "================================================================================"
99+
echo -e -n "\e[0m"
100+
}
101+
102+
print_help()
103+
{
104+
SCRIPT_NAME=`basename $0`
105+
print_ERR " ERROR: No NEXTSPACE directory specified."
106+
printf "\n"
107+
print_H2 "You have to specify directory where NEXTSPACE git clone resides."
108+
print_H2 "For example, consider this scenario:"
109+
printf "\n"
110+
print_H2 "$ git clone https://github.com/trunkmaster/nextspace"
111+
print_H2 "$ cd nextspace"
112+
print_H2 "$ ./scripts/$SCRIPT_NAME ~/nextspace"
113+
printf "\n"
114+
}
115+
116+
prepare_environment()
117+
{
118+
print_H1 " Prepare build environment"
119+
print_H2 "===== Install RPM build tools..."
120+
121+
rpm -q rpm-build 2>&1 > /dev/null
122+
if [ $? -eq 1 ]; then BUILD_TOOLS+=" rpm-build"; fi
123+
rpm -q rpmdevtools 2>&1 > /dev/null
124+
if [ $? -eq 1 ]; then BUILD_TOOLS+=" rpmdevtools"; fi
125+
rpm -q make 2>&1 > /dev/null
126+
if [ $? -eq 1 ]; then BUILD_TOOLS+=" make"; fi
127+
rpm -q patch 2>&1 > /dev/null
128+
if [ $? -eq 1 ]; then BUILD_TOOLS+=" patch"; fi
129+
130+
if [ -f /etc/os-release ]; then
131+
if [ "${OS_ID}" = "rhel" ] && [ "${OS_VERSION}" = "9" ];then
132+
sudo dnf -y install epel-release
133+
sudo dnf config-manager --set-enabled crb
134+
sudo dnf -y install clang
135+
else
136+
if [ "$OS_ID" = "fedora" ];then
137+
sudo dnf -y install clang
138+
else
139+
print_H2 ">>>>> Can't find /etc/os-release - this OS is unsupported."
140+
return 1
141+
fi
142+
fi
143+
fi
144+
145+
if [ "${BUILD_TOOLS}" != "" ]; then
146+
sudo dnf -y install ${BUILD_TOOLS}
147+
fi
148+
}

0 commit comments

Comments
 (0)