Print this page
Change entire requirement to optional.
| Split |
Close |
| Expand all |
| Collapse all |
--- old/lib/functions.sh
+++ new/lib/functions.sh
1 1 #!/bin/bash
2 2 #
3 3 # CDDL HEADER START
4 4 #
5 5 # The contents of this file are subject to the terms of the
6 6 # Common Development and Distribution License, Version 1.0 only
7 7 # (the "License"). You may not use this file except in compliance
8 8 # with the License.
9 9 #
10 10 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
11 11 # or http://www.opensolaris.org/os/licensing.
12 12 # See the License for the specific language governing permissions
13 13 # and limitations under the License.
14 14 #
15 15 # When distributing Covered Code, include this CDDL HEADER in each
16 16 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
17 17 # If applicable, add the following below this CDDL HEADER, with the
18 18 # fields enclosed by brackets "[]" replaced with your own identifying
19 19 # information: Portions Copyright [yyyy] [name of copyright owner]
20 20 #
21 21 # CDDL HEADER END
22 22 #
23 23 #
24 24 # Copyright 2015 OmniTI Computer Consulting, Inc. All rights reserved.
25 25 # Use is subject to license terms.
26 26 #
27 27
28 28 umask 022
29 29
30 30 #############################################################################
31 31 # functions.sh
32 32 #############################################################################
33 33 # Helper functions for building packages that should be common to all build
34 34 # scripts
35 35 #############################################################################
36 36
37 37 #############################################################################
38 38 # Process command line options
39 39 #############################################################################
40 40 process_opts() {
41 41 SCREENOUT=
42 42 FLAVOR=
43 43 OLDFLAVOR=
44 44 BUILDARCH=both
45 45 OLDBUILDARCH=
46 46 BATCH=
47 47 DEPVER=
48 48 while getopts "bpf:ha:d:" opt; do
49 49 case $opt in
50 50 h)
51 51 show_usage
52 52 exit
53 53 ;;
54 54 \?)
55 55 show_usage
56 56 exit 2
57 57 ;;
58 58 p)
59 59 SCREENOUT=1
60 60 ;;
61 61 b)
62 62 BATCH=1 # Batch mode - exit on error
63 63 ;;
64 64 f)
65 65 FLAVOR=$OPTARG
66 66 OLDFLAVOR=$OPTARG # Used to see if the script overrides the
67 67 # flavor
68 68 ;;
69 69 a)
70 70 BUILDARCH=$OPTARG
71 71 OLDBUILDARCH=$OPTARG # Used to see if the script overrides the
72 72 # BUILDARCH variable
73 73 if [[ "$BUILDARCH" != "32" && "$BUILDARCH" != "64" &&
74 74 "$BUILDARCH" != "both" ]]; then
75 75 echo "Invalid build architecture specified: $BUILDARCH"
76 76 show_usage
77 77 exit 2
78 78 fi
79 79 ;;
80 80 d)
81 81 DEPVER=$OPTARG
82 82 ;;
83 83 esac
84 84 done
85 85 }
86 86
87 87 #############################################################################
88 88 # Show usage information
89 89 #############################################################################
90 90 show_usage() {
91 91 echo "Usage: $0 [-b] [-p] [-f FLAVOR] [-h] [-a 32|64|both] [-d DEPVER]"
92 92 echo " -b : batch mode (exit on errors without asking)"
93 93 echo " -p : output all commands to the screen as well as log file"
94 94 echo " -f FLAVOR : build a specific package flavor"
95 95 echo " -h : print this help text"
96 96 echo " -a ARCH : build 32/64 bit only, or both (default: both)"
97 97 echo " -d DEPVER : specify an extra dependency version (no default)"
98 98 }
99 99
100 100 #############################################################################
101 101 # Log output of a command to a file
102 102 #############################################################################
103 103 logcmd() {
104 104 if [[ -z "$SCREENOUT" ]]; then
105 105 echo Running: "$@" >> $LOGFILE
106 106 "$@" >> $LOGFILE 2>&1
107 107 else
108 108 echo Running: "$@" | tee $LOGFILE
109 109 "$@" | tee $LOGFILE 2>&1
110 110 fi
111 111 }
112 112 logmsg() {
113 113 echo "$@" >> $LOGFILE
114 114 echo "$@"
115 115 }
116 116 logerr() {
117 117 # Print an error message and ask the user if they wish to continue
118 118 logmsg $@
119 119 if [[ -z $BATCH ]]; then
120 120 ask_to_continue "An Error occured in the build. "
121 121 else
122 122 exit 1
123 123 fi
124 124 }
125 125 ask_to_continue() {
126 126 # Ask the user if they want to continue or quit
127 127 echo -n "${1}Do you wish to continue anyway? (y/n) "
128 128 read
129 129 while [[ ! "$REPLY" =~ [yYnN] ]]; do
130 130 echo -n "continue? (y/n) "
131 131 read
132 132 done
133 133 if [[ "$REPLY" == "n" || "$REPLY" == "N" ]]; then
134 134 logmsg "===== Build aborted ====="
135 135 exit 1
136 136 fi
137 137 logmsg "===== User elected to continue after prompt. ====="
138 138 }
139 139
140 140 #############################################################################
141 141 # URL encoding for package names, at least
142 142 #############################################################################
143 143 # This isn't real URL encoding, just a couple of common substitutions
144 144 url_encode() {
145 145 [ $# -lt 1 ] && logerr "Not enough arguments to url_encode(). Expecting a string to encode."
146 146 local encoded="$1";
147 147 encoded=`echo $encoded | sed -e 's!/!%2F!g' -e 's!+!%2B!g'`
148 148 encoded=`echo $encoded | sed -e 's/%../_/g;'`
149 149 echo $encoded
150 150 }
151 151
152 152 #############################################################################
153 153 # Some initialization
154 154 #############################################################################
155 155 # Set the LANG to C as the assembler will freak out on unicode in headers
156 156 LANG=C
157 157 export LANG
158 158 # Determine what release we're running as that affects some versions of things
159 159 RELEASE=$(head -1 /etc/release | awk '{ print $3 }')
160 160 # Set the path - This can be overriden/extended in the build script
161 161 PATH="/usr/ccs/bin:/usr/bin:/usr/sbin:/usr/gnu/bin:/usr/sfw/bin"
162 162 case ${RELEASE:1} in
163 163 151004)
164 164 PATH="/opt/gcc-4.6.3/bin:$PATH"
165 165 GCC_CMD="/opt/gcc-4.6.3/bin/gcc"
166 166 GCC_PKG="developer/gcc46"
167 167 ;;
168 168 151006)
169 169 PATH="/opt/gcc-4.7.2/bin:$PATH"
170 170 GCC_CMD="/opt/gcc-4.7.2/bin/gcc"
171 171 GCC_PKG="developer/gcc47"
172 172 ;;
173 173 151008|151010|151012|151014)
174 174 PATH="/opt/gcc-4.8.1/bin:$PATH"
175 175 GCC_CMD="/opt/gcc-4.8.1/bin/gcc"
176 176 GCC_PKG="developer/gcc48"
177 177 ;;
178 178 151016)
179 179 PATH="/opt/gcc-5.1.0/bin:$PATH"
180 180 GCC_CMD="/opt/gcc-5.1.0/bin/gcc"
181 181 GCC_PKG="developer/gcc51"
182 182 ;;
183 183 *)
184 184 logerr "Release $RELEASE not supported for omniti-ms"
185 185 ;;
186 186 esac
187 187 export PATH
188 188 # The dir where this file is located - used for sourcing further files
189 189 MYDIR=$PWD/`dirname $BASH_SOURCE[0]`
190 190 # The dir where this file was sourced from - this will be the directory of the
191 191 # build script
192 192 SRCDIR=$PWD/`dirname $0`
193 193
194 194 #############################################################################
195 195 # Load configuration options
196 196 #############################################################################
197 197 . $MYDIR/config.sh
198 198 . $MYDIR/site.sh
199 199
200 200 # Platform information
201 201 SUNOSVER=`uname -r` # e.g. 5.11
202 202
203 203 if [[ -f $LOGFILE ]]; then
204 204 mv $LOGFILE $LOGFILE.1
205 205 fi
206 206 process_opts $@
207 207
208 208 BasicRequirements(){
209 209 local needed=""
210 210 [[ -x $GCC_CMD ]] || needed+=" $GCC_PKG"
211 211 [[ -x /usr/bin/ar ]] || needed+=" developer/object-file"
212 212 [[ -x /usr/bin/ld ]] || needed+=" developer/linker"
213 213 [[ -f /usr/lib/crt1.o ]] || needed+=" developer/library/lint"
214 214 [[ -x /usr/bin/gmake ]] || needed+=" developer/build/gnu-make"
215 215 [[ -f /usr/include/sys/types.h ]] || needed+=" system/header"
216 216 [[ -f /usr/include/math.h ]] || needed+=" system/library/math/header-math"
217 217 [[ -x /usr/bin/rsync ]] || needed+=" network/rsync"
218 218 if [[ -n "$needed" ]]; then
219 219 logmsg "You appear to be missing some basic build requirements."
220 220 logmsg "To fix this run:"
221 221 logmsg " "
222 222 logmsg " sudo pkg install$needed"
223 223 logerr
224 224 fi
225 225 }
226 226 BasicRequirements
227 227
228 228 #############################################################################
229 229 # Running as root is not safe
230 230 #############################################################################
231 231 if [[ "$UID" = "0" ]]; then
232 232 logerr "--- You cannot run this as root"
233 233 fi
234 234
235 235 #############################################################################
236 236 # Print startup message
237 237 #############################################################################
238 238 [[ -z "$NOBANNER" ]] && logmsg "===== Build started at `date` ====="
239 239 #############################################################################
240 240 # Initialization function
241 241 #############################################################################
242 242 init() {
243 243 # Print out current settings
244 244 logmsg "Package name: $PKG"
245 245
246 246 # In the ms.omniti.com repo, we want all pkg FMRIs to start with "omniti/"
247 247 FMRI_PREFIX=${PKG:0:7}
248 248 if [[ ! $FMRI_PREFIX = "omniti/" ]]; then
249 249 logerr "Package name should begin with \"omniti/\". Please change the value of PKG in the build script."
250 250 fi
251 251
252 252 # Selected flavor
253 253 if [[ -z "$FLAVOR" ]]; then
254 254 logmsg "Selected flavor: None (use -f to specify a flavor)"
255 255 else
256 256 logmsg "Selected Flavor: $FLAVOR"
257 257 fi
258 258 if [[ -n "$OLDFLAVOR" && "$OLDFLAVOR" != "$FLAVOR" ]]; then
259 259 logmsg "NOTICE - The flavor was overridden by the build script."
260 260 logmsg "The flavor specified on the command line was: $OLDFLAVOR"
261 261 fi
262 262 # Build arch
263 263 logmsg "Selected build arch: $BUILDARCH"
264 264 if [[ -n "$OLDBUILDARCH" && "$OLDBUILDARCH" != "$BUILDARCH" ]]; then
265 265 logmsg "NOTICE - The build arch was overridden by the build script."
266 266 logmsg "The build arch specified on the command line was: $OLDFLAVOR"
267 267 fi
268 268 # Extra dependency version
269 269 if [[ -z "$DEPVER" ]]; then
270 270 logmsg "Extra dependency: None (use -d to specify a version)"
271 271 else
272 272 logmsg "Extra dependency: $DEPVER"
273 273 fi
274 274 # Ensure SUMMARY and DESC are non-empty
275 275 if [[ -z "$SUMMARY" ]]; then
276 276 logerr "SUMMARY may not be empty. Please update your build script"
277 277 elif [[ -z "$DESC" ]]; then
278 278 logerr "DESC may not be empty. Please update your build script"
279 279 fi
280 280
281 281 # BUILDDIR can be used to manually specify what directory the program is
282 282 # built in (i.e. what the tarball extracts to). This defaults to the name
283 283 # and version of the program, which works in most cases.
284 284 if [[ -z $BUILDDIR ]]; then
285 285 BUILDDIR=$PROG-$VER
286 286 fi
287 287
288 288 RPATH=`echo $PKGSRVR | sed -e 's/^file:\/*/\//'`
289 289 if [[ "$RPATH" != "$PKGSRVR" ]]; then
290 290 if [[ ! -d $RPATH ]]; then
291 291 pkgrepo create $RPATH || \
292 292 logerr "Could not local repo"
293 293 pkgrepo add-publisher -s $RPATH $PKGPUBLISHER || \
294 294 logerr "Could not set publisher on repo"
295 295 fi
296 296 fi
297 297 pkgrepo get -s $PKGSRVR > /dev/null 2>&1 || \
298 298 logerr "The PKGSRVR ($PKGSRVR) isn't available. All is doomed."
299 299 verify_depends
300 300 }
301 301
302 302 #############################################################################
303 303 # Verify any dependencies
304 304 #############################################################################
305 305 verify_depends() {
306 306 logmsg "Verifying build dependencies"
307 307 [[ -z "$BUILD_DEPENDS_IPS" ]] && BUILD_DEPENDS_IPS=$BUILD_DEPENDS
308 308 for i in $BUILD_DEPENDS_IPS; do
309 309 # Trim indicators to get the true name (see make_package for details)
310 310 case ${i:0:1} in
311 311 \=|\?)
312 312 i=${i:1}
313 313 ;;
314 314 \-)
315 315 # If it's an exclude, we should error if it's installed rather than missing
316 316 i=${i:1}
317 317 pkg info $i > /dev/null 2<&1 &&
318 318 logerr "--- Excluded dependency $i cannot be installed with this package."
319 319 continue
320 320 ;;
321 321 esac
322 322 pkg info $i > /dev/null 2<&1 ||
323 323 logerr "--- Build dependency $i not found"
324 324 done
325 325 }
326 326
327 327 #############################################################################
328 328 # People that need this should call it explicitly
329 329 #############################################################################
330 330 run_autoconf() {
331 331 logmsg "Running autoconf"
332 332 pushd $TMPDIR/$BUILDDIR > /dev/null
333 333 logcmd autoconf || logerr "Failed to run autoconf"
334 334 popd > /dev/null
335 335 }
336 336
337 337 run_autogen() {
338 338 logmsg "Running autogen.sh"
339 339 pushd $TMPDIR/$BUILDDIR > /dev/null
340 340 CFLAGS="$CFLAGS32 $CFLAGS" \
341 341 CXXFLAGS="$CXXFLAGS32 $CXXFLAGS" \
342 342 CPPFLAGS="$CPPFLAGS32 $CPPFLAGS" \
343 343 LDFLAGS="$LDFLAGS32 $LDFLAGS" \
344 344 CC=$CC CXX=$CXX \
345 345 logcmd ./autogen.sh $CONFIGURE_OPTS_32 $CONFIGURE_OPTS_64 $CONFIGURE_OPTS || \
346 346 logerr "Failed to run autogen.sh"
347 347 popd > /dev/null
348 348 }
349 349
350 350 #############################################################################
351 351 # Stuff that needs to be done/set before we start building
352 352 #############################################################################
353 353 prep_build() {
354 354 logmsg "Preparing for build"
355 355
356 356 # Get the current date/time for the package timestamp
357 357 DATETIME=`TZ=UTC /usr/bin/date +"%Y%m%dT%H%M%SZ"`
358 358
359 359 logmsg "--- Creating temporary install dir"
360 360 # We might need to encode some special chars
361 361 PKGE=$(url_encode $PKG)
362 362 # For DESTDIR the '%' can cause problems for some install scripts
363 363 PKGD=${PKGE//%/_}
364 364 DESTDIR=$DTMPDIR/${PKGD}_pkg
365 365 if [[ -z $DONT_REMOVE_INSTALL_DIR ]]; then
366 366 logcmd chmod -R u+w $DESTDIR > /dev/null 2>&1
367 367 logcmd rm -rf $DESTDIR || \
368 368 logerr "Failed to remove old temporary install dir"
369 369 mkdir -p $DESTDIR || \
370 370 logerr "Failed to create temporary install dir"
371 371 fi
372 372 }
373 373
374 374 #############################################################################
375 375 # Applies patches contained in $PATCHDIR (default patches/)
376 376 #############################################################################
377 377 check_for_patches() {
378 378 if [[ -z $1 ]]; then
379 379 logmsg "Checking for patches in $PATCHDIR/"
380 380 else
381 381 logmsg "Checking for patches in $PATCHDIR/ ($1)"
382 382 fi
383 383 if [[ ! -d $SRCDIR/$PATCHDIR ]]; then
384 384 logmsg "--- No patches directory found"
385 385 return 1
386 386 fi
387 387 if [[ ! -f $SRCDIR/$PATCHDIR/series ]]; then
388 388 logmsg "--- No series file (list of patches) found"
389 389 return 1
390 390 fi
391 391 return 0
392 392 }
393 393
394 394 patch_source() {
395 395 if ! check_for_patches "in order to apply them"; then
396 396 logmsg "--- Not applying any patches"
397 397 else
398 398 logmsg "Applying patches"
399 399 # Read the series file for patch filenames
400 400 exec 3<"$SRCDIR/$PATCHDIR/series" # Open the series file with handle 3
401 401 pushd $TMPDIR/$BUILDDIR > /dev/null
402 402 while read LINE <&3 ; do
403 403 # Split Line into filename+args
404 404 patch_file $LINE
405 405 done
406 406 popd > /dev/null
407 407 exec 3<&- # Close the file
408 408 fi
409 409 }
410 410
411 411 patch_file() {
412 412 FILENAME=$1
413 413 shift
414 414 ARGS=$@
415 415 if [[ ! -f $SRCDIR/$PATCHDIR/$FILENAME ]]; then
416 416 logmsg "--- Patch file $FILENAME not found. Skipping patch."
417 417 return
418 418 fi
419 419 # Note - if -p is specified more than once, then the last one takes
420 420 # precedence, so we can specify -p1 at the beginning to default to -p1.
421 421 # -t - don't ask questions
422 422 # -N - don't try to apply a reverse patch
423 423 if ! logcmd $PATCH -p1 -t -N $ARGS < $SRCDIR/$PATCHDIR/$FILENAME; then
424 424 logerr "--- Patch $FILENAME failed"
425 425 else
426 426 logmsg "--- Applied patch $FILENAME"
427 427 fi
428 428 }
429 429
430 430 #############################################################################
431 431 # Download source from git
432 432 #############################################################################
433 433 # Parameters
434 434 # $1 - repos
435 435 # $2 - branch
436 436 # $3 - commit
437 437 # $4 - version
438 438 #
439 439 # E.g.
440 440 # download_git https://github.com/omniti-labs/nab master HEAD
441 441 download_git() {
442 442 local REPOS=$1
443 443 local BRANCH=$2
444 444 local COMMIT=$3
445 445 local VERSION=$4
446 446 if [ -n "$BRANCH" ]; then
447 447 BRANCH="master"
448 448 fi
449 449 if [ -n "$COMMIT" ]; then
450 450 COMMIT="HEAD"
451 451 fi
452 452 pushd $TMPDIR > /dev/null
453 453 logmsg "Checking for source directory"
454 454 if [ -d $BUILDDIR ]; then
455 455 logmsg "--- removing previous source checkout"
456 456 logcmd rm -rf $BUILDDIR
457 457 fi
458 458 logmsg "Checking code out from git repo"
459 459 logcmd $GIT clone $REPOS $BUILDDIR
460 460 pushd $BUILDDIR > /dev/null
461 461 if [ -n "$COMMIT" ]; then
462 462 logcmd $GIT checkout $COMMIT
463 463 fi
464 464 if [ -n "$VERSION" ]; then
465 465 VER=$VERSION
466 466 VERHUMAN=$VER
467 467 else
468 468 REV=`$GIT log -1 --format=format:%at`
469 469 REVDATE=`echo $REV | gawk '{ print strftime("%c %Z",$1) }'`
470 470 VER=0.1.$REV
471 471 VERHUMAN="checkout from $REVDATE"
472 472 fi
473 473 popd > /dev/null
474 474 popd > /dev/null
475 475 }
476 476
477 477 #############################################################################
478 478 # Download source tarball if needed and extract it
479 479 #############################################################################
480 480 # Parameters
481 481 # $1 - directory name on the server
482 482 # $2 - program name
483 483 # $3 - program version
484 484 # $4 - target directory
485 485 #
486 486 # E.g.
487 487 # download_source myprog myprog 1.2.3 will try:
488 488 # http://mirrors.omniti.com/myprog/myprog-1.2.3.tar.gz
489 489 download_source() {
490 490 local DLDIR=$1
491 491 local PROG=$2
492 492 local VER=$3
493 493 local TARGETDIR=$4
494 494 if [[ -z $VER ]]; then
495 495 local ARCHIVEPREFIX=$PROG
496 496 else
497 497 local ARCHIVEPREFIX=$PROG-$VER
498 498 fi
499 499 if [[ -z $TARGETDIR ]]; then
500 500 # Default to $TMPDIR if no output dir specified
501 501 TARGETDIR=$TMPDIR
502 502 fi
503 503 # Create TARGETDIR if it doesn't exist
504 504 if [[ ! -d $TARGETDIR ]]; then
505 505 logmsg "Specified target directory $TARGETDIR does not exist. Creating it now."
506 506 logcmd mkdir -p $TARGETDIR
507 507 fi
508 508 pushd $TARGETDIR > /dev/null
509 509 logmsg "Checking for source directory"
510 510 if [ -d $BUILDDIR ]; then
511 511 logmsg "--- Source directory found"
512 512 if check_for_patches "to see if we need to remove the source dir"; then
513 513 logmsg "--- Patches are present, removing source directory"
514 514 logcmd rm -rf $BUILDDIR || \
515 515 logerr "Failed to remove source directory"
516 516 else
517 517 logmsg "--- Patches are not present, keeping source directory"
518 518 popd > /dev/null
519 519 return
520 520 fi
521 521 else
522 522 logmsg "--- Source directory not found"
523 523 fi
524 524
525 525 # If we reach this point, the source directory was either not found, or it
526 526 # was removed due to patches being present.
527 527 logmsg "Checking for $PROG source archive"
528 528 find_archive $ARCHIVEPREFIX FILENAME
529 529 if [[ "$FILENAME" == "" ]]; then
530 530 # Try all possible archive names
531 531 logmsg "--- Archive not found."
532 532 logmsg "Downloading archive"
533 533 URLPREFIX=http://$MIRROR/$DLDIR/$ARCHIVEPREFIX
534 534 $WGET -a $LOGFILE $URLPREFIX.tar.gz || \
535 535 $WGET -a $LOGFILE $URLPREFIX.tar.bz2 || \
536 536 $WGET -a $LOGFILE $URLPREFIX.tar.xz || \
537 537 $WGET -a $LOGFILE $URLPREFIX.tgz || \
538 538 $WGET -a $LOGFILE $URLPREFIX.tbz || \
539 539 $WGET -a $LOGFILE $URLPREFIX.tar || \
540 540 logerr "--- Failed to download file"
541 541 find_archive $ARCHIVEPREFIX FILENAME
542 542 if [[ "$FILENAME" == "" ]]; then
543 543 logerr "Unable to find downloaded file."
544 544 fi
545 545 else
546 546 logmsg "--- $PROG source archive found"
547 547 fi
548 548 # Extract the archive
549 549 logmsg "Extracting archive: $FILENAME"
550 550 if ! logcmd extract_archive $FILENAME; then
551 551 logerr "--- Unable to extract archive."
552 552 fi
553 553 # Make sure the archive actually extracted some source where we expect
554 554 if [[ ! -d $BUILDDIR ]]; then
555 555 logerr "--- Extracted source is not in the expected location" \
556 556 " ($BUILDDIR)"
557 557 fi
558 558 popd > /dev/null
559 559 }
560 560
561 561 # Finds an existing archive and stores its value in a variable whose name
562 562 # is passed as a second parameter
563 563 # Example: find_archive myprog-1.2.3 FILENAME
564 564 # Stores myprog-1.2.3.tar.gz in $FILENAME
565 565 find_archive() {
566 566 FILES=`ls $1.{tar.bz2,tar.gz,tar.xz,tgz,tbz,tar} 2>/dev/null`
567 567 FILES=${FILES%% *} # Take only the first filename returned
568 568 # This dereferences the second parameter passed
569 569 eval "$2=\"$FILES\""
570 570 }
571 571
572 572 # Extracts an archive regardless of its extension
573 573 extract_archive() {
574 574 if [[ ${1: -7} == ".tar.gz" || ${1: -4} == ".tgz" ]]; then
575 575 $GZIP -dc $1 | $TAR xvf -
576 576 elif [[ ${1: -8} == ".tar.bz2" || ${1: -4} == ".tbz" ]]; then
577 577 $BUNZIP2 -dc $1 | $TAR xvf -
578 578 elif [[ ${1: -7} == ".tar.xz" ]]; then
579 579 $XZCAT $1 | $TAR xvf -
580 580 elif [[ ${1: -4} == ".tar" ]]; then
581 581 $TAR xvf $1
582 582 else
583 583 return 1
584 584 fi
585 585 }
586 586
587 587 #############################################################################
588 588 # Make the package
589 589 #############################################################################
590 590 make_package() {
591 591 logmsg "Making package"
592 592 PKGSEND=/usr/bin/pkgsend
593 593 PKGDEPEND=/usr/bin/pkgdepend
594 594 PKGMOGRIFY=/usr/bin/pkgmogrify
595 595 PKGFMT=/usr/bin/pkgfmt
596 596 P5M_INT=$TMPDIR/${PKGE}.p5m.int
597 597 P5M_FINAL=$TMPDIR/${PKGE}.p5m
598 598 GLOBAL_MOG_FILE=$MYDIR/global-transforms.mog
599 599 MY_MOG_FILE=$TMPDIR/${PKGE}.mog
600 600
601 601 ## Strip leading zeros in version components.
602 602 VER=`echo $VER | sed -e 's/\.0*\([1-9]\)/.\1/g;'`
603 603 FMRI="${PKG}@${VER},${SUNOSVER}-${PVER}"
604 604 if [[ -n "$DESTDIR" ]]; then
605 605 logmsg "--- Generating package manifest from $DESTDIR"
606 606 logmsg "------ Running: $PKGSEND generate $DESTDIR > $P5M_INT"
607 607 $PKGSEND generate $DESTDIR > $P5M_INT || \
608 608 logerr "------ Failed to generate manifest"
609 609 else
610 610 logmsg "--- Looks like a meta-package. Creating empty manifest"
611 611 logcmd touch $P5M_INT || \
612 612 logerr "------ Failed to create empty manifest"
613 613 fi
614 614 logmsg "--- Generating package metadata"
615 615 echo "set name=pkg.fmri value=$FMRI" > $MY_MOG_FILE
616 616 # Set human-readable version, if it exists
617 617 if [[ -n "$VERHUMAN" ]]; then
618 618 logmsg "------ Setting human-readable version"
619 619 echo "set name=pkg.human-version value=\"$VERHUMAN\"" >> $MY_MOG_FILE
620 620 fi
621 621 echo "set name=pkg.summary value=\"$SUMMARY\"" >> $MY_MOG_FILE
622 622 echo "set name=pkg.descr value=\"$DESC\"" >> $MY_MOG_FILE
623 623 echo "set name=publisher value=\"sa@omniti.com\"" >> $MY_MOG_FILE
624 624 if [[ -n "$DEPENDS_IPS" ]]; then
625 625 logmsg "------ Adding dependencies"
626 626 for i in $DEPENDS_IPS; do
627 627 # IPS dependencies have multiple types, of which we care about four:
628 628 # require, optional, incorporate, exclude
629 629 # For backward compatibility, assume no indicator means type=require
630 630 # FMRI attributes are implicitly rooted so we don't have to prefix
631 631 # 'pkg:/' or worry about ambiguities in names
632 632 local DEPTYPE="require"
633 633 case ${i:0:1} in
634 634 \=)
635 635 DEPTYPE="incorporate"
636 636 i=${i:1}
637 637 ;;
638 638 \?)
639 639 DEPTYPE="optional"
640 640 i=${i:1}
641 641 ;;
642 642 \-)
643 643 DEPTYPE="exclude"
644 644 i=${i:1}
645 645 ;;
646 646 esac
647 647 echo "depend type=$DEPTYPE fmri=${i}" >> $MY_MOG_FILE
648 648 done
|
↓ open down ↓ |
648 lines elided |
↑ open up ↑ |
649 649 fi
650 650 if [[ -f $SRCDIR/local.mog ]]; then
651 651 LOCAL_MOG_FILE=$SRCDIR/local.mog
652 652 fi
653 653 logmsg "--- Applying transforms"
654 654 $PKGMOGRIFY $P5M_INT $MY_MOG_FILE $GLOBAL_MOG_FILE $LOCAL_MOG_FILE $* > $P5M_INT.stage1
655 655 if [[ -z "$NO_AUTO_DEPENDS" ]]; then
656 656 $PKGDEPEND generate -d $DESTDIR $P5M_INT.stage1 > $P5M_INT.dep
657 657 $PKGDEPEND resolve $P5M_INT.dep
658 658 cat $P5M_INT.dep.res >> $P5M_INT.stage1
659 - # Use a "require" dependency on the 'entire' metapackage so that
659 + # Use an "optional" dependency on the 'entire' metapackage so that
660 660 # we don't let a later version for an unsupported early OmniOS install.
661 661 # For example:
662 662 # foo@1.9-0.151006 exists.
663 663 # We update it to:
664 664 # foo@1.10-0.151014
665 - # and in both cases make it *require* entire@11-0.151XXX as appropriate.
665 + # and in both cases make it *lock* to entire@11-0.151XXX as appropriate.
666 666 # So foo@1.10 won't install on any OmniOS older than r151014.
667 667 # This used to be *incorporate* but that put both a floor AND a ceiling
668 668 # on the revision of OmniOS, and having just a floor is sufficient
669 669 # thanks to illumos's versioned libraries and backward compatibility.
670 - echo "depend fmri=pkg:/entire@11-$PVER type=require" >> $P5M_INT.stage1
670 + # If a user uninstalls "entire", they go beyond the realm of support.
671 + # Some users can do this safely (developers who use onu(1ONBLD), e.g.).
672 + echo "depend fmri=pkg:/entire@11-$PVER type=optional" >> $P5M_INT.stage1
671 673 fi
672 674 $PKGFMT -u < $P5M_INT.stage1 > $P5M_FINAL
673 675 logmsg "--- Publishing package to $PKGSRVR"
674 676 if [[ -z "$BATCH" ]]; then
675 677 ask_to_continue "Last chance to sanity-check before publication! "
676 678 fi
677 679 if [[ -n "$DESTDIR" ]]; then
678 680 logcmd $PKGSEND -s $PKGSRVR publish -d $DESTDIR -d $TMPDIR/$BUILDDIR \
679 681 -d $SRCDIR -T \*.py $P5M_FINAL || \
680 682 logerr "------ Failed to publish package"
681 683 else
682 684 # If we're a metapackage (no DESTDIR) then there are no directories to check
683 685 logcmd $PKGSEND -s $PKGSRVR publish $P5M_FINAL || \
684 686 logerr "------ Failed to publish package"
685 687 fi
686 688 logmsg "--- Published $FMRI"
687 689 }
688 690
689 691 #############################################################################
690 692 # Make isaexec stub binaries
691 693 #############################################################################
692 694 make_isa_stub() {
693 695 logmsg "Making isaexec stub binaries"
694 696 [[ -z $ISAEXEC_DIRS ]] && ISAEXEC_DIRS="bin sbin"
695 697 for DIR in $ISAEXEC_DIRS; do
696 698 if [[ -d $DESTDIR$PREFIX/$DIR ]]; then
697 699 logmsg "--- $DIR"
698 700 pushd $DESTDIR$PREFIX/$DIR > /dev/null
699 701 make_isaexec_stub_arch $ISAPART
700 702 make_isaexec_stub_arch $ISAPART64
701 703 popd > /dev/null
702 704 fi
703 705 done
704 706 }
705 707
706 708 make_isaexec_stub_arch() {
707 709 for file in $1/*; do
708 710 [[ -f $file ]] || continue # Deals with empty dirs & non-files
709 711 # Check to make sure we don't have a script
710 712 read -n 5 < $file
711 713 file=`echo $file | sed -e "s/$1\///;"`
712 714 # Skip if we already made a stub for this file
713 715 [[ -f $file ]] && continue
714 716 # Only copy non-binaries if we set NOSCRIPTSTUB
715 717 if [[ $REPLY != $'\177'ELF && -n "$NOSCRIPTSTUB" ]]; then
716 718 logmsg "------ Non-binary file: $file - copying instead"
717 719 cp $1/$file .
718 720 chmod +x $file
719 721 continue
720 722 fi
721 723 logmsg "------ $file"
722 724 # Run the makeisa.sh script
723 725 CC=$CC \
724 726 logcmd $MYDIR/makeisa.sh $PREFIX/$DIR $file || \
725 727 logerr "--- Failed to make isaexec stub for $DIR/$file"
726 728 done
727 729 }
728 730
729 731 #############################################################################
730 732 # Build commands
731 733 #############################################################################
732 734 # Notes:
733 735 # - These methods are designed to work in the general case.
734 736 # - You can set CFLAGS/LDFLAGS (and CFLAGS32/CFLAGS64 for arch specific flags)
735 737 # - Configure flags are set in CONFIGURE_OPTS_32 and CONFIGURE_OPTS_64 with
736 738 # defaults set in config.sh. You can append to these variables or replace
737 739 # them if the defaults don't work for you.
738 740 # - In the normal case, where you just want to add --enable-feature, set
739 741 # CONFIGURE_OPTS. This will be appended to the end of CONFIGURE_CMD
740 742 # for both 32 and 64 bit builds.
741 743 # - Any of these functions can be overriden in your build script, so if
742 744 # anything here doesn't apply to the build process for your application,
743 745 # just override that function with whatever code you need. The build
744 746 # function itself can be overriden if the build process doesn't fit into a
745 747 # configure, make, make install pattern.
746 748 #############################################################################
747 749 make_clean() {
748 750 logmsg "--- make (dist)clean"
749 751 logcmd $MAKE distclean || \
750 752 logcmd $MAKE clean || \
751 753 logmsg "--- *** WARNING *** make (dist)clean Failed"
752 754 }
753 755
754 756 configure32() {
755 757 logmsg "--- configure (32-bit)"
756 758 CFLAGS="$CFLAGS32 $CFLAGS" \
757 759 CXXFLAGS="$CXXFLAGS32 $CXXFLAGS" \
758 760 CPPFLAGS="$CPPFLAGS32 $CPPFLAGS" \
759 761 LDFLAGS="$LDFLAGS32 $LDFLAGS" \
760 762 CC=$CC CXX=$CXX \
761 763 logcmd $CONFIGURE_CMD $CONFIGURE_OPTS_32 \
762 764 $CONFIGURE_OPTS || \
763 765 logerr "--- Configure failed"
764 766 }
765 767
766 768 configure64() {
767 769 logmsg "--- configure (64-bit)"
768 770 CFLAGS="$CFLAGS64 $CFLAGS" \
769 771 CXXFLAGS="$CXXFLAGS64 $CXXFLAGS" \
770 772 CPPFLAGS="$CPPFLAGS64 $CPPFLAGS" \
771 773 LDFLAGS="$LDFLAGS64 $LDFLAGS" \
772 774 CC=$CC CXX=$CXX \
773 775 logcmd $CONFIGURE_CMD $CONFIGURE_OPTS_64 \
774 776 $CONFIGURE_OPTS || \
775 777 logerr "--- Configure failed"
776 778 }
777 779
778 780 make_prog() {
779 781 [[ -n $NO_PARALLEL_MAKE ]] && MAKE_JOBS=""
780 782 logmsg "--- make"
781 783 logcmd $MAKE $MAKE_JOBS || \
782 784 logerr "--- Make failed"
783 785 }
784 786
785 787 make_prog32() {
786 788 make_prog
787 789 }
788 790
789 791 make_prog64() {
790 792 make_prog
791 793 }
792 794
793 795 make_install() {
794 796 logmsg "--- make install"
795 797 logcmd $MAKE DESTDIR=${DESTDIR} install || \
796 798 logerr "--- Make install failed"
797 799 }
798 800
799 801 make_install32() {
800 802 make_install
801 803 }
802 804
803 805 make_install64() {
804 806 make_install
805 807 }
806 808
807 809 make_pure_install() {
808 810 # Make pure_install for perl modules so they don't touch perllocal.pod
809 811 logmsg "--- make install (pure)"
810 812 logcmd $MAKE DESTDIR=${DESTDIR} pure_install || \
811 813 logerr "--- Make pure_install failed"
812 814 }
813 815
814 816 make_param() {
815 817 logmsg "--- make $@"
816 818 logcmd $MAKE "$@" || \
817 819 logerr "--- $MAKE $1 failed"
818 820 }
819 821
820 822 # Helper function that can be called by build scripts to make in a specific dir
821 823 make_in() {
822 824 [[ -z $1 ]] && logerr "------ Make in dir failed - no dir specified"
823 825 [[ -n $NO_PARALLEL_MAKE ]] && MAKE_JOBS=""
824 826 logmsg "------ make in $1"
825 827 logcmd $MAKE $MAKE_JOBS -C $1 || \
826 828 logerr "------ Make in $1 failed"
827 829 }
828 830
829 831 # Helper function that can be called by build scripts to install in a specific
830 832 # dir
831 833 make_install_in() {
832 834 [[ -z $1 ]] && logerr "--- Make install in dir failed - no dir specified"
833 835 logmsg "------ make install in $1"
834 836 logcmd $MAKE -C $1 DESTDIR=${DESTDIR} install || \
835 837 logerr "------ Make install in $1 failed"
836 838 }
837 839
838 840 build() {
839 841 if [[ $BUILDARCH == "32" || $BUILDARCH == "both" ]]; then
840 842 build32
841 843 fi
842 844 if [[ $BUILDARCH == "64" || $BUILDARCH == "both" ]]; then
843 845 build64
844 846 fi
845 847 }
846 848
847 849 build32() {
848 850 pushd $TMPDIR/$BUILDDIR > /dev/null
849 851 logmsg "Building 32-bit"
850 852 export ISALIST="$ISAPART"
851 853 make_clean
852 854 configure32
853 855 make_prog32
854 856 make_install32
855 857 popd > /dev/null
856 858 unset ISALIST
857 859 export ISALIST
858 860 }
859 861
860 862 build64() {
861 863 pushd $TMPDIR/$BUILDDIR > /dev/null
862 864 logmsg "Building 64-bit"
863 865 make_clean
864 866 configure64
865 867 make_prog64
866 868 make_install64
867 869 popd > /dev/null
868 870 }
869 871
870 872 #############################################################################
871 873 # Build function for python programs
872 874 #############################################################################
873 875 pre_python_32() {
874 876 logmsg "prepping 32bit python build"
875 877 }
876 878 pre_python_64() {
877 879 logmsg "prepping 64bit python build"
878 880 }
879 881 python_build() {
880 882 if [[ -z "$PYTHON" ]]; then logerr "PYTHON not set"; fi
881 883 if [[ -z "$PYTHONPATH" ]]; then logerr "PYTHONPATH not set"; fi
882 884 if [[ -z "$PYTHONLIB" ]]; then logerr "PYTHONLIB not set"; fi
883 885 logmsg "Building using python setup.py"
884 886 pushd $TMPDIR/$BUILDDIR > /dev/null
885 887
886 888 if [[ $BUILDARCH == "32" || $BUILDARCH == "both" ]]; then
887 889 buildpython32
888 890 fi
889 891 if [[ $BUILDARCH == "64" || $BUILDARCH == "both" ]]; then
890 892 buildpython64
891 893 fi
892 894 popd > /dev/null
893 895 }
894 896
895 897 buildpython32() {
896 898 ISALIST=i386
897 899 export ISALIST
898 900 pre_python_32
899 901 logmsg "--- setup.py (32) build"
900 902 CFLAGS="$CFLAGS32 $CFLAGS" \
901 903 CXXFLAGS="$CXXFLAGS32 $CXXFLAGS" \
902 904 CPPFLAGS="$CPPFLAGS32 $CPPFLAGS" \
903 905 LDFLAGS="$LDFLAGS32 $LDFLAGS" \
904 906 CC=$CC CXX=$CXX \
905 907 logcmd $PYTHON ./setup.py build ||
906 908 logerr "--- build failed"
907 909 logmsg "--- setup.py (32) install"
908 910 logcmd $PYTHON \
909 911 ./setup.py install --root=$DESTDIR ||
910 912 logerr "--- install failed"
911 913 }
912 914
913 915 buildpython64(){
914 916 ISALIST="amd64 i386"
915 917 export ISALIST
916 918 pre_python_64
917 919 logmsg "--- setup.py (64) build"
918 920 CFLAGS="$CFLAGS64 $CFLAGS" \
919 921 CXXFLAGS="$CXXFLAGS64 $CXXFLAGS" \
920 922 CPPFLAGS="$CPPFLAGS64 $CPPFLAGS" \
921 923 LDFLAGS="$LDFLAGS64 $LDFLAGS" \
922 924 CC=$CC CXX=$CXX \
923 925 logcmd $PYTHON ./setup.py build ||
924 926 logerr "--- build failed"
925 927 logmsg "--- setup.py (64) install"
926 928 logcmd $PYTHON \
927 929 ./setup.py install --root=$DESTDIR ||
928 930 logerr "--- install failed"
929 931 }
930 932
931 933 #############################################################################
932 934 # Build/test function for perl modules
933 935 #############################################################################
934 936 # Detects whether to use Build.PL or Makefile.PL
935 937 # Note: Build.PL probably needs Module::Build installed
936 938 #############################################################################
937 939 vendorizeperl() {
938 940 logcmd mv $DESTDIR/usr/perl5/lib/site_perl $DESTDIR/usr/perl5/vendor_perl || logerr "can't move to vendor_perl"
939 941 logcmd mkdir -p $DESTDIR/usr/perl5/${DEPVER}
940 942 logcmd mv $DESTDIR/usr/perl5/man $DESTDIR/usr/perl5/${DEPVER}/man || logerr "can't move perl man"
941 943 }
942 944
943 945 buildperl() {
944 946 if [[ -f $SRCDIR/${PROG}-${VER}.env ]]; then
945 947 logmsg "Sourcing environment file: $SRCDIR/${PROG}-${VER}.env"
946 948 source $SRCDIR/${PROG}-${VER}.env
947 949 fi
948 950 if [[ $BUILDARCH == "32" || $BUILDARCH == "both" ]]; then
949 951 buildperl32
950 952 fi
951 953 if [[ $BUILDARCH == "64" || $BUILDARCH == "both" ]]; then
952 954 buildperl64
953 955 fi
954 956 }
955 957
956 958 buildperl32() {
957 959 if [[ -f $SRCDIR/${PROG}-${VER}.env32 ]]; then
958 960 logmsg "Sourcing environment file: $SRCDIR/${PROG}-${VER}.env32"
959 961 source $SRCDIR/${PROG}-${VER}.env32
960 962 fi
961 963 pushd $TMPDIR/$BUILDDIR > /dev/null
962 964 logmsg "Building 32-bit"
963 965 export ISALIST="$ISAPART"
964 966 local OPTS
965 967 OPTS=${MAKEFILE_OPTS//_ARCH_/}
966 968 OPTS=${OPTS//_ARCHBIN_/$ISAPART}
967 969 if [[ -f Makefile.PL ]]; then
968 970 make_clean
969 971 makefilepl32 $OPTS
970 972 make_prog
971 973 [[ -n $PERL_MAKE_TEST ]] && make_param test
972 974 make_pure_install
973 975 elif [[ -f Build.PL ]]; then
974 976 build_clean
975 977 buildpl32 $OPTS
976 978 build_prog
977 979 [[ -n $PERL_MAKE_TEST ]] && build_test
978 980 build_install
979 981 fi
980 982 popd > /dev/null
981 983 unset ISALIST
982 984 export ISALIST
983 985 }
984 986
985 987 buildperl64() {
986 988 if [[ -f $SRCDIR/${PROG}-${VER}.env64 ]]; then
987 989 logmsg "Sourcing environment file: $SRCDIR/${PROG}-${VER}.env64"
988 990 source $SRCDIR/${PROG}-${VER}.env64
989 991 fi
990 992 pushd $TMPDIR/$BUILDDIR > /dev/null
991 993 logmsg "Building 64-bit"
992 994 local OPTS
993 995 OPTS=${MAKEFILE_OPTS//_ARCH_/$ISAPART64}
994 996 OPTS=${OPTS//_ARCHBIN_/$ISAPART64}
995 997 if [[ -f Makefile.PL ]]; then
996 998 make_clean
997 999 makefilepl64 $OPTS
998 1000 make_prog
999 1001 [[ -n $PERL_MAKE_TEST ]] && make_param test
1000 1002 make_pure_install
1001 1003 elif [[ -f Build.PL ]]; then
1002 1004 build_clean
1003 1005 buildpl64 $OPTS
1004 1006 build_prog
1005 1007 [[ -n $PERL_MAKE_TEST ]] && build_test
1006 1008 build_install
1007 1009 fi
1008 1010 popd > /dev/null
1009 1011 }
1010 1012
1011 1013 makefilepl32() {
1012 1014 logmsg "--- Makefile.PL 32-bit"
1013 1015 logcmd $PERL32 Makefile.PL PREFIX=$PREFIX $@ ||
1014 1016 logerr "Failed to run Makefile.PL"
1015 1017 }
1016 1018
1017 1019 makefilepl64() {
1018 1020 logmsg "--- Makefile.PL 64-bit"
1019 1021 logcmd $PERL64 Makefile.PL PREFIX=$PREFIX $@ ||
1020 1022 logerr "Failed to run Makefile.PL"
1021 1023 }
1022 1024
1023 1025 buildpl32() {
1024 1026 logmsg "--- Build.PL 32-bit"
1025 1027 logcmd $PERL32 Build.PL prefix=$PREFIX $@ ||
1026 1028 logerr "Failed to run Build.PL"
1027 1029 }
1028 1030
1029 1031 buildpl64() {
1030 1032 logmsg "--- Build.PL 64-bit"
1031 1033 logcmd $PERL64 Build.PL prefix=$PREFIX $@ ||
1032 1034 logerr "Failed to run Build.PL"
1033 1035 }
1034 1036
1035 1037 build_clean() {
1036 1038 logmsg "--- Build (dist)clean"
1037 1039 logcmd ./Build distclean || \
1038 1040 logcmd ./Build clean || \
1039 1041 logmsg "--- *** WARNING *** make (dist)clean Failed"
1040 1042 }
1041 1043
1042 1044 build_prog() {
1043 1045 logmsg "--- Build"
1044 1046 logcmd ./Build ||
1045 1047 logerr "Build failed"
1046 1048 }
1047 1049
1048 1050 build_test() {
1049 1051 logmsg "--- Build test"
1050 1052 logcmd ./Build test ||
1051 1053 logerr "Build test failed"
1052 1054 }
1053 1055
1054 1056 build_install() {
1055 1057 logmsg "--- Build install"
1056 1058 logcmd ./Build pure_install --destdir=$DESTDIR || \
1057 1059 logmsg "Build install failed"
1058 1060 }
1059 1061
1060 1062 test_if_core() {
1061 1063 logmsg "Testing whether $MODNAME is in core"
1062 1064 logmsg "--- Ensuring ${PKG} is not installed"
1063 1065 if logcmd pkg info ${PKG}; then
1064 1066 logerr "------ Package ${PKG} appears to be installed. Please uninstall it."
1065 1067 else
1066 1068 logmsg "------ Not installed, good."
1067 1069 fi
1068 1070 if logcmd $PERL32 -M$MODNAME -e '1'; then
1069 1071 # Module is in core, don't create a package
1070 1072 logmsg "--- Module is in core for Perl $DEPVER. Not creating a package."
1071 1073 exit 0
1072 1074 else
1073 1075 logmsg "--- Module is not in core for Perl $DEPVER. Continuing with build."
1074 1076 fi
1075 1077 }
1076 1078
1077 1079 #############################################################################
1078 1080 # NPM build for node.js modules
1079 1081 #############################################################################
1080 1082 build_npm() {
1081 1083 logmsg "Building module with npm"
1082 1084 [[ -n "$NPM" ]] || NPM=/opt/omni/bin/npm
1083 1085 pushd $TMPDIR > /dev/null
1084 1086 if [[ -d node_modules ]]; then
1085 1087 logcmd rm -rf node_modules
1086 1088 fi
1087 1089 logcmd $NPM install ${PROG}@${VER} --ws:verbose || \
1088 1090 logerr "--- npm build failed"
1089 1091 logmsg "Installing module into $DESTDIR"
1090 1092 logcmd mkdir -p $DESTDIR$PREFIX/lib/node || \
1091 1093 logerr "--- Unable to create destination directory"
1092 1094 logcmd rsync -a node_modules/ $DESTDIR$PREFIX/lib/node/ || \
1093 1095 logerr "--- Unable to copy files to destination directory"
1094 1096 popd > /dev/null
1095 1097 }
1096 1098
1097 1099 #############################################################################
1098 1100 # Scan the destination install and strip the non-stipped ELF objects
1099 1101 #############################################################################
1100 1102 strip_install() {
1101 1103 logmsg "Stripping installation"
1102 1104 pushd $DESTDIR > /dev/null || logerr "Cannot change to installation directory"
1103 1105 while read file
1104 1106 do
1105 1107 if [[ "$1" = "-x" ]]; then
1106 1108 ACTION=$(file $file | grep ELF | egrep -v "(, stripped|debugging)")
1107 1109 else
1108 1110 ACTION=$(file $file | grep ELF | grep "not stripped")
1109 1111 fi
1110 1112 if [[ -n "$ACTION" ]]; then
1111 1113 logmsg "------ stripping $file"
1112 1114 MODE=$(stat -c %a "$file")
1113 1115 logcmd chmod 644 "$file" || logerr "chmod failed: $file"
1114 1116 logcmd strip $* "$file" || logerr "strip failed: $file"
1115 1117 logcmd chmod $MODE "$file" || logerr "chmod failed: $file"
1116 1118 fi
1117 1119 done < <(find . -depth -type f)
1118 1120 popd > /dev/null
1119 1121 }
1120 1122
1121 1123 #############################################################################
1122 1124 # Clean up and print Done message
1123 1125 #############################################################################
1124 1126 clean_up() {
1125 1127 logmsg "Cleaning up"
1126 1128 if [[ -z $DONT_REMOVE_INSTALL_DIR ]]; then
1127 1129 logmsg "--- Removing temporary install directory $DESTDIR"
1128 1130 logcmd chmod -R u+w $DESTDIR > /dev/null 2>&1
1129 1131 logcmd rm -rf $DESTDIR || \
1130 1132 logerr "Failed to remove temporary install directory"
1131 1133 logmsg "--- Cleaning up temporary manifest and transform files"
1132 1134 logcmd rm -f $P5M_INT $P5M_FINAL $MY_MOG_FILE || \
1133 1135 logerr "Failed to remove temporary manifest and transform files"
1134 1136 logmsg "Done."
1135 1137 fi
1136 1138 }
1137 1139
1138 1140 #############################################################################
1139 1141 # Helper function that will let you save a predefined function so you can
1140 1142 # override it and call it later
1141 1143 #############################################################################
1142 1144 save_function() {
1143 1145 local ORIG_FUNC=$(declare -f $1)
1144 1146 local NEWNAME_FUNC="$2${ORIG_FUNC#$1}"
1145 1147 eval "$NEWNAME_FUNC"
1146 1148 }
1147 1149
1148 1150 # Vim hints
1149 1151 # vim:ts=4:sw=4:et:
|
↓ open down ↓ |
469 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX