diff options
author | Andoni Morales Alastruey <ylatuya@gmail.com> | 2012-11-14 17:33:32 +0100 |
---|---|---|
committer | Andoni Morales Alastruey <ylatuya@gmail.com> | 2012-11-14 17:33:32 +0100 |
commit | 687bea1ead80280cadff68c46936654f9ad2e771 (patch) | |
tree | 9001b185328a6de76633674c60fcfbf860739724 /tools | |
parent | 337cfdd44bbe460ad3806c8c76ce10661d42645b (diff) |
Add a new tool to build release for other distros
Diffstat (limited to 'tools')
-rw-r--r-- | tools/bootstrap-debian.sh | 48 | ||||
-rw-r--r-- | tools/bootstrap-redhat.sh | 41 | ||||
-rw-r--r-- | tools/build-release.sh | 81 |
3 files changed, 170 insertions, 0 deletions
diff --git a/tools/bootstrap-debian.sh b/tools/bootstrap-debian.sh new file mode 100644 index 00000000..2f15d04f --- /dev/null +++ b/tools/bootstrap-debian.sh @@ -0,0 +1,48 @@ +#!/bin/sh + +set -e + +CHROOT_PREFIX=$1 +DISTRO=$2 +DISTRO_VERSION=$3 +ARCH=$4 +USER=$5 + +CHROOT_PATH=$CHROOT_PREFIX/$DISTRO-$DISTRO_VERSION-$ARCH + +die() { + echo "ERROR: $@" + exit 1 +} + +if test $DISTRO = "ubuntu"; then + mirror=http://archive.ubuntu.com/ubuntu + cerbero_distro=debian +elif test $DISTRO = "debian"; then + mirror=http://ftp.debian.org/debian + cerbero_distro=debian +else + die "invalid distro $DISTRO" +fi + +cerbero_distro_version="$DISTRO"_"$DISTRO_VERSION" + +echo "bootstraping $DISTRO-$DISTRO_VERSION" +debootstrap --arch=$ARCH $DISTRO_VERSION $CHROOT_PATH $mirror + +echo "installing sudo" +chroot $CHROOT_PATH apt-get -y --force-yes install sudo + +echo "installing git" +chroot $CHROOT_PATH apt-get -y --force-yes install git-core + +echo "installing python and python-argparse" +chroot $CHROOT_PATH apt-get -y --force-yes install python python-argparse + +echo "installing locales" +chroot $CHROOT_PATH apt-get -y --force-yes install locales +chroot $CHROOT_PATH locale-gen en_GB.UTF-8 + +echo "installing vim" +chroot $CHROOT_PATH apt-get -y --force-yes install vim +chroot $CHROOT_PATH update-alternatives --set editor /usr/bin/vim.basic diff --git a/tools/bootstrap-redhat.sh b/tools/bootstrap-redhat.sh new file mode 100644 index 00000000..ae42037b --- /dev/null +++ b/tools/bootstrap-redhat.sh @@ -0,0 +1,41 @@ +#!/bin/sh + +set -e +set -x + +CHROOT_PREFIX=$1 +DISTRO=$2 +DISTRO_VERSION=$3 +ARCH=$4 +USER=$5 + +CHROOT_PATH=$CHROOT_PREFIX/$DISTRO-$DISTRO_VERSION-$ARCH + +die() { + echo "ERROR: $@" + exit 1 +} + +echo "bootstraping $DISTRO-$DISTRO_VERSION" + +apt-get install yum rpm + +echo "installing mock" + +set +e +groupadd -r mock +usermod -G $USER mock +git clone git://git.fedorahosted.org/git/mock.git mock +set -e + +cd mock +./autogen.sh +./configure +make +make install +mock -r $DISTRO-$DISTRO_VERSION-$ARCH --init --resultdir=~/mock +rm -f $CHROOT_PATH +ln -s /var/lib/mock/$DISTRO-$DISTRO_VERSION-$ARCH/root $CHROOT_PATH + +echo "installing yum git and vim" +mock -r $DISTRO-$DISTRO_VERSION-$ARCH install git yum vim --resultdir=~/mock diff --git a/tools/build-release.sh b/tools/build-release.sh new file mode 100644 index 00000000..d5a83c20 --- /dev/null +++ b/tools/build-release.sh @@ -0,0 +1,81 @@ +#!/bin/sh +# usage: +# $ sudo sh tools/build-release.sh ~/cerbero/roots redhat fedora 16 x86_64 username +# $ sudo sh tools/build-release.sh ~/cerbero/roots debian debian squeeze i386 username +set -e + +CHROOT_PREFIX=$1 +DISTRO_FAMILY=$2 +DISTRO=$3 +DISTRO_VERSION=$4 +ARCH=$5 +USER=$6 + +CHROOT_PATH=$CHROOT_PREFIX/$DISTRO-$DISTRO_VERSION-$ARCH +BASEDIR=$(dirname $0) + +die() { + echo "ERROR: $@" + exit 1 +} + +sh $BASEDIR/bootstrap-$DISTRO_FAMILY.sh $CHROOT_PREFIX $DISTRO $DISTRO_VERSION $ARCH $USER + +cerbero_distro=`echo $DISTRO_FAMILY | awk '{print toupper($0)}'` +cerbero_distro_version=`echo "$DISTRO"_"$DISTRO_VERSION" | awk '{print toupper($0)}'` + +cp /etc/resolv.conf $CHROOT_PATH/etc/resolv.conf +cp /etc/hosts $CHROOT_PATH/etc/hosts +hostname=$USER-$DISTRO-$DISTRO_VERSION-$ARCH-chroot +# hostnames cannot contain _ +hostname=$(echo $hostname | sed s/'_'/'-'/g) +#echo $hostname > $CHROOT_PATH/etc/hostname +#chroot $CHROOT_PATH hostname $hostname +echo $hostname > $CHROOT_PATH/etc/debian_chroot + +userid=$(grep $USER /etc/passwd | cut -d: -f3) +echo "$USER:x:$userid:$userid:$USER,,,:/home/$USER:/bin/bash" >> $CHROOT_PATH/etc/passwd +echo "$USER::15460::::::" >> $CHROOT_PATH/etc/shadow +echo "$USER:x:$userid:" >> $CHROOT_PATH/etc/group +echo "$USER ALL=NOPASSWD: ALL" >> $CHROOT_PATH/etc/sudoers + +echo "copying user git/ssh/gpg configurations" +mkdir -p $CHROOT_PATH/home/$USER + +cp -f /home/$USER/.gitconfig $CHROOT_PATH/home/$USER/ +cp -rf /home/$USER/.ssh $CHROOT_PATH/home/$USER/ +chmod -R 700 $CHROOT_PATH/home/$USER/.ssh/ +cp -rf /home/$USER/.gnupg $CHROOT_PATH/home/$USER/ +chmod -R 700 $CHROOT_PATH/home/$USER/.gnupg/ + +echo "copying vim configuration files and installing/setting vim as default editor" +cp -f /home/$USER/.vimrc $CHROOT_PATH/home/$USER/ +cp -rf /home/$USER/.vim $CHROOT_PATH/home/$USER/ + +echo "generating cerbero tarball" +make dist-tarball +echo "extracting tarball at $CHROOT_PATH/home/$USER/git" +mkdir -p $CHROOT_PATH/home/$USER/git +tar --bzip2 -xvf dist/cerbero-0.1.0.tar.bz2 -C $CHROOT_PATH/home/$USER/git/ +cp -rf .git $CHROOT_PATH/home/$USER/git/cerbero-0.1.0/ + +echo "generating $CHROOT_PATH/home/$USER/.cerbero/cerbero.cdc from template" +mkdir -p $CHROOT_PATH/home/$USER/.cerbero +cp -f tools/cerbero.cbc.template $CHROOT_PATH/home/$USER/.cerbero/cerbero.cbc +echo "distro = Distro.$cerbero_distro" >> $CHROOT_PATH/home/$USER/.cerbero/cerbero.cbc +echo "distro_version = DistroVersion.$cerbero_distro_version" >> $CHROOT_PATH/home/$USER/.cerbero/cerbero.cbc +sudo mkdir -p $CHROOT_PATH/opt/gstreamer-sdk + +echo "fixing permissions" +chown -R $USER:$USER $CHROOT_PATH/home/$USER +chown -R $USER:$USER $CHROOT_PATH/opt/gstreamer-sdk + +echo "mounting /proc and /sys" +mount -o bind /proc $CHROOT_PATH/proc +mount -o bind /sys $CHROOT_PATH/sys + +echo "chroot created" + +echo "starting the build" +echo "cd ~/git/cerbero-0.1.0 && ./cerbero-uninstalled bootstrap && ./cerbero-uninstalled package gstreamer-sdk" > $CHROOT_PATH/home/$USER/run_package +chroot $CHROOT_PATH su $USER /home/$USER/run_package |