]>
Commit | Line | Data |
---|---|---|
19361cb7 | 1 | # Makefile to (re-)generate db versions of system database files. |
74015205 | 2 | # Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc. |
19361cb7 UD |
3 | # This file is part of the GNU C Library. |
4 | # Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996. | |
5 | # | |
41bdb6e2 | 6 | |
19361cb7 | 7 | # The GNU C Library is free software; you can redistribute it and/or |
41bdb6e2 AJ |
8 | # modify it under the terms of the GNU Lesser General Public |
9 | # License as published by the Free Software Foundation; either | |
10 | # version 2.1 of the License, or (at your option) any later version. | |
19361cb7 UD |
11 | |
12 | # The GNU C Library is distributed in the hope that it will be useful, | |
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
41bdb6e2 AJ |
15 | # Lesser General Public License for more details. |
16 | ||
17 | # You should have received a copy of the GNU Lesser General Public | |
18 | # License along with the GNU C Library; if not, write to the Free | |
19 | # Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA | |
20 | # 02111-1307 USA. | |
19361cb7 | 21 | |
6e953631 | 22 | DATABASES = $(wildcard /etc/passwd /etc/group /etc/ethers /etc/protocols \ |
a68b0d31 | 23 | /etc/rpc /etc/services /etc/shadow /etc/netgroup) |
6e953631 UD |
24 | |
25 | VAR_DB = /var/db | |
26 | ||
27 | AWK = awk | |
28 | MAKEDB = makedb --quiet | |
29 | ||
30 | all: $(patsubst %,$(VAR_DB)/%.db,$(notdir $(DATABASES))) | |
31 | ||
32 | ||
33 | $(VAR_DB)/passwd.db: /etc/passwd | |
34 | @echo -n "$(patsubst %.db,%,$(@F))... " | |
afd4eb37 | 35 | @$(AWK) 'BEGIN { FS=":"; OFS=":"; cnt=0 } \ |
ecb9d3e1 UD |
36 | /^[ \t]*$$/ { next } \ |
37 | /^[ \t]*#/ { next } \ | |
afd4eb37 | 38 | { printf "0%u ", cnt++; print } \ |
6e953631 | 39 | /^[^#]/ { printf ".%s ", $$1; print; \ |
74015205 | 40 | printf "=%s ", $$3; print }' $^ | \ |
6e953631 UD |
41 | $(MAKEDB) -o $@ - |
42 | @echo "done." | |
43 | ||
44 | $(VAR_DB)/group.db: /etc/group | |
45 | @echo -n "$(patsubst %.db,%,$(@F))... " | |
afd4eb37 | 46 | @$(AWK) 'BEGIN { FS=":"; OFS=":"; cnt=0 } \ |
ecb9d3e1 UD |
47 | /^[ \t]*$$/ { next } \ |
48 | /^[ \t]*#/ { next } \ | |
afd4eb37 | 49 | { printf "0%u ", cnt++; print } \ |
6e953631 UD |
50 | /^[^#]/ { printf ".%s ", $$1; print; \ |
51 | printf "=%s ", $$3; print }' $^ | \ | |
52 | $(MAKEDB) -o $@ - | |
53 | @echo "done." | |
54 | ||
55 | $(VAR_DB)/ethers.db: /etc/ethers | |
56 | @echo -n "$(patsubst %.db,%,$(@F))... " | |
afd4eb37 | 57 | @$(AWK) 'BEGIN { cnt=0 } \ |
ecb9d3e1 UD |
58 | /^[ \t]*$$/ { next } \ |
59 | /^[ \t]*#/ { next } \ | |
afd4eb37 UD |
60 | { printf "0%u ", cnt++; print } \ |
61 | /^[^#]/ { printf ".%s ", $$1; print; \ | |
6e953631 UD |
62 | printf "=%s ", $$2; print }' $^ | \ |
63 | $(MAKEDB) -o $@ - | |
64 | @echo "done." | |
65 | ||
66 | $(VAR_DB)/protocols.db: /etc/protocols | |
67 | @echo -n "$(patsubst %.db,%,$(@F))... " | |
afd4eb37 | 68 | @$(AWK) 'BEGIN { cnt=0 } \ |
ecb9d3e1 UD |
69 | /^[ \t]*$$/ { next } \ |
70 | /^[ \t]*#/ { next } \ | |
afd4eb37 UD |
71 | { printf "0%u ", cnt++; print } \ |
72 | /^[^#]/ { printf ".%s ", $$1; print; \ | |
6e953631 UD |
73 | printf "=%s ", $$2; print; \ |
74 | for (i = 3; i <= NF && !($$i ~ /^#/); ++i) \ | |
75 | { printf ".%s ", $$i; print } }' $^ | \ | |
76 | $(MAKEDB) -o $@ - | |
77 | @echo "done." | |
78 | ||
79 | $(VAR_DB)/rpc.db: /etc/rpc | |
80 | @echo -n "$(patsubst %.db,%,$(@F))... " | |
afd4eb37 | 81 | @$(AWK) 'BEGIN { cnt=0 } \ |
ecb9d3e1 UD |
82 | /^[ \t]*$$/ { next } \ |
83 | /^[ \t]*#/ { next } \ | |
afd4eb37 UD |
84 | { printf "0%u ", cnt++; print } \ |
85 | /^[^#]/ { printf ".%s ", $$1; print; \ | |
6e953631 UD |
86 | printf "=%s ", $$2; print; \ |
87 | for (i = 3; i <= NF && !($$i ~ /^#/); ++i) \ | |
88 | { printf ".%s ", $$i; print } }' $^ | \ | |
89 | $(MAKEDB) -o $@ - | |
90 | @echo "done." | |
91 | ||
92 | $(VAR_DB)/services.db: /etc/services | |
93 | @echo -n "$(patsubst %.db,%,$(@F))... " | |
afd4eb37 | 94 | @$(AWK) 'BEGIN { FS="[ \t/]+"; cnt=0 } \ |
ecb9d3e1 UD |
95 | /^[ \t]*$$/ { next } \ |
96 | /^[ \t]*#/ { next } \ | |
afd4eb37 | 97 | { printf "0%u ", cnt++; print } \ |
6e953631 | 98 | /^[^#]/ { printf ".%s/%s ", $$1, $$3; print; \ |
ecb9d3e1 | 99 | printf ".%s/ ", $$1; print; \ |
6e953631 | 100 | printf "=%s/%s ", $$2, $$3; print; \ |
ecb9d3e1 | 101 | printf "=%s/ ", $$2; print; \ |
6e953631 | 102 | for (i = 4; i <= NF && !($$i ~ /^#/); ++i) \ |
ecb9d3e1 UD |
103 | { printf ".%s/%s ", $$i, $$3; print; \ |
104 | printf ".%s/ ", $$i; print } }' $^ | \ | |
6e953631 UD |
105 | $(MAKEDB) -o $@ - |
106 | @echo "done." | |
107 | ||
108 | $(VAR_DB)/shadow.db: /etc/shadow | |
109 | @echo -n "$(patsubst %.db,%,$(@F))... " | |
afd4eb37 | 110 | @$(AWK) 'BEGIN { FS=":"; OFS=":"; cnt=0 } \ |
ecb9d3e1 UD |
111 | /^[ \t]*$$/ { next } \ |
112 | /^[ \t]*#/ { next } \ | |
afd4eb37 | 113 | { printf "0%u ", cnt++; print } \ |
6e953631 | 114 | /^[^#]/ { printf ".%s ", $$1; print }' $^ | \ |
361d49e6 | 115 | (umask 077 && $(MAKEDB) -o $@ -) |
6e953631 | 116 | @echo "done." |
361d49e6 UD |
117 | @if chgrp shadow $@ 2>/dev/null; then \ |
118 | chmod g+r $@; \ | |
119 | else \ | |
118bad87 | 120 | chown 0 $@; chgrp 0 $@; chmod 600 $@; \ |
361d49e6 UD |
121 | echo; \ |
122 | echo "Warning: The shadow password database $@"; \ | |
123 | echo "has been set to be readable only by root. You may want"; \ | |
124 | echo "to make it readable by the \`shadow' group depending"; \ | |
125 | echo "on your configuration."; \ | |
126 | echo; \ | |
127 | fi | |
a68b0d31 UD |
128 | |
129 | $(VAR_DB)/netgroup.db: /etc/netgroup | |
130 | @echo -n "$(patsubst %.db,%,$(@F))... " | |
afd4eb37 | 131 | @$(AWK) 'BEGIN { cnt=0 } \ |
ecb9d3e1 UD |
132 | /^[ \t]*$$/ { next } \ |
133 | /^[ \t]*#/ { next } \ | |
afd4eb37 UD |
134 | { printf "0%u ", cnt++; print } \ |
135 | /^[^#]/ { end=sub(/\\/, " "); \ | |
a68b0d31 UD |
136 | gsub(/[ \t]+/, " "); \ |
137 | if(end == 1) printf "%s", $$0; else print }' $^ | \ | |
138 | $(MAKEDB) -o $@ - | |
139 | @echo "done." |