forked from boypt/openssh-rpms
-
Notifications
You must be signed in to change notification settings - Fork 3
/
compile.sh
executable file
·82 lines (68 loc) · 1.91 KB
/
compile.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/usr/bin/env bash
# Bash3 Boilerplate. Copyright (c) 2014, kvz.io
set -o errexit
set -o pipefail
set -o nounset
# set -o xtrace
trap 'echo -e "Aborted, error $? in command: $BASH_COMMAND"; trap ERR; exit 1' ERR
# Set magic variables for current file & dir
__dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
__file="${__dir}/$(basename "${BASH_SOURCE[0]}")"
__base="$(basename ${__file} .sh)"
__root="$(cd "$(dirname "${__dir}")" && pwd)" # <-- change this as it depends on your app
rpmtopdir="${1:-}"
# trap 'echo Signal caught, cleaning up >&2; cd /tmp; /bin/rm -rfv "$TMP"; exit 15' 1 2 3 15
# allow command fail:
# fail_command || true
if [[ -z $rpmtopdir ]]; then
VAREL=$(rpm --eval '%{?dist}')
case $VAREL in
.el7)
rpmtopdir=el7
;;
.el6)
rpmtopdir=el6
;;
.el5)
rpmtopdir=el5
# on centos5, it's prefered to use gcc44
if yum --disablerepo=* list installed gcc44; then
export CC=gcc44
fi
;;
*)
echo "rpm dist undefined, please specify: el5 el6 el7"
exit 1
;;
esac
fi
if [[ ! -d $rpmtopdir ]]; then
echo "only work in el5/el6/el7"
echo "eg: ${0} el7"
exit 1
fi
source version.env
CHECKEXISTS() {
if [[ ! -f $__dir/downloads/$1 ]];then
echo "$1 not found, run 'pullsrc.sh', or manually put it in the downloads dir."
exit 1
fi
}
SOURCES=( $OPENSSHSRC \
$OPENSSLSRC \
$ASKPASSSRC \
)
pushd $rpmtopdir
for fn in ${SOURCES[@]}; do
CHECKEXISTS $fn
install -v -m666 $__dir/downloads/$fn ./SOURCES/
done
rpmbuild -ba SPECS/openssh.spec --target $(uname -m) --define "_topdir $PWD" \
--define "opensslver ${OPENSSLVER}" \
--define "opensshver ${OPENSSHVER}" \
--define "opensshpkgrel ${PKGREL}" \
--define 'no_gtk2 1' \
--define 'skip_gnome_askpass 1' \
--define 'skip_x11_askpass 1' \
;
popd