1
# Makefile to (re-)generate db versions of system database files.
2
# Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
3
# This file is part of the GNU C Library.
4
# Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
6
# The GNU C Library is free software; you can redistribute it and/or
7
# modify it under the terms of the GNU Library General Public License as
8
# published by the Free Software Foundation; either version 2 of the
9
# License, or (at your option) any later version.
11
# The GNU C Library is distributed in the hope that it will be useful,
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
# Library General Public License for more details.
16
# You should have received a copy of the GNU Library General Public
17
# License along with the GNU C Library; see the file COPYING.LIB. If not,
18
# write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19
# Boston, MA 02111-1307, USA. */
22
# XXX: Do not edit this file, it will be overwritten on upgrades. Instead
23
# edit /etc/default/libnss-db.
25
include /etc/default/libnss-db
27
DATABASES = $(wildcard $(addprefix $(ETC)/,$(DBS)))
29
all: $(patsubst %,$(VAR_DB)/%.db,$(notdir $(DATABASES)))
32
$(VAR_DB)/passwd.db: $(ETC)/passwd
33
@echo -n "$(patsubst %.db,%,$(@F))... "
34
@$(AWK) 'BEGIN { FS=":"; OFS=":"; cnt=0 } \
35
/^[ \t]*$$/ { next } \
37
{ printf "0%u ", cnt++; print } \
38
/^[^#]/ { printf ".%s ", $$1; print; \
39
printf "=%s ", $$3; print }' $^ | \
43
$(VAR_DB)/group.db: $(ETC)/group
44
@echo -n "$(patsubst %.db,%,$(@F))... "
45
@$(AWK) 'BEGIN { FS=":"; OFS=":"; cnt=0 } \
46
/^[ \t]*$$/ { next } \
48
{ printf "0%u ", cnt++; print } \
49
/^[^#]/ { printf ".%s ", $$1; print; \
50
printf "=%s ", $$3; print }' $^ | \
54
$(VAR_DB)/ethers.db: $(ETC)/ethers
55
@echo -n "$(patsubst %.db,%,$(@F))... "
56
@$(AWK) 'BEGIN { cnt=0 } \
57
/^[ \t]*$$/ { next } \
59
{ printf "0%u ", cnt++; print } \
60
/^[^#]/ { printf ".%s ", $$1; print; \
61
printf "=%s ", $$2; print }' $^ | \
65
$(VAR_DB)/protocols.db: $(ETC)/protocols
66
@echo -n "$(patsubst %.db,%,$(@F))... "
67
@$(AWK) 'BEGIN { cnt=0 } \
68
/^[ \t]*$$/ { next } \
70
{ printf "0%u ", cnt++; print } \
71
/^[^#]/ { printf ".%s ", $$1; print; \
72
printf "=%s ", $$2; print; \
73
for (i = 3; i <= NF && !($$i ~ /^#/); ++i) \
74
{ printf ".%s ", $$i; print } }' $^ | \
78
$(VAR_DB)/rpc.db: $(ETC)/rpc
79
@echo -n "$(patsubst %.db,%,$(@F))... "
80
@$(AWK) 'BEGIN { cnt=0 } \
81
/^[ \t]*$$/ { next } \
83
{ printf "0%u ", cnt++; print } \
84
/^[^#]/ { printf ".%s ", $$1; print; \
85
printf "=%s ", $$2; print; \
86
for (i = 3; i <= NF && !($$i ~ /^#/); ++i) \
87
{ printf ".%s ", $$i; print } }' $^ | \
91
$(VAR_DB)/services.db: $(ETC)/services
92
@echo -n "$(patsubst %.db,%,$(@F))... "
93
@$(AWK) 'BEGIN { FS="[ \t/]+"; cnt=0 } \
94
/^[ \t]*$$/ { next } \
96
{ printf "0%u ", cnt++; print } \
97
/^[^#]/ { printf ".%s/%s ", $$1, $$3; print; \
98
printf ".%s/ ", $$1; print; \
99
printf "=%s/%s ", $$2, $$3; print; \
100
printf "=%s/ ", $$2; print; \
101
for (i = 4; i <= NF && !($$i ~ /^#/); ++i) \
102
{ printf ".%s/%s ", $$i, $$3; print; \
103
printf ".%s/ ", $$i; print } }' $^ | \
107
$(VAR_DB)/shadow.db: $(ETC)/shadow
108
@echo -n "$(patsubst %.db,%,$(@F))... "
109
@$(AWK) 'BEGIN { FS=":"; OFS=":"; cnt=0 } \
110
/^[ \t]*$$/ { next } \
111
/^[ \t]*#/ { next } \
112
{ printf "0%u ", cnt++; print } \
113
/^[^#]/ { printf ".%s ", $$1; print }' $^ | \
114
(umask 077 && $(MAKEDB) -o $@ -)
116
@if chgrp shadow $@ 2>/dev/null; then \
119
chown 0 $@; chgrp 0 $@; chmod 600 $@; \
121
echo "Warning: The shadow password database $@"; \
122
echo "has been set to be readable only by root. You may want"; \
123
echo "to make it readable by the \`shadow' group depending"; \
124
echo "on your configuration."; \
128
$(VAR_DB)/netgroup.db: $(ETC)/netgroup
129
@echo -n "$(patsubst %.db,%,$(@F))... "
130
@$(AWK) 'BEGIN { cnt=0 } \
131
/^[ \t]*$$/ { next } \
132
/^[ \t]*#/ { next } \
133
{ printf "0%u ", cnt++; print } \
134
/^[^#]/ { end=sub(/\\/, " "); \
135
gsub(/[ \t]+/, " "); \
136
if(end == 1) printf "%s", $$0; else print }' $^ | \