head	1.22;
access;
symbols
	RELENG_8_4:1.22.0.2
	RELENG_9_1_0_RELEASE:1.21.40.1.4.2
	RELENG_9_1:1.21.40.1.0.4
	RELENG_9_1_BP:1.21.40.1
	RELENG_8_3_0_RELEASE:1.21.34.1.8.1
	RELENG_8_3:1.21.34.1.0.8
	RELENG_8_3_BP:1.21.34.1
	RELENG_9_0_0_RELEASE:1.21.40.1.2.1
	RELENG_9_0:1.21.40.1.0.2
	RELENG_9_0_BP:1.21.40.1
	RELENG_9:1.21.0.40
	RELENG_9_BP:1.21
	RELENG_7_4_0_RELEASE:1.21.38.1
	RELENG_8_2_0_RELEASE:1.21.34.1.6.1
	RELENG_7_4:1.21.0.38
	RELENG_7_4_BP:1.21
	RELENG_8_2:1.21.34.1.0.6
	RELENG_8_2_BP:1.21.34.1
	RELENG_8_1_0_RELEASE:1.21.34.1.4.1
	RELENG_8_1:1.21.34.1.0.4
	RELENG_8_1_BP:1.21.34.1
	RELENG_7_3_0_RELEASE:1.21.36.1
	RELENG_7_3:1.21.0.36
	RELENG_7_3_BP:1.21
	RELENG_8_0_0_RELEASE:1.21.34.1.2.1
	RELENG_8_0:1.21.34.1.0.2
	RELENG_8_0_BP:1.21.34.1
	RELENG_8:1.21.0.34
	RELENG_8_BP:1.21
	RELENG_7_2_0_RELEASE:1.21.32.1
	RELENG_7_2:1.21.0.32
	RELENG_7_2_BP:1.21
	RELENG_7_1_0_RELEASE:1.21.30.1
	RELENG_6_4_0_RELEASE:1.21.28.1
	RELENG_7_1:1.21.0.30
	RELENG_7_1_BP:1.21
	RELENG_6_4:1.21.0.28
	RELENG_6_4_BP:1.21
	RELENG_7_0_0_RELEASE:1.21
	RELENG_6_3_0_RELEASE:1.21
	RELENG_7_0:1.21.0.26
	RELENG_7_0_BP:1.21
	RELENG_6_3:1.21.0.24
	RELENG_6_3_BP:1.21
	RELENG_7:1.21.0.22
	RELENG_7_BP:1.21
	RELENG_6_2_0_RELEASE:1.21
	RELENG_6_2:1.21.0.20
	RELENG_6_2_BP:1.21
	RELENG_5_5_0_RELEASE:1.21
	RELENG_5_5:1.21.0.18
	RELENG_5_5_BP:1.21
	RELENG_6_1_0_RELEASE:1.21
	RELENG_6_1:1.21.0.16
	RELENG_6_1_BP:1.21
	RELENG_6_0_0_RELEASE:1.21
	RELENG_6_0:1.21.0.14
	RELENG_6_0_BP:1.21
	RELENG_6:1.21.0.12
	RELENG_6_BP:1.21
	RELENG_5_4_0_RELEASE:1.21
	RELENG_5_4:1.21.0.10
	RELENG_5_4_BP:1.21
	RELENG_4_11_0_RELEASE:1.20
	RELENG_4_11:1.20.0.26
	RELENG_4_11_BP:1.20
	RELENG_5_3_0_RELEASE:1.21
	RELENG_5_3:1.21.0.8
	RELENG_5_3_BP:1.21
	RELENG_5:1.21.0.6
	RELENG_5_BP:1.21
	RELENG_4_10_0_RELEASE:1.20
	RELENG_4_10:1.20.0.24
	RELENG_4_10_BP:1.20
	RELENG_5_2_1_RELEASE:1.21
	RELENG_5_2_0_RELEASE:1.21
	RELENG_5_2:1.21.0.4
	RELENG_5_2_BP:1.21
	RELENG_4_9_0_RELEASE:1.20
	RELENG_4_9:1.20.0.22
	RELENG_4_9_BP:1.20
	RELENG_5_1_0_RELEASE:1.21
	RELENG_5_1:1.21.0.2
	RELENG_5_1_BP:1.21
	RELENG_4_8_0_RELEASE:1.20
	RELENG_4_8:1.20.0.20
	RELENG_4_8_BP:1.20
	RELENG_5_0_0_RELEASE:1.20
	RELENG_5_0:1.20.0.18
	RELENG_5_0_BP:1.20
	RELENG_4_7_0_RELEASE:1.20
	RELENG_4_7:1.20.0.16
	RELENG_4_7_BP:1.20
	RELENG_4_6_2_RELEASE:1.20
	RELENG_4_6_1_RELEASE:1.20
	RELENG_4_6_0_RELEASE:1.20
	RELENG_4_6:1.20.0.14
	RELENG_4_6_BP:1.20
	RELENG_4_5_0_RELEASE:1.20
	RELENG_4_5:1.20.0.12
	RELENG_4_5_BP:1.20
	RELENG_4_4_0_RELEASE:1.20
	RELENG_4_4:1.20.0.10
	RELENG_4_4_BP:1.20
	RELENG_4_3_0_RELEASE:1.20
	RELENG_4_3:1.20.0.8
	RELENG_4_3_BP:1.20
	RELENG_4_2_0_RELEASE:1.20
	RELENG_4_1_1_RELEASE:1.20
	PRE_SMPNG:1.20
	RELENG_4_1_0_RELEASE:1.20
	RELENG_3_5_0_RELEASE:1.20
	RELENG_4_0_0_RELEASE:1.20
	RELENG_4:1.20.0.6
	RELENG_4_BP:1.20
	RELENG_3_4_0_RELEASE:1.20
	RELENG_3_3_0_RELEASE:1.20
	RELENG_3_2_PAO:1.20.0.4
	RELENG_3_2_PAO_BP:1.20
	RELENG_3_2_0_RELEASE:1.20
	RELENG_3_1_0_RELEASE:1.20
	RELENG_3:1.20.0.2
	RELENG_3_BP:1.20
	RELENG_2_2_8_RELEASE:1.16.2.1
	RELENG_3_0_0_RELEASE:1.19
	RELENG_2_2_7_RELEASE:1.16.2.1
	RELENG_2_2_6_RELEASE:1.16.2.1
	RELENG_2_2_5_RELEASE:1.16.2.1
	RELENG_2_2_2_RELEASE:1.16.2.1
	RELENG_2_2_1_RELEASE:1.16.2.1
	RELENG_2_2_0_RELEASE:1.16.2.1
	RELENG_2_1_7_RELEASE:1.13
	RELENG_2_1_6_1_RELEASE:1.13
	RELENG_2_1_6_RELEASE:1.13
	RELENG_2_2:1.16.0.2
	RELENG_2_2_BP:1.16
	RELENG_2_1_5_RELEASE:1.13
	RELENG_2_1_0_RELEASE:1.13
	RELENG_2_1_0:1.13.0.4
	RELENG_2_1_0_BP:1.13
	RELENG_2_0_5_RELEASE:1.13
	RELENG_2_0_5:1.13.0.2
	RELENG_2_0_5_BP:1.13
	RELENG_2_0_5_ALPHA:1.13
	RELEASE_2_0:1.6
	BETA_2_0:1.6
	ALPHA_2_0:1.6.0.2
	orig:1.1.1.1
	phk:1.1.1;
locks; strict;
comment	@# @;


1.22
date	2012.11.17.01.54.43;	author svnexp;	state Exp;
branches
	1.22.2.1;
next	1.21;

1.21
date	2003.01.01.18.49.01;	author schweikh;	state Exp;
branches
	1.21.12.1
	1.21.22.1
	1.21.28.1
	1.21.30.1
	1.21.32.1
	1.21.34.1
	1.21.36.1
	1.21.38.1
	1.21.40.1;
next	1.20;

1.20
date	99.01.19.11.52.57;	author danny;	state Exp;
branches;
next	1.19;

1.19
date	96.11.20.08.21.27;	author phk;	state Exp;
branches;
next	1.18;

1.18
date	96.11.17.08.11.16;	author phk;	state Exp;
branches;
next	1.17;

1.17
date	96.11.16.19.30.12;	author phk;	state Exp;
branches;
next	1.16;

1.16
date	96.09.07.19.50.48;	author peter;	state Exp;
branches
	1.16.2.1;
next	1.15;

1.15
date	96.09.07.18.48.52;	author peter;	state Exp;
branches;
next	1.14;

1.14
date	96.05.09.20.54.03;	author phk;	state Exp;
branches;
next	1.13;

1.13
date	95.03.29.06.13.08;	author phk;	state Exp;
branches;
next	1.12;

1.12
date	95.02.28.20.52.56;	author phk;	state Exp;
branches;
next	1.11;

1.11
date	95.02.27.22.26.58;	author phk;	state Exp;
branches;
next	1.10;

1.10
date	95.02.21.02.09.47;	author phk;	state Exp;
branches;
next	1.9;

1.9
date	95.02.20.03.03.02;	author phk;	state Exp;
branches;
next	1.8;

1.8
date	95.02.19.04.51.41;	author phk;	state Exp;
branches;
next	1.7;

1.7
date	94.12.08.21.46.04;	author phk;	state Exp;
branches;
next	1.6;

1.6
date	94.10.24.20.09.39;	author phk;	state Exp;
branches;
next	1.5;

1.5
date	94.09.26.06.01.01;	author phk;	state Exp;
branches;
next	1.4;

1.4
date	94.09.22.02.49.24;	author phk;	state Exp;
branches;
next	1.3;

1.3
date	94.09.21.04.38.48;	author phk;	state Exp;
branches;
next	1.2;

1.2
date	94.09.20.07.13.39;	author phk;	state Exp;
branches;
next	1.1;

1.1
date	94.09.19.07.32.23;	author phk;	state Exp;
branches
	1.1.1.1;
next	;

1.22.2.1
date	2012.11.17.01.54.43;	author svnexp;	state dead;
branches;
next	1.22.2.2;

1.22.2.2
date	2013.03.28.13.06.15;	author svnexp;	state Exp;
branches;
next	;

1.21.12.1
date	2012.11.17.07.46.16;	author svnexp;	state Exp;
branches;
next	;

1.21.22.1
date	2012.11.17.08.09.01;	author svnexp;	state Exp;
branches;
next	;

1.21.28.1
date	2008.10.02.02.57.24;	author kensmith;	state Exp;
branches;
next	;

1.21.30.1
date	2008.11.25.02.59.29;	author kensmith;	state Exp;
branches;
next	;

1.21.32.1
date	2009.04.15.03.14.26;	author kensmith;	state Exp;
branches;
next	;

1.21.34.1
date	2009.08.03.08.13.06;	author kensmith;	state Exp;
branches
	1.21.34.1.2.1
	1.21.34.1.4.1
	1.21.34.1.6.1
	1.21.34.1.8.1;
next	1.21.34.2;

1.21.34.2
date	2012.11.17.10.37.22;	author svnexp;	state Exp;
branches;
next	;

1.21.34.1.2.1
date	2009.10.25.01.10.29;	author kensmith;	state Exp;
branches;
next	;

1.21.34.1.4.1
date	2010.06.14.02.09.06;	author kensmith;	state Exp;
branches;
next	;

1.21.34.1.6.1
date	2010.12.21.17.09.25;	author kensmith;	state Exp;
branches;
next	;

1.21.34.1.8.1
date	2012.03.03.06.15.13;	author kensmith;	state Exp;
branches;
next	1.21.34.1.8.2;

1.21.34.1.8.2
date	2012.11.17.08.25.54;	author svnexp;	state Exp;
branches;
next	;

1.21.36.1
date	2010.02.10.00.26.20;	author kensmith;	state Exp;
branches;
next	;

1.21.38.1
date	2010.12.21.17.10.29;	author kensmith;	state Exp;
branches;
next	1.21.38.2;

1.21.38.2
date	2012.11.17.08.17.47;	author svnexp;	state Exp;
branches;
next	;

1.21.40.1
date	2011.09.23.00.51.37;	author kensmith;	state Exp;
branches
	1.21.40.1.2.1
	1.21.40.1.4.1;
next	1.21.40.2;

1.21.40.2
date	2012.11.17.11.37.43;	author svnexp;	state Exp;
branches;
next	;

1.21.40.1.2.1
date	2011.11.11.04.20.22;	author kensmith;	state Exp;
branches;
next	1.21.40.1.2.2;

1.21.40.1.2.2
date	2012.11.17.08.37.40;	author svnexp;	state Exp;
branches;
next	;

1.21.40.1.4.1
date	2012.08.05.23.54.33;	author kensmith;	state Exp;
branches;
next	1.21.40.1.4.2;

1.21.40.1.4.2
date	2012.11.17.08.48.32;	author svnexp;	state Exp;
branches;
next	;

1.16.2.1
date	96.11.21.16.49.54;	author phk;	state Exp;
branches;
next	;

1.1.1.1
date	94.09.19.07.32.24;	author phk;	state Exp;
branches;
next	;


desc
@@


1.22
log
@Switching exporter and resync
@
text
@#!/usr/local/bin/tclsh7.4
#
# $FreeBSD: head/usr.sbin/ctm/mkCTM/mkCTM 108533 2003-01-01 18:49:04Z schweikh $

#############################################################################
### Do we already have this delta ?
#############################################################################

proc find_delta {nbr} {
    global CTMname CTMdest
    if {[file exists [format "%s/$CTMname.%04d" $CTMdest $nbr]]} { return 1 }
    if {[file exists [format "%s/$CTMname.%04d.gz" $CTMdest $nbr]]} { return 1 }
    return 0
}

#############################################################################
### The top level code...
#############################################################################

set CTMSW	/home/ctm/SW

cd $CTMSW

# Defaults...
set CTMapply 1
set CTMignore {^///}
set CTMbogus {\.core$}
set CTMmail {}
set CTMqueue {}
set CTMqueuemail {}
set CTMmaxctm 10000000
set CTMmaxmsg 100000
set CTMsuff {}
set CTMdate     [exec date -u +%Y%m%d%H%M%SZ]
set CTMtmp  {}
set CTMcopy  {}
set CTMdest  {}
set CTMprefix  .
set CTMtest 0
set CTMspecial 0
set CTMscan .
set CTMfirst 0
set max_damage 100

set damage 0
set changes 0

source $argv
exec sh -c "date -u '+%Y%m%d%H%M%S $argv'" >> ${CTMSW}/log

if {$CTMtmp == ""} {
    set CTMtmp $CTMSW/../tmp/${CTMname}_${CTMsuff}
}
if {$CTMcopy == ""} {
    set CTMcopy $CTMSW/../$CTMname
}
if {$CTMdest == ""} {
    set CTMdest $CTMSW/../CTM-pub/$CTMname
}

# Make sure we only run one at a time...

set CTMlock Lck.${CTMname}.${CTMdate}.[pid]
exec rm -f ${CTMlock}
exec echo starting > ${CTMlock}
if {[catch "exec ln $CTMlock LCK.$CTMname" a]} {
	puts "Not going, lock exists..."
	exec rm -f $CTMlock
	exit 1
}
exec rm -f $CTMlock
set CTMlock LCK.$CTMname

set CTMscratch ${CTMtmp}.tmp

while 1 {
    if { ! $CTMspecial} {
	if {$CTMfirst} {
		set CTMnbr 0
	} else {
		set CTMnbr [lindex [exec cat $CTMcopy/.ctm_status] 1]
	}

	if {$CTMnbr > 0 && ![find_delta $CTMnbr]} {
	    puts "$CTMname delta $CTMnbr doesn't exist..."
	    exec rm -f $CTMlock
	    exit 1
	}

	incr CTMnbr

	if {[find_delta $CTMnbr]} {
	    puts "$CTMname delta $CTMnbr does already exist..."
	    exec rm -f $CTMlock
	    exit 1
	}

	set fo [open $CTMref/.ctm_status w]
	puts $fo "$CTMname $CTMnbr"
	close $fo
	incr changes -1

    } else {
	set CTMnbr [lindex [exec cat $CTMref/.ctm_status] 1]
    }

    puts "Doing CTMname $CTMname CTMnbr $CTMnbr$CTMsuff CTMdate $CTMdate"
    flush stdout
    exec sh -c "rm -f ${CTMtmp}.* ${CTMtmp}:*" >&@@ stdout

    set  nm [format "%s.%04d%s" $CTMname $CTMnbr $CTMsuff]

    set x1 $CTMcopy
    if {$x1 == ""} {
	exec mkdir ${CTMtmp}.dir
	set x1 ${CTMtmp}.dir
    }
    set r1 [catch "exec ${CTMSW}/mkctm -I ${CTMignore} -B ${CTMbogus} -l ${CTMtmp}.log -D $max_damage $CTMname $CTMnbr $CTMdate . $x1 $CTMref | md5 -p | gzip -9 > ${CTMtmp}:${nm}.gz 2>@@ stderr" r2]

    if {$r1} {
	if {[lindex $errorCode 2] == 4} {
		puts "No changes, stopping."
		exec rm -f $CTMlock
		exit 0
	}
	puts "problems, stopping now."
        puts "errorCode $errorCode"
	puts "$r2"
        exec rm -f $CTMlock
	exit 1
    }
	
    puts "mkctm done"

    if {$CTMtest} {
	puts "testing, stopping now."
        exec rm -f $CTMlock
	exit 0
    }
    if {$CTMapply} {
	    puts "Applying delta"
	    flush stdout
	    exec echo now applying > $CTMlock
	    exec sh -e -c "cd $CTMcopy ; $CTMSW/ctm -v -v -v ${CTMtmp}:${nm}.gz" >& ${CTMtmp}.apply
	    exec echo did apply > $CTMlock
    }
    puts "Moving delta"
    flush stdout
    exec mv ${CTMtmp}:${nm}.gz $CTMdest/.CTMtmp_${nm}.gz >&@@ stdout
    exec mv $CTMdest/.CTMtmp_${nm}.gz $CTMdest/${nm}.gz >&@@ stdout
    exec echo moved > $CTMlock

    exec sh -c "rm -rf ${CTMtmp}.*" >&@@ stdout

    if {$CTMmail != ""} {
	puts "Mailing delta"
	flush stdout
	exec $CTMSW/ctm_smail -m $CTMmaxmsg -c $CTMmaxctm $CTMdest/${nm}.gz $CTMmail >&@@ stdout
	if {$CTMqueue != "" && $CTMqueuemail != ""} {
	    puts "Queueing delta"
	    flush stdout
	    exec $CTMSW/ctm_smail -m $CTMmaxmsg -c $CTMmaxctm -q $CTMqueue $CTMdest/${nm}.gz $CTMqueuemail >&@@ stdout
	    puts "Sending initial two deltas"
	    flush stdout
	    exec $CTMSW/ctm_dequeue -n 2 $CTMqueue >&@@ stdout
	}
    }
    exec echo mailed > $CTMlock

    # If we did an absolute delta: stop.
    if {$CTMsuff != ""} break

    # Make an absolute delta (!) every 100 deltas
    if {$CTMnbr == 0 || ($CTMnbr % 100)} break

    # Make an absolute delta too...
    set CTMref $CTMcopy
    set CTMsuff A
    set CTMcopy ""
    set CTMmail ""
    set CTMqueue ""
    set CTMqueuemail ""
    set CTMapply 0
    set CTMspecial 1
    exec rm -f $CTMlock
}
puts "done."
exec rm -f $CTMlock
@


1.22.2.1
log
@file mkCTM was added on branch RELENG_8_4 on 2013-03-28 13:06:15 +0000
@
text
@d1 188
@


1.22.2.2
log
@## SVN ## Exported commit - http://svnweb.freebsd.org/changeset/base/248810
## SVN ## CVS IS DEPRECATED: http://wiki.freebsd.org/CvsIsDeprecated
@
text
@a0 188
#!/usr/local/bin/tclsh7.4
#
# $FreeBSD: releng/8.4/usr.sbin/ctm/mkCTM/mkCTM 108533 2003-01-01 18:49:04Z schweikh $

#############################################################################
### Do we already have this delta ?
#############################################################################

proc find_delta {nbr} {
    global CTMname CTMdest
    if {[file exists [format "%s/$CTMname.%04d" $CTMdest $nbr]]} { return 1 }
    if {[file exists [format "%s/$CTMname.%04d.gz" $CTMdest $nbr]]} { return 1 }
    return 0
}

#############################################################################
### The top level code...
#############################################################################

set CTMSW	/home/ctm/SW

cd $CTMSW

# Defaults...
set CTMapply 1
set CTMignore {^///}
set CTMbogus {\.core$}
set CTMmail {}
set CTMqueue {}
set CTMqueuemail {}
set CTMmaxctm 10000000
set CTMmaxmsg 100000
set CTMsuff {}
set CTMdate     [exec date -u +%Y%m%d%H%M%SZ]
set CTMtmp  {}
set CTMcopy  {}
set CTMdest  {}
set CTMprefix  .
set CTMtest 0
set CTMspecial 0
set CTMscan .
set CTMfirst 0
set max_damage 100

set damage 0
set changes 0

source $argv
exec sh -c "date -u '+%Y%m%d%H%M%S $argv'" >> ${CTMSW}/log

if {$CTMtmp == ""} {
    set CTMtmp $CTMSW/../tmp/${CTMname}_${CTMsuff}
}
if {$CTMcopy == ""} {
    set CTMcopy $CTMSW/../$CTMname
}
if {$CTMdest == ""} {
    set CTMdest $CTMSW/../CTM-pub/$CTMname
}

# Make sure we only run one at a time...

set CTMlock Lck.${CTMname}.${CTMdate}.[pid]
exec rm -f ${CTMlock}
exec echo starting > ${CTMlock}
if {[catch "exec ln $CTMlock LCK.$CTMname" a]} {
	puts "Not going, lock exists..."
	exec rm -f $CTMlock
	exit 1
}
exec rm -f $CTMlock
set CTMlock LCK.$CTMname

set CTMscratch ${CTMtmp}.tmp

while 1 {
    if { ! $CTMspecial} {
	if {$CTMfirst} {
		set CTMnbr 0
	} else {
		set CTMnbr [lindex [exec cat $CTMcopy/.ctm_status] 1]
	}

	if {$CTMnbr > 0 && ![find_delta $CTMnbr]} {
	    puts "$CTMname delta $CTMnbr doesn't exist..."
	    exec rm -f $CTMlock
	    exit 1
	}

	incr CTMnbr

	if {[find_delta $CTMnbr]} {
	    puts "$CTMname delta $CTMnbr does already exist..."
	    exec rm -f $CTMlock
	    exit 1
	}

	set fo [open $CTMref/.ctm_status w]
	puts $fo "$CTMname $CTMnbr"
	close $fo
	incr changes -1

    } else {
	set CTMnbr [lindex [exec cat $CTMref/.ctm_status] 1]
    }

    puts "Doing CTMname $CTMname CTMnbr $CTMnbr$CTMsuff CTMdate $CTMdate"
    flush stdout
    exec sh -c "rm -f ${CTMtmp}.* ${CTMtmp}:*" >&@@ stdout

    set  nm [format "%s.%04d%s" $CTMname $CTMnbr $CTMsuff]

    set x1 $CTMcopy
    if {$x1 == ""} {
	exec mkdir ${CTMtmp}.dir
	set x1 ${CTMtmp}.dir
    }
    set r1 [catch "exec ${CTMSW}/mkctm -I ${CTMignore} -B ${CTMbogus} -l ${CTMtmp}.log -D $max_damage $CTMname $CTMnbr $CTMdate . $x1 $CTMref | md5 -p | gzip -9 > ${CTMtmp}:${nm}.gz 2>@@ stderr" r2]

    if {$r1} {
	if {[lindex $errorCode 2] == 4} {
		puts "No changes, stopping."
		exec rm -f $CTMlock
		exit 0
	}
	puts "problems, stopping now."
        puts "errorCode $errorCode"
	puts "$r2"
        exec rm -f $CTMlock
	exit 1
    }
	
    puts "mkctm done"

    if {$CTMtest} {
	puts "testing, stopping now."
        exec rm -f $CTMlock
	exit 0
    }
    if {$CTMapply} {
	    puts "Applying delta"
	    flush stdout
	    exec echo now applying > $CTMlock
	    exec sh -e -c "cd $CTMcopy ; $CTMSW/ctm -v -v -v ${CTMtmp}:${nm}.gz" >& ${CTMtmp}.apply
	    exec echo did apply > $CTMlock
    }
    puts "Moving delta"
    flush stdout
    exec mv ${CTMtmp}:${nm}.gz $CTMdest/.CTMtmp_${nm}.gz >&@@ stdout
    exec mv $CTMdest/.CTMtmp_${nm}.gz $CTMdest/${nm}.gz >&@@ stdout
    exec echo moved > $CTMlock

    exec sh -c "rm -rf ${CTMtmp}.*" >&@@ stdout

    if {$CTMmail != ""} {
	puts "Mailing delta"
	flush stdout
	exec $CTMSW/ctm_smail -m $CTMmaxmsg -c $CTMmaxctm $CTMdest/${nm}.gz $CTMmail >&@@ stdout
	if {$CTMqueue != "" && $CTMqueuemail != ""} {
	    puts "Queueing delta"
	    flush stdout
	    exec $CTMSW/ctm_smail -m $CTMmaxmsg -c $CTMmaxctm -q $CTMqueue $CTMdest/${nm}.gz $CTMqueuemail >&@@ stdout
	    puts "Sending initial two deltas"
	    flush stdout
	    exec $CTMSW/ctm_dequeue -n 2 $CTMqueue >&@@ stdout
	}
    }
    exec echo mailed > $CTMlock

    # If we did an absolute delta: stop.
    if {$CTMsuff != ""} break

    # Make an absolute delta (!) every 100 deltas
    if {$CTMnbr == 0 || ($CTMnbr % 100)} break

    # Make an absolute delta too...
    set CTMref $CTMcopy
    set CTMsuff A
    set CTMcopy ""
    set CTMmail ""
    set CTMqueue ""
    set CTMqueuemail ""
    set CTMapply 0
    set CTMspecial 1
    exec rm -f $CTMlock
}
puts "done."
exec rm -f $CTMlock
@


1.21
log
@Correct typos, mostly s/ a / an / where appropriate. Some whitespace cleanup,
especially in troff files.
@
text
@d3 1
a3 1
# $FreeBSD$
@


1.21.22.1
log
@Switch importer
@
text
@d3 1
a3 1
# $FreeBSD: stable/7/usr.sbin/ctm/mkCTM/mkCTM 108533 2003-01-01 18:49:04Z schweikh $
@


1.21.12.1
log
@Switch importer
@
text
@d3 1
a3 1
# $FreeBSD: stable/6/usr.sbin/ctm/mkCTM/mkCTM 108533 2003-01-01 18:49:04Z schweikh $
@


1.21.40.1
log
@SVN rev 225736 on 2011-09-23 00:51:37Z by kensmith

Copy head to stable/9 as part of 9.0-RELEASE release cycle.

Approved by:	re (implicit)
@
text
@@


1.21.40.2
log
@## SVN ##
## SVN ## Exported commit - http://svnweb.freebsd.org/changeset/base/ 242902
## SVN ## CVS IS DEPRECATED: http://wiki.freebsd.org/CvsIsDeprecated
## SVN ##
## SVN ## ------------------------------------------------------------------------
## SVN ## r242902 | dteske | 2012-11-11 23:29:45 +0000 (Sun, 11 Nov 2012) | 10 lines
## SVN ##
## SVN ## Fix a regression introduced by SVN r211417 that saw the breakage of a feature
## SVN ## documented in usr.sbin/sysinstall/help/shortcuts.hlp (reproduced below):
## SVN ##
## SVN ## If /usr/sbin/sysinstall is linked to another filename, say
## SVN ## `/usr/local/bin/configPackages', then the basename will be used
## SVN ## as an implicit command name.
## SVN ##
## SVN ## Reviewed by:	adrian (co-mentor)
## SVN ## Approved by:	adrian (co-mentor)
## SVN ##
## SVN ## ------------------------------------------------------------------------
## SVN ##
@
text
@d3 1
a3 1
# $FreeBSD: stable/9/usr.sbin/ctm/mkCTM/mkCTM 108533 2003-01-01 18:49:04Z schweikh $
@


1.21.40.1.4.1
log
@SVN rev 239080 on 2012-08-05 23:54:33Z by kensmith

Copy stable/9 to releng/9.1 as part of the 9.1-RELEASE release process.

Approved by:	re (implicit)
@
text
@@


1.21.40.1.4.2
log
@Switch importer
@
text
@d3 1
a3 1
# $FreeBSD: releng/9.1/usr.sbin/ctm/mkCTM/mkCTM 108533 2003-01-01 18:49:04Z schweikh $
@


1.21.40.1.2.1
log
@SVN rev 227445 on 2011-11-11 04:20:22Z by kensmith

Copy stable/9 to releng/9.0 as part of the FreeBSD 9.0-RELEASE release
cycle.

Approved by:	re (implicit)
@
text
@@


1.21.40.1.2.2
log
@Switch importer
@
text
@d3 1
a3 1
# $FreeBSD: releng/9.0/usr.sbin/ctm/mkCTM/mkCTM 108533 2003-01-01 18:49:04Z schweikh $
@


1.21.38.1
log
@SVN rev 216618 on 2010-12-21 17:10:29Z by kensmith

Copy stable/7 to releng/7.4 in preparation for FreeBSD-7.4 release.

Approved by:	re (implicit)
@
text
@@


1.21.38.2
log
@Switch importer
@
text
@d3 1
a3 1
# $FreeBSD: releng/7.4/usr.sbin/ctm/mkCTM/mkCTM 108533 2003-01-01 18:49:04Z schweikh $
@


1.21.36.1
log
@SVN rev 203736 on 2010-02-10 00:26:20Z by kensmith

Copy stable/7 to releng/7.3 as part of the 7.3-RELEASE process.

Approved by:	re (implicit)
@
text
@@


1.21.34.1
log
@SVN rev 196045 on 2009-08-03 08:13:06Z by kensmith

Copy head to stable/8 as part of 8.0 Release cycle.

Approved by:	re (Implicit)
@
text
@@


1.21.34.2
log
@## SVN ##
## SVN ## Exported commit - http://svnweb.freebsd.org/changeset/base/ 242909
## SVN ## CVS IS DEPRECATED: http://wiki.freebsd.org/CvsIsDeprecated
## SVN ##
## SVN ## ------------------------------------------------------------------------
## SVN ## r242909 | dim | 2012-11-12 07:47:19 +0000 (Mon, 12 Nov 2012) | 20 lines
## SVN ##
## SVN ## MFC r242625:
## SVN ##
## SVN ## Remove duplicate const specifiers in many drivers (I hope I got all of
## SVN ## them, please let me know if not).  Most of these are of the form:
## SVN ##
## SVN ## static const struct bzzt_type {
## SVN ##       [...list of members...]
## SVN ## } const bzzt_devs[] = {
## SVN ##       [...list of initializers...]
## SVN ## };
## SVN ##
## SVN ## The second const is unnecessary, as arrays cannot be modified anyway,
## SVN ## and if the elements are const, the whole thing is const automatically
## SVN ## (e.g. it is placed in .rodata).
## SVN ##
## SVN ## I have verified this does not change the binary output of a full kernel
## SVN ## build (except for build timestamps embedded in the object files).
## SVN ##
## SVN ## Reviewed by:	yongari, marius
## SVN ##
## SVN ## ------------------------------------------------------------------------
## SVN ##
@
text
@d3 1
a3 1
# $FreeBSD: stable/8/usr.sbin/ctm/mkCTM/mkCTM 108533 2003-01-01 18:49:04Z schweikh $
@


1.21.34.1.8.1
log
@SVN rev 232438 on 2012-03-03 06:15:13Z by kensmith

Copy stable/8 to releng/8.3 as part of 8.3-RELEASE release cycle.

Approved by:	re (implicit)
@
text
@@


1.21.34.1.8.2
log
@Switch importer
@
text
@d3 1
a3 1
# $FreeBSD: releng/8.3/usr.sbin/ctm/mkCTM/mkCTM 108533 2003-01-01 18:49:04Z schweikh $
@


1.21.34.1.6.1
log
@SVN rev 216617 on 2010-12-21 17:09:25Z by kensmith

Copy stable/8 to releng/8.2 in preparation for FreeBSD-8.2 release.

Approved by:	re (implicit)
@
text
@@


1.21.34.1.4.1
log
@SVN rev 209145 on 2010-06-14 02:09:06Z by kensmith

Copy stable/8 to releng/8.1 in preparation for 8.1-RC1.

Approved by:	re (implicit)
@
text
@@


1.21.34.1.2.1
log
@SVN rev 198460 on 2009-10-25 01:10:29Z by kensmith

Copy stable/8 to releng/8.0 as part of 8.0-RELEASE release procedure.

Approved by:	re (implicit)
@
text
@@


1.21.32.1
log
@SVN rev 191087 on 2009-04-15 03:14:26Z by kensmith

Create releng/7.2 from stable/7 in preparation for 7.2-RELEASE.

Approved by:	re (implicit)
@
text
@@


1.21.30.1
log
@SVN rev 185281 on 2008-11-25 02:59:29Z by kensmith

Create releng/7.1 in preparation for moving into RC phase of 7.1 release
cycle.

Approved by:	re (implicit)
@
text
@@


1.21.28.1
log
@SVN rev 183531 on 2008-10-02 02:57:24Z by kensmith

Create releng/6.4 from stable/6 in preparation for 6.4-RC1.

Approved by:	re (implicit)
@
text
@@


1.20
log
@Use 4 digit year in log file, rather than 2.
@
text
@d2 2
d173 1
a173 1
    # Make a absolute delta (!) every 100 deltas
@


1.19
log
@Latest reality.
@
text
@d47 1
a47 1
exec sh -c "date -u '+%y%m%d%H%M%S $argv'" >> ${CTMSW}/log
@


1.18
log
@Make the case where there is no changes look less fatal.
@
text
@d116 1
a116 1
    set r1 [catch "exec ${CTMSW}/mkctm -I ${CTMignore} -B ${CTMbogus} -l ${CTMtmp}.log -D $max_damage $CTMname $CTMnbr . $CTMdate $x1 $CTMref | md5 -p | gzip -9 > ${CTMtmp}:${nm}.gz 2>@@ stderr" r2]
@


1.17
log
@Improve mkctm.c so we can use it, and start using it.
This should help quite a bit on the load.  Notice that
some minor changes in config files will be needed.
Contact me for details.
@
text
@d119 5
@


1.16
log
@After queueing deltas, send out an initial two mails since that will cover
99.9% of the cases at with out delay as before.
@
text
@a3 100
### Add something
#############################################################################
# Type Name Mode User Group Barf Size Hash

proc CTMadd {t n m u g b s h} {
    global fo_files fo_mkdir changes CTMref

    puts stderr "A $b  $t  $n"
    incr changes

    if {$t == "d"} {
	puts $fo_mkdir "CTMDM $n $u $g $m"
    } elseif {$t == "f"} {
	puts $fo_files "CTMFM $n $u $g $m $h $s"
	flush $fo_files
	exec cat $CTMref/$n >@@ $fo_files
	puts $fo_files ""
    } else {
	puts "confused in CTMadd"
	exit 0
    }
}

#############################################################################
### Delete something
#############################################################################
# Type Name Mode User Group Barf Size Hash

proc CTMdel {t n m u g b s h} {
    global fo_del fo_rmdir changes damage max_damage CTMlock

    puts stderr "D $b  $t  $n"
    incr damage 
    incr changes

    if {$damage > $max_damage} {
	exec rm -f $CTMlock
	return
    }
    if {$t == "d"} {
	puts $fo_rmdir "CTMDR $n"
    } elseif {$t == "f"} {
	puts $fo_del "CTMFR $n $h"
    } else {
	puts "confused in CTMdel"
	exit 0
    }
}

#############################################################################
### Change something
#############################################################################
# Type Name Mode User Group Barf Size Hash

proc CTMchg {t1 n1 m1 u1 g1 b1 s1 h1 t2 n2 m2 u2 g2 b2 s2 h2} {
    global fo_files CTMref CTMcopy changes damage CTMscratch

    # Ignore attribute changes for directories
    if {$t1 == "d" && $t2 == "d"} return

    # turn file into dir or vice versa...
    if {$t1 != $t2} {
	CTMdel $t1 $n1 $m1 $u1 $g1 $b1 $s1 $h1
	CTMadd $t2 $n2 $m2 $u2 $g2 $b2 $s2 $h2
	return
    }

    # only files allowed past this poing...
    if {$t1 != "f" && $t2 != "f"} {
        puts "confused in CTMchg"
        exit 0
    }

    # Ignore attribute changes for files
    if {"x$h1" == "x$h2" && $s1 == $s2} return

    if {$s2 == 0} { incr damage }
    incr changes

    # If diff will deal with it...
    if {$b1 == "0" && $b2 == "0"} {
	set i [catch "exec diff -n $CTMcopy/$n1 $CTMref/$n2 > $CTMscratch" j]
	set s [file size $CTMscratch]
	if {$s < $s2} {
	    puts stderr "E $b1$b2 $t1$t2 $n1"
	    puts $fo_files "CTMFN $n1 $u2 $g2 $m2 $h1 $h2 $s"
	    flush $fo_files
	    exec cat $CTMscratch >@@ $fo_files
	    puts $fo_files ""
	    return
	}
    } 
    puts stderr "R $b1$b2 $t1$t2 $n1"
    puts $fo_files "CTMFS $n2 $u2 $g2 $m2 $h1 $h2 $s2"
    flush $fo_files
    exec cat $CTMref/$n2 >@@ $fo_files
    puts $fo_files ""
}

#############################################################################
d24 2
a25 1
set CTMdont {^///}
d41 1
a41 1
set max_damage 1200
a45 1
exec sh -c "date -u '+%y%m%d%H%M%S $argv'" >> /home/ctm/log
d47 1
d67 1
a67 1
	exit 0
d85 1
a85 1
	    exit 0
d93 1
a93 1
	    exit 0
a104 6
    if {"$CTMcopy" == "" } { 
	set f1 [open /dev/null]
    } else {
	set f1 [open "| ./ctm_scan $CTMcopy $CTMscan"]
    }

d109 1
a109 38
    set f2 [open "| ./ctm_scan $CTMref $CTMscan"]

    set fo_del   [open $CTMtmp.del w]
    set fo_rmdir [open $CTMtmp.rmdir w]
    set fo_mkdir [open $CTMtmp.mkdir w]
    set fo_files [open $CTMtmp.files w]

    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 {[regexp $CTMdont /$n1]} { set l1 "" ; continue }
	if {[regexp $CTMdont /$n2]} { set l2 "" ; continue }

	# they're all the same...
	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 the name is the same we're safe...
	if {$n1 == $n2}  { 
	    eval CTMchg $l1 $l2
	    set l1 ""
	    set l2 "" 
	    continue 
	}
d111 11
a121 40
	# To avoid this anomaly:
	# A -  d  src/gnu/lib/libreadline/readline/Attic
	# A 0  f  src/gnu/lib/libreadline/readline/Attic/readline.h,v
	# A 0  f  src/gnu/lib/libreadline/readline.c,v
	# D 0  f  src/gnu/lib/libreadline/readline/readline.h,v
	# D 0  f  src/gnu/lib/libreadline/readline.c,v
	# we have to make things somewhat complicated...

	# if they have the same number of components...
	set ll1 [llength [split $n1 /]]
	set ll2 [llength [split $n2 /]]
	if {$ll1 == $ll2} {
	    if {$n1 < $n2 } { 
		eval CTMdel $l1 ; set l1 "" ; continue 
	    } else {
		eval CTMadd $l2 ; set l2 "" ; continue 
	    }
	} 
	if {$ll1 < $ll2} {
		eval CTMadd $l2 ; set l2 "" ; continue 
	} else {
		eval CTMdel $l1 ; set l1 "" ; continue 
	}
    }

    close $fo_del
    close $fo_rmdir
    close $fo_mkdir
    close $fo_files

    if {$damage > $max_damage} {
	puts "Too much damage: $damage deletes"
		exec sh -c "rm -f ${CTMtmp}.*"
		exec rm -f $CTMlock
	exit 0
    }

    if {!$changes} {
	puts "no changes"
	exec sh -c "rm -f ${CTMtmp}.*"
d123 1
a123 1
	exit 0
d125 2
a126 16

    exec echo CTM_BEGIN 2.0 $CTMname $CTMnbr $CTMdate $CTMprefix > $CTMtmp.begin

    puts "Assembling delta"
    flush stdout
    set  nm [format "%s.%04d%s" $CTMname $CTMnbr $CTMsuff]

    set fdout [open "| /sbin/md5 -p | gzip -9 > ${CTMtmp}:${nm}.gz" w]

    foreach i {begin del rmdir mkdir files} {
	exec cat $CTMtmp.$i >@@$fdout
    }
    puts $fdout "CTM_END " nonewline
    close $fdout ; unset fdout

    exec sh -c "rm -f ${CTMtmp}.*" >&@@ stdout
d137 1
a137 1
	    exec sh -e -c "cd $CTMcopy ; $CTMSW/ctm -v -v -v ${CTMtmp}:${nm}.gz" >&@@ stdout
d145 2
@


1.16.2.1
log
@YAMFC
@
text
@d4 100
d124 1
a124 2
set CTMignore {^///}
set CTMbogus {\.core$}
d140 1
a140 1
set max_damage 100
d145 1
a146 1
exec sh -c "date -u '+%y%m%d%H%M%S $argv'" >> ${CTMSW}/log
d166 1
a166 1
	exit 1
d184 1
a184 1
	    exit 1
d192 1
a192 1
	    exit 1
d204 6
d214 63
a276 1
    set  nm [format "%s.%04d%s" $CTMname $CTMnbr $CTMsuff]
d278 8
a285 10
    set x1 $CTMcopy
    if {$x1 == ""} {
	exec mkdir ${CTMtmp}.dir
	set x1 ${CTMtmp}.dir
    }
    set r1 [catch "exec ${CTMSW}/mkctm -I ${CTMignore} -B ${CTMbogus} -l ${CTMtmp}.log -D $max_damage $CTMname $CTMnbr $CTMdate . $x1 $CTMref | md5 -p | gzip -9 > ${CTMtmp}:${nm}.gz 2>@@ stderr" r2]

    if {$r1} {
	if {[lindex $errorCode 2] == 4} {
		puts "No changes, stopping."
d287 6
a292 5
		exit 0
	}
	puts "problems, stopping now."
        puts "errorCode $errorCode"
	puts "$r2"
d294 13
a306 1
	exit 1
d308 4
a311 2
	
    puts "mkctm done"
d322 1
a322 1
	    exec sh -e -c "cd $CTMcopy ; $CTMSW/ctm -v -v -v ${CTMtmp}:${nm}.gz" >& ${CTMtmp}.apply
a329 2

    exec sh -c "rm -rf ${CTMtmp}.*" >&@@ stdout
@


1.15
log
@- resync with configs running on freefall
- add ctm_conf.gnats from freefall
- add support for doing both the immediate mailout and the queued mailout.
- use "sendmail -odq -t" rather than "sendamil -t" to make it queue to
  the mailqueue rather than immediately begin transmission. This allows
  us to take advantage of our ordered dequeueing system without blowing
  WC's T1 to hell with a 50 part mailout in parallel.
- bump the max ctm size from 3MB to 10MB....  This is mainly for the fast
  list.
@
text
@d339 3
@


1.14
log
@Update to current reality.
mkctm.c can replace the guts of mkCTM if anybody feels like it...
@
text
@d126 4
d334 6
a339 1
	exec $CTMSW/ctm_smail -m 100000 -c 3000000 $CTMdest/${nm}.gz $CTMmail >&@@ stdout
d354 2
@


1.13
log
@The latest round of bugfixes here...
@
text
@d1 1
a1 1
#!/usr/local/bin/tcl
d141 1
d156 1
a156 1
set CTMlock Lck.${CTMname}.${CTMdate}.[id process]
d281 2
a282 2
	exec sh -c "rm -f ${CTMtmp}.*"
        exec rm -f $CTMlock
d307 1
a307 1
    exec sh -x -c "rm -f ${CTMtmp}.*" >&@@ stdout
d318 1
a318 1
	    exec sh -e -x -c "cd $CTMcopy ; $CTMSW/ctm -v -v -v ${CTMtmp}:${nm}.gz" >&@@ stdout
@


1.12
log
@Added lock-files, so we should know if the machine panic'ed in the middle
of an "apply".
@
text
@d33 1
a33 1
    global fo_del fo_rmdir changes damage max_damage
d40 2
a41 2
	puts "Too much damage"
	exit 0
d134 3
a136 1
set max_damage 100
d158 1
a158 1
if {[catch "ln $CTMlock LCK.$CTMname" a]} {
d161 1
d170 5
a174 1
	set CTMnbr [lindex [exec cat $CTMcopy/.ctm_status] 1]
d176 1
a176 1
	if {![find_delta $CTMnbr]} {
d202 1
a202 1
	set f1 [open "| ./ctm_scan $CTMcopy"]
d209 1
a209 1
    set f2 [open "| ./ctm_scan $CTMref"]
d337 1
a337 1
    if {$CTMnbr % 100} break
d346 1
@


1.11
log
@Latest updates to this.
@
text
@d151 12
d171 2
a172 1
	    # exit 0
d179 1
d274 1
d281 1
d303 1
d309 1
d311 1
d317 1
d324 1
d341 1
@


1.10
log
@Be more exclusive about cvs-locks.
@
text
@d133 1
d154 1
a154 1
    if { "$CTMcopy" != "" } {
a173 1
	set f1 [open "| ./ctm_scan $CTMcopy"]
d176 3
d180 2
d184 1
a184 1
    puts "Doing CTMname $CTMname CTMnbr $CTMnbr CTMdate $CTMdate"
d275 1
a275 2
    set fdmd5 [open "|/sbin/md5 >> $CTMtmp.end" w]
    set fdout [open "| gzip -9 > ${CTMtmp}:${nm}.gz" w]
a277 1
	exec cat $CTMtmp.$i >@@$fdmd5
a279 2
    puts $fdmd5 "CTM_END " nonewline
    close $fdmd5 ; unset fdmd5
a280 2
    flush $fdout
    exec cat $CTMtmp.end >@@$fdout
d302 1
a302 1
	exec $CTMSW/ctm_smail -m 50000 -c 3000000 $CTMdest/${nm}.gz $CTMmail >&@@ stdout
d317 1
@


1.9
log
@The new and improved mkCTM.  Learning from this experience it has been
improved on a couple of accounts.  Amongst these are "damage control"
more than 100 files removed and it will bail out...
@
text
@d303 1
a303 1
	exec $CTMSW/ctm_smail -m 50000 -c 300000 $CTMdest/${nm}.gz $CTMmail >&@@ stdout
@


1.8
log
@Some recent small changes.  Probably about time I start writing this in C.
@
text
@d1 1
a1 1
#!/usr/local/bin/tclsh
d3 3
a5 54
set CTMignoreCVS 0
set CTMapply 1
set CTMdont {^///}
set CTMmail {}
set CTMsuff {}

source $argv

cd /u1/CTM/SW

set tmp $CTMtmp
set dd  $CTMdest
set d1  $CTMcopy
set d2  $CTMref
set foo $CTMdate
set foo $CTMprefix
set foo $CTMname

if { "$d1" != "" } {
    ####
    # 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

    set fo [open $d2/.ctm_status w]
    puts $fo "$CTMname $CTMnbr"
    close $fo

    puts "Doing CTMname $CTMname CTMnbr $CTMnbr CTMdate $CTMdate"

    exec sh -x -c "rm -f ${tmp}.*" >&@@ stdout

    set f1 [open "| ./ctm_scan $d1"]
    # set this to minus one, to compensate for .ctm_status
    set changes -1
} else {
    set CTMnbr [lindex [exec cat $d2/.ctm_status] 1]
    puts "Doing CTMname $CTMname CTMnbr $CTMnbr CTMdate $CTMdate"
    exec sh -x -c "rm -f ${tmp}.*" >&@@ stdout
    set f1 [open /dev/null]
    set changes 0
}
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]

#####
d9 2
a10 1
    global fo_files fo_mkdir changes d2
d12 2
d16 8
a23 2
	incr changes
	return
a24 6
    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
d26 6
d33 2
a34 1
    global fo_del fo_rmdir changes
d36 7
d45 5
a49 2
	incr changes
	return
a50 3
    puts $fo_del "CTMFR $n $h"
    incr changes
    return
d52 6
d59 7
a65 5
    global fo_files d2 d1 changes
    if {$t1 == "d" && $t2 == "d"} {
	return
    }
    if {$t1 == "d" || $t2 == "d"} {
d70 5
a74 6
    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
d76 8
d85 2
a86 2
	set i [catch "exec diff -n $d1/$n1 $d2/$n2 > tmp" j]
	set s [file size tmp]
d91 1
a91 1
	    exec cat tmp >@@ $fo_files
a92 1
	    incr changes
d95 1
a95 1
    }
d99 1
a99 1
    exec cat $d2/$n2 >@@ $fo_files
a100 2
    incr changes
    return
a101 3
#####
set l1 ""
set l2 ""
d103 14
a116 1
while 1 {
d118 1
a118 1
    if {$l1 == ""} {gets $f1 l1}
d120 1
a120 3
    if {$l2 == ""} {gets $f2 l2}
    
    if {$l1 == "" && $l2 == ""} break
d122 12
a133 2
    set n1 [lindex $l1 1]
    set n2 [lindex $l2 1]
d135 2
a136 2
    #if {[regexp $CTMdont /$n1]} { set l1 "" ; continue }
    if {[regexp $CTMdont /$n2]} { set l2 "" ; continue }
d138 1
a138 2
    # they're all the same...
    if {$l1 == $l2}  { set l1 "" ; set l2 "" ; continue }
d140 9
a148 4
    if {$CTMignoreCVS } {
	if {[regexp {/CVS/} $l1]} {set l1 ""; continue }
	if {[regexp {/CVS/} $l2]} {set l2 ""; continue }
    }
d150 1
a150 1
    if {$l1 == "" }   { eval CTMadd $l2 ; set l2 "" ; continue }
d152 3
a154 1
    if {$l2 == "" }   { eval CTMdel $l1 ; set l1 "" ; continue }
d156 4
a159 2
    # if the name is the same we're safe...
    if {$n1 == $n2}  { eval CTMchg $l1 $l2 ; set l1 "" ; set l2 "" ; continue }
d161 1
a161 7
    # To avoid this anomaly:
    # A -  d  src/gnu/lib/libreadline/readline/Attic
    # A 0  f  src/gnu/lib/libreadline/readline/Attic/readline.h,v
    # A 0  f  src/gnu/lib/libreadline/readline.c,v
    # D 0  f  src/gnu/lib/libreadline/readline/readline.h,v
    # D 0  f  src/gnu/lib/libreadline/readline.c,v
    # we have to make things somewhat complicated...
d163 3
a165 8
    # if they have the same number of components...
    set ll1 [llength [split $n1 /]]
    set ll2 [llength [split $n2 /]]
    if {$ll1 == $ll2} {
	if {$n1 < $n2 } { 
	    eval CTMdel $l1 ; set l1 "" ; continue 
	} else {
	    eval CTMadd $l2 ; set l2 "" ; continue 
d167 7
a173 3
    } 
    if {$ll1 < $ll2} {
	    eval CTMadd $l2 ; set l2 "" ; continue 
d175 2
a176 1
	    eval CTMdel $l1 ; set l1 "" ; continue 
d179 10
a188 1
    
d190 56
a245 1
}
d247 10
a256 4
close $fo_del
close $fo_rmdir
close $fo_mkdir
close $fo_files
d258 5
a262 4
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 | /sbin/md5]
exec echo "$m" >> $tmp.end
d264 1
a264 7
if {!$changes} {
    puts "no changes"
    exec sh -c "rm -f ${tmp}.*"
    exit 0
}
flush stdout
set  nm [format "%s.%04d%s" $CTMname $CTMnbr $CTMsuff]
d266 39
a304 2
exec cat $tmp.begin $tmp.del $tmp.rmdir $tmp.mkdir $tmp.files $tmp.end \
	| gzip -9 > ${tmp}:${nm}.gz 
d306 2
a307 1
exec sh -x -c "rm -f ${tmp}.*" >&@@ stdout
d309 2
a310 5
if {$CTMapply} {
	exec sh -e -x -c "cd $CTMcopy ; /u1/CTM/SW/ctm -v -v -v ${tmp}:${nm}.gz" >&@@ stdout
}
exec mv ${tmp}:${nm}.gz $dd/.tmp_${nm}.gz >&@@ stdout
exec mv $dd/.tmp_${nm}.gz $dd/${nm}.gz >&@@ stdout
d312 6
a317 2
if {$CTMmail != ""} {
    exec /u1/phk/ctm_smail/ctm_smail -m 50000 -c 300000 $dd/${nm}.gz $CTMmail >&@@ stdout
d319 1
@


1.7
log
@Update to current reality.
@
text
@d7 1
d21 27
a47 6
####
# 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
a48 11
set CTMnbr $i

set fo [open $d2/.ctm_status w]
puts $fo "$CTMname $CTMnbr"
close $fo

puts "Doing CTMname $CTMname CTMnbr $CTMnbr CTMdate $CTMdate"

exec sh -x -c "rm -f ${tmp}.*" >&@@ stdout

set f1 [open "| ./ctm_scan $d1"]
a54 2
# set this to minus one, to compensate for .ctm_status
set changes -1
a175 1
	    puts "<$ll1> < <$ll2>\n  <$l1>\n  <$l2>"
a177 1
	    puts "<$ll1> > <$ll2>\n  <$l1>\n  <$l2>"
d201 1
a201 1
set  nm [format "%s.%04d" $CTMname $CTMnbr]
@


1.6
log
@These patches fix some lesser problems:

1) malloc.h doesn't exits in 2.0.
2) Makefile.inc wasn't picked up so one of the build steps (install?)
failed.
3) LIBMD wasn't depended on.
4) "ctm foo" dumped core because "foo" doesn't have a '.' in it.

Bruce

I updated the mkCTM stuff while I was at it anyway.  /phk

Reviewed by:	phk
Submitted by:	bde
@
text
@d6 1
a19 11
exec sh -x -c "rm -f ${tmp}.*" >&@@ stdout

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

d29 4
d35 12
d133 1
d145 29
a173 1
    if {$n1 < $n2 }   { eval CTMdel $l1 ; set l1 "" ; continue }
a174 1
    if {$n1 > $n2 }   { eval CTMadd $l2 ; set l2 "" ; continue }
a175 1
    if {$n1 == $n2}  { eval CTMchg $l1 $l2 ; set l1 "" ; set l2 "" ; continue }
d206 4
@


1.5
log
@A couple of nit-picks.
@
text
@d5 1
d9 2
d124 3
d161 1
a161 1
set  nm [format "%s/%s.%04d" $dd $CTMname $CTMnbr]
d164 1
a164 1
	| gzip -9 > ${nm}.gz 
d169 1
a169 1
	exec sh -e -x -c "cd $CTMcopy ; /root/CTM/ctm -v -v -v ${nm}.gz" >&@@ stdout
d171 2
@


1.4
log
@Various cleanup and fixes.
@
text
@d16 1
a16 1
exec rm -f $tmp.*
a85 1
	puts stderr "E $b1$b2 $t1$t2 $n1"
d89 1
d151 1
a151 1
    exec sh -c "rm -f $tmp.*"
d154 7
a161 3
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 
exec sh -c "rm -f $tmp.*"
@


1.3
log
@The next batch of refinements.  Now it no longer needs to call on ed(1) to
fix our files, it has a builtin "diff -n" editor.
@
text
@d87 1
a87 1
	set i [catch "exec diff -e $d1/$n1 $d2/$n2 > tmp" j]
d90 1
a90 1
	    puts $fo_files "CTMFE $n1 $u2 $g2 $m2 $h1 $h2 $s"
@


1.2
log
@A bunch of improvements.  Still far to go.
@
text
@d85 1
a85 1
    if {$b1 == "0" || $b2 == "0"} {
@


1.1
log
@Initial revision
@
text
@d3 3
d85 12
a96 8
    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
d98 2
a99 4
    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"
d101 1
a101 1
    exec cat tmp >@@ $fo_files
d104 1
d123 5
d146 1
a146 1
set m [exec cat $tmp.begin $tmp.del $tmp.rmdir $tmp.mkdir $tmp.files $tmp.end | md5]
d156 1
a156 1
exec cat $tmp.begin $tmp.del $tmp.rmdir $tmp.mkdir $tmp.files $tmp.end | gzip -9 -v > ${nm}.gz 2>@@ stdout
d158 3
a160 1
exec sh -e -x -c "cd $CTMcopy ; /root/CTM/ctm -v -v -v ${nm}.gz" >&@@ stdout
@


1.1.1.1
log
@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

@
text
@@
