From owner-ctm-announce Thu Nov 11 12: 6:19 1999 Delivered-To: ctm-announce@freebsd.org Received: from alcanet.com.au (border.alcanet.com.au [203.62.196.10]) by hub.freebsd.org (Postfix) with ESMTP id 0C76F14E4E for ; Thu, 11 Nov 1999 12:05:47 -0800 (PST) (envelope-from jeremyp@gsmx07.alcatel.com.au) Received: by border.alcanet.com.au id <40322>; Fri, 12 Nov 1999 06:59:37 +1100 Content-return: prohibited Date: Fri, 12 Nov 1999 07:05:32 +1100 From: Peter Jeremy Subject: Recovering from ports-cur and src-cur problems To: ctm-announce@FreeBSD.ORG Reply-To: peter.jeremy@alcatel.com.au Message-Id: <99Nov12.065937est.40322@border.alcanet.com.au> MIME-version: 1.0 X-Mailer: Mutt 1.0pre3i Content-type: multipart/mixed; boundary="9zSXsLTf0vkW971A" Sender: owner-ctm-announce@FreeBSD.ORG Precedence: bulk --9zSXsLTf0vkW971A Content-Type: text/plain; charset=us-ascii This mail is being posted with Chuck Robey's OK. This list is still intended to be low volume and discussions should off-list. I suspect this is somewhat later than Chuck would have liked, but attached is a perl script I knocked up a couple of months ago to let me delete sections from a CTM delta. With a bit of hacking, those of you who have applied the `wrong' version of the duplicated ports-cur or cvs-cur deltas should be able to recover fairly easily (assuming you still have a copy of the delta you applied, or at least a list of the files). In its current form, it's designed to turn chop bits out of a directory full of CTM deltas and leave the result as valid CTM deltas in a second directory. (This lets me keep a CVS subtree on a second system without having to build my own deltas). By changing the code that selects whether to keep the delta or not (the statement following the comment #XXXXXX), you could use it to chop the already applied bits out of your delta and get CTM to apply the rest. (My [untested] solution would be to build an array of files that were in the first delta and skip these when processing the second delta. The result will be a CTM file (without the .ctm_status file) which ctm should be able to apply). There's no documentation because this was never intended for public consumption. RTSL. (I will attempt to answer questions off-list). WARNING: The output files generated by this script look _identical_ to the original CTM deltas as far as ctm(8) is concerned. This script worked for me. No warranty etc etc. I accept no responsibility for bullet holes in your feet. Peter -- Peter Jeremy (VK2PJ) peter.jeremy@alcatel.com.au Alcatel Australia Limited 41 Mandible St Phone: +61 2 9690 5019 ALEXANDRIA NSW 2015 Fax: +61 2 9690 5982 --9zSXsLTf0vkW971A Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=ctm_shrink #!/usr/bin/perl -w # # Strip CTM archives down to the bits we have locally on vk2pj: # CVSROOT (without CVSROOT/commitlogs) and src use POSIX ":sys_wait_h"; ($#ARGV == 1) || die "Usage: $0 indir outdir\n"; ($indir, $outdir) = @ARGV; $SIG{PIPE} = 'IGNORE'; # Load and sort files from both input directories (opendir(DIR, $indir) && (@indir = readdir(DIR)) && closedir(DIR)) || die "$0: Failed to load $indir: $!\n"; -d $outdir || mkdir($outdir, 0777); (opendir(DIR, $outdir) && (@outdir = readdir(DIR)) && closedir(DIR)) || die "$0: Failed to load $outdir: $!\n"; @indir = sort(@indir); @outdir{@outdir} = (1) x @outdir; # Locate files in $indir that aren't in $outdir and process them foreach $file (@indir) { ($file =~ /^\./) && next; defined($outdir{$file}) || &convert($indir . '/' . $file, $outdir . '/' . $file); } # convert(infile, outfile) - Convert a CTM delta `infile' to a cutdown # version in `outfile'. Die if anything goes wrong. sub convert { local($infile, $outfile) = @_; local($pid, $_, $key, @args, $name, $len); warn "Creating $outfile\n"; # Arrange to write the output to $outfile open(STDOUT, '>' . $outfile) || die "$0: Failed to open $outfile: $!\n"; if ($infile =~ /\.gz/) { # Compressed input re/write via gzip # warn "Input compressed\n"; open(IN, 'gzcat ' . $infile . '|') || die "$0: Failed to open $infile: $!\n"; # warn "started gzcat on input\n"; open(STDOUT, '| gzip') || die "$0: Failed to fork gzip: $!\n"; # warn "started gzip on output\n"; } else { open(IN, $infile) || die "$0: Failed to open $infile: $!\n"; } # And insert md5 into the output open(STDOUT, '| /sbin/md5 -p') || die "$0: Failed to fork md5: $!\n"; # And another md5 to validate input (pipe(RD1, MD5_CHECK) && pipe(MD5_OUT, WR2)) || die "$0: Pipes failed: $!\n"; defined($pid = fork) || die "$0: fork() failed: $!\n"; if (!$pid) { # child open(STDOUT, '>&WR2') || die "$0: Failed to dup stdout: $!\n"; open(STDIN, '>&RD1') || die "$0: Failed to dup stdin: $!\n"; exec '/sbin/md5'; exit 1; } close(RD1); close(WR2); # All FDs ready: Read the CTM file from IN, copy it to MD5_CHECK # (excluding the trailing MD5 sum), chop off the bits we don't want # and forward to STDOUT (which is piped through various processes # to the output file) while () { /^CTM/ || die "$0: Phase error in $infile: $!"; ($key, $name, @args) = split; $len = 0; if ($key eq 'CTMFM') { $len = $args[4] + 1; } elsif ($key eq 'CTMFS' || $key eq 'CTMFN') { $len = $args[5] + 1; } elsif ($key eq 'CTM_BEGIN') { print(MD5_CHECK $_) || die "$0: md5 check error: $!"; print($_) || die "$0: md5 check error: $!"; next; } elsif ($key eq 'CTM_END') { print(MD5_CHECK 'CTM_END ') || die "$0: md5 check error: $!"; close(MD5_CHECK) || die "$0: md5 check error: $!"; defined($md5 = ) || die "$0: Error reading md5 sum: $!"; chop($md5); ($md5 eq $name) || die "$0: md5 mismatch: $md5 != $name\n"; print 'CTM_END '; last; } ($len > 0) && (read(IN, $_, $len, length($_)) || die "$0: read error: $!\n"); print(MD5_CHECK $_) || die "$0: md5 check error: $!"; #XXXXX Select what pieces to pass through here. ($name =~ m:^src/: || ($name =~ m:^CVSROOT/: && $name !~ m:^CVSROOT/commitlogs/:) || $name eq '.ctm_status') && (print($_) || die "$0: write error: $!"); } close(MD5_OUT) || die "$0: Failed to close md5 check: $!"; close(STDOUT) || die "$0: Failed to close output: $!"; close(IN) || die "$0: Failed to close input: $!"; # Dispose of zombies do { $kid = waitpid(-1,&WNOHANG); } until $kid == -1; } --9zSXsLTf0vkW971A-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe ctm-announce" in the body of the message