#!/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-zA-Z][a-z_0-9.\-]+$'){ echo 'bad name: [a-zA-Z][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 } . /rc/bin/patch/defs mountfs patch=$1 email=$2 shift shift for(i in $*){ if(test -e $i) if(du -a $i | awk '{print $2}' | grep -s '(^[586]\.)|(\.a?[586]$)'){ echo there are object or library files. clean it first >[1=2] exit fail } } if(test -e $PD/$patch){ echo Patch $patch already exists. >[1=2] echo Press return to continue and redefine it, or delete to cancel. >[1=2] read npatch=`{mkuniq $PD $patch} mv $PD/$patch $PD/$npatch || fail cant renamed old version } if(test -e $PD/$patch) fail patch already exists d=$PD/$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/removed for(i in $*){ i=`{cleanname -d `{pwd} $i} if(! test -e $i){ echo $i >>$d/removed } if not{ uniq=`{mkuniq $d $i} if(test -e $SD/$i) cpfile $SD/$i $d/$uniq.orig cpfile $i $d/$uniq 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){ rm -rf $d echo 'no description given; aborting' >[1=2] exit oops } >$d/done # add the patch name to the applied list, so that it is not pull # when it's patch/Applied in the future. echo $patch >> /dist/patch/applied echo $d locally applied.