myGUIDE random notes, random thoughts

15Sep/081

All about SVN

Subversion (or SVN) is an open source version control system that can be used to maintain several versions of files such as program source codes, webpages, and other documentation. It has several features including most CVS features, versioned copy, delete, renames, etc. Most Linux installations already include SVN so that you can use it immediately if you like. 

I started using SVN only recently to track changes I made to the source codes of programs I have written, and hence this note. SVN is quite handy as it allows you to access your source code from any computer which can access your repository. You can commit changes you made to the code in one workstation, and when you work on those codes in another workstation,  you can just update the local copy to reflect the changes you made. In the following, I'll assume that SVN is already installed.

1. Creating an SVN Repository

   1: [user@mycomp] cd
   2: [user@mycomp] mkdir Repos
   3: [user@mycomp] svnadmin create Repos

First, create a directory which will serve as the SVN repository. In the example above, a directory called Repos/ is created in the user's home directory (line 2). To tell SVN to use this as the repos, use svnadmin create command passing the directory name as the target (line 3).  After executing this command, SVN will place several directories and files in this directory. You can check the contents of Repos/ by running ls -al Repos.

2. Storing codes into the repository

   1: [user@mycomp] mkdir appwebcam
   2: [user@mycomp] mkdir appwebcam/trunk
   3: [user@mycomp] mkdir appwebcam/logs
   4: [user@mycomp] mkdir appwebcam/branches
   5: [user@mycomp] mkdir appwebcam/trunk/SRC
   6: [user@mycomp] mkdir appwebcam/trunk/bin

Now that you have your repository setup, it is time to add some data into it. You can structure the data within the repository any way you like. But usually, you'll have a main directory for a project (say, appwebcam/), then within this, you have subdirectories for trunk/, logs/, and branches/. Within the trunk/ subdirectory, you can have SRC/ subdirectory to hold your source codes, bin/ subdirectory for the binaries, etc. Lines 1-6 simply create this directory structure. 

3. Import your codes to the repository

   1: [user@mycomp] svn import ./appwebcam file:///home/user/Repos/appwebcam -m "Initial import"
   2: Adding appwebcam/trunk
   3: Adding appwebcam/trunk/SRC
   4: Adding appwebcam/trunk/bin
   5: Adding appwebcam/logs
   6: Adding appwebcam/branches

To import the created directory structure into the repository, use svn import as shown in line 1 giving the directory you want to import (./appwebcam), the location of the repository (file:///home/user/Repos/appwebcam), and an import comment option (-m "Initial import") as parameters. This will create an "invisible" directory appwebcam/ under the Repos/ directory.

4. Checking out codes from the repository

   1: [user@mycomp] svn co file:///home/user/Repos/appwebcam/trunk appwebcam
   2: A    appwebcam/SRC
   3: A    appwebcam/bin
   4: Checked out revision 1.

Finally, if you want to checkout a certain portion of your repository, use svn checkout (or svn co). In the above example, only the contents of the trunk/ subdirectory under appwebcam/ are being checkout into the appwebcam/ directory in the user's current directory. After the checkout, appwebcam/ will contain the SRC/ and bin/ subdirectories.

Tagged as: 1 Comment
5Sep/082

Generating self-signed certificate using ADT to sign AIR applications

To package an Adobe AIR application using ADT (AIR Developer Tool), a certificate is needed. Digitally signing your application with a certificate from a recognized certificate authority identifies you as the publisher. It also provides assurance to users that your application has not been accidentally or maliciously altered. For these purposes, you can get a certificate from known certificate providers such as VeriSign or Thawte. But if you're just developing an application for personal or friends' use, you can use a self-signed certificate, which can be generated using ADT. You can then use this certificate to sign your personal AIR applications :-) .

To generate the certificate, run the following command:

adt -certificate -cn name [-ou org_unit][-o org_name][-c country] key_type pfx_file password

where -cn name is the common name that will be used for the generated certificate, -ou org_unit refers to the organizational unit issuing the certificate, -o org_name is the name of the organization issuing the certificate, -c country is a two-letter ISO-3166 country code, key_type can either be "1024-RSA" or "2048-RSA" pfx_file is the name of the file where the certificate will be stored, and password is the certificate's password. The parameters inside square brackets are optional.

As an example, the actual command may look like this:

   1: adt -certificate -cn "My Certificate" -ou bagarinao.com -o "ABK Co" -c US 2048-RSA myCert.p12 sd#$wd23

   2: adt -certificate -cn "AIR App" 1024-RSA MyCert.p12 sd#$wd23

The first line illustrates how to generate a certificate specifying all the possible parameters. On the other hand, the second line only uses the required parameters in generating the certificate. Both will generate a new certificate and will store it in a file called myCert.p12 with password sd#$wd23.

To use the generated certificate to sign an AIR application, use adt using the -package option instead of the -certificate option. Use -storetype pkcs12, -keystore myCert.p12, and -keypass sd#$wd23 to specify the certificate that will be used to sign the application. The command is something like

adt -package -storetype pkcs12 -keystore myCert.p12 -keypass sd#$wd23 <airfile> <app-desc> other-files ..

where <airfile> is the name of your package, <app-desc> specifies the XML application descriptor file, and other-files are the files and directories that you want to package with your air application.