Technical Tips for LPML Methods
 
(DOING THINGS YOU ONLY DREAMT ABOUT WHEN YOU WERE A KID)
LPML icon

Note: you will need to use TAB values instead of spaces inside the listed Makefile's below; see http://www.gnu.org/manual/make/.

Contents
 
1. Using LPML to quickly install files on a cluster of multiple computers
2. Capturing all the WARNINGS and outputting
3. The interactions between LPML, PIML, and XFML

#1. Using LPML to quickly install files on a cluster of multiple computers

Example scenario: output a network identification file to all the computers present within a cluster.

Solution: the following Makefile and hosts.xfml files work to implement the following.

# LPML TECH TIP Example #1a. Makefile

NET_hosts_tab:
	make TIMESTAMP=`date +"%s"` METAMTARGET="TRANSPORT" \
	MTARGET="hosts_tab" HOSTNAME="$(HOSTNAME)" lpmladm

hosts_tab: TEST_hosts_tab
	cat hosts.lpml | \
	perl xfml_parse.pl /home/user/hosts.xfml | \
	perl lpml_parse.pl install $(CATEGORY) $(DIST) "$(SOURCE)" \
	"$(TARGET)" > Makefile.install
	make -f Makefile.install directories
	make -f Makefile.install files
	@echo "If hosts.tab has changed, restart httpd and loncontrol:"
	@echo "   /etc/rc.d/init.d/httpd restart"
	@echo "   /etc/rc.d/init.d/loncontrol restart"

lpmladm:
	@if (test $(METAMTARGET) = "TRANSPORT"); then \
		echo "Transporting to $(HOSTNAME)"; \
		sudo make DIST=$(DIST) CATEGORY=$(CATEGORY) \
		SOURCE="$(SOURCE)" \
		TARGET="lpmladm.$(TIMESTAMP)" \
		NORESTORECONF="$(NORESTORECONF)" "$(MTARGET)"; \
		cd lpmladm.$(TIMESTAMP); \
		sudo tar czvf ../tarball$(TIMESTAMP).tar.gz .; \
		cd ..; scp tarball$(TIMESTAMP).tar.gz \
		lpmladm@$(HOSTNAME):~/tarball$(TIMESTAMP).tar.gz; \
		ssh lpmladm@$(HOSTNAME) sudo mv tarball$(TIMESTAMP).tar.gz /; \
		ssh lpmladm@$(HOSTNAME) sudo tar -x -z -v -C / \
		-p --same-owner -f \
		/tarball$(TIMESTAMP).tar.gz; \
		ssh lpmladm@$(HOSTNAME) sudo rm -f \
		/tarball$(TIMESTAMP).tar.gz; \
	elif (test $(METAMTARGET) = "LAUNCH"); then \
		echo "Launching process on $(HOSTNAME)"; \
		LAUNCHSAVE=$(OUTSTREAM) $(SAVE); \
		make DIST=$(DIST) CATEGORY=$(CATEGORY) SOURCE="$(SOURCE)" \
		TARGET="$(TARGET)" NORESTORECONF="$(NORESTORECONF)" \
		LAUNCH="$(LAUNCHSAVE)" "$(MTARGET)"; \
		scp $(SAVE) lpmladm@$(HOSTNAME):~/$(SAVE); \
		ssh lpmladm@$(HOSTNAME) sudo perl $(SAVE); \
		ssh lpmladm@$(HOSTNAME) sudo rm -f $(SAVE); \
	else \
		echo "**** ERROR **** Incorrect METAMTARGET"; \
	fi

<!-- LPML TECH TIP Example #1b. hosts.xfml -->
<xfml>
<clause>
<when:name match='/^source$/'>
<when:cdata match='!/^loncom\/hosts\.tab$/'>
<choice:exclude nodename='file' />
</when:cdata>
</when:name>
</clause>
<clause>
<choice:exclude nodename='fileglob' />
</clause>
<clause>
<choice:exclude nodename='link' />
</clause>
<clause>
<when:name match='/^targetdir$/'>
<when:cdata match='!/^home\/httpd\/lonTabs$/'>
<choice:exclude nodename='directory' />
</when:cdata>
</when:name>
</clause>
<clause>
<choice:exclude nodename='rpm' />
</clause>
<clause>
<choice:exclude nodename='specialnotices' />
</clause>
</xfml>

Note that the target (HOSTNAME) computer should accept RSARhostsAuthentication protocol over the secure shell from the computer you are entering the commands below on:

 bash$ make HOSTNAME="somwhere.acomputerglows.com" NET_hosts_tab

#2. Capturing all the WARNINGS and outputting

Notice that the make warningnote is called at the end of the install target.
# LPML TECH TIP Example #2a. Makefile

# Shows how the WARNINGS file can be tested after source-to-target installation

install: TEST_hosts_tab Makefile.install Makefile
  echo -n "" > WARNINGS
  make -f Makefile.install SOURCE="$(SOURCE)" TARGET="$(TARGET)" \
  directories
  make -f Makefile.install SOURCE="$(SOURCE)" TARGET="$(TARGET)" files
  make -f Makefile.install SOURCE="$(SOURCE)" TARGET="$(TARGET)" links
  make warningnote

warningnote:
  @if (test -s WARNINGS); then \
    W=`grep -c '\*\*\*\* WARNING' WARNINGS`; \
    E=`grep -c '\*\*\*\* ERROR' WARNINGS`; \
    N=`grep -c '\*\*\*\* NOTE' WARNINGS`; \
    echo "--->  $$W WARNINGS ENCOUNTERED!       "; \
    echo "--->  $$E ERRORS ENCOUNTERED!         "; \
    echo "--->  $$N NOTES ENCOUNTERED!          "; \
    echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"; \
    echo "!!!!  Please read the WARNINGS file !!!!"; \
    echo "!!!!   to make sure everything is   !!!!"; \
    echo "!!!!    correct and taken care of   !!!!"; \
    echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"; \
  fi

#3. The interactions between LPML, PIML, and XFML.


LPML: Linux Packaging Markup Language
XFML: XML Filtering Markup Language
PIML: Post-Installation Markup Language
SourceForge.net Logo