GOAL: draft for a quick start guide to set up a simple strategy that allows you to maintain a customized version of OFBiz under SVN revision control and synchronized with the standard OFBiz SVN.
- This strategy is a simple implementation of the Vendor Branch Pattern; for more details about Vendor Branches refer to the "Version Control with Subversion" manual (see here)
- Here is a specific simple strategy for Windows
- Note that for the development phase you may prefer to directly work with the trunk following this strategy. You may even use it in production see these threads
Overview: The plan is to develop a customized version of OFBiz called customofbiz, but we want to stay up to date with the official OFBiz development. We will target to do the update once every month but it can be done at any point in time.
- Get OFBiz from the official Apache SVN server (let's say r482800 - this in no way suggests that revision is good, bad or otherwise it's just a number);
- Import it into the local SVN repository as the ofbiz project; and tag it as ofbiz r482800;
- Use it as the base for my customofbiz project making changes as needed to do the customisation.
- Next month get the latest OFBiz revision, let's say r483333, from the official Apache SVN and update the local ofbiz project in the local repository with it (also adding a tag to it, for example ofbiz r483333).
- Finally do a merge between ofbiz r482800, ofbiz r483333 and my working copy (containing the up to date customofbiz project), resolve the conflicts and commit everything to the local customofbiz.
Repository structure
Here is the local repository structure to maintain:
ofbiz
ofbiz/current
---> this will contain the latest official OFBiz release
ofbiz/ofbiz-<revnumA>
---> these are the monthly tags for the official OFBiz release (e.g. ofbiz-r482800, ofbiz-r483333, etc...)
ofbiz/ofbiz-<revnumB>
...
ofbiz/ofbiz-<revnumN>
customofbiz
customofbiz/trunk
---> this is the trunk of the customofbiz project (initially it will be the same as ofbiz <revnumA>)
How to set up an SVN repository and start the svn service
Initialization of an empty repository
svnadmin create ./svn-repos
- Edit the ./svn-repos/conf/svnserve.conf file
- Edit the ./svn-repos/conf/passwd file
Start the service
svnserve --daemon --root ./svn-repos
Import Apache OFBiz for the first time and create the customofbiz project
Get the revision or latest version of OFBiz you will be starting from for this sample its r482800:
svn export http://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk ./tmpdir/ofbiz-r482800
Import it as the ofbiz project in the repository
svn import -m "Import OFBiz r482800" ./tmpdir/ofbiz-r482800 svn://localhost/ofbiz/current
Make a tag for ofbiz r482800
svn copy -m "Tag r482800 vendor drop" svn://localhost/ofbiz/current svn://localhost/ofbiz/ofbiz-r482800
Create the "ofbizcustom" project (initially it's a copy of the OFBiz r482800 tag)
svn mkdir -m "" svn://localhost/customofbiz svn copy -m "OfbizCustom is initially built over the ofbiz-r482800 tag" svn://localhost/ofbiz/ofbiz-r482800 svn://localhost/customofbiz/trunk
Working with the customofbiz project
Checkout the trunk of customofbiz
svn co svn://localhost/customofbiz/trunk ./tmpdir/customofbiz
- Make changes to customofbiz and then commit the new revisions to the local repository etc...
How to synch customofbiz with ofbiz every month
Every month we get a new OFBiz revision (in this example, we get revision r483333)
svn export http://svn.apache.org/repos/asf/ofbiz/trunk ./tmpdir/ofbiz-r483333
Update the current version of "ofbiz" project in the local svn repository and automatically create a tag (r483333, see the -t argument)
./svn_load_dirs.pl -t ofbiz-r483333 svn://localhost/ofbiz current ./tmpdir/ofbiz-r483333
question: are the svn properties that need to be applied to new files correctly retrieved from the .svnversion/conf file?
answer: probably not; you have to setup a config file (as described at the bottom of this page) and pass it to the svn_load_dirs.pl script with the -p argument.We have to synch customofbiz, that was based on the ofbiz-r482800 tag, with the new ofbiz tag ofbiz-r483333; we do this in a working copy, not directly in the repository (before doing this, make sure that your working directory is up to date "svn up" and has no local changes "svn st").
svn merge svn://localhost/ofbiz/ofbiz-r482800 svn://localhost/ofbiz/ofbiz-r483333 ./tmpdir/customofbiz
- Conflicts are possible and you will need to fix those in your local working folder, test and then commit the changes.
It is also a good idea to tag the new customofbiz revision.
svn copy -m "OfbizCustom is initially built over the OFBiz r482800 tag" svn://localhost/customofbiz/trunk svn://localhost/customofbiz/customofbiz-r483333
Continuing with the example, let's say that one month later, you want to export a new OFBiz release (r486422) and import it with (svn_load_dir.pl) in the ofbiz/current and as a new tag ofbiz-r486422; Use the following command to perform the merge (thanks to Kenneth Porter for the tip):
svn merge svn://localhost/ofbiz/ofbiz-r483333 svn://localhost/ofbiz/ofbiz-r486422 ./tmpdir/customofbiz
Tip: export a local svn rather than direct from the OFBiz SVN server
Taking a complete snapshot from the live SVN server every merge can be a long job and place additional load on those servers. The export process describe above can also be done from a locally held OFBiz version that you update using standard "svn up" command.
First time round do a clean checkout to a local folder "ofbiz_clean"
svn co http://svn.apache.org/repos/asf/ofbiz/trunk ofbiz_clean
Next export the local "ofbiz_clean" rather than the OFBiz SVN server
svn export ofbiz_clean ./tmpdir/ofbiz-r482800
Then you follow on with the instructions above to import and merge until you come to your next update at which point you
svn up ofbiz_clean
and then again export the local copy
svn export ofbiz_clean ./tmpdir/ofbiz-r483333
4 Comments
Unknown User (mimil)
Hello,
the thing I don't see (and was not able to answer myself with google) is how to commit back things you may want from the customofbiz.
I also don't understant why it is not possible (at least I didn't find someone doing it) to use svn:external instead of svn export from the ofbiz repository. In that case there would be no more merge to do between ofbiz revisions.
If you have any suggest on both questions
Enrique Ruiz (DiSiD Technologies)
Interesting new section in SVN Book about this theme:
http://svnbook.red-bean.com/en/1.5/svn.advanced.vendorbr.html
Note that the given command examples are for SVN 1.5, take it as a guide.
Hope it will be useful
Mike
----------------------------------
SETUP A SIMPLE OFBIZ VENDOR BRANCH
----------------------------------
I went through the pain of setting up a "vendor branch" of ofbiz, so I thought I'd share it with the community. The supplied instructions in the wiki seemed confusing, and didn't go into detail. Since I'm into automation, my script (svn_local.sh) allows the following:
Keep a local copy of ofbiz (trunk|0904|1004), allow it to be modified, but at the same time have the ability to receive upstream updates from the Apache Ofbiz SVN server, and merge them into your own local copy. For the most part, this works automatically.
The attached ofbiz_vendor_branch.tar.gz has the script.
To clarify, I'm not a subversion expert, so my setup is ultra simple, anonymous read/write, no password, etc. My svn server is safely behind a firewall, so I'm not worried about multi users, passwords, hackers, etc. This works for me because I'm a one man show. Your requirements are probably different.
To get started, we need to keep local copies of the following:
http://svn.apache.org/repos/asf/ofbiz/trunk -or- http://svn.apache.org/repos/asf/ofbiz/branches/release09.04 -or- http://svn.apache.org/repos/asf/ofbiz/branches/release10.04 -or- all three!
These are always kept up to date via "svn update", and are kept in /opt/ofbiz.svn.
The script (svn_local.sh) allows all three (or more in the future) branches to be tracked. For me, the best branch for deployment is trunk, because it seems to be the most stable, and gets more attention from the developers. For the purpose of this setup, I'm just going focus on trunk, but tracking 0904 or 1004 (or all three) is as easy as tweaking a variable (in svn_local.sh).
The Apache and Local versions are kept in /opt/ofbiz.svn, and are named:
/opt/ofbiz.svn/asf.ofbiz.0904
/opt/ofbiz.svn/asf.ofbiz.1004
/opt/ofbiz.svn/asf.ofbiz.trunk
The "local" copies are called.
/opt/ofbiz.svn/opt.ofbiz.0904
/opt/ofbiz.svn/opt.ofbiz.1004
/opt/ofbiz.svn/opt.ofbiz.trunk
NOTE: Regarding this path (/opt/ofbiz.svn). For simplicity, use the same path (at least initially). The script resides in the "/opt/ofbiz.svn/bin" directory, and will always place the above checked out directories one level above the script (in /opt/ofbiz.svn).
Also, this script runs on an Ubuntu host, I've never tried to run this on windows. However, It might work under cygwin.
Internally (within the local SVN repository), the directories are organized like this:
ofbiz/
ofbiz/asf/
ofbiz/asf/ofbiz.1004
ofbiz/asf/ofbiz.trunk
ofbiz/opt/
ofbiz/opt/ofbiz.1004
ofbiz/opt/ofbiz.trunk
NOTE: If you already have an SVN repository, then I'd fully analyze/test this process (on a separate machine) to see if it "fits" into your local SVN repository w/o clobbering your own stuff. If you have "ofbiz" at the top of your SVN tree (like above), then there may be issues. You have been warned!
These directories are strictly used to track changes to the local repositories. Your actual names (when you check out a working copy) could be different. In my case, when I check out the working local copy, I place it in /opt/ofbiz.version, and this is where I actually fire up ofbiz from (later).
You could tweak these names, but this will require hacking the script, and it is not recommended, at least until you understand how it works.
The attached tar file contains the following items:
drwxr-xr-x root/root 0 2011-03-16 10:38 opt/ofbiz.svn/bin/
-rwxr-xr-x root/root 6478 2011-03-16 09:36 opt/ofbiz.svn/bin/svn_local.sh
rw-rr- root/root 9630 2009-05-12 10:25 opt/ofbiz.svn/bin/svn_load_dirs.README
rw-rr- root/root 7201 2011-03-16 10:12 opt/ofbiz.svn/bin/config
rw-rr- root/root 7201 2011-03-16 10:12 opt/ofbiz.svn/bin/README
-rwxr-xr-x root/root 67335 2010-08-27 18:50 opt/ofbiz.svn/bin/svn_load_dirs.pl
-rwxr-xr-x root/root 436 2010-09-06 11:36 opt/ofbiz.svn/bin/svnserv
#
Here are the contents:
--------------------------------------------------------------
/opt/ofbiz.svn/bin/svnserv (used to fire up the SVN daemon)
/opt/ofbiz.svn/bin/svn_load_dirs.pl (NOT written by me)
/opt/ofbiz.svn/bin/svn_local.sh (MY script, that automates all)
/opt/ofbiz.svn/bin/config (SVN client config file, discussed later)
/opt/ofbiz.svn/bin/README (These docs)
--------------------------------------------------------------
NOTE: The svn_load_dirs.pl (part of Apache) is a perl script which magically merges the various repositories. This one works for me, so I provided it. It DOES require various perl modules that must be satisfied so it properly works.
To get started, you will need your own SVN repository. Here are the steps.
--------------------------------------------------------------
STEP 1) Create your own local SVN repository
--------------------------------------------------------------
I suggest you use /var/svn/repos, it will make it easier, and my script uses it (later).
--------------------------------------------------------------
STEP 2) Tweak SVN for anonymous read-write
--------------------------------------------------------------
general
anon-access = write
auth-access = write
password-db = passwd
Copy /opt/ofbiz.svn/bin/svnserv into /etc/init.d (unless you don't already have one), and fire up the svnserv init script. You may have to tweak it (works for Ubuntu).
Make sure it's running.
/# ps -efww|grep svn
root 6436 1 0 18:47 ? 00:00:00 svnserve -d -r /var/svn/repos
--------------------------------------------------------------
STEP 3) Copy the client config to the proper location.
--------------------------------------------------------------
NOTE: The svn client config needs to be copied to the home directory of the user who runs the svn command. In this case, probably /root/.subversion/config -or- place it in (again Ubuntu) /etc/subversion/config, which would make it available to all users on that machine. Also, if you plan on running ofbiz on a different machine, then you need to make sure this 'config' file is on all machines. so:
--------------------------------------------------------------
STEP 4) Create a "svn" DNS entry for your local domain (optional)
--------------------------------------------------------------
If you have your own local area network and your own DNS server, it is good practice to create a "svn" host, which is an alias to the host where the local SVN repository exists. For instance, if your local domain is "internal.net", create "svn.internal.net", which points to the real host.
--------------------------------------------------------------
STEP 5) Untar the attached tar file from the root directory
--------------------------------------------------------------
--------------------------------------------------------------
STEP 6) Configure the script (choose trunk/branches)
--------------------------------------------------------------
Set the variables ofbiz_versions and local_svnserv.
Variable: ofbiz_versions
All three Ofbiz versions (NOT recommended)
ofbiz_versions="trunk:trunk branches/release10.04:1004 branches/release09.04:0904"
Trunk+1004 (also not really recommended)
ofbiz_versions="trunk:trunk branches/release10.04:1004"
Just Trunk:
ofbiz_versions="trunk:trunk"
Just 1004:
ofbiz_versions="branches/release10.04:1004"
The item on the right side of the colon will be used to create the name of the directory entry. For instance, you check out the branch "branches/release10.04" and it create a directory called "opt.ofbiz.1004".
If you choose to track multiple branches (not recommended), then your local SVN server will get pretty fat (and slow). Beware.
Variable: local_svnserv
local_svnserv="svn://svn.internal.net"
#local_svnserv="svn://svn"
#local_svnserv="file:///var/svn/repos"
Choose the way you want to access you own local repository. If you followed the above directions, then you already have the svnserv daemon running. The first one is using the DNS name (so is the second, but there is an /etc/resolv.conf that has "search internal.net" defined). This is really the recommended way of accessing a local SVN server. You can then check out the code from ANY machine on your local area network. If you are running on just a single machine, then you COULD use the "file:///..." method, which is fast (and least flexible).
--------------------------------------------------------------
STEP 7) Run the svn_load_dirs.pl utility to make sure it works
--------------------------------------------------------------
Look for any perl modules missing, and satisfy the requirements. You should get the help syntax of the script.
On Ubuntu, you can do a bunch of "apt-get install ITEM" to satisfy the perl module, or you could use the CPAN method, which consists of a bunch of:
perl -MCPAN -e "install Digest::MD5"
Statements until the script is happy. Don't attempt STEP 8 until svn_load_dirs.pl is happy.
ALSO: Check svn_load_dirs.pl and verify line 32:
my $svn = '/usr/bin/svn';
Points to the correct svn binary (above is Ubuntu).
--------------------------------------------------------------
STEP 8) Run svn_local.sh in "init" mode
--------------------------------------------------------------
NOTE: Don't forget STEP 3 (svn client "config") or you'll have problems with the next step.
lots of output
NOTE: This is only done ONCE (with "init"), to initially populate the repository.
The script is in debug mode (during init) in case any problems occur.
--------------------------------------------------------------
STEP 9) Checkout the "local" (running) branch of the ofbiz repository you want
--------------------------------------------------------------
Decide where you want to run ofbiz. /opt always works for me.
NOTE: The right argument is the directory that will be created. You can name it
anything you want. I recommend ofbiz.trunk to match SVN.
....
A ofbiz.trunk/ivy.xml
A ofbiz.trunk/startofbizBoth.bat
A ofbiz.trunk/KEYS
A ofbiz.trunk/rc.ofbiz
A ofbiz.trunk/startofbizPos.bat
Checked out revision 11.
#
Notice that even for 1004, you still checkout the "trunk" of the local 1004 repository
--------------------------------------------------------------
STEP 10) Check things out, test, etc.
--------------------------------------------------------------
Change directory, and run "svn info" You should see a low revision #, like 11.
The "Last Changed Rev:" is probably r11. The log should show "Initial import...."
--------------------------------------------------------------
STEP 11) Change something, commit changes to your local repository
--------------------------------------------------------------
A newapp
--------------------------------------------------------------
This is a newapp in hot-deploy
-This line, and those below, will be ignored-
A hot-deploy/newapp
--------------------------------------------------------------
Adding hot-deploy/newapp
Committed revision 12.
--------------------------------------------------------------
STEP 12) Run updates from Apache OFBIZ, and "merge" changes into your local repo.
--------------------------------------------------------------
Sometime later, after the developers tweaked something in trunk, run the following:
If nothing changed, then you'll see:
--------------------------------------------------------------
NOTE: FOUND svn_load_dirs.pl in /opt/ofbiz.svn/bin/svn_load_dirs.pl
Remote ASF: http://svn.apache.org/repos/asf/ofbiz/trunk
Local ASF: svn://svn/ofbiz/asf/ofbiz.trunk
Local OFB: svn://svn/ofbiz/opt/ofbiz.trunk
http://svn.apache.org/repos/asf/ofbiz/trunk Revision: 1082281
Last Changed Revisions: Last:1082281 Current:1082281
Repository revisions match
#
--------------------------------------------------------------
Otherwise, you'll lots of magical output that hopefully ends up with your local svn repository opt.ofbiz.trunk updated with fresh patches/changes from Ofbiz being merged into your own changes being made locally.
This works automatically for the most part, but on occasion you may have a collision when you might have to accept/reject a merge option.
The script also creates directories like this:
/opt/ofbiz.svn/asf.ofbiz.trunk.1079456
/opt/ofbiz.svn/asf.ofbiz.trunk.1080107
/opt/ofbiz.svn/asf.ofbiz.trunk.1080776
/opt/ofbiz.svn/asf.ofbiz.trunk.1081185
Which are checked out versions of trunk. These can be blown away if you like, but I like them because I can do stuff like "diffing" between revisions:
diff -r asf.ofbiz.trunk.1081444 asf.ofbiz.trunk.1081740
--------------------------------------------------------------
STEP 13) Update your local (running) copy of ofbiz with the latest changes.
--------------------------------------------------------------
Suppose you (like me) run the "running" version of ofbiz in /opt/ofbiz.trunk, which you checked out in STEP 9.
You run the update/merge process:
lots of output
Even though you did the above steps, the copy you are running in /opt/ofbiz.trunk is STILL running the old code. You must also update your running (checked out) code, like this:
....... update statements ............
/etc/init.d/ofbiz.trunk restart ... etc..
Thats it. If you have problems initially creating the repository, make sure you followed STEP #3. You can always blow away the /var/svn/repos, and re-init.
If any errors show up, you can always un-comment line #6 "set -x" to show the debug steps.
If you already have a modified ofbiz directory that you want to merge into this process, then that will be tricky, and a lot more work. However, you could probably do it like this:
Run the above procedure, checking out a new code branch (like in STEP 9). You then need to detect the changes between your existing, running code and copy each modified (or missing) file/directory (i.e., one by one into the checked out directory (/opt/ofbiz.trunk). Then, just:
I hope this helps someone. Good luck!!
Attachment is next
Mike
The attachment is #1 on the upper left hand corner of this page.