Visar inlägg med etikett linux. Visa alla inlägg
Visar inlägg med etikett linux. Visa alla inlägg

onsdag 25 januari 2012

Gitosis

Adapted from http://blog.agdunn.net/?p=277


pacman -S git-core setuptools
useradd --home-dir=/media/STORAGE/git --create-home --system git
su -l git

git clone git://eagain.net/gitosis.git
cd ~/gitosis
patch gitosis/ssh.py <<EOF
37c37
<     TEMPLATE=('command="gitosis-serve %(user)s",no-port-forwarding,'
---
>     TEMPLATE=('command=".local/bin/gitosis-serve %(user)s",no-port-forwarding,'
EOF
patch gitosis/templates/admin/hooks/post-update <<EOF
3c3
< gitosis-run-hook post-update
---
> ~/.local/bin/gitosis-run-hook post-update
EOF
git commit -a -m 'Adapt Gitosis for being installed with python setup.py install --user' --author 'Lars Rasmusson <Lars.Rasmusson@gmail.com>'
python2.7 setup.py install --user

~/.local/bin/gitosis-init  
[ paste your public ssh key and press CTRL-D ]

chmod u+x ~/repositories/gitosis-admin.git/hooks/post-update

Now you can clone the repository gitosis-admin.git from the server using

git clone git@servername:gitosis-admin.git


To add a user with pubkey file username.pub


cp username.pub gitosis-admin/keydir/
(cd gitosis-admin; git commit keydir -m 'added user'; git push)

To give the user access to a repository, add him to a group
(or create a new group for him), and add the repository name
to the ‘writable’ list for that group in gitosis-admin/gitosis.conf



tisdag 15 juni 2010

Building a gcc cross compiler

This was based on an example from http://www.arklyffe.com/main/content/arm-gcc-toolchain-build, but I had to use --disable-multilib to get gcc to compile. Or else, it would fail some of its ./configuration steps (I think for instance libz failed).

Note that gcc is built twice, once to get a boot strap compiler that can compile newlib for the target platform, and then again to compile gcc to use newlib as its C library.

# build tool chain
TARGET=arm-none-eabi
TARGET=i486-none-elf
INSTALL=$HOME/test/$TARGET
GCC_VER=4.5.0
###

export PATH=$INSTALL/bin:$PATH

mkdir $INSTALL
cd $INSTALL
mkdir build
cd build

(
wget http://ftp.sunet.se/pub/gnu/gmp/gmp-5.0.1.tar.bz2 &
wget http://ftp.sunet.se/pub/gnu/mpfr/mpfr-2.4.2.tar.bz2 &
wget http://ftp.sunet.se/pub/gnu/gcc/infrastructure/mpc-0.8.1.tar.gz &
wait
)

tar -xjf gmp-5.0.1.tar.bz2
tar -xjf mpfr-2.4.2.tar.bz2
tar -xzf mpc-0.8.1.tar.gz

(
wget http://ftp.sunet.se/pub/gnu/binutils/binutils-2.20.tar.bz2 & 
wget http://ftp.sunet.se/pub/gnu/gcc/releases/gcc-$GCC_VER/gcc-core-$GCC_VER.tar.bz2 &
wget http://ftp.sunet.se/pub/gnu/gcc/releases/gcc-$GCC_VER/gcc-g++-$GCC_VER.tar.bz2 &
wget http://ftp.sunet.se/pub/gnu/gdb/gdb-7.1.tar.bz2 &
wait
)
tar -xjf binutils-2.20.tar.bz2
tar -xjf gcc-core-$GCC_VER.tar.bz2
tar -xjf gcc-g++-$GCC_VER.tar.bz2
tar -xjf gdb-7.1.tar.bz2

wget ftp://sources.redhat.com/pub/newlib/newlib-1.18.0.tar.gz
tar -xzf newlib-1.18.0.tar.gz

mkdir gmp-5.0.1/build; cd gmp-5.0.1/build
../configure --prefix=$INSTALL/build/gmp --disable-shared --enable-static
make -j8 && make install
cd ../../
mkdir mpfr-2.4.2/build; cd mpfr-2.4.2/build
../configure --prefix=$INSTALL/build/mpfr --with-gmp=$INSTALL/build/gmp \
   --disable-shared --enable-static
make -j8 && make install
cd ../../
mkdir mpc-0.8.1/build; cd mpc-0.8.1/build
../configure --prefix=$INSTALL/build/mpc --with-gmp=$INSTALL/build/gmp \
   --with-mpfr=$INSTALL/build/mpfr --disable-shared --enable-static
make -j8 && make install
cd ../../

patch -l -p0 <<EOF
--- binutils-2.20/gas/as.h      2010-06-15 18:49:19.771279712 +0000
+++ binutils-2.20/gas/as.h      2010-06-15 18:50:10.400278790 +0000
@@ -238,7 +238,7 @@
 #define know(p) gas_assert(p)  /* Verify our assumptions!  */
 #endif /* not yet defined */
 #else
-#define know(p)                        /* know() checks are no-op.ed  */
+#define know(p)        do {} while(0)  /* know() checks are no-op.ed  */
 #endif
 
 /* input_scrub.c */
EOF

mkdir binutils-2.20/build; cd binutils-2.20/build
../configure --prefix=$INSTALL --target=$TARGET --enable-interwork \
   --enable-multilib --disable-nls --disable-shared --disable-threads \
   --with-gcc --with-gnu-as --with-gnu-ld
make -j8 && make install
cd ../../

mkdir gcc-$GCC_VER/build; cd gcc-$GCC_VER/build
../configure --prefix=$INSTALL --target=$TARGET --enable-interwork \
   --disable-multilib --enable-languages=c --with-newlib --disable-nls \
   --disable-shared --disable-threads --with-gnu-as --with-gnu-ld \
   --with-gmp=$INSTALL/build/gmp --with-mpfr=$INSTALL/build/mpfr \
   --with-mpc=$INSTALL/build/mpc --without-headers
make -j8 all-gcc && make install-gcc
cd ../../

mkdir newlib-1.18.0/build; cd newlib-1.18.0/build
../configure --prefix=$INSTALL --target=$TARGET --enable-interwork \
   --enable-multilib --with-gnu-as --with-gnu-ld --disable-nls 
make -j8 && make install
cd ../../

rm -rf gcc-$GCC_VER/build
mkdir gcc-$GCC_VER/build; cd gcc-$GCC_VER/build
../configure --prefix=$INSTALL --target=$TARGET --enable-interwork \
   --disable-multilib --enable-languages=c,c++ --with-newlib --disable-nls \
   --disable-shared --disable-threads --with-gnu-as --with-gnu-ld \
   --with-gmp=$INSTALL/build/gmp --with-mpfr=$INSTALL/build/mpfr \
   --with-mpc=$INSTALL/build/mpc
make -j8 && make install
cd ../../

tisdag 25 maj 2010

Creating a Xen Ubuntu Lucid DomU

# work in progress
# create a new file system, add a user, enable networking with dummy ip4 address,  create the VM

vg=cluster5
export vm=myvm
LUCID=/mnt
lvcreate --size 1G --name $vm  $vg
mkfs.ext4 /dev/$vg/$vm

mount /dev/$vg/$vm $LUCID
debootstrap --variant=buildd --arch i386 lucid $LUCID http://se.archive.ubuntu.com/ubuntu
chroot $LUCID
export LC_ALL=C

cat > /etc/apt/sources.list <<EOF
deb http://se.archive.ubuntu.com/ubuntu lucid          main restricted universe
deb http://se.archive.ubuntu.com/ubuntu lucid-security main restricted universe
EOF

apt-get update
apt-get -y install ubuntu-minimal openssh-server
adduser --ingroup sudo larsr
# fill in stuff

echo $vm > /etc/hostname
cat >>/etc/network/interfaces <<EOF
auto eth0
iface eth0 inet static
 address 1.1.1.1
 netmask 255.255.255.255
EOF

exit
umount $LUCID

xm create /dev/null kernel=/boot/vmlinuz-2.6.31.13 ramdisk=/boot/initrd.img-2.6.31.13 name=$vm  disk=phy:/dev/$vg/$vm,/dev/xvda1,w  root=/dev/xvda1 vif="mac=00:16:3e:0e:34:14,vifname=$vm" -c

Then you can create snapshots of the disk very quickly (thanks to LVM)
orig=vm
vm=newvm
lvcreate --snapshot --size 1G --name $vm $vg/$orig
mount /dev/$vg/$vm /mnt
echo $vm > /mnt/etc/hostname 
umount /mnt

torsdag 6 maj 2010

Install Ubuntu Lucid Lynx root file system from command line

Here is a link to a more thorough post

If you are running an older version of ubuntu, or some other debian distribution, you can create a lucid lynx root file system like this

First install the debootstrap package (it should include the settings file for lucid lynx)
1. download it from http://packages.ubuntu.com/intrepid-backports/all/debootstrap/download
2. install it with sudo dpkg -i NAME_OF_PACKAGE.deb

Create the root filesystem (on a mounted partition, that you have prepared, here I just mkdir a place)

3. mkdir ~/lucid
4. sudo debootstrap --variant=buildd --arch i386 lucid ~/lucid http://archive.ubuntu.com/ubuntu/

That's it!

Debootstrap copies the /etc/passwd so  you can login, but it doesn't copy over the network settings or other servers, so make sure that they are correct before starting a machine with the new root file system.