Experimental package creation tool for MinGW.org
Révision | 31e1a0101520daf5f8b8e66345a2121745337a3b (tree) |
---|---|
l'heure | 2022-03-07 21:51:44 |
Auteur | Keith Marshall <keith@user...> |
Commiter | Keith Marshall |
Verify accessibility of git and hg root directories.
* src/plugins/git.sh src/plugins/hg.sh (initialize_abs_srcdir): Use it
to verify that the nominated package source directory actually exists;
abort if it doesn't, when it is required to do so.
@@ -10,7 +10,7 @@ | ||
10 | 10 | # $Id$ |
11 | 11 | # |
12 | 12 | # Written by Keith Marshall <keith@users.osdn.me> |
13 | -# Copyright (C) 2019, MinGW.OSDN Project | |
13 | +# Copyright (C) 2019, 2022, MinGW.OSDN Project | |
14 | 14 | # |
15 | 15 | # Permission is hereby granted, free of charge, to any person obtaining a copy |
16 | 16 | # of this software and associated documentation files (the "Software"), to deal |
@@ -57,6 +57,7 @@ | ||
57 | 57 | # |
58 | 58 | defn_add_hook initialize plugin git_plugin_initialize |
59 | 59 | git_plugin_initialize() { |
60 | + initialize_abs_srcdir || exit | |
60 | 61 | phase "initialize local git repository" |
61 | 62 | ( cd $PACKAGE_SRCDIR |
62 | 63 | git init --quiet |
@@ -105,6 +106,7 @@ | ||
105 | 106 | defn_set_hook stage_srcdist plugin git_plugin_stage_srcdist |
106 | 107 | git_plugin_stage_srcdist() { |
107 | 108 | step "check source tree integrity" |
109 | + initialize_abs_srcdir || exit | |
108 | 110 | # |
109 | 111 | # The "mingw-pkg distribute" action is not allowed to proceed, if |
110 | 112 | # the source code repository is contaminated by untracked files, or |
@@ -10,7 +10,7 @@ | ||
10 | 10 | # $Id$ |
11 | 11 | # |
12 | 12 | # Written by Keith Marshall <keith@users.osdn.me> |
13 | -# Copyright (C) 2011-2013, 2016-2019, MinGW.OSDN Project | |
13 | +# Copyright (C) 2011-2013, 2016-2019, 2020, 2022, MinGW.OSDN Project | |
14 | 14 | # |
15 | 15 | # Permission is hereby granted, free of charge, to any person obtaining a copy |
16 | 16 | # of this software and associated documentation files (the "Software"), to deal |
@@ -36,19 +36,20 @@ | ||
36 | 36 | STAGED_PKGROOT=${STAGED_PKGROOT-"`pwd`"} |
37 | 37 | |
38 | 38 | # When running hg, on behalf of this plug-in, we may need to ensure that |
39 | -# it is run in the top source directory; invoking it as $HG_CMD guarantees | |
39 | +# it is run in the top source directory; invoking it as HG_CMD guarantees | |
40 | 40 | # that this requirement is satisfied. |
41 | 41 | # |
42 | - HG_CMD='eval hg --cwd "$PACKAGE_ABS_SRCDIR"' | |
42 | + HG_CMD() { hg --cwd "`abs_srcdir`" "$@"; } | |
43 | 43 | |
44 | 44 | # The hg_plugin_initialize function hooks into the "mingw-pkg initialize" |
45 | 45 | # action, to set up the requisite hg repository whence any distributable |
46 | 46 | # package images will be constructed. Note that this runs a sequence of |
47 | 47 | # hg commands within a sub-shell; changing the working directory for this |
48 | -# sub-shell obviates the need to use $HG_CMD. | |
48 | +# sub-shell obviates the need to use HG_CMD. | |
49 | 49 | # |
50 | 50 | defn_add_hook initialize plugin hg_plugin_initialize |
51 | 51 | hg_plugin_initialize() { |
52 | + initialize_abs_srcdir || exit | |
52 | 53 | phase "initialize local mercurial repository" |
53 | 54 | ( cd $PACKAGE_SRCDIR |
54 | 55 | hg init |
@@ -78,7 +79,7 @@ | ||
78 | 79 | # |
79 | 80 | action_load_package_specs() { hg_plugin_load_package_specs; } |
80 | 81 | hg_plugin_load_package_specs() { action_prepare_package_specs |
81 | - test -f $PACKAGE_SRCDIR/arch/${ARCH="`$HG_CMD branch 2> /dev/null \ | |
82 | + test -f $PACKAGE_SRCDIR/arch/${ARCH="`HG_CMD branch 2> /dev/null \ | |
82 | 83 | || echo $ARCH_DEFAULT`"}/$PACKAGE-$VERSION-$ARCH.pkgspec && \ |
83 | 84 | . $PACKAGE_SRCDIR/arch/$ARCH/$PACKAGE-$VERSION-$ARCH.pkgspec |
84 | 85 | } |
@@ -90,8 +91,9 @@ | ||
90 | 91 | # any applied patches, which must be managed by MQ. |
91 | 92 | # |
92 | 93 | defn_set_hook stage_srcdist plugin hg_plugin_stage_srcdist |
93 | - hg_plugin_stage_srcdist() { local HG_ROOT=`$HG_CMD root` | |
94 | + hg_plugin_stage_srcdist() { | |
94 | 95 | step "check source tree integrity" |
96 | + initialize_abs_srcdir && local HG_ROOT=`HG_CMD root` || exit | |
95 | 97 | # |
96 | 98 | # The "mingw-pkg distribute" action is not allowed to proceed, if |
97 | 99 | # the source code repository is contaminated by untracked files, or |
@@ -101,11 +103,11 @@ | ||
101 | 103 | show_status() { |
102 | 104 | warning "$1"; printf >&2 '%s\n\n' "$warning_colour$2$unbold" |
103 | 105 | } |
104 | - untracked="`$HG_CMD status | grep '^?'`" && { | |
106 | + untracked="`HG_CMD status | grep '^?'`" && { | |
105 | 107 | show_status "untracked files in source tree..." "$untracked" |
106 | 108 | ${ignore_untracked_files-false} || EXIT_CODE=1 |
107 | 109 | } |
108 | - uncommitted="`$HG_CMD status | grep '^[AMR!]'`" && { | |
110 | + uncommitted="`HG_CMD status | grep '^[AMR!]'`" && { | |
109 | 111 | show_status "locally modified files in source tree..." "$uncommitted" |
110 | 112 | EXIT_CODE=1 |
111 | 113 | } |