1: # The NSDL to LON-CAPA Gateway Server
2:
3: # Scott Harrison
4: # $Id: Makefile,v 1.8 2002/10/13 06:25:16 harris41 Exp $
5:
6: # Quick usage:
7: # Either type "make all" (compiles and installs code onto your system), or
8: # type "make tardist" and use the distributable tarball.
9:
10: DISTPROBE=`perl ./distprobe`
11: DIST=$(DISTPROBE)
12: CATEGORY="development"
13: SOURCE=..
14: TARGET=""
15: NORESTORECONF="0"
16: HOSTNAME=""
17: LAUNCH=| perl
18: OUTSTREAM=>
19: SAVE=program.pl.$(TIMESTAMP)
20: LAUNCHSAVE=$(OUTSTREAM) $(SAVE)
21: METAMTARGET=""
22: MTARGET=""
23: VERSION=0.1
24: DIRTARGET=nsdl
25:
26: help:
27: @echo "*** You need to specify a valid target ***"
28: @echo "To get a list of valid targets: \"make help_TARGETS\""
29: @echo "To get a list of valid options: \"make help_OPTIONS\""
30: @echo " "
31: @echo "Typically invoked targets are:"
32: @echo " make build"
33: @echo " make install"
34: @echo " make all"
35: @echo " make tardist"
36: @echo " make clean"
37:
38: help_OPTIONS:
39: @echo "You can specify options to your Makefile target."
40: @echo "(option) DIST can be redhat6, redhat7, debian2.2, or default"
41: @echo "(option) CATEGORY can be runtime or development"
42: @echo "(option) SOURCE is an absolute or relative directory path"
43: @echo "(option) TARGET is an absolute or relative directory path"
44:
45: help_TARGETS:
46: @echo "Valid targets"
47: @echo "build: compile the CVS source tree"
48: @echo "install: install from a compiled CVS source tree to a "
49: @echo " specified TARGET destination on the filesystem"
50: @echo "test: test different parts of the LON-CAPA system (TEST_*)"
51: @echo "TEST_lpml: make sure that the system can process "
52: @echo " the Linux Packaging Markup Language"
53: @echo "TEST_system_dependencies: make sure that all needed system "
54: @echo " components are active and present "
55: @echo " on the server such as perl modules"
56: @echo " and the MySQL database"
57: @echo "TEST_weblayer: mimic various web-based interactions with "
58: @echo " respect to the login and various system "
59: @echo " actions on the Gateway server"
60: @echo "HTML: generate an HTML-formatted description of the "
61: @echo " NSDL to LON-CAPA Gateway Server CVS source files"
62: @echo "doc: compiles documentation for the system administration of"
63: @echo " the gateway server"
64: @echo "status: compare the TARGET filesystem with a compiled CVS "
65: @echo " source directory"
66: @echo "statuspost: post the results of "make status" to "
67: @echo " TARGET/home/httpd/html/lon-status/filestatus.html"
68: @echo "rpmstatus: compare the rpms on a system to defined lists "
69: @echo " CVS:doc/otherfiles/cd_rpms and "
70: @echo " CVS:doc/otherfiles/rpm_list.txt"
71: @echo "rpmstatuspost: post the results of "make rpmstatus" to "
72: @echo " TARGET/home/httpd/html/lon-status/rpmstatus.html"
73: @echo "tardist: build a tarball that will upgrade the software on a "
74: @echo " system"
75:
76: build: Makefile.build
77: echo -n "" > WARNINGS
78: make -f Makefile.build all
79: make warningnote
80:
81: Makefile.build: Makefile alwaysrun
82: cat gatewayfiles.lpml | \
83: perl lpml_parse.pl build $(CATEGORY) $(DIST) "$(SOURCE)" \
84: "$(TARGET)" > Makefile.build
85:
86: NET_install:
87: make TIMESTAMP=`date +"%s"` METAMTARGET="TRANSPORT" \
88: MTARGET="install" HOSTNAME="$(HOSTNAME)" lpmladm
89: make warningnote
90:
91: install: Makefile.install
92: @echo -n "" > WARNINGS
93: make -f Makefile.install SOURCE="$(SOURCE)" TARGET="$(TARGET)" \
94: directories
95: make -f Makefile.install SOURCE="$(SOURCE)" TARGET="$(TARGET)" files
96: make warningnote
97:
98: Makefile.install: Makefile alwaysrun
99: cat gatewayfiles.lpml | \
100: perl lpml_parse.pl install $(CATEGORY) $(DIST) "$(SOURCE)" \
101: "$(TARGET)" > Makefile.install
102:
103: alwaysrun:
104:
105: test: TEST_lpml TEST_system_dependencies TEST_weblayer
106: @echo "ALL TESTS SUCCESSFUL"
107:
108: TEST_lpml:
109: @echo "TESTING LPML INSTALLATION MECHANISM"
110: cd lpml_test; perl filecomparetest.pl
111:
112: TEST_system_dependencies:
113: @echo "TESTING WEB LAYER"
114: @echo "not yet implemented"
115:
116: TEST_weblayer:
117: @echo "TESTING SYSTEM DEPENDENCIES"
118: @echo "not yet implemented"
119:
120: HTML:
121: install -d HTML
122: cp $(SOURCE)/doc/gatewayfiles/*.gif HTML
123: cat gatewayfiles.lpml | \
124: perl lpml_parse.pl html development default "$(SOURCE)" '$(TARGET)' \
125: > HTML/index.html
126:
127: doc:
128: @echo "Not yet implemented"
129:
130: status:
131: @echo "Not yet implemented"
132:
133: statuspost:
134: @echo "Not yet implemented"
135:
136: tardist:
137: @echo "Not yet fully implemented"
138: make MANIFEST_all
139: make vanillatar
140: @cd $(SOURCE); \
141: if (test -h $(DIRTARGET)); then \
142: echo "$(DIRTARGET) link already defined; assume okay"; \
143: else \
144: ln -s . $(DIRTARGET); \
145: fi
146: cd $(SOURCE); \
147: tar --no-recursion --numeric-owner --files-from MANIFEST \
148: -h -czf $(DIRTARGET).tar.gz 2>tar_WARNINGS || [ "0" == "0" ]
149: cat $(SOURCE)/tar_WARNINGS | \
150: xargs --replace=XXX echo '**** WARNING **** XXX' > WARNINGS
151: rm -f $(SOURCE)/tar_WARNINGS
152: make warningnote
153:
154: # ------------------------------------ Top-level files such as UPDATE and TEST.
155: vanillatar:
156: # --------------------------- Point UPDATE to the internal make process
157: echo '#!/bin/sh' > $(SOURCE)/UPDATE
158: echo 'touch build/WARNINGS' >> $(SOURCE)/UPDATE;
159: echo 'ln -s build/WARNINGS WARNINGS' >> $(SOURCE)/UPDATE;
160: echo 'cd build; make build' >> $(SOURCE)/UPDATE
161: echo 'make install' >> $(SOURCE)/UPDATE
162: echo 'make warningnote' >> $(SOURCE)/UPDATE
163: # ----------------------------- Point TEST to the internal make process
164: echo '#!/bin/sh' > $(SOURCE)/TEST
165: echo 'cd build; make test' >> $(SOURCE)/TEST
166: # ----------------------- vanilla executables must indeed be executable
167: chmod a+rx $(SOURCE)/UPDATE
168: chmod a+rx $(SOURCE)/TEST
169:
170: MANIFEST_all:
171: rm -f $(SOURCE)/MANIFEST
172: make MANIFEST_lpml
173: make MANIFEST_vanillatar
174:
175: MANIFEST_lpml:
176: cat $(SOURCE)/build/buildfiles.lpml | \
177: perl lpml_parse.pl MANIFEST development default \
178: '$(SOURCE)' '$(TARGET)' | grep '[[:alnum:]]' | \
179: perl -nle 'print "$(DIRTARGET)/$$_"' >> $(SOURCE)/MANIFEST
180: cat $(SOURCE)/build/testfiles.lpml | \
181: perl lpml_parse.pl MANIFEST development default \
182: '$(SOURCE)' '$(TARGET)' | grep '[[:alnum:]]' | \
183: perl -nle 'print "$(DIRTARGET)/$$_"' >> $(SOURCE)/MANIFEST
184: cat $(SOURCE)/build/gatewayfiles.lpml | \
185: perl lpml_parse.pl MANIFEST development default \
186: '$(SOURCE)' '$(TARGET)' | grep '[[:alnum:]]' | \
187: perl -nle 'print "$(DIRTARGET)/$$_"' >> $(SOURCE)/MANIFEST
188:
189: # ------------ Files for top-level (the vanilla layer that the user first sees)
190: MANIFEST_vanillatar:
191: echo '$(DIRTARGET)/README' >> $(SOURCE)/MANIFEST
192: echo '$(DIRTARGET)/UPDATE' >> $(SOURCE)/MANIFEST
193: echo '$(DIRTARGET)/TEST' >> $(SOURCE)/MANIFEST
194:
195: warningnote:
196: @if (test -s WARNINGS); then \
197: W=`grep -c '\*\*\*\* WARNING' WARNINGS`; \
198: E=`grep -c '\*\*\*\* ERROR' WARNINGS`; \
199: N=`grep -c '\*\*\*\* NOTE' WARNINGS`; \
200: echo "---> $$W WARNINGS ENCOUNTERED! "; \
201: echo "---> $$E ERRORS ENCOUNTERED! "; \
202: echo "---> $$N NOTES ENCOUNTERED! "; \
203: echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"; \
204: echo "!!!! Please read the WARNINGS file !!!!"; \
205: echo "!!!! to make sure everything is !!!!"; \
206: echo "!!!! correct and taken care of !!!!"; \
207: echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"; \
208: fi
209:
210: lpmladm:
211: @if (test $(METAMTARGET) = "TRANSPORT"); then \
212: echo "Transporting to $(HOSTNAME)"; \
213: sudo mkdir lpmladm.$(TIMESTAMP); \
214: sudo make DIST=$(DIST) CATEGORY=$(CATEGORY) \
215: SOURCE="$(SOURCE)" \
216: TARGET="lpmladm.$(TIMESTAMP)" \
217: NORESTORECONF="$(NORESTORECONF)" "$(MTARGET)"; \
218: cd lpmladm.$(TIMESTAMP); \
219: sudo tar czf ../tarball$(TIMESTAMP).tar.gz .; \
220: cd ..; scp tarball$(TIMESTAMP).tar.gz \
221: lpmladm@$(HOSTNAME):~/tarball$(TIMESTAMP).tar.gz; \
222: sudo rm -Rf lpmladm.$(TIMESTAMP); \
223: sudo rm -f tarball$(TIMESTAMP).tar.gz; \
224: ssh lpmladm@$(HOSTNAME) sudo mv tarball$(TIMESTAMP).tar.gz /; \
225: ssh lpmladm@$(HOSTNAME) sudo tar -x -z -C / \
226: -p --same-owner -f \
227: /tarball$(TIMESTAMP).tar.gz; \
228: ssh lpmladm@$(HOSTNAME) sudo rm -f \
229: /tarball$(TIMESTAMP).tar.gz; \
230: elif (test $(METAMTARGET) = "LAUNCH"); then \
231: echo "Launching process on $(HOSTNAME)"; \
232: LAUNCHSAVE=$(OUTSTREAM) $(SAVE); \
233: make DIST=$(DIST) CATEGORY=$(CATEGORY) SOURCE="$(SOURCE)" \
234: TARGET="$(TARGET)" NORESTORECONF="$(NORESTORECONF)" \
235: LAUNCH="$(LAUNCHSAVE)" "$(MTARGET)"; \
236: scp $(SAVE) lpmladm@$(HOSTNAME):$(SAVE); \
237: ssh lpmladm@$(HOSTNAME) sudo -u $(LAUNCHUSER) perl $(SAVE); \
238: else \
239: echo "**** ERROR **** Incorrect METAMTARGET"; \
240: fi
241: # ssh lpmladm@$(HOSTNAME) sudo rm -f $(SAVE); \
242:
243: clean:
244: @echo "Not yet implemented"
245: rm -f ../java/*.class
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>