Michael Uleysky wrote: > 2014-02-03 Bruce Dubbs <bruce.du...@gmail.com>: > >> I am getting ready to change the iana file installation in LFS. The >> procedure will be to download: >> >> >> http://anduin.linuxfromscratch.org/sources/LFS/lfs-packages/conglomeration/iana-etc/iana-files-1.0.tar.xz >> >> After unpacking the install will be: >> >> install -m644 -u root -g root services protocols /etc >> install -m744 -u root -g root update* /usr/sbin >> > > I add a simple Makefile for this.
Why add a Makefile for such a simple install? >> Two executable scripts are installed, update-iana-protocols and >> update-iana-services. These scripts create /usr/share/iana-etc if it >> does not exist and use wget (not available in LFS) to get the upstream >> xml files. The scripts then parse the xml files and update >> /etc/protocols and /etc/services as appropriate. >> >> As I write this, I'm thinking that the header of the installed files >> should perhaps also read: >> >> # To update this file, use the update-iana-<file> script. >> > Also include in my patch. > > >> >> We might also want to just number the tarball iana-files-1.tar.xz and >> increment the number as needed without major/minor versions. >> > May be iana-files-$DATE_OF_UPDATE.tar.xz? Seems to be overkill since the only time I foresee this changing is if the upstream xml format changes. We have been using files since 2006 and this is the first time it has come up. >> Other tweaks can be made. Please let me know what you think. >> > I create a patch with some additions: > 1) Simple Makefile for installation. I think, we must also include source > protocol-numbers.xml and service-names-port-numbers.xml in installation. I thought about that, but why is it needed? It's not in the old tarball and we've never needed it. I'm not completely against this though. > 2) I add an option "restore" for update scripts. With this option services > and protocols will be regenerated from backup xml files. Again, this seems to be overkill. The tarball has the needed files if that is needed. Generally the files are just in /etc and don't often change. The only update we've ever needed is to change sunrpc to rpcbind in the services file. Another comment. If we start adding options to the scripts, we need to add at least a help option and perhaps man pages. I'm trying to KISS this change. -- Bruce > > diff -urNd iana-files-1.0/Makefile iana-files-1.0-michael/Makefile > --- iana-files-1.0/Makefile 1970-01-01 10:00:00.000000000 +1000 > +++ iana-files-1.0-michael/Makefile 2014-02-03 20:43:46.571416045 +1100 > @@ -0,0 +1,17 @@ > +PREFIX = > +EXECPREFIX = /usr > +DATAPREFIX = /usr > + > +main: services protocols > + > +install-data: main protocol-numbers.xml service-names-port-numbers.xml > + install -o root -g root -m644 services $(PREFIX)/etc/ > + install -o root -g root -m644 protocols $(PREFIX)/etc/ > + install -o root -g root -m644 -D protocol-numbers.xml > $(DATAPREFIX)/share/iana-etc/protocol-numbers.xml > + install -o root -g root -m644 -D service-names-port-numbers.xml > $(DATAPREFIX)/share/iana-etc/service-names-port-numbers.xml > + > +install-bin: update-iana-protocols update-iana-services > + install -o root -g root -m700 update-iana-protocols > $(EXECPREFIX)/sbin/ > + install -o root -g root -m700 update-iana-services $(EXECPREFIX)/sbin/ > + > +install: install-data install-bin > diff -urNd iana-files-1.0/update-iana-protocols > iana-files-1.0-michael/update-iana-protocols > --- iana-files-1.0/update-iana-protocols 2014-02-03 15:04:08.000000000 > +1100 > +++ iana-files-1.0-michael/update-iana-protocols 2014-02-03 > 20:50:20.594435684 +1100 > @@ -6,6 +6,9 @@ > exit 1 > } > > +RESTORE=0 > +if [ "$1" == "restore" ]; then RESTORE=1; fi > + > if [ $(id -u) -ne 0 ]; then > echo "$0: You must be root to run this script" > exit 1 > @@ -18,18 +21,12 @@ > DATE=$(date) > > mkdir -p $IANA_DIR > -cd $IANA_DIR > - > -if [ -e $FILE ]; then > - mv -f $FILE ${FILE}.backup > -fi > - > -wget $HTTP/protocol-numbers/$FILE || > - die "Could not download $FILE" $LINENO > +cd $IANA_DIR > > PROTOCOLS="BEGIN { > print \"# See the full IANA XML file at: $IANA_DIR/$FILE\" > print \"# Updated $DATE\n\" > + print \"# To update this file, use the update-iana-protocols script\n\" > print \"# protocol num aliases # comments\" > print \"# -------- ----------- ---------------\" > > @@ -45,6 +42,16 @@ > printf \"%-15s %3i %-15s # %s\n\", tolower(n),v,n,d > }" > > -gawk --re-interval -v strip=yes -- "$PROTOCOLS" $FILE > /etc/protocols > -echo "/etc/protocols updated" > +if [ $RESTORE -ne 0 ]; then > + gawk --re-interval -v strip=yes -- "$PROTOCOLS" ${FILE}.backup > > /etc/protocols > + echo "/etc/protocols restored" > +else > + if [ -e $FILE ]; then > + mv -f $FILE ${FILE}.backup > + fi > > + wget $HTTP/protocol-numbers/$FILE || > + die "Could not download $FILE" $LINENO > + gawk --re-interval -v strip=yes -- "$PROTOCOLS" $FILE > /etc/protocols > + echo "/etc/protocols updated" > +fi > diff -urNd iana-files-1.0/update-iana-services > iana-files-1.0-michael/update-iana-services > --- iana-files-1.0/update-iana-services 2014-02-03 15:04:08.000000000 > +1100 > +++ iana-files-1.0-michael/update-iana-services 2014-02-03 > 20:52:28.159442043 +1100 > @@ -6,6 +6,9 @@ > exit 1 > } > > +RESTORE=0 > +if [ "$1" == "restore" ]; then RESTORE=1; fi > + > if [ $(id -u) -ne 0 ]; then > echo "$0: You must be root to run this script" > exit 1 > @@ -18,18 +21,12 @@ > DATE=$(date) > > mkdir -p $IANA_DIR > -cd $IANA_DIR > - > -if [ -e $FILE ]; then > - mv -f $FILE ${FILE}.backup > -fi > - > -wget $HTTP/service-names-port-numbers/$FILE || > - die "Could not download $FILE" $LINENO > +cd $IANA_DIR > > SERVICES="BEGIN { > print \"# See the full IANA XML file at: $IANA_DIR/$FILE\" > print \"# Updated $DATE\n\" > + print \"# To update this file, use the update-iana-services script\" > print \"# The range for assigned ports managed by the IANA is 0-1023.\n\" > print \"# Port Assignments:\n\" > print \"# Keyword Decimal Description\" > @@ -49,6 +46,16 @@ > printf \"%-15s %5i/%-5s # %s\n\", n,u,p,d # services > }" > > -gawk -v strip=yes -- "$SERVICES" $FILE | sed "s/sunrpc /rpcbind/" > > /etc/services > +if [ $RESTORE -ne 0 ]; then > + gawk -v strip=yes -- "$SERVICES" ${FILE}.backup | sed "s/sunrpc > /rpcbind/" > /etc/services > + echo "/etc/services restored" > +else > + if [ -e $FILE ]; then > + mv -f $FILE ${FILE}.backup > + fi > + wget $HTTP/service-names-port-numbers/$FILE || > + die "Could not download $FILE" $LINENO > > -echo "/etc/services updated" > + gawk -v strip=yes -- "$SERVICES" ${FILE} | sed "s/sunrpc /rpcbind/" > > /etc/services > + echo "/etc/services updated" > +fi > > > >> -- Bruce >> -- >> http://linuxfromscratch.org/mailman/listinfo/lfs-dev >> FAQ: http://www.linuxfromscratch.org/faq/ >> Unsubscribe: See the above information page >> > > > -- http://linuxfromscratch.org/mailman/listinfo/lfs-dev FAQ: http://www.linuxfromscratch.org/faq/ Unsubscribe: See the above information page