Enable bash-completion in bash_profile
[pkgusr] / README
1 -*- mode:text; eval:(footnote-balloons) -*-
2 Time-stamp: <Saturday Mar  8, 2014 17:30:08 steve>
3
4 Introduction:
5 ============
6
7 Here are the tools I use for package management on bastard.  It is
8 based _very_ heavily on the LFS hint:
9
10   "More control and package management using package users (v1.4)"
11
12 Which I have included in this repo (see LFS-pkgusr-hint.txt) and is
13 considered essential reading.
14
15 The main differences (enhancements?) these tools have over the
16 original LFS hint are:
17
18          o A set of convenience shell functions for pkg users, and a
19            pseudo "master installer"[1]
20
21          o Make it easy to give individual settings to each pkg user.
22            For example, some pkg users may need ssh/gnupg or $DISPLAY
23            set. 
24
25          o Better build script and .project templates
26
27            As of v1.4 of the hint, Matt uses a central build script
28            and each pkgusr has a "build.conf"... an interesting idea
29            and I may switch to that method one day, but for now I use
30            a build script for each pkgusr.
31
32          o Better uninstall script.
33
34          o Most of the "wrapper" scripts have been updated or
35            rewritten.
36
37          o Includes a `which' script.
38
39          o Includes a `/bin/mail' script.
40
41          o Includes a `lesspipe.sh' script (unashamedly stolen from
42            Pat Volkerding and Slackware.  Thanks, Pat!)
43
44          o A more complete list of "install" directories.
45            Everyone's needs and tastes are different so not everything
46            I have in my list of install directories you'll want.  Edit
47            it to suit you.
48
49          o Includes an elisp library that implements much of the
50            convenience shell functions. [2]
51
52          o Allow pkgusr to run ldconfig as root safely via a wrapper
53            script and sudo.
54
55            Matt uses a setuid C wrapper that calls execve(2) to do
56            this.  Which, IMO, is not the right way to go.  
57            
58
59 You should understand that not everything here can be used straight away.
60 The /bin/mail script, for example, needs Zsh, and Sendmail installed
61 (could probably be rewritten to use bash with very little effort); the
62 ldconfig wrapper needs sudo; if you want to set yourself up as a "master
63 installer", OpenSSL and OpenSSH are needed; and pkgusr.el needs SXEmacs
64 (or XEmacs/Emacs) obviously.
65
66 FHS Note:
67 ========
68
69 As of 2021-02-06 I have switched over to following the current FHS
70 policy that states /bin /sbin /lib /lib64 should all be symlinks into
71 /usr.  This conflicts with a lot of the {B,}LFS build/install
72 instructions that have you move libraries and other binaries into /lib
73 /bin /sbin etc.  You pretty much just gotta ignore that shit and embrace
74 2021... we have cookies!
75
76 Pre-Installation:
77 ================
78
79   1.  Install bison, flex, nano, and less (in that order) into your
80       /tools dir.  Bison, and flex are needed to build binutils in the
81       chroot.  And nano and less make life for the package user so
82       much easier.
83
84       As of LFS SVN-20140303, they still do not install bison and
85       flex in chapter 5.  I think it might be because they install
86       the binutils from gnu (eww), whereas I install the _proper_
87       optimised for Linux binutils from kernel.org which requires
88       bison/flex.  It is also odd that in chapter 6 when they do
89       install these 2 packages, they do them in the wrong order
90       (bison should be done before flex).
91
92   2.  At the point in the book where it has you mount the devpts
93       filesystem, it neglects to mention that you have to specify a
94       mode and gid:
95            mount -vt devpts devpts ${LFS}/dev/pts -o gid=5,mode=620
96
97       Update:  I think LFS has this now, but check anyway.
98
99   3.  Install sudo into your /tools dir.  Sudo is used to let pkgusrs
100       run ldconfig as root, thereby bypassing the annoyance of getting
101       errors about /etc/ld.so.cache not being able to be updated.
102
103       I don't have a LFS build chain anymore so I am not 100% certain
104       if this is possible, but I cannot think of any reasons why it
105       shouldn't be.  Let me know if you have an issue with this step.
106
107   4.  When creating the initial /etc/group file, I don't use the LFS
108       book suggestions.  I have my own set groups that I've been using
109       since 1995, and old habits are so hard to break. :-)
110
111       Anyhoo, here's my initial group file...
112
113 cat>/etc/group<<EOF
114 root:x:0:
115 bin:x:1:
116 daemon:x:2:
117 sys:x:3:
118 adm:x:4:
119 tty:x:5:
120 disk:x:6:
121 lp:x:7:
122 mem:x:8:
123 kmem:x:9:
124 wheel:x:10:
125 floppy:x:11:
126 mail:x:12:
127 news:x:13:
128 uucp:x:14:
129 man:x:15:
130 dialout:x:16:
131 audio:x:17:
132 video:x:18:
133 cdrom:x:19:
134 games:x:20:
135 utmp:x:22:
136 usb:x:23:
137 tape:x:26:
138 nobody:x:98:
139 nogroup:x:99:
140 users:x:1000:
141 EOF
142
143 Installation:
144 ============
145
146 Step 1... Go read that LFS hint.  You'll probably want to read it
147 through a couple of times.
148
149 Step 2... Don't follow the instructions in the LFS hint for how to set
150 things up and where to dump the scripts etc.  Instead see the next
151 section, "Pkgusr Specific Installation".
152
153 Pkgusr Specific Installation
154 ============================
155
156 In the hint it tells you how where and when to put the helper scripts and
157 stuff, which is great, but I have not included the "more-control-scripts"
158 tarball in this repo.  I've rewritten/tweaked most of the scripts and
159 split them out into their respective directories so that I can easily
160 modify and track them.  Because of that you may get a little lost in
161 aligning what the hint says to the files you have in this repo.
162
163 When
164 ----
165 Right _BEFORE_ installing linux libc headers at start of Chap 6 in the
166 LFS book.
167
168 Where
169 -----
170 From _OUTSIDE_ the chroot environment
171
172 Who
173 ---
174 Do this as root
175
176 How
177 ---
178 Copy'n'Paste Fun!
179
180 PKGUSR=/path/to/your/pkgusr/repo/working/dir &&  ## Yeah, edit this bit!
181 cp -va ${PKGUSR}/etc/pkgusr ${LFS}/etc &&
182 chown -vR 0:0 ${LFS}/etc/pkgusr &&
183 install -vm711 -o0 -g0 -d ${LFS}/etc/sudoers.d &&
184 install -vm440 -o0 -g0 ${PKGUSR}/etc/sudoers.d/99-pkgusr \
185     ${LFS}/etc/sudoers.d &&
186 install -vm644 ${PKGUSR}/installdir.lst ${LFS}/root &&
187 install -vm755 ${PKGUSR}/bin/{which,mail} ${LFS}/usr/bin &&
188 install -vm755 ${PKGUSR}/usr/bin/* ${LFS}/usr/bin &&
189 install -vm750 -o0 -g9999 -d ${LFS}/usr/lib/pkgusr &&
190 install -vm550 -o0 -g9999 ${PKGUSR}/usr/lib/pkgusr/* \
191     ${LFS}/usr/lib/pkgusr &&
192 install -vm755 ${PKGUSR}/usr/sbin/{add_package_user,install_package} \
193     ${LFS}/usr/sbin &&
194 install -vm755 ${PKGUSR}/usr/sbin/{group,user}add ${LFS}/tools/bin &&
195 unset PKGUSR
196
197 From this point on you need to re-enter the chroot environment.  So
198 these next (and final) steps are done _INSIDE_ the chroot (as root).
199
200 Create the install group:
201 ------------------------
202
203 groupadd -g 9999 install
204
205
206 Set up the install directories:
207 ------------------------------
208 (you did peruse and edit this list getting rid of things you know for
209 sure you won't need, didn't you?)
210
211 while read dir; do
212     if [ ! -d ${dir} ]; then
213         install -v -m1775 -o0 -g9999 -d ${dir}
214     fi
215 done < /root/installdir.lst
216
217 One last symlink:
218 ----------------
219
220   ln -sv /tools/lib/libncurses.so.5 /usr/lib/libncursesw.so.5
221
222 (don't forget you'll have to remove that before you install ncurses
223 later)
224
225 Alright, where are we up to now?  Well, in the LFS hint you are up to:
226
227   7.2 Walkthrough: Installing linux-libc-headers
228
229 And in the LFS book, you are up to:
230
231   6.7. Linux-3.13.5 API Headers
232
233 So have fun building the rest of your LFS system!
234
235
236 Footnotes: 
237 [1]  The "master installer" is just someone who can change their
238      identity to a pkg user.  It _could_ be root, though I don't
239      recommend it.  I use a ssh->root->su->pkgusr from my personal A/C
240      which is a single "step" (I'm not stopping in a root shell).
241
242 [2]  pkgusr.el is probably fairly SXEmacs-centric, but should work
243      with perhaps minor changes on XEmacs or even GNU/Emacs.
244