lkml.org 
[lkml]   [1998]   [Feb]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subjectgzippedkernel
[Can one send only letter to list from account he's subscribed it?
I'm sending this for second time now]

I created two utilities to gzip most of the .c files in the kernel
source, making it smaller and also made new rules for Makefile.
So kernel compiling takes less space. This patch aims ppl with having no
big winchester. Please read the Documentation in the attachment, that
should be the first one.
Feedback would be appreciated.

Seasons
------------------------------------------------------------------------------
if(Detect(Micro\$oft)) CloseAll(Windows);
------------------------------------------------------------------------------
Kuti Gabor ksx@balu.sch.bme.hu
seasons@falcon.sch.bme.hu
diff -uNr linux/Documentation/gzippedkernel.txt linux-patched/Documentation/gzippedkernel.txt
--- linux/Documentation/gzippedkernel.txt Thu Jan 1 01:00:00 1970
+++ linux-patched/Documentation/gzippedkernel.txt Wed Feb 25 18:49:06 1998
@@ -0,0 +1,59 @@
+Gzipped Kernel
+19-02-1998
+Gabor KUTI
+<seasons@makosteszta.sote.hu>
+
+The whole idea came about a month ago, when I wanted to ship the newest
+development kernel to home on disks, and scared its size -- it was just
+about ten megs packed. And since I don't have a big winchester, so not a
+big Linux partition, had to delete something at least to get it untarred.
+
+Linux 2.2 is coming and people who don't have terabytes of capacity as me
+will want to compile and use it also. So why not pack the C sources one by
+one? Of course I got in mind that in that case unzipping takes time when
+compiling, but thought that this time penalty is worth to compile [and
+even if you need it, probably you don't have a fast processor, eh? so
+about 10% less or more waiting..]. I wanted to create these utilities not
+to distract those who can afford lots of space.
+
+So created two utilities [they can be found in the scripts directory], one
+of them is gzipkernel. It zips/unzips an already untarred kernel. Zips
+documentation also, but in arch only it works for i386, since I can't test
+whether for other platforms it works [and on the other hand, they might not
+need it at all]. The other one [called flygzip] zips on the fly as a full
+tar.gz gets unpacked. It is really for those who are on lack of space.
+By compiling, new rules take care of the packed files.
+
+It is allowed to mix packed and non-packed files, but take care that one
+filename should exist in its .c either .c.gz format! Gzipkernel gives a
+warning about it and leaves the files untouched, but make clean simply
+erases .c, since it thinks that it is the unpacked version of .c.gz [so if
+you have modified it that then should start again..]. It should be so,
+since some sources has its own rule, I didn't want to make these scripts
+rule dependent, so there's a rule for %.c: %.c.gz in the Makefile. But
+then after compiling I cannot erase it, so some files will be lying
+around. So if you want to make changes to a file, DON'T keep its .gz
+version!
+ -----------------------
+* YOU HAVE BEEN WARNED! *
+ -----------------------
+
+And now let's see some performance:
+It's measured on a 486DX4-120, 24 megz RAM, 850M Quantum Trailblazer.
+
+kernel v2.1.87:
+no modification:
+size: 43282k
+2200.06user 216.12system 41:41.62elapsed 96%CPU (0avgtext+0avgdata
+
+new rule, gzipped:
+size: 24946k
+2282.12user 309.85system 44:42.89elapsed 96%CPU (0avgtext+0avgdata
+
+So as you see, it really doesn't take so much longer.. but in return
+source code is nearly half of the original!
+
+TODO
+- Since all sources are zipped, patch-kernel cannot do its job. It should
+be extended that before patching it unzips all the affected files [and
+maybe then zips them again].
diff -uNr linux/Makefile linux-patched/Makefile
--- linux/Makefile Tue Feb 24 22:34:22 1998
+++ linux-patched/Makefile Tue Feb 24 22:46:29 1998
@@ -346,6 +346,7 @@
rm -f core `find . -name '*.[oas]' ! -regex '.*lxdialog/.*' -print`
rm -f core `find . -type f -name 'core' -print`
rm -f core `find . -name '.*.flags' -print`
+ for i in `find . -name *.c`;do if [ -f $$i.gz ]; then rm -f $$i;fi;done
rm -f vmlinux System.map
rm -f .tmp*
rm -f drivers/char/consolemap_deftbl.c drivers/char/conmakehash
diff -uNr linux/Rules.make linux-patched/Rules.make
--- linux/Rules.make Tue Feb 24 22:34:26 1998
+++ linux-patched/Rules.make Wed Feb 25 14:08:37 1998
@@ -44,6 +44,14 @@
# Common rules
#

+%.o: %.c.gz
+ gzip -dc $< >$(basename $<); \
+ $(CC) $(CFLAGS) $(EXTRA_CFLAGS) -c -o $@ $(basename $<); \
+ rm -f $(basename $<)
+
+%.c: %.c.gz
+ gzip -dc $< >$(basename $<)
+
%.s: %.c
$(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$@) -S $< -o $@

@@ -104,6 +112,9 @@
#
fastdep: dummy
$(TOPDIR)/scripts/mkdep $(wildcard *.[chS] local.h.master) > .depend
+ if [ -n "$(wildcard *.c.gz)" ]; then \
+ for i in $(wildcard *.c.gz); do gzip -dc $$i > $${i%.gz}; \
+ $(TOPDIR)/scripts/mkdep $${i%.gz} >> .depend; rm -f $${i%.gz};done;fi
ifdef ALL_SUB_DIRS
set -e; for i in $(ALL_SUB_DIRS); do $(MAKE) -C $$i fastdep; done
endif
diff -uNr linux/scripts/flygzip linux-patched/scripts/flygzip
--- linux/scripts/flygzip Thu Jan 1 01:00:00 1970
+++ linux-patched/scripts/flygzip Wed Feb 25 18:57:45 1998
@@ -0,0 +1,116 @@
+#!/bin/sh
+# This utility allows to gzip most of the .c files in the source tree,
+# making it much smaller, however we pay time penalty by compiling..
+# By zipping it leaves some directories untouched to avoid screw-up
+# Then, by compiling, new rules take care of gzipped sources
+#
+# Gabor KUTI [seasons@makosteszta.sote.hu]
+
+dopack()
+{
+if [ $DEBUG ]; then echo Looking for files to pack... ;fi
+gzip $(find $1 -path $1'/scripts' -prune -o -path \
+$1'/init' -prune -o -path $1'/arch' -prune -o -type f -name *.c \
+-mmin +5 -print)
+
+# Documentation pack
+if [ -d $1/Documentation ];then
+gzip $(find $1/Documentation -name *.gz -prune -o -type f -mmin +5 \
+-print)
+fi
+
+# Arch dependent code comes here -- it's for i386 yet, since I can't run
+# linux on another platform [so cannot test whether it works..]
+# Trying to make it global anyway [except for m68k there is boot
+# directory for every platform, should be left out, works with its own
+# rules, I don't want to make this so arch dependent. I suppose for
+# m68k all amiga/atari/etc. dirs. should be untouched]..
+
+# i386
+# The following if might be taken out for other platforms -- could not
+# test it! Tell me whether it's needed at all and about your results.
+if [ $ARCH = "i386" ]; then
+if [ -d $1/arch/$ARCH ]; then
+gzip $(find $1/arch/$ARCH -path $1/arch/$ARCH/boot -prune -o -name *.c -mmin +5 -print)
+rm -f `find $1/arch/ -path $1/arch/$ARCH -prune -o -print`
+fi
+fi
+}
+
+# Uncomment it if you want debug info
+# DEBUG=1
+
+ARCH=$(uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/)
+MAINDIR=linux
+
+if [ -z "$1" ]; then
+echo Usage `basename $0` linux-x.y.z.tar.gz [limit]
+echo
+echo This utility allows you to pack most of the .c files on the fly
+echo as kernel gets unpacked. This source tree will be much smaller,
+echo however we pay time penalty by compiling. If you specify \'limit\'
+echo then utility stops the untarring when the created source tree
+echo exceeds this limit and waits until packing gets some free space,
+echo then continues.
+echo Note: This limit is just an about one, not exact!
+echo Note2: If you specify too little value, untarring could never finish
+echo since it waits for gzip, but gzip has nothing more work to do..
+echo I tested with 30000, seems to be o.k.
+echo To pack an already untarred kernel source tree, use \'gzipkernel\'
+exit 1
+fi
+
+if [ $1 != "c" ];then
+# Parent
+ $0 c g 2> /dev/null &
+if [ "$2" ]; then
+ $0 c $2 2> /dev/null &
+fi
+ if [ $DEBUG ];then echo Starting untarring..;fi
+ gzip -dc $1 | tar xf -
+ if [ $DEBUG ];then
+ echo Untarring done..
+ echo Waiting for child\(s\) to be done..
+ fi
+ wait
+ exit 0
+
+else
+if [ $2 = "g" ]; then
+# Child who zips
+if [ $DEBUG ]; then echo Starting child who takes care of packing; fi
+while [ $(/sbin/pidof tar) ]; do
+ dopack $MAINDIR
+done
+
+dopack $MAINDIR
+
+# Included in last stage of compiling
+if [ -f $MAINDIR/lib/inflate.c.gz ]; then
+ gzip -d $MAINDIR/lib/inflate.c.gz
+fi
+
+if [ $DEBUG ]; then echo Child who takes care of packing is finished; fi
+exit 0
+
+else
+# Child who controls space occupation
+if [ $DEBUG ]; then echo Starting child who takes care of limit; fi
+while [ $(/sbin/pidof tar) ]
+ do
+ if [ `du -s $MAINDIR|cut -f1` -gt $2 ]; then
+ if [ $DEBUG ]; then echo Limit exceeded, sending SIGSTOP; fi
+ kill -SIGSTOP $(/sbin/pidof tar)
+ while [ `du -s $MAINDIR|cut -f1` -gt `expr $2 - 2048` ];do
+ sleep 1
+ done
+ if [ $DEBUG ]; then echo Limit is ok, sending SIGCONT; fi
+ kill -SIGCONT $(/sbin/pidof tar)
+ sleep 1
+ fi
+done
+if [ $DEBUG ]; then echo Child who takes care of limit is finished; fi
+exit 0
+
+fi
+fi
diff -uNr linux/scripts/gzipkernel linux-patched/scripts/gzipkernel
--- linux/scripts/gzipkernel Thu Jan 1 01:00:00 1970
+++ linux-patched/scripts/gzipkernel Wed Feb 25 18:58:17 1998
@@ -0,0 +1,68 @@
+#!/bin/sh
+# This utility allows to gzip most of the .c files in the source tree,
+# making it much smaller, however we pay time penalty by compiling..
+# By zipping it leaves some directories untouched to avoid screw-up
+# Then, by compiling, new rules take care of gzipped sources
+#
+# Gabor KUTI [seasons@makosteszta.sote.hu]
+
+usage()
+{
+echo Usage: `basename $0` in/out [path]
+echo
+echo This utility allows you to gzip most of the .c files in an already
+echo unpacked source tree, making it much smaller, however we pay time
+echo penalty by compiling. For on-the-fly gzipping use \'flygzip\'
+echo
+}
+
+if [ -z $1 ]; then
+usage
+exit 1
+fi
+
+if [ -z $2 ]; then
+ cd `dirname $0`/..
+else
+ cd $2
+fi
+
+if [ $1 = 'in' ]; then
+for i in $(find . -path './scripts' -prune -o -path \
+'./init' -prune -o -path './arch' -prune -o -type f -name *.c -print);
+do
+ if [ -f $i.gz ]; then
+ echo Warning: $i.gz already exists, leaving untouched
+ else
+ gzip $i
+ fi
+
+done
+
+# Included in last stage of compiling
+if [ -f ./lib/inflate.c.gz ]; then gzip -d ./lib/inflate.c.gz;fi
+
+# Documentation pack
+gzip `find Documentation -name *.gz -prune -o -type f -print`
+
+# Arch dependent code comes here -- it's for i386 yet, since I can't run
+# linux on another platform [so cannot test whether it works..]
+
+# i386
+gzip `find arch/i386/ -path 'arch/i386/boot' -prune -o -name *.c -print`
+
+elif [ $1 = 'out' ]; then
+for i in $(find . -name *.gz)
+do
+ if [ -f ${i%.gz} ]; then
+ echo Warning: ${i%.gz} already exists, leaving untouched
+ else
+ gzip -d $i
+ fi
+done
+
+else
+usage
+fi
+
+cd -
\
 
 \ /
  Last update: 2005-03-22 13:41    [W:0.039 / U:0.112 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site