From 2ab4fdc460bbc8570ce83f4cb11075b372f126df Mon Sep 17 00:00:00 2001 From: Eitan Adler Date: Thu, 13 Sep 2012 17:49:11 +0000 Subject: [PATCH] Remove scripts and tools which only functioned when src was using CVS Approved by: cperciva MFC after: 1 week --- tools/diag/README | 2 - tools/diag/ac/README | 9 - tools/diag/ac/cknames.pl | 107 ----- tools/diag/ac/ent.sh | 58 --- tools/tools/README | 4 - tools/tools/backout_commit/backout_commit.rb | 350 --------------- tools/tools/mfc/Makefile | 10 - tools/tools/mfc/README | 19 - tools/tools/mfc/mfc.awk | 33 -- tools/tools/mfc/mfc.pl | 450 ------------------- tools/tools/mfc/mfc.sh | 38 -- 11 files changed, 1080 deletions(-) delete mode 100644 tools/diag/ac/README delete mode 100644 tools/diag/ac/cknames.pl delete mode 100644 tools/diag/ac/ent.sh delete mode 100644 tools/tools/backout_commit/backout_commit.rb delete mode 100644 tools/tools/mfc/Makefile delete mode 100644 tools/tools/mfc/README delete mode 100644 tools/tools/mfc/mfc.awk delete mode 100644 tools/tools/mfc/mfc.pl delete mode 100644 tools/tools/mfc/mfc.sh diff --git a/tools/diag/README b/tools/diag/README index 814794367921..30438a20ccab 100644 --- a/tools/diag/README +++ b/tools/diag/README @@ -8,8 +8,6 @@ the integrity. Please make a subdir per program, and add a brief description to this file. -ac Various scripts that checks of style/content correctness of - committers lists in doc/ area. dumpvfscache program that can be used to examine the contents of the vfs name cache. httpd-error check for Web files which does not exists on your host diff --git a/tools/diag/ac/README b/tools/diag/ac/README deleted file mode 100644 index 48c1cad0db79..000000000000 --- a/tools/diag/ac/README +++ /dev/null @@ -1,9 +0,0 @@ -Various scripts that checks of style/content correctness of -committers lists in doc/ area. - -ac check if the contributors article is in sync with the - committers list -ent.sh check for ordering/content problems in .ent files (authors.ent, - teams.ent, etc) - -$FreeBSD$ diff --git a/tools/diag/ac/cknames.pl b/tools/diag/ac/cknames.pl deleted file mode 100644 index a3ffe3192f3c..000000000000 --- a/tools/diag/ac/cknames.pl +++ /dev/null @@ -1,107 +0,0 @@ -#!/usr/bin/perl -w -# -# Copyright (c) 2002,2003 Alexey Zelkin -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE -# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -# SUCH DAMAGE. -# -# cknames.pl -- this scripts checks for integrity of person lists -# between authors.ent, CVSROOT/access and passwd database -# at freefall.freebsd.org -# -# NOTE: This script is supposed to run at freefall.freebsd.org *only* -# -# $FreeBSD$ -# - -$debug = 0; -$accessfile = "CVSROOT/access"; -$authorsfile = "doc/en_US.ISO8859-1/share/sgml/authors.ent"; - -@cvsroots = qw( - /home/ncvs - /home/pcvs - /home/dcvs -); - -$doccvsroot = "/home/dcvs"; -$cvs_pfx = "cvs -Q -R -d "; -$cvs_sfx = " co -p"; - -open(PASSWD, 'ypcat passwd |') || die "open passwd data: $!\n"; -while () { - ($login,undef) = split(/:/); - $login =~ s/_//g; # remove _ from usernames since this - # character is not allowed in docbook entities - print "passwd user: $login\n" if $debug; - $users{$login} = 1; -} -close PASSWD; - -foreach (@cvsroots) { - print "$cvs_pfx $_ $cvs_sfx $accessfile\n" if $debug; - open (ACCESS, "$cvs_pfx $_ $cvs_sfx $accessfile |") || - die "checkout $accessfile: $!\n"; - while () { - chomp; - next if /^#/; - ($accuser, undef) = split /\s/; - $accuser =~ s/_//g; - print "access user: $accuser\n" if $debug; - $access{$accuser} = 1; - } - close ACCESS; -} - -open (AUTHORS, "$cvs_pfx $doccvsroot $cvs_sfx $authorsfile |") || - die "checkout $authorsfile: $!\n"; -while () { - $author = $1 if /ENTITY a\.([^ ]+)/; - next if !$author; - print "authors entity: $author\n" if $debug; - $authors{$author} = 1; - $author = ""; -} -close AUTHORS; - -print "\n"; -print "People listed in CVSROOT/access, but have no account\n"; -print "----------------------------------------------------\n"; -foreach (keys %access) { - print "$_\n" if (!defined $users{$_}); -} - -print "\n"; -print "People listed in autors.ent, not have no account\n"; -print "------------------------------------------------\n"; -foreach (keys %authors) { - print "$_\n" if (!defined $users{$_}); -} - -print "\n"; -print "People listed in CVSROOT/access, but not listed in authors.ent\n"; -print "--------------------------------------------------------------\n"; -foreach (keys %access) { - print "$_\n" if (!defined $authors{$_}); -} - -print "\n"; diff --git a/tools/diag/ac/ent.sh b/tools/diag/ac/ent.sh deleted file mode 100644 index fbc2219dd4de..000000000000 --- a/tools/diag/ac/ent.sh +++ /dev/null @@ -1,58 +0,0 @@ -#!/bin/sh -x -# Copyright (c) 2002,2003 Alexey Zelkin -# -# ent.sh -- this script checks {authors,teams}.ent files for correctness -# -# $FreeBSD$ - -: ${CVSROOT=/home/dcvs} -prefix=doc/en_US.ISO8859-1/share/sgml -cvs='cvs -Q -R co -p' -diff='diff -u' -tmp=${TMPDIR-/tmp}/_entities - -ckfile() { - -ckf=$1 - -$cvs $prefix/$ckf 2>/dev/null | - grep ENTITY | - awk '{ print $2 }' > $tmp.entsrc -sort -u $tmp.entsrc > $tmp.entsrc2 -$diff $tmp.entsrc $tmp.entsrc2 > $ckf.order - -$cvs $prefix/$ckf 2>/dev/null | - perl -ne 'print "$1 -- $2\n" if /ENTITY ([^ ]+).*(.*)<\/email>/' | - grep -vi freebsd.org > $ckf.addr - -} - -ckresults() { - -ckf=$1 - -if [ -s $ckf.order ]; then - echo "Ordering check for $ckf failed. See $ckf.ordering file for details." -else - rm -f $ckf.order - echo "Ordering check for $ckf is Ok. " -fi - -if [ -s $ckf.addr ]; then - echo "Email addresses for $ckf failed. See $ckf.addr file for details." -else - rm -f $ckf.addr - echo "Email addresses check for $ckf is Ok. " -fi - -} - -ckfile "authors.ent" -ckfile "teams.ent" - -echo - -ckresults "authors.ent" -ckresults "teams.ent" - -rm -f $tmp.entsrc $tmp.entsrc2 diff --git a/tools/tools/README b/tools/tools/README index 9c3db2fc5364..1260683cbba4 100644 --- a/tools/tools/README +++ b/tools/tools/README @@ -10,8 +10,6 @@ file. ansify Convert K&R-style function definitions to ANSI style ath Tools specific to the Atheros 802.11 support -backout_commit A tool for reading in a commit message and generating - a script that will backout the commit. cfi Common Flash Interface (CFI) tool commitsdb A tool for reconstructing commit history using md5 checksums of the commit logs. @@ -45,8 +43,6 @@ kerninclude Shellscript to find unused #includes in the kernel. kernxref Shellscript to cross reference symbols in the LINT kernel. kttcp An in-kernel version of the ttcp network performance tool mctest A multicast test program -mfc Merge a directory from HEAD to a branch where it does not - already exist and other MFC related script(s). mid Create a Message-ID database for mailing lists. mwl Tools specific to the Marvell 88W8363 support ncpus Count the number of processors diff --git a/tools/tools/backout_commit/backout_commit.rb b/tools/tools/backout_commit/backout_commit.rb deleted file mode 100644 index 264c271b60bf..000000000000 --- a/tools/tools/backout_commit/backout_commit.rb +++ /dev/null @@ -1,350 +0,0 @@ -#!/usr/bin/env ruby -w - -# $FreeBSD$ - -# Please note, that this utility must be kept in sync with -# CVSROOT/log_accum.pl. If someone has a different output from their -# mail client when saving e-mails as text files, feel free to hack it -# in as an option. -# -# If someone would like to hack in the ability to generate diffs based -# off of this script, by all means, be my guest. - -require 'getoptlong' - -$basedir = '/usr' -$backout_script = "backout-#{Time.now.strftime("%Y-%m-%d-%H-%M")}.sh" -$commit_authors = [] -$commit_dates = [] -$commit_file = nil -$commit_message = nil -$cvsbin = nil -$cvs_path = '/usr/bin/cvs' -$cvsrc_ignore = true -$debug = 0 -$echo_path = '/usr/bin/echo' -$echo_warnings = true -$force_script_edit = false -$force_remove = false -$output = $stdout -$quiet_script = false -$shell_path = '/bin/sh' -$shell_args = '--' - -def debug(level, *msgs) - if level <= $debug - if $debug > 1 - $output.puts "DEBUG(#{level}): #{msgs.shift}" - else - $output.puts msgs.shift - end - - for msg in msgs - $output.puts "\t #{msg}" - end - end -end # def debug() - - -def usage(msg, info = nil) - out = (msg.nil? ? $stdout : $stderr) - out.puts "#{File.basename($0)} usage:" << (msg.nil? ? '' : " #{msg}") - out.puts "#{info}" unless info.nil? - out.puts "" - out.puts " -s, --backout-script= Specifies the filename of the script" - out.puts " -D, --basedir= Specifies the base directory [/usr]" - out.puts " -a, --commit-author= Forces a commit author" - out.puts " -d, --commit-date= Forces a commit date" - out.puts " -m, --commit-file= Specifies a commit message file" - out.puts " -M, --commit-message= Specifies a commit message" - out.puts " -c, --cvs-path= Specifies the CVS binary to be used [cvs]" - out.puts " -C, --cvsrc-ignore= If true, will ignore options in ~/.cvsrc" - out.puts " -e, --echo-path= Specifies the path to echo" - out.puts " -f, --force-remove= If true, removes new files [false]" - out.puts " -F, --force-edit= If true, add -C to the shell arguments in" - out.puts " the backout script if the shell is sh," - out.puts " which forces an edit of the script" - out.puts " -O, --output= Specifies what fd to direct the output to" - out.puts " -A, --shell-args= Specifies the shell arguments to be used" - out.puts " -S, --shell-path= Specifies the shell to be used [/bin/sh]" - out.puts " -W, --warnings= Turns on or off warnings [true]" - exit(msg.nil? ? 0 : 1) -end - - -OPTION_LIST = [ - ['--backout-script','-s', GetoptLong::REQUIRED_ARGUMENT], - ['--basedir','-D', GetoptLong::REQUIRED_ARGUMENT], - ['--commit-author','-a', GetoptLong::REQUIRED_ARGUMENT], - ['--commit-date','-d', GetoptLong::REQUIRED_ARGUMENT], - ['--commit-file','-m', GetoptLong::REQUIRED_ARGUMENT], - ['--commit-message','-M', GetoptLong::REQUIRED_ARGUMENT], - ['--cvs-path','-c',GetoptLong::REQUIRED_ARGUMENT], - ['--cvsrc-ignore','-C',GetoptLong::REQUIRED_ARGUMENT], - ['--echo-path','-e',GetoptLong::REQUIRED_ARGUMENT], - ['--force-edit','-F',GetoptLong::REQUIRED_ARGUMENT], - ['--force-remove','-f',GetoptLong::REQUIRED_ARGUMENT], - ['--output', '-O', GetoptLong::REQUIRED_ARGUMENT], - ['--quiet-script','-q',GetoptLong::REQUIRED_ARGUMENT], - ['--shell-args','-A',GetoptLong::REQUIRED_ARGUMENT], - ['--shell-path','-S',GetoptLong::REQUIRED_ARGUMENT], - ['--warnings','-w', GetoptLong::REQUIRED_ARGUMENT], -] - -opt_parser = GetoptLong.new(*OPTION_LIST) -opt_parser.quiet = true - -begin - opt_parser.each do |opt,arg| - case opt - when '--backout-script' - debug(3, "backout script was #{$backout_script.inspect} : is #{arg.inspect}") - $backout_script = arg - when '--basedir' - debug(3, "base directory was #{$basedir.inspect} : is #{arg.inspect}") - $basedir = arg - when '--commit-author' - debug(3, "commit author #{arg.inspect} added to list") - $commit_authors.push(arg.dup) - when '--commit-date' - debug(3, "commit date #{arg.inspect} added to list") - $commit_date.push(arg.dup) - when '--commit-file' - debug(3, "commit file was #{$commit_file.inspect} : is #{arg.inspect}") - $commit_file = arg - when '--commit-message' - debug(3, "commit message was #{$commit_message.inspect} : is #{arg.inspect}") - $commit_message = arg - when '--cvs-path' - debug(3, "cvs path was #{$cvs_path.inspect} : is #{arg.inspect}") - $cvs_path = arg - when '--cvsrc-ignore' - if arg =~ /true|yes/i - $cvsrc_ignore = true - elsif arg =~ /false|no/i - $cvsrc_ignore = false - else - usage("#{opt}: unknown bool format \"#{arg}\"", "Valid options are \"true\", \"false\", \"yes\", or \"no\"") - end - debug(3, "ignoring of ~/.cvsrc is set to #{$cvsrc_ignore.inspect}") - when '--echo-path' - debug(3, "echo path was #{$echo_path.inspect} : is #{arg.inspect}") - $echo_path = arg - when '--force-edit' - if arg =~ /true|yes/i - $force_script_edit = true - elsif arg =~ /false|no/i - $force_script_edit = false - else - usage("#{opt}: unknown bool format \"#{arg}\"", "Valid options are \"true\", \"false\", \"yes\", or \"no\"") - end - debug(3, "force edit of backout script is set to #{$force_script_edit.inspect}") - when '--force-remove' - if arg =~ /true|yes/i - $force_remove = true - elsif arg =~ /false|no/i - $force_remove = false - else - usage("#{opt}: unknown bool format \"#{arg}\"", "Valid options are \"true\", \"false\", \"yes\", or \"no\"") - end - debug(3, "force removal of files is set to #{$force_remove.inspect}") - when '--output' - case arg - when 'stdout' - $output = $stdout - when 'stderr' - $output = $stderr - else - usage("#{opt}: unknown output format","Valid outputs are \"stdout\" and \"stderr\"") - end - debug(3, "output set to #{arg}") - when '--quiet-script' - if arg =~ /true|yes/i - $quiet_script = true - elsif arg =~ /false|no/i - $quiet_script = false - else - usage("#{opt}: unknown bool format \"#{arg}\"", "Valid options are \"true\", \"false\", \"yes\", or \"no\"") - end - debug(3, "quiet script is set to #{$quiet_script.inspect}") - when '--shell-args' - debug(3, "shell args were #{$shell_args.inspect} : is #{arg.inspect}") - $shell_args = arg - when '--shell-path' - debug(3, "shell path was #{$shell_path.inspect} : is #{arg.inspect}") - $shell_path = arg - when '--warnings' - if arg =~ /true|yes/i - $echo_warnings = true - elsif arg =~ /false|no/i - $echo_warnings = false - else - usage("#{opt}: unknown bool format \"#{arg}\"", "Valid options are \"true\", \"false\", \"yes\", or \"no\"") - end - debug(3, "warnings are set to #{$echo_warnings.inspect}") - end - end -rescue GetoptLong::InvalidOption - usage("invalid argument") -rescue GetoptLong::MissingArgument - usage("missing argument") -rescue GetoptLong::NeedlessArgument => msg - usage("passed an extra argument: #{msg}") -end - -debug(3, "Verbosity set to: #{$debug}") - -$cvsbin = $cvs_path -$cvsbin << " -f" if $cvsrc_ignore - -if ARGV.length < 1 - usage("require a commit message to parse") -end - -$output.puts("Backout directory:\t#{$basedir}") -$output.puts("Backout script:\t\t#{$backout_script}") -$output.puts("") - -# Backout script - to be run by hand -File.open($backout_script, "w+") do |f| - removals = [] - updates = [] - files = [] - - f.puts("#!#{$shell_path}#{($force_script_edit && $shell_path == '/bin/sh') ? ' -C' : ''} #{$shell_args}") - f.puts() - f.puts("# Generated at: #{Time.now()}") - f.puts("# Generated by: #{ENV['USER']}\@#{ENV['HOST']}") - f.puts() - f.puts("BASEDIR=#{$basedir}") - f.puts('if [ $BASEDIR != $PWD ]; then') - f.puts(' echo "Please change to $BASEDIR before running this shell script"') - f.puts(' exit 1') - f.puts('fi') - f.puts() - - author_regexp = Regexp.new(/^([^\ ]+)\s+([\d]{4})\/([\d]{2})\/([\d]{2}) ([\d]{2}):([\d]{2}):([\d]{2}) ([A-Z]{3})$/) - file_regexp = Regexp.new(/^ ([\d\.]+)\s+\+([\d]+) \-([\d]+)\s+(.*?)$/) - newdead_regexp = Regexp.new(/^(.*?) \((new|dead)\)$/) - rev_regexp = Regexp.new(/^ Revision Changes Path$/) - - for email_file in ARGV - File.open(email_file) do |e| - $output.print("Scanning through #{email_file}...") - found_files = false - for line in e - line.chomp! - if found_files == false - amd = author_regexp.match(line) - if !amd.nil? - $commit_authors.push(amd[1].dup) - $commit_dates.push(Time.local(*amd[2..7]).dup) - elsif rev_regexp.match(line) - found_files = true - end - else # if found_files - md = file_regexp.match(line) - next if md.nil? - - filename = md[4] - ndmd = newdead_regexp.match(filename) - if !ndmd.nil? - filename = ndmd[1] - if ndmd[2] == 'new' - removals.push(filename) - f.puts("#{$force_remove ? '' : '# '}#{$echo_path} -n \"Removing #{filename}...\"") if !$quiet_script - f.puts("#{$force_remove ? '' : '# '}#{$cvsbin} rm -f #{filename}") - f.puts("#{$force_remove ? '' : '# '}#{$echo_path} \"done.\"") if !$quiet_script - f.puts() - files.push(filename) - next - end - end - f.puts("#{$echo_path} -n \"Updating #{filename} to #{md[1]}...\"") if !$quiet_script - f.puts("#{$cvsbin} up -p -r #{md[1]} #{filename} > #{filename}") - f.puts("#{$echo_path} \"done.\"") if !$quiet_script - f.puts() - files.push(filename) - end # if found_files - end # for line in.. - $output.puts("done.") - end # File.open() - end # for email_file in ARGV... - - if removals.length > 0 && $force_remove == false - f.puts("#{$echo_warnings ? '' : '# '}#{$echo_path} \"You may want to remove the following file#{removals.length > 1 ? 's' : ''}:\"") - for filename in removals - f.puts("#{$echo_warnings ? '' : '# '}#{$echo_path} \"\t#{filename}\"") - end - f.puts() - f.puts("#{$echo_warnings ? '' : '# '}#{$echo_path} \"There is code in #{$backout_script} to remove #{removals.length > 1 ? 'these files' : 'this file'} for you,\"") - f.puts("#{$echo_warnings ? '' : '# '}#{$echo_path} \"just uncomment them or pass the option --force-remove=true to #{$0}.\"") - end - - f.puts() - f.puts("# # # Uncomment the following line to commit the backout.") - f.puts("# # #{$echo_path} -n \"Committing backout...\"") if !$quiet_script - if !$commit_message.nil? - if $commit_message.empty? or $commit_message =~ /^default|no|yes|true|false/i - $commit_message = "Backout of commit by #{$commit_authors.join(', ')} done on #{$commit_dates.join(', ')} because\n[___FILL_IN_THE_BLANK___]\n" - end - - f.puts() - f.puts("# # # EDIT COMMIT MESSAGE HERE") - f.puts("CVSCOMMITMSG=< diff --git a/tools/tools/mfc/README b/tools/tools/mfc/README deleted file mode 100644 index 1396ae747982..000000000000 --- a/tools/tools/mfc/README +++ /dev/null @@ -1,19 +0,0 @@ -$FreeBSD$ - -Summarize scripts abilities and purposes. - -- mfc.awk: added by jmg - -Takes in a commit message and generates the proper (hopefully) update -j lines -and commit line to do the MFC. - -- mfc.sh: added by des - -A simple shell script to help MFC an entire directory to a branch where it -does not already exist. - -- mfc.pl: added by flz - -A perl script that takes a message-id, a commit mail or a query string and -generates a patchset along with a commit message and a commit script if the -user has commit rights. diff --git a/tools/tools/mfc/mfc.awk b/tools/tools/mfc/mfc.awk deleted file mode 100644 index 0aa98b5fe9e1..000000000000 --- a/tools/tools/mfc/mfc.awk +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/awk -f -# -# $FreeBSD$ -# - -BEGIN { - CVSROOT="ncvs:/home/ncvs" - UPDATEOPTS="-kk" -} - -/^>/ { - sub(">[ ]*", "") -} - -/^Revision/ || $1 == "" { - next -} - -{ - if (sub("1.", "") != 1) - next - if (!(match($2, "\\+[0-9]") && match($3, "-[0-9]"))) - next - printf("cvs -d %s update %s -j 1.%d -j 1.%d %s\n", CVSROOT, UPDATEOPTS, $1 - 1, $1, $4) - files[$4] = 1 -} - -END { - for (i in files) - fl = fl " " i - printf("cvs -d %s diff -kk %s | less\n", CVSROOT, fl); - printf("cvs -d %s commit %s\n", CVSROOT, fl); -} diff --git a/tools/tools/mfc/mfc.pl b/tools/tools/mfc/mfc.pl deleted file mode 100644 index 18138a825a54..000000000000 --- a/tools/tools/mfc/mfc.pl +++ /dev/null @@ -1,450 +0,0 @@ -#! /usr/bin/env perl -# -# mfc - perl script to generate patchsets from commit mail or message-id. -# -# Copyright (c) 2006 Florent Thoumie -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE -# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -# SUCH DAMAGE. -# -# $FreeBSD$ -# - -# This perl scripts only uses programs that are part of the base system. -# Since some people use NO_FOO options, here's the list of used programs : -# - cvs -# - fetch -# - perl (with getopt module) -# - mkdir, cat, chmod, grep (hopefully everybody has them) -# - cdiff or colordiff (optional) -# -# This script is using 3 environment variables : -# - MFCHOME: directory where patches, scripts and commit message will be stored. -# - MFCCVSROOT: alternative CVSROOT used to generate diffs for new/dead files. -# - MFCLOGIN: define this to your freefall login if you have commit rights. -# -# TODO: Look for XXX in the file. -# - -use strict; -use warnings; - -use Env; -use Env qw(MFCHOME MFCLOGIN MFCCVSROOT); -use Getopt::Std; -use IO::Handle; - -my $mfchome = $MFCHOME ? $MFCHOME : "/var/tmp/mfc"; -my $mfclogin = $MFCLOGIN ? $MFCLOGIN : ""; -my $cvsroot = $MFCCVSROOT ? $MFCCVSROOT : ':pserver:anoncvs@anoncvs.at.FreeBSD.org:/home/ncvs'; - -my $version = "1.1.0"; -my %opt; -my $commit_author; -my $commit_date; -my %mfc_files = ( ); -my %new_files = ( ); -my %dead_files = ( ); -my @msgids = ( ); -my @logmsg = ( ); -my @commitmail = ( ); -my $commiturl; -my @prs; -my @submitted_by; -my @reviewed_by; -my @obtained_from; -my $cdiff; -my $answer; -my $mfc_func = \&mfc_headers; - -sub init() -{ - # Enable autoflush of output to always show prompts. Without this, - # piping output will fail to display a prompt. - autoflush STDOUT 1; - - # Look for pre-requisites. - my @reqs = ( "fetch", "cvs", "mkdir", "cat", "chmod", "grep" ); - my $cmd; - foreach (@reqs) { - $cmd = `which $_`; - die "$_ is missing. Please check pre-requisites." if ($cmd =~ /^$/); - } - $cdiff = `which cdiff`; - $cdiff = `which colordiff` if ($cdiff =~ /^$/); - - # Parse command-line options. - my $opt_string = 'bf:hi:m:s:v'; - getopts( "$opt_string", \%opt ) or usage(); - usage() if !$opt{i} or $opt{h}; - @msgids = split / /, $opt{m} if (defined($opt{m})); -} - -sub usage() -{ - print STDERR << "EOF"; -$0 version $version - -Usage: $0 [-v] -h - $0 [-vb] -f file -i id - $0 [-vb] -m msg-id -i id - $0 [-vb] -s query -i id -Options: - -b : generate a backout patch - -f file : commit mail file to use ('-' for stdin) - -h : this (help) message - -i id : identifier used to save commit log message and patch - -m msg-id : message-id referring to the original commit (you can use more than one) - -s query : search commit mail archives (a filename with his revision is a good search) - -v : be a little more verbose -Examples: - $0 -m 200601081417.k08EH4EN027418 -i uscanner - $0 -s "param.h 1.41" -i move_acpi - $0 -f commit.txt -i id - $0 -m "200601081417.k08EH4EN027418 200601110806.k0B86m9C054798" -i consecutive - -Please report bugs to: Florent Thoumie -EOF - exit 1; -} - -sub previous_revision($) -{ - my ($rev) = @_; - my @rev; - - # XXX - I'm not sure this is working as it should. - return 0 if ($rev =~ /^1\.1$/); - @rev = split '\.', $rev; - return undef unless @rev; - if (($#rev % 2) != 1) { - pop @rev; - return join ".", @rev; - } - if ($rev[-1] == 1) { - pop @rev; - return &previous_revision(join ".", @rev); - } else { - $rev[-1]--; - return join ".", @rev; - } -} - -sub fetch_mail($) -{ - my $msgid = $_[0]; - my $url = ""; - - $msgid =~ s///; - $msgid =~ s/@.*//; - - $url = `fetch -q -o - 'http://www.freebsd.org/cgi/mid.cgi?id=$msgid'| grep getmsg.cgi | head -n 1`; - - if ($url =~ /^$/) { - print "No mail found for Message-Id <$msgid>.\n"; - exit 1; - } - $url =~ s/.*href="(.*)".*/$1/; - $url =~ s/\n$/\+raw/; - $url = "http://www.freebsd.org/cgi/$url"; - return $url; -} - -sub search_mail($) -{ - my $query = $_[0]; - - $query =~ s/\s+/+/g; - - # XXX - I guess we could take 5 first results instead of just the first - # but it has been working correctly for each search I've made so ... - my $result = `fetch -q -o - 'http://www.freebsd.org/cgi/search.cgi?words=$query&max=1&sort=score&index=recent&source=cvs-all' | grep getmsg.cgi`; - - $result =~ s/.*href="(.*)">.*/http:\/\/www.freebsd.org\/cgi\/$1+raw/; - if ($result =~ /^$/) { - print "No commit mail found for '$query'.\n"; - exit 1; - } - return $result; -} - -sub fetch_diff($) -{ - my $name = $_[0]; - my $old = $mfc_files{$name}{"from"}; - my $new = $mfc_files{$name}{"to"}; - - # CVSWeb uses rcsdiff instead of cvs rdiff, that's a problem for deleted and new files. - # Need to use cvs to generate reversed diff for backout commits. - if ($opt{b}) { - print " Generating reversed diff for $name using cvs diff...\n"; - system("cvs -d $cvsroot diff -u -j$new -j$old $name >> $mfchome/$opt{i}/patch 2>/dev/null"); - } elsif (exists($new_files{$name}) or exists($dead_files{$name})) { - print " Generating diff for $name using cvs rdiff...\n"; - system("cvs -d $cvsroot rdiff -u -r$old -r$new $name >> $mfchome/$opt{i}/patch 2>/dev/null"); - } else { - print " Fetching diff for $name from cvsweb.freebsd.org...\n"; - system("fetch -q -o - \"http://www.freebsd.org/cgi/cvsweb.cgi/$name.diff?r1=$old&r2=$new\" >> $mfchome/$opt{i}/patch"); - } -} - -sub mfc_headers($) -{ - if ($_[0] =~ /^$/) { - $mfc_func = \&mfc_author; - } elsif ($_[0] =~ /^(\w+)\s+(\S+\s\S+\s\S+)$/) { - # Skipped headers (probably a copy/paste from sobomax MFC reminder). - mfc_author($_[0]); - } else { - if ($_[0] =~ /^Message-Id:\s*(\S+)$/ and ($opt{v} or $opt{s})) { - print "Message-Id is $1.\n"; - } - } -} - -sub mfc_author($) -{ - if (!($_[0] =~ /^(\w+)\s+(\S+\s\S+\s\S+)$/)) { - die "Can't determine commit author and date."; - } - $commit_author = $1; - $commit_date = $2; - - print "Committed by $commit_author on $commit_date.\n"; - - $mfc_func = \&mfc_modified_files; -} - -sub mfc_modified_files($) -{ - if ($_[0] =~ /^\s+Log:/) { - $mfc_func = \&mfc_log; - } else { - # Nothing - } -} - -sub mfc_log($) -{ - if ($_[0] =~ /^\s*Revision\s+Changes\s+Path\s*$/) { - $mfc_func = \&mfc_revisions; - } else { - push(@logmsg, $_[0]); - } -} - -sub mfc_revisions($) -{ - my $name; - my $rev; - my $prev; - - return if ($_[0] =~ /^$/); - if (!($_[0] =~ /^\s+(\S+)\s+\S+\s+\S+\s+(\S+)/)) { - # Probably two consecutive cut/paste commit mails. - $mfc_func = \&mfc_headers; - mfc_headers($_[0]); - return; - } else { - $_[0] =~ /\s+(\S+)\s+\S+\s+\S+\s+(\S+)/; - $name = $2; - $rev = $1; - - $new_files{$name} = undef if ($_[0] =~ /\(new\)$/); - $dead_files{$name} = undef if ($_[0] =~ /\(dead\)$/); - - if (defined($mfc_files{$name}{"from"})) { - $prev = previous_revision($rev); - if ($mfc_files{$name}{"to"} =~ /^$prev$/) { - $mfc_files{$name}{"to"} = $rev; - } else { - die "Non-consecutive revisions found for $name."; - } - } else { - $mfc_files{$name}{"to"} = $rev; - $mfc_files{$name}{"from"} = previous_revision($rev); - } - } -} - -sub strip_log(@) { - my $tmp; - - while ($#logmsg >= 0 and ($logmsg[$#logmsg] =~ /^\s*$/ or $logmsg[$#logmsg] =~ /^\s\s\w+(\s\w+)*:\s+\w+(\s+\w+)*/)) { - $tmp = pop(@logmsg); - $tmp =~ s/^\s*//; - chomp($tmp); - if ($tmp =~ /^PR:\s+(.*)/) { - push(@prs, $1); - } - if ($tmp =~ /^Submitted by:\s+(.*)/) { - push(@submitted_by, $1); - } - if ($tmp =~ /^Reviewed by:\s+(.*)/) { - push(@reviewed_by, $1); - } - if ($tmp =~ /^Obtained from:\s+(.*)/) { - push(@obtained_from, $1); - } - } -} - -sub print_epilog { - my $tmp; - - if ($#prs >= 0) { - $tmp = join(", ", @prs); - chomp($tmp); - print MSG "PR:\t\t$tmp\n"; - } - if ($#submitted_by >= 0) { - $tmp = join(", ", @submitted_by); - chomp($tmp); - print MSG "Submitted by:\t$tmp\n"; - } - if ($#reviewed_by >= 0) { - $tmp = join(", ", @reviewed_by); - chomp($tmp); - print MSG "Reviewed by:\t$tmp\n"; - } - if ($#obtained_from >= 0) { - $tmp = join(", ", @obtained_from); - chomp($tmp); - print MSG "Obtained from:\t$tmp\n"; - } -} - -init(); - -if ($opt{s}) { - print "Searching commit mail on www.freebsd.org...\n"; - $commiturl = search_mail($opt{s}); - print "Fetching commit mail from www.freebsd.org...\n"; - @commitmail = `fetch -q -o - $commiturl`; - $mfc_func->($_) foreach (@commitmail); - strip_log(@logmsg); -} elsif ($opt{f}) { - open MAIL, $opt{f} || die "Can't open $opt{f} for reading."; - @commitmail = ; - close MAIL; - $mfc_func->($_) foreach (@commitmail); - strip_log(@logmsg); -} else { # $opt{m} - foreach (@msgids) { - print "Fetching commit mail from www.freebsd.org...\n"; - $commiturl = fetch_mail($_); - @commitmail = `fetch -q -o - $commiturl`; - $mfc_func->($_) foreach (@commitmail); - strip_log(@logmsg); - } -} - -die "Doesn't seem you gave me a real commit mail." if ($mfc_func == \&mfc_headers); -die "No file affected by commit?" if (scalar(keys(%mfc_files)) == 0); - -# Create directory and truncate patch file. -system("mkdir -p $mfchome/$opt{i}"); -system("cat /dev/null > $mfchome/$opt{i}/patch"); - -if ($opt{v} or $opt{s}) { - # Print files touched by commit(s). - print "Files touched by commit(s):\n"; - print " ", $_, ": rev ", $mfc_files{$_}{"from"}, " -> ", $mfc_files{$_}{"to"}, "\n" foreach (keys(%mfc_files)); -} - -if ($opt{s}) { - print "Is it the commit you were looking for ? [Yn] "; - $answer = ; - chomp($answer); - if ($answer =~ /^[Nn]$/) { - print "Sorry that I couldn't help you.\n"; - exit 0; - } -} - -# Generating patch. -print "Processing patch...\n"; -fetch_diff($_) foreach (keys(%mfc_files)); - -if ($mfclogin) { - # Create commit message from previous commit message. - print "Processing commit message...\n"; - # Chop empty lines Template lines like "Approved by: (might be dangerous)". - open MSG, "> $mfchome/$opt{i}/msg" || die "Can't open $mfchome/$opt{i}/msg for writing."; - if ($opt{b}) { - print MSG "Backout this commit:\n\n"; - } else { - print MSG "MFC:\n\n"; - } - - # Append merged file names and revisions to the commit message. - print MSG $_ foreach (@logmsg); - if (!$opt{b}) { - print MSG "\n"; - print MSG " ", $_, ": rev ", $mfc_files{$_}{"from"}, " -> ", $mfc_files{$_}{"to"}, "\n" foreach (keys(%mfc_files)); - } - - # Append useful info gathered from Submitted/Obtained/... lines. - print MSG "\n"; - print_epilog(); - close MSG; - - # Create commit script. - print "Processing commit script...\n"; - open SCRIPT, "> $mfchome/$opt{i}/script" || die "Can't open $mfchome/$opt{i}/script for writing."; - print SCRIPT "#! /bin/sh\n\n"; - print SCRIPT "# This script has been automatically generated by $0.\n\n"; - print SCRIPT "export CVSROOT=\"$mfclogin\@ncvs.freebsd.org:/home/ncvs\"\n\n"; - - if (scalar(keys(%new_files)) or scalar(keys(%dead_files))) { - if (scalar(keys(%new_files))) { - print SCRIPT "cvs add"; - print SCRIPT " \\\n $_" foreach (keys(%new_files)); - print SCRIPT "\n"; - } - if (scalar(keys(%dead_files))) { - print SCRIPT "cvs rm -f"; - print SCRIPT " \\\n $_" foreach (keys(%dead_files)); - print SCRIPT "\n"; - } - } - - print SCRIPT "cvs diff"; - print SCRIPT " \\\n $_" foreach (keys(%mfc_files)); - if ($cdiff =~ /^$/) { - print SCRIPT "\n"; - } else { - print SCRIPT " | $cdiff"; - } - - print SCRIPT "cvs ci"; - print SCRIPT " \\\n $_" foreach (keys(%mfc_files)); - print SCRIPT "\n"; - - close SCRIPT; - system("chmod a+x $mfchome/$opt{i}/script"); -} - -print "Done, output directory is $mfchome/$opt{i}/\n"; - -exit 0; diff --git a/tools/tools/mfc/mfc.sh b/tools/tools/mfc/mfc.sh deleted file mode 100644 index cf7d663e23da..000000000000 --- a/tools/tools/mfc/mfc.sh +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/sh -# -# Merge an entire directory from HEAD to a given branch -# -# $FreeBSD$ -# - -if [ $# -eq 1 -a -f CVS/Tag ] ; then - set -- "${1}" "$(sed -e 's/^T//' " 1>&2 - exit 1 -fi - -dir="${1}" -branch="${2}" - -set -e - -# Get sources from HEAD -/usr/bin/cvs -f -Q up -kk -Pd -A "${dir}" - -# Fake a cvs add... -find "${dir}" -type d -name CVS | -while read d ; do - echo "${d%/CVS}" - - # Fix up Entries so the files look newly added - sed -E -i'' -e \ - "s|^/([^/]+)/.*|/\1/0/Merged \1 from HEAD//T${branch}|" \ - "${d}/Entries" - - # Set directory tag - echo "T${branch}" >"$d/Tag" -done