Remove lfs-uefi.txt symlink
[linux_from_scratch_hints.git] / PREVIOUS_FORMAT / installwatch.txt
blob69a454ad5c79069b40a6375a6520ae2bfc1687c7
1 TITLE:          Using Installwatch as a Package Manager
2 LFS VERSION:    Any
3 AUTHOR:         Robert Park <rbpark@ualberta.ca>
5 SYNOPSIS: 
6         Use installwatch to keep track of what files got installed when you compiled
7         something from source. Includes an easy method for removing those files,
8         packaging those files up, and installing said packages.
10 HINT:
12 Changelog
13 ---------
15 Revision 1.14  2003/01/22 07:52:43  feztaa
16 Fixed URL to the nuke script.
18 Revision 1.13  2002/09/15 05:39:34  feztaa
19 Changed email address, among other fixes.
21 Revision 1.12  2002/08/08 02:23:05  feztaa
22 Nuke script updated to version 1.13; major rewrite to enhance readability
23 and to reflect new features.
25 Revision 1.11  2002/07/31 07:14:50  feztaa
26 Updated nuke script to version 1.12
28 Revision 1.10  2002/07/27 01:06:27  feztaa
29 Updated nuke script to version 1.11
31 Revision 1.9  2002/06/15 18:03:12  feztaa
32 Updated nuke script to version 1.9
34 Intro
35 -----
37 One big problem with LFS is that there is no package management system.  This
38 means that it is a *HUGE* pain in the butt to uninstall something, since there
39 is no record of what got installed where, and by what program.
41 There are lots of other ways to implement "package management" in LFS; but this
42 is the one that I use ;)
44 Notes
45 -----
47 In an attempt to make this easier to read, all "code blocks" that you should
48 execute on the commandline start and end with "##--CODE--##". Quoted text,
49 such as the output of a program, is prefixed with four spaces.
51 Also, if you're trying to use this during the early stages of Chapter 6 in the
52 LFS book, it will fail miserably for you. The reason is that installwatch needs
53 programs to be dynamically linked for it to work; in Chapter 6, all of your
54 programs are statically linked. Installwatch *might* work for you near the end
55 of chapter 6 when most of the static stuff is gone, but I advise not using it
56 until chapter 6 is finished and you're installing other stuff. I've yet to find
57 a program that wouldn't install properly with installwatch, just as long as
58 your stuff is dynamically linked.
60 Requirements
61 ------------
63 You'll need to download installwatch, which you can get from one of these
64 locations:
66 http://asic-linux.com.mx/~izto/checkinstall/installwatch.html
67 http://proyectos.glo.org.mx/checkinstall/installwatch.html
69 If both these sites are down, try this one (but only as a last resort):
71 http://www.google.ca/search?hl=en&q=installwatch+izto+0.6.3&meta=
73 I used version 0.6.3 to write this hint, but other versions should work as well
74 (just as long as their logfiles are in the same format).
76 You'll also need my 'nuke' script, which is used for uninstalling software,
77 among other things. You can get that here:
79 http://www.ualberta.ca/~rbpark/projects/nuke
81 You'll need to download that into /usr/sbin, and chmod it to 750 (rwxr-x---).
82 Yep, it finally grew too large to be included within this hint itself ;)
84 Instructions
85 ------------
87 1. Install Installwatch.
89 Unpack and compile installwatch. Compilation is done like so:
91 ##--CODE--##
92 make &&
93 make install
94 ##--CODE--##
96 2. Fix Make.
98 Make must be owned by the root group:
100 ##--CODE--##
101 chgrp root /usr/bin/make
102 ##--CODE--##
104 I've also heard that installwatch will not work if make is setgid. I'm not sure
105 if this is true, but you might want to make sure it isn't:
107 ##--CODE--##
108 chmod -s /usr/bin/make
109 ##--CODE--##
111 3. Prepare the Filesystem.
113 To use the nuke script, you'll need the /var/install, /var/uninstall, and
114 /var/packages directories, which will be explained later. Create them like this
115 (as root):
117 ##--CODE--##
118 mkdir /var/{install,uninstall,packages}
119 chmod 750 /var/{install,uninstall,packages}
120 ##--CODE--##
122 The install directory will be where we put installwatch's logfiles, and the
123 uninstall directory will be where we put the log of what we deleted with the
124 "nuke" script that I am going to show you next. The packages directory is where
125 we'll store the packages that we can create from installed software.
127 4. Using Installwatch.
129 Now I'm going to show you how to use installwatch to create the logfiles that
130 will be used by the nuke script.
132 When you are reading installation instructions for something, and you see "make
133 install", you'll want to replace that with this:
135 ##--CODE--##
136 installwatch -o /var/install/programname-version make install
137 ##--CODE--##
139 But, if you're too lazy and don't want to remember all that, create an alias
140 similar to this one:
142 ##--CODE--##
143 alias iw='installwatch -o /var/install/$(basename $(pwd))'
144 ##--CODE--##
146 This will take the name of the current directory, and use that as the logfile
147 name to use in /var/install. The idea is that the name of the directory you are
148 compiling source in is descriptive of the software you are compiling. For
149 example, I compiled XMMS in /usr/src/xmms-1.2.7, and this alias created the
150 logfile named "/var/install/xmms-1.2.7". You'll want to put this alias into
151 your bashrc, so that you won't have to recreate the alias every time you start
152 a new shell.
154 If you're going to use this alias as-is, then wherever you see "make install"
155 in the installation instructions for something, you'll have to prefix it with
156 "iw". For example, instead of the standard "./configure && make && make
157 install", you'd type this:
159 ##--CODE--##
160 ./configure && make && iw make install
161 ##--CODE--##
163 5. Using Nuke.
165 The nuke script has many uses, the first and foremost of which is to
166 uninstall software by analyzing installwatch logfiles.
168 Uninstalling software is extremely easy with the nuke script, you simply give
169 it a logfile from /var/install, and it will remove the software from your
170 system, and then create a logfile in /var/uninstall telling you how the
171 uninstall went.
173 Lets say for example, you wanted to uninstall a program called 'foobar 1.0'.
174 Since we have the foobar-1.0 logfile, we can simply do this:
176 ##--CODE--##
177 nuke foobar-1.0
178 ##--CODE--##
180 And nuke will produce some output like this:
182     Processing foobar-1.0 ... done.
183     Uninstalling foobar-1.0 ... successful.
185 The first line simply means it was processing the logfile to determine what
186 files to delete, and the second line means that it deleted them.
188 It also keeps a logfile of what got deleted. This is in /var/uninstall, and has
189 the same name as the logfile in /var/install. This new logfile will look
190 something like this:
192     Removed Files/Directories
193     -------------------------
194     
195     /usr/share/man/man1/foobar.1
196     /usr/bin/foobar
198 This file is in the format of one filename per line, and if there were any
199 errors removing files, the filename will be followed by " -- " and the error
200 message. So you might see something like this:
202     Removed Files/Directories
203     -------------------------
204     
205     /usr/share/foobar/foo -- Permission denied
206     /usr/share/foobar -- Directory not empty
208 Which means that neither were removed.
210 Once you are satisfied that the program was uninstalled properly, you can
211 remove the logfile from /var/uninstall. The nuke script will automatically
212 remove the logfile from /var/install if all of the files were removed properly.
214 6. Nuke's 'Report' Mode.
216 As I mentioned before, nuke has many uses. I already showed you how to use
217 it to uninstall software, now I'm going to show you how to use it to simply
218 see what files got installed with each program.
220 All you have to do is add "--report" (or "-r") to nuke's argument list, like
223 ##--CODE--##
224 nuke --report foobar-1.0
225 ##--CODE--##
227 Now nuke won't remove the program. Instead, it will produce output like this:
229     Processing foobar-1.0 ... done.
230     Files/Directories installed by foobar-1.0
231     -----------------------------------------
232     
233     /usr/share/man/man1/foobar.1:  open, chown, and chmod
234     /usr/bin/foobar:  open, chown, and chmod
236 And this simply means that both of the listed files were created (open),
237 chown'ed, and chmod'ed.
239 7. Nuke's 'Package' Mode.
241 Nuke now has an experimental method of producing packages from logfiles.  These
242 packages are not intended for general distribution (and aren't meant as a
243 replacement for RPMs or anything fancy like that). They don't store any
244 dependancy information, and in fact they are just tarballs.
246 The primary use of these tarballs would be for easily installing a program onto
247 many identical systems (compile once, install everywhere), or as backups for
248 users with lots of HD space, but little processing power (for them, it's easier
249 to install the package than to recompile it).
251 Anyway, to make a package, first you must have installed something with
252 installwatch, and you must have the installwatch logfile (in /var/install).
253 Then you just call nuke with the "--package" (or "-p") option, and it creates
254 the package for you, like this:
256 ##--CODE--##
257 nuke --package foobar-1.0
258 ##--CODE--##
260 This will produce output similar to the following:
262     Processing foobar-1.0 ... done.
263     Packing files from foobar-1.0 into /var/packages/foobar-1.0.fez.pkg ... 
264     /usr/bin/foobar
265     /usr/share/man/man1/foobar.1
266     /var/install/foobar-1.0
268 The .fez.pkg file itself is just a .tar.bz2 file in reality, but there are
269 special options that you have to pass to tar for it to unpack properly,
270 and instead of trying to force you to remember them, I just let the nuke
271 script handle that as well.
273 8. Nuke's 'Install' Mode.
275 The other part of the experimental packaging support in the nuke script
276 is it's ability to install the packages that it creates. All you have to
277 do is put the .fez.pkg file into /var/packages (it's placed there by default),
278 and then run nuke with the "--install" (or "-i") option, like this:
280 ##--CODE--##
281 nuke --install foobar-1.0.fez.pkg
282 ##--CODE--##
284 This will produce output similar to this:
286     Unpacking files from /var/packages/foobar-1.0.fez.pkg ... 
287     /usr/bin/foobar
288     /usr/share/man/man1/foobar.1
289     /var/install/foobar-1.0
291 Which just tells us which files it unpacked, and to where.
293 The End
294 -------
296 Congratulations! You now have an extremely easy method of removing software,
297 packaging software, and installing packages for software that was compiled from
298 source!
300 If you encounter any problems, please let me know. I want to make this as good
301 as it can possibly be ;)
303 Thanks To
304 ---------
306 'Lovechild' (from the linuxjunior.org forums), for the original idea,
307 Zenith Lau <zenithlau@sniic.com>, for symlink fixes in the nuke script,
308 and everybody who reported problems that they found.