Date: Mon, 15 Jan 2001 19:26:49 +0200 From: Maxim Sobolev <sobomax@FreeBSD.org> To: ports@FreeBSD.org Subject: RFC1: tool to automate common operations with patchfiles Message-ID: <3A6332D9.11A6ABC6@FreeBSD.org> References: <3A5F3B98.954D80A5@FreeBSD.org>
next in thread | previous in thread | raw e-mail | index | archive | help
Hi again, Just uploaded a somewhat improved version at: http://people.freebsd.org/~sobomax/patchtool New in this revision: - in the update mode (`-u') the tool is now honours last modification time of the patchfile, file from which diff to be generated and ${PATCH_COOKIE} file to determine if the patchfile in question should be updated or it's already up to date; - more consistent error handling; - cleaned up internal structure a bit; - added several missed comments; - fixed several typos/bugs. I'm going to commit it tomorrow, so please test it and let me know your feelings ;). -Maxim Maxim Sobolev wrote: > Hi folks, > > With this message I'm attaching a new tool aimed to significantly simplify > common operations with ports' patches. I modelled it based on my own experience > with the subject, so I hope it would be useful for all hardcore porters and > would like to hear your comments/suggestions/patches/flames etc. > > The tool has the following two modes of operation: > > 1. Generate a patchfile(a) from the user supplied file(s). > ---------------------------------------------------------- > Following example session should give you an idea on how it operates: > $ pwd > /somewhere/myport/work/myport-1.0/src/lib/bar > $ cp foo.c foo.c.orig > $ vi foo.c > [..] <-make your changes > $ patchtool foo.c | more > [..] <-read the diff > $ patchtool -a foo.c > Generating patchfile: patch-src_lib_bar_foo.c <- now you have patchfile ready > in /somewhere/myport/files > [..] > > The tool tries hard to guess correct path of the file relatively to WRKSRC, so > you current directory does not matter and patch should be generated properly > wherever you are, so example, the following will work all the same: > > $ cd /to/the/hell > $ patchtool -a /somewhere/myport/work/myport-1.0/src/lib/bar/foo.c > Generating patchfile: patch-src_lib_bar_foo.c... > $ patchtool -a ../../../somewhere/myport/work/myport-1.0/src/lib/bar/foo.c > Generating patchfile: patch-src_lib_bar_foo.c... > > Several notes: > - `-a' option instructs the tool to automatically save resulting diff into > appropriate patchfile instead of dumping it to the stdout; > > - the tool is smart enough to check your existing patches before generating > patchfile, so for example if in the previous case you already had a patch for > src/lib/bar/foo.c called patch-xxx, then it would update that existing > patchfile instead of creating a new one; > > - the tool honours WRKDIRPREFIX; > > - you can supply arbitrary number of files to generate patches from, you can > even mix files from the different ports - the resulting patchfiles will be > placed into the appropriate PATCHDIRs properly, for example: > > $ patchtool -a port1/work/port1-1.0/1.c port2/work/port2-1.0/2.c > Generating patchfile: patch-1.c... > Generating patchfile: patch-2.c... > > will generate port1/files/patch-1.c and port2/files/patch-2.c. > > 2. Update pointed by the user patchfile(s). > ------------------------------------------- > Another mode of operation is updating of already existing patchfiles. In this > mode the tool updates all patchfiles specified in the command line, for > example: > > $ patchtool -u files/patch-aa files/patch-be > Updating patchfile: patch-aa... > Updating patchfile: patch-be... > > Alternatively you can specify any directory within a tree of a particular port, > in that case all patches that belong to this port will be updated, for example: > > $ ls /somewhere/myport/files > patch-1 patch-8 > $ patchtool -u /somewhere/myport > Updating patchfile: patch-1... > Updating patchfile: patch-8... > $ patchtool -u /somewhere/myport/files > Updating patchfile: patch-1... > Updating patchfile: patch-8... > $ cd /somewhere/myport/work > $ patchtool -u ./ > Updating patchfile: patch-1... > Updating patchfile: patch-8... > [etc] > > Final notes: > - you can tweak many aspects of behaviour, e.g. default diff flags (/me hands > will Will PT_DIFF_ARGS=-u0), patchfile prefix, suffix for saved version of > files etc., by setting appropriate environment variable. See comments at the > very beginning of the file; > > - error handling may not be ideal at the moment - please report any problems > you may have with it; > > - the tool currently doesn't try to make sure that the patch is in fact needs > to be updated, so use -u for existing ports with prejudice (it may generate > unnecessary repobloat); > > - sourcecode is best viewed with tabsize=4. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-ports" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3A6332D9.11A6ABC6>