Debian Wheezy: server setup/configuration

# Change default Language:
dpkg-reconfigure locales

# Change font size of tty:
setfont /usr/share/consolefonts/Lat15-Terminus24x12.psf.gz

# Change default font size for all tty:
nano /etc/default/console-setup
–FONTFACE=”Fixed”
–FONTSIZE=”8×16″
++FONTFACE=”LAT15-Terminus”
++FONTSIZE=”24×12″

/etc/init.d/console-setup restart

# Update /etc/apt/source.list

# wheezy
deb http://debian.ustc.edu.cn/debian/ wheezy main
deb-src http://debian.ustc.edu.cn/debian/ wheezy main

deb http://debian.ustc.edu.cn/debian/ wheezy non-free
deb-src http://debian.ustc.edu.cn/debian/ wheezy non-free

deb http://debian.ustc.edu.cn/debian/ wheezy contrib
deb-src http://debian.ustc.edu.cn/debian/ wheezy contrib

# security
deb http://security.debian.org/ wheezy/updates main
deb-src http://security.debian.org/ wheezy/updates main

# updates
deb http://debian.ustc.edu.cn/debian/ wheezy-updates main
deb-src http://debian.ustc.edu.cn/debian/ wheezy-updates main

deb http://debian.ustc.edu.cn/debian/ wheezy-updates non-free
deb-src http://debian.ustc.edu.cn/debian/ wheezy-updates non-free

deb http://debian.ustc.edu.cn/debian/ wheezy-updates contrib
deb-src http://debian.ustc.edu.cn/debian/ wheezy-updates contrib

# proposed updates
deb http://debian.ustc.edu.cn/debian/ wheezy-proposed-updates main
deb-src http://debian.ustc.edu.cn/debian/ wheezy-proposed-updates main

deb http://debian.ustc.edu.cn/debian/ wheezy-proposed-updates non-free
deb-src http://debian.ustc.edu.cn/debian/ wheezy-proposed-updates non-free

deb http://debian.ustc.edu.cn/debian/ wheezy-proposed-updates contrib
deb-src http://debian.ustc.edu.cn/debian/ wheezy-proposed-updates contrib

# backports
deb http://debian.ustc.edu.cn/debian/ wheezy-backports main
deb-src http://debian.ustc.edu.cn/debian/ wheezy-backports main

deb http://debian.ustc.edu.cn/debian/ wheezy-backports non-free
deb-src http://debian.ustc.edu.cn/debian/ wheezy-backports non-free

deb http://debian.ustc.edu.cn/debian/ wheezy-backports contrib
deb-src http://debian.ustc.edu.cn/debian/ wheezy-backports contrib

 

# Install mouse daemon

apt-get install gpm

 

Mirror SVN repository

#!/bin/bash
SVN=/mirror/svn
PRJ=”DD-WRT”
BASE=${SVN}/${PRJ}
MIRROR=file://$BASE
MASTER=svn://svn.dd-wrt.com/${PRJ}
BUILD=”/build”

[[ ! -d ${BASE} ]] && {
svnadmin create ${BASE}

cat > ${BASE}/hooks/pre-revprop-change <<EOF
#!/bin/sh
exit 0
EOF

chmod +x ${BASE}/hooks/pre-revprop-change

svnsync init ${MIRROR} ${MASTER}
}

# list
svn proplist –verbose –revprop -r 0 ${MIRROR}

#sync mirror against master
svnsync –non-interactive sync ${MIRROR}

# list
#svn proplist –verbose –revprop -r 0 ${MIRROR}

exit

# Checkout build
mkdir ${BUILD}/${PRJ}
cd ${BUILD}/${PRJ}
svn checkout -q ${MIRROR}/branches/devel ${PRJ}-devel

#Update build against mirror
cd ${BUILD}/${PRJ}
svn update
svn log –verbose –limit 3

# build image
# http://www.dd-wrt.com/wiki/index.php/Development/zh_cn

clone svn repository into git

## Install git-svn tool
# if CentOS
yum install subversion-perl

# if Ubuntu
sudo apt-get install libsvn-perl

## In git server, Create empty repo of exfat as my project

## Create Bare repo of /repo/exfat
cd /repo
git init --bare exfat.git
cd exfat.git
cp hooks/post-update.sample hooks/post-update
git symbolic-ref HEAD refs/remotes/trunk

## Clone svn with git-svn in work repo of /repo/svn/exfat
cd /repo/svn
git svn clone -s http://exfat.googlecode.com/svn /repo/svn/exfat
cd exfat
git config core.worktree /repo/svn/exfat
git gc

## Convert SVN Tag to Git Tag
/usr/local/bin/svn2git

##   Add svn ignore, if have
git svn show-ignore > .gitignore
git add .gitignore
git commit -m ‘Convert svn:ignore properties to .gitignore.’

# # Push git rep to bare repository
git remote add origin /repo/exfat.git
git push origin –mirror

## Put other svn branch into bare repo
# git branch -r
git checkout -t -b svn-trunk trunk
git push origin –mirror

git checkout -t -b svn-v1.0.x v1.0.x
git push origin –mirror

 

## Verify by checkout in workstation

cd /tmp/test
git clone ssh://git.zhenglei.net/repo/exfat.git
cd exfat

setup git server on centos 5

# Install Git on git.zhenglei.net
yum install expat-devel zlib-devel gettext-devel openssl-devel
unzip git-1.7.2.5.zip
cd git-1.7.2.5
make prefix=/usr/local install

## Create empty repository of test.git in /repo of git.zhenglei.net
mkdir /repo
cd /repo
GIT_DIR=test.git git init
cd test.git
git –bare update-server-info
cp hooks/post-update.sample hooks/post-update

## Access git.zhenglei.net via port XXXX over ssh
# Config ssh on workstation
echo “Host git.zhenglei.net” >>~/.ssh/config
echo “hostname git.zhenglei.net”>>~/.ssh/config
echo port XXXX >>~/.ssh/config

## Clone test.git
git clone ssh://root@git.zhenglei.net/repo/test.git

## Add README in local
cd test
touch README
git add README
git commit -m “add readme”

## Push back to server
git push origin master

Script to Build Android Kernel Under Ubuntu

#!/bin/bash
#
ANDROID=”android-4.1.1_r6.1″
GCC=4.4.3

KERNEL=goldfish
KCONFIG=goldfish_armv7_defconfig

#GIT_SERVER=aosp.zhenglei.net
GIT_SERVER=127.0.0.1
GIT_PATH=”git/aosp”

PREBUILT=prebuilt
HOST=”linux-x86″
ARCH=”arm”
BUILD_PATH=”build”

function get_Tool {
LOC=”$1″
TAG=”$2″
VER=”$3″
TOOL_CHAIN=${ARCH}-eabi-${GCC}

if [ ! -d ${LOC}/${TOOL_CHAIN} ];then
if [ ! -d ${PREBUILT}/${TOOL_PATH} ];then
if [ -d ${PREBUILT} ];then
rm -rf ${PREBUILT}
fi
git clone git://${GIT_SERVER}/${GIT_PATH}/platform/prebuilt
fi

cd ${PREBUILT}
CUR_BRANCH=`git branch|grep “^* “|sed “s/^* //”`
if [ “${CUR_BRANCH}” != “${TAG}” ];then
#    git tag -l
git checkout -b ${TAG}
fi
cd ..

cp -r ${PREBUILT}/${HOST}/toolchain/${TOOL_CHAIN} ${LOC}

fi
TOOL_PATH=”`pwd`/${LOC}/${TOOL_CHAIN}”
}

function get_Kernel {
kernel=”$1″
if [ ! -d ${kernel} ];then
git clone git://${GIT_SERVER}/${GIT_PATH}/kernel/${kernel}.git
fi

cd ${kernel}
# git branch -a
CUR_BRANCH=`git branch|grep “^* “|sed “s/^* //”`
if [ “${CUR_BRANCH}” != “${kernel}” ];then
git checkout -t remotes/origin/android-${kernel}-2.6.29 -b ${kernel}
fi
if [ ! -d ../${BUILD_PATH}/${kernel} ];then
mkdir ../${BUILD_PATH}/${kernel}
git archive –format tar HEAD|tar x -C ../${BUILD_PATH}/${kernel}/
fi
cd ..
}

function build_Kernel {
config=$1
cd ${BUILD_PATH}/${kernel}
#ls -l arch/${ARCH}/configs/
make ${config}

START=`date +%s`
echo “Start to build at time:  $START”
echo “################################”
echo
echo

make -j4

echo
echo
echo “################################”
FINISH=`date +%s`
echo “Finish build at time: $FINISH”
echo
ELAPSED=`expr $FINISH – $START`
echo “Elapsed time: $ELAPSED”
cd ..
cd ..
}

##### Main ######
if [ ! -d ${BUILD_PATH} ];then
mkdir ${BUILD_PATH}
fi

rm -rf ${BUILD_PATH}/*

get_Tool $BUILD_PATH $ANDROID $GCC

export ARCH=arm
export SUBARCH=arm
export CROSS_COMPILE=arm-eabi-
export PATH=${TOOL_PATH}/bin:$PATH

get_Kernel $KERNEL

build_Kernel $KCONFIG

# Output

cp ${BUILD_PATH}/${KERNEL}/arch/${ARCH}/boot/zImage ${BUILD_PATH}/${KERNEL}/

# Luanch emulator with build kernel
# emulator -kernel ${KERNEL}/zImage