2013年9月28日土曜日

Setting up a PC to run Linux/Fedora while keeping Windows install




Task 1 Prepare a USB drive with Fedora installation source

Why?

We need a media that contains Fedora on either CD/DVD or USB thumb drive. I chose USB drive since I have several old USB drives with smaller capacity sitting around at home.

How big should USB drive be?

Fedora 19 installation files is 951 MB. I used 2GB USB drive.


How do I "burn" Fedora installation image to USB drive?


You need to run a program called "USB Live Creator" which is available here.


Once you finish installing USB Live Creator, start the tool.


  • Select an appropriate Fedora image from "Download Fedora" drop-down
  • Insert your USB drive to your PC, and then select it at "Target Device" drop-down

(Press "Refresh" icon as necessary)


Once finished, you have an USB drive from which you can boot up a PC with Fedora.

Task 2 Parepare a USB drive with a partition tool

Why?

In order to keep your existing Windows OS, I need to free up my C: drive on my notebook computer.

I used a tool called Gnome Partition Editor (or Gparted for short). To use Gparted, you need to prepare a media with Gparted on it. I chose yet another USB thumb drive for that (but you can burn a CD too).

The size of Gparted is about 160MB. I have another 1GB USB drive that is used for anything useful at home (I bought this USB drive long time ago, paid $200 dollars back then, thinking it is a good investment! Now the price is so cheap that this is just a junk in my shoe box, but it now has some good use!)

How do I create a USB drive with Gparted?


I used a tool called "Tuxboot", which is available at SourceForge.

Once you download and lunch tuxboot,

  • Select "gparted-live-stable" under "On-Line Distribution" drop-down box (try "gparted-live-testing" if something goes wrong. I had to do that)
  • Select "USB Drive" at "Type:" drop-down.
  • Select an appropriate drive pointing to your USB drive.




Task 3 Prepare your hard drive with free partition

How to reboot using Gparted?

  • Shut down your PC
  • Insert your USB drive into a USB socket
  • Start your PC
  • While the machine is starting up, hit F12 to go to boot menu (NOTE: this key depends on you machine. Carefully watch the initial screen and look for "Boot menu")


At the boot menu, choose USB drive from the list of boot device 



Then, let Gparted start. Provide answers to a series of simple questions. Eventually Gparted user interface shows up.

How to shrink the Windows partition to free up space

With Gparted user interface, you can easily shrink a partition: use mouse to re-size, or punch in a number. As for the size, I chose to simply cut my 500GB drive into half: one for Window and the other for Linux.

How to reserve a primary partition for /home directory (Optional)


You can have an independent partition to be mounted as /home directory so that whenever I need to re-install Linux, I don't lose my data and some applications.

I created a primary partition of 100GB in size. The remaining free space will be used for other part of Linux installation.

Note that this step is optional. If you don't care, just leave the half of the HDD as "free"..

Here is the final state of my C: drive before I quit Gparted.


When you are happy, shut down the machine, and un-plug your USB with Gparted on it.


Step 4 Install Fedora using the USB drive

We will be using the USB drive, which contains Fedora, we created earlier.


  • Remove Gparted USB drive, if its still there
  • Insert the USB drive with Fedora into an USB slot
  • Restart your machine
  • Hit F12 to go to boot menu, then select USB drive.
  • Let Fedora OS to load.

Once Fedora is loaded from USB drive, you will see this choice. Choose "Install to Hard Drive"



Follow instructions. Everything is straightforward, except maybe the part where you configure disk storage.

How to mount my 100GB partition for /home directory


While configuring storage/partitions for Fedora install, I need to tell the install to use my 100GB partition to be mounted to /home

First, select a partition that corresponds to the 100GB partiion. In my case, it is listed as below.


Then, look at the right hand side pane. You can specify "/home" under "Mount Point:" field.



Configure other partitions


I followed information described in Fedora Recommended Partitioning Scheme to set up other major partitions such as /boo, root (/), swap, etc.

My final partitions look like this.



Complete Fedora installation

You need to at least provide a password for super user. Once done, just continue with the instructions.

You are done!

2013年9月19日木曜日

Setting up a HelloWorld Java project with Git and Jenkins under 5 minutes

What is assumed

  • Java is installed
  • Git is installed
  • Jenkins is installed

1. Create a HelloWorld java program



$ mkdir hello


$ emacs HelloWorld.java (or Notepad HelloWorld.java on Windows)


public class HelloWorld {
  public static void main (String[] args) {
    System.out.println("Hello World !!");
  }



$ emacs run.sh (Let's create a script to compile and run. Its Notepad run.bat on Windows)


javac HelloWorld.java
java HelloWorld


$ run.sh (execute the script you just created. Its run.bat on Windows)

2. Create a Git repository for HelloWorld source



$ git init


$ git add HelloWorld.java run.sh


$ git commit -m "created"


$ git log

3. Create a Jenkins job to get latest code from the Git repository and then build and run HelloWorld project



1. In Jenkins, bring up "Manage Plugins" screen




2. Make sure that Jenkins GIT plugin is installed. If not, install it.




3. Create a new Jenkins Job.



Name this job "git_test".


4. In the job configuration page, choose Git for "Source Code Management" and then set "Repository URL" point to your Git repository.




To figure out a string to put in to "Repository URL" box, see my local path to the Git repository can compare with you environment.

[tsuyoshi_watanabe@ywatanabe hello]$ pwd
/home/tsuyoshi_watanabe/sandbox/gittest/hello


5. Add run.sh script as a new build step





4. Putting all together

Choose "Build Now" for our newly created job.






Now, Jenkins hit our Git repository to clone a temporary source tree, and then execute our "run.sh" script.

2013年9月18日水曜日

Test publish a Jar file to your local Artifactory from Gradle build under 5 minutes

What you need:



What is assumed


  • Artifactory is installed at its factory default port 8081
  • Artifactory's pre-configured "admin" user's password is "password" (default)

Steps


1. Create a copy of Java Quickstart

2. Open build.gradle file and replace the content with the gradle script in the following:


buildscript {
    repositories {
        maven {
            url 'http://localhost:8081/artifactory/plugins-release'
            credentials {
                username = "admin"
                password = "password"
            }
        }
    }
    dependencies {
        classpath(group: 'org.jfrog.buildinfo', name: 'build-info-extractor-gradle', version: '2.0.9')
    }
}

apply plugin: 'java'
apply plugin: 'artifactory'
apply plugin: 'maven'

sourceCompatibility = 1.5
version = '1.0.2'
group = 'test.quickstart'

jar {
    manifest {
        attributes 'Implementation-Title': 'Gradle Quickstart', 'Implementation-Version': version
    }
}


dependencies {
    compile group: 'commons-collections', name: 'commons-collections', version: '3.2'
}

artifactory {
    contextUrl = "http://localhost:8081/artifactory"   //The base Artifactory URL if not overridden by the publisher/resolver
    publish {
        repository {
            repoKey = 'libs-release-local'
            username = "admin"
            password = "password"
            maven = true
            
        }
    }
    resolve {
        repository {
            repoKey = 'libs-release'
            username = "admin"
            password = "password"
            maven = true
            
        }
    }
}

3. At command prompt, run $ gradle artifactoryPublish

4. Verify that Quickstart.jar file is added to artifactory by checking localhost:8081

Done.

Yet another GIT tutorial under 5 minutes.

At your command prompt, type "git", Nothing happens? Please Google "How to install GIT" and come back.

Just keep typing the following and observe what happens. (This procedure is based on this blog).

Start at any junk directory/folder such as temp.

Start!


$ mkdir gittest


cd gittest


mkdir example.git


cd example.git


git init --bare


cd ..


git clone example.git example1


cd example1


$ emacs test.txt (use Notepad on Windows)


Type "hello" in test.txt, and then save and close notepad.


git add test.txt


git status 


git commit -a -m "new file added."


git status


git push origin master


cd ..


git clone example.git example2


cd example2


git log


emacs test.txt


Type "I am using GIT!" in test.txt, and then save and close notepad.


git status


git commit -a -m "added another line."


git status


git push origin master


cd ../example1


git log


git pull


git log


Done!


You have just simulated a typical coding cycles using any version control system.
  1. Created a new repository for the team
  2. A team member added a new source file (initial implementation)
  3. Another team member modified the file (bug fix)
  4. The first team member received the fix made by his buddy.