1 | | This is a simple guide for developers, to allow a common tree structure and commit messages for every package stored into the main repository. |
| 1 | = SVN Tutorial = |
| 2 | |
| 3 | This is a simple guide for developers, to allow a common tree structure and commit messages for every project stored into the main repository. |
| 4 | |
| 5 | == Preparation == |
| 6 | |
| 7 | While there is a great SVN GUI called [http://www.smartsvn.com SmartSVN] which is highly recommended to use (version 6.x.x and 7.0.7 work greatly under OS/2 due to our nice [http://trac.netlabs.org/java/ OpenJDK 1.6 port]), sometimes working with the SVN tool from the command line is more desirable. In particular, the examples in this tutorial show the usage of the SVN command line client. Note that these command line examples imply using RPM `ash` as the current shell (unless stated otherwise). |
| 8 | |
| 9 | In order to make the command line SVN client more comfortable, there are several useful tips and tricks. |
| 10 | |
| 11 | 1. Set the EDITOR environment variable to a text editor that can be started form the command line by passing a file name to edit as the first (and only) argument, e.g.: |
| 12 | {{{ |
| 13 | set EDITOR=e.exe |
| 14 | }}} |
| 15 | This will make SVN call this editor whenever it needs you to edit some multi-line text (e.g. when writing a commit message). |
| 16 | |
| 17 | 2. Set up an external diff viewer (to be described later). |
| 18 | |
| 19 | == Creating New Project From Existing Sources == |
| 20 | |
| 21 | Let's assume that there is a project is named `pixman` that you want to import to this repository. First, you need to create the vendor tree on the SVN server where you will import the original sources: |
| 22 | {{{ |
| 23 | svn mkdir --parents http://svn.netlabs.org/repos/ports/pixman/vendor/current -m "pixman: Create vendor tree." |
| 24 | }}} |
| 25 | The real-life result of this step is in r1222. |
| 26 | |
| 27 | Then you need to check out the vendor tree to your file system: |
| 28 | {{{ |
| 29 | mkdir pixman |
| 30 | svn co http://svn.netlabs.org/repos/ports/pixman/vendor/current pixman/vendor-current |
| 31 | }}} |
| 32 | |
| 33 | The next step is to import original sources. There are two possible cases: using a tarball from the vendor or taking the sources right from the vendor's source repository (SVN, GIT, HG, etc). There is one essential difference between these cases: the tarball will usually contain pre-generated sources necessary for the build (and sometimes also the documentation) while the repository doesn't contain these files assuming they will be regenerated by the developer. The vendor's repository looks like a more suitable source for importing (because it makes no sense to store generated files in a version control system). But most projects in this '''ports''' repository are Linux-oriented and we don't have all the tools necessary to generate build files (and, especially, documentation), so sometimes it is more desirable to take a tarball for importing (and remove files we can generate on OS/2 later on). |
| 34 | |
| 35 | Let's assume we downloaded a tarball of the version we want to import, e.g.`pixman-0.32.8.tar.gz` for the pixman library version 0.32.8. Now unpack it to `pixman/vendor-current`: |
| 36 | {{{ |
| 37 | tar xvf pixman-0.32.8.tar.gz --strip-components=1 -C pixman/vendor-current |
| 38 | }}} |
| 39 | |
| 40 | Now commit all the original files with these commands: |
| 41 | {{{ |
| 42 | cd pixman/vendor-current |
| 43 | svn add * |
| 44 | svn commit |
| 45 | }}} |
| 46 | This should open your favorite editor (set by the EDITOR environment variable) where you enter the commit message. Note that using the `-m` switch is not enough in this case as your commit message at this step needs to be multi-line, like this one: |
| 47 | {{{ |
| 48 | pixman: Import version 0.32.8 from vendor. |
| 49 | |
| 50 | Source URL: http://cairographics.org/releases/pixman-0.32.8.tar.gz |
| 51 | }}} |
| 52 | Note that you should specify the exact download URL of the tarball (or the URL of the repository tag) you used for the import operation in this commit — it may be needed to get the this tarball later to check that everything was properly imported etc. Check r1223 for the real-life example. |
| 53 | |
| 54 | Now, in case if the sources were imported from a tarball, it's time to detect which files can be regenerated and should be removed. If the project you are importing is autotools-based, then the best way to do it is to unpack the tarball into a temporary directory and try to run the following command from there (unless there is a special script like `autogen.sh`, `bootstrap` and similar in which case you should use that script instead). This also assumes you have `autoconf`, `automake` and `libtool` packages installed: |
| 55 | {{{ |
| 56 | autoreconf -fvi |
| 57 | }}} |
| 58 | The changed timestamps will tell you which files were re-generated. You may then try to remove these files and run `autoreconf` again to see if they can be actually re-generated from scratch. If they do (and look similar to the originals), you may safely remove them at this point. You may even try to build the project to double check that the build files were correctly re-generated. For our pixman project, such files are these: |
| 59 | {{{ |
| 60 | aclocal.m4 |
| 61 | compile |
| 62 | config.guess |
| 63 | config.h.in |
| 64 | config.sub |
| 65 | configure |
| 66 | depcomp |
| 67 | install-sh |
| 68 | ltmain.sh |
| 69 | Makefile.in |
| 70 | missing |
| 71 | test-driver |
| 72 | demos/Makefile.in |
| 73 | pixman/Makefile.in |
| 74 | test/Makefile.in |
| 75 | }}} |
| 76 | |
| 77 | Now you first remove these files from under SVN control with `svn rm FILENAME` (be careful not to remove necessary files!) and then commit the result with this command: |
| 78 | {{{ |
| 79 | svn commit -m "pixman: Remove generated files for version 0.32.8 from vendor." |
| 80 | }}} |
| 81 | The result is in r1224. |
| 82 | |
| 83 | Note that another important reason to re-generate as much files as possible on the developer's machine (besides saving space and history in the SVN repository) is to make sure the generated files will get OS/2-specific changes necessary for the build to work correctly. This is needed since not all OS/2 patches to the toolchain reach upstream repositories in time and hence the generated file provided in the tar ball may not know about OS/2 at all and will simply not work. Besides this, a recent version of autotools may have some important fix to apply and so on. So the developer should always re-generate these files locally before performing a build. |
| 84 | |
| 85 | The next step is to mark the result of the new vendor import with a version tag for further reference, like this ( see r1225): |
| 86 | {{{ |
| 87 | svn copy http://svn.netlabs.org/repos/ports/pixman/vendor/current http://svn.netlabs.org/repos/ports/pixman/vendor/0.32.8 -m "pixman: Tag version 0.32.8 from vendor." |
| 88 | }}} |
| 89 | |
| 90 | Now it's finally time to start off the project trunk where OS/2 development will actually take place (r1226): |
| 91 | {{{ |
| 92 | svn copy http://svn.netlabs.org/repos/ports/pixman/vendor/0.32.8 http://svn.netlabs.org/repos/ports/pixman/trunk -m "pixman: Start off trunk from version 0.32.8 from vendor." |
| 93 | }}} |
| 94 | |
| 95 | Now you can check out the trunk locally with: |
| 96 | {{{ |
| 97 | cd .. |
| 98 | svn co svn copy http://svn.netlabs.org/repos/ports/pixman/trunk |
| 99 | }}} |
| 100 | and start working on patches to make it build and work on OS/2. |
| 101 | |
| 102 | Changes should be committed to the trunk grouped into logically connected chunks, one commit per each logical modification using this commit message as a template: |
| 103 | {{{ |
| 104 | pixman: Describe your modification here in few words. |
| 105 | |
| 106 | Provide a more detailed description of this logical modification here, if necessary. |
| 107 | You may also give references to related tickets and to other commits here. |
| 108 | }}} |
| 109 | |
| 110 | '''And the last but not the least''': ''Please double-check the diff of every changed file, as well as the commit message, before you actually commit it! In SVN, it's impossible to invisibly undo a failed commit, you will have to apply a new commit with fixes for your typos, forgotten files and so on which messes up history and not good for further analysis.'' |
| 111 | |
| 112 | == Updating Sources to a New Vendor Version == |
| 113 | |
| 114 | [to be written later] |
| 115 | |
| 116 | == Old Instructions (to be removed) == |