theslinux-buildsystem branch _utils updated f710b5b Return if we are not be able to update :_func variable

  • From: git@xxxxxxxxxxxxxxxxxxxx
  • To: theslinux-phantom@xxxxxxxxxxxxx
  • Date: Fri, 09 Aug 2013 18:25:21 -0700

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "theslinux-buildsystem".

The branch, _utils has been updated
       via  f710b5be65753c7b62dff7db1fa86bb674a61464 (commit)
       via  a19fccd0a2bb4910b86fabc8daf7c7d59ea36009 (commit)
      from  9fcd4260b7a1dcd526a56d7f904305c82f38a88c (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit f710b5be65753c7b62dff7db1fa86bb674a61464
Author: Ky-Anh Huynh <kyanh@xxxxxxxxxxxxx>
Date:   Sat Aug 10 08:23:55 2013 +0700

    Return if we are not be able to update :_func variable

commit a19fccd0a2bb4910b86fabc8daf7c7d59ea36009
Author: Ky-Anh Huynh <kyanh@xxxxxxxxxxxxx>
Date:   Sat Aug 10 08:08:28 2013 +0700

    + :_pkgbuild_to_yaml_with_check. ship :install script
    
    * New function :*_with_check will use Ruby/YAML to check the syntax of
      the YAML output provided by :pkgbuild_to_yaml
    
    * The contents of :install script will be shipped with YAML output
    * FIXME: Unable to detect :install script of sub-package
    * FIXME: Unable to detect sub-packages information

-----------------------------------------------------------------------

Summary of changes:
 _utils/run.sh | 96 +++++++++++++++++++++++++++++++++++++++++++++++------------
 1 file changed, 77 insertions(+), 19 deletions(-)

diff --git a/_utils/run.sh b/_utils/run.sh
index 5ca2f08..a00c8bb 100755
--- a/_utils/run.sh
+++ b/_utils/run.sh
@@ -779,7 +779,13 @@ _get_update() {
 # package. The primary purpose is to gather information from packages
 # quicly and simple. We also build our own hierachy of dependencies.
 #
-# TODO: embeded some bash script into YAML output
+# Input
+#   Current build environment that's detected by `_s_env`
+#
+# Output
+#   YAML string should be checked by a 3rd party method
+#   Always return 0. See also `_pkgbuild_to_yaml_with_check`
+#
 _pkgbuild_to_yaml() {
   _s_env || return 1
 
@@ -804,31 +810,83 @@ _pkgbuild_to_yaml() {
   # /Copied from `makepkg`
 
   source "PKGBUILD" || return 127
+
   cat <<EOF
 ---
 $PACKAGE_BASE:
-  version: $PACKAGE_VERSION
-  description: $pkgdesc
-  install: $install
-  feature: $PACKAGE_FEATURE
-  url: $url
+  version: "$PACKAGE_VERSION"
+  description: "$pkgdesc"
+  feature: "$PACKAGE_FEATURE"
+  url: "$url"
   license: "${license[@]}"
-  packages:
-$(for _u in "${pkgname[@]}"; do echo "  - $_u";done)
-  sources:
-$(for _u in "${source[@]}"; do echo "  - $_u";done)
-  conflicts:
-$(for _u in "${conflicts[@]}"; do echo "  - $_u";done)
-  provides:
-$(for _u in "${provides[@]}"; do echo "  - $_u";done)
-  replaces:
-$(for _u in "${replaces[@]}"; do echo "  - $_u";done)
-  makedepends:
-$(for _u in "${makedepends[@]}"; do echo "  - $_u";done)
 EOF
+
+  [[ -z "${pkgname}" ]] \
+    && echo "  packages:" \
+    && for _u in "${pkgname[@]}"; do echo "  - $_u"; done
+
+  [[ -n "${sources}" ]] \
+    && echo "  sources:" \
+    && for _u in "${source[@]}"; do echo "  - $_u"; done
+
+  [[ -n "${conflicts}" ]] \
+    && echo "  conflicts:" \
+    && for _u in "${conflicts[@]}"; do echo "  - $_u"; done
+
+  [[ -n "${provides}" ]] \
+    && echo "  provides:" \
+    && for _u in "${provides[@]}"; do echo "  - $_u"; done
+
+  [[ -n "${replaces}" ]] \
+    && echo "  replaces:" \
+    && for _u in "${replaces[@]}"; do echo "  - $_u"; done
+
+  [[ -n "${makedepends}" ]] \
+    && echo "  makedepends:" \
+    && for _u in "${makedepends[@]}"; do echo "  - $_u"; done
+
+  [[ ! -f "$install" ]] \
+    && [[ -f "${PACKAGE_BASE}.install" ]] \
+    && install="${PACKAGE_BASE}.install" \
+    || install=""
+
+  # The contents of `install` script will be shipped with the package
+  # FIXME: If a sub-package provides its own `install` script we can not
+  # FIXME: detect the script here. Should find another way.
+  [[ -z "$install" ]] \
+  || {
+    echo "  install: |"
+    cat "$install" | awk '{printf("    %s\n", $0)}'
+  }
+
+  : 'This function often returns successfully'
 }
 
-_func=""
+# Check the output of `_pkgbuild_to_yaml` with Ruby/YAML
+# The output of this command is often more compact that the original
+# output of `_pkgbuild_to_yaml`.
+#
+# Input
+#   As same as `_pkgbuild_to_yaml`
+#
+# Output
+#   error || Valid YAML file
+#
+# FIXME: A valid PKGBUILD should containn some basic fields like
+# FIXME: package name, version, build script,... The check should know
+# FIXME: this and return error if there is any missing field
+#
+# FIXME: What happends if we have 10,000 packages to check!?
+#
+_pkgbuild_to_yaml_with_check() {
+  _pkgbuild_to_yaml "$@" \
+  | ruby -ryaml -e "puts YAML.dump(YAML.load(STDIN))"
+}
+
+# main routine #########################################################
+
+unset _func || _die "Unable to update '_func' variable"
+
 case "${0##*/}" in
   "s-import-package") _func="_import_packages" ;;
   "s-makepkg")        _func="_makepkg" ;;


hooks/post-receive
-- 
theslinux-buildsystem
--
Purpose: Store commits, feeds from other projects
Post: mailto:theslinux-phantom@xxxxxxxxxxxxx
Archive, Gmane: http://theslinux.org/lists/phantom/
Subscribe: mailto:theslinux-phantom-request@xxxxxxxxxxxxx?Subject=subscribe
Unsubscribe: mailto:theslinux-phantom-request@xxxxxxxxxxxxx?Subject=unsubscribe
Other information: http://theslinux.org/lists (vi) or 
http://theslinux.org/lists/en (en)
Support: mailto:theslinux-questions@xxxxxxxxxxxxx

Other related posts:

  • » theslinux-buildsystem branch _utils updated f710b5b Return if we are not be able to update :_func variable - git