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.

75 lines
2.1 KiB

  1. #!/bin/sh
  2. # --- SDE-COPYRIGHT-NOTE-BEGIN ---
  3. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  4. #
  5. # Filename: lib/misc/copypackage.sh
  6. # Copyright (C) 2008 The OpenSDE Project
  7. # Copyright (C) 2006 The T2 SDE Project
  8. #
  9. # More information can be found in the files COPYING and README.
  10. #
  11. # This program is free software; you can redistribute it and/or modify
  12. # it under the terms of the GNU General Public License as published by
  13. # the Free Software Foundation; version 2 of the License. A copy of the
  14. # GNU General Public License can be found in the file COPYING.
  15. # --- SDE-COPYRIGHT-NOTE-END ---
  16. show_usage() {
  17. echo "Usage: $0 <source> <target> <pkg> ..."
  18. exit 1
  19. }
  20. cppkg() {
  21. local from="$1" to="$2" pkg="$3"
  22. if [ -f $from/var/adm/flists/$pkg ]; then
  23. if [ -f $to/var/adm/flists/$pkg ]; then
  24. echo "$pkg: already present at target ($to)"
  25. cut -d' ' -f2- $to/var/adm/flists/$pkg | while read -r f; do
  26. if [ "$f" = "var/adm/flists/$pkg" ]; then
  27. true
  28. elif [ ! -d "$to/$f" ]; then
  29. rm -vf "$to/$f"
  30. fi
  31. done
  32. rm -vf $to/var/adm/logs/*-$pkg.{err,out,log} 2> /dev/null
  33. fi
  34. echo "$pkg: $from -> $to"
  35. cut -d' ' -f2- $from/var/adm/flists/$pkg |
  36. tar -C "$from/" --ignore-failed-read --no-recursion -T - -c -O |
  37. tar -C "$to" --same-owner --preserve -xvf -
  38. cp -v $from/var/adm/logs/*-$pkg.{err,out,log} $to/var/adm/logs/ 2> /dev/null
  39. else
  40. echo "$pkg: package not found at source ($from)"
  41. fi
  42. }
  43. source="$1"; shift
  44. target="$1"; shift
  45. if [ $# -gt 0 -a -f ./config/$source/config -a -f ./config/$target/config -a "$source" != "$target" ]; then
  46. SDECFG_ID=
  47. eval `grep SDECFG_ID= ./config/$source/config`
  48. if [ -d "./build/$SDECFG_ID/var/adm/flists/" ]; then
  49. source=./build/$SDECFG_ID
  50. SDECFG_ID=
  51. eval `grep SDECFG_ID= ./config/$target/config`
  52. if [ -d "./build/$SDECFG_ID/var/adm/flists/" ]; then
  53. target=./build/$SDECFG_ID
  54. for x in $*; do
  55. cppkg "$source" "$target" "$x"
  56. done
  57. else
  58. echo "'$target' is not a valid config" 1>&2
  59. show_usage
  60. fi
  61. else
  62. echo "'$source' is not a valid config" 1>&2
  63. show_usage
  64. fi
  65. else
  66. echo "Invalid Arguments" 1>&2
  67. show_usage
  68. fi