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.


> 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?


> 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.
2) I add an option "restore" for update scripts. With this option services
and protocols will be regenerated from backup xml files.


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

Reply via email to