diff --git a/make/projects-dir.mk b/make/projects-dir.mk index c6c3fbcb..926c0d0e 100644 --- a/make/projects-dir.mk +++ b/make/projects-dir.mk @@ -101,10 +101,7 @@ ifneq ($(EXCLUDE_FROM_BUILD),) endif # non-interactive mode -INTERACTIVE ?= true -ifneq ($(INTERACTIVE),true) - DASH_Y := -y -endif +INTERACTIVE ?= auto # ------------ external programs II @@ -119,6 +116,7 @@ endif JW_PKG_PY = $(TIME) python3 $(JWB_SCRIPT_DIR)/jw-pkg.py --prefix $(shell pwd) $(JW_PKG_PY_EXTRA_OPTS) JW_PKG_PY_PROJECTS = $(JW_PKG_PY) projects JW_PKG_PY_BUILD = $(JW_PKG_PY_PRJECTS) build $(JW_PKG_PY_EXTRA_BUILD_OPTS) +PKG_MANAGER ?= $(JW_PKG_PY) distro --interactive=$(INTERACTIVE) PGIT_SH := /bin/bash $(JWB_SCRIPT_DIR)/pgit.sh ifneq ($(origin PROJECTS_DIR_REMOTE_BASE),undefined) @@ -140,7 +138,6 @@ ifneq ($(JANWARE_USER),) endif PURGE_SH = /bin/bash $(firstword $(wildcard $(JWB_SCRIPT_DIR)/purge-stale-projects.sh $(JW_PKG_BINDIR)/purge-stale-projects.sh) purge-not-found) -PKG_MANAGER_SH ?= /bin/bash $(firstword $(wildcard $(JWB_SCRIPT_DIR)/pkg-manager.sh $(JW_PKG_BINDIR)/pkg-manager.sh) pkg-manager-not-found) CREATE_PROJECT_SH ?= /bin/bash $(firstword $(wildcard $(JWB_SCRIPT_DIR)/jw-pkg-create-project.sh $(JW_PKG_BINDIR)/jw-pkg-create-project.sh) jw-pkg-create-project-not-found) LIST_VCS_FILES_SH = /bin/bash $(firstword $(wildcard $(JWB_SCRIPT_DIR)/scm.sh $(JW_PKG_BINDIR)/scm.sh) scm-sh-not-found) ls-files GIT_SRV_ADMIN_SH = JW_PKG_SSH_EXTRA_OPTS="$(JW_PKG_SSH_EXTRA_OPTS)" $(GIT_SSH) $(JANWARE_USER)@git.janware.com $(JW_PKG_REMOTE_BINDIR)/git-srv-admin.sh @@ -241,13 +238,13 @@ cloc: # --- package-related targets pkg-manager-refresh: - $(PKG_MANAGER_SH) refresh $(DASH_Y) + $(PKG_MANAGER) refresh pkg-install-build-deps: - $(PKG_MANAGER_SH) install $(DASH_Y) "$(BASE_PKGS) $(shell $(JW_PKG_PY_PROJECTS) required-os-pkg --skip-excluded --flavours build $(TARGET_PROJECTS))" + $(PKG_MANAGER) install $(BASE_PKGS) $(shell $(JW_PKG_PY_PROJECTS) required-os-pkg --skip-excluded --flavours build $(TARGET_PROJECTS)) pkg-install-release-deps: - $(PKG_MANAGER_SH) install $(DASH_Y) "$(BASE_PKGS) $(shell $(JW_PKG_PY_PROJECTS) required-os-pkg --skip-excluded --flavours 'build run release' $(TARGET_PROJECTS))" + $(PKG_MANAGER) install $(BASE_PKGS) $(shell $(JW_PKG_PY_PROJECTS) required-os-pkg --skip-excluded --flavours 'build run release' $(TARGET_PROJECTS)) pkg-release-reinstall: $(PREREQ_RELEASE) diff --git a/make/topdir.mk b/make/topdir.mk index 09e3aac1..58a18c98 100644 --- a/make/topdir.mk +++ b/make/topdir.mk @@ -21,7 +21,8 @@ GIT_DESCR = $(TOPDIR)/.git/description GIT_MAIN_BRANCH ?= master OPT_JANWARE_PROJECT ?= -j -PKG_MANAGER_SH ?= /bin/bash $(firstword $(wildcard $(JWB_SCRIPT_DIR)/pkg-manager.sh /opt/jw-pkg/bin/pkg-manager.sh) pkg-manager-not-found) +INTERACTIVE ?= auto +PKG_MANAGER ?= $(JW_PKG_PY) distro --interactive=$(INTERACTIVE) ifeq ($(OPT_JANWARE_PROJECT),-j) REMOTE_GIT_FLAVOUR ?= proj @@ -209,16 +210,16 @@ git-pull-%: fi pkg-manager-refresh: - $(PKG_MANAGER_SH) refresh $(DASH_Y) + $(PKG_MANAGER) refresh pkg-install-build-deps: - $(PKG_MANAGER_SH) install $(DASH_Y) $(BASE_PKGS) $(shell $(proj_query_cmd) required-os-pkg --skip-excluded --flavours "build" $(PROJECT)) + $(PKG_MANAGER) install $(BASE_PKGS) $(shell $(proj_query_cmd) required-os-pkg --skip-excluded --flavours "build" $(PROJECT)) pkg-install-release-deps: - $(PKG_MANAGER_SH) install $(DASH_Y) $(BASE_PKGS) $(shell $(proj_query_cmd) required-os-pkg --skip-excluded --flavours "build run release" $(PROJECT)) + $(PKG_MANAGER) install $(BASE_PKGS) $(shell $(proj_query_cmd) required-os-pkg --skip-excluded --flavours "build run release" $(PROJECT)) pkg-install-testbuild-deps: - $(PKG_MANAGER_SH) install $(DASH_Y) $(BASE_PKGS) $(shell $(proj_query_cmd) pkg-requires --delimiter=' ' --no-version build,run,release $(PROJECT)) + $(PKG_MANAGER) install $(BASE_PKGS) $(shell $(proj_query_cmd) pkg-requires --delimiter=' ' --no-version build,run,release $(PROJECT)) echo-hash: $(Q)/bin/bash $(PKG_SH_EXE) hash diff --git a/scripts/pkg-manager.sh b/scripts/pkg-manager.sh deleted file mode 100644 index 50c9cc4d..00000000 --- a/scripts/pkg-manager.sh +++ /dev/null @@ -1,168 +0,0 @@ -#!/bin/sh - -log() -{ - echo $@ >&2 -} - -err() -{ - echo $@ >&2 -} - -fatal() -{ - err "Giving up: $@" - exit 1 -} - -usage() -{ - cat<<-EOT - $myname cmd args - EOT -} - -run() -{ - log "Running ==== $@" - "$@" -} - -cmd_dup() -{ - local env opts global_opts - local non_interactive - - set -- `getopt 'y' $*` - while [ "$1" != -- ] ; do - case "$1" in - -y) - non_interactive=1 - ;; - esac - shift - done - shift - - [ "$sudo" ] && sudo="$sudo $env -S" - - case $ID in - opensuse|suse) - [ "$non_interactive" = 1 ] && { - opts="--force-resolution --auto-agree-with-licenses" - global_opts="$global_opts --non-interactive --gpg-auto-import-keys --no-gpg-checks" - } - run $sudo zypper $global_opts dup $opts "$@" - ;; - debian|ubuntu|raspbian) - fatal "Tried to run distribution upgrade on unsupported platform \"$ID\"" - ;; - arch) - fatal "Tried to run distribution upgrade on unsupported platform \"$ID\"" - ;; - centos) - fatal "Tried to run distribution upgrade on unsupported platform \"$ID\"" - ;; - *) - fatal "Tried to install on unsupported platform \"$ID\"" - ;; - esac -} - -cmd_install() -{ - local env opts global_opts - local non_interactive - - set -- `getopt 'y' $*` - while [ "$1" != -- ] ; do - case "$1" in - -y) - non_interactive=1 - ;; - esac - shift - done - shift - - [ "$sudo" ] && sudo="$sudo $env -S" - - case $ID in - opensuse|suse) - [ "$non_interactive" = 1 ] && { - opts="--force-resolution --auto-agree-with-licenses" - global_opts="$global_opts --non-interactive --gpg-auto-import-keys --no-gpg-checks" - } - run $sudo zypper $global_opts install $opts "$@" - ;; - debian|ubuntu|raspbian) - [ "$non_interactive" = 1 ] && { - global_opts="$global_opts -yq" - env="$env DEBIAN_FRONTEND=noninteractive" - } - run $sudo apt-get $global_opts install "$@" - ;; - arch) - [ "$non_interactive" = 1 ] && { - global_opts="$global_opts --noconfirm" - env="$env DEBIAN_FRONTEND=noninteractive" - } - run $sudo pacman $global_opts -S --needed "$@" - ;; - centos) - run $sudo yum $global_opts install -y "$@" - ;; - *) - fatal "Tried to install on unsupported platform \"$ID\"" - ;; - esac -} - -cmd_refresh() -{ - local env opts global_opts - local non_interactive - - set -- `getopt 'y' $*` - while [ "$1" != -- ] ; do - case "$1" in - -y) - non_interactive=1 - ;; - esac - shift - done - shift - - [ "$sudo" ] && sudo="$sudo $env -S" - - case $ID in - opensuse|suse) - [ "$non_interactive" = 1 ] && { - global_opts="$global_opts --non-interactive --gpg-auto-import-keys --no-gpg-checks" - } - run $sudo zypper $global_opts refresh $opts "$@" - ;; - debian|ubuntu|raspbian) - run $sudo apt-get $global_opts update "$@" - ;; - centos) - run $sudo yum $global_opts clean expire-cache "$@" - run $sudo yum $global_opts makecache "$@" - ;; - *) - fatal "Tried to update unsupported platform \"$ID\"" - ;; - esac -} - -# -- here we go -myname=`basename $0` -. /etc/os-release -ID=${ID%%-*} -[ "$EUID" ] || EUID=$(id -un) -[ "$EUID" = 0 ] || sudo=/usr/bin/sudo -cmd="$1" -shift -cmd_$cmd "$@"