1 AUTHOR: Zhou Peng(Chowroc) <chowroc dot z at gmail dot com>
5 LICENSE: GNU Free Documentation License Version 1.2
7 SYNOPSIS: crablfs -- User Based Package Management System
10 Every package and its files belong to a system normal user, and
11 a batch script to rebuild or migrate your personalized LFS/BLFS
12 system by install all your packages all at once.
15 http://cheeseshop.python.org/pypi?:action=display&name=crablfs
16 https://sourceforge.net/project/showfiles.php?group_id=180695
25 crablfs: User Based Package Management System which is written in
26 python. Every package and its files belong to a system normal user,
27 and a batch script to rebuild or migrate your personalized LFS/BLFS
28 system by install all your packages automatically all at once. The
29 goal of "crablfs" is to exert more control on packages that compiled
30 from source, and reduce the costs of system migration and backup.
32 The basic theory is: every package in the system has a corresponding
33 user it belongs to, the installation actions(copy, mkdir, etc) will
34 run by this user, thus all the files a package generated have the
35 mode of this user. At the same time, all those users belongs to a
36 'install' group, and the key directories in the system such as
37 /usr/local, /usr/local/bin, etc have g+s,o+t mode, and owned to the
38 'install' group, to make different packages create their own files
39 and directories in those directories.
41 There are many benefits to use this method. which can be looked up
44 More Control and Package Management using Package Users (v1.2)
45 http://www.linuxfromscratch.org/hints/downloads/files/more_control_and_pkg_man.txt
47 Based on this theory, the package manager "userpack" is a command
48 line interface like rpm and paco, for finishing some necessary
49 operations. It can install, remove, query a package, or list all
50 packages of current system, or find the package owner of a specified
51 file. the package name($pkgname-$version) will add to the list file
52 (/usr/src/packages.list for default).
54 Every package user has its own HOME dir, which is default to
55 /usr/src/$pkgname. It will stores compressed source archives, all
56 patches and supplementary files for installation, and installation
57 profiles which contains the information of the package, such as
58 user/group, source archive, patches, create time and those commands
59 to build this package.
61 By default, "userpack" use interactive mode, which will start a
62 shell like command line, in which you type "cmd $command" to execute
63 the corresponding command, and those commands will been recorded to
64 "installation profile"(described before). This profile can be used
65 to execute installation commands automatically in noninteractive
68 The script "crablfs" is a batch script write in python, it is another
69 ALFS instance in other words, which make use of the automated ability
70 of "userpack". It can use the list file(/usr/src/packages.list)
71 mentioned before, to operate the compressed source archives and
72 installation profiles you appointed automatically. And you can also
73 specified a directory that has the same structure as $homepre
74 (/usr/src) to build a ALFS system automatically. This means that you
75 can migrate from an old system to new ones more easily -- and rebuild
76 your personalized system more quickly.
78 The essential differences among Linux distributions is the
79 differences of the package management ways. As a distribution, LFS
80 actually does not has a mature package manager itself, this of course
81 roots to the flexibility of LFS, but for daily use, a mature package
82 management system is necessary. It is recommended to use User Based
83 Management in the BLFS document, but the LFS hints only give the basic
84 principles which is very creative, but the shell scripts is not
85 enough to form a self-consistency system. So I write one regardless of
86 unveil my superficialness, a hope that my crude remarks may draw forth
89 Of course crablfs is not only used for LFS, it aims to those packages
90 that build from source code, so it can used on other distributions, too.
92 It's now available from:
93 https://sourceforge.net/project/showfiles.php?group_id=180695
94 http://cheeseshop.python.org/pypi?:action=display&name=crablfs
97 To make sure that crablfs also under the control of package
98 management, to install by the following way to build the tools chain:
99 # export PYTHONPATH=/opt/lib/python2.4/site-packages
100 // sys.path will not be influenced by PYTHONPATH
102 *** Now the pexpect package is optional ***
103 # tar xfz pexpect-2.1.tar.gz
105 # python setup.py install --prefix=/opt
108 # tar xfz crablfs-0.1.tar.gz
111 *** define all key directories ***
112 *** these dirs will belong to 'install' group.and have g+s,o+t mode ***
132 /usr/local/share/doc/
133 /usr/local/share/info/
134 /usr/local/share/locale/
135 /usr/local/share/man/
136 /usr/local/share/man/man1/
137 /usr/local/share/man/man2/
138 /usr/local/share/man/man3/
139 /usr/local/share/man/man4/
140 /usr/local/share/man/man5/
141 /usr/local/share/man/man6/
142 /usr/local/share/man/man7/
143 /usr/local/share/man/man8/
144 /usr/local/share/misc/
145 /usr/local/share/terminfo/
146 /usr/local/share/zoneinfo/
147 /usr/lib/python2.4/site-packages/
148 /usr/lib64/python2.4/site-packages/
149 // Adjust it for you own needs
150 # python setup.py install --prefix=/opt
153 # /opt/bin/userpack init
154 # /opt/bin/userpack install -f /tmp/crablfs-0.1.tar.gz crablfs-0.1
155 crablfs> cmd tar xfz crablfs-0.1.tar.gz
156 crablfs> cmd cd crablfs-0.1
157 crablfs> cmd python setup.py install --install-scripts=/usr/local/bin
159 crablfs> cmd rm -rf crablfs-0.1
162 *** Now the pexpect package is optional ***
163 # userpack install -f /tmp/pexpect-2.1.tar.gz pexpect-2.1
164 crablfs> cmd tar xfz pexpect-2.1.tar.gz
165 crablfs> cmd cd pexpect-2.1
166 crablfs> cmd python setup.py install
168 crablfs> cmd rm -rf pexpect-2.1
173 (3) package management:
174 Manager is 'userpack'.
176 a. install a package:
177 # userpack install $pkgname-$version
179 # userpack install rxvt-2.7.10
181 # userpack install meida.mplayer-1.0pre8
182 because the system support '.' for user name.
185 # upm i $pkgname-$version
189 * It is not true for LFS system,the shadow package that LFS use
190 only support [-a-z0-9_] chars, so I wrote a shadow module to access
191 /etc/passwd, /etc/group, /etc/shadow, /etc/gshadow directly.
193 *. So far the classification function have not been tested strictly.
196 Under the conditions above, the default action will taken, that is:
197 the compressed source archive and patches are considered to have
198 been in the dir of HOME(/usr/src/$pkgname), other will you should
199 specify it with argument:
200 # userpack install -f /mnt/file/packages/rxvt-2.7.10.tar.gz rxvt-2.7.10
201 to make those archive and patches to be copied to HOME.
203 This command will start an interactive command line, it is simple and
204 only several command. In fact it is like a shell, you can type any
205 'shell' command to install the package, only need add 'cmd' before the
206 command to make the 'userpack' records the commands. These commands
207 will be stored into HOME/.config(installation profile).
208 crablfs> cmd tar xfz rxvt-2.7.10.tar.gz
209 crablfs> cmd cd rxvt-2.7.10
210 crablfs> cmd ./configure
212 crablfs> cmd make install
214 crablfs> cmd rm -rf rxvt-2.7.10
217 You should known that the current user is the package user, not root;
218 and current working directory is the user's HOME, so there may be
219 ownership problem(What is the purpose of User Based Package
222 When you type commands, you can use 'list' to see what you have typed:
224 0, tar xfz rxvt-2.7.10.tar.gz
230 Use 'rollback' to clean up these, and 'del N' to delete specified
233 If you want to execute a command but not want it to be recorded into
234 the 'list', just 'do':
237 You must 'commit/cmt' at last, thus all the commands will be recorded
238 to the .config, the $pkgname-$version couple will been add to list
239 file(/usr/src/packages.list for default), to indicate that the package
240 has been installed. If there is a command error makes the installation
241 failed, and the fault can't been clean up by yourself, just type
242 'quit' and the installation terminated, but the archive and patches
243 will still be copied to HOME.
245 If there is any other supplementary files:
246 # userpack install -f /mnt/file/packages/MPlayer-1.0per8.tar.bz2 \
247 -p /mnt/file/packages/all-20060611.tar.bz2 \
248 -p /mnt/file/packages/Blue-1.6.tar.bz2 mplayer-1.0pre8
249 // all is mplayer's codecs.Blue is GUI Skin.
251 If you have the installation profile before, you can use -a|--auto
252 to install automatically:
253 # userpack install -a rxvt-2.7.10
254 This means the HOME/.config exists, otherwise use -c|--profile:
255 # userpack install -ac /mnt/packages/confiles/rxvt-2.7.10 rxvt-2.7.10
257 If you have burned /usr/src to DCD-R's sources dir, you can also
258 execute the automatically installation below:
259 # userpack install -as /mnt/dvdrom/sources rxvt-2.7.10
261 Moreover, the sources could also on the net such as ftp or ssh:
262 ssh://localhost/sources/mlterm-2.9.3.tar.gz
263 scp://localhost/sources/mlterm-2.9.3.tar.gz
265 ftp://localhost/pub/sources/mlterm-2.9.3.tar.gz
268 -f ftp://192.168.0.1/pub/sources/mlterm-2.9.3.tar.gz mlterm-2.9.3
271 If the package name(mlterm-2.9.3) is not given, it can be parsed
272 from the archive name(mlterm-2.9.3.tar.gz) automatically by 'userpack'.
275 If a archive has problem and makes installation failed, the archive
276 still has been copied to HOME, and the next time 'userpack' will check
277 whether the archive exists in HOME, if true, copy will not occur. To
278 change this, use -C|--copy-force:
279 # userpack install -Caf libesmtp-1.0.3r1.tar.bz2
281 About the user/group ID, 'userpack' can define its own range,
282 default from 1000 to 20000, U can define in
283 /usr/lib/python2.4/site-packages/crablfs/shadow.py:
291 This mean the normal user ids range is (1000, 19999), admin group ids
292 is (950, 999). So 'install' group will be 950 by default.
294 Besides the 'install', other admin groups will be used as 'application
295 groups'. For example, 'glib2', 'atk', 'gtk', 'gtk2' all belongs to
296 'GTK' group for some limited directories sharing, such as
298 /usr/share/gtk-doc/html
299 thus no modification of userpack.dirs is necessary.
301 Correspondingly, add a '-G' option to support multiple groups, for
302 example, 'xfce4' belogs to 'xfce4', 'install' and 'GTK' group.
303 (default is 'xfce4' and 'install').
305 Now I can do this to support 'applications group' and 'multiple groups':
306 # upm i -G GTK glib2-2.6.4
309 crablfs> chgrp GTK /usr/share/gtk-doc/{,html}
310 crablfs> chmod g+w,o+t /usr/share/gtk-doc/{,html}
313 # upm i -G GTK atk-1.9.1
316 These all can be read from the installation profiles and be executed
320 # userpack remove rxvt-2.7.10
324 c. list all packages under the control:
334 d. query a file's package owner:
335 # userpack owner /usr/local/bin/mlterm
337 # upm o /usr/local/bin/mlterm
340 e. list all files a package contains:
341 # userpack files pexpect-2.1
344 /usr/lib/python2.4/site-packages/fdpexpect.py
345 /usr/lib/python2.4/site-packages/pxssh.py
346 /usr/lib/python2.4/site-packages/pexpect.py
347 /usr/lib/python2.4/site-packages/pxssh.pyc
348 /usr/lib/python2.4/site-packages/pexpect.pyc
349 /usr/lib/python2.4/site-packages/fdpexpect.pyc
351 This will read $HOME/.files to print all files the package have. This
352 file is generated by the Package Manager 'userpack' as soon as the
353 installation is finished, but you can force 'userpack' to regenerate
356 This command will also print all the files of the package.
358 (4) About the pkgname & version rule:
359 This is the argument to
360 'userpack', the form is '$pkgname-$version', the python re pattern
362 '^(?P<pkgname>(\w+-{0,1})+)(-(?P<version>(\d[\w]*[-\.])*\d[\w]*))'
364 That is '$pkgname' part is 'part1[-part2][-part3][...]', every part
365 could contains '[-a-zA-Z0-9_]', no rules for start char, but it is
366 recommended to use alphabet; when meet '-[0-9][a-zA-Z0-9_]\.'
367 pattern('-' follows a string start with digit, and follows a '.'),
368 this will be considered as start part of $version, $version can also
369 contains other '-', and when meet a string not start with digit,
370 $version ends. chars follows are ignored.
373 It is mentioned before that all commands will be recorded to
374 HOME/.config, and 'userpack' can also use this commands to run
375 automatically, so there could be a batch script to use packages.list
376 to install those packages all at once. Based on this, we can get an
379 The target of the instance is extended to tranditional nALFS and
380 jhalfs, for more personalized environment, for example: The first
381 time, I build LFS/BLFS step by step, and the packages installed,
382 related with their own's information & operations are recorded to
383 the profiles, the next time, I can use those profiles to build the
384 software envrionment I need with a 'turn key' way, exactly as those
385 before. This means I can migrate many times, and others can also use
386 my profiles to build their own personalized system. The end target
387 also contains a platform independent operation.
389 This batch script is 'crablfs'.
392 So far, it is only tested under the condition that the LFS base
393 system has been built, to use 'crablfs' to build a bunch of BLFS
394 packages, so it is the future to make the LFS base system under the
395 control of package management system.
398 At first, adjust the tool chain:
400 # tar xfj python-2.4.1.tar.bz2
402 # patch -Np1 -i ../python-2.4.1-gdbm-1.patch
403 # ./configure --prefix=/opt --enable-shared
404 # make && make install
406 # rm -rf python-2.4.1
407 // U'd better delete it, otherwise may be problems
409 # export PYTHONPATH=/opt/lib/python2.4/site-packages
411 *** Now pexpect is optional ***
412 # tar xfz pexpect-2.1.tar.gz
414 # /opt/bin/python setup.py install --prefix=/opt
418 # tar xfz crablfs-0.1.tar.gz
420 # cp userpack.dirs.blfs userpack.dirs
421 // Adjust for you own need and system
422 // Whenever U meet pemission problem, just adjust /etc/userpack.dirs
423 // and run 'userpack init'
424 # /opt/bin/python setup.py install --prefix=/opt
426 # /opt/bin/userpack init
427 # /opt/bin/userpack install -f python-2.4.1.tar.bz2 -p
428 # python-2.4.1-gdbm-1.patch python-2.4.1
429 crablfs> cmd tar xfj python-2.4.1.tar.bz2
430 crablfs> cmd cd python-2.4.1
431 crablfs> cmd ./configure --prefix=/usr --enable-shared
433 crablfs> cmd make install
435 crablfs> cmd rm -rf python-2.4.1
438 # /opt/bin/userpack install -f crablfs-0.1.tar.gz crablfs-0.1
439 crablfs> cmd tar xfz crablfs-0.1.tar.gz
440 crablfs> cmd cd crablfs-0.1
441 crablfs> cmd python setup.py install --install-scripts=/usr/local/bin
443 crablfs> cmd rm -rf crablfs-0.1
446 *** Now the pexpect is optional ***
447 # userpack install -f pexpect-2.1.tar.gz pexpect-2.1
448 crablfs> cmd tar xfz pexpect-2.1.tar.gz
449 crablfs> cmd cd pexpect-2.1
450 crablfs> cmd python setup.py install
452 crablfs> cmd rm -rf pexpect-2.1
462 Now there is a script 'scripts/setup-blfs' to do these all!
465 And use the same way, I installed some packages:
467 # cat /usr/src/packages.list
515 startup-notification-0.8
516 hicolor-icon-theme-0.8
520 The X Window is OK and xfce is usable, so I try to *migrate*:
521 # mv /usr/src/packages.list /blfs-sources/
522 # copy-profiles /usr/src
523 // This will generate a profiles dir in current dir,
524 // which contains all the profiles from $homepre(/usr/src)
525 # mv profiles /blfs-sources
527 -C /blfs-sources/profiles/ \
529 /blfs-sources/packages.list
531 If you have installed such a BLFS system and burned /usr/src all to
532 the DVD-R, you can do the following for another system to install all
534 # crablfs -t crablfs[/default] \
535 -s /mnt/dvdrom/sources/ \
536 /mnt/dvdrom/sources/packages.list
538 You may want to adjust 'packages.list' for your own needs, if you want
539 , you can also edit the profiles.
541 crablfs will record current successfully installed package name to
542 /var/log/crablfs/.mark. Because of the packages dependencies
543 problems, if one package failed, the 'crablfs' process terminated.
544 After you clean up the problem, you can continue from the
547 So if .mark point to the last item of packages.list, 'crablfs' will
548 do nothing. Adjust it for you need.
550 Moreover, 'crablfs' will check packages.list, illegal package name
551 will terminate 'crablfs' and do nothing; if the name in .mark not in
552 packages.list, you will get a "x not in list" error report, you can
553 adjust corresponding, or just delete the .mark file.
555 So far, there are few permission problems, and all can avoid by
556 changing the installtion arguments. The wrappers for chmod, chgrp,
557 chown, install may be needed, but so far I have not see the
558 neccessary. To dicide this for further using and testing.
562 * Add gettext internationlized support
563 * Whole infomations show of a package
565 * Add code for cmdline to read .config history commands
566 * Make cmdline can execute 'root' commands, as 'sudo', by IPC?
568 * File lock of packages.list
569 * Change .config to the form of '$pkgname-$version'
570 * Enganced platform independent support:
571 Add var and env var to cmdline for different $ARCH & $LOCALE
572 * Support multi installation sources
573 * Enganced classification mechanism
574 * Intergrated checking
575 * Enganced configuration getting & setting: Plain Tree & XML
576 * Consider package dependencies problems
577 * Better documents: internal, design doc and manual
578 * Make 'userpack init' can adjust those dir items deleted from 'userpack.dirs'
582 When want to install 'glib2-2.6.4', but type in error with
584 # upm i -a -c profiles/glib2 glib-2.6.4
585 This will mistakenly remove all files of glib-1.2.10!!! Because when a
586 package installation failed, the Manager will remove all the files
587 that generated by 'install', 'cp', 'mv' commands during the process.
589 So far, this limitation roots in the limitation of package version
590 control, this also makes 'upgrade' not easy.
594 Matthias S. Benkmann built the original principle
598 For crablfs-0.1.1beta.
601 crablfs-0.1 has been distributed at 2006-10-20, so I write this hint.