Sie sind auf Seite 1von 18

Operating Systems PS-2

GCC, Source Control,

Building Minix
Can Kavaklolu

Source Control (Versioning)

o diff, emails

o subversion (svn), cvs

o git, mercurial (hg)

Manual Versioning
diff command
o cp a a.orig
o <edit a>
o diff a.orig a > a.patch

Send email
o a.patch

patch command
o patch b a.patch

Centralized Versioning
Versioning server
Clients commit to server
Can not commit conflicting versions
Clients checkout only from server
Revert from local hidden folder

Distributed Versioning
No servers
Clients commit to local repository
o local versioning!

Clients pull/push to any repository

Revert from local hidden folder
Need a deployment policy

Basic Git Usage

Create a new
o git init

Create a bare
o git init --bare

Repository status
o git status

Add files to track

o git add file
o Can not add

Move files
o git mv file newfile

Remove files
o git rm newfile

Commit (all)
o git commit file -m
"log comment"
o git commit -a -m "log

Who wrote this line

Basic Git Usage

Add remote repository
o git remote add ck ssh://

Clone from remote repository

o git clone ssh://

List remote repositories

o git remote -v
o "origin"

Pull / push to remote repository

o git pull
o git push
o git pull

Basic Git Usage

Inspect log
o git log
o git log v0.01..v0.02

Diff with previous version

o git diff HEAD^ HEAD

Tag code
o git tag v0.1

Checkout previous versions

o git checkout <prev_version_hash>
o git checkout <tag>

Basic Git Usage

Create branches for experimenting
o git branch
o examples on help!

User configuration
o git config --global "John Doe"
o git config --global ""

Getting help
o git help
o git help commit

Why Build?
Scripting languages
o bash, perl, python, php, javascript

Object code
o java

Native binary
o C, C++

Building Native Applications

in Linux
Simple method
o g++ my.c

A little bit more involved

o g++ -c my.c -o my.o
o g++ my.o -o my
o file *

What happened here?

Building a Static Library

Create archive
o ar -cvq libmylib.a mylib.o mylib2.o

Contents of archive
o ar -t libmylib.a

Create executable
o g++ test.cpp libmylib.a
o g++ test.cpp -L. -lmylib

Run executable anywhere

Building a Dynamic Library

Create shared library
o g++ -Wall -fPIC -c mylib.cpp mylib2.cpp
o g++ -shared -Wl,-soname, -o mylib.o mylib2.o

Build with shared library

o ln -s
o g++ -Wall -I. -L. -lmylib test.cpp

Execute using shared library

o in same directory
o export LD_LIBRARY_PATH=$(pwd)/dynamic
o ./dynamic/a.out

Building Minix
Take snapshot first!
cd /usr/src
make world

Boot with default kernel
o "Start Minix 3" , option 1 in boot menu

Use virtualization snapshot backup

Command Line Access

Network problems?
o Select "Bridged Adapter" from
Virtual Box > Machine >Settings

Do not like tty console?

o pkgin update (only once)
o pkgin install openssh
o set root password
o reboot
o login with ssh

Is ssh server running?

o find / | grep sshd

Compile your own Minix kernel

Optional Homework
Research and report on ssh private key
authentication method
Write a c/c++ program in Ubuntu as follows:
o Main function calls funciton 1 and function 2
o Functions 1 and 2 write hello and world!
o Write a Makefile that has compiling with dynamic
library and compiling with static library options
o Build the project in Minix. If you encounter problems,
research on and try to overcome them

List and define basic clang options

List and define basic git options