rendered paste body#!/sbin/runscript# Copyright 1999-2006 Gentoo Foundation# Distributed under the terms of the GNU General Public License v2# $Header: $# /etc/init.d/squash_portage allows efficient compression of# Gentoo portage arborescence## It requires support for the loop device and squashfs enabled in the kernel,# module autoloading is also highly recommended.# sys-fs/squashfs and sys-fs/unionfs are necessary for read-write support.## Author: Mathias Laurin# 2006-11-28, v.0.1.5(4)# patched for aufs . yoshi314#source /etc/make.confSQFS_DIRNAME=/home/gentooSQFS_CUR=.$SQFS_DIRNAME/portage.sqfs.SQFS_NEW=.$SQFS_DIRNAME/portage-current.sqfs.SQFS_OLD=.$SQFS_DIRNAME/portage-old.sqfs.DEF_RW=./dev/shm/.portage-rw.depend() { need localmount}#w przypadku gdy w make.conf jest niezdefiniowany portdirif [ "$PORTDIR" = "" ]; then PORTDIR=/usr/portagefi#pozyskanie UID i GID . po kazdej instalacji systemu sa inne,#wiec najlepiej ich szukac za kazdym razemUID_A=$(grep paludisbuild /etc/passwd | cut -d\: -f3)GID_A=$(grep paludisbuild /etc/group | cut -d\: -f3)start() { ebegin "Mounting read-only squashfs image" mount -rt squashfs -o loop,nodev,noexec $SQFS_CUR $PORTDIR retval=$? eend $retval [ $retval -ne 0 ] && return $retval ebegin "Mounting read-write with aufs" if [ ! $PORTAGE_RW ] then einfo " mounted in tmpfs (RAM)" PORTAGE_RW="${DEF_RW}" fi [ -d $PORTAGE_RW ] || mkdir -p $PORTAGE_RW chmod 0750 $PORTAGE_RW chown portage:paludisbuild $PORTAGE_RW mount -t aufs -o br=$PORTAGE_RW=rw:$PORTDIR=ro none $PORTDIR eend $?}stop() { ebegin "Updating portage tree" [ ! $PORTAGE_RW ] && PORTAGE_RW="${DEF_RW}" if [ ! -z `ls -A --ignore=.wh* $PORTAGE_RW | head -n1` ] then einfo " Syncing the tree" mv -f $SQFS_NEW $SQFS_OLD einfo " Running mksquashfs $PORTDIR $SQFS_NEW -no-duplicates -force-uid $UID_A -force-gid $GID_A 2>/dev/null" mksquashfs $PORTDIR $SQFS_NEW -no-duplicates -force-uid $UID_A -force-gid $GID_A 2>/dev/null retval=$? ln -sf $SQFS_NEW $SQFS_CUR else einfo " Nothing to do" retval=0 fi eend $retval ebegin "Unmounting the tree" umount -t aufs $PORTDIR umount -t squashfs $PORTDIR rm -rf $PORTAGE_RW eend 0}