diff options
author | Luke Shumaker <lukeshu@sbcglobal.net> | 2015-06-25 23:56:37 -0600 |
---|---|---|
committer | Luke Shumaker <lukeshu@sbcglobal.net> | 2015-06-26 00:30:16 -0600 |
commit | acc687b3a74e3c8d750630c323d223f1c63599db (patch) | |
tree | da55f9a30ffebc005d3a0157d70ca8d997afa959 /rvs | |
parent | bddd6fb07906e660260ef0fced05440ecac8d9e9 (diff) |
mkdir rvs; mv * rvs
Diffstat (limited to 'rvs')
41 files changed, 3215 insertions, 0 deletions
diff --git a/rvs/COPYING b/rvs/COPYING new file mode 100644 index 0000000..d60c31a --- /dev/null +++ b/rvs/COPYING @@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + <one line to give the program's name and a brief idea of what it does.> + Copyright (C) <year> <name of author> + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + <signature of Ty Coon>, 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. diff --git a/rvs/HACKING b/rvs/HACKING new file mode 100644 index 0000000..a198138 --- /dev/null +++ b/rvs/HACKING @@ -0,0 +1,295 @@ +#!/bin/more + + Version 0.8c reimplements the wrapper in C, to allow better + cooperation betweem plugins via dependancies. This probably makes + a lot of this document out-dated, but a lot of it is still good, it + describes the workings of the plugins, and the repo structure. + + I know this file is long* and boring. I try to keep it preened and + informative, but would rather spend my time actually hacking. If + you think you can help this file, have at it! ~ Luke Shumaker + + * at 200+ lines, it's longer than any rvs source file + +- - -cut-here- - 8< - - - - - - - - - - - - - - - - - - - - - - - - - +////////////////////////////////////////////////////////////////////// + rvs 0.7.0 + retroactive versioning system + a versioning system that allows you to check + in commit 2 before commit 1 +////////////////////////////////////////////////////////////////////// + + hacking + + build basics + + One of the coolest things about rvs (imo) is how modular and + customizable it is. If you wish to create a fork of rvs, it wls ould + be a good idea to give it a different name. This can be done + without even changing a single source file! Simply run configure + with `--name=NAME' option (variables that have `rvs' in the name + will not be renamed, but the user will never know this unless they + peek ath the code). + + Other options to configure and their default values are: + name='rvs' + The name of the program. Note that unlike most + variables, you should NOT call this in Makefiles + (`$(name)'), but use `$(rvs)' instead. + RVS='$(bindir)/$(rvs)' + Where the exectuable will be. `$(rvs)' is the same as + `$(name)' (see above). In this document it is + sometimes reffered to as the `wrapper'. + SHELL='/bin/sh' + The shell that will be used by make, and the shell + that scripts will run in. (Perhaps we should make + these separate variables?) + prefix='/usr/local' + Standard GNU variable. Many of you will want to + change this to `/usr', or `/home/USER_NAME' + exec_prefix='$(prefix)' + Standard GNU variable. + bindir='$(exec_prefix)/bin' + Standard GNU variable. + sbindir='$(exec_prefix)/sbin' + Standard GNU variable. + libexecdir='$(exec_prefix)/libexec' + Standard GNU variable. The plugins will be installed + at $(libexecdir)/$(name) + srcdir=$(readlink -f `dirname "$0"`) + Where the source code is. The default value evaluates + to the directory of the `configure' script. + + These can either be changed by manually changing `configure' or by + running it like: + ./configure --VAR_NAME=VALUE + + In this document, the `$(VAR_NAME)' refers to whatever you set the + value to. + + The configure script will run on any instance of `Makefile.in' in + $(srcdir). + + Currently, rvs is distributed with 2 pluggins. `repo'(sitory) is + the core of the rvs file database. `users' handles all usernames, + settings, and other info. + + commands + + By itself, rvs does almost nothing. All real functionality is + provided by plugins. When you invoke rvs, you do so in the format + `rvs COMMAND'. Plugins work by adding new commands. + + Most commands are provided by plugins, however, a few are built in: + init + Initializes a repository in the current directory. It creates + `./.$(name)', and runs any initalizers for + plugins. + install PLUGIN DIR + Installs PLUGIN, for which the files are found in DIR. Unless + an older version is already installed, it adds the plugin to + have lowest priority (see `$(libexecdir)/$(rvs)/plugins'). + uninstall PLUGIN + Uninstalls PLUGIN. Did that really need to be said? + + A plugin is simply a collection of independant executable files. + When rvs is invoked, it looks for the COMMAND in a few places: + 1) checks if COMMAND is an built-in command + 2) looks at the file `$(libexecdir)/$(rvs)/plugins'. This is a + newline-delimited list of plugin names. + 3) loops through the directories `$(libexecdir)/$(rvs)/PLUGIN', + where PLUGIN is one of the values in + `$(libexecdir)/$(rvs)/plugins', in the order they appear in + the file. + 4) if rvs does not find the command, it reports an error + + + If you would like to contribute a plugin, or distribute one with a + fork, all you have to do is put it in `$(srcdir)/plugins/NAME'. The + main Makefile will recognize any directory in `$(srcdir)/plugins/' + as a plugin, and will run `make -C `plugins/NAME/Makefile'. It + should create a directory (mine use `plugins/NAME/out') to put ALL, + and ONLY the final files to be used by that plugin. + +========this is outdated but I don't really want to keep editing it == + + build system + + The build system rvs uses is rather simple. + `./configure' does two things: + * create a sed script (`var.sed') + * run every incance of `$(srcdir)/Makefile.in' through + `var.sed' to generate a propper `Makefile' + + `var.sed' contains all configuration variables. When it processes + a file every instance of `@VAR_NAME@' is replaced by that + variable's value. This makes `configure' act much like a GNU + package `congfigure'. Note that this replacement only happens for + defined variables. + + Most of these can easily be changed _after_ `compilation' also: + VER line 4 of the wrapper + SHELL line 1 of each shell script + prefix simply move the wrapper + bindir simply move the wrapper + libexecdir move the directory, then update the line + `RVSDIR=...' in the wrapper + + I have designed this system to be extremely modular. As you may + have figured out, each bit on functionality is in it's own + executable, and the file you call when you type `rvs' is just a + wrapper for them. + + The wrapper is quite simple in mechanism. It simply checks if + `$$libdir$$/COMMAND_NAME' exists, and if so, runs that file. + + The `rvs commit' command is also quite simple in design. It takes a + single argument; the file to commit. If no target is specified, it + defaults to `./'. It checks which type of file the target is, and + runs `rvs commit.FILE_CODE TARGET'. The file codes are as follows: + + block (buffered) special b + character (unbuffered) special c + directory d + named pipe (FIFO) p + regular file f + symbolic link l + socket s + door (Solaris only) D + + As you probably noticed (if you've looked at the blueprints or + source files), only directories and regular files have been + implemented as of rvs 0.7.0. + + After `rvs commit' has done this, it creates a meta-file for that + commit. The meta file contains author, copyright owner, licence + data, file permissions, timestamps, etc. The id of the meta-file is + written to stdout, and used to later check out that commit. + + get works in much the same way as commit, only it reads the file + type from the meta-file, then runs `rvs get.FILE_CODE COMMIT_ID'. + + If you implement any other file types, save the commit and get + functions in the propper locations. + + Any commit function should take a filename as an argument and + output the according commit id to stdout. stderr should be used + for all messages. + + Any get function should take the commit id as an argument and + uses stdout only if verbose, or to report errors. + + To summarize, the modules are separate programs and communicate via + pipes, which is generally considered bad-design, and libraries + should be used instead. I deliberatly broke this because: + + 1. incompatible licences can be used for different modules + 2. modules can be added/removed on the fly + 3. one can use any language to write new modules, without + having to worry about bindings`$(libexecdir)/$(rvs) + + $$libdir$$/lib/ + THIS WAS WRITTEN FOR rvs 0.6.2 + THIS PORTION OF THE CODE IS BEING REVISED IN rvs 0.6.3 + + I have created two 'libraries' for use by rvs components. They + provide several functions that can be accessed by shell script by + using the code: + source "`rvs -d`/lib/stdio" + or + source "`rvs -d`/lib/rvsdb" + (`rvs -d' returns $$libdir$$) + stdio provides several functions for printing messages: + verbose MESSAGE + print MESSAGE to stdout only if $verbose is set to '-v' + out MESSAGE + print MESSAGE to stdout if $verbose isn't set to '-q' + warn MESSAGE + print "rvs: MESSAGE" to stderr + error MESSAGE + print "rvs: MESSAGE" and a quick message about `rvs --help' + (hinting at user error) to stderr, then exit with error + fatal MESSAGE + For internal error. Print "rvs: MESSAGE" to stderr and exit + with error + version + print the version information and exit with success + + rvsdb provides several functions and variables for dealing with the + rvs database: + getid FILE + returns what the id of a given file would be if it were in + the database. This is used to know where to put files when + commiting them. In 0.5.8-0.6.3 this is just the sha1sum of + the file + NOTE: the "log*" functions aren't very stable or developed + loginit FILE + initialize an rvs log at FILE. These logs are used for + metafiles, directory listings, and (probably) eventually + checkout logs + lograw LOG + prepare LOG for reading, and write the output to stdout (to + pipe into another function). This is mostly for internal + use by rvsdb + logread LOG VAR + read variable VAR from the logfile LOG + logwrite LOG VAR VAL + set variable VAR to VAL in the logfile LOG + logfind LOG VAL + return all the names of variables in logfile LOG who have + the value VAL + + the database (.rvs/*) + + So, what are all these files doing in this database? The scheme is + fairly simple. In the `.rvs' directory there is 1 directory, the + `files' directory. There used to be a folder for tempfiles (0.5.8- + 0.6.2), but no more (0.6.3+). If you need a tempfile, just run: + FILENAME=`tempfile` + The `files' directory is where all the data is kept. + + When any file is commited, whether it be a regular file, a + directory, a link, or any other type of file, 2 file are created in + `.rvs/files', the "raw-file" and the "meta-file". When we speek of + file IDs, we mean the filename of the corresponding file in + `.rvs/files' in rvs 0.5.8-0.6.3 this is just the sha1sum of the + file. The meta-file stores everything not part of the file itself; + the filename, file-type, author, copyright owner, file permissions, + timestamps, etc, and the ID of the corresponding raw-file. In the + case of an regular file, the raw-file contains the file itself. For + directories, it contains pointers to each file inside the + directory. + + $$libdir$$/commit calls $$libdir$$/commit.FILETYPE to generate the + raw-file, but generates the meta-file itself (in `.rvs/tmp', then + calls commit.f to commit the meta-file). It then returns the ID of + the meta-file. Therefore, the user never deals with the IDs of + raw-files, and doesn't need to. The metafiles contain pointers to + the corresponding raw-files. + + To keep things modular, commit.f is the ONLY thing that should + actually put files in `.rvs/files', and get.f the only thing that + should get them. Everything else should call them. + + The repo and init are the ONLY things that should have `.rvs' + hardcoded into them. If the repository directory is needed, then + use `rvs repo'. Again, in the core, these should only be the .f + functions, however, it will be useful to plugins. + + Why do we have the `files' directory, why don't we just put + everything in `.rvs'? This way: + * There is a spot to put user data, when we get around to writing + it + + + final thoughts + + I have set up bazaar repository at Launchpad: + https://launchpad.net/rvs + Only until rvs becomes self-hosting. + + If anyone needs any help, let me know, either via email, or via + Launchpad, I'll be happy to help/would love to have your help! + +~ Luke Shumaker <LukeShu@sbcglobal.net> +Happy Hacking! diff --git a/rvs/Makefile.in b/rvs/Makefile.in new file mode 100644 index 0000000..9b884e4 --- /dev/null +++ b/rvs/Makefile.in @@ -0,0 +1,126 @@ +#!/usr/bin/make -f +name = @name@ +ver = 0.8r58 +# Copyright (C) 2009 Luke Shumaker +# +# This file is part of rvs. +# +# rvs is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 2, or (at your option) any later version. +# +# rvs is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with rvs; see the file COPYING. +# If not, write to the Free Software Foundation, +# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +export rvs = $(name) +# directories ###################################################### +srcdir = @srcdir@ +prefix = @prefix@ +exec_prefix = @exec_prefix@ +bindir = @bindir@ +sbindir = @sbindir@ +libexecdir = @libexecdir@ +dirs = $(srcdir) $(prefix) $(exec_prefix) $(bindir) $(sbindir) $(libexecdir) +export srcdir prefix exec_prefix bindir sbindir libexecdir + +# programs ######################################################### +CC = @CC@ +RVS = @RVS@ +SHELL = @SHELL@ +RM = rm -f +CP = cp +SED = sed +INSTALL = install +MKDIR = $(INSTALL) -d #mkdir -p +INSTALL_PROGRAM = $(INSTALL) +INSTALL_DATA = $(INSTALL) -m 644 +TOUCH = touch +export RVS SHELL RM CP SED INSTALL MKDIR INSTALL_PROGRAM INSTALL_DATA TOUCH + +# plugins ########################################################## +plugins = $(patsubst $(srcdir)/plugins/%,%, \ + $(shell find $(srcdir)/plugins/* -maxdepth 0 -type d)) + +build-plugins = $(addprefix p-,$(plugins)) +install-plugins = $(addprefix install-p-,$(plugins)) +uninstall-plugins = $(addprefix uninstall-p-,$(plugins)) +clean-plugins = $(addprefix clean-p-,$(plugins)) +distclean-plugins = $(addprefix distclean-p-,$(plugins)) +dist-plugins = $(addprefix dist-p-,$(plugins)) + +# phony targets #################################################### +all : wrapper $(build-plugins) +.PHONY : install uninstall clean distclean dist libexec \ + build-wrapper install-wrapper uninstall-wrapper clean-wrapper distclean-wrapper dist-wrapper +#$(build-plugins) $(install-plugins) $(uninstall-plugins) $(clean-plugins) $(distclean-plugins) $(dist-plugins) + +.SUFFIXES : + +# install ########################################################## + +install : install-wrapper libexec $(install-plugins) + +# $(libexecdir)/rvs/* +libexec : $(libexecdir)/$(rvs)/plugins +$(libexecdir)/$(rvs)/plugins : $(libexecdir)/$(rvs) + $(TOUCH) $@ + +# uninstall ######################################################## + +uninstall : + $(RM) $(bindir)/$(rvs) + $(RM) -r $(libexecdir)/$(rvs) + +# clean ############################################################ + +clean : $(clean-plugins) clean-wrapper + +distclean : clean $(distclean-plugins) distclean-wrapper + $(RM) Makefile + +# dist ############################################################# + +d = $(name)-$(ver) +dist : $(d).tar.gz + +$(d).tar.gz : $(d) + tar -czf $@ $< + +$(d) : distclean + $(INSTALL) -m 777 -d $@ + $(CP) -r $(srcdir)/* $@ + +# wrapper ########################################################## + +wrapper : build-wrapper +build-wrapper : wrapper/ wrapper/Makefile; $(MAKE) -C $< +uninstall-wrapper : wrapper/ wrapper/Makefile; $(MAKE) -C $< uninstall +clean-wrapper : wrapper/ wrapper/Makefile; $(MAKE) -C $< clean +distclean-wrapper : wrapper/ wrapper/Makefile; $(MAKE) -C $< distclean +dist-wrapper : wrapper/ wrapper/Makefile; $(MAKE) -C $< dist + +install-wrapper : wrapper/ wrapper/Makefile wrapper; $(MAKE) -C $< install +$(RVS) : install-wrapper + +# plugins ########################################################## + +install-p-% : plugins/% plugins/%/Makefile p-% libexec $(RVS) + $(MAKE) -C $< install +p-% : plugins/% plugins/%/Makefile ; $(MAKE) -C $< +uninstall-p-% : plugins/% plugins/%/Makefile ; $(MAKE) -C $< uninstall +clean-p-% : plugins/% plugins/%/Makefile ; $(MAKE) -C $< clean +distclean-p-% : plugins/% plugins/%/Makefile ; $(MAKE) -C $< distclean +dist-p-% : plugins/% plugins/%/Makefile ; $(MAKE) -C $< dist + +# implicit rules ################################################### + +$(dirs) $(libexecdir)/$(rvs) : + $(MKDIR) $@ + diff --git a/rvs/README b/rvs/README new file mode 100644 index 0000000..be5298c --- /dev/null +++ b/rvs/README @@ -0,0 +1,94 @@ +#!/bin/more +////////////////////////////////////////////////////////////////////// + rvs 0.8c r54 + retroactive versioning system + a versioning system that allows you to check + in commit 2 before commit 1 +////////////////////////////////////////////////////////////////////// + +introduction + + rvs is about being able to go back and edit *anything* that has + already been committed. Yes, some other SCMs do this, but fuck + things proper if someone else has a copy of the old version. + + Why would you want to do this? Take for example the Bazaar + repository rvs is hosted on: It starts at 0.6.0, what if I later + want to import 0.0.0 - 0.5.10? Or if I'm trying to construct a + history of BSD, and import all the BSDs I can find, such as + 1,3,4, then latter find 2? + +system requirements + + Pretty much any *nix system should be able to run rvs. If you + need to use a shell other than /bin/sh, run ./configure with + the --SHELL=YOUR_SHELL option. rvs is not designed for Windows, + but should be able to run in bash if you have some *nix pack + installed. + + To my knowledge, this is the absolute requirements (all but the + shell need to be in your PATH): + * a POSIX shell (tested with dash, and GNU BASH) + * cat (included in GNU Core Utils) + * cp (included in GNU Core Utils) + * cut (included in GNU Core Utils) + * echo (included in GNU Core Utils) + * mkdir (included in GNU Core Utils) + * rm (included in GNU Core Utils) + * sed (included in GNU Core Utils) + * sha1sum (included in GNU Core Utils) + * tempfile (included in GNU Core Utils) + * tr (included in GNU Core Utils) + +building + + rvs doesn't exactly use the GNU build system, but acts much like + it does. To build rvs with default configuration, simply run: + $ ./configure + $ make + # make install + + It's generally considered good practice to build in another + directory than the source directory. If you would still like to do + this, it can be done in rvs-0.6.1 and up. + + Configuration + + There are several configuration variables that can be set. You can + modify these configuration variables by running ./configure such + as: + $ ./configure --VAR_NAME=VALUE + + The different configuration variables are as follows: + name='rvs' + The name of the program. Note that unlike most + variables, you should NOT call this in Makefiles + (`$(name)'), but use `$(rvs)'s instead. + CC='gcc' + The C language compiler to use. + RVS='$(bindir)/$(rvs)' + Where the exectuable will be. `$(rvs)' is the same as + `$(name)' (see above) + SHELL='/bin/sh' + The shell that will be used by make, and the shell + that scripts will run in. (Perhaps we should make + these separate variables?) + prefix='/usr/local' + Standard GNU variable. Many of you will want to + change this to `/usr', or `/home/USER_NAME' + exec_prefix='$(prefix)' + Standard GNU variable. + bindir='$(exec_prefix)/bin' + Standard GNU variable. + sbindir='$(exec_prefix)/sbin' + Standard GNU variable. + libexecdir='$(exec_prefix)/libexec' + Standard GNU variable. The plugins will be installed + at $(libexecdir)/$(name) + srcdir=$(readlink -f `dirname "$0"`) + Where the source code is. The default value evaluates + to the directory of the `configure' script. + +~ Luke Shumaker <LukeShu@sbcglobal.net> +Happy Hacking! + diff --git a/rvs/configure b/rvs/configure new file mode 100755 index 0000000..5e19b16 --- /dev/null +++ b/rvs/configure @@ -0,0 +1,97 @@ +#!/usr/bin/env bash +name='configure' # rvs configureation script +#version='0.7.3' +# Copyright (C) 2009 Luke Shumaker +# +# This file is part of rvs. +# +# rvs is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 2, or (at your option) any later version. +# +# rvs is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with rvs; see the file COPYING. +# If not, write to the Free Software Foundation, +# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + _name='rvs' + _CC='gcc' + _RVS='$(bindir)/$(rvs)' + _SHELL='/bin/sh' + _prefix='/usr/local' +_exec_prefix='$(prefix)' + _bindir='$(exec_prefix)/bin' + _sbindir='$(exec_prefix)/sbin' + _libexecdir='$(exec_prefix)/libexec' + _srcdir=$(readlink -f `dirname "$0"`) + +vars='name CC RVS SHELL prefix exec_prefix bindir sbindir libexecdir srcdir' + +error() { + echo "$name: $1" >> /dev/stderr + exit 1 +} + +args=`getopt -n "$name" -o "${sopt}" -l "${lopt}${vars}" -- "$@"` +if [ $? == 0 ]; then + set -- $args + while [ $# -gt 0 ]; do case "$1" in + --) break;; + --*) + var0="${1/--/}" + match='false' + for var1 in $vars; do + if [ "$var0" == "$var1" ]; then + match='true' + break; + fi + done + if [ "$match" == 'true' ]; then + val="$2" + eval _$var0=$val + else + error "option \`$1' not recognized"; + fi + :;; + *) error "option \`$1' not recognized";; + esac + shift + done +else + error 'unable to parse command line arguments' +fi + +echo '#!/bin/sed -f' > var.sed +for var in $vars; do + var1="_$var" + val=${!var1} + + # GNU bash optimized version + var=${var//':'/'\:'} + val=${val//':'/'\:'} + # POSIX version + #var=`echo "$var" | sed 's@:@\\:@g'` + #val=`echo "$val" | sed 's@:@\\:@g'` + + echo "s:@$var@:$val:g" >> var.sed +done + +echo "11 a# DO NOT edit this file, it has been generated by configure, and will +11 a# be overwritten. Instead, edit the file \`Makefile.in'" >> var.sed + +Makefiles=`find "${_srcdir}/" -regextype posix-extended \ +-regex '(.*/)?Makefile\.in' -type f` + +for orig in $Makefiles; do + new=${orig/%.in/} + new=${new/#$_srcdir\//} + mkdir -p `dirname "$new"` + sed -f var.sed < "${orig}" > "${new}" +done +#rm var.sed + diff --git a/rvs/plugins/repo/Makefile.in b/rvs/plugins/repo/Makefile.in new file mode 100644 index 0000000..7078bb6 --- /dev/null +++ b/rvs/plugins/repo/Makefile.in @@ -0,0 +1,108 @@ +#!/usr/bin/make -f +name=repo +ver=0.8r61 +# Copyright (C) 2009 Luke Shumaker +# +# This file is part of rvs. +# +# rvs is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 2, or (at your option) any later version. +# +# rvs is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with rvs; see the file COPYING. +# If not, write to the Free Software Foundation, +# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +export rvs ?= @name@ +# directories ###################################################### +srcdir ?= @srcdir@ +prefix ?= @prefix@ +exec_prefix ?= @exec_prefix@ +bindir ?= @bindir@ +sbindir ?= @sbindir@ +libexecdir ?= @libexecdir@ +dirs = $(srcdir) $(prefix) $(exec_prefix) $(bindir) $(sbindir) $(libexecdir)/ +#export srcdir prefix exec_prefix bindir sbindir libexecdir + +# programs ######################################################### +CC ?= @CC@ +RVS ?= @RVS@ +SHELL ?= @SHELL@ +RM ?= rm +CP ?= cp +SED ?= sed +INSTALL ?= install +MKDIR ?= $(INSTALL) -d #mkdir -p +INSTALL_PROGRAM ?= $(INSTALL) +INSTALL_DATA ?= $(INSTALL) -m 644 +TOUCH ?= touch # This file doesn't use touch +#export RVS SHELL RM CP SED INSTALL MKDIR INSTALL_PROGRAM INSTALL_DATA TOUCH + +# phony targets #################################################### +all : $(name) +.PHONY : $(name) install uninstall clean distclean dist +.SUFFIXES : + +# build ############################################################ +mysrcdir = $(srcdir)/plugins/$(name) +myoutdir = out + +srcFiles = $(filter-out %/Makefile.in,$(shell find $(mysrcdir)/ -type f)) + +shSrcFiles = $(filter %.sh,$(srcFiles)) +shOutFiles = $(patsubst $(mysrcdir)/%,$(myoutdir)/%,$(basename $(shSrcFiles))) + +$(name) : $(myoutdir) $(shOutFiles) $(myoutdir)/plugin.conf + +$(myoutdir)/plugin.conf : $(mysrcdir)/plugin.conf + $(INSTALL_DATA) $< $@ + +# (un)install ###################################################### + +install : all + $(RVS) install $(name)-$(ver) $(myoutdir) + +uninstall : + $(RVS) uninstall $(name) + +# clean ############################################################ + +clean : + +distclean : clean + $(RM) Makefile + $(RM) -r out + +# dist ############################################################# + +id = $(name)-$(ver) +dist : $(id).tar.gz + +$(id).tar.gz : $(id) + tar -czf $@ $< + +$(id) : distclean + $(INSTALL) -m 777 -d $@ + $(CP) -r $(mysrcdir)/* $@ + +# implicit rules ################################################### + +b := @ +# build shell scripts +$(myoutdir)/% : $(mysrcdir)/%.sh $(myoutdir) + $(INSTALL_PROGRAM) $< $@ + $(SED) -i \ + -e 's/$bSHELL@/$(subst /,\/,$(SHELL))/g' \ + -e 's/$blibexecdir@/$(subst /,\/,$(libexecdir))/g' \ + -e 's/$bID@/$(subst /,\/,$(id))/g' \ + $@ + +$(dirs) $(libexecdir)/$(rvs) $(myoutdir) : + $(MKDIR) $@ + diff --git a/rvs/plugins/repo/commit.d.sh b/rvs/plugins/repo/commit.d.sh new file mode 100644 index 0000000..9545b08 --- /dev/null +++ b/rvs/plugins/repo/commit.d.sh @@ -0,0 +1,36 @@ +#!@SHELL@ +name='rvs repo commit.d' +ver=0.8r61 +# Copyright (C) 2009 Luke Shumaker +# +# This file is part of rvs. +# +# rvs is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 2, or (at your option) any later version. +# +# rvs is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with rvs; see the file COPYING. +# If not, write to the Free Software Foundation, +# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +source "$libexecdir/@ID@/stdio" + +# commit.d DIRNAME +dir="$1" +tmp=`mktemp` + +cd "$dir" +for file in *; do + hash=`"$RVS" commit "$file"` + echo "$file:$hash" >> "$tmp" +done + +"$RVS" commit.f "$tmp" +rm "$tmp" + diff --git a/rvs/plugins/repo/commit.f.sh b/rvs/plugins/repo/commit.f.sh new file mode 100644 index 0000000..851c023 --- /dev/null +++ b/rvs/plugins/repo/commit.f.sh @@ -0,0 +1,33 @@ +#!@SHELL@ +name='rvs repo commit.f' +ver=0.8r61 +# Copyright (C) 2009 Luke Shumaker +# +# This file is part of rvs. +# +# rvs is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 2, or (at your option) any later version. +# +# rvs is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with rvs; see the file COPYING. +# If not, write to the Free Software Foundation, +# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#source "$libexecdir/@ID@/stdio" + +# commit.f FILENAME +file="$1" + +#hash=`md5sum $file | sed "s/ .*$//"` +hash=`sha1sum $file | sed "s/ .*$//"` +if [ ! -f "$REPO/@ID@/$hash" ]; then + install -m 644 -o $USER -g $USER -T "$file" "$REPO/@ID@/$hash" +fi +echo "$hash" + diff --git a/rvs/plugins/repo/commit.sh b/rvs/plugins/repo/commit.sh new file mode 100644 index 0000000..0baa931 --- /dev/null +++ b/rvs/plugins/repo/commit.sh @@ -0,0 +1,55 @@ +#!@SHELL@ +name='rvs repo commit' +ver=0.8r61 +# Copyright (C) 2009 Luke Shumaker +# +# This file is part of rvs. +# +# rvs is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 2, or (at your option) any later version. +# +# rvs is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with rvs; see the file COPYING. +# If not, write to the Free Software Foundation, +# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +source "$libexecdir/@ID@/stdio" + +# commit FILE +file=${1-.} + +if [ ! -e $file ]; then error "file \`$file' does not exist"; +# START file type list +elif [ -L $file ]; then type='l'; # symbolic link +elif [ -b $file ]; then type='b'; # block (buffered) special +elif [ -c $file ]; then type='c'; # character (unbuffered) special +elif [ -d $file ]; then type='d'; # directory +elif [ -p $file ]; then type='p'; # named pipe (FIFO) +elif [ -f $file ]; then type='f'; # regular file +elif [ -s $file ]; then type='s'; # socket +#elif [ -D $file ]; then type='D'; # door (Solaris only) +# END file type list +else error "could not identify file type of \`$file'" +fi + +out "+$type `pwd`/$file" +ret=`"$RVS" commit.$type "$file"` + +tmp=`mktemp` +cat << __EOF__ > "$tmp" +name:$file +hash:$ret +type:$type +author:$user +owner:$owner +license:$license +__EOF__ + +"$RVS" commit.f "$tmp" +rm "$tmp" + diff --git a/rvs/plugins/repo/get.d.sh b/rvs/plugins/repo/get.d.sh new file mode 100644 index 0000000..4f95a57 --- /dev/null +++ b/rvs/plugins/repo/get.d.sh @@ -0,0 +1,47 @@ +#!@SHELL@ +name='rvs repo get.d' +ver=0.8r61 +# Copyright (C) 2009 Luke Shumaker +# +# This file is part of rvs. +# +# rvs is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 2, or (at your option) any later version. +# +# rvs is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with rvs; see the file COPYING. +# If not, write to the Free Software Foundation, +# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#source "$libexecdir/@ID@/stdio" + +# get.d ID DIRNAME +id="$1" +dir="$2" + +tmp=`mktemp` +"$RVS" get.f "$id" "$tmp" + +#install -d "$dir" +mkdir -p "$dir" + +cd "$dir" +rm -rf ./* +while read line; do + # GNU bash optimized version + #hash=${line/#*:/} + #name=${line/%:${hash}/} + # POSIX version + hash=`echo "$line" | sed 's/^.*://'` + name=`echo "$line" | sed "s/:$hash$//"` + "$RVS" get "$hash" "$name" +done < "$tmp" + +rm "$tmp" + diff --git a/rvs/plugins/repo/get.f.sh b/rvs/plugins/repo/get.f.sh new file mode 100644 index 0000000..bb43099 --- /dev/null +++ b/rvs/plugins/repo/get.f.sh @@ -0,0 +1,29 @@ +#!@SHELL@ +name='rvs repo get.f' +ver=0.8r61 +# Copyright (C) 2009 Luke Shumaker +# +# This file is part of rvs. +# +# rvs is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 2, or (at your option) any later version. +# +# rvs is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with rvs; see the file COPYING. +# If not, write to the Free Software Foundation, +# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#source "$libexecdir/@ID@/stdio" + +# get.f ID FILENAME +id="$1" +file="$2" + +install -T "$REPO/@ID@/$id" "$file" + diff --git a/rvs/plugins/repo/get.sh b/rvs/plugins/repo/get.sh new file mode 100644 index 0000000..a047e87 --- /dev/null +++ b/rvs/plugins/repo/get.sh @@ -0,0 +1,36 @@ +#!@SHELL@ +name='rvs repo get' +ver=0.8r61 +# Copyright (C) 2009 Luke Shumaker +# +# This file is part of rvs. +# +# rvs is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 2, or (at your option) any later version. +# +# rvs is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with rvs; see the file COPYING. +# If not, write to the Free Software Foundation, +# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +source "$libexecdir/@ID@/stdio" + +# get ID [FILE] +id="$1" +tmp=`mktemp` +"$RVS" get.f "$id" "$tmp" +type="`sed -n 's/^type://p' "$tmp"`" +file="${2-`sed -n 's/^name://p' "$tmp"`}" +hash="`sed -n 's/^hash://p' "$tmp"`" + +out "-$type `pwd`/$file" +"$RVS" get.$type "$hash" "$file" + +rm "$tmp" + diff --git a/rvs/plugins/repo/plugin.conf b/rvs/plugins/repo/plugin.conf new file mode 100644 index 0000000..6028a0f --- /dev/null +++ b/rvs/plugins/repo/plugin.conf @@ -0,0 +1,8 @@ +# rvs repo plugins.conf +# ver=0.8r61 +commit +commit.d +commit.f +get +get.d +get.f diff --git a/rvs/plugins/repo/stdio.sh b/rvs/plugins/repo/stdio.sh new file mode 100644 index 0000000..d4fed0e --- /dev/null +++ b/rvs/plugins/repo/stdio.sh @@ -0,0 +1,68 @@ +#!@SHELL@ +#name='rvs repo stdio' +#ver=0.8r61 +# Copyright (C) 2009 Luke Shumaker +# +# This file is part of rvs. +# +# rvs is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 2, or (at your option) any later version. +# +# rvs is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with rvs; see the file COPYING. +# If not, write to the Free Software Foundation, +# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +verbose() { + if [ "$volume" == '-v' ]; then + echo $@ >> /dev/stderr + fi +} + +out() { + if [ "$volume" != '-q' ]; then + echo $@ >> /dev/stderr + fi +} + +warn () { + echo "$name: $1" >> /dev/stderr +} + +fatal () { + warn "$1" + exit 1 +} + +error() { + warn "$1" + cat << __error__ >> /dev/stderr +Usage: $name $usage + +Try \`$name --help\' for more options. +__error__ + exit 1 +} + +version() { + echo "$name $ver" + if [ "$volume" != '-q' ]; then + cat << __disclaimer__ +$name is copyright (C) 2009 Luke Shumaker +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +Originally written by Luke Shumaker <LukeShu@sbcglobal.net>. +__disclaimer__ + fi + exit 0 +} + diff --git a/rvs/plugins/users/Makefile.in b/rvs/plugins/users/Makefile.in new file mode 100644 index 0000000..0ac9cf5 --- /dev/null +++ b/rvs/plugins/users/Makefile.in @@ -0,0 +1,108 @@ +#!/usr/bin/make -f +name=users +ver=0.8r61 +# Copyright (C) 2009 Luke Shumaker +# +# This file is part of rvs. +# +# rvs is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 2, or (at your option) any later version. +# +# rvs is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with rvs; see the file COPYING. +# If not, write to the Free Software Foundation, +# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +export rvs ?= @name@ +# directories ###################################################### +srcdir ?= @srcdir@ +prefix ?= @prefix@ +exec_prefix ?= @exec_prefix@ +bindir ?= @bindir@ +sbindir ?= @sbindir@ +libexecdir ?= @libexecdir@ +dirs = $(srcdir) $(prefix) $(exec_prefix) $(bindir) $(sbindir) $(libexecdir)/ +#export srcdir prefix exec_prefix bindir sbindir libexecdir + +# programs ######################################################### +CC ?= @CC@ +RVS ?= @RVS@ +SHELL ?= @SHELL@ +RM ?= rm +CP ?= cp +SED ?= sed +INSTALL ?= install +MKDIR ?= $(INSTALL) -d #mkdir -p +INSTALL_PROGRAM ?= $(INSTALL) +INSTALL_DATA ?= $(INSTALL) -m 644 +TOUCH ?= touch # This file doesn't use touch +#export RVS SHELL RM CP SED INSTALL MKDIR INSTALL_PROGRAM INSTALL_DATA TOUCH + +# phony targets #################################################### +all : $(name) +.PHONY : $(name) install uninstall clean distclean dist +.SUFFIXES : + +# build ############################################################ +mysrcdir = $(srcdir)/plugins/$(name) +myoutdir = out + +srcFiles = $(filter-out %/Makefile.in,$(shell find $(mysrcdir)/ -type f)) + +shSrcFiles = $(filter %.sh,$(srcFiles)) +shOutFiles = $(patsubst $(mysrcdir)/%,$(myoutdir)/%,$(basename $(shSrcFiles))) + +$(name) : $(myoutdir) $(shOutFiles) $(myoutdir)/plugin.conf + +$(myoutdir)/plugin.conf : $(mysrcdir)/plugin.conf + $(INSTALL_DATA) $< $@ + +# (un)install ###################################################### + +install : all + $(RVS) install $(name)-$(ver) $(myoutdir) + +uninstall : + $(RVS) uninstall $(name) + +# clean ############################################################ + +clean : + +distclean : clean + $(RM) Makefile + $(RM) -r out + +# dist ############################################################# + +id = $(name)-$(ver) +dist : $(id).tar.gz + +$(id).tar.gz : $(id) + tar -czf $@ $< + +$(id) : distclean + $(INSTALL) -m 777 -d $@ + $(CP) -r $(mysrcdir)/* $@ + +# implicit rules ################################################### + +b := @ +# build shell scripts +$(myoutdir)/% : $(mysrcdir)/%.sh $(myoutdir) + $(INSTALL_PROGRAM) $< $@ + $(SED) -i \ + -e 's/$bSHELL@/$(subst /,\/,$(SHELL))/g' \ + -e 's/$blibexecdir@/$(subst /,\/,$(libexecdir))/g' \ + -e 's/$bID@/$(subst /,\/,$(id))/g' \ + $@ + +$(dirs) $(libexecdir)/$(rvs) $(myoutdir) : + $(MKDIR) $@ + diff --git a/rvs/plugins/users/commit.sh b/rvs/plugins/users/commit.sh new file mode 100644 index 0000000..cb2488d --- /dev/null +++ b/rvs/plugins/users/commit.sh @@ -0,0 +1,31 @@ +#!@SHELL@ +name='rvs users commit' +ver=0.8r61 +# Copyright (C) 2009 Luke Shumaker +# +# This file is part of rvs. +# +# rvs is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 2, or (at your option) any later version. +# +# rvs is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with rvs; see the file COPYING. +# If not, write to the Free Software Foundation, +# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +source "$libexecdir/@ID@/stdio" + +ret=`$RVS repo-0.7beta/commit $@` +if [ -f "$REPO/@ID@/user" ]; then + cp "$REPO/@ID@/user" "$REPO/@ID@/repo/$ret" + echo "$ret" +else + error 'you must be logged in to commit files' +fi + diff --git a/rvs/plugins/users/init.sh b/rvs/plugins/users/init.sh new file mode 100644 index 0000000..41f7d77 --- /dev/null +++ b/rvs/plugins/users/init.sh @@ -0,0 +1,30 @@ +#!@SHELL@ +name='rvs users init' +ver=0.8r61 +# Copyright (C) 2009 Luke Shumaker +# +# This file is part of rvs. +# +# rvs is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 2, or (at your option) any later version. +# +# rvs is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with rvs; see the file COPYING. +# If not, write to the Free Software Foundation, +# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#source "$libexecdir/@ID@/stdio" + +mkdir -p "$REPO/@ID@"/{users,repo} +cat << __EOF__ > "$REPO/@ID@/users/Public Domain" +author:anonymous +owner:Public Domain +license: +__EOF__ + diff --git a/rvs/plugins/users/login.sh b/rvs/plugins/users/login.sh new file mode 100644 index 0000000..340c7db --- /dev/null +++ b/rvs/plugins/users/login.sh @@ -0,0 +1,30 @@ +#!@SHELL@ +name='rvs users login' +ver=0.8r61 +# Copyright (C) 2009 Luke Shumaker +# +# This file is part of rvs. +# +# rvs is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 2, or (at your option) any later version. +# +# rvs is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with rvs; see the file COPYING. +# If not, write to the Free Software Foundation, +# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +source "$libexecdir/@ID@/stdio" + +user="$1" +if [ -f "$REPO/@ID@/users/$user" ]; then + install -m 644 -T "$REPO/@ID@/users/$user" "$REPO/@ID@/../user" +else + error "User \`$user' does not exist" +fi + diff --git a/rvs/plugins/users/logout.sh b/rvs/plugins/users/logout.sh new file mode 100644 index 0000000..43011a1 --- /dev/null +++ b/rvs/plugins/users/logout.sh @@ -0,0 +1,29 @@ +#!@SHELL@ +name='rvs users logout' +ver=0.8r61 +# Copyright (C) 2009 Luke Shumaker +# +# This file is part of rvs. +# +# rvs is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 2, or (at your option) any later version. +# +# rvs is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with rvs; see the file COPYING. +# If not, write to the Free Software Foundation, +# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +source "$libexecdir/@ID@/stdio" + +if [ -f "$REPO/@ID@/../user" ]; then + rm "$REPO/@ID@/../user" +else + error 'you must be logged in to logout' +fi + diff --git a/rvs/plugins/users/mkuser.sh b/rvs/plugins/users/mkuser.sh new file mode 100644 index 0000000..68c16b2 --- /dev/null +++ b/rvs/plugins/users/mkuser.sh @@ -0,0 +1,29 @@ +#!@SHELL@ +name='rvs users mkuser' +ver=0.8r61 +# Copyright (C) 2009 Luke Shumaker +# +# This file is part of rvs. +# +# rvs is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 2, or (at your option) any later version. +# +# rvs is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with rvs; see the file COPYING. +# If not, write to the Free Software Foundation, +# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +source "$libexecdir/@ID@/stdio" + +author="$1" +touch "$REPO/@ID@/users/$author" +cat << __EOF__ > "$REPO/@ID@/users/$author" +author:$author +__EOF__ + diff --git a/rvs/plugins/users/plugin.conf b/rvs/plugins/users/plugin.conf new file mode 100644 index 0000000..1224b23 --- /dev/null +++ b/rvs/plugins/users/plugin.conf @@ -0,0 +1,7 @@ +# rvs users plugins.conf +# ver=0.8r61 +commit:repo-0.8r61/commit +login +logout +mkuser +rmuser diff --git a/rvs/plugins/users/rmuser.sh b/rvs/plugins/users/rmuser.sh new file mode 100644 index 0000000..a9f566f --- /dev/null +++ b/rvs/plugins/users/rmuser.sh @@ -0,0 +1,30 @@ +#!@SHELL@ +name='rvs users rmuser' +ver=0.8r61 +# Copyright (C) 2009 Luke Shumaker +# +# This file is part of rvs. +# +# rvs is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 2, or (at your option) any later version. +# +# rvs is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with rvs; see the file COPYING. +# If not, write to the Free Software Foundation, +# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +source "$libexecdir/@ID@/stdio" + +user="$1" +if [ -f "$REPO/@ID@/users/$user" ]; then + rm "$REPO/@ID@/users/$user" +else + error "User \`$user' does not exist" +fi + diff --git a/rvs/plugins/users/stdio.sh b/rvs/plugins/users/stdio.sh new file mode 100644 index 0000000..a8bd155 --- /dev/null +++ b/rvs/plugins/users/stdio.sh @@ -0,0 +1,68 @@ +#!@SHELL@ +#name='rvs users stdio' +#ver=0.8r61 +# Copyright (C) 2009 Luke Shumaker +# +# This file is part of rvs. +# +# rvs is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 2, or (at your option) any later version. +# +# rvs is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with rvs; see the file COPYING. +# If not, write to the Free Software Foundation, +# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +verbose() { + if [ "$volume" == '-v' ]; then + echo $@ >> /dev/stderr + fi +} + +out() { + if [ "$volume" != '-q' ]; then + echo $@ >> /dev/stderr + fi +} + +warn () { + echo "$name: $1" >> /dev/stderr +} + +fatal () { + warn "$1" + exit 1 +} + +error() { + warn "$1" + cat << __error__ >> /dev/stderr +Usage: $name $usage + +Try \`$name --help\' for more options. +__error__ + exit 1 +} + +version() { + echo "$name $ver" + if [ "$volume" != '-q' ]; then + cat << __disclaimer__ +$name is copyright (C) 2009 Luke Shumaker +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +Originally written by Luke Shumaker <lukeshu@sbcglobal.net>. +__disclaimer__ + fi + exit 0 +} + diff --git a/rvs/wrapper/Makefile.in b/rvs/wrapper/Makefile.in new file mode 100644 index 0000000..9584a2a --- /dev/null +++ b/rvs/wrapper/Makefile.in @@ -0,0 +1,114 @@ +#!/usr/bin/make -f +name = @name@ +ver = 0.8r60 +# Copyright (C) 2009 Luke Shumaker +# +# This file is part of rvs. +# +# rvs is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 2, or (at your option) any later version. +# +# rvs is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with rvs; see the file COPYING. +# If not, write to the Free Software Foundation, +# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +export rvs ?= @name@ +# directories ###################################################### +srcdir ?= @srcdir@ +prefix ?= @prefix@ +exec_prefix ?= @exec_prefix@ +bindir ?= @bindir@ +sbindir ?= @sbindir@ +libexecdir ?= @libexecdir@ +dirs = $(srcdir) $(prefix) $(exec_prefix) $(bindir) $(sbindir) $(libexecdir) +#export srcdir prefix exec_prefix bindir sbindir libexecdir + +# programs ######################################################### +CC = @CC@ +RVS ?= @RVS@ +SHELL ?= @SHELL@ +RM ?= rm +CP ?= cp +SED ?= sed +INSTALL ?= install +MKDIR ?= $(INSTALL) -d #mkdir -p +INSTALL_PROGRAM ?= $(INSTALL) +INSTALL_DATA ?= $(INSTALL) -m 644 +TOUCH ?= touch # This file doesn't use touch +#export RVS SHELL RM CP SED INSTALL MKDIR INSTALL_PROGRAM INSTALL_DATA TOUCH + +CFLAGS = -g \ + -DNAME=\"$(name)\" \ + -DVER=\"$(ver)\" \ + -Dlibexecdir=\"$(libexecdir)/$(rvs)\" \ + -Dplugin_conf=\"plugin.conf\" + +# phony targets #################################################### +all : rvs runcom +.PHONY : install uninstall clean distclean dist install-runcom +.SUFFIXES : .c .o +VPATH = $(srcdir)/wrapper + +# most everything ################################################## +RUNCOM = $(libexecdir)/$(rvs)/runcom +install : $(RVS) $(RUNCOM) +$(RVS) : rvs $(dir $(RVS)) + $(INSTALL_PROGRAM) $< $@ + +OBJ = runcom.o rvs.o plugins.o \ + plugin-depend.o \ + plugin-find.o \ + plugin-load.o \ + plugin-parse.o \ + plugin-run.o \ + +runcom: $(OBJ) + gcc -o $@ $^ + +$(RUNCOM): runcom $(dir $(RUNCOM)) + $(INSTALL_PROGRAM) $< $@ + +b := @ +# build shell scripts +rvs : rvs.sh + $(INSTALL_PROGRAM) $< $@ + $(SED) -i \ + -e 's/$bSHELL@/$(subst /,\/,$(SHELL))/g' \ + -e 's/$bname@/$(rvs)/g' \ + -e 's/$blibexecdir@/$(subst /,\/,$(libexecdir))/g' \ + $@ + +uninstall : + $(RM) $(RVS) + $(RM) $(libexecdir)/$(rvs)/runcom + +clean : + +distclean : clean + $(RM) rvs + $(RM) Makefile + +# dist ############################################################# + +d = $(name)-$(ver) +dist : $(d).tar.gz + +$(d).tar.gz : $(d) + tar -czf $@ $< + +$(d) : distclean + $(INSTALL) -m 777 -d $@ + $(CP) -r $(srcdir)/* $@ + +# implicit rules ################################################### + +$(dirs) $(libexecdir)/$(rvs) : + $(MKDIR) $@ + diff --git a/rvs/wrapper/TODO b/rvs/wrapper/TODO new file mode 100644 index 0000000..9734938 --- /dev/null +++ b/rvs/wrapper/TODO @@ -0,0 +1,12 @@ +#! /bin/more + +* actually launch the plugins +* plugin-run.h: + the function _plugin_sh_mktemp() is an ugly hack, it exists + because a) it is secure b) it is easier to write a hack using + methods I understand, than learn those I don't c) point b + especially when I just want to get it working. + +~ Luke Shumaker +Happy Hacking! + diff --git a/rvs/wrapper/plugin-depend.c b/rvs/wrapper/plugin-depend.c new file mode 100644 index 0000000..de21a93 --- /dev/null +++ b/rvs/wrapper/plugin-depend.c @@ -0,0 +1,146 @@ +/* wrapper/plugin-depend.c -- load a command dependancy tree + system depends: <string.h> <error.h> + Copyright (C) 2009 Luke Shumaker + + This file is part of rvs. + + rvs is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your + option) any later version. + + rvs is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with rvs; see the file COPYING. + If not, write to the Free Software Foundation, + 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +#include <string.h> +#include <error.h> + +#include "rvs.h" +#include "plugin-find.h" + +#include "plugin-depend.h" + +/* translates a string in format `plugin/command' into a pointer to the command + DON'T plan on using the string again, it will be mutilated! + (so we go ahead and free() it and set the pointer to NULL) */ +struct plugin_command * +plugin_depend_parse (char **string, + struct plugin *plugins, + struct plugin_command *root) +{ + struct plugin_command *command=NULL; + + if (*string==NULL) + command=root; + else { + /* *string is in the format `plugin/command' */ + /* char *del=delimeter */ + char *del=strchr(*string,'/'); + del[0]='\0'; + /* *string = PLUGIN_NAME */ + /* &del[1] = COMMAND_NAME */ + struct plugin *plugin; + plugin =plugin_find_plugin(plugins, *string ); + if (plugin==NULL) + error(EXIT_FAILURE,0,"cannot find plugin `%s'",*string); + command=plugin_find_plugin_command(plugin->commands, &del[1] ); + if (command==NULL) + error(EXIT_FAILURE,0, + "plugin `%s' does not contain command `%s'", + *string,&del[1]); + xfree(*string); + *string=NULL; + } + return command; +} + +/* used by plugin_depend_add */ +void +_plugin_depend_add (struct plugin_command *prev, + struct plugin_command *next) +{ + if (prev->d_next==NULL) { + prev->d_next=next; + } else { + _plugin_depend_add(prev->d_next,next); + } +} + +/* plugin_depend_add(depend,depender) */ +void +plugin_depend_add (struct plugin_command *depend, + struct plugin_command *depender) +{ + if (depend->d_child==NULL) { + depend->d_child=depender; + } else { + _plugin_depend_add(depend->d_child,depender); + } +} + +/* take care of depends for `command' */ +void +plugin_depend_command (struct plugin_command *command, + struct plugin *plugins, + struct plugin_command *root, int ind) +{ + if (command!=NULL) { + if (command->depend == NULL) { + /* the depend still needs to be parsed */ + command->depend=plugin_depend_parse( + &(command->depends),plugins,root); + } + plugin_depend_add(command->depend,command); + } +} + +/* take care of commands for a `plugin', and those after it (linked list) */ +void +plugin_depend_plugin_all (struct plugin *plugin, + struct plugin *plugins, + struct plugin_command *root) +{ + plugin_depend_command(plugin->commands,plugins,root,0); + if (plugin->next != NULL) { + plugin_depend_plugin_all(plugin->next,plugins,root); + } +} + +/* take care of all depends */ +struct plugin_command * +plugin_depend_all (struct plugin *plugins) +{ + struct plugin_command *root=plugin_mk_command(); + + plugin_depend_plugin_all(plugins,plugins,root); + return root; +} + +void +_plugin_depend_list (struct plugin_command_list *commands, + struct plugin *plugins, + struct plugin_command *root,int ind) +{ + if (commands!=NULL) { + plugin_depend_command(commands->command,plugins,root,ind++); + _plugin_depend_list(commands->next,plugins,root,ind++); + } +} + +struct plugin_command * +plugin_depend_list (struct plugin_command_list *commands, + struct plugin *plugins) +{ + struct plugin_command *root=plugin_mk_command(); + _plugin_depend_list(commands,plugins,root,0); + return root; +} + diff --git a/rvs/wrapper/plugin-depend.h b/rvs/wrapper/plugin-depend.h new file mode 100644 index 0000000..580c03f --- /dev/null +++ b/rvs/wrapper/plugin-depend.h @@ -0,0 +1,83 @@ +/* wrapper/plugin-parse.h -- parse rvs plugin config files + system depends: <stdio.h> <string.h> <error.h> + Copyright (C) 2009 Luke Shumaker + + This file is part of rvs. + + rvs is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your + option) any later version. + + rvs is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with rvs; see the file COPYING. + If not, write to the Free Software Foundation, + 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ +#ifndef FILE_plugin_depend_h_SEEN +#define FILE_plugin_depend_h_SEEN + +#include "plugins.h" +#include "plugin-find.h" + +/* translates a string in format `plugin/command' into a pointer to the command + DON'T plan on using the string again, it will be mutilated! + (so we go ahead and free() it and set the pointer to NULL) */ +extern +struct plugin_command * +plugin_depend_parse (char **string, + struct plugin *plugins, + struct plugin_command *root); + +/* used by plugin_depend_add */ +extern +void +_plugin_depend_add (struct plugin_command *prev, + struct plugin_command *next); + +/* plugin_depend_add(depend,depender) */ +extern +void +plugin_depend_add (struct plugin_command *depend, + struct plugin_command *depender); + +/* take care of depends for `command' */ +extern +void +plugin_depend_command (struct plugin_command *command, + struct plugin *plugins, + struct plugin_command *root, int ind); + +/* take care of commands for a `plugin', and those after it (linked list) */ +extern +void +plugin_depend_plugin_all (struct plugin *plugin, + struct plugin *plugins, + struct plugin_command *root); + +/* take care of all depends */ +extern +struct plugin_command * +plugin_depend_all (struct plugin *plugins); + +extern +void +_plugin_depend_list (struct plugin_command_list *commands, + struct plugin *plugins, + struct plugin_command *root,int ind); + +extern +struct plugin_command * +plugin_depend_list (struct plugin_command_list *commands, + struct plugin *plugins); + + + + +#endif + diff --git a/rvs/wrapper/plugin-find.c b/rvs/wrapper/plugin-find.c new file mode 100644 index 0000000..98e16af --- /dev/null +++ b/rvs/wrapper/plugin-find.c @@ -0,0 +1,103 @@ +/* wrapper/plugin-find.h -- search functions for rvs plugins + system depends: <string.h> + Copyright (C) 2009 Luke Shumaker + + This file is part of rvs. + + rvs is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your + option) any later version. + + rvs is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with rvs; see the file COPYING. + If not, write to the Free Software Foundation, + 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +#include <string.h> /* only uses `strcmp' */ + +#include "rvs.h" +#include "plugins.h" + +#include "plugin-find.h" + +/* returns first plugin with `name' (duplicates are... unwise) */ +struct plugin * +plugin_find_plugin(struct plugin *node, char *name) +{ + + if (node==NULL) + return node; + else { + if (strcmp(node->name,name) == 0) + return node; + else + return plugin_find_plugin(node->next,name); + } +} + +/* returns plugin `name within plugin `node' */ +struct plugin_command * +plugin_find_plugin_command(struct plugin_command *node, char *name) +{ + if (node==NULL) + return node; + else { + if (strcmp(node->name,name) == 0) + return node; + else + return plugin_find_plugin_command(node->next,name); + } +} + +/* returns the first command with `name' it finds */ +struct plugin_command * +plugin_find_command(struct plugin *plugin, char *name) +{ + if (plugin==NULL) + return NULL; + else { + struct plugin_command *ret; + ret=plugin_find_plugin_command(plugin->commands,name); + if (ret == NULL) + ret=plugin_find_command(plugin->next,name); + return ret; + } +} + +/* returns a linked list of all commands with `name' it finds */ +struct plugin_command_list * +plugin_find_commands(struct plugin *plugin, char *name) +{ + if (plugin==NULL) + return NULL; + else { + struct plugin_command *command; + command=plugin_find_command(plugin,name); + struct plugin_command_list *node; + if (command==NULL) + node=plugin_find_commands(plugin->next,name); + else { + node=xmalloc( sizeof *node ); + node->command=command; + node->next=plugin_find_commands(plugin->next,name); + } + return node; + } +} + +void +plugin_free_list(struct plugin_command_list *node) +{ + if (node!=NULL) { + plugin_free_list(node->next); + xfree(node); + } +} + diff --git a/rvs/wrapper/plugin-find.h b/rvs/wrapper/plugin-find.h new file mode 100644 index 0000000..0185117 --- /dev/null +++ b/rvs/wrapper/plugin-find.h @@ -0,0 +1,64 @@ +/* wrapper/plugin-find.h -- search functions for rvs plugins + system depends: <string.h> + Copyright (C) 2009 Luke Shumaker + + This file is part of rvs. + + rvs is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your + option) any later version. + + rvs is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with rvs; see the file COPYING. + If not, write to the Free Software Foundation, + 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ +#ifndef FILE_plugin_find_h_SEEN +#define FILE_plugin_find_h_SEEN + +#include <string.h> /* only uses `strcmp' */ + +#include "rvs.h" +#include "plugins.h" + +/*------------------------------struct------------------------------*/ +/* a linked list of commands, for use by `plugin_find_commands' */ +struct plugin_command_list +{ + struct plugin_command *command; + struct plugin_command_list *next; +}; + +/*-----------------------------function-----------------------------*/ +/* returns first plugin with `name' (duplicates are... unwise) */ +extern +struct plugin * +plugin_find_plugin(struct plugin *node, char *name); + +/* returns plugin `name within plugin `node' */ +extern +struct plugin_command * +plugin_find_plugin_command(struct plugin_command *node, char *name); + +/* returns the first command with `name' it finds */ +extern +struct plugin_command * +plugin_find_command(struct plugin *plugin, char *name); + +/* returns a linked list of all commands with `name' it finds */ +extern +struct plugin_command_list * +plugin_find_commands(struct plugin *plugin, char *name); + +extern +void +plugin_free_list(struct plugin_command_list *node); + +#endif + diff --git a/rvs/wrapper/plugin-load.c b/rvs/wrapper/plugin-load.c new file mode 100644 index 0000000..142fcd5 --- /dev/null +++ b/rvs/wrapper/plugin-load.c @@ -0,0 +1,78 @@ +/* wrapper/plugin-load.h -- load rvs plugins into mem + system depens: <stdio.h>, GNU <string.h> + Copyright (C) 2009 Luke Shumaker + + This file is part of rvs. + + rvs is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your + option) any later version. + + rvs is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with rvs; see the file COPYING. + If not, write to the Free Software Foundation, + 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +#include <stdio.h> +#include <string.h> + +#include "rvs.h" +#include "plugins.h" +#include "plugin-parse.h" + +#include "plugin-load.h" + +/*- plugin_load ----------------------------------------------------*\ + now, load plugin plug_name, +\* whose configuration file is plugin_conf */ +struct plugin * +plugin_load (const char *plug_name) +{ + struct plugin *plugin=xmalloc( sizeof(*plugin) ); + plugin->name=stralloc(plug_name); + plugin->next=NULL; + + xchdir(plug_name); + FILE *file = xfopen(plugin_conf,"r"); + plugin->commands=plugin_parse(plugin, file); + fclose( file ); + xchdir(".."); + + return plugin; +} + +/*- load_plugins ---------------------------------------------------*\ + Load all the plugins + assume we're in rvs's libexecdir, where plugins are +\* Use `plugin_conf' as the name of the config file for each plugin */ + +struct plugin * +load_plugins (FILE *list) +{ + struct plugin *first=NULL; /* we return this */ + struct plugin **prev=&first; /* this is the previous plugin->next */ + struct plugin *plugin; /* this is the current plugin */ + + size_t nbytes = 10; + char *plug_name=(char *)xmalloc(nbytes); + while ( getline(&plug_name, &nbytes, list) > 0 ) { + char *del=strchr(plug_name,'\n'); + del[0]='\0'; + /*if (strlen(plug_name)!=0) {*/ + if (plug_name[0]!='\0') {; + plugin=plugin_load(plug_name); + *prev=plugin;/* this sets the last's `next' */ + prev=&plugin->next; + } + } + + return first; +} + diff --git a/rvs/wrapper/plugin-load.h b/rvs/wrapper/plugin-load.h new file mode 100644 index 0000000..f214151 --- /dev/null +++ b/rvs/wrapper/plugin-load.h @@ -0,0 +1,47 @@ +/* wrapper/plugin-load.h -- load rvs plugins into mem + system depens: <stdio.h>, GNU <string.h> + Copyright (C) 2009 Luke Shumaker + + This file is part of rvs. + + rvs is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your + option) any later version. + + rvs is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with rvs; see the file COPYING. + If not, write to the Free Software Foundation, + 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ +#ifndef FILE_plugin_load_h_SEEN +#define FILE_plugin_load_h_SEEN + +#include <stdio.h> +#include <string.h> + +#include "rvs.h" +#include "plugins.h" +#include "plugin-parse.h" + +/*- plugin_load ----------------------------------------------------*\ + now, load plugin plug_name, +\* whose configuration file is plugin_conf */ +extern +struct plugin * +plugin_load (const char *plug_name); + +/*- load_plugins ---------------------------------------------------*\ + Load all the plugins + assume we're in rvs's libexecdir, where plugins are +\* Use `plugin_conf' as the name of the config file for each plugin */ +extern +struct plugin * +load_plugins (FILE *list); +#endif + diff --git a/rvs/wrapper/plugin-parse.c b/rvs/wrapper/plugin-parse.c new file mode 100644 index 0000000..4a35586 --- /dev/null +++ b/rvs/wrapper/plugin-parse.c @@ -0,0 +1,132 @@ +/* wrapper/plugin-parse.c -- parse rvs plugin config files + system depends: <stdio.h> <string.h> <error.h> + Copyright (C) 2009 Luke Shumaker + + This file is part of rvs. + + rvs is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your + option) any later version. + + rvs is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with rvs; see the file COPYING. + If not, write to the Free Software Foundation, + 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +#include <stdio.h> +#include <string.h> +#include <error.h> /* only used in `plugin_parse_escape' for `error' */ + +#include "rvs.h" +#include "plugins.h" + +#include "plugin-parse.h" + +void +plugin_parse_comment (FILE *file) +{ + char c; + while ( (c=getc(file)) != EOF ) { + if ( c == '\n' ) { + ungetc (c, file); + break; + } + } +} + +char +plugin_parse_escape(FILE *file) +{ + char c=getc(file); + switch (c) { + case 'n': + c = '\n'; + case '\\': + case '#': + case ':': + break; + default: + error(EXIT_FAILURE,0,"syntax error"); + break; + } + return c; +} + +#define _parse_share(string) \ + case '#':\ + plugin_parse_comment(file);\ + break;\ + case '\\':\ + c[0]=plugin_parse_escape(file);\ + default:\ + stradds(&nbytes,string,(char *)&c);\ + break; + +char * +plugin_parse_depend (FILE *file) +{ + size_t nbytes = 10; + char *string = (char *)xmalloc(nbytes); + string[0]='\0'; + + char c[2] = " \0"; + while ( (c[0]=getc(file)) != EOF ) { + switch (c[0]) { + case '\n': + ungetc (c[0], file); + return string; + break; + _parse_share(&string) + } + } + return string; +} + +struct plugin_command * +plugin_parse (struct plugin *plugin, FILE *file) +{ + struct plugin_command *command; + + char c[2] = " \0"; + c[0]=getc(file); + + if (c[0]==EOF) + command=NULL; + else { + ungetc (c[0], file); + command=plugin_mk_command(); + command->plugin=plugin; + + size_t nbytes = 10; + command->name = (char *)xmalloc(nbytes); + command->name[0]='\0'; + + while ( (c[0]=getc(file)) != EOF ) { + switch (c[0]) { + case '\n': + /*if (strlen(command->name)==0) {*/ + if (command->name[0]=='\0') { + plugin_free_command(command); + return plugin_parse(plugin,file); + } else + command->next=plugin_parse( + plugin,file); + break; + case ':': + command->depends=plugin_parse_depend( + file); + break; + _parse_share(&(command->name)) + } + } + } + return command; +} + diff --git a/rvs/wrapper/plugin-parse.h b/rvs/wrapper/plugin-parse.h new file mode 100644 index 0000000..67ee06f --- /dev/null +++ b/rvs/wrapper/plugin-parse.h @@ -0,0 +1,49 @@ +/* wrapper/plugin-parse.c -- parse rvs plugin config files + system depends: <stdio.h> <string.h> <error.h> + Copyright (C) 2009 Luke Shumaker + + This file is part of rvs. + + rvs is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your + option) any later version. + + rvs is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with rvs; see the file COPYING. + If not, write to the Free Software Foundation, + 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ +#ifndef FILE_plugin_parse_h_SEEN +#define FILE_plugin_parse_h_SEEN + +#include <stdio.h> +#include <string.h> +#include <error.h> /* only used in `plugin_parse_escape' for `error' */ + +#include "rvs.h" +#include "plugins.h" + +extern +void +plugin_parse_comment (FILE *file); + +extern +char +plugin_parse_escape(FILE *file); + +extern +char * +plugin_parse_depend (FILE *file); + +extern +struct plugin_command * +plugin_parse (struct plugin *plugin, FILE *file); + +#endif + diff --git a/rvs/wrapper/plugin-run.c b/rvs/wrapper/plugin-run.c new file mode 100644 index 0000000..26d4480 --- /dev/null +++ b/rvs/wrapper/plugin-run.c @@ -0,0 +1,89 @@ +/* wrapper/plugin-run.c -- run a heiarchy of commands + system depens: <stdio.h> <stdlib.h> + Copyright (C) 2009 Luke Shumaker + + This file is part of rvs. + + rvs is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your + option) any later version. + + rvs is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with rvs; see the file COPYING. + If not, write to the Free Software Foundation, + 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +#include <stdio.h> +#include <stdlib.h> + +#include "rvs.h" +#include "plugins.h" +#include "plugin-find.h" + +#include "plugin-run.h" + +/* this function is an ugly hack */ +char * +_plugin_sh_mktemp() +{ + size_t nbytes = 10; + char *string = (char *)malloc(nbytes); + string[0]='\0'; + + FILE *out=popen("mktemp -t rvs-XXXXXXXXXX","r"); + char c[2]=" \0"; + while ( (c[0]=getc(out)) != '\n' ) { + stradds(&nbytes,&string,(char *)&c); + } + pclose(out); + return string; +} + +void +plugin_run_command(struct plugin_command *command, char *args, char *depfile) +{ + if (command!=NULL) { + char *outfile=_plugin_sh_mktemp(); + /* make command string: + `libexecdir/plugin_name/command < depfile > outfile' + */ + int nbytes=20; + char *coms=(char *)xmalloc(nbytes); + coms[0]='\0'; + stradds(&nbytes,&coms,libexecdir); + stradds(&nbytes,&coms,"/"); + stradds(&nbytes,&coms,command->plugin->name); + stradds(&nbytes,&coms,"/"); + stradds(&nbytes,&coms,command->name); + stradds(&nbytes,&coms," "); + stradds(&nbytes,&coms,args); + stradds(&nbytes,&coms," < "); + stradds(&nbytes,&coms,depfile); + stradds(&nbytes,&coms," > "); + stradds(&nbytes,&coms,outfile); + + xsystem(coms); + xfree(coms); + plugin_run_command(command->d_child,args,outfile); + xfree(outfile); + plugin_run_command(command->d_next ,args,depfile); + } +} + +/* needs to take the root command */ +void +plugin_run(struct plugin_command *command,char *args) +{ + /*plugin_run_command(command->d_child,"/dev/null");*/ + char *outfile=_plugin_sh_mktemp(); + plugin_run_command(command->d_child,args,outfile); + xfree(outfile); +} + diff --git a/rvs/wrapper/plugin-run.h b/rvs/wrapper/plugin-run.h new file mode 100644 index 0000000..99beff4 --- /dev/null +++ b/rvs/wrapper/plugin-run.h @@ -0,0 +1,47 @@ +/* wrapper/plugin-run.h -- run a heiarchy of commands + system depens: <stdio.h> <stdlib.h> + Copyright (C) 2009 Luke Shumaker + + This file is part of rvs. + + rvs is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your + option) any later version. + + rvs is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with rvs; see the file COPYING. + If not, write to the Free Software Foundation, + 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ +#ifndef FILE_plugin_run_h_SEEN +#define FILE_plugin_run_h_SEEN + +#include <stdio.h> +#include <stdlib.h> + +#include "rvs.h" +#include "plugins.h" +#include "plugin-find.h" + +/* this function is an ugly hack */ +extern +char * +_plugin_sh_mktemp(); + +extern +void +plugin_run_command(struct plugin_command *command, char *args, char *depfile); + +/* needs to take the root command */ +extern +void +plugin_run(struct plugin_command *command, char *args); + +#endif + diff --git a/rvs/wrapper/plugins.c b/rvs/wrapper/plugins.c new file mode 100644 index 0000000..70ce3e1 --- /dev/null +++ b/rvs/wrapper/plugins.c @@ -0,0 +1,71 @@ +/* wrapper/plugins.c -- struct definitions and basic functions for rvs plugins + system depends: this file is truly system-independant + Copyright (C) 2009 Luke Shumaker + + This file is part of rvs. + + rvs is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your + option) any later version. + + rvs is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with rvs; see the file COPYING. + If not, write to the Free Software Foundation, + 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +#include "rvs.h" + +#include "plugins.h" + +/* create a blank plugin_command */ +struct plugin_command * +plugin_mk_command() +{ + struct plugin_command *command; + command=(struct plugin_command *)xmalloc(sizeof(*command)); + + /* node */ + command->name=NULL; + command->plugin=NULL; + command->depend=NULL; + command->depends=NULL; + + /* linked list */ + command->next=NULL; + + /* depends */ + command->d_child=NULL; + command->d_next=NULL; + + return command; +} + +void +plugin_free_command(struct plugin_command *command) +{ + if (command!=NULL) { + plugin_free_command(command->next); + xfree(command->name); + xfree(command->depends); + xfree(command); + } +} + +void +plugin_free_plugin(struct plugin *plugin) +{ + if (plugin!=NULL) { + xfree(plugin->name); + plugin_free_command(plugin->commands); + plugin_free_plugin(plugin->next); + xfree(plugin); + } +} + diff --git a/rvs/wrapper/plugins.h b/rvs/wrapper/plugins.h new file mode 100644 index 0000000..2b5a96e --- /dev/null +++ b/rvs/wrapper/plugins.h @@ -0,0 +1,69 @@ +/* wrapper/plugins.h -- struct definitions and basic functions for rvs plugins + system depends: this file is truly system-independant + Copyright (C) 2009 Luke Shumaker + + This file is part of rvs. + + rvs is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your + option) any later version. + + rvs is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with rvs; see the file COPYING. + If not, write to the Free Software Foundation, + 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ +#ifndef FILE_plugins_h_SEEN +#define FILE_plugins_h_SEEN + +#include "rvs.h" + +/* a plugin */ +/* a generic binary tree emulating a n-ary tree via linked list */ +struct plugin +{ + char *name; + struct plugin_command *commands;/* left leaf */ + struct plugin *next; /* right leaf */ +}; + +/* a single plugin command */ +struct plugin_command +{ + /* node */ + char *name; + struct plugin *plugin; /* which plugin does it belong to? */ + struct plugin_command *depend; /* what does this depend on? */ + char *depends;/* what does this depend on? (string) */ + + /* linked list */ + struct plugin_command *next; + + /* depends, linked list */ + /* for a dependancy tree, this seems like it should be a *\ + \* separate struct, but this is the simplest way. */ + struct plugin_command *d_child; + struct plugin_command *d_next; +}; + +/* create a blank plugin_command */ +extern +struct plugin_command * +plugin_mk_command(); + +extern +void +plugin_free_command(struct plugin_command *command); + +extern +void +plugin_free_plugin(struct plugin *plugin); + +#endif + diff --git a/rvs/wrapper/runcom.c b/rvs/wrapper/runcom.c new file mode 100644 index 0000000..10e9919 --- /dev/null +++ b/rvs/wrapper/runcom.c @@ -0,0 +1,74 @@ +/* wrapper/runcom.c -- main program loop + system depends: this file is truly system-independant + Copyright (C) 2009 Luke Shumaker + + This file is part of rvs. + + rvs is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your + option) any later version. + + rvs is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with rvs; see the file COPYING. + If not, write to the Free Software Foundation, + 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +const char *name=NAME; +const char *ver=VER; + +#include "rvs.h" +#include "plugins.h" +#include "plugin-load.h" +#include "plugin-find.h" +#include "plugin-depend.h" +#include "plugin-run.h" + +int +main ( int argc, char *argv[] ) +{ + if (argc > 1) { + /*load*/ + char *cwd=getcwd(NULL,0); + xchdir(libexecdir); + struct plugin *plugins; + plugins=load_plugins(stdin); + struct plugin_command_list *list; + list=plugin_find_commands(plugins,argv[1]); + if (list==NULL) + error(EXIT_FAILURE,0,"unrecognized command `%s'", + argv[1]); + struct plugin_command *root; + root=plugin_depend_list(list,plugins); + + /*do*/ + xchdir(cwd); + int nbytes=10; + char *args=xmalloc(nbytes); + args[0]='\0'; + int i; + for (i=2; i<argc; i++) { + stradds(&nbytes, &args, "\"" ); + stradds(&nbytes, &args, argv[i]); + stradds(&nbytes, &args, "\" "); + } + + plugin_run(root,args); + + /*free*/ + plugin_free_list(list); + plugin_free_command(root); + plugin_free_plugin(plugins); + } + return 0; +} + +/* Copy/Paste Virus 1.3c Please copy and paste this text anywhere. Track *\ +\* its progress by searching for this MD5#f7eac285ebfe21c4587bfebb9582f90d */ + diff --git a/rvs/wrapper/rvs.c b/rvs/wrapper/rvs.c new file mode 100644 index 0000000..a2a8a37 --- /dev/null +++ b/rvs/wrapper/rvs.c @@ -0,0 +1,117 @@ +/* wrapper/rvs.c -- general and machine specific functions for rvs. + system depends:<stdio.h> <stdlib.h> <string.h> <unistd.h> <errno.h> <error.h> + Copyright (C) 2009 Luke Shumaker + + This file is part of rvs. + + rvs is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your + option) any later version. + + rvs is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with rvs; see the file COPYING. + If not, write to the Free Software Foundation, + 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#include <errno.h> +#include <error.h> + +#include "rvs.h" + +void * +xmalloc (size_t size) +{ + void *value = malloc (size); + if (value == NULL) { + perror(program_invocation_name); + exit(EXIT_FAILURE); + } + return value; +} + +void * +xrealloc (void *ptr, size_t size) +{ + void *value = realloc (ptr, size); + if (value == NULL) { + perror(program_invocation_name); + exit(EXIT_FAILURE); + } + return value; +} + +void +xfree (void *ptr) +{ + if (ptr!=NULL) + free (ptr); +} + +void +xsystem (const char *command) +{ + int stat=system(command); + if (stat!=0) { + if (stat==-1) { + fprintf(stderr, + "%s: unable to launch run command", + program_invocation_name); + exit(EXIT_FAILURE); + } else + exit(EXIT_FAILURE); + } +} + +/* unistd.h */ +int +xchdir (const char *filename) +{ + int ret=chdir(filename); + if (ret != 0) + error(EXIT_FAILURE,errno,"%s/",filename); + return ret; +} + +/* stdio.h */ +FILE * +xfopen (const char *filename, const char *opentype) +{ + FILE *file = fopen(filename,opentype); + /* fopen gives NULL on failure */ + if ( file == NULL ) + error(EXIT_FAILURE,errno,"%s",filename); + return file; +} + +/* string funtions */ +void +stradds(size_t *size, char **dest, char *str) +{ + if (*size > ( strlen(*dest) + strlen(str) )) + strcat(*dest, str); + else { + *size = strlen(*dest) + strlen(str) + 1; + *dest = (char *) xrealloc (*dest, *size); + strcat(*dest, str); + } +} + +char * +stralloc (const char *string) +{ + char *copy = (char *)xmalloc(strlen(string)+1); + strcpy(copy,string); + return copy; +} + diff --git a/rvs/wrapper/rvs.h b/rvs/wrapper/rvs.h new file mode 100644 index 0000000..bdd5c68 --- /dev/null +++ b/rvs/wrapper/rvs.h @@ -0,0 +1,76 @@ +/* wrapper/rvs.h -- general and machine specific functions for rvs. + system depends:<stdio.h> <stdlib.h> <string.h> <unistd.h> <errno.h> <error.h> + Copyright (C) 2009 Luke Shumaker + + This file is part of rvs. + + rvs is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your + option) any later version. + + rvs is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with rvs; see the file COPYING. + If not, write to the Free Software Foundation, + 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ +#ifndef FILE_rvs_h_SEEN +#define FILE_rvs_h_SEEN + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#include <errno.h> +#include <error.h> + +/* glibc */ +extern char *program_invocation_name; +extern char *program_invocation_short_name; + +/* stdlib.h */ +/*extern int EXIT_SUCCESS;*/ +/*extern int EXIT_FAILURE;*/ + +extern +void * +xmalloc (size_t size); + +extern +void * +xrealloc (void *ptr, size_t size); + +extern +void +xfree (void *ptr); + +extern +void +xsystem (const char *command); + +/* unistd.h */ +extern +int +xchdir (const char *filename); + +/* stdio.h */ +extern +FILE * +xfopen (const char *filename, const char *opentype); + +/* string funtions */ +extern +void +stradds(size_t *size, char **dest, char *str); + +extern +char * +stralloc (const char *string); + +#endif + diff --git a/rvs/wrapper/rvs.sh b/rvs/wrapper/rvs.sh new file mode 100644 index 0000000..a515f2d --- /dev/null +++ b/rvs/wrapper/rvs.sh @@ -0,0 +1,110 @@ +#!@SHELL@ +name='@name@' +ver='0.8r61' +# Copyright (C) 2009 Luke Shumaker +# +# This file is part of rvs. +# +# rvs is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 2, or (at your option) any later version. +# +# rvs is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with rvs; see the file COPYING. +# If not, write to the Free Software Foundation, +# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +RVS="$0" #RVS="@rvs@" +libexecdir="@libexecdir@/$name" + +_error() { + echo "$RVS: $1" >> /dev/stderr + exit 1 +} + +_repo() { + repo=".$name" + pwd=`pwd` + owd="$pwd" + + while [ "$pwd" != "`pwd`" ] && [ ! -e "`pwd`/$repo" ]; do + pwd=`pwd` + cd .. + done + + if [ -e "`pwd`/$repo" ]; then + echo "`pwd`/$repo" + else + _error "no $name repository found" + fi + cd "$owd" +} + +_init() { + repo=`_repo 2> /dev/null` + if [ -z "$repo" ]; then + repo=".$name" + install -d "$repo" + install -m644 -T $libexecdir/plugins $repo/plugins + while read plugin; do + echo "initializing plugin \`$plugin'" + install -d "$repo/$plugin" + export REPO=.rvs/$plugin + if [ -e "$libexecdir/$plugin/init" ]; then + "$libexecdir/$plugin/init" + fi + done < $repo/plugins + else + _error "repository already exists at \`$repo'" + fi +} + +_install() { + id=$1 + dir=${2-$id} + name=`echo $id | sed 's/-.*$//'` + if (grep "^$name-" "$libexecdir/plugins" &> /dev/null); then + # an entry for this plugin already exists, though possibly a + # different version + sed -i "s/^$name-.*$/$id/" "$libexecdir/plugins" + else + echo "$id" >> "$libexecdir/plugins" + fi + rm -rf "$libexecdir/$id" + cp -rpT "$dir" "$libexecdir/$id" +} + +_uninstall() { + id=$1 + sed -i "/^$id$/ d" "$libexecdir/plugins" + rm -rf "$libexecdir/$id" +} + +# START OPTION HANDLING # +com=$1; +# END OPTION HANDLING # +case "$com" in + '') _error 'no command specified';; + # 'repo') _repo; exit $?;; + 'init') _init; exit $?;; + 'install') shift; _install $@; exit $?;; + 'uninstall') shift; _uninstall $@; exit $?;; + *) REPO=`_repo` + if [ "$?" = '0' ]; then + export RVS libexecdir REPO + "$libexecdir/runcom" $@ < $REPO/plugins + exit $? + else + _error "cannot find an existing repository" + fi + :;; +esac + +# Copy/Paste Virus 1.3c Please copy and paste this text anywhere. Track +# its progress by searching for this MD5#f7eac285ebfe21c4587bfebb9582f90d + |