diff options
author | Marc Kleine-Budde <mkl@pengutronix.de> | 2010-07-16 15:29:26 +0200 |
---|---|---|
committer | Marc Kleine-Budde <mkl@pengutronix.de> | 2010-07-16 15:29:26 +0200 |
commit | 1520848b7812e6daf8f78cf084fbb14f57802082 (patch) | |
tree | db5f006c0d84ecf42a2173aa26a5ea2032038a2c /scripts | |
parent | 97cdd287d8ed06c3154340f04f43d491df669a13 (diff) | |
parent | 219728562e61ab5cf73bb6b5499fb68a36b273d2 (diff) | |
download | ptxdist-1520848b7812e6daf8f78cf084fbb14f57802082.tar.gz ptxdist-1520848b7812e6daf8f78cf084fbb14f57802082.tar.xz |
Merge branch 'next/image_cleanups' of git://git.pengutronix.de/git/mkl/ptxdist
Conflicts:
scripts/lib/ptxd_make_install.sh
This is due to "360f73777af1661d85ae0aa2434b6acde22da9fa" Fix
dependencies to files in projectroot.
The modifications to ptxd_make_install_init have been moved to
ptxd_make_xpkg_prepare.
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/lib/ptxd_make_00-init.sh | 3 | ||||
-rw-r--r-- | scripts/lib/ptxd_make_image_common.sh | 77 | ||||
-rw-r--r-- | scripts/lib/ptxd_make_image_fix_permissions.sh (renamed from scripts/lib/ptxd_make_fixpermissions.sh) | 75 | ||||
-rw-r--r-- | scripts/lib/ptxd_make_image_prepare_work_dir.sh | 74 | ||||
-rw-r--r-- | scripts/lib/ptxd_make_install.sh | 178 | ||||
-rw-r--r-- | scripts/lib/ptxd_make_world_patchin.sh | 2 | ||||
-rw-r--r-- | scripts/lib/ptxd_make_xpkg_common.sh | 43 | ||||
-rw-r--r-- | scripts/lib/ptxd_make_xpkg_finish.sh | 37 | ||||
-rw-r--r-- | scripts/lib/ptxd_make_xpkg_fixup.sh | 32 | ||||
-rw-r--r-- | scripts/lib/ptxd_make_xpkg_prepare.sh | 63 | ||||
-rw-r--r-- | scripts/libptxdist.sh | 34 |
11 files changed, 366 insertions, 252 deletions
diff --git a/scripts/lib/ptxd_make_00-init.sh b/scripts/lib/ptxd_make_00-init.sh index 709f7936d..5568efc2c 100644 --- a/scripts/lib/ptxd_make_00-init.sh +++ b/scripts/lib/ptxd_make_00-init.sh @@ -148,6 +148,9 @@ ptxd_init_ptxdist_path() { PTXDIST_PATH_PATCHES="${PTXDIST_PATH//://patches:}" export PTXDIST_PATH_PATCHES + PTXDIST_PATH_RULES="${PTXDIST_PATH//://rules:}" + export PTXDIST_PATH_RULES + ptxd_init_ptxdist_path_sysroot } diff --git a/scripts/lib/ptxd_make_image_common.sh b/scripts/lib/ptxd_make_image_common.sh new file mode 100644 index 000000000..7cb0ed64d --- /dev/null +++ b/scripts/lib/ptxd_make_image_common.sh @@ -0,0 +1,77 @@ +#!/bin/bash +# +# Copyright (C) 2010 by Marc Kleine-Budde <mkl@pengutronix.de> +# +# See CREDITS for details about who has contributed to this project. +# +# For further information about the PTXdist project and license conditions +# see the README file. +# + + +# +# ptxd_get_ipkg_files - get full path to ipkgs that should be installed +# +# in: +# - $image_pkgs_selected_target space seperated list of selected +# packages +# +# out: +# - $ptxd_reply_ipkg_files array of ipkg files +# - $ptxd_reply_perm_files array of permission files +# +ptxd_get_ipkg_files() { + # map pkg_label to pkg's ipkg files + local -a ptxd_reply + ptxd_do_xpkg_map ${image_pkgs_selected_target} + + unset ptxd_reply_ipkg_files ptxd_reply_perm_files + + set -- "${ptxd_reply[@]}" + while [ ${#} -ne 0 ]; do + # look in "image_ipkg_repo_dirs" for ipkg files + + # FIXME: add IPKG_ARCH, pkg_version? + local -a ipkg_files + ipkg_files="${image_ipkg_repo_dirs[@]/%//${1}_*.ipk}" + + # take first hit + if ptxd_get_path "${ipkg_files[@]}"; then + ptxd_reply_ipkg_files[${#ptxd_reply_ipkg_files[@]}]="${ptxd_reply}" + ptxd_reply_perm_files[${#ptxd_reply_perm_files[@]}]="${ptxd_reply%/*/*}/state/${1}.perms" + else + ptxd_bailout "\ + +Unable to find xpkg file for '${1}', this should not happen! +Run first 'ptxdist clean root' then 'ptxdist images' again. +" + fi + + shift + done + + # + # take care about production build + # + if [ -n "${PTXDIST_PROD_PLATFORMDIR}" ]; then + if ! ptxd_get_path "${PTXDIST_PROD_PLATFORMDIR}/packages/*.ipk"; then + ptxd_bailout "use production BSP: no ipkg files found in '${PTXDIST_PROD_PLATFORMDIR}/packages'" + fi + ptxd_reply_ipkg_files=( "${ptxd_reply_ipkg_files[@]}" "${ptxd_reply[@]}" ) + + if ! ptxd_get_path "${PTXDIST_PROD_PLATFORMDIR}/state/*.perms"; then + ptxd_bailout "use production BSP: no perms files found in '${PTXDIST_PROD_PLATFORMDIR}/state" + fi + ptxd_reply_perm_files=( "${ptxd_reply_perm_files[@]}" "${ptxd_reply[@]}" ) + fi +} +export -f ptxd_get_ipkg_files + + +# +# initialize variables needed for image creation +# +ptxd_make_image_init() { + image_ipkg_repo_dirs=( "${ptx_pkg_dir}" ) +} +export -f ptxd_make_image_init diff --git a/scripts/lib/ptxd_make_fixpermissions.sh b/scripts/lib/ptxd_make_image_fix_permissions.sh index 0d3d7b982..66225bcd8 100644 --- a/scripts/lib/ptxd_make_fixpermissions.sh +++ b/scripts/lib/ptxd_make_image_fix_permissions.sh @@ -8,7 +8,7 @@ # see the README file. # -ptxd_make_fixpermissions_generate() { +ptxd_make_image_fix_permissions_generate() { case "${kind}" in n) # erase existing nodes @@ -25,17 +25,18 @@ EOF ;; esac } -export -f ptxd_make_fixpermissions_generate +export -f ptxd_make_image_fix_permissions_generate -ptxd_make_fixpermissions_check() { +ptxd_make_image_fix_permissions_check() { local workdir="${1}" local ifs_orig="${IFS}" IFS=":" # just care about dev-nodes, for now - egrep "^[n]:" "${permfile}" | while read kind file uid_should gid_should prm_should type major_should minor_should; do + egrep -h "^[n]:" "${ptxd_reply_perm_files[@]}" | + while read kind file uid_should gid_should prm_should type major_should minor_should; do local fixup=false file="${workdir}/${file#/}" @@ -73,44 +74,34 @@ ptxd_make_fixpermissions_check() { fi if [ "${fixup}" = "true" ]; then - ptxd_make_fixpermissions_generate + ptxd_make_image_fix_permissions_generate fi done IFS="${ifs_orig}" } -export -f ptxd_make_fixpermissions_check +export -f ptxd_make_image_fix_permissions_check +# +# ptxd_make_image_fix_permissions - create device nodes in nfsroots +# +ptxd_make_image_fix_permissions() { + ptxd_make_image_init && -ptxd_make_fixpermissions() { - local permfile workdirs opt + local fixscript="${PTXDIST_TEMPDIR}/${FUNCNAME}" && + touch "${fixscript}" && + chmod +x "${fixscript}" && - while getopts "p:r:" opt; do - case "$opt" in - p) - permfile="${OPTARG}" - ;; - r) - workdirs="${workdirs}${workdirs:+:}${OPTARG}" - ;; - *) - ;; - esac - done + # get permission files + local -a ptxd_reply_ipkg_file ptxd_reply_perm_files && + ptxd_get_ipkg_files || return - local fixscript - fixscript="$(mktemp "${PTXDIST_TEMPDIR}/fixpermissions.XXXXXXXXXX")" || ptxd_bailout "failed to create tempfile" - chmod +x "${fixscript}" - - local ifs_orig="${IFS}" - IFS=":" - set -- ${workdirs} - IFS="${ifs_orig}" + set -- "${ptx_nfsroot}" "${ptx_nfsroot_dbg}" exec 3> "${fixscript}" while [ ${#} -ne 0 ]; do - ptxd_make_fixpermissions_check "${1}" || return + ptxd_make_image_fix_permissions_check "${1}" || return shift done exec 3>&- @@ -131,18 +122,7 @@ In order to create them root privileges are required. EOF read -t 5 -p "(Please press enter to start 'sudo' to gain root privileges.)" - if [ ${?} -eq 0 ]; then - sudo "${fixscript}" || { - cat <<EOF - -error: creation of device node(s) failed. - -EOF - return 1 - } - echo - rm "${fixscript}" - else + if [ ${?} -ne 0 ]; then cat >&2 <<EOF @@ -151,6 +131,17 @@ WARNING: NFS-root might not be working correctly! EOF + return + fi + + if ! sudo "${fixscript}"; then + cat <<EOF + +error: creation of device node(s) failed. + +EOF + return 1 fi + echo } -export -f ptxd_make_fixpermissions +export -f ptxd_make_image_fix_permissions diff --git a/scripts/lib/ptxd_make_image_prepare_work_dir.sh b/scripts/lib/ptxd_make_image_prepare_work_dir.sh new file mode 100644 index 000000000..055494e02 --- /dev/null +++ b/scripts/lib/ptxd_make_image_prepare_work_dir.sh @@ -0,0 +1,74 @@ +#!/bin/bash +# +# Copyright (C) 2010 by Marc Kleine-Budde <mkl@pengutronix.de> +# +# See CREDITS for details about who has contributed to this project. +# +# For further information about the PTXdist project and license conditions +# see the README file. +# + + +# +# ptxd_make_image_extract_ipkg_files - extract ipkg for later image generation +# +# in: +# - $image_work_dir directory where ipkg are extracted +# - $image_permissions name of file that should contain all permissions +# - $image_pkgs_selected_target space seperated list of selected +# packages +# - $PTXDIST_IPKG_ARCH_STRING ARCH variable for ipkg files +# - $PTXCONF_IPKG_IPKG_CONF_URL the URL to use in /etc/ipkg.conf +# +# out: +# - $image_permissions file containing all permissions +# +ptxd_make_image_extract_ipkg_files() { + # FIXME: consolidate "ptxd_install_setup_src" + local src="/etc/ipkg.conf" + local ipkg_conf="${PTXDIST_TEMPDIR}/${FUNCNAME}_ipkg.conf" + local -a list ptxd_reply + list=( \ + "${PTXDIST_WORKSPACE}/projectroot${PTXDIST_PLATFORMSUFFIX}${src}" \ + "${PTXDIST_WORKSPACE}/projectroot${src}${PTXDIST_PLATFORMSUFFIX}" \ + "${PTXDIST_WORKSPACE}/projectroot${src}" \ + "${PTXDIST_TOPDIR}/generic${src}" \ + ) + + if ! ptxd_get_path "${list[@]}"; then + local IFS=" +" + ptxd_bailout " +unable to find '${src}' + +These location have been searched: +${list[*]} +" + fi + + rm -rf "${image_work_dir}" && + mkdir -p "${image_work_dir}" && + + ARCH="${PTXDIST_IPKG_ARCH_STRING}" \ + SRC="${PTXCONF_IPKG_IPKG_CONF_URL}" \ + ptxd_replace_magic "${ptxd_reply}" > "${ipkg_conf}" && + + DESTDIR="${image_work_dir}" \ + fakeroot -- ipkg-cl -f "${ipkg_conf}" -o "${image_work_dir}" \ + install "${ptxd_reply_ipkg_files[@]}" && + if ! cat "${ptxd_reply_perm_files[@]}" > "${image_permissions}"; then + echo "${PTXDIST_LOG_PROMPT}error: failed read permission files" >&2 + return 1 + fi + + return +} +export -f ptxd_make_image_extract_ipkg_files + + +ptxd_make_image_prepare_work_dir() { + ptxd_make_image_init && + ptxd_get_ipkg_files && + ptxd_make_image_extract_ipkg_files +} +export -f ptxd_make_image_prepare_work_dir diff --git a/scripts/lib/ptxd_make_install.sh b/scripts/lib/ptxd_make_install.sh deleted file mode 100644 index 93209e985..000000000 --- a/scripts/lib/ptxd_make_install.sh +++ /dev/null @@ -1,178 +0,0 @@ -#!/bin/bash -# -# Copyright (C) 2005, 2006, 2007 Robert Schwebel <r.schwebel@pengutronix.de> -# 2008, 2009 by Marc Kleine-Budde <mkl@pengutronix.de> -# -# See CREDITS for details about who has contributed to this project. -# -# For further information about the PTXdist project and license conditions -# see the README file. -# - -# -# -p PACKET -# -ptxd_make_install_init() { - . ${PTXDIST_TOPDIR}/scripts/ptxdist_vars.sh || return - - ptxd_make_xpkg_init || return - - local opt - while getopts "p:t:" opt; do - case "${opt}" in - p) - local packet="${OPTARG}" - ;; - t) - local target="${OPTARG##*/}" - target="${target%%.targetinstall*}" - ;; - *) - return 1 - ;; - esac - done - - if [ -z "${packet}" ]; then - echo - echo "Error: empty parameter to 'install_init()'" - echo - return 1 - fi - - echo "install_init: preparing for image creation..." - - rm -fr -- \ - "${pkg_xpkg_tmp}" \ - "${pkg_xpkg_cmds}" \ - "${pkg_xpkg_perms}" \ - "${pkg_xpkg_install_deps}" && - mkdir -p -- "${pkg_ipkg_control_dir}" && - touch "${pkg_xpkg_cmds}" || return - - local replace_from="ARCH" - local replace_to="${PTXDIST_IPKG_ARCH_STRING}" - - echo -n "install_init: @${replace_from}@ -> ${replace_to} ... " - sed -e "s,@${replace_from}@,${replace_to},g" "${RULESDIR}/default.ipkg" > \ - "${pkg_ipkg_control}" || return - echo "done" - - local script rd found - for script in \ - preinst postinst prerm postrm; do - - echo -n "install_init: ${script} " - unset found - - for rd in \ - "${PROJECTRULESDIR}" "${RULESDIR}"; do - - local abs_script="${rd}/${packet}.${script}" - - if [ -f "${abs_script}" ]; then - install -m 0755 \ - -D "${abs_script}" \ - "${pkg_ipkg_control_dir}/${script}" || return - - echo "packaging: '${abs_script}'" - - if [ "${script}" = "preinst" ]; then - echo "install_init: executing '${abs_script}'" - DESTDIR="${ROOTDIR}" /bin/sh "${abs_script}" || return - fi - - found=true - break - fi - done - - if [ -z "${found}" ]; then - echo "not available" - fi - done -} - -export -f ptxd_make_install_init - - -# -# -# -ptxd_make_install_fixup() { - . ${PTXDIST_TOPDIR}/scripts/ptxdist_vars.sh || return - - ptxd_make_xpkg_init || return - - local opt - while getopts "p:f:t:s:" opt; do - case "${opt}" in - p) - local packet="${OPTARG}" - ;; - f) - local replace_from="${OPTARG}" - ;; - t) - local replace_to="${OPTARG}" - ;; - s) - local target="${OPTARG##*/}" - target="${target%%.targetinstall*}" - ;; - *) - return 1 - ;; - esac - done - - if [ -z "${packet}" ]; then - echo - echo "Error: empty parameter to 'install_fixup()'" - echo - return 1 - fi - - case "${replace_from}" in - AUTHOR) - replace_to="`echo ${replace_to} | sed -e 's/\([^\\]\)@/\1\\\@/g'`" - ;; - PACKAGE) - replace_to="`echo ${replace_to} | sed -e 's/_/-/g'`" - - # - # track "pkg name" to "xpkg filename" - # - if [ -e "${pkg_xpkg_map}" ]; then - sed -i -e "/^${replace_to}$/d" "${pkg_xpkg_map}" && - - if [ -s "${pkg_xpkg_map}" ]; then - cat >&2 <<EOF - -${PREFIX}warning: more than one ipkg per PTXdist package detected: - -pkg: '${target}' -ipkg: '${replace_to}' and '$(cat "${pkg_xpkg_map}")' - - -EOF - fi - fi && - echo "${replace_to}" >> "${pkg_xpkg_map}" || return - - - ;; - VERSION) - replace_to="${replace_to//[-_]/.}${PTXCONF_PROJECT_BUILD//[-_]/.}" - ;; - DEPENDS) - return - ;; - esac - - echo -n "install_fixup: @${replace_from}@ -> ${replace_to} ... " - sed -i -e "s,@$replace_from@,$replace_to,g" "${pkg_ipkg_control}" || return - echo "done." -} - -export -f ptxd_make_install_fixup diff --git a/scripts/lib/ptxd_make_world_patchin.sh b/scripts/lib/ptxd_make_world_patchin.sh index 087c60dba..91b8ff190 100644 --- a/scripts/lib/ptxd_make_world_patchin.sh +++ b/scripts/lib/ptxd_make_world_patchin.sh @@ -30,7 +30,7 @@ ptxd_make_world_patchin_apply_init() ${PTXDIST_PATH_PATCHES//://${pkg_pkg} }" # find patch_dir - if ! ptxd_get_dirs "${path}"; then + if ! ptxd_get_path "${path}"; then echo "patchin: no patches found" return fi diff --git a/scripts/lib/ptxd_make_xpkg_common.sh b/scripts/lib/ptxd_make_xpkg_common.sh index a756f20c8..5b925ec05 100644 --- a/scripts/lib/ptxd_make_xpkg_common.sh +++ b/scripts/lib/ptxd_make_xpkg_common.sh @@ -1,6 +1,6 @@ #!/bin/bash # -# Copyright (C) 2008, 2009 by Marc Kleine-Budde <mkl@pengutronix.de> +# Copyright (C) 2008, 2009, 2010 by Marc Kleine-Budde <mkl@pengutronix.de> # # See CREDITS for details about who has contributed to this project. # @@ -25,6 +25,30 @@ export -f ptxd_dopermissions # +# ptxd_do_xpkg_map - do the mapping from package name to xpkg name(s) +# +# in: +# ${@} package name(s) +# +# out: +# ${ptxd_reply[@]} array of xpkg names +# +# return: +# 0 if xpkg names are found +# 1 if no xpkg names are found +# +# ptxd_reply (array) +# +ptxd_do_xpkg_map() { + set -- "${@/#/${ptx_state_dir}/}" + ptxd_reply=( $(cat "${@/%/.xpkg.map}" 2>/dev/null) ) + + [ ${#ptxd_reply[@]} -ne 0 ] +} +export -f ptxd_do_xpkg_map + + +# # initialize variables needed for packaging # ptxd_make_xpkg_init() { @@ -32,6 +56,23 @@ ptxd_make_xpkg_init() { ptxd_bailout "'pkg_xpkg' or 'pkg_xpkg_type' undefined" fi + # + # sanitize pkg_xpkg name + # + # replace "_" by "-" + # + pkg_xpkg="${pkg_xpkg//_/-}" + + # + # sanitize pkg_version + # + # replace "_" by "." + # + pkg_xpkg_version="${pkg_version//_/.}" + if [ -z ${pkg_xpkg_version} ]; then + ptxd_bailout "${FUNCNAME}: please define <PKG>_VERSION" + fi + ptxd_make_world_init || return # license diff --git a/scripts/lib/ptxd_make_xpkg_finish.sh b/scripts/lib/ptxd_make_xpkg_finish.sh index 719b07598..d7ba5ac94 100644 --- a/scripts/lib/ptxd_make_xpkg_finish.sh +++ b/scripts/lib/ptxd_make_xpkg_finish.sh @@ -50,28 +50,36 @@ export -f ptxd_make_xpkg_deps # function to create a generic package # ptxd_make_xpkg_finish() { - . ${PTXDIST_TOPDIR}/scripts/ptxdist_vars.sh || return - ptxd_make_xpkg_init || return # - # no perm file -> no files to package -> exit + # no command file -> no files to package -> exit # if [ \! -s "${pkg_xpkg_cmds}" ]; then - ptxd_pedantic "Packet '${pkg_xpkg}' is empty. not generating" && rm -rf -- "${pkg_xpkg_tmp}" && + ptxd_pedantic "Packet '${pkg_xpkg}' is empty. not generating" + return + fi && - #FIXME: we rely in 1-to-1 mapping here + # + # track "pkg name" to "xpkg filename" mapping + # + if [ -e "${pkg_xpkg_map}" ]; then sed -i -e "/^${pkg_xpkg}$/d" "${pkg_xpkg_map}" && + if [ -s "${pkg_xpkg_map}" ]; then + cat >&2 <<EOF - if [ \! -s "${pkg_xpkg_map}" ]; then - rm -f -- "${pkg_xpkg_map}" - fi +${PTXDIST_LOG_PROMPT}warning: more than one ipkg per package detected: - return - fi +package: '${pkg_pkg}' +ipkg: '${pkg_xpkg}' and '$(cat "${pkg_xpkg_map}")' +EOF + fi + fi && + echo "${pkg_xpkg}" >> "${pkg_xpkg_map}" || return + # # license # @@ -99,12 +107,11 @@ ptxd_make_xpkg_finish() { # # post install # - if [ -f "${PTXDIST_WORKSPACE}/rules/${pkg_xpkg}.postinst" ]; then - echo "xpkg_finish: running postinst" - DESTDIR="${ROOTDIR}" /bin/sh "${PTXDIST_WORKSPACE}/rules/${pkg_xpkg}.postinst" - elif [ -f "${PTXDIST_TOPDIR}/rules/${pkg_xpkg}.postinst" ]; then + # FIXME: install ipkg rather than executing script + if ptxd_get_path "${PTXDIST_PATH_RULES//://${pkg_xpkg}.postinst }"; then echo "xpkg_finish: running postinst" - DESTDIR="${ROOTDIR}" /bin/sh "${PTXDIST_TOPDIR}/rules/${pkg_xpkg}.postinst" + DESTDIR="${ptx_nfsroot}" /bin/sh "${ptxd_reply}" + DESTDIR="${ptx_nfsroot_dbg}" /bin/sh "${ptxd_reply}" fi return diff --git a/scripts/lib/ptxd_make_xpkg_fixup.sh b/scripts/lib/ptxd_make_xpkg_fixup.sh new file mode 100644 index 000000000..42cebdaf2 --- /dev/null +++ b/scripts/lib/ptxd_make_xpkg_fixup.sh @@ -0,0 +1,32 @@ +#!/bin/bash +# +# Copyright (C) 2005, 2006, 2007 Robert Schwebel <r.schwebel@pengutronix.de> +# 2008, 2009, 2010 by Marc Kleine-Budde <mkl@pengutronix.de> +# +# See CREDITS for details about who has contributed to this project. +# +# For further information about the PTXdist project and license conditions +# see the README file. +# + +# +# +# +ptxd_make_xpkg_fixup() { + ptxd_make_xpkg_init || return + + case "${pkg_xpkg_fixup_from}" in + AUTHOR) + pkg_xpkg_fixup_to="`echo ${pkg_xpkg_fixup_to} | sed -e 's/\([^\\]\)@/\1\\\@/g'`" + ;; + DEPENDS|PACKAGE|VERSION) + return + ;; + esac + + echo -n "install_fixup: @${pkg_xpkg_fixup_from}@ -> ${pkg_xpkg_fixup_to} ... " + sed -i -e "s,@$pkg_xpkg_fixup_from@,$pkg_xpkg_fixup_to,g" "${pkg_ipkg_control}" || return + echo "done." +} + +export -f ptxd_make_xpkg_fixup diff --git a/scripts/lib/ptxd_make_xpkg_prepare.sh b/scripts/lib/ptxd_make_xpkg_prepare.sh new file mode 100644 index 000000000..61b520c98 --- /dev/null +++ b/scripts/lib/ptxd_make_xpkg_prepare.sh @@ -0,0 +1,63 @@ +#!/bin/bash +# +# Copyright (C) 2005, 2006, 2007 Robert Schwebel <r.schwebel@pengutronix.de> +# 2008, 2009, 2010 by Marc Kleine-Budde <mkl@pengutronix.de> +# +# See CREDITS for details about who has contributed to this project. +# +# For further information about the PTXdist project and license conditions +# see the README file. +# + +# +# +ptxd_make_xpkg_prepare() { + ptxd_make_xpkg_init || return + + echo "install_init: preparing for image creation of '${pkg_xpkg}'..." + + rm -fr -- \ + "${pkg_xpkg_tmp}" \ + "${pkg_xpkg_cmds}" \ + "${pkg_xpkg_perms}" \ + "${pkg_xpkg_install_deps}" && + mkdir -p -- "${pkg_ipkg_control_dir}" && + touch "${pkg_xpkg_cmds}" || return + + # + # replace ARCH and PACKAGE in control file + # + echo -e "\ +install_init: @ARCH@ -> ${PTXDIST_IPKG_ARCH_STRING} +install_init: @PACKAGE@ -> ${pkg_xpkg} +install_init: @VERSION@ -> ${pkg_xpkg_version}" + + ARCH="${PTXDIST_IPKG_ARCH_STRING}" \ + PACKAGE="${pkg_xpkg}" \ + VERSION="${pkg_xpkg_version}" \ + ptxd_replace_magic "${PTXDIST_TOPDIR}/config/xpkg/ipkg.control" > \ + "${pkg_ipkg_control}" || return + + local script + for script in preinst postinst prerm postrm; do + echo -n "install_init: ${script} " + + if ptxd_get_path "${PTXDIST_PATH_RULES//://${pkg_xpkg}.${script} }"; then + install -m 0755 \ + -D "${ptxd_reply}" \ + "${pkg_ipkg_control_dir}/${script}" || return + + echo "packaging: '$(ptxd_print_path "${ptxd_reply}")'" + + # FIXME: install ipkg rather than executing script + if [ "${script}" = "preinst" ]; then + echo "install_init: executing '${ptxd_reply}'" + DESTDIR="${ptx_nfsroot}" /bin/sh "${ptxd_reply}" + DESTDIR="${ptx_nfsroot_dbg}" /bin/sh "${ptxd_reply}" + fi + else + echo "not available" + fi + done +} +export -f ptxd_make_xpkg_prepare diff --git a/scripts/libptxdist.sh b/scripts/libptxdist.sh index 6af6aaaa3..430452f2d 100644 --- a/scripts/libptxdist.sh +++ b/scripts/libptxdist.sh @@ -1,13 +1,6 @@ #!/bin/bash PTX_DEBUG=${PTX_DEBUG:="false"} - -# -# awk script for permission fixing -# -DOPERMISSIONS='{ if ($1 == "f") printf("chmod %s .%s; chown %s.%s .%s;\n", $5, $2, $3, $4, $2); if ($1 == "n") printf("mknod -m %s .%s %s %s %s; chown %s.%s .%s;\n", $5, $2, $6, $7, $8, $3, $4, $2);}' - - PTX_DIALOG="dialog --aspect 60" PTX_DIALOG_HEIGHT=0 PTX_DIALOG_WIDTH=0 @@ -376,7 +369,8 @@ ptxd_make_log() { # -# replaces @MAGIC@ with MAGIC from environment +# replaces @MAGIC@ with MAGIC from environment (if available) +# it will stay @MAGIC@ if MAGIC is unset in the environment # # $1 input file # stdout: output @@ -384,9 +378,14 @@ ptxd_make_log() { ptxd_replace_magic() { gawk ' $0 ~ /@[A-Z0-9_]+@/ { - while (match($0, "@[A-Z0-9_]+@")) { - var = substr($0, RSTART+1, RLENGTH-2); - gsub("@" var "@", ENVIRON[var]); + line = $0 + + while (match(line, "@[A-Z0-9_]+@")) { + var = substr(line, RSTART + 1, RLENGTH - 2); + line = substr(line, RSTART + RLENGTH); + + if (var in ENVIRON) + gsub("@" var "@", ENVIRON[var]); } } @@ -436,17 +435,22 @@ ptxd_dumpstack() { # +# ptxd_get_path - look for files and/or dirs # # return: -# 0 if dirs are found -# 1 if no dirs are found +# 0 if files/dirs are found +# 1 if no files/dirs are found # -ptxd_get_dirs() { +# array "ptxd_reply" containing the found files/dirs +# +ptxd_get_path() { + [ -n "${1}" ] || return + ptxd_reply=( $(eval command ls -f -d "${@}" 2>/dev/null) ) [ ${#ptxd_reply[@]} -ne 0 ] } -export -f ptxd_get_dirs +export -f ptxd_get_path # |