about summary refs log tree commit diff
path: root/nss/db-Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'nss/db-Makefile')
-rw-r--r--nss/db-Makefile68
1 files changed, 68 insertions, 0 deletions
diff --git a/nss/db-Makefile b/nss/db-Makefile
new file mode 100644
index 0000000000..881cabfa4b
--- /dev/null
+++ b/nss/db-Makefile
@@ -0,0 +1,68 @@
+DATABASES = $(wildcard /etc/passwd /etc/group /etc/ethers /etc/protocols \
+		       /etc/rpc /etc/services /etc/shadow)
+
+VAR_DB = /var/db
+
+AWK = awk
+MAKEDB = makedb --quiet
+
+all: $(patsubst %,$(VAR_DB)/%.db,$(notdir $(DATABASES)))
+
+
+$(VAR_DB)/passwd.db: /etc/passwd
+	@echo -n "$(patsubst %.db,%,$(@F))... "
+	@$(AWK) 'BEGIN { FS=":"; OFS=":" } \
+		 /^[^#]/ { printf ".%s ", $$1; print; \
+			   printf "=%s ", $$3; print }' $^ | \
+	$(MAKEDB) -o $@ -
+	@echo "done."
+
+$(VAR_DB)/group.db: /etc/group
+	@echo -n "$(patsubst %.db,%,$(@F))... "
+	@$(AWK) 'BEGIN { FS=":"; OFS=":" } \
+		 /^[^#]/ { printf ".%s ", $$1; print; \
+			   printf "=%s ", $$3; print }' $^ | \
+	$(MAKEDB) -o $@ -
+	@echo "done."
+
+$(VAR_DB)/ethers.db: /etc/ethers
+	@echo -n "$(patsubst %.db,%,$(@F))... "
+	@$(AWK) '/^[^#]/ { printf ".%s ", $$1; print; \
+			   printf "=%s ", $$2; print }' $^ | \
+	$(MAKEDB) -o $@ -
+	@echo "done."
+
+$(VAR_DB)/protocols.db: /etc/protocols
+	@echo -n "$(patsubst %.db,%,$(@F))... "
+	@$(AWK) '/^[^#]/ { printf ".%s ", $$1; print; \
+			   printf "=%s ", $$2; print; \
+			   for (i = 3; i <= NF && !($$i ~ /^#/); ++i) \
+			     { printf ".%s ", $$i; print } }' $^ | \
+	$(MAKEDB) -o $@ -
+	@echo "done."
+
+$(VAR_DB)/rpc.db: /etc/rpc
+	@echo -n "$(patsubst %.db,%,$(@F))... "
+	@$(AWK) '/^[^#]/ { printf ".%s ", $$1; print; \
+			   printf "=%s ", $$2; print; \
+			   for (i = 3; i <= NF && !($$i ~ /^#/); ++i) \
+			     { printf ".%s ", $$i; print } }' $^ | \
+	$(MAKEDB) -o $@ -
+	@echo "done."
+
+$(VAR_DB)/services.db: /etc/services
+	@echo -n "$(patsubst %.db,%,$(@F))... "
+	@$(AWK) 'BEGIN { FS="[ \t/]+" } \
+		 /^[^#]/ { printf ".%s/%s ", $$1, $$3; print; \
+			   printf "=%s/%s ", $$2, $$3; print; \
+			   for (i = 4; i <= NF && !($$i ~ /^#/); ++i) \
+			     { printf ".%s/%s ", $$i, $$3; print } }' $^ | \
+	$(MAKEDB) -o $@ -
+	@echo "done."
+
+$(VAR_DB)/shadow.db: /etc/shadow
+	@echo -n "$(patsubst %.db,%,$(@F))... "
+	@$(AWK) 'BEGIN { FS=":"; OFS=":" } \
+		 /^[^#]/ { printf ".%s ", $$1; print }' $^ | \
+	$(MAKEDB) -o $@ -
+	@echo "done."