Revised draft of SRFI 103, 104 David Van Horn (11 Dec 2009 16:03 UTC)
Different dialects under the same root Vitaly Magerya (11 Dec 2009 18:12 UTC)
Re: Different dialects under the same root Derick Eddington (12 Dec 2009 01:48 UTC)
Re: Different dialects under the same root Vitaly Magerya (12 Dec 2009 12:16 UTC)
A utility for renaming old-style file names Derick Eddington (12 Dec 2009 06:20 UTC)
Re: A utility for renaming old-style file names Göran Weinholt (25 Dec 2009 19:37 UTC)
Re: A utility for renaming old-style file names Derick Eddington (26 Dec 2009 22:54 UTC)

A utility for renaming old-style file names Derick Eddington 12 Dec 2009 06:19 UTC

The new revision of SRFI 103 changes the file name extension for R6RS
library files from .sls and .IMPL.sls to .r6rs-lib and .IMPL-r6rs-lib.
I've made a program to assist with renaming files, and it is available
as the rename-old-style.r6rs-prog file in the tar-ball at:
http://srfi.schemers.org/srfi-104/library-files-utilities.tar.gz .

I've successfully used it to rename the files of my collections of
R6RS libraries, and have tested it with Ikarus and PLT.

It's an R6RS program and it requires the library
(srfi :104 library-files-utilities), available in the same tar-ball,
and a number of libraries from my Xitomatl collection [1] (revision at
least 194 is required (and that revision has old-style file names)).

What follows are instructions for using it and an example.

Its help print-out is:

    Usage: rename-old-style directory rename-command delete-command

    Rename old-style .sls and .IMPL.sls to .r6rs-lib and .IMPL-r6rs-lib,
    also normalizing %-encoding of characters.
    Ask to remove PLT-style versions.
    Ask to rename to implicit file names.
    Ask to rename directories which may need normalizing.
    Ask to delete or rename symbolic links.

    Examples:
      rename-old-style a-collection mv rm
      rename-old-style a-collection "bzr mv" "bzr rm"
      rename-old-style a-collection "echo rename" "echo delete"

    Arguments:
      directory:
	A directory containing library file names to process.
	It may be renamed itself, its contents may be renamed, and it
	is recursively descended to maybe rename in its sub-directories.
      rename-command:
	A shell command prefix which renames files.  It must take two
	arguments: the old file name and the new file name.
      delete-command:
	A shell command prefix which deletes files.  It must take one
	argument: the file name to delete.

The below instructions are for running it on an R6RS system which does
not support SRFI 103 and uses .sls and .IMPL.sls files and does not
support implicit file names.  (It can also be run on a system which
does support SRFI 103, such as my modified Ikarus [2], if new-style
library files exist for the required libraries.)

Step 0: install pre-requisites

$ cd /path/to/search-path
$ bzr checkout --lightweight lp:~derick-eddington/scheme-libraries/xitomatl
$ bzr checkout --lightweight lp:~scheme-libraries-team/scheme-libraries/srfi
$ mkdir srfi/%3a104  # might need to be different, depending on system
$ cd srfi/%3a104
$ wget http://srfi.schemers.org/srfi-104/library-files-utilities.tar.gz
$ tar -x -z -f library-files-utilities.tar.gz

Step 1: setup (srfi :104 library-files-utilities) for use with .sls system

$ cd /path/to/srfi/%3a104
$ ln -s library-files-utilities/main.r6rs-lib library-files-utilities.sls
$ cd library-files-utilities
$ ln -s per-OS.r6rs-lib per-OS.sls
$ ln -s initialize.SYSTEM-r6rs-lib initialize.SYSTEM.sls  # replace SYSTEM

Step 2: rename a collection of library files

$ cd /path/to/search-path
$ ls -l -R %E2%99%A5%CE%BB  # only for example purposes
%E2%99%A5%CE%BB:
-rw-r--r-- %3a*poiuy.%ce%bb.sls
lrwxrwxrwx alias.ajax.sls -> qwerty-3-4.sls
drwxr-xr-x foo%3abar*zab%58blah
-rw-r--r-- foo%3abar*zab%58blah.acme.sls
-rw-r--r-- foo%3abar*zab%58blah.sls
drwxr-xr-x hoho
-rw-r--r-- hoho.sls
-rw-r--r-- qwerty-3-4.sls
%E2%99%A5%CE%BB/foo%3abar*zab%58blah:
-rw-r--r-- asdf.sls
%E2%99%A5%CE%BB/hoho:
-rw-r--r-- hjkl-1-2.sls
-rw-r--r-- hjkl-1-2.super.sls
lrwxrwxrwx hjkl.sls -> hjkl-1-2.sls
lrwxrwxrwx hjkl.super.sls -> hjkl-1-2.super.sls

$ scheme-script /path/to/rename-old-style.r6rs-prog %E2%99%A5%CE%BB mv rm
Rename directory %E2%99%A5%CE%BB ? [yes/no] yes
Delete symlink ♥λ/alias.ajax.sls ? [yes/no] no
Rename symlink ♥λ/alias.ajax.sls ? [yes/no] yes
Rename ♥λ/hoho.sls to implicit file name? [yes/no] no
Remove version of ♥λ/qwerty-3-4.sls ? [yes/no] no
Rename ♥λ/foo%3abar*zab%58blah.acme.sls to implicit file name? [yes/no] yes
Rename ♥λ/foo%3abar*zab%58blah.sls to implicit file name? [yes/no] yes
Rename directory ♥λ/foo%3abar*zab%58blah ? [yes/no] yes
Delete symlink ♥λ/hoho/hjkl.super.sls ? [yes/no] yes
Delete symlink ♥λ/hoho/hjkl.sls ? [yes/no] yes
Remove version of ♥λ/hoho/hjkl-1-2.super.sls ? [yes/no] yes
Remove version of ♥λ/hoho/hjkl-1-2.sls ? [yes/no] yes

$ ls -l -R ♥λ  # only for example purposes
♥λ:
-rw-r--r-- %3A%2Apoiuy.%ce%bb-r6rs-lib  # system name unchanged
lrwxrwxrwx alias.ajax-r6rs-lib -> qwerty-3-4.sls  # now it's a broken symlink
drwxr-xr-x foo%3Abar%2AzabXblah
drwxr-xr-x hoho
-rw-r--r-- hoho.r6rs-lib
-rw-r--r-- qwerty-3-4.r6rs-lib
♥λ/foo%3Abar%2AzabXblah:
-rw-r--r-- asdf.r6rs-lib
-rw-r--r-- main.acme-r6rs-lib
-rw-r--r-- main.r6rs-lib
♥λ/hoho:
-rw-r--r-- hjkl.r6rs-lib
-rw-r--r-- hjkl.super-r6rs-lib

Note that rename-old-style.r6rs-prog can easily be modified to rename
other extensions such as .sps to .r6rs-prog.

[1] https://code.launchpad.net/~derick-eddington/scheme-libraries/xitomatl
[2] https://code.launchpad.net/~derick-eddington/ikarus/ikarus.dev--SRFI-104

--
: Derick
----------------------------------------------------------------