* updated ksystemlog (21.12.1 -> 21.12.2), untested
[t2-trunk.git] / misc / archive / copypackage.sh
blob61ba7103844ed8c19fa5aa8e0b1859b0e1d49758
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 ---
16 show_usage() {
17 echo "Usage: $0 <source> <target> <pkg> ..."
18 exit 1
21 cppkg() {
22 local from="$1" to="$2" pkg="$3"
23 if [ -f $from/var/adm/flists/$pkg ]; then
24 if [ -f $to/var/adm/flists/$pkg ]; then
25 echo "$pkg: already present at target ($to)"
26 cut -d' ' -f2- $to/var/adm/flists/$pkg | while read -r f; do
27 if [ "$f" == var/adm/flists/$pkg ]; then
28 true
29 elif [ ! -d "$to/$f" ]; then
30 rm -vf "$to/$f"
32 done
33 rm -vf $to/var/adm/logs/*-$pkg.{err,out,log} 2> /dev/null
36 echo "$pkg: $from -> $to"
37 cut -d' ' -f2- $from/var/adm/flists/$pkg |
38 tar -C "$from/" --ignore-failed-read --no-recursion -T - -c -O |
39 tar -C "$to" --same-owner --preserve -xvf -
40 cp -v $from/var/adm/logs/*-$pkg.{err,out,log} $to/var/adm/logs/ 2> /dev/null
41 else
42 echo "$pkg: package not found at source ($from)"
46 source="$1"; shift
47 target="$1"; shift
49 if [ $# -gt 0 -a -f ./config/$source/config -a -f ./config/$target/config -a "$source" != "$target" ]; then
50 SDECFG_ID=
51 eval `grep SDECFG_ID= ./config/$source/config`
52 if [ -d "./build/$SDECFG_ID/var/adm/flists/" ]; then
53 source=./build/$SDECFG_ID
55 SDECFG_ID=
56 eval `grep SDECFG_ID= ./config/$target/config`
57 if [ -d "./build/$SDECFG_ID/var/adm/flists/" ]; then
58 target=./build/$SDECFG_ID
60 for x in $*; do
61 cppkg "$source" "$target" "$x"
62 done
63 else
64 echo "'$target' is not a valid config" 1>&2
65 show_usage
67 else
68 echo "'$source' is not a valid config" 1>&2
69 show_usage
71 else
72 echo "Invalid Arguments" 1>&2
73 show_usage