Gentoo Archives: gentoo-embedded

From: Ned Ludd <solar@g.o>
To: gentoo-embedded@l.g.o
Subject: [gentoo-embedded] [Fwd: [gentoo-portage-dev] /var/db/pkg, package - sizes and formats]
Date: Wed, 03 Nov 2004 20:55:12
Message-Id: 1099515306.8064.13105.camel@simple
1 Oh for those of you that like see that activity is going on.
2
3 -----Forwarded Message-----
4 From: Ned Ludd <solar@g.o>
5 To: gentoo-portage-dev@l.g.o
6 Subject: [gentoo-portage-dev] /var/db/pkg, package - sizes and formats
7 Date: Wed, 03 Nov 2004 15:31:03 -0500
8
9 Does anybody know the point of /var/db/pkg/*/*/{[A-Z]*,*.ebuild} when
10 /var/db/pkg/*/*/env*.bz2 contains all the same info minus the
11 (CBUILD,CONTENTS,COUNTER,DEBUGBUILD)?
12
13 DEBUGBUILD is 0 bytes most of the time. Does it really need to exist in
14 production environments?
15
16 These sparse files add up in size really quickly and I'd like to see
17 portage shift into a direction where these things are planned out vs
18 just added. I don't see any reason why portage could not simply extract
19 the variables portage from the saved environment.bz2 when needed or even
20 preloading them.
21
22 I work on an embedded images and I have the option to dump 100% of
23 /var/db/ thus having no way of knowing what's installed but I'd like to
24 keep track of what's installed and not be forced into using a hacked up
25 methods which post rm stuff from a target ROOT= in order to yield the
26 desired result of keeping track of data without wasting valuable
27 resources.
28
29 Using patch2 from http://bugs.gentoo.org/show_bug.cgi?id=67190
30 And a mini subdistro meta ebuild
31 http://oc12.net/~solar/gensoekris-0.0.1.ebuild
32 INSTALL_MASK='*.a *.h /usr/include /usr/lib/*.o *.sample' ROOT=/tmp/root
33 emerge gensoekris -K
34
35 du -hs .
36 12M .
37 cd var/db/pkg/
38 du -hs .
39 3.8M .
40 # About 1/3rd of this file systems entire size is extra pkg data.
41
42 # Everything else seems to be in the env so lets kill some of the temp
43 fluff and do some testing.
44 find . -name '[A-Z]*' -o -name '*.ebuild' | egrep -v
45 'CBUILD|CONTENTS|COUNTER' | xargs rm
46
47 du -hs .
48 1.1M .
49
50 # So it seems we could be down from 3.8 to 1.1M and still have all
51 needed info for portage.
52
53 # Now lets take a look at the package and how this could work. I'll use
54 iptables as an exmaple. When all is said and done we want only an
55 environment.bz2 left in var/db/pkg/iptables-1.2.11-r2/
56
57 ls -l $(portageq envvar PKGDIR)/All/iptables-1.2.11-r2.tbz2
58 -rw-r--r-- 1 root root 179724 Oct 10 00:53
59 /usr/portage//packages/i386-pc-linux-uclibc//All/iptables-1.2.11-r2.tbz2
60
61 # extract the portage made tarball.
62 mkdir root
63 tar jxf
64 /usr/portage//packages/i386-pc-linux-uclibc//All/iptables-1.2.11-r2.tbz2
65 -C root/
66 du -hs root
67 660K root
68
69 # Repack the contents (new pkg format)
70 cd root
71 tar jcvf ../iptables-1.2.11-r2.tbz2 ./
72 cd ../net-firewall/iptables-1.2.11-r2/
73 bzip2 CONTENTS
74 bunzip2 environment.bz2
75 echo CBUILD=$(cat CBUILD) >> environment
76 echo COUNTER=$(cat COUNTER) >> environment
77 bzip2 environment
78 cat CONTENTS.bz2 >> environment.bz2
79 cd ../../
80 cat net-firewall/iptables-1.2.11-r2/environment.bz2 >>
81 iptables-1.2.11-r2.tbz2
82 ls -l iptables-1.2.11-r2.tbz2
83 -rw-r--r-- 1 root root 174892 Nov 3 19:01 iptables-1.2.11-r2.tbz2
84
85 # As we can see the package size has become smaller.
86 echo $((179724-174892))
87 4832
88
89 # Just for kix take that number and assume say about 100000 users have
90 about 500 packages installed and see that across the board we could save
91 the users about
92 export f=$(($(($((4832*500))*100000))/1024))
93 dd if=/dev/zero of=$f count=1 bs=$f ; ls -lh $f ; rm $f
94 -rw-r--r-- 1 root root r 226M Nov 3 14:19 235937500
95 # probably not really realistic as 100k of users don't have buildpkg
96 enabled.
97
98 # Anyway lets test the new package.tbz2.
99 mkdir root
100 tar jxf iptables-1.2.11-r2.tbz2 -C root ; echo $?
101 0
102 du -hs root
103 660K root
104 # good 660K matches same as portage built tarball that was extracted
105 into the root/ from before.
106
107 # The du -b here could become some other tool which seeks to the second
108 BZh9 header in the tarball. But to test that we could still get info out
109 of the tarballs so portage could use/load it I did.
110
111 tail -c $(du -b net-firewall/iptables-1.2.11-r2/environment.bz2 ) |
112 bzgrep ^ARCH=
113
114 # which returned.
115 ARCH=x86
116
117 # now lets see how big
118 rm iptables-1.2.11-r2.tbz2
119 find . -name '[A-Z]*' | xargs rm
120 du -hs .
121 732K .
122
123 # Well sweet we just got a dir that was 3.8M down to 732K and don't
124 appear to have lost anything.
125
126 # New total size
127 du -hs /tmp/root
128 8.2M /tmp/root
129 # which compresses down to about 3.6M nicely (Not bad for 36 pkgs)
130
131 # another box which is my desktop is
132 du -hs /var/db/pkg/ ; du -bhs /var/db/pkg/
133 83M /var/db/pkg/
134 29M /var/db/pkg/
135 # I bet most of yours are nearly as large or larger.
136
137 # Cost savings here could be alot better for everybody if we moved into
138 a direction which I just demonstrated.
139
140 In short this all could work if we simply
141 Compressed the file CONTENTS and appended it to end of environment.bz2
142 then appended environment.bz2 to the end of the ${P}.tbz2
143
144 Anybody see flaws/problems in the basic idea?
145 Would this structure be suitable as the next gen pkg format?
146 --
147 Ned Ludd <solar@g.o>
148 Gentoo (hardened,security,infrastructure,embedded) Developer

Attachments

File name MIME type
signature.asc application/pgp-signature