9front - general discussion about 9front
 help / color / mirror / Atom feed
* [9front] [PATCH] grabrfc: update fetching
@ 2023-10-10  3:14 Romano
  2023-10-10 21:33 ` ori
  0 siblings, 1 reply; 2+ messages in thread
From: Romano @ 2023-10-10  3:14 UTC (permalink / raw)
  To: 9front


The canonical server for fetching draft RFCs is defunct for ftp access, so a mirror site is now used. Add -d flag to fetch draft RFCs but otherwise do not. When fetching drafts, also fetch index and abstract files. For both normal and draft RFCs, only look for .txt files as there a lot of other files in remote directories that are not relevant.
---
diff 01a98f25ecef2c291b67a92e39021a3173c59ce2 5e5cea4f135bd19a80ba949bcc72984fa9645721
--- a/lib/rfc/grabrfc
+++ b/lib/rfc/grabrfc
@@ -1,19 +1,27 @@
-#!/bin/rc
-# grabrfc - copy new rfcs and drafts into /lib/rfc
+#!/bin/rc -b
+# grabrfc - copy new rfcs into /lib/rfc
+# grabrfc -d - copy draft rfcs as well
 rfork en
 path=(/bin)
 fn cd
 
+flagfmt='d:drafts'
+eval `''{aux/getflags $*} || exec aux/usage
+
 dom=`{ndb/query sys $sysname dom}
 if(~ $dom '') dom=$sysname
 
-ramfs
-ftpfs -q/ -a $user@$dom ftp.rfc-editor.org	# was ftp.isi.edu
+ftpfs -q/ -a $user@$dom ftp.rfc-editor.org
 
 found=no
 LIB=/lib/rfc
 cd /n/ftp/in-notes
-for(i in rfc*){
+fn cprfc {
+		f=$1
+		shift
+}
+
+for(i in rfc*.txt){
 	target=`{
 		echo $i | sed '
 			s/.txt$//
@@ -31,19 +39,42 @@
 		sed 's/^[0-9]/rfc&/' >$LIB/index
 unmount /n/ftp
 
-ftpfs -q/ -a $user@$dom ftp.ietf.org
+if (~ $drafts '')
+	exit
 
+ftpfs -q/ -a $user@$dom ftp.math.utah.edu
+
 # copy in new ones
 found=no
 LIB=/lib/rfc/drafts
 mkdir -p $LIB
-cd /n/ftp/internet-drafts
-for(i in *){
-	target=$i
+cd /n/ftp/pub/mirrors/ftp.ietf.org/internet-drafts
+for(i in draft-*.txt){
+	target=`{
+		echo $i | sed '
+			s/.txt$//
+			s/draft-//'
+	}
 	if (test ! -e $LIB/$target && test -f $i &&
 	    test `{ls -s $i | sed 's/ .*//'} -ge 2){
-		cp $i $LIB/$target
-		chmod 664 $LIB/$target
-		echo drafts/$i
+			cp $i $LIB/$target
+			chmod 664 $LIB/$target
+			found=yes
+			echo drafts/$target
 	}
 }
+if (~ $found yes) {
+	if (test -f 1id-index.txt)
+		<1id-index.txt sed '
+			s/\.txt//
+			s/draft-//' > $LIB/index
+	if not
+		>[1=2] echo no draft index found
+	if (test -f 1id-abstracts.txt)
+		<1id-abstracts.txt sed '
+			s/\.txt//
+			s/draft-//' > $LIB/abstracts
+	if not
+		>[1=2] echo no abstracts found
+}
+unmount /n/ftp


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [9front] [PATCH] grabrfc: update fetching
  2023-10-10  3:14 [9front] [PATCH] grabrfc: update fetching Romano
@ 2023-10-10 21:33 ` ori
  0 siblings, 0 replies; 2+ messages in thread
From: ori @ 2023-10-10 21:33 UTC (permalink / raw)
  To: 9front

Quoth Romano <unobe@cpan.org>:
> 
> The canonical server for fetching draft RFCs is defunct for ftp access, so a mirror site is now used. Add -d flag to fetch draft RFCs but otherwise do not. When fetching drafts, also fetch index and abstract files. For both normal and draft RFCs, only look for .txt files as there a lot of other files in remote directories that are not relevant.

looks good to me, though we should probably rewrite to fetch over https;
ftp overall is moribund.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-10-10 21:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-10  3:14 [9front] [PATCH] grabrfc: update fetching Romano
2023-10-10 21:33 ` ori

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).