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.

74 lines
2.1 KiB

  1. #!/bin/sh
  2. # --- T2-COPYRIGHT-NOTE-BEGIN ---
  3. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  4. #
  5. # T2 SDE: misc/archive/copypackage.sh
  6. # Copyright (C) 2006 The T2 SDE 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. # --- T2-COPYRIGHT-NOTE-END ---
  15. show_usage() {
  16. echo "Usage: $0 <source> <target> <pkg> ..."
  17. exit 1
  18. }
  19. cppkg() {
  20. local from="$1" to="$2" pkg="$3"
  21. if [ -f $from/var/adm/flists/$pkg ]; then
  22. if [ -f $to/var/adm/flists/$pkg ]; then
  23. echo "$pkg: already present at target ($to)"
  24. cut -d' ' -f2- $to/var/adm/flists/$pkg | while read -r f; do
  25. if [ "$f" == var/adm/flists/$pkg ]; then
  26. true
  27. elif [ ! -d "$to/$f" ]; then
  28. rm -vf "$to/$f"
  29. fi
  30. done
  31. rm -vf $to/var/adm/logs/*-$pkg.{err,out,log} 2> /dev/null
  32. fi
  33. echo "$pkg: $from -> $to"
  34. cut -d' ' -f2- $from/var/adm/flists/$pkg |
  35. tar -C "$from/" --ignore-failed-read --no-recursion -T - -c -O |
  36. tar -C "$to" --same-owner --preserve -xvf -
  37. cp -v $from/var/adm/logs/*-$pkg.{err,out,log} $to/var/adm/logs/ 2> /dev/null
  38. else
  39. echo "$pkg: package not found at source ($from)"
  40. fi
  41. }
  42. source="$1"; shift
  43. target="$1"; shift
  44. if [ $# -gt 0 -a -f ./config/$source/config -a -f ./config/$target/config -a "$source" != "$target" ]; then
  45. SDECFG_ID=
  46. eval `grep SDECFG_ID= ./config/$source/config`
  47. if [ -d "./build/$SDECFG_ID/var/adm/flists/" ]; then
  48. source=./build/$SDECFG_ID
  49. SDECFG_ID=
  50. eval `grep SDECFG_ID= ./config/$target/config`
  51. if [ -d "./build/$SDECFG_ID/var/adm/flists/" ]; then
  52. target=./build/$SDECFG_ID
  53. for x in $*; do
  54. cppkg "$source" "$target" "$x"
  55. done
  56. else
  57. echo "'$target' is not a valid config" 1>&2
  58. show_usage
  59. fi
  60. else
  61. echo "'$source' is not a valid config" 1>&2
  62. show_usage
  63. fi
  64. else
  65. echo "Invalid Arguments" 1>&2
  66. show_usage
  67. fi