All pastes #644110 Raw Edit

squash_overlays

public shellscript v1 · immutable
#644110 ·published 2007-08-03 07:58 UTC
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/aufs are necessary for read-write support.##   Author: Mathias Laurin#   2006-11-28, v.0.1.5(4)#   aufs by yoshi314#source /etc/make.confPORTDIR=/home/gentoo/overlaysSQFS_DIRNAME=/home/gentooSQFS_CUR="$SQFS_DIRNAME/overlays.sqfs"SQFS_NEW="$SQFS_DIRNAME/overlays-current.sqfs"SQFS_OLD="$SQFS_DIRNAME/overlays-old.sqfs"DEF_RW="/dev/shm/.overlays-rw"#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)depend() {	need localmount}start() {	ebegin "Mounting read-only squashfs image [overlays]"	mount -rt squashfs -o loop,nodev,noexec $SQFS_CUR $PORTDIR	retval=$?	eend $retval	[ $retval -ne 0 ] && return $retval	ebegin "Mounting read-write with aufs [overlays]"	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 [overlays]"	[ ! $PORTAGE_RW ] && PORTAGE_RW="${DEF_RW}"	if [ ! -z `ls -A --ignore=.wh* $PORTAGE_RW | head -n1` ]	then		einfo " Syncing the tree [overlays]"		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 [overlays]"		umount -t aufs $PORTDIR	umount -t squashfs $PORTDIR	rm -rf $PORTAGE_RW	eend 0}