From: Michael Tremer Date: Sat, 31 Oct 2009 11:26:27 +0000 (+0100) Subject: naoki: Code cleanup. No functional changes. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cee183e8af613c5c7e5b84aa7386e43e5c444c06;p=ipfire-3.x.git naoki: Code cleanup. No functional changes. --- diff --git a/make.sh b/make.sh index d3d8f6914..c55dd14b8 100755 --- a/make.sh +++ b/make.sh @@ -20,16 +20,9 @@ ############################################################################### # -NAME="IPFire" # Software name -SNAME="ipfire" # Short name -VERSION="3.0-prealpha2" # Version number -SLOGAN="Gluttony" # Software slogan - BASEDIR=/ipfire-3.x -. ${BASEDIR}/tools/ui-functions - -NAOKI=${BASEDIR}/tools/naoki +. ${BASEDIR}/tools/common-include while [ $# -gt 0 ]; do case "${1}" in @@ -37,6 +30,10 @@ while [ $# -gt 0 ]; do DEBUG=1 log DEBUG "Debugging mode enabled by command line." ;; + --toolchain) + TOOLCHAIN=1 + log DEBUG "Toolchain mode enabled by command line." + ;; *) action=${1} shift @@ -46,23 +43,25 @@ while [ $# -gt 0 ]; do shift done +export DEBUG TOOLCHAIN + function package() { local action=${1} shift case "${action}" in dependencies|deps) - echo -e "${BOLD}Build dependencies:${NORMAL} $(package_build_dependencies $@)" - echo -e "${BOLD}Dependencies:${NORMAL} $(package_dependencies $@)" + echo -e "${BOLD}Build dependencies:${NORMAL} $(package_build_dependencies $@ | tr '\n' ' ')" + echo -e "${BOLD}Dependencies:${NORMAL} $(package_runtime_dependencies $@ | tr '\n' ' ')" ;; find) find_package $@ ;; list) - ${NAOKI} --toolchain list + package_list ;; profile|info) - ${NAOKI} profile $@ + package_profile $(find_package $@) ;; _info) package_info $(find_package $@) @@ -70,23 +69,9 @@ function package() { esac } -function listmatch() { - local arg=${1} - shift - - local value - for value in $@; do - if [ "${arg}" == "${value}" ]; then - return 0 - fi - done - return 1 -} - - case "${action}" in package|pkg) - package $@ + package $@e ;; toolchain) TOOLCHAIN=1 diff --git a/tools/common-constants b/tools/common-constants new file mode 100644 index 000000000..2622e95b0 --- /dev/null +++ b/tools/common-constants @@ -0,0 +1,21 @@ + + +BASEDIR=/ipfire-3.x + +DEBUG=1 ## XXX currently always on + +DISTRO_NAME=IPFire +DISTRO_SNAME=ipfire +DISTRO_EPOCH=3 +DISTRO_VERSION=${DISTRO_EPOCH}.0-prealpha2 +DISTRO_SLOGAN="Gluttony" + +# Machine's infotmation +HOSTNAME=$(&2 + exit 1 +fi + +. ${BASEDIR}/tools/common-constants +. ${BASEDIR}/tools/common-package-functions +. ${BASEDIR}/tools/common-ui-functions + +# Read in .config +if [ -e "${BASEDIR}/.config" ]; then + log DEBUG "Loading .config..." + source ${BASEDIR}/.config +fi diff --git a/tools/package-functions b/tools/common-package-functions similarity index 93% rename from tools/package-functions rename to tools/common-package-functions index c6db59060..845eef4a7 100644 --- a/tools/package-functions +++ b/tools/common-package-functions @@ -1,5 +1,4 @@ - -PKG_DIR=${BASEDIR}/pkgs +#!/bin/bash function listmatch() { local arg=${1} @@ -17,7 +16,7 @@ function listmatch() { function is_package() { local package=$(find_package ${1}) - if [ -e "${PKG_DIR}/${package}/${package##*/}.nm" ]; then + if [ -e "${DIR_PKGS}/${package}/${package##*/}.nm" ]; then return 0 else log ERROR "Package ${package} is not known." @@ -29,7 +28,7 @@ function find_package() { local package=${1} #log DEBUG "Searching for package \"${package}\"." - if [ -e "${PKG_DIR}/${package}" ]; then + if [ -e "${DIR_PKGS}/${package}" ]; then echo "${package}" return 0 fi @@ -47,7 +46,7 @@ function find_package() { function package_repos() { local repo - for repo in ${PKG_DIR}/*; do + for repo in ${DIR_PKGS}/*; do if [ ! -d "${repo}" ]; then continue fi @@ -70,12 +69,12 @@ function package_list() { local repo for repo in $(package_repos); do - for package in ${PKG_DIR}/${repo}/*; do + for package in ${DIR_PKGS}/${repo}/*; do if [ ! -d "${package}" ]; then continue fi - package=${package#${PKG_DIR}/} + package=${package#${DIR_PKGS}/} # Skip if package does not fullfill our criteria is_package ${package} || continue @@ -110,11 +109,17 @@ function package_profile() { function package_info() { local p=$(find_package ${1}) - log DEBUG "Fetching package information from ${PKG_DIR}/${p}..." + log DEBUG "Fetching package information from ${DIR_PKGS}/${p}..." + + echo "gothere: ${p}" > .test is_package ${p} || return 1 - CHROOT=0 naoki_make ${p} --without-chroot info | grep -v "^make:" + if [ "${NAOKI_INCLUDE}" = "1" ]; then + CHROOT=0 naoki_make ${p} --without-chroot info | grep -v "^make:" + else + ${NAOKI} info ${p} + fi } function package_get() { diff --git a/tools/ui-functions b/tools/common-ui-functions similarity index 100% rename from tools/ui-functions rename to tools/common-ui-functions diff --git a/tools/naoki b/tools/naoki index e7c663368..e9deaa9f8 100755 --- a/tools/naoki +++ b/tools/naoki @@ -1,5 +1,7 @@ #!/bin/bash +BASEDIR=/ipfire-3.x + . /ipfire-3.x/tools/naoki-include # Read in global configuration @@ -103,7 +105,7 @@ case "${ACTION}" in package_profile ${PKG_NAME} ;; - raw) + raw|info) package_info ${PKG_NAME} ;; diff --git a/tools/naoki-constants b/tools/naoki-constants index 02a4b1755..480fa0f4e 100644 --- a/tools/naoki-constants +++ b/tools/naoki-constants @@ -1,25 +1,8 @@ #!/bin/bash -DEBUG=1 ## XXX currently always on - -DISTRO_NAME=IPFire -DISTRO_SNAME=ipfire -DISTRO_EPOCH=3 -DISTRO_VERSION=${DISTRO_EPOCH}.0-prealpha2 -DISTRO_SLOGAN="Gluttony" - -# Machine's infotmation -HOSTNAME=$(&2 + exit 1 +fi -LOGFILE=${BASEDIR}/naoki.log +export NAOKI_INCLUDE=1 -. ${BASEDIR}/tools/naoki-functions -. ${BASEDIR}/tools/naoki-constants +. ${BASEDIR}/tools/common-include +. ${BASEDIR}/tools/naoki-constants +. ${BASEDIR}/tools/naoki-functions log DEBUG "Started up naoki instance with pid $$"