new package: add package 'compcache', move init script to create swap to package 'compcache'

Signed-off-by: Stephan Raue <stephan@openelec.tv>
This commit is contained in:
Stephan Raue 2010-10-22 07:34:42 +02:00
parent cb10d9bb60
commit 11636df893
11 changed files with 91 additions and 14 deletions

View File

@ -0,0 +1,6 @@
#!/bin/sh
. config/options $1
cd $PKG_BUILD
make CC=$CC KERNELDIR=$(kernel_path)

View File

@ -29,26 +29,24 @@
INSTALLED_MEMORY=`cat /proc/meminfo | grep 'MemTotal:' | awk '{print $2}'`
if [ $INSTALLED_MEMORY -le 500000 -a -f $HOME/.config/swapon ]; then
if [ "$INSTALLED_MEMORY" -le 500000 ]; then
if [ ! -f $HOME/.cache/swapfile ]; then
progress "creating swapfile"
progress "creating swapfile"
mkdir -p $HOME/.cache
dd if=/dev/zero of=$HOME/.cache/swapfile bs=1024 count=524288
mkswap $HOME/.cache/swapfile
fi
# load zram module
modprobe zram
progress "enable swapfile"
swapon -p 10000 $HOME/.cache/swapfile
# setup space for zram
echo "$INSTALLED_MEMORY"/2*1024 | bc > /sys/block/zram0/disksize
[ $INSTALLED_MEMORY -le 260000 ] \
&& sysctl -w vm.swappiness=100 \
|| sysctl -w vm.swappiness=60
# create swap
mkswap /dev/zram0 >/dev/null 2>&1
else
progress "activating swapfile"
sysctl -w vm.swappiness=0
# create swap
swapon -p 10000 /dev/zram0 >/dev/null 2>&1
sysctl -w vm.swappiness=100 >/dev/null 2>&1
fi

View File

@ -0,0 +1,19 @@
#!/bin/sh
. config/options $1
$SCRIPTS/build busybox-hosttools
VER=`ls $BUILD/linux*/modules/lib/modules`
mkdir -p $INSTALL/lib/modules/$VER/zram
cp $PKG_BUILD/zram.ko $INSTALL/lib/modules/$VER/zram
for MOD in `find $INSTALL/lib/modules/$VER/zram -name *.ko`; do
$STRIP --strip-debug $MOD
done
$ROOT/$TOOLCHAIN/sbin/depmod -b $INSTALL $VER > /dev/null
for i in `ls $INSTALL/lib/modules/*/modules.* | grep -v modules.dep | grep -v modules.alias | grep -v modules.symbols`; do
rm -f $i
done

View File

@ -0,0 +1,14 @@
PKG_NAME="compcache"
PKG_VERSION="20101022"
PKG_REV="1"
PKG_ARCH="any"
PKG_LICENSE="GPL"
PKG_SITE="http://code.google.com/p/compcache/"
PKG_URL="http://sources.openelec.tv/svn/$PKG_NAME-$PKG_VERSION.tar.bz2"
PKG_DEPENDS=""
PKG_BUILD_DEPENDS="toolchain linux"
PKG_PRIORITY="optional"
PKG_SECTION="system"
PKG_SHORTDESC="compcache: creates RAM based block device (named ramzswap) which acts as swap disk"
PKG_LONGDESC="compcache creates RAM based block device (named ramzswap) which acts as swap disk. Pages swapped to this disk are compressed and stored in memory itself."
PKG_IS_ADDON="no"

View File

@ -0,0 +1,14 @@
#!/bin/sh
. config/options $1
STAMP=$STAMPS/$1/unpack
test $PKG_DIR/config/linux.$TARGET_ARCH.conf -nt $STAMP -o \
$PKG_DIR/config/linux.$TARGET_PLATFORM.conf -nt $STAMP -o \
$PROJECT_DIR/$PROJECT/linux/linux.$TARGET_ARCH.conf -nt $STAMP -o \
$PROJECT_DIR/$PROJECT/linux/linux.$TARGET_PLATFORM.conf -nt $STAMP -o \
$PKG_DIR/url -nt $STAMP -o \
$PKG_DIR/meta -nt $STAMP && rm -f $STAMP
exit 0

View File

@ -0,0 +1,12 @@
diff -Naur compcache-20101022/zram_drv.c compcache-20101022.patch/zram_drv.c
--- compcache-20101022/zram_drv.c 2010-10-22 04:13:51.000000000 +0200
+++ compcache-20101022.patch/zram_drv.c 2010-10-22 04:31:48.407299221 +0200
@@ -458,7 +458,7 @@
return 0;
}
- if (unlikely(bio_rw_flagged(bio, BIO_RW_DISCARD))) {
+ if (unlikely(bio->bi_rw & REQ_DISCARD)) {
zram_discard(zram, bio);
return 0;
}

View File

@ -2,6 +2,8 @@
. config/options $1
[ "$ZRAM_SUPPORT" = "yes" ] && $SCRIPTS/install compcache
for drivers in "$ADDITIONAL_DRIVERS"; do
[ "$drivers" = rtl8192se ] && $SCRIPTS/install rtl8192se

View File

@ -86,6 +86,9 @@
# e.g. ADDITIONAL_DRIVERS="rtl8192se"
ADDITIONAL_DRIVERS=""
# build with compressed swap (zram) support (yes / no)
ZRAM_SUPPORT="yes"
# build with network support (yes / no)
NETWORK="yes"

View File

@ -86,6 +86,9 @@
# e.g. ADDITIONAL_DRIVERS="rtl8192se"
ADDITIONAL_DRIVERS="rtl8192se"
# build with compressed swap (zram) support (yes / no)
ZRAM_SUPPORT="no"
# build with network support (yes / no)
NETWORK="yes"

View File

@ -86,6 +86,9 @@
# e.g. ADDITIONAL_DRIVERS="rtl8192se"
ADDITIONAL_DRIVERS="rtl8192se"
# build with compressed swap (zram) support (yes / no)
ZRAM_SUPPORT="no"
# build with network support (yes / no)
NETWORK="yes"

View File

@ -86,6 +86,9 @@
# e.g. ADDITIONAL_DRIVERS="rtl8192se"
ADDITIONAL_DRIVERS="rtl8192se"
# build with compressed swap (zram) support (yes / no)
ZRAM_SUPPORT="no"
# build with network support (yes / no)
NETWORK="yes"