From 5e589497c57830e89f6175cccdb29593c85e517c Mon Sep 17 00:00:00 2001 From: Takeshi Nakatani Date: Fri, 7 Feb 2025 10:23:18 +0900 Subject: [PATCH] Changed support OSes and Fixed scripts, etc --- .github/workflows/build_helper.sh | 6 +-- .github/workflows/ci.yml | 5 +-- .github/workflows/docker_helper.sh | 26 ++++++------ .github/workflows/ostypevars.sh | 26 +++--------- AUTHORS | 2 +- README.md | 4 +- autogen.sh | 8 ++-- buildutils/alpine_build.sh | 8 ++-- buildutils/debian_build.sh | 18 ++++---- buildutils/k2hdkc-service-helper | 56 +++++++++++++++++++------ buildutils/make_commit_hash.sh | 12 +++--- buildutils/make_commit_hash_source.sh | 6 +-- buildutils/make_description.sh | 10 ++--- buildutils/make_release_version_file.sh | 10 ++--- buildutils/make_rpm_changelog.sh | 2 +- buildutils/make_variables.sh | 16 +++---- buildutils/rpm_build.sh | 12 +++--- configure.ac | 12 +++--- tests/test.sh | 18 +++++--- 19 files changed, 140 insertions(+), 117 deletions(-) diff --git a/.github/workflows/build_helper.sh b/.github/workflows/build_helper.sh index 3f2ca07..26b2583 100755 --- a/.github/workflows/build_helper.sh +++ b/.github/workflows/build_helper.sh @@ -1350,7 +1350,7 @@ if [ "${RUN_SHELLCHECK}" -eq 1 ]; then # Fedora # if ({ RUNCMD "${INSTALLER_BIN}" "${INSTALL_CMD}" "${INSTALL_CMD_ARG}" "${INSTALL_AUTO_ARG}" ShellCheck || echo > "${PIPEFAILURE_FILE}"; } | sed -e 's/^/ /g') && rm "${PIPEFAILURE_FILE}" >/dev/null 2>&1; then - PRNERR "Failed to install cppcheck" + PRNERR "Failed to install shellcheck" exit 1 fi @@ -1377,7 +1377,7 @@ if [ "${RUN_SHELLCHECK}" -eq 1 ]; then # Ubuntu or Debian # if ({ RUNCMD "${INSTALLER_BIN}" "${INSTALL_CMD}" "${INSTALL_CMD_ARG}" "${INSTALL_AUTO_ARG}" shellcheck || echo > "${PIPEFAILURE_FILE}"; } | sed -e 's/^/ /g') && rm "${PIPEFAILURE_FILE}" >/dev/null 2>&1; then - PRNERR "Failed to install cppcheck" + PRNERR "Failed to install shellcheck" exit 1 fi @@ -1386,7 +1386,7 @@ if [ "${RUN_SHELLCHECK}" -eq 1 ]; then # Alpine # if ({ RUNCMD "${INSTALLER_BIN}" "${INSTALL_CMD}" "${INSTALL_CMD_ARG}" "${INSTALL_AUTO_ARG}" shellcheck || echo > "${PIPEFAILURE_FILE}"; } | sed -e 's/^/ /g') && rm "${PIPEFAILURE_FILE}" >/dev/null 2>&1; then - PRNERR "Failed to install cppcheck" + PRNERR "Failed to install shellcheck" exit 1 fi diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 02c9c0b..8859e0b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -63,16 +63,15 @@ jobs: container: - ubuntu:24.04 - ubuntu:22.04 - - ubuntu:20.04 - debian:bookworm - debian:bullseye - rockylinux:9 - rockylinux:8 - fedora:41 - fedora:40 + - alpine:3.21 - alpine:3.20 - alpine:3.19 - - alpine:3.18 container: image: ${{ matrix.container }} @@ -150,7 +149,7 @@ jobs: # : If you want to use the created Docker image as the default image, specify "default". # imageinfo: - - alpine:3.20,alpine:3.20,alpine,default + - alpine:3.21,alpine:3.21,alpine,default - ubuntu:24.04,ubuntu:24.04,ubuntu # diff --git a/.github/workflows/docker_helper.sh b/.github/workflows/docker_helper.sh index 1a18e18..12d7c2c 100755 --- a/.github/workflows/docker_helper.sh +++ b/.github/workflows/docker_helper.sh @@ -159,7 +159,7 @@ func_usage() echo " Option:" echo " --help(-h) print help" echo " --imagetype-vars-file(-f) specify the file path to imagetype variable(deafult. \"imagetypevars.sh\")" - echo " --imageinfo(-i) specify infomration about "base docker image", "base docker dev image", "os type tag" and "default flag" (ex. \"alpine:latest,alpine:latest,alpine,default\")" + echo " --imageinfo(-i) specify infomration about \"base docker image\", \"base docker dev image\", \"os type tag\" and \"default flag\" (ex. \"alpine:latest,alpine:latest,alpine,default\")" echo " --organization(-o) specify organaization name on DockerHub(default. \"antpickax\")" echo " --imagenames(-n) specify build image names, separate multiple names with commas(ex. \"target,target-dev\")" echo " --imageversion(-v) the value of this option is set automatically and is usually not specified.(ex. \"1.0.0\")" @@ -363,11 +363,11 @@ while [ $# -ne 0 ]; do if [ -z "$1" ]; then break - elif [ "$1" = "-h" ] || [ "$1" = "-H" ] || [ "$1" = "--help" ] || [ "$1" = "--HELP" ]; then + elif echo "$1" | grep -q -i -e "^-h$" -e "^--help$"; then func_usage "${PRGNAME}" exit 0 - elif [ "$1" = "-f" ] || [ "$1" = "-F" ] || [ "$1" = "--imagetype-vars-file" ] || [ "$1" = "--IMAGETYPE-VARS-FILE" ]; then + elif echo "$1" | grep -q -i -e "^-f$" -e "^--imagetype-vars-file$"; then if [ -n "${OPT_IMAGEVAR_FILE}" ]; then PRNERR "already set \"--imagetype-vars-file(-f)\" option." exit 1 @@ -387,7 +387,7 @@ while [ $# -ne 0 ]; do OPT_IMAGEVAR_FILE="$1" fi - elif [ "$1" = "-i" ] || [ "$1" = "-I" ] || [ "$1" = "--imageinfo" ] || [ "$1" = "--IMAGEINFO" ]; then + elif echo "$1" | grep -q -i -e "^-i$" -e "^--imageinfo$"; then if [ -n "${OPT_DOCKER_IMAGE_INFO}" ]; then PRNERR "already set \"--imageinfo(-i)\" option." exit 1 @@ -399,7 +399,7 @@ while [ $# -ne 0 ]; do fi OPT_DOCKER_IMAGE_INFO="$1" - elif [ "$1" = "-o" ] || [ "$1" = "-O" ] || [ "$1" = "--organization" ] || [ "$1" = "--ORGANIZATION" ]; then + elif echo "$1" | grep -q -i -e "^-o$" -e "^--organization$"; then if [ -n "${OPT_DOCKER_HUB_ORG}" ]; then PRNERR "already set \"--organization(-o)\" option." exit 1 @@ -411,7 +411,7 @@ while [ $# -ne 0 ]; do fi OPT_DOCKER_HUB_ORG="$1" - elif [ "$1" = "-n" ] || [ "$1" = "-N" ] || [ "$1" = "--imagenames" ] || [ "$1" = "--IMAGENAMES" ]; then + elif echo "$1" | grep -q -i -e "^-n$" -e "^--imagenames$"; then if [ -n "${OPT_IMAGE_NAMES}" ]; then PRNERR "already set \"--imagenames(-n)\" option." exit 1 @@ -423,7 +423,7 @@ while [ $# -ne 0 ]; do fi OPT_IMAGE_NAMES="$1" - elif [ "$1" = "-v" ] || [ "$1" = "-V" ] || [ "$1" = "--imageversion" ] || [ "$1" = "--IMAGEVERSION" ]; then + elif echo "$1" | grep -q -i -e "^-v$" -e "^--imageversion$"; then if [ -n "${OPT_IMAGE_VERSION}" ]; then PRNERR "already set \"--imageversion(-v)\" option." exit 1 @@ -435,35 +435,35 @@ while [ $# -ne 0 ]; do fi OPT_IMAGE_VERSION="$1" - elif [ "$1" = "-p" ] || [ "$1" = "-P" ] || [ "$1" = "--push" ] || [ "$1" = "--PUSH" ]; then + elif echo "$1" | grep -q -i -e "^-p$" -e "^--push$"; then if [ -n "${OPT_FORCE_PUSH}" ]; then PRNERR "already set \"--push(-p)\" or \"--notpush(-np)\" option." exit 1 fi OPT_FORCE_PUSH="true" - elif [ "$1" = "-np" ] || [ "$1" = "-NP" ] || [ "$1" = "--notpush" ] || [ "$1" = "--NOTPUSH" ]; then + elif echo "$1" | grep -q -i -e "^-np$" -e "^--notpush$"; then if [ -n "${OPT_FORCE_PUSH}" ]; then PRNERR "already set \"--push(-p)\" or \"--notpush(-np)\" option." exit 1 fi OPT_FORCE_PUSH="false" - elif [ "$1" = "-usepc" ] || [ "$1" = "-USEPC" ] || [ "$1" = "--use-packagecloudio-repo" ] || [ "$1" = "--USE-PACKAGECLOUDIO-REPO" ]; then + elif echo "$1" | grep -q -i -e "^-usepc$" -e "^--use-packagecloudio-repo$"; then if [ -n "${OPT_USE_PACKAGECLOUD_REPO}" ]; then PRNERR "already set \"--use-packagecloudio-repo(-usepc)\" or \"--not-use-packagecloudio-repo(-notpc)\" option." exit 1 fi OPT_USE_PACKAGECLOUD_REPO=1 - elif [ "$1" = "-notpc" ] || [ "$1" = "-NOTPC" ] || [ "$1" = "--not-use-packagecloudio-repo" ] || [ "$1" = "--NOT-USE-PACKAGECLOUDIO-REPO" ]; then + elif echo "$1" | grep -q -i -e "^-notpc$" -e "^--not-use-packagecloudio-repo$"; then if [ -n "${OPT_USE_PACKAGECLOUD_REPO}" ]; then PRNERR "already set \"--use-packagecloudio-repo(-usepc)\" or \"--not-use-packagecloudio-repo(-notpc)\" option." exit 1 fi OPT_USE_PACKAGECLOUD_REPO=0 - elif [ "$1" = "-pcowner" ] || [ "$1" = "-PCOWNER" ] || [ "$1" = "--packagecloudio-owner" ] || [ "$1" = "--PACKAGECLOUDIO-OWNER" ]; then + elif echo "$1" | grep -q -i -e "^-pcowner$" -e "^--packagecloudio-owner$"; then if [ -n "${OPT_PACKAGECLOUD_OWNER}" ]; then PRNERR "already set \"--packagecloudio-owner(-pcowner)\" option." exit 1 @@ -475,7 +475,7 @@ while [ $# -ne 0 ]; do fi OPT_PACKAGECLOUD_OWNER="$1" - elif [ "$1" = "-pcdlrepo" ] || [ "$1" = "-PCDLREPO" ] || [ "$1" = "--packagecloudio-download-repo" ] || [ "$1" = "--PACKAGECLOUDIO-DOWNLOAD-REPO" ]; then + elif echo "$1" | grep -q -i -e "^-pcdlrepo$" -e "^--packagecloudio-download-repo$"; then if [ -n "${OPT_PACKAGECLOUD_DOWNLOAD_REPO}" ]; then PRNERR "already set \"--packagecloudio-download-repo(-pcdlrepo)\" option." exit 1 diff --git a/.github/workflows/ostypevars.sh b/.github/workflows/ostypevars.sh index f1b195a..03fdcfc 100644 --- a/.github/workflows/ostypevars.sh +++ b/.github/workflows/ostypevars.sh @@ -122,20 +122,6 @@ elif echo "${CI_OSTYPE}" | grep -q -i -e "ubuntu:22.04" -e "ubuntu:jammy"; then PKG_EXT="deb" IS_OS_UBUNTU=1 -elif echo "${CI_OSTYPE}" | grep -q -i -e "ubuntu:20.04" -e "ubuntu:focal"; then - DIST_TAG="ubuntu/focal" - INSTALL_PKG_LIST="git autoconf autotools-dev gcc g++ make gdb dh-make fakeroot dpkg-dev devscripts libtool pkg-config ruby-dev rubygems rubygems-integration procps libyaml-dev chmpx-dev gnutls-dev dh-systemd" - INSTALLER_BIN="apt-get" - UPDATE_CMD="update" - UPDATE_CMD_ARG="" - INSTALL_CMD="install" - INSTALL_CMD_ARG="" - INSTALL_AUTO_ARG="-y" - INSTALL_QUIET_ARG="-qq" - PKG_OUTPUT_DIR="debian_build" - PKG_EXT="deb" - IS_OS_UBUNTU=1 - elif echo "${CI_OSTYPE}" | grep -q -i -e "debian:12" -e "debian:bookworm"; then DIST_TAG="debian/bookworm" INSTALL_PKG_LIST="git autoconf autotools-dev gcc g++ make gdb dh-make fakeroot dpkg-dev devscripts libtool pkg-config ruby-dev rubygems rubygems-integration procps libyaml-dev chmpx-dev libssl-dev" @@ -242,8 +228,8 @@ elif echo "${CI_OSTYPE}" | grep -q -i "fedora:40"; then PKG_EXT="rpm" IS_OS_FEDORA=1 -elif echo "${CI_OSTYPE}" | grep -q -i "alpine:3.20"; then - DIST_TAG="alpine/v3.20" +elif echo "${CI_OSTYPE}" | grep -q -i "alpine:3.21"; then + DIST_TAG="alpine/v3.21" INSTALL_PKG_LIST="bash sudo alpine-sdk automake autoconf libtool groff util-linux-misc musl-locales ruby-dev procps yaml-dev chmpx-dev openssl-dev" INSTALLER_BIN="apk" UPDATE_CMD="update" @@ -256,8 +242,8 @@ elif echo "${CI_OSTYPE}" | grep -q -i "alpine:3.20"; then PKG_EXT="apk" IS_OS_ALPINE=1 -elif echo "${CI_OSTYPE}" | grep -q -i "alpine:3.19"; then - DIST_TAG="alpine/v3.19" +elif echo "${CI_OSTYPE}" | grep -q -i "alpine:3.20"; then + DIST_TAG="alpine/v3.20" INSTALL_PKG_LIST="bash sudo alpine-sdk automake autoconf libtool groff util-linux-misc musl-locales ruby-dev procps yaml-dev chmpx-dev openssl-dev" INSTALLER_BIN="apk" UPDATE_CMD="update" @@ -270,8 +256,8 @@ elif echo "${CI_OSTYPE}" | grep -q -i "alpine:3.19"; then PKG_EXT="apk" IS_OS_ALPINE=1 -elif echo "${CI_OSTYPE}" | grep -q -i "alpine:3.18"; then - DIST_TAG="alpine/v3.18" +elif echo "${CI_OSTYPE}" | grep -q -i "alpine:3.19"; then + DIST_TAG="alpine/v3.19" INSTALL_PKG_LIST="bash sudo alpine-sdk automake autoconf libtool groff util-linux-misc musl-locales ruby-dev procps yaml-dev chmpx-dev openssl-dev" INSTALLER_BIN="apk" UPDATE_CMD="update" diff --git a/AUTHORS b/AUTHORS index b01193a..8df09aa 100644 --- a/AUTHORS +++ b/AUTHORS @@ -2,6 +2,6 @@ Wrote from scratch the initial version of k2hdkc. -2. Hirotaka Wakabayashi +2. Hirotaka Wakabayashi Technical engineer of k2hdkc product. diff --git a/README.md b/README.md index 9e2abed..dd01494 100644 --- a/README.md +++ b/README.md @@ -5,8 +5,9 @@ K2HDKC [![GitHub forks](https://img.shields.io/github/forks/yahoojapan/k2hdkc.svg)](https://github.com/yahoojapan/k2hdkc/network) [![GitHub stars](https://img.shields.io/github/stars/yahoojapan/k2hdkc.svg)](https://github.com/yahoojapan/k2hdkc/stargazers) [![GitHub issues](https://img.shields.io/github/issues/yahoojapan/k2hdkc.svg)](https://github.com/yahoojapan/k2hdkc/issues) -[![debian packages](https://img.shields.io/badge/deb-packagecloud.io-844fec.svg)](https://packagecloud.io/antpickax/stable) [![RPM packages](https://img.shields.io/badge/rpm-packagecloud.io-844fec.svg)](https://packagecloud.io/antpickax/stable) +[![debian packages](https://img.shields.io/badge/deb-packagecloud.io-844fec.svg)](https://packagecloud.io/antpickax/stable) +[![ALPINE packages](https://img.shields.io/badge/apk-packagecloud.io-844fec.svg)](https://packagecloud.io/antpickax/stable) [![Docker image](https://img.shields.io/docker/pulls/antpickax/k2hdkc.svg)](https://hub.docker.com/r/antpickax/k2hdkc) [![Docker dev image](https://img.shields.io/docker/pulls/antpickax/k2hdkc-dev.svg)](https://hub.docker.com/r/antpickax/k2hdkc-dev) @@ -42,6 +43,7 @@ Provides the key expiration function which is the feature of k2hash as distribut ### Packages - [RPM packages(packagecloud.io)](https://packagecloud.io/antpickax/stable) - [Debian packages(packagecloud.io)](https://packagecloud.io/antpickax/stable) +- [ALPINE packages(packagecloud.io)](https://packagecloud.io/antpickax/stable) ### Docker images - [k2hdkc(Docker Hub)](https://hub.docker.com/r/antpickax/k2hdkc) diff --git a/autogen.sh b/autogen.sh index 3d4170f..a4ac58a 100755 --- a/autogen.sh +++ b/autogen.sh @@ -54,18 +54,18 @@ while [ $# -ne 0 ]; do echo "[ERROR] Parameters are something wrong." exit 1 - elif [ "$1" = "-h" ] || [ "$1" = "-H" ] || [ "$1" = "--help" ] || [ "$1" = "--HELP" ]; then + elif echo "$1" | grep -q -i -e "^-h$" -e "^--help$"; then echo "Usage: ${AUTOGEN_NAME} [--help(-h)] [--no_update_version_file(-nu)] [--no_aclocal_force(-na)] [--no_check_ver_diff(-nc)]" exit 0 - elif [ "$1" = "-nu" ] || [ "$1" = "-NU" ] || [ "$1" = "--no_update_version_file" ] || [ "$1" = "--NO_UPDATE_VERSION_FILE" ]; then + elif echo "$1" | grep -q -i -e "^-nu$" -e "^--no_update_version_file$"; then UPDATE_VERSION_FILE=0 FORCEPARAM="" # do not need force - elif [ "$1" = "-na" ] || [ "$1" = "-NA" ] || [ "$1" = "--no_aclocal_force" ] || [ "$1" = "--NO_ACLOCAL_FORCE" ]; then + elif echo "$1" | grep -q -i -e "^-na$" -e "^--no_aclocal_force$"; then FORCEPARAM="" - elif [ "$1" = "-nc" ] || [ "$1" = "-NC" ] || [ "$1" = "--no_check_ver_diff" ] || [ "$1" = "--NO_CHECK_VER_DIFF" ]; then + elif echo "$1" | grep -q -i -e "^-nc$" -e "^--no_check_ver_diff$"; then PARAMETERS="$1" else diff --git a/buildutils/alpine_build.sh b/buildutils/alpine_build.sh index 013a111..d0a5680 100755 --- a/buildutils/alpine_build.sh +++ b/buildutils/alpine_build.sh @@ -99,11 +99,11 @@ while [ $# -ne 0 ]; do if [ -z "$1" ]; then break - elif [ "$1" = "-h" ] || [ "$1" = "-H" ] || [ "$1" = "--help" ] || [ "$1" = "--HELP" ]; then + elif echo "$1" | grep -q -i -e "^-h$" -e "^--help$"; then func_usage "${PRGNAME}" exit 0 - elif [ "$1" = "-b" ] || [ "$1" = "-B" ] || [ "$1" = "--buildnum" ] || [ "$1" = "--BUILDNUM" ]; then + elif echo "$1" | grep -q -i -e "^-b$" -e "^--buildnum$"; then if [ -n "${BUILD_NUMBER}" ]; then echo "[ERROR] Already --buildnum(-b) option is specified(${BUILD_NUMBER})." 1>&2 exit 1 @@ -119,7 +119,7 @@ while [ $# -ne 0 ]; do fi BUILD_NUMBER="$1" - elif [ "$1" = "-p" ] || [ "$1" = "-P" ] || [ "$1" = "--product" ] || [ "$1" = "--PRODUCT" ]; then + elif echo "$1" | grep -q -i -e "^-p$" -e "^--product$"; then if [ -n "${PACKAGE_NAME}" ]; then echo "[ERROR] Already --product(-p) option is specified(${PACKAGE_NAME})." 1>&2 exit 1 @@ -131,7 +131,7 @@ while [ $# -ne 0 ]; do fi PACKAGE_NAME="$1" - elif [ "$1" = "-y" ] || [ "$1" = "-Y" ] || [ "$1" = "--yes" ] || [ "$1" = "--YES" ]; then + elif echo "$1" | grep -q -i -e "^-y$" -e "^--yes$"; then if [ "${NO_INTERACTIVE}" -ne 0 ]; then echo "[ERROR] Already --yes(-y) option is specified." 1>&2 exit 1 diff --git a/buildutils/debian_build.sh b/buildutils/debian_build.sh index f407dc3..727456a 100755 --- a/buildutils/debian_build.sh +++ b/buildutils/debian_build.sh @@ -104,11 +104,11 @@ while [ $# -ne 0 ]; do if [ -z "$1" ]; then break - elif [ "$1" = "-h" ] || [ "$1" = "-H" ] || [ "$1" = "--help" ] || [ "$1" = "--HELP" ]; then + elif echo "$1" | grep -q -i -e "^-h$" -e "^--help$"; then func_usage "${PRGNAME}" exit 0 - elif [ "$1" = "-b" ] || [ "$1" = "-B" ] || [ "$1" = "--buildnum" ] || [ "$1" = "--BUILDNUM" ]; then + elif echo "$1" | grep -q -i -e "^-b$" -e "^--buildnum$"; then if [ "${BUILD_NUMBER}" -ne 0 ]; then echo "[ERROR] Already --buildnum(-b) option is specified(${BUILD_NUMBER})." 1>&2 exit 1 @@ -128,7 +128,7 @@ while [ $# -ne 0 ]; do fi BUILD_NUMBER="$1" - elif [ "$1" = "-p" ] || [ "$1" = "-P" ] || [ "$1" = "--product" ] || [ "$1" = "--PRODUCT" ]; then + elif echo "$1" | grep -q -i -e "^-p$" -e "^--product$"; then if [ -n "${PACKAGE_NAME}" ]; then echo "[ERROR] Already --product(-p) option is specified(${PACKAGE_NAME})." 1>&2 exit 1 @@ -140,7 +140,7 @@ while [ $# -ne 0 ]; do fi PACKAGE_NAME="$1" - elif [ "$1" = "-c" ] || [ "$1" = "-C" ] || [ "$1" = "--class" ] || [ "$1" = "--CLASS" ]; then + elif echo "$1" | grep -q -i -e "^-c$" -e "^--class$"; then if [ -n "${PKG_CLASS_NAME}" ]; then echo "[ERROR] Already --class(-c) option is specified(${PKG_CLASS_NAME})." 1>&2 exit 1 @@ -152,7 +152,7 @@ while [ $# -ne 0 ]; do fi PKG_CLASS_NAME="$1" - elif [ "$1" = "-dt" ] || [ "$1" = "-DT" ] || [ "$1" = "--disttype" ] || [ "$1" = "--DISTTYPE" ]; then + elif echo "$1" | grep -q -i -e "^-dt$" -e "^--disttype$"; then if [ -n "${OS_VERSION_NAME}" ]; then echo "[ERROR] Already --disttype(-dt) option is specified(${OS_VERSION_NAME})." 1>&2 exit 1 @@ -164,14 +164,14 @@ while [ $# -ne 0 ]; do fi OS_VERSION_NAME="$1" - elif [ "$1" = "-r" ] || [ "$1" = "-R" ] || [ "$1" = "--rootdir" ] || [ "$1" = "--ROOTDIR" ]; then + elif echo "$1" | grep -q -i -e "^-r$" -e "^--rootdir$"; then if [ "${IS_ROOTDIR}" -ne 0 ]; then echo "[ERROR] Already --rootdir(-r) option is specified." 1>&2 exit 1 fi IS_ROOTDIR=1 - elif [ "$1" = "-y" ] || [ "$1" = "-Y" ] || [ "$1" = "--yes" ] || [ "$1" = "--YES" ]; then + elif echo "$1" | grep -q -i -e "^-y$" -e "^--yes$"; then if [ "${NO_INTERACTIVE}" -ne 0 ]; then echo "[ERROR] Already --yes(-y) option is specified." 1>&2 exit 1 @@ -255,9 +255,9 @@ if [ "${NO_INTERACTIVE}" -eq 0 ]; then printf '[INPUT] Confirm (y/n) : ' read -r CONFIRM - if [ "${CONFIRM}" = "y" ] || [ "${CONFIRM}" = "Y" ] || [ "${CONFIRM}" = "yes" ] || [ "${CONFIRM}" = "YES" ]; then + if echo "${CONFIRM}" | grep -q -i -e "^y$" -e "^yes$"; then IS_CONFIRMED=1 - elif [ "${CONFIRM}" = "n" ] || [ "${CONFIRM}" = "N" ] || [ "${CONFIRM}" = "no" ] || [ "${CONFIRM}" = "NO" ]; then + elif echo "${CONFIRM}" | grep -q -i -e "^n$" -e "^no$"; then echo "Interrupt this processing, bye..." exit 0 fi diff --git a/buildutils/k2hdkc-service-helper b/buildutils/k2hdkc-service-helper index a8a303a..28b30ae 100755 --- a/buildutils/k2hdkc-service-helper +++ b/buildutils/k2hdkc-service-helper @@ -440,7 +440,7 @@ wait_process_up() # Check process # # shellcheck disable=SC2009 - if ps -p "${_WAITPROC_PID}" | grep -v PID | grep -q -v -i 'defunct'; then + if ( ps -o pid,stat ax 2>/dev/null | grep -v 'PID' | awk '$2~/^[^Z]/ { print $1 }' | grep -q "^${_WAITPROC_PID}$" || exit 1 && exit 0 ); then # # OK(single checking) # @@ -458,7 +458,7 @@ wait_process_up() # Re-check process # # shellcheck disable=SC2009 - if ps -p "${_WAITPROC_PID}" | grep -v PID | grep -q -v -i 'defunct'; then + if ( ps -o pid,stat ax 2>/dev/null | grep -v 'PID' | awk '$2~/^[^Z]/ { print $1 }' | grep -q "^${_WAITPROC_PID}$" || exit 1 && exit 0 ); then # # OK(double checking) # @@ -531,7 +531,7 @@ start_process() if _STARTPROC_PID=$(cat "${_STARTPROC_PIDFILE}"); then # shellcheck disable=SC2009 - if ps -p "${_STARTPROC_PID}" | grep -v PID | grep -q -v -i 'defunct'; then + if ( ps -o pid,stat ax 2>/dev/null | grep -v 'PID' | awk '$2~/^[^Z]/ { print $1 }' | grep -q "^${_STARTPROC_PID}$" || exit 1 && exit 0 ); then log_err "Could not start a new process because PID file(${_STARTPROC_PIDFILE}) exists and the process(${_STARTPROC_PID}) is running." return 1 fi @@ -572,6 +572,7 @@ start_process() # shellcheck disable=SC2068 sudo -u "${_STARTPROC_OWNER}" $@ 2>&1 | sudo tee "${_STARTPROC_REDIRECTFILE}" >/dev/null 2>&1 & fi + _TMP_PARENT_PROCESS_ID="$!" # [NOTE] # Detects the PID of sudo's child process because it is running a @@ -579,8 +580,37 @@ start_process() # sleep 1 - # shellcheck disable=SC2009 - _STARTPROC_PROCESS_ID=$(ps --ppid $! | grep "${_STARTPROC_PROCNAME}" | grep -v sudo | awk '{print $1}') + # + # Try to find child process id + # + _STARTPROC_PROCESS_ID="" + while [ -z "${_STARTPROC_PROCESS_ID}" ]; do + # + # Get child process id and process name ( start "_TMP_PARENT_PROCESS_ID" as parent process id ) + # + # shellcheck disable=SC2009 + _TMP_CHILD_PROCESS_ID=$(ps -o pid,ppid,args ax | awk "\$2~/^${_TMP_PARENT_PROCESS_ID}/ { print \$1 }") + if [ -z "${_TMP_CHILD_PROCESS_ID}" ]; then + # + # Not found child process id + # + break + fi + + # shellcheck disable=SC2009 + _TMP_CHILD_PROCESS_PROC=$(ps -o pid,ppid,args ax | awk "\$2~/^${_TMP_PARENT_PROCESS_ID}/ { print \$3 }") + if ! ( echo "${_TMP_CHILD_PROCESS_PROC}" | grep -q -i 'sudo' || exit 1 && exit 0 ); then + # + # Found not "sudo" child process -> break + # + _STARTPROC_PROCESS_ID="${_TMP_CHILD_PROCESS_ID}" + else + # + # Found "sudo" child process -> continue to loop + # + _TMP_PARENT_PROCESS_ID="${_TMP_CHILD_PROCESS_ID}" + fi + done else if [ -n "${_STARTPROC_REDIRECTFILE}" ] && [ "${_STARTPROC_REDIRECTFILE}" = "NO" ]; then # shellcheck disable=SC2068 @@ -608,7 +638,7 @@ start_process() # Check process running # # shellcheck disable=SC2009 - if ! ps -p "${_STARTPROC_PROCESS_ID}" | grep -v PID | grep -q -v -i 'defunct'; then + if ! ( ps -o pid,stat ax 2>/dev/null | grep -v 'PID' | awk '$2~/^[^Z]/ { print $1 }' | grep -q "^${_STARTPROC_PROCESS_ID}$" || exit 1 && exit 0 ); then log_err "Could not start a new process, it was launched but exited soon." return 1 fi @@ -675,7 +705,7 @@ stop_process() # Check process # # shellcheck disable=SC2009 - if ! ps -p "${_STOPPROC_PID}" | grep -v PID | grep -q -v -i 'defunct'; then + if ! ( ps -o pid,stat ax 2>/dev/null | grep -v 'PID' | awk '$2~/^[^Z]/ { print $1 }' | grep -q "^${_STOPPROC_PID}$" || exit 1 && exit 0 ); then echo "Stopped PID(${_STOPPROC_PID}) process." rm -f "${_STOPPROC_PID_FILE}" return 0 @@ -693,7 +723,7 @@ stop_process() # Check process # # shellcheck disable=SC2009 - if ! ps -p "${_STOPPROC_PID}" | grep -v PID | grep -q -v -i 'defunct'; then + if ! ( ps -o pid,stat ax 2>/dev/null | grep -v 'PID' | awk '$2~/^[^Z]/ { print $1 }' | grep -q "^${_STOPPROC_PID}$" || exit 1 && exit 0 ); then echo "Stopped PID(${_STOPPROC_PID}) process." rm -f "${_STOPPROC_PID_FILE}" return 0 @@ -712,7 +742,7 @@ stop_process() # Check process # # shellcheck disable=SC2009 - if ! ps -p "${_STOPPROC_PID}" | grep -v PID | grep -q -v -i 'defunct'; then + if ! ( ps -o pid,stat ax 2>/dev/null | grep -v 'PID' | awk '$2~/^[^Z]/ { print $1 }' | grep -q "^${_STOPPROC_PID}$" || exit 1 && exit 0 ); then echo "Stopped PID(${_STOPPROC_PID}) process." rm -f "${_STOPPROC_PID_FILE}" return 0 @@ -1215,7 +1245,7 @@ if [ "${SCRIPT_MODE}" = "STOP" ]; then # Check old process # # shellcheck disable=SC2009 - if ! ps -p "${OLD_PROCESS_PID}" | grep -v PID | grep -q -v -i 'defunct'; then + if ! ( ps -o pid,stat ax 2>/dev/null | grep -v 'PID' | awk '$2~/^[^Z]/ { print $1 }' | grep -q "^${OLD_PROCESS_PID}$" || exit 1 && exit 0 ); then log_info "PID(${OLD_PROCESS_PID}) process is not exusted, then the process has stopped." rm -f "${PIDDIR}/${SERVICE_PIDFILE}" exit 0 @@ -1241,7 +1271,7 @@ if [ "${SCRIPT_MODE}" = "STOP" ]; then # Check process running # # shellcheck disable=SC2009 - if ! ps -p "${OLD_PROCESS_PID}" | grep -v PID | grep -q -v -i 'defunct'; then + if ! ( ps -o pid,stat ax 2>/dev/null | grep -v 'PID' | awk '$2~/^[^Z]/ { print $1 }' | grep -q "^${OLD_PROCESS_PID}$" || exit 1 && exit 0 ); then # # Stopped # @@ -1261,7 +1291,7 @@ if [ "${SCRIPT_MODE}" = "STOP" ]; then sleep "${INTERVAL_SEC_FOR_LOOP}" # shellcheck disable=SC2009 - if ps -p "${OLD_PROCESS_PID}" | grep -v PID | grep -q -v -i 'defunct'; then + if ( ps -o pid,stat ax 2>/dev/null | grep -v 'PID' | awk '$2~/^[^Z]/ { print $1 }' | grep -q "^${OLD_PROCESS_PID}$" || exit 1 && exit 0 ); then log_err "Could not stop PID(${OLD_PROCESS_PID}) process." exit 1 fi @@ -1280,7 +1310,7 @@ else OLD_PROCESS_PID=$(tr -d '\n' < "${PIDDIR}/${SERVICE_PIDFILE}") if [ $$ -ne "${OLD_PROCESS_PID}" ]; then # shellcheck disable=SC2009 - if ps -p "${OLD_PROCESS_PID}" | grep -v PID | grep -q -v -i 'defunct'; then + if ( ps -o pid,stat ax 2>/dev/null | grep -v 'PID' | awk '$2~/^[^Z]/ { print $1 }' | grep -q "^${OLD_PROCESS_PID}$" || exit 1 && exit 0 ); then log_err "Process PID(${OLD_PROCESS_PID}) has not stopped yet." exit 1 fi diff --git a/buildutils/make_commit_hash.sh b/buildutils/make_commit_hash.sh index 2c6a87f..d328fa9 100755 --- a/buildutils/make_commit_hash.sh +++ b/buildutils/make_commit_hash.sh @@ -69,11 +69,11 @@ while [ $# -ne 0 ]; do if [ -z "$1" ]; then break - elif [ "$1" = "-h" ] || [ "$1" = "-H" ] || [ "$1" = "--help" ] || [ "$1" = "--HELP" ]; then + elif echo "$1" | grep -q -i -e "^-h$" -e "^--help$"; then func_usage "${PRGNAME}" exit 0 - elif [ "$1" = "-o" ] || [ "$1" = "-O" ] || [ "$1" = "--organization" ] || [ "$1" = "--ORGANIZATION" ]; then + elif echo "$1" | grep -q -i -e "^-o$" -e "^--organization$"; then if [ -n "${ORGNAME}" ]; then echo "[ERROR] already --organization(-o) option is specified(${ORGNAME})." 1>&2 echo "unknown" @@ -87,7 +87,7 @@ while [ $# -ne 0 ]; do fi ORGNAME="$1" - elif [ "$1" = "-r" ] || [ "$1" = "-R" ] || [ "$1" = "--reponame" ] || [ "$1" = "--REPONAME" ]; then + elif echo "$1" | grep -q -i -e "^-r$" -e "^--reponame$"; then if [ -n "${REPONAME}" ]; then echo "[ERROR] already --reponame(-r) option is specified(${REPONAME})." 1>&2 echo "unknown" @@ -101,7 +101,7 @@ while [ $# -ne 0 ]; do fi REPONAME="$1" - elif [ "$1" = "-ep" ] || [ "$1" = "-EP" ] || [ "$1" = "--endpoint" ] || [ "$1" = "--ENDPOINT" ]; then + elif echo "$1" | grep -q -i -e "^-ep$" -e "^--endpoint$"; then if [ -n "${ENDPOINT}" ]; then echo "[ERROR] already --endpoint(-ep) option is specified(${ENDPOINT})." 1>&2 echo "unknown" @@ -115,7 +115,7 @@ while [ $# -ne 0 ]; do fi ENDPOINT="$1" - elif [ "$1" = "-t" ] || [ "$1" = "-T" ] || [ "$1" = "--tag" ] || [ "$1" = "--TAG" ]; then + elif echo "$1" | grep -q -i -e "^-t$" -e "^--tag$"; then if [ -n "${TAGNAME}" ]; then echo "[ERROR] already --tag(-t) option is specified(${TAGNAME})." 1>&2 echo "unknown" @@ -129,7 +129,7 @@ while [ $# -ne 0 ]; do fi TAGNAME="$1" - elif [ "$1" = "-s" ] || [ "$1" = "-S" ] || [ "$1" = "--short" ] || [ "$1" = "--SHORT" ]; then + elif echo "$1" | grep -q -i -e "^-s$" -e "^--short$"; then if [ "${ISSHORT}" -eq 1 ]; then echo "[ERROR] already --short(-s) option is specified." 1>&2 echo "unknown" diff --git a/buildutils/make_commit_hash_source.sh b/buildutils/make_commit_hash_source.sh index 59036c8..8fa3aba 100755 --- a/buildutils/make_commit_hash_source.sh +++ b/buildutils/make_commit_hash_source.sh @@ -50,7 +50,7 @@ func_usage() echo "" echo "Usage: $1 [--help(-h)] [--direct commit_hash(-dch) ] " echo " --help(-h) print help." - echo " --direct commit_hash(-dch) the commit_hash value directly when .git directory does not exist." + echo " --direct_commit_hash(-dch) the commit_hash value directly when .git directory does not exist." echo " file path specify output file path" echo " value name specify variable name in output C source file" echo "" @@ -63,11 +63,11 @@ while [ $# -ne 0 ]; do if [ -z "$1" ]; then break - elif [ "$1" = "-h" ] || [ "$1" = "-H" ] || [ "$1" = "--help" ] || [ "$1" = "--HELP" ]; then + elif echo "$1" | grep -q -i -e "^-h$" -e "^--help$"; then func_usage "${PRGNAME}" exit 0 - elif [ "$1" = "-dch" ] || [ "$1" = "-DCH" ] || [ "$1" = "--direct commit_hash" ] || [ "$1" = "--DIRECT COMMIT_HASH" ]; then + elif echo "$1" | grep -q -i -e "^-dch$" -e "^--direct_commit_hash$"; then if [ -n "${DIRECT_COMMIT_HASH}" ]; then echo "[ERROR] Already --direct_commit_hash(-dch) option is specified(${DIRECT_COMMIT_HASH})." 1>&2 exit 1 diff --git a/buildutils/make_description.sh b/buildutils/make_description.sh index 5ffc604..c138730 100755 --- a/buildutils/make_description.sh +++ b/buildutils/make_description.sh @@ -67,11 +67,11 @@ while [ $# -ne 0 ]; do if [ -z "$1" ]; then break - elif [ "$1" = "-h" ] || [ "$1" = "-H" ] || [ "$1" = "--help" ] || [ "$1" = "--HELP" ]; then + elif echo "$1" | grep -q -i -e "^-h$" -e "^--help$"; then func_usage "${PRGNAME}" exit 0 - elif [ "$1" = "-s" ] || [ "$1" = "-S" ] || [ "$1" = "--short" ] || [ "$1" = "--SHORT" ]; then + elif echo "$1" | grep -q -i -e "^-s$" -e "^--short$"; then if [ "${EXCLUSIVE_OPT}" -eq 1 ]; then echo "[ERROR] already one of eclusive options( --short(-s), --long(-l), --esclong(-e), --deblong(-d) ) is specified." 1>&2 echo "No description because the ${PRGNAME} program failed to extract the description." @@ -80,7 +80,7 @@ while [ $# -ne 0 ]; do IS_SHORT=1 EXCLUSIVE_OPT=1 - elif [ "$1" = "-l" ] || [ "$1" = "-L" ] || [ "$1" = "--long" ] || [ "$1" = "--LONG" ]; then + elif echo "$1" | grep -q -i -e "^-l$" -e "^--long$"; then if [ "${EXCLUSIVE_OPT}" -eq 1 ]; then echo "[ERROR] already one of eclusive options( --short(-s), --long(-l), --esclong(-e), --deblong(-d) ) is specified." 1>&2 echo "No description because the ${PRGNAME} program failed to extract the description." @@ -90,7 +90,7 @@ while [ $# -ne 0 ]; do IS_DEB_CONTROL_FILE=0 EXCLUSIVE_OPT=1 - elif [ "$1" = "-e" ] || [ "$1" = "-E" ] || [ "$1" = "--esclong" ] || [ "$1" = "--ESCLONG" ]; then + elif echo "$1" | grep -q -i -e "^-e$" -e "^--esclong$"; then if [ "${EXCLUSIVE_OPT}" -eq 1 ]; then echo "[ERROR] already one of eclusive options( --short(-s), --long(-l), --esclong(-e), --deblong(-d) ) is specified." 1>&2 echo "No description because the ${PRGNAME} program failed to extract the description." @@ -107,7 +107,7 @@ while [ $# -ne 0 ]; do # ESC_LF_CHAR='\n'\\ - elif [ "$1" = "-d" ] || [ "$1" = "-D" ] || [ "$1" = "--deblong" ] || [ "$1" = "--DEBLONG" ]; then + elif echo "$1" | grep -q -i -e "^-d$" -e "^--deblong$"; then if [ "${EXCLUSIVE_OPT}" -eq 1 ]; then echo "[ERROR] already one of eclusive options( --short(-s), --long(-l), --esclong(-e), --deblong(-d) ) is specified." 1>&2 echo "No description because the ${PRGNAME} program failed to extract the description." diff --git a/buildutils/make_release_version_file.sh b/buildutils/make_release_version_file.sh index 8a2331f..1416080 100755 --- a/buildutils/make_release_version_file.sh +++ b/buildutils/make_release_version_file.sh @@ -68,31 +68,31 @@ while [ $# -ne 0 ]; do if [ -z "$1" ]; then break - elif [ "$1" = "-h" ] || [ "$1" = "-H" ] || [ "$1" = "--help" ] || [ "$1" = "--HELP" ]; then + elif echo "$1" | grep -q -i -e "^-h$" -e "^--help$"; then func_usage "${PRGNAME}" exit 0 - elif [ "$1" = "-ng" ] || [ "$1" = "-NG" ] || [ "$1" = "--not_use_git" ] || [ "$1" = "--NOT_USE_GIT" ]; then + elif echo "$1" | grep -q -i -e "^-ng$" -e "^--not_use_git$"; then if [ "${NOT_USE_GIT}" -ne 0 ]; then echo "[ERROR] already --not_use_git(-ng) option is specified." 1>&2 exit 1 fi NOT_USE_GIT=1 - elif [ "$1" = "-nd" ] || [ "$1" = "-ND" ] || [ "$1" = "--no_check_ver_diff" ] || [ "$1" = "--NO_CHECK_VER_DIFF" ]; then + elif echo "$1" | grep -q -i -e "^-nd$" -e "^--no_check_ver_diff$"; then if [ "${NO_CHECK_VER_DIFF}" -ne 0 ]; then echo "[ERROR] already --no_check_ver_diff(-nd) option is specified." 1>&2 exit 1 fi NO_CHECK_VER_DIFF=1 - elif [ "$1" = "-f" ] || [ "$1" = "-F" ] || [ "$1" = "--file" ] || [ "$1" = "--FILE" ]; then + elif echo "$1" | grep -q -i -e "^-f$" -e "^--file$"; then if [ -n "${CHANGELOG_FILE}" ]; then echo "[ERROR] already --file(-f) option is specified(${CHANGELOG_FILE})." 1>&2 exit 1 fi shift - if [ $# -eq 0 ] || [ -z "$1" ]; then + if [ $# -eq 0 ]; then echo "[ERROR] Must set changelog file path after -file(-f) option." 1>&2 exit 1 fi diff --git a/buildutils/make_rpm_changelog.sh b/buildutils/make_rpm_changelog.sh index 37c5e9e..5a1875a 100755 --- a/buildutils/make_rpm_changelog.sh +++ b/buildutils/make_rpm_changelog.sh @@ -61,7 +61,7 @@ while [ $# -ne 0 ]; do if [ -z "$1" ]; then break - elif [ "$1" = "-h" ] || [ "$1" = "-H" ] || [ "$1" = "--help" ] || [ "$1" = "--HELP" ]; then + elif echo "$1" | grep -q -i -e "^-h$" -e "^--help$"; then func_usage "${PRGNAME}" exit 0 diff --git a/buildutils/make_variables.sh b/buildutils/make_variables.sh index 7eb1cbb..d230f62 100755 --- a/buildutils/make_variables.sh +++ b/buildutils/make_variables.sh @@ -65,11 +65,11 @@ while [ $# -ne 0 ]; do if [ -z "$1" ]; then break - elif [ "$1" = "-h" ] || [ "$1" = "-H" ] || [ "$1" = "--help" ] || [ "$1" = "--HELP" ]; then + elif echo "$1" | grep -q -i -e "^-h$" -e "^--help$"; then func_usage "${PRGNAME}" exit 0 - elif [ "$1" = "-pv" ] || [ "$1" = "-PV" ] || [ "$1" = "--pkg_version" ] || [ "$1" = "--PKG_VERSION" ]; then + elif echo "$1" | grep -q -i -e "^-pv$" -e "^--pkg_version$"; then if [ "${EXCLUSIVE_OPT}" -eq 1 ]; then echo "[ERROR] already one of eclusive options( --pkg_version(-pv), --lib_version_info(-lvi), --lib_version_for_link(-lvl), --major_number(-mn), --debhelper_dep(-dd), --debhelper_dep_with_systemd(-dds), --rpmpkg_group(-rg) ) is specified." 1>&2 printf '0' @@ -78,7 +78,7 @@ while [ $# -ne 0 ]; do PRGMODE="PKG" EXCLUSIVE_OPT=1 - elif [ "$1" = "-lvi" ] || [ "$1" = "-LVI" ] || [ "$1" = "--lib_version_info" ] || [ "$1" = "--LIB_VERSION_INFO" ]; then + elif echo "$1" | grep -q -i -e "^-lvi$" -e "^--lib_version_info$"; then if [ "${EXCLUSIVE_OPT}" -eq 1 ]; then echo "[ERROR] already one of eclusive options( --pkg_version(-pv), --lib_version_info(-lvi), --lib_version_for_link(-lvl), --major_number(-mn), --debhelper_dep(-dd), --debhelper_dep_with_systemd(-dds), --rpmpkg_group(-rg) ) is specified." 1>&2 printf '0' @@ -87,7 +87,7 @@ while [ $# -ne 0 ]; do PRGMODE="LIB" EXCLUSIVE_OPT=1 - elif [ "$1" = "-lvl" ] || [ "$1" = "-LVL" ] || [ "$1" = "--lib_version_for_link" ] || [ "$1" = "--LIB_VERSION_FOR_LINK" ]; then + elif echo "$1" | grep -q -i -e "^-lvl$" -e "^--lib_version_for_link$"; then if [ "${EXCLUSIVE_OPT}" -eq 1 ]; then echo "[ERROR] already one of eclusive options( --pkg_version(-pv), --lib_version_info(-lvi), --lib_version_for_link(-lvl), --major_number(-mn), --debhelper_dep(-dd), --debhelper_dep_with_systemd(-dds), --rpmpkg_group(-rg) ) is specified." 1>&2 printf '0' @@ -96,7 +96,7 @@ while [ $# -ne 0 ]; do PRGMODE="LINK" EXCLUSIVE_OPT=1 - elif [ "$1" = "-mn" ] || [ "$1" = "-MN" ] || [ "$1" = "--major_number" ] || [ "$1" = "--MAJOR_NUMBER" ]; then + elif echo "$1" | grep -q -i -e "^-mn$" -e "^--major_number$"; then if [ "${EXCLUSIVE_OPT}" -eq 1 ]; then echo "[ERROR] already one of eclusive options( --pkg_version(-pv), --lib_version_info(-lvi), --lib_version_for_link(-lvl), --major_number(-mn), --debhelper_dep(-dd), --debhelper_dep_with_systemd(-dds), --rpmpkg_group(-rg) ) is specified." 1>&2 printf '0' @@ -105,7 +105,7 @@ while [ $# -ne 0 ]; do PRGMODE="MAJOR" EXCLUSIVE_OPT=1 - elif [ "$1" = "-dd" ] || [ "$1" = "-DD" ] || [ "$1" = "--debhelper_dep" ] || [ "$1" = "--DEBHELPER_DEP" ]; then + elif echo "$1" | grep -q -i -e "^-dd$" -e "^--debhelper_dep$"; then if [ "${EXCLUSIVE_OPT}" -eq 1 ]; then echo "[ERROR] already one of eclusive options( --pkg_version(-pv), --lib_version_info(-lvi), --lib_version_for_link(-lvl), --major_number(-mn), --debhelper_dep(-dd), --debhelper_dep_with_systemd(-dds), --rpmpkg_group(-rg) ) is specified." 1>&2 printf '0' @@ -115,7 +115,7 @@ while [ $# -ne 0 ]; do DEB_WITH_SYSTEMD=0 EXCLUSIVE_OPT=1 - elif [ "$1" = "-dds" ] || [ "$1" = "-DDS" ] || [ "$1" = "--debhelper_dep_with_systemd" ] || [ "$1" = "--DEBHELPER_DEP_WITH_SYSTEMD" ]; then + elif echo "$1" | grep -q -i -e "^-dds$" -e "^--debhelper_dep_with_systemd$"; then if [ "${EXCLUSIVE_OPT}" -eq 1 ]; then echo "[ERROR] already one of eclusive options( --pkg_version(-pv), --lib_version_info(-lvi), --lib_version_for_link(-lvl), --major_number(-mn), --debhelper_dep(-dd), --debhelper_dep_with_systemd(-dds), --rpmpkg_group(-rg) ) is specified." 1>&2 printf '0' @@ -125,7 +125,7 @@ while [ $# -ne 0 ]; do DEB_WITH_SYSTEMD=1 EXCLUSIVE_OPT=1 - elif [ "$1" = "-rg" ] || [ "$1" = "-RG" ] || [ "$1" = "--rpmpkg_group" ] || [ "$1" = "--RPMPKG_GROUP" ]; then + elif echo "$1" | grep -q -i -e "^-rg$" -e "^--rpmpkg_group$"; then if [ "${EXCLUSIVE_OPT}" -eq 1 ]; then echo "[ERROR] already one of eclusive options( --pkg_version(-pv), --lib_version_info(-lvi), --lib_version_for_link(-lvl), --major_number(-mn), --debhelper_dep(-dd), --debhelper_dep_with_systemd(-dds), --rpmpkg_group(-rg) ) is specified." 1>&2 printf '0' diff --git a/buildutils/rpm_build.sh b/buildutils/rpm_build.sh index 8ba71af..ffe69c2 100755 --- a/buildutils/rpm_build.sh +++ b/buildutils/rpm_build.sh @@ -86,11 +86,11 @@ while [ $# -ne 0 ]; do if [ -z "$1" ]; then break - elif [ "$1" = "-h" ] || [ "$1" = "-H" ] || [ "$1" = "--help" ] || [ "$1" = "--HELP" ]; then + elif echo "$1" | grep -q -i -e "^-h$" -e "^--help$"; then func_usage "${PRGNAME}" exit 0 - elif [ "$1" = "-b" ] || [ "$1" = "-B" ] || [ "$1" = "--buildnum" ] || [ "$1" = "--BUILDNUM" ]; then + elif echo "$1" | grep -q -i -e "^-b$" -e "^--buildnum$"; then if [ "${BUILD_NUMBER}" -ne 0 ]; then echo "[ERROR] Already --buildnum(-b) option is specified(${BUILD_NUMBER})." 1>&2 exit 1 @@ -110,7 +110,7 @@ while [ $# -ne 0 ]; do fi BUILD_NUMBER="$1" - elif [ "$1" = "-p" ] || [ "$1" = "-P" ] || [ "$1" = "--product" ] || [ "$1" = "--PRODUCT" ]; then + elif echo "$1" | grep -q -i -e "^-p$" -e "^--product$"; then if [ -n "${PACKAGE_NAME}" ]; then echo "[ERROR] Already --product(-p) option is specified(${PACKAGE_NAME})." 1>&2 exit 1 @@ -122,7 +122,7 @@ while [ $# -ne 0 ]; do fi PACKAGE_NAME="$1" - elif [ "$1" = "-y" ] || [ "$1" = "-Y" ] || [ "$1" = "--yes" ] || [ "$1" = "--YES" ]; then + elif echo "$1" | grep -q -i -e "^-y$" -e "^--yes$"; then if [ "${NO_INTERACTIVE}" -ne 0 ]; then echo "[ERROR] Already --yes(-y) option is specified." 1>&2 exit 1 @@ -172,9 +172,9 @@ if [ "${NO_INTERACTIVE}" -eq 0 ]; then printf '[INPUT] Confirm (y/n) : ' read -r CONFIRM - if [ "${CONFIRM}" = "y" ] || [ "${CONFIRM}" = "Y" ] || [ "${CONFIRM}" = "yes" ] || [ "${CONFIRM}" = "YES" ]; then + if echo "${CONFIRM}" | grep -q -i -e "^y$" -e "^yes$"; then IS_CONFIRMED=1 - elif [ "${CONFIRM}" = "n" ] || [ "${CONFIRM}" = "N" ] || [ "${CONFIRM}" = "no" ] || [ "${CONFIRM}" = "NO" ]; then + elif echo "${CONFIRM}" | grep -q -i -e "^n$" -e "^no$"; then echo "Interrupt this processing, bye..." exit 0 fi diff --git a/configure.ac b/configure.ac index 44f7670..d260676 100644 --- a/configure.ac +++ b/configure.ac @@ -144,9 +144,9 @@ AS_IF([test "$PKG_CONFIG" = "no"], [AC_MSG_ERROR(You have to install pkg-config # # Version list for Libraries # -AC_SUBST([LIB_MINVER_CHMPX], "1.0.106") -AC_SUBST([LIB_MINVER_LIBK2HASH], "1.0.97") -AC_SUBST([LIB_MINVER_LIBFULLOCK], "1.0.61") +AC_SUBST([LIB_MINVER_CHMPX], "1.0.108") +AC_SUBST([LIB_MINVER_LIBK2HASH], "1.0.98") +AC_SUBST([LIB_MINVER_LIBFULLOCK], "1.0.62") # # Checking Libraries @@ -161,9 +161,9 @@ AC_ARG_ENABLE(check-depend-libs, esac] ) AS_IF([test ${check_depend_libs} = 1], [AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no)]) -AS_IF([test ${check_depend_libs} = 1], [PKG_CHECK_MODULES([fullock], [libfullock >= 1.0.61], [], [AC_MSG_ERROR(not found libfullock package)])]) -AS_IF([test ${check_depend_libs} = 1], [PKG_CHECK_MODULES([k2hash], [libk2hash >= 1.0.97], [], [AC_MSG_ERROR(not found k2hash package)])]) -AS_IF([test ${check_depend_libs} = 1], [PKG_CHECK_MODULES([chmpx], [libchmpx >= 1.0.106], [], [AC_MSG_ERROR(not found chmpx package)])]) +AS_IF([test ${check_depend_libs} = 1], [PKG_CHECK_MODULES([fullock], [libfullock >= 1.0.62], [], [AC_MSG_ERROR(not found libfullock package)])]) +AS_IF([test ${check_depend_libs} = 1], [PKG_CHECK_MODULES([k2hash], [libk2hash >= 1.0.98], [], [AC_MSG_ERROR(not found k2hash package)])]) +AS_IF([test ${check_depend_libs} = 1], [PKG_CHECK_MODULES([chmpx], [libchmpx >= 1.0.108], [], [AC_MSG_ERROR(not found chmpx package)])]) # # CFLAGS/CXXFLAGS diff --git a/tests/test.sh b/tests/test.sh index 71860fb..28c3322 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -335,15 +335,19 @@ stop_process() # # Check running status # - if ! ps -p "${_ONE_PID}" >/dev/null 2>&1; then + # shellcheck disable=SC2009 + if ! ( ps -o pid,stat ax 2>/dev/null | grep -v 'PID' | awk '$2~/^[^Z]/ { print $1 }' | grep -q "^${_ONE_PID}$" || exit 1 && exit 0 ); then break fi + # # Try HUP # kill -HUP "${_ONE_PID}" > /dev/null 2>&1 sleep 1 - if ! ps -p "${_ONE_PID}" >/dev/null 2>&1; then + + # shellcheck disable=SC2009 + if ! ( ps -o pid,stat ax 2>/dev/null | grep -v 'PID' | awk '$2~/^[^Z]/ { print $1 }' | grep -q "^${_ONE_PID}$" || exit 1 && exit 0 ); then break fi @@ -352,7 +356,9 @@ stop_process() # kill -KILL "${_ONE_PID}" > /dev/null 2>&1 sleep 1 - if ! ps -p "${_ONE_PID}" >/dev/null 2>&1; then + + # shellcheck disable=SC2009 + if ! ( ps -o pid,stat ax 2>/dev/null | grep -v 'PID' | awk '$2~/^[^Z]/ { print $1 }' | grep -q "^${_ONE_PID}$" || exit 1 && exit 0 ); then break fi _MAX_TRYCOUNT=$((_MAX_TRYCOUNT - 1)) @@ -360,11 +366,11 @@ stop_process() if [ "${_MAX_TRYCOUNT}" -le 0 ]; then # shellcheck disable=SC2009 - if ps -p "${_ONE_PID}" | grep -v PID | grep -q -i 'defunct'; then - PRNWARN "Could not stop ${_ONE_PID} process, because it has defunct status. So assume we were able to stop it." - else + if ( ps -o pid,stat ax 2>/dev/null | grep -v 'PID' | awk '$2~/^[^Z]/ { print $1 }' | grep -q "^${_ONE_PID}$" || exit 1 && exit 0 ); then PRNERR "Could not stop ${_ONE_PID} process" _STOP_RESULT=1 + else + PRNWARN "Could not stop ${_ONE_PID} process, because it has maybe defunct status. So assume we were able to stop it." fi fi done