shithub: riscv

Download patch

ref: a59e61a6a4e11e0256da0d209afa38ccacd460a2
parent: 23f8872bc10fbe9ffd2b0067db1f91d8eaaabb40
author: Ori Bernstein <ori@eigenstate.org>
date: Sun May 22 13:27:31 EDT 2022

patch(1): remove bell labs patch scripts

bell labs is dead, and nobody is listening; 9front
has our own patch submission proces.

diff: cannot open a/rc/bin/patch//null: file does not exist: 'a/rc/bin/patch//null'
--- a/rc/bin/patch/applied
+++ /dev/null
@@ -1,8 +1,0 @@
-#!/bin/rc
-
-if(~ $#* 0){
-	echo 'usage: patch/applied patch-name...' >[1=2]
-	exit usage
-}
-
-patch/move applied $*
--- a/rc/bin/patch/apply
+++ /dev/null
@@ -1,79 +1,0 @@
-#!/bin/rc
-
-rfork e
-
-if(! ~ $#* 1){
-	echo 'usage: patch/apply patch-name' >[1=2]
-	exit usage
-}
-
-if(! test -d /n/sources/patch){
-	rfork n
-	9fs sources
-}
-
-if(! test -d /n/sources/patch/$1){
-	echo 'no such patch' /n/sources/patch/$1 >[1=2]
-	exit nopatch
-}
-
-builtin cd /n/sources/patch/$1 || exit nopatch
-if(! patch/okay .){
-	echo 'bad patch: '$status >[1=2]
-	exit badpatch
-}
-
-if(! echo >.tmp || ! rm .tmp){
-	echo no write permission >[1=2]
-	exit 'no write permission'
-}
-
-echo -n merge... >[1=2]
-fn xxx {
-	if(! test -f $1)
-		cp $2 $2.new
-	if not
-		ape/diff3 -m $1 $2.orig $2 >$2.new
-	if(grep -s '^<<<<' $2.new){
-		echo conflicts merging $1';' see `{pwd}^/$2.new >[1=2]
-		
-		touch failed
-	}
-}
-rm -f failed
-cat files | sed 's/^/xxx /' | rc
-if(test -f failed){
-	echo exiting without changes >[1=2]
-	exit failed
-}
-
-echo -n backup... >[1=2]
-fn xxx {
-	# echo cp $1 $2.backup
-	cp $1 $2.backup
-}
-cat files | sed 's/^/xxx /' |rc
-
-echo -n copy... >[1=2]
-fn xxx {
-	# echo cp $2.new $1
-	cp $2.new $1 || touch failed
-}
-cat files | sed 's/^/xxx /' | rc
-
-fn xxx {
-	# echo cp $2.backup $1
-	cp $2.backup $1
-}
-
-if(test -f failed){
-	echo copying failed, restoring backups >[1=2]
-	cat files | sed 's/^/xxx /' | rc
-	exit failed
-}
-
-echo >[1=2]
-
-echo to update sources: >[1=2]
-cat files | awk '{print "	update " $1 }' >[1=2]
-
--- a/rc/bin/patch/create
+++ /dev/null
@@ -1,85 +1,0 @@
-#!/bin/rc
-rfork e
-
-fn xchmod { 
-	chmod $* >[2]/dev/null
-}
-
-if(~ $#* 0 1 2){
-	echo 'usage: patch/create name email file... [< description]' >[1=2]
-	exit usage
-}
-
-if(! echo $1 | grep -s '^[a-z_0-9.\-]+$'){
-	echo 'bad name: [a-z0-9._\-]+ only' >[1=2]
-	exit usage
-}
-if(! echo $2 | grep -s '^(-|[A-Za-z0-9.\-+]+@[A-Za-z0-9.\-+]+)$'){
-	echo 'bad email: [a-z0-9.-+] only; use ''-'' to not leave an email address.' >[1=2]
-	exit usage
-}
-
-if(! test -d /n/sources/patch){
-	rfork n
-	9fs sources
-}
-
-patch=$1
-email=$2
-shift
-shift
-d=/n/sources/patch/$patch
-if(! mkdir $d){
-	echo mkdir $d failed >[1=2]
-	exit mkdir
-}
-if(! ~ $email -){
-	echo $email >$d/email
-}
-
-xchmod o-w $d
->$d/readme
->$d/files
->$d/notes
-for(i in $*){
-	i=`{cleanname -d `{pwd} $i}
-	if(! test -f $i){
-		echo error: cannot find $i >[1=2]
-		rm -rf $d
-		exit oops
-	}
-	short=`{basename $i}
-	uniq=$short
-	n=0
-	while(test -f $d/$uniq){
-		uniq=$short.$n
-		n=`{echo 1+$n | hoc}
-	}
-	cp $i $d/$uniq
-	if(test -f /n/sources/plan9/$i){
-		if(cmp -s /n/sources/plan9/$i $i)
-			echo warning: new file $i does not differ from sources >[1=2]
-		cp /n/sources/plan9/$i $d/$uniq.orig
-	}
-	if not
-		echo warning: new file $i not on sources >[1=2]
-	echo $i $uniq >>$d/files
-}
-@{builtin cd $d && xchmod ug+rw * && xchmod a+r *}
-
-if(~ `{cat /proc/$pid/fd | awk 'NR==2{print $NF}'} */dev/cons && test -w /dev/consctl){
-	>/dev/consctl {
-		echo holdon
-		cat >$d/readme
-	}
-}
-if not
-	cat >$d/readme
-
-if(! test -s $d/readme){
-	echo 'no description given; aborting' >[1=2]
-	rm -rf $d
-	exit oops
-}
-
-echo $d
--- a/rc/bin/patch/diff
+++ /dev/null
@@ -1,45 +1,0 @@
-#!/bin/rc
-# patch/diff [-w] patch-name
-rfork e
-fn usage {
-	echo 'usage: patch/diff [-bmnwz] patch-name' >[1=2]
-	exit usage
-}
-
-dopts=(-c)
-while (! ~ $#* 0 && ~ $1 -*) {
-	switch ($1) {
-	case -[bmnw]
-		dopts=($dopts $1)
-	case -z
-		dopts=()
-	case *
-		usage
-	}
-	shift
-}
-if(! ~ $#* 1)
-	usage
-
-if(! test -d /n/sources/patch){
-	rfork n
-	9fs sources
-}
-
-if(! test -d /n/sources/patch/$1){
-	echo 'no such patch' /n/sources/patch/$1 >[1=2]
-	exit nopatch
-}
-
-builtin cd /n/sources/patch/$1 || exit nopatch
-if(! patch/okay .){
-	echo 'bad patch: '$status >[1=2]
-	exit badpatch
-}
-
-d=/n/sources/patch/$1
-fn xxx {
-	echo $1
-	diff $dopts $2.orig $d/$2 | sed 's/^/	/'
-}
-cat files | sed 's/^/xxx /' | rc
--- a/rc/bin/patch/list
+++ /dev/null
@@ -1,54 +1,0 @@
-#!/bin/rc
-
-rfork e
-if(! test -d /n/sources/patch){
-	rfork n
-	9fs sources
-}
-
-pref=''
-builtin cd /n/sources/patch || {
-	echo 'can''t cd /n/sources/patch' >[1=2]
-	exit no-sources
-}
-
-if(~ $1 applied saved sorry maybe){
-	pref=$1^'/'
-	shift
-}
-if(~ $#* 0)
-	*=(`{
-		if(~ $pref *?*)
-			builtin cd $pref
-		ls -t | grep -v '^(applied|saved|sorry|maybe)$'
-	})
-
-trunc=(sed 5q)
-if(~ $#* 1)
-	trunc=cat
-
-{
-for(i in $*){
-	i=$pref^$i
-	if(test -f $i/origls)
-		cat $i/origls | awk '{$NF="'$i'"; print}'
-	if not
-		ls -ld $i
-	if(patch/okay $i){
-		if(test -r $i/email)
-			echo from `{cat $i/email}
-		cat $i/files | awk '{print "	" $1}'
-		cat $i/readme | sed 's/^/	/' | $trunc
-		if(test -f $i/notes){
-			echo
-			cat $i/notes
-		}
-	}
-	if not
-		echo '	'bad patch: $status >[1=2]
-	echo
-}
-} >/tmp/patchtmp.$pid
-
-cat /tmp/patchtmp.$pid
-rm -f /tmp/patchtmp.$pid
--- a/rc/bin/patch/move
+++ /dev/null
@@ -1,31 +1,0 @@
-#!/bin/rc
-# patch/move target patch-tree... - move patch tree(s) to target dir
-rfork e
-pats=/n/sources/patch
-if(~ $#* 0 1){
-	echo 'usage: patch/move dst patch-name...' >[1=2]
-	exit usage
-}
-
-if(! test -d $pats){
-	rfork n
-	9fs sources
-}
-cd $pats
-
-dst=$1
-shift
-for(src){
-	patbase = `{basename $src}
-	patdest = $dst/$patbase
-	if (~ $dst $src $patbase)
-		echo $0: skipping $src >[1=2]
-	if not if(! test -d $src)
-		echo $0: no such patch $pats/$src >[1=2]
-	if not if(test -d $patdest)
-		echo $0: already have $pats/$patdest >[1=2]
-	if not
-		ls -ldp $src >$src/origls &&
-			mkdir $patdest && dircp $src $patdest && rm -rf $src &&
-			test -s $patdest/email && patch/notify $patdest
-}
--- a/rc/bin/patch/note
+++ /dev/null
@@ -1,35 +1,0 @@
-#!/bin/rc
-
-rfork e
-if(! ~ $#* 1){
-	echo 'usage: patch/note patch-name' >[1=2]
-	exit usage
-}
-
-if(! test -d /n/sources/patch){
-	rfork n
-	9fs sources
-}
-
-if(! test -d /n/sources/patch/$1){
-	echo 'no such patch' /n/sources/patch/$1 >[1=2]
-	exit nopatch
-}
-
-builtin cd /n/sources/patch/$1 || exit nopatch
-if(! patch/okay .){
-	echo 'bad patch: '$status >[1=2]
-	exit badpatch
-}
-
-if(~ `{cat /proc/$pid/fd | awk 'NR==2{print $NF}'} */dev/cons && ~ `{ls -l /dev/consctl | awk '{print $1}'} *w*){
-	>/dev/consctl {
-		echo holdon
-		{echo `{date} `{cat /dev/user}
-		cat |sed 's/^/    /'; echo } >>notes
-	}
-}
-if not
-	{echo `{date} `{cat /dev/user}
-	cat |sed 's/^/    /'; echo } >>notes
-
--- a/rc/bin/patch/notify
+++ /dev/null
@@ -1,9 +1,0 @@
-#!/bin/rc
-# patch/notify
-rfork e
-for(i)
-	# don't flood sys when merely shuffling patches around
-	if (~ $i applied/* saved/* sorry/*) {
-		patch/list $i | mail -s 'patch/list '^$i sys \
-			`{cat /n/sources/patch/$i/email}
-	}
--- a/rc/bin/patch/okay
+++ /dev/null
@@ -1,14 +1,0 @@
-#!/bin/rc
-
-rfork e
-if(! ~ $#* 1){
-	echo usage: patch/okay dir >[1=2]
-	exit usage
-}
-
-i=$1
-if(! test -s $i/files || ! test -s $i/readme)
-	exit 'missing files'
-if(grep -v '^/[_a-zA-Z0-9.\-+/:]+ [_a-zA-Z0-9.\-+:]+$' $i/files)
-	exit 'bad file list' 
-exit 0
--- a/rc/bin/patch/remove
+++ /dev/null
@@ -1,19 +1,0 @@
-#!/bin/rc
-
-rfork e
-if(~ $#* 0){
-	echo 'usage: patch/remove patch-name...' >[1=2]
-	exit usage
-}
-
-if(! test -d /n/sources/patch){
-	rfork n
-	9fs sources
-}
-
-for(i){
-	if(! test -d /n/sources/patch/$i)
-		echo 'no such patch' /n/sources/patch/$i >[1=2]
-	if not
-		rm -rf /n/sources/patch/$i
-}
--- a/rc/bin/patch/save
+++ /dev/null
@@ -1,8 +1,0 @@
-#!/bin/rc
-
-if(~ $#* 0){
-	echo 'usage: patch/save patch-name...' >[1=2]
-	exit usage
-}
-
-patch/move saved $*
--- a/rc/bin/patch/sorry
+++ /dev/null
@@ -1,8 +1,0 @@
-#!/bin/rc
-
-if(~ $#* 0){
-	echo 'usage: patch/sorry patch-name...' >[1=2]
-	exit usage
-}
-
-patch/move sorry $*
--- a/rc/bin/patch/undo
+++ /dev/null
@@ -1,35 +1,0 @@
-#!/bin/rc
-
-rfork e
-if(! ~ $#* 1){
-	echo 'usage: patch/undo patch-name' >[1=2]
-	exit usage
-}
-
-if(! test -d /n/sources/patch){
-	rfork n
-	9fs sources
-}
-
-if(! test -d /n/sources/patch/$1){
-	echo 'no such patch' /n/sources/patch/$1 >[1=2]
-	exit nopatch
-}
-
-d=$1
-builtin cd /n/sources/patch/$1 || exit nopatch
-if(! patch/okay .){
-	echo 'bad patch: '$status >[1=2]
-	exit badpatch
-}
-
-fn xxx {
-	if(cmp $2.new $1){
-		echo cp /n/sources/patch/$d/$2.backup $1
-		cp $2.backup $1
-	}
-	if not
-		echo $1 has changed since patch was applied! >[1=2]
-}
-cat files | sed 's/^/xxx /' |rc
-
--- a/sys/man/1/patch
+++ /dev/null
@@ -1,158 +1,0 @@
-.TH PATCH 1
-.SH NAME
-patch \- simple patch creation and tracking system
-.SH SYNOPSIS
-.B patch/create
-.I name
-.I email
-.I files ...
-[
-.B < 
-.I description
-]
-.PP
-.B patch/list
-[
-.I name ...
-]
-.PP
-.B patch/diff
-.I name
-.PP
-.B patch/apply
-.I name
-.PP
-.B patch/undo
-.I name
-.PP
-.B patch/note
-.I name 
-[
-.B <
-.I note
-]
-.SH DESCRIPTION
-These scripts are a simple patch submission and tracking system
-used to propose additions or changes to Plan 9.
-There is no guarantee that any patch will be accepted, nor
-that it will be accepted verbatim.
-Each patch has a 
-.I name
-(lowercase letters, numbers, dash, dot, and underscore only)
-and is stored in
-.BI /n/sources/patch/ name.
-.PP
-.I Patch/create
-creates a new patch consisting of the changes to
-the listed files from the distribution, reading
-a description of the patch from standard input:
-please provide an explanation of what the change is supposed to do,
-some context, and a rationale for the change.
-Test data or pointers to same to verify that the fix works are also welcome.
-When sending a patch, follow these guidelines:
-.IP • 3
-Before preparing the patch, run
-.I replica/pull
-and base your patch on current distribution source code.
-.IP •
-If this is a bug fix, explain the bug clearly.
-Don't assume the bug is obvious from the fix.
-.IP •
-If this is a new feature, explain it clearly.
-Don't assume it is obvious from the change.
-.IP •
-Make the new code look as much like the old code as possible:
-don't make gratuitous changes, and do follow the style of the old code.
-See
-.IR style (6)
-for the canonical Plan 9 coding style.
-.IP •
-If your patch changes externally-visible behaviour,
-update the manual page.
-.PP
-The
-.I email
-address, if not
-.LR - ,
-will be sent notification messages when the patch is applied, rejected,
-or commented on.
-If rejected, the e-mail will contain a note explaining why and
-probably listing suggested changes and encouraging you to resubmit.
-.PP
-.I Patch/list
-displays information about the named patches,
-or all currently pending patches if none are specified.
-.PP
-.I Patch/diff
-shows a patch as diffs between the original
-source files and the patched source files.
-.PP
-.I Patch/apply
-applies the patch to the current source tree.
-It is intended to be run by the Plan 9 developers with
-.B pie
-as their root file system.
-If the source has changed since the patch was
-created,
-.I apply
-will report the conflict and not change any files.
-Before changing any files,
-.I patch/apply
-makes backup copies of the current source tree's
-files.  The backups are stored in the patch directory.
-.PP
-.I Patch/undo
-will copy the backups saved by
-.I patch/apply
-back into the source tree.
-It will not restore a backup if the file
-being replaced is not byte-identical to the one
-created by 
-.I patch/apply.
-.SH EXAMPLES
-Propose a change to
-.IR pwd ,
-which you have modified locally:
-.IP
-.EX
-% patch/create pwd-errors user@host.dom /sys/src/cmd/pwd.c
-Fix pwd to print errors to fd 2 rather than 1.
-^D
-% 
-.EE
-.PP
-Then the developers at Bell Labs run
-.IP
-.EX
-patch/diff pwd-errors
-.EE
-.PP
-to inspect the change (possibly viewing
-.B /n/sources/patch/pwd-errors/pwd.c
-to see the larger context).
-To make the change, they run
-.IP
-.EX
-patch/apply pwd-errors
-.EE
-.LP
-Otherwise they run
-.IP
-.EX
-% patch/note pwd-errors
-Pwd should definitely print errors to fd 1 because ...
-^D
-% 
-.EE
-.PP
-to add a note to the 
-.B /n/sources/pwd-errors/notes
-file.
-.SH FILES
-.B /n/sources/patch
-.SH SOURCE
-.B /rc/bin/patch
-.SH SEE ALSO
-.IR diff (1)
-.br
-.B http://plan9.bell-labs.com/wiki/plan9/How_to_contribute