-
Notifications
You must be signed in to change notification settings - Fork 2
/
make.ksh
executable file
·145 lines (119 loc) · 4.19 KB
/
make.ksh
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#!/usr/bin/ksh -e
# Copyright 2012-2022 -- Michael Felt
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# BUILDAIX.KSH - build myself!
# check for required fileset
# call a script to set environment variables
# call "configure" of project, or just run make if Makefile exists
cmd=$0
lslpp -L bos.adt.insttools >/dev/null 2>&1
if [[ $? -ne 0 ]]; then
print "${cmd}: must have bos.adt.insttools installed"
exit 99
fi
[[ `id -u` -ne 0 ]] \
&& print "${cmd}: mkinstallp must be run with root authority" >&2 \
&& exit 97
# when packaing buildaix - always 32-bit mode!
unset OBJECT_MODE
cwd=`pwd`
PATH=${cwd}/opt/bin:${PATH}
unset vrmf
unset lpp
while getopts "-:V:P:F:h" opt; do
case $opt in
# INVALID
:)
print "${cmd}: Invalid syntax: -${OPTARG} needs an argument" > ${tty}
error="error"
exit 91
;;
# print "${cmd}: Invalid option: -${opt}" > ${tty}
\?)
print "${cmd}: Invalid option: " > ${tty}
error="error"
exit 92
;;
#specify Product of $Program.#PRODUCT.$Fileset name - override aixinfo
P)
PRODUCT=${OPTARG}
export PRODUCT
;;
#specify Fileset name - override aixinfo
F)
FILESET=${OPTARG}
export FILESET
;;
#specify VRMF number - override aixinfo
V)
v=${OPTARG}
cnt=`echo ${v} | awk -F. ' { print NF } '`
if [[ $cnt -eq 4 ]]; then
VRMF=${v}
else
print -- ${v} is not a valid vrmf format
exit -2
fi
unset v
;;
esac
done
# Add line to set FILESET='buildaix', if not set to something else
FILESET=${FILESET-"buildaix"}
[[ -z $VRMF ]] && print "$0: must supply a new version number" && exit -1
. opt/bin/aixinfo # set environment and installp variables
# my "install"
LPP=${PROGRAM}/${PRODUCT}
TEMPDIR=/var/tmp/${LPP}/${FILESET}/${VRMF}
export PROGRAM PRODUCT FILESET VRMF
rm -rf ${TEMPDIR}
mkdir -p ${TEMPDIR}
[[ $? -ne 0 ]] && print $cmd: cannot make TEMPDIR at $TEMPDIR && exit -1
# TODO - have .info directory in $TEMP_LPP
# for redirected output and to save template
rm -rf .buildaix
mkdir -p .buildaix
mkdir -p ${TEMPDIR}/opt/bin
for file in buildaix.ksh aixinfo mkinstallp.ksh mkXany mkX32 mkX64 mergelibs.ksh ; do
cp -p opt/bin/$file ${TEMPDIR}/opt/bin
done
mkdir -p ${TEMPDIR}/usr/share/man/man1
for file in buildaix.1; do
cp -p usr/share/man/man1/$file ${TEMPDIR}/usr/share/man/man1
done
mkdir -p ${TEMPDIR}/opt/buildaix/include
for file in bzlib.h zlib.h zconf.h; do
cp -p opt/buildaix/include/$file ${TEMPDIR}/opt/buildaix/include
done
cp -rp opt/buildaix/templates ${TEMPDIR}/opt/buildaix/templates
rm -rf ${TEMPDIR}/opt/buildaix/templates/.svn
# mkinstallp does not accept links that begin with / and cannot be resolved immediately
# e.g., $TEMPDIR/opt/bin/buildaix.ksh exists, but not /opt/bin/buildaix.ksh
# and so the mkinstallp fails
# therefore, use relative names
mkdir -p ${TEMPDIR}/usr/bin
ln -s ../../opt/bin/buildaix.ksh $TEMPDIR/usr/bin/buildaix
print "# removing old buildaix - if still present, ignore error message - if any"
installp -u aixtools.buildaix >/dev/null
print -- "+-----------------------------------------------------------------------------+"
print "+ mkinstallp.ksh $TEMPDIR > .buildaix/mkinstallp.out"
opt/bin/mkinstallp.ksh $TEMPDIR | tee .buildaix/mkinstallp.out
[[ $? -ne 0 ]] &&
print mkinstallp.ksh returned an error && tail .buildaix/mkinstallp.out && exit -1
# rm -rf $TEMPDIR
# list installable fileset(s)
print -- "+-----------------------------------------------------------------------------+"
# installp -d . -L
ls -l installp/ppc
print -- "+-----------------------------------------------------------------------------+"