]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - SunOS5/replace
Import IP-Filter 5.1.2 into vendor branches using the existing license that
[FreeBSD/FreeBSD.git] / SunOS5 / replace
1 #!/bin/ksh
2 SBIN=/usr/sbin
3 debug=echo
4 undo=0
5
6 update() {
7         echo "UPDATE $1 $2 $3"
8         base=$1
9         dir=$2
10         file=$3
11         Z=$IFS
12         IFS=:
13         set $file
14         if [[ -z $2 ]] ; then
15                 o=$1
16                 n=$1
17         else
18                 o=$1
19                 n=$2
20         fi
21         set $dir
22         sdir=$1
23         ddir=$2
24         IFS=$Z
25
26         if [[ -z ${sdir} && ! -d ${base}/${ddir} ]] ; then
27                 ddir=
28         fi
29
30         sprog=${cpudir}/${sdir}/${n}
31         dprog=${base}/${ddir}/${o}
32
33         if [[ $undo -eq 0 ]] ; then
34                 if [[ -d ${base}/${ddir} ]] ; then
35                         if [[ ! -f ${dprog}.dist ]] ; then
36                                 $debug /bin/mv ${dprog} ${dprog}.dist
37                                 $debug /bin/cp -p ${dprog}.dist ${dprog}
38                         fi
39                         $debug /bin/cp ${sprog} ${dprog}
40                 else
41                         links=$(/bin/ls -dl ${dprog} | awk ' { print $2; } ' -)
42                         if [[ $links -eq 1 ]] ; then
43                                 if [[ ! -f ${dprog}.dist ]] ; then
44                                         $debug /bin/mv ${dprog} ${dprog}.dist
45                                         $debug /bin/cp -p ${dprog}.dist ${dprog}
46                                 fi
47                                 $debug /bin/cp ${sprog} ${dprog}
48                         fi
49                 fi
50         else
51                 if [[ -f ${dprog}.dist ]] ; then
52                         $debug /bin/mv -f ${dprog}.dist ${dprog}
53                 fi
54         fi
55 }
56
57 while [[ $# -gt 0 ]] ; do
58         case $1 in
59         undo)
60                 undo=1
61                 ;;
62         -f)
63                 debug=
64                 ;;
65         -d)
66                 debug=echo
67                 ;;
68         esac
69         shift
70 done
71
72 case $(pwd) in
73 */SunOS5)
74         ;;
75 */SunOS5/*)
76         exit 1
77         ;;
78 *)
79         cd SunOS5
80         ;;
81 esac
82 cpu=`uname -p`
83 cpudir=${cpu}-`uname -r`
84
85 if [[ -d ${cpudir}/amd64 ]] ; then
86         big=amd64
87 fi
88 if [[ -d ${cpudir}/sparcv9 ]] ; then
89         big=sparcv9
90 fi
91 if [[ -d ${cpudir}/i86 ]] ; then
92         small=i86
93 fi
94 if [[ -d ${cpudir}/sparc ]] ; then
95         small=sparc
96 fi
97 echo "$cpudir.$big.$small."
98
99 if [[ -n ${big} ]] ; then
100         for i in ipf:ipf.exe ipfs ipfstat ipmon ipnat ippool; do
101                 update $SBIN ${big}:${big} $i
102         done
103         update /usr/lib/ipf ${big}:${big} ipftest
104         update /usr/kernel/drv ${big}:${big} ipf
105 fi
106 if [[ -n ${small} ]] ; then
107         for i in ipf:ipf.exe ipfs ipfstat ipmon ipnat ippool; do
108                 update $SBIN ${small}:${small} $i
109         done
110         update /usr/lib/ipf ${small}:${small} ipftest
111         update /usr/kernel/drv "${small}:" ipf
112 fi
113 if [[ -z ${small} && -z ${big} ]] ; then
114         if [[ -z ${small} ]] ; then
115                 case ${cpu} in
116                 i386)
117                         small=i86
118                         ;;
119                 sparc)
120                         small=sparc
121                         ;;
122                 esac
123         fi
124         for i in ipf:ipf.exe ipfs ipfstat ipmon ipnat ippool; do
125                 update $SBIN :${small} $i
126         done
127         update /usr/lib/ipf :${small} ipftest
128         update /usr/kernel/drv :${small} ipf
129 fi
130
131 cpudir=..
132 for i in ip_compat.h ip_fil.h ipl.h ip_nat.h ip_state.h ip_sync.h ip_scan.h \
133          ip_pool.h ip_lookup.h; do
134         update /usr/include/netinet : $i
135         update /usr/sfw/lib/gcc/i386-pc-solaris2.10/3.4.3/include/netinet/ : $i
136 done
137 exit 0