Sie sind auf Seite 1von 18

Operating Systems PS-2

GCC, Source Control,


Building Minix
Can Kavaklolu
Contact: eposta@cankavaklioglu.name.tr

Source Control (Versioning)


Manual
o diff, emails

Centralized
o subversion (svn), cvs

Distributed
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
repository
o git init

Create a bare
repository
o git init --bare

Repository status
o git status

Add files to track


o git add file
o Can not add
directories!

Move files
o git mv file newfile

Remove files
o git rm newfile

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

Who wrote this line

Basic Git Usage


Add remote repository
o git remote add ck ssh://can@ck.name.tr/~/gittir/code

Clone from remote repository


o git clone ssh://can@ck.name.tr/~/gittir/code

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 user.name "John Doe"
o git config --global user.email "johndoe@minix3.org"

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
or
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,libmylib.so.1 -o libmylib.so.1 mylib.o mylib2.o

Build with shared library


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

Execute using shared library


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

Building Minix
Take snapshot first!
cd /usr/src
make world
reboot
Alternatives
o http://wiki.minix3.org/en/DevelopersGuide/RebuildingSystem

Recovering
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
o

Todo
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!
respectively
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