• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Keine Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Experimental package creation tool for MinGW.org


Commit MetaInfo

Revision28704533138e4016bb9748de883015c2eb1d08c1 (tree)
Zeit2022-03-12 08:32:28
AutorKeith Marshall <keith@user...>
CommiterKeith Marshall

Log Message

Add mkspec "--edit" and "--force-overwrite" options.

* src/modules/options.sh (--edit, --force-overwrite): Define them.
* src/modules/mkspec.sh (--edit, --force-overwrite): Implement them.
* src/modules/help.sh (--edit, --force-overwrite): Document them.

Ändern Zusammenfassung

Diff

--- a/src/modules/help.sh
+++ b/src/modules/help.sh
@@ -109,6 +109,15 @@
109109 output, rather than creating or overwriting the
110110 default package specification file.
111111
112+ -e, --edit When specified in association with "mkspec" open
113+ the package specification file for editing, using
114+ the editor specified by the EDITOR variable.
115+
116+ -f, --force-overwrite
117+ Allow the "mkspec" action to overwrite an existing
118+ package specification file; normally, this would be
119+ blocked, to prevent accidental overwrite.
120+
112121 --xtool Enable cross-compiler build mode; do not pass any
113122 "--build" or "--host" options to configure, so that
114123 configuration relates to native compilation of the
--- a/src/modules/mkspec.sh
+++ b/src/modules/mkspec.sh
@@ -32,32 +32,53 @@
3232 #
3333 # -----------------------------------------------------------------------------
3434 #
35- local SPECSFILE SPECSFILE_DIR
36- SPECSFILE_DIR=${PACKAGE_SRCDIR-"."}/arch/${ARCH-"mingw32"}
37- SPECSFILE=$PACKAGE-$VERSION${ARCH+"-$ARCH"}.pkgspec
35+# Unless streaming the specification file content to stdout, determine an
36+# appropriate output file path name, and take precautions to avoid writing
37+# over an existing file.
38+#
3839 ${write_stdout=false} || {
40+ local SPECSFILE SPECSFILE_DIR
41+ SPECSFILE_DIR=${PACKAGE_SRCDIR-"."}/arch/${ARCH-"mingw32"}
42+ SPECSFILE=$PACKAGE-$VERSION${ARCH+"-$ARCH"}.pkgspec
3943 test -e "$SPECSFILE_DIR/$SPECSFILE" && {
40- error "file '$SPECSFILE' already exists"; exit 1
44+ ${force_overwrite-false} || {
45+ ${edit_mode-false} || {
46+ error "file '$SPECSFILE' already exists"; exit 1
47+ }
48+ local newfile=false
49+ }
4150 }
4251 }
52+# Once we've verified intent to write a new specification data stream, we
53+# must ensure that designated output directory exists, if required, after
54+# which we arrange to stream to the designated location, via stdout.
55+#
56+ ${newfile-true} && (
57+ $write_stdout || {
58+ mkdir -p "$SPECSFILE_DIR"
59+ exec > "$SPECSFILE_DIR/$SPECSFILE"
60+ }
61+
62+# Set up template substitutions for download URIs...
4363 #
44-( $write_stdout || {
45- mkdir -p "$SPECSFILE_DIR"
46- exec > "$SPECSFILE_DIR/$SPECSFILE"
47- }
64+ test "${PACKAGE_HOME_URI+set}" = set && PKGHOME_SET="" || PKGHOME_SET="# "
4865
66+# ...for the optional "pkgrelease" specification...
67+#
4968 test "${RELEASE+"set"}" = set && RELEASE_PREFIX="" || RELEASE_PREFIX="# "
5069
70+# ...and for archive compression choices...
71+#
5172 case $COMPRESS_CMD in
5273 gzip) COMPRESSION_TYPE=.gz ;;
5374 bzip2) COMPRESSION_TYPE=.bz2 ;;
5475 lzma) COMPRESSION_TYPE=.lzma ;;
5576 xz) COMPRESSION_TYPE=.xz ;;
5677 esac
57-
58- test "${PACKAGE_HOME_URI+set}" = set && PKGHOME_SET="" || PKGHOME_SET="# "
5978 PACKAGE_TYPE_SUFFIX=${ARCHIVE_CMD-"tar"}${COMPRESSION_TYPE-".gz"}
6079
80+# ...before emitting the specification data stream.
81+#
6182 cat <<ETX
6283 # $PACKAGE-$VERSION${RELEASE+"-$RELEASE"}${ARCH+"-$ARCH"}.pkgspec
6384 #
@@ -219,4 +240,21 @@ affiliate "MinGW Contributed Applications"
219240 # $PACKAGE-$VERSION${RELEASE+"-$RELEASE"}${ARCH+"-$ARCH"}.pkgspec: end of file
220241 ETX
221242 )
243+# Regardless of whether we've just created it, or not, if the "--edit"
244+# option has been specified, then we should immediately open the package
245+# specification file in our preferred editor; however, we cannot do this,
246+# if the specification file content was streamed to stdout, or if the
247+# $EDITOR shell variable has not been specified.
248+#
249+ if ${edit_mode-false}
250+ then ${write_stdout-false} && {
251+ error "cannot edit the standard output data stream"
252+ } || {
253+ test "${EDITOR+set}" = set && $EDITOR "$SPECSFILE_DIR/$SPECSFILE" || {
254+ error 'editing requested but $EDITOR is not defined'
255+ }
256+ }
257+ fi
258+#
259+# -----------------------------------------------------------------------------
222260 # $RCSfile$: end of file
--- a/src/modules/options.sh
+++ b/src/modules/options.sh
@@ -49,6 +49,12 @@
4949 optdefine c stdout
5050 opteval_stdout() { write_stdout=true; }
5151
52+ optdefine e edit
53+ opteval_edit() { edit_mode=true; }
54+
55+ optdefine f force-overwrite
56+ opteval_force_overwrite() { force_overwrite=true; }
57+
5258 optdefine option requires_argument
5359 opteval_option() { option $optarg; }
5460
@@ -56,7 +62,7 @@
5662 opteval_arch() { ARCH="$optarg"; }
5763
5864 optdefine identity requires_argument
59- opteval_identity() { PORTSPEC="$optarg"; }
65+ opteval_identity() { PORTSPEC="$optarg" SRCDIR=${SRCDIR-"./$optarg"}; }
6066
6167 optdefine port
6268 opteval_port() { MINGW_PORT_DISTRIBUTION=true SRCTAG=port; }