Experimental package creation tool for MinGW.org
リビジョン | ab99dcb2790314d6dd9a4eb31cfc11926ca57dfe (tree) |
---|---|
日時 | 2022-03-06 07:38:46 |
作者 | Keith Marshall <keith@user...> |
コミッター | Keith Marshall |
Improve source directory identification mechanisms.
* src/modules/pkgspec.sh (initialize_abs_srcdir, abs_srcdir): New
functions; implement them to identify, and report source path name.
(pkgspec_from_srcdir): Do not require the basename from...
(PACKAGE_ABS_SRCDIR): ...this; it may not be defined, whereas...
(PACKAGE_SRCDIR): ...this is, and is sufficient.
@@ -9,7 +9,7 @@ | ||
9 | 9 | # $Id$ |
10 | 10 | # |
11 | 11 | # Written by Keith Marshall <keith@users.osdn.me> |
12 | -# Copyright (C) 2011-2014, 2017, 2018, 2020, MinGW.OSDN Project | |
12 | +# Copyright (C) 2011-2014, 2017, 2018, 2020, 2022, MinGW.OSDN Project | |
13 | 13 | # |
14 | 14 | # Permission is hereby granted, free of charge, to any person obtaining a copy |
15 | 15 | # of this software and associated documentation files (the "Software"), to deal |
@@ -39,9 +39,22 @@ | ||
39 | 39 | # |
40 | 40 | ARCH=${ARCH-"mingw32"} |
41 | 41 | |
42 | -# Provide an absolute canonical reference form for PACKAGE_SRCDIR. | |
42 | +# Determine an absolute canonical reference form for PACKAGE_SRCDIR; provide | |
43 | +# a capability to abort if inaccessible, but allow for deferred failure. | |
43 | 44 | # |
44 | - PACKAGE_ABS_SRCDIR=`cd $PACKAGE_SRCDIR; pwd` | |
45 | + abs_srcdir() { 2> /dev/null cd $PACKAGE_SRCDIR && pwd || { | |
46 | + ${1-"true"} && die 2 "cannot access directory '$PACKAGE_SRCDIR'" | |
47 | + } | |
48 | + } | |
49 | +# If available, store this canonical reference in PACKAGE_ABS_SRCDIR, and | |
50 | +# redefine the evaluator function to simply reproduce the stored path. | |
51 | +# | |
52 | + initialize_abs_srcdir() { | |
53 | + PACKAGE_ABS_SRCDIR=`abs_srcdir ${1+"$1"}` && { | |
54 | + abs_srcdir() { echo "$PACKAGE_ABS_SRCDIR"; } | |
55 | + } | |
56 | + } | |
57 | + initialize_abs_srcdir ${fail_if_inaccessible-"false"} | |
45 | 58 | |
46 | 59 | # Ensure we have a PACKAGE name specification; if not, attempt to deduce |
47 | 60 | # a suitable default from the name of the top-level source code directory. |
@@ -51,7 +64,7 @@ | ||
51 | 64 | # |
52 | 65 | # An optional second argument overrides the default derivation. |
53 | 66 | # |
54 | - IFS=-; set -- ${2-`basename "$PACKAGE_ABS_SRCDIR"`}; IFS= | |
67 | + IFS=-; set -- ${2-`basename "$PACKAGE_SRCDIR"`}; IFS= | |
55 | 68 | value= fs=; $pkgspec_request_class "$@" |
56 | 69 | } |
57 | 70 | pkgspec_get_name() { |