Browse Source

build/confirm: simple but effective confirmation dialog

pull/97/head
Franco Fichtner 2 years ago
parent
commit
418b0eec9a
4 changed files with 57 additions and 6 deletions
  1. +4
    -4
      Makefile
  2. +5
    -0
      README.md
  3. +6
    -2
      build/common.sh
  4. +42
    -0
      build/confirm.sh

+ 4
- 4
Makefile View File

@ -23,10 +23,10 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
STEPS= arm base boot chroot clean compress core distfiles download \
dvd info kernel nano plugins ports prefetch print rebase \
release rename serial sign skim test update upload verify \
vga vm xtools
STEPS= arm base boot chroot clean compress confirm core distfiles \
download dvd info kernel nano plugins ports prefetch print \
rebase release rename serial sign skim test update upload \
verify vga vm xtools
SCRIPTS= batch nightly refresh pkg_fingerprint pkg_sign
.PHONY: ${STEPS}

+ 5
- 0
README.md View File

@ -416,6 +416,11 @@ specify the remote end, e.g. SERVER=user@does.not.exist
Additionally, UPLOADDIR can be used to specify a remote location. At
this point only "logs" upload cleares and creates directories on the fly.
If you want to script interactive prompts you may use the confirm target
to operate yes or no questions before an action:
# make info confirm dvd
Last but not least, a refresh of OPNsense core and plugins on package
sets is invoked using:

+ 6
- 2
build/common.sh View File

@ -241,13 +241,17 @@ export PRODUCT_CORE="${PRODUCT_TYPE}${PRODUCT_SUFFIX}"
export PRODUCT_PLUGINS="os-*"
export PRODUCT_PLUGIN="os-*${PRODUCT_SUFFIX}"
if [ "${SELF}" != print -a "${SELF}" != info ]; then
case "${SELF}" in
confirm|info|print)
;;
*)
if [ -z "${PRINT_ENV_SKIP}" ]; then
export PRINT_ENV_SKIP=1
env | sort
fi
echo ">>> Running build step: ${SELF}"
fi
;;
esac
git_reset()
{

+ 42
- 0
build/confirm.sh View File

@ -0,0 +1,42 @@
#!/bin/sh
# Copyright (c) 2018 Franco Fichtner <franco@opnsense.org>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
set -e
SELF=confirm
. ./common.sh
read -p "Proceed with this action? [y/N]: " YN
case ${YN} in
[yY])
;;
*)
exit 1
;;
esac

Loading…
Cancel
Save