aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin/ctm/mkCTM
diff options
context:
space:
mode:
authorPoul-Henning Kamp <phk@FreeBSD.org>1994-09-19 07:32:24 +0000
committerPoul-Henning Kamp <phk@FreeBSD.org>1994-09-19 07:32:24 +0000
commitec5d3c392aa83e8831603ad5015610a8074104a0 (patch)
tree799f3f1ccbac4227213385e9fe39fdb8a21677a2 /usr.sbin/ctm/mkCTM
parent986c2270fe0d6f841d6cc9db1bb64f743b751d6d (diff)
downloadsrc-ec5d3c392aa83e8831603ad5015610a8074104a0.tar.gz
src-ec5d3c392aa83e8831603ad5015610a8074104a0.zip
This is the present state of CTM version 2. Please do not ask for
subscriptions yet. Wait for the announcement. CTM is my humble attempt to get -current out to people beyond TCP/IP connections. This is for people with dial-up connections and such. CTM can make a delta from one version to another of a source-tree, in a efficient and verified way. Even if there are binary files in the tree. It will even try to make the delta as small as possible. It is OK with me if you yell "Bloating!" but I'll just forward your email to some of the happy customers from CTM version 1, and let them tell you what they think. I will not put ctm into "make world" yet. For now it is just the logical way to get the sources out to people who helps me test this. Poul-Henning
Notes
Notes: svn path=/cvs2svn/branches/phk/; revision=2886
Diffstat (limited to 'usr.sbin/ctm/mkCTM')
-rw-r--r--usr.sbin/ctm/mkCTM/ctm_conf.cvs-cur9
-rw-r--r--usr.sbin/ctm/mkCTM/ctm_conf.src-cur9
-rw-r--r--usr.sbin/ctm/mkCTM/mkCTM147
3 files changed, 165 insertions, 0 deletions
diff --git a/usr.sbin/ctm/mkCTM/ctm_conf.cvs-cur b/usr.sbin/ctm/mkCTM/ctm_conf.cvs-cur
new file mode 100644
index 000000000000..bbef14dff9fe
--- /dev/null
+++ b/usr.sbin/ctm/mkCTM/ctm_conf.cvs-cur
@@ -0,0 +1,9 @@
+#!/usr/local/bin/tclsh
+
+set CTMname cvs-cur
+set CTMdest /u4/CTM
+set CTMref /u1/CVS-FreeBSD
+set CTMprefix .
+set CTMcopy $CTMdest/$CTMname
+set CTMtmp $CTMdest/_tmp_$CTMname
+set CTMdate [exec date -u +%Y%m%d%H%M%SZ]
diff --git a/usr.sbin/ctm/mkCTM/ctm_conf.src-cur b/usr.sbin/ctm/mkCTM/ctm_conf.src-cur
new file mode 100644
index 000000000000..d81d39f2d98b
--- /dev/null
+++ b/usr.sbin/ctm/mkCTM/ctm_conf.src-cur
@@ -0,0 +1,9 @@
+#!/usr/local/bin/tclsh
+
+set CTMname src-cur
+set CTMdest /u1/CTM
+set CTMref /u4/ftp/pub/FreeBSD/SRC-current/src
+set CTMprefix .
+set CTMcopy $CTMdest/$CTMname
+set CTMtmp $CTMdest/_tmp_$CTMname
+set CTMdate [exec date -u +%Y%m%d%H%M%SZ]
diff --git a/usr.sbin/ctm/mkCTM/mkCTM b/usr.sbin/ctm/mkCTM/mkCTM
new file mode 100644
index 000000000000..5d94fa3c1ab5
--- /dev/null
+++ b/usr.sbin/ctm/mkCTM/mkCTM
@@ -0,0 +1,147 @@
+#!/usr/local/bin/tclsh
+
+source $argv
+
+set tmp $CTMtmp
+set dd $CTMdest
+set d1 $CTMcopy
+set d2 $CTMref
+set foo $CTMdate
+set foo $CTMprefix
+set foo $CTMname
+
+exec rm -f $tmp.*
+
+set f1 [open "| ./ctm_scan $d1"]
+set f2 [open "| ./ctm_scan $d2"]
+
+set fo_del [open $tmp.del w]
+set fo_rmdir [open $tmp.rmdir w]
+set fo_mkdir [open $tmp.mkdir w]
+set fo_files [open $tmp.files w]
+set changes 0
+
+####
+# Find CTM#
+for {set i 0} {1} {incr i} {
+ if {[file exists [format "%s/$CTMname.%04d" $dd $i]]} continue
+ if {[file exists [format "%s/$CTMname.%04d.gz" $dd $i]]} continue
+ break
+}
+set CTMnbr $i
+
+puts "Doing CTMname $CTMname CTMnbr $CTMnbr CTMdate $CTMdate"
+
+#####
+# Type Name Mode User Group Barf Size Hash
+
+proc CTMadd {t n m u g b s h} {
+ global fo_files fo_mkdir changes d2
+ puts stderr "A $b $t $n"
+ if {$t == "d"} {
+ puts $fo_mkdir "CTMDM $n $u $g $m"
+ incr changes
+ return
+ }
+ puts $fo_files "CTMFM $n $u $g $m $h $s"
+ flush $fo_files
+ exec cat $d2/$n >@ $fo_files
+ puts $fo_files ""
+ incr changes
+ return
+}
+proc CTMdel {t n m u g b s h} {
+ global fo_del fo_rmdir changes
+ puts stderr "D $b $t $n"
+ if {$t == "d"} {
+ puts $fo_rmdir "CTMDR $n"
+ incr changes
+ return
+ }
+ puts $fo_del "CTMFR $n $h"
+ incr changes
+ return
+}
+proc CTMchg {t1 n1 m1 u1 g1 b1 s1 h1 t2 n2 m2 u2 g2 b2 s2 h2} {
+ global fo_files d2 d1 changes
+ if {$t1 == "d" && $t2 == "d"} {
+ return
+ }
+ if {$t1 == "d" || $t2 == "d"} {
+ CTMdel $t1 $n1 $m1 $u1 $g1 $b1 $s1 $h1
+ CTMadd $t2 $n2 $m2 $u2 $g2 $b2 $s2 $h2
+ return
+ }
+ if {"x$h1" == "x$h2" && $s1 == $s2} {
+ return
+ puts stderr "M $b1$b2 $t1$t2 $n1"
+ puts $fo_files "CTMFA $n2 $u2 $g2 $m2 $h2"
+ incr changes
+ return
+ }
+ if {$b1 != "0" || $b2 != "0"} {
+ puts stderr "R $b1$b2 $t1$t2 $n1"
+ puts $fo_files "CTMFS $n2 $u2 $g2 $m2 $h1 $h2 $s2"
+ flush $fo_files
+ exec cat $d2/$n2 >@ $fo_files
+ puts $fo_files ""
+ incr changes
+ return
+ }
+ puts stderr "E $b1$b2 $t1$t2 $n1"
+ set i [catch "exec diff -e $d1/$n1 $d2/$n2 > tmp" j]
+ set s [file size tmp]
+ puts $fo_files "CTMFE $n1 $u2 $g2 $m2 $h1 $h2 $s"
+ flush $fo_files
+ exec cat tmp >@ $fo_files
+ puts $fo_files ""
+ incr changes
+}
+#####
+set l1 ""
+set l2 ""
+
+while 1 {
+
+ if {$l1 == ""} {gets $f1 l1}
+
+ if {$l2 == ""} {gets $f2 l2}
+
+ if {$l1 == "" && $l2 == ""} break
+
+ set n1 [lindex $l1 1]
+ set n2 [lindex $l2 1]
+
+ if {$l1 == $l2} { set l1 "" ; set l2 "" ; continue }
+
+ if {$l1 == "" } { eval CTMadd $l2 ; set l2 "" ; continue }
+
+ if {$l2 == "" } { eval CTMdel $l1 ; set l1 "" ; continue }
+
+ if {$n1 < $n2 } { eval CTMdel $l1 ; set l1 "" ; continue }
+
+ if {$n1 > $n2 } { eval CTMadd $l2 ; set l2 "" ; continue }
+
+ if {$n1 == $n2} { eval CTMchg $l1 $l2 ; set l1 "" ; set l2 "" ; continue }
+}
+
+close $fo_del
+close $fo_rmdir
+close $fo_mkdir
+close $fo_files
+
+exec echo CTM_BEGIN 2.0 $CTMname $CTMnbr $CTMdate $CTMprefix > $tmp.begin
+exec echo -n "CTM_END " >> $tmp.end
+set m [exec cat $tmp.begin $tmp.del $tmp.rmdir $tmp.mkdir $tmp.files $tmp.end | md5]
+exec echo "$m" >> $tmp.end
+
+if {!$changes} {
+ puts "no changes"
+ exec sh -c "rm -f $tmp.*"
+ exit 0
+}
+
+set nm [format "%s/%s.%04d" $dd $CTMname $CTMnbr]
+exec cat $tmp.begin $tmp.del $tmp.rmdir $tmp.mkdir $tmp.files $tmp.end | gzip -9 -v > ${nm}.gz 2>@ stdout
+exec sh -c "rm -f $tmp.*"
+exec sh -e -x -c "cd $CTMcopy ; /root/CTM/ctm -v -v -v ${nm}.gz" >&@ stdout