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.

117 lines
2.5 KiB

  1. #!/bin/sh
  2. # --- SDE-COPYRIGHT-NOTE-BEGIN ---
  3. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  4. #
  5. # Filename: bin/sde-create-pkgdb
  6. # Copyright (C) 2008 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. #Description: Creates a packagedb file for a build
  16. [ -n "$SDEROOT" ] ||
  17. export SDEROOT=$( cd "${0%/*}/.."; pwd -P )
  18. . "$SDEROOT/lib/libsde.in"
  19. . "$SDEROOT/lib/sde-config.in"
  20. create_usage() {
  21. local progname=${0##*/}
  22. echo "Usage: ${progname//-/ } -c <config>"
  23. }
  24. shortopts='c:'
  25. longopts='cfg:'
  26. options=$( getopt -o "$shortopts" -l "$longopts" -- "$@" )
  27. if [ $? -ne 0 ]; then
  28. create_usage
  29. exit -1
  30. fi
  31. # load new arguments list
  32. eval set -- "$options"
  33. config=default
  34. while [ $# -gt 0 ]; do
  35. case "$1" in
  36. -c|--cfg)
  37. config=$2; shift
  38. ;;
  39. --) shift; break ;;
  40. esac
  41. shift
  42. done
  43. config_exists "$config" || echo_abort 1 "$config: config not found."
  44. builddir="$SDEROOT/build/$(config_id "$config")"
  45. admdir="$builddir/var/adm"
  46. tarballdir="$builddir/TOOLCHAIN/pkgs"
  47. pkgdbfile="$tarballdir/packages.db"
  48. pkgfile_ver=$(config_getvar PKGFILE_VER "$config")
  49. pkgfile_ext=$(config_getvar PKGFILE_TYPE "$config")
  50. # validate $admdir and $tarballdir
  51. for x in packages descs dependencies cksums; do
  52. [ -d "$admdir/$x" ] || echo_abort 1 "$config: var/adm/ is incomplete."
  53. done
  54. [ -d "$tarballdir/" ] || echo_abort 1 "$config: no built packages."
  55. create_pkgdb_entry()
  56. {
  57. local admdir="$1" pkg="$2" x=
  58. $ECHO_E "$pkg"
  59. $ECHO_E "\027"
  60. grep -v '^\[COPY\]' "$admdir/descs/$pkg"
  61. $ECHO_E "\027"
  62. for x in dependencies cksums; do
  63. cat "$admdir/$x/$pkg"
  64. $ECHO_E "\027"
  65. done
  66. $ECHO_E "\004"
  67. }
  68. trap ':' INT
  69. for pkg in $( cd "$admdir/descs/"; ls -1 * 2> /dev/null ) ; do
  70. [ "$pkg" != "TRANS.TBL" ] || continue
  71. if [ "$pkgfile_ver" = 1 ]; then
  72. ver=$(grep '^Package Name and Version' \
  73. "$admdir/packages/$pkg" | cut -f6 -d' ')
  74. else
  75. ver=
  76. fi
  77. pkgfile="$pkg${ver:+-$ver}.$pkgfile_ext"
  78. if [ -s "$tarballdir/$pkgfile" ]; then
  79. create_pkgdb_entry "$admdir" "$pkg"
  80. else
  81. echo_warning "$pkg: binary package not found."
  82. fi
  83. done | gzip -c > "$pkgdbfile.$$"
  84. errno=$?
  85. if [ $errno -eq 0 ]; then
  86. mv "$pkgdbfile.$$" "$pkgdbfile"
  87. else
  88. rm -f "$pkgdbfile.$$"
  89. exit $errno
  90. fi