I added install_config which is the same as install_alternative except it also adds the file name to conffiles inside of the .ipk file so it is handled by the package manager as a config file.
Signed-off-by: George McCollister <[email protected]> --- rules/post/install.make | 28 ++++++++++++++++++++++++++++ scripts/lib/ptxd_make_ipkg_common.sh | 1 + scripts/lib/ptxd_make_xpkg_pkg.sh | 20 +++++++++++++++++--- 3 files changed, 46 insertions(+), 3 deletions(-) diff --git a/rules/post/install.make b/rules/post/install.make index 4a18ba3..1c609be 100644 --- a/rules/post/install.make +++ b/rules/post/install.make @@ -87,6 +87,34 @@ install_alternative = \ echo "ptxd_install_alternative '$$FILE' '$$DST' '$$OWN' '$$GRP' '$$PER' '$$STRIP'" >> "$(STATEDIR)/$$XPKG.cmds" # +# install_config +# +# Installs a config file with user/group ownership and permissions via +# fakeroot. Adds filename to conffiles +# +# This macro first looks in $(PTXDIST_WORKSPACE)/projectroot for the file to copy and then +# in $(PTXDIST_TOPDIR)/generic and installs the file under $(ROOTDIR) +# +# $1: xpkg label +# $2: UID +# $3: GID +# $4: permissions (octal) +# $5: source file +# $6: (strip, obsolete) +# $7: destination (optional) +# +install_config = \ + XPKG=$(subst _,-,$(strip $(1))); \ + OWN=$(strip $(2)); \ + GRP=$(strip $(3)); \ + PER=$(strip $(4)); \ + FILE=$(strip $(5)); \ + STRIP=$(strip $(6)); \ + DST=$(strip $(7)); \ + $(call install_check, install_config); \ + echo "ptxd_install_config '$$FILE' '$$DST' '$$OWN' '$$GRP' '$$PER' '$$STRIP'" >> "$(STATEDIR)/$$XPKG.cmds" + +# # install_tree # # Installs all files and subdirectories with user/group ownership and diff --git a/scripts/lib/ptxd_make_ipkg_common.sh b/scripts/lib/ptxd_make_ipkg_common.sh index eb7151c..b23fcff 100644 --- a/scripts/lib/ptxd_make_ipkg_common.sh +++ b/scripts/lib/ptxd_make_ipkg_common.sh @@ -16,5 +16,6 @@ ptxd_make_ipkg_init() { pkg_ipkg_tmp="${pkg_xpkg_tmp}/ipkg" pkg_ipkg_control_dir="${pkg_ipkg_tmp}/CONTROL" pkg_ipkg_control="${pkg_ipkg_control_dir}/control" + pkg_xpkg_conffiles="${pkg_xpkg_control_dir}/conffiles" } export -f ptxd_make_ipkg_init \ No newline at end of file diff --git a/scripts/lib/ptxd_make_xpkg_pkg.sh b/scripts/lib/ptxd_make_xpkg_pkg.sh index 7cd35d7..a5390bc 100644 --- a/scripts/lib/ptxd_make_xpkg_pkg.sh +++ b/scripts/lib/ptxd_make_xpkg_pkg.sh @@ -54,7 +54,7 @@ ptxd_install_setup_src() { local -a list - if [ "${cmd}" = "alternative" ]; then + if [ "${cmd}" = "alternative" -o "${cmd}" = "config" ]; then # # if pkg_dir is empty we'll have some some empty entries in # the array, but that's no problem for the "-e" below. @@ -205,9 +205,10 @@ install ${cmd}: fi ;; *) - if [ "${strip:0:1}" = "/" -a "${cmd}" = "alternative" ]; then + if [ "${strip:0:1}" = "/" ] && \ + [ "${cmd}" = "alternative" -o "${cmd}" = "config" ]; then ptxd_bailout " -the 6th parameter of 'install_alternative' is strip, not the destination. +the 6th parameter of 'install_${cmd}' is strip, not the destination. Usually, just remove the 6th parameter and everything works fine. " fi @@ -303,6 +304,19 @@ ptxd_install_alternative() { } export -f ptxd_install_alternative +ptxd_install_config() { + local cmd="config" + local src="${1}" + local dst="${2}" + shift 2 + ptxd_install_file_impl "${src}" "${dst:-${src}}" "${@}" && + # this is a config file add it to conffiles so it's handled correctly + echo "${dst:-${src}}" >> "${pkg_xpkg_conffiles}" && + chown 0:0 "${pkg_xpkg_conffiles}" || + ptxd_install_error "install_config failed!" +} +export -f ptxd_install_config + ptxd_install_file() { local cmd="file" ptxd_install_file_impl "$@" || -- 1.7.1 -- ptxdist mailing list [email protected]
