-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
111 lines (78 loc) · 3.21 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
include /etc/os-release
NAME = pam_checkhomedir
VERSION = 0.0.4
CC=gcc
CFLAGS=-I. -lm
DEPS =
OBJ =
PREFIX =
%.o: %.c $(DEPS)
$(CC) -c -fPIC -o $@ $< $(CFLAGS)
$(NAME):
echo "$(ID_LIKE)"
$(CC) -fPIC -shared -o [email protected] [email protected] $(CFLAGS)
test%:
$(CC) -o a.$@ [email protected] $< $(CFLAGS)
clean:
rm -rvf *.o a.* *.so $(NAME)-$(VERSION)/ rpm/$(NAME)-$(VERSION).tar.gz
###
### Installers
###
install: install_bin install_conf install_docs
install_bin: install_bin_$(ID_LIKE)
install_conf: install_conf_$(ID_LIKE)
source: pam_checkhomedir
mkdir -p $(NAME)-$(VERSION)
cp -v LICENSE $(NAME)-$(VERSION)/
cp -v pam_checkhomedir.8 $(NAME)-$(VERSION)/
cp -v pam_checkhomedir.so $(NAME)-$(VERSION)/
cp -v README.md $(NAME)-$(VERSION)/
tar czvf rpm/$(NAME)-$(VERSION).tar.gz $(NAME)-$(VERSION)/
install_docs:
install -v -o root -g root -m 755 pam_checkhomedir.8 $(PREFIX)/usr/share/man/man8/
install_bin_"debian": install_bin_debian
install_bin_debian:
install -v -o root -g root -m 755 pam_checkhomedir.so $(PREFIX)/lib/x86_64-linux-gnu/security/
install_conf_"debian": install_conf_debian
install_conf_debian:
install -v -o root -g root -m 755 checkhomedir $(PREFIX)/usr/share/pam-configs/checkhomedir
pam-auth-update --package
install_bin_"fedora": install_bin_fedora
install_bin_fedora:
install -v -o root -g root -m 755 pam_checkhomedir.so $(PREFIX)/usr/lib64/security/
install_conf_"fedora": install_conf_fedora
install_conf_fedora:
grep -q pam_checkhomedir.so /etc/pam.d/system-auth || perl -i -pe 's/(^auth.*pam_env.so.*$$)/$$1\nauth required pam_checkhomedir.so /' /etc/pam.d/system-auth
grep -q pam_checkhomedir.so /etc/pam.d/password-auth || perl -i -pe 's/(^auth.*pam_env.so.*$$)/$$1\nauth required pam_checkhomedir.so /' /etc/pam.d/password-auth
###
### Uninstallers
###
uninstall: uninstall_bin uninstall_conf uninstall_docs
uninstall_bin: uninstall_bin_$(ID_LIKE)
uninstall_conf: uninstall_conf_$(ID_LIKE)
uninstall_docs:
rm -vf /usr/share/man/man8/pam_checkhomedir.8
uninstall_bin_"debian": uninstall_bin_debian
uninstall_bin_debian:
rm -vf /usr/lib64/security/pam_checkhomedir.so
uninstall_conf_"debian": uninstall_conf_debian
uninstall_conf_debian:
rm -vf /usr/share/pam-configs/checkhomedir
pam-auth-update --package
uninstall_bin_"fedora": uninstall_bin_fedora
uninstall_bin_fedora:
rm -vf /usr/lib64/security/pam_checkhomedir.so
uninstall_conf_"fedora": uninstall_conf_fedora
uninstall_conf_fedora:
perl -i -pe 's/^.*pam_checkhomedir.*\n$$//' /etc/pam.d/system-auth
perl -i -pe 's/^.*pam_checkhomedir.*\n$$//' /etc/pam.d/password-auth
updateversion: clean
@(( NEWVER )) || echo 'update version requires define NEWVER. (e.g. make NEWVER=x.x.x updateversion)'
@(( NEWVER )) || exit
@echo $(NEWVER)
# perl -i -pe 's/^(VERSION =).*/\1 $(NEWVER)/' Makefile
# perl -i -pe 's/^(.*#define __PCHD_VERSION__).*$$/ \1 "$(NEWVER)" /' $(NAME).c
# perl -i -pe 's/^(.*#define __PCHD_VERSION_D__).*$$/ \1 $(NEWVER) /' $(NAME).c
# cp -v rpm/$(NAME)-$(VERSION).spec rpm/$(NAME)-$(NEWVER).spec
# perl -i -pe 's/^(%define.*version.*)%d.*$$/ \1 $(NEWVER) /' rpm/$(NAME)-$(NEWVER).spec
# perl -i -pe "s/.TH.*$/.TH man 8 \"$$(date "+%d %b %Y")\" \"$(NEWVER)\" \"$(NAME) man page\" " $(NAME).8