OpenSDE Framework (without history before r20070)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

86 lines
2.2 KiB

  1. #!/bin/sh
  2. # --- SDE-COPYRIGHT-NOTE-BEGIN ---
  3. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  4. #
  5. # Filename: lib/sde-binary/package-gem.sh
  6. # Copyright (C) 2007 The OpenSDE Project
  7. #
  8. # More information can be found in the files COPYING and README.
  9. #
  10. # This program is free software; you can redistribute it and/or modify
  11. # it under the terms of the GNU General Public License as published by
  12. # the Free Software Foundation; version 2 of the License. A copy of the
  13. # GNU General Public License can be found in the file COPYING.
  14. # --- SDE-COPYRIGHT-NOTE-END ---
  15. . lib/libsde.in
  16. pkg_name=
  17. versioned=
  18. root=
  19. usage() {
  20. cat <<EOT
  21. Creates a GEM file for a given package based on it's flist
  22. Usage: ${0} [--versioned] [--root <root>] [--output <output>] <package>
  23. root location of the root of the sandbox
  24. output folder to place the binary packages
  25. package name of the package
  26. --versioned use package version in the resulting file name
  27. EOT
  28. }
  29. while [ $# -gt 0 ]; do
  30. case "$1" in
  31. --versioned) versioned=1 ;;
  32. --root) root="$2"; shift ;;
  33. --output) output="$2"; shift ;;
  34. --*) usage; exit 1 ;;
  35. *) if [ "$pkg_name" ]; then
  36. usage; exit 1
  37. else
  38. pkg_name="$1"
  39. fi ;;
  40. esac
  41. shift
  42. done
  43. if [ -z "$pkg_name" ]; then
  44. usage; exit 1
  45. elif [ ! -r "${root}/var/adm/packages/$pkg_name" ]; then
  46. echo_error "package '$pkg_name' not found."
  47. exit 2
  48. elif [ "$versioned" ]; then
  49. version=$( grep '^Package Name and Version:' "${root}/var/adm/packages/$pkg_name" | cut -f6 -d' ' )
  50. if [ -z "$version" ]; then
  51. echo_error "package '$pkg_name' is broken."
  52. exit 2
  53. fi
  54. else
  55. version=
  56. fi
  57. output="${output:-.}"
  58. filename="${pkg_name}${versioned:+-${version}}"
  59. if $SDEROOT/lib/sde-binary/package.sh --type "tar.bz2" ${versioned:+--versioned} --root "${root}" \
  60. --output "${output}" "${pkg_name}"; then
  61. echo_status "Converting $filename.tar.bz2 into GEM format"
  62. mine -C "${root}/var/adm" "$output/$filename.tar.bz2" "$pkg_name" \
  63. "$output/$filename.gem.tmp"
  64. errno=$?
  65. if [ "$?" != 0 ]; then
  66. echo_error "Failed to create '$output/$filename.gem'"
  67. rm -f "$output/$filename.gem.tmp"
  68. else
  69. mv "$output/$filename.gem"{.tmp,}
  70. fi
  71. echo_status "Removing temporary ${filename}tar.bz2 file"
  72. rm -f "$output/$filename.tar.bz2"
  73. exit $errno
  74. fi