/fw/bin/fw-init.in
Autoconf | 186 lines | 115 code | 38 blank | 33 comment | 28 complexity | 08bdd9a62fbe658ac5914a8e99fc9179 MD5 | raw file
Possible License(s): BSD-3-Clause, MPL-2.0-no-copyleft-exception
- #! /bin/sh
- #---------------------------------------------------------------------
- # chicken and egg
- #---------------------------------------------------------------------
- which perl >/dev/null 2>/dev/null || {
- echo "fw-init: fatal: can't locate perl" 1>&2
- exit 1
- }
- if test -z "${FW_ROOT}"
- then
- FW_ROOT=`echo "$0" | perl -pe 's%bin//?fw-init$%%;'`
- export FW_ROOT
- fi
- test -f "${FW_ROOT}/share/fw/sh/fw-find.sh" || {
- echo "fw-init: fatal: can't determine FW_ROOT" 1>&2
- echo "fw-init; fatal: please set the environment variable" 1>&2
- exit 1
- }
- . "${FW_ROOT}/share/fw/sh/fw-find.sh"
- #---------------------------------------------------------------------
- # routines
- #---------------------------------------------------------------------
- fw_source "fw-init" "sh/fatal.sh"
- fw_source "fw-init" "sh/fw-exec.sh"
- fw_source "fw-init" "sh/parse-args.sh"
- fw_source "fw-init" "sh/validate-args.sh"
- base_initialize () \
- {
- local maintainer
- local who
- local where
- fw_exec "revision/$revision/init" "$@" || fatal "fw-init"
- cd "$name" || fatal "fw-init"
- ln -sf "${FW_ROOT}/share/fw" . || fatal "fw-init"
- fw_exec "revision/$revision/ignore-files" fw || fatal "fw-init"
- test -z "$localize" || test ! -e "${FW_ROOT}/share/fw.local" || (
- dir=`pwd`
- cd ${FW_ROOT}/share/
- find "fw.local" -print | cpio -pvd "$dir"
- ) || fatal "fw-init"
- cat > bootstrap <<EOD || fatal "fw-init"
- #! /bin/sh
- if test -d fw/bin
- then
- PATH="\`pwd\`/fw/bin:\$PATH"
- export PATH
- fi
- fwb=\`which fw-bootstrap\`
- if test -z "\$fwb"
- then
- echo "bootstrap: fatal: fw-bootstrap not installed or not in PATH" 1>&2
- exit 1
- fi
- "\$fwb" --fw_version "@PACKAGE_VERSION@" $@ "\$@"
- EOD
- chmod +x bootstrap || fatal "fw-init"
- fw_exec "revision/$revision/add-files" bootstrap || fatal "fw-init"
- mkdir fw-pkgin || fatal "fw-init"
- fw_exec "revision/$revision/add-dir" fw-pkgin || fatal "fw-init"
- (
- cd fw-pkgin || exit 1
- cat <<EOD > config || exit 1
- # The FW_PACKAGE_MAINTAINER field is populated with the environment
- # variable FW_PACKAGE_DEFAULT_MAINTAINER if non-empty at init time
- FW_PACKAGE_NAME="$name"
- FW_PACKAGE_VERSION="0.0.0"
- FW_PACKAGE_MAINTAINER="${FW_PACKAGE_DEFAULT_MAINTAINER:="`whoami` <`whoami`@`hostname`>"}"
- FW_PACKAGE_SHORT_DESCRIPTION="A short description."
- FW_PACKAGE_DESCRIPTION=\`cat README\`
- FW_PACKAGE_ARCHITECTURE_DEPENDENT="1"
- # Dependency information. The native syntax corresponds to Debian,
- # http://www.debian.org/doc/debian-policy/ch-relationships.html
- # Section 7.1 "Syntax of Relationship Fields"
- #
- # For other packaging systems, the syntax is translated for you.
- FW_PACKAGE_DEPENDS=""
- FW_PACKAGE_CONFLICTS=""
- FW_PACKAGE_PROVIDES=""
- FW_PACKAGE_REPLACES=""
- FW_PACKAGE_SUGGESTS=""
- FW_PACKAGE_BUILD_DEPENDS=""
- FW_PACKAGE_BUILD_CONFLICTS=""
- # dupload is used for submitting debian packages to a package archive
- # The FW_DUPLOAD_ARGS field is populated with the environment variable
- # FW_DEFAULT_DUPLOAD_ARGS if non-empty at init time
- FW_DUPLOAD_ARGS=\${FW_DUPLOAD_ARGS-"${FW_DEFAULT_DUPLOAD_ARGS:="-q"}"}
- # scp+createrepo is used for submitting rpm packages to a package archive
- # The FW_RPM_REPO_USER, FW_RPM_REPO_HOST, FW_RPM_REPO_BASEDIR,
- # and FW_RPM_POSTCREATEREPO_COMMANDS variables are populated with
- # FW_RPM_REPO_USER_DEFAULT, FW_RPM_REPO_HOST_DEFAULT,
- # FW_RPM_REPO_BASEDIR_DEFAULT, and FW_RPM_POSTCREATEREPO_COMMANDS_DEFAULT
- # respectively if non-empty at init time
- FW_RPM_REPO_USER=\${FW_RPM_REPO_USER-"${FW_RPM_REPO_USER_DEFAULT:=\`whoami\`}"}
- FW_RPM_REPO_HOST=\${FW_RPM_REPO_HOST-"${FW_RPM_REPO_HOST_DEFAULT:=localhost}"}
- FW_RPM_REPO_BASEDIR=\${FW_RPM_REPO_BASEDIR-"${FW_RPM_REPO_BASEDIR_DEFAULT}"}
- FW_RPM_CREATEREPO_ARGS=\${FW_RPM_CREATEREPO_ARGS-"${FW_RPM_CREATEREPO_ARGS_DEFAULT:="-q --database"}"}
- # this variable controls whether createrepo is run incrementally (--update).
- # possible settings are yes (always do it), no (never do it), and
- # auto (do it if the repository has been previously initialized)
- FW_RPM_CREATEREPO_INCREMENTAL=\${FW_RPM_CREATEREPO_INCREMENTAL-"auto"}
- # these commands will be run after a successful createrepo run
- FW_RPM_POSTCREATEREPO_COMMANDS=\${FW_RPM_POSTCREATEREPO_COMMANDS-"${FW_RPM_POSTCREATEREPO_COMMANDS_DEFAULT:="true"}"}
- # here's a suggestion:
- # FW_RPM_POSTCREATEREPO_COMMANDS="gpg --detach-sign --armor repodata/repomd.xml"
- EOD
- for x in post-install \
- post-remove \
- pre-install \
- pre-remove \
- start \
- stop
- do
- fw_find "build/automake/fw-pkgin/$x" file
- test -z "$file" && exit 1
- cp -f "$file" . || exit 1
- chmod +w "$x" || exit 1
- done
- fw_exec "revision/$revision/add-files" config \
- post-install \
- post-remove \
- pre-install \
- pre-remove \
- start \
- stop
- ) || fatal "fw-init"
- fw_find "revision/$revision/init-fw-pkgin-config" file
- test -z "$file" || {
- "$file" "$@" || fatal "fw-init"
- }
- }
- run_init () \
- {
- fw_exec "template/$template/init" "$@" || {
- echo "fw-init: error: init failed" 1>&2
- fatal "fw-init"
- }
- }
- #---------------------------------------------------------------------
- # main
- #---------------------------------------------------------------------
- parse_args "fw-init" "$@"
- test -z "$help" || {
- echo "usage: fw-init [ --trace ] --name name --revision revision --template template [ template specific args ... ] " 1>&2
- exit 0
- }
- validate_args "fw-init" "name revision template" "revision template"
- base_initialize "$@"
- run_init "$@"