lilypond-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Md5sums and lilypond repository - First contribution


From: Philippe Neyrat
Subject: Md5sums and lilypond repository - First contribution
Date: Mon, 29 Nov 2010 08:41:28 +0000 (UTC)
User-agent: Loom/3.14 (http://gmane.org/)

This message was rejected at address@hidden, cause I'm not a
member of the list...
So I try to re-sent it there...

Hello,

I'm a simple user of Lilypond and I'm not sure this is the good place
for me to write a message, but I don't really know where to ask...

First of all, as a user, I'd like the repositories to show md5sums of
different versions of Lilypond. But for the moment, nothing can prevent
lilypond users from bad transfer from the net.

On the french lilypond user list, one asked for it, and I decide to try
to write some GPL stuff for the community...

So I wrote this script, "mkrcmd5f" (Make recursive md5 files),
which enable you to create, recursively in a directory tree, a file,
generally called "md5sums.txt", containing a list of all the md5sum
hashes of each file in the directory.
It is written in bash, for linux-like systems, so I hope you don't use
another very famous and popular operating system...
I'd like to know if you can use it on the repositories, in order to have
files with md5sum hashes of the different versions of Lilypond.

You can modify it (names of files generated, choice of hash method, etc.).

I hope this script will be useful.
I'd like to know if you'll use it, and, if yes, tell me how I could
write it in a better way.

Don't forget to change the owner of the script as "root", and enable
execution only for root...

It contains nothing malicious.

if (I'm not in a good place to ask that)
Then (Sorry...)
else (Thanks, bye.)

Philippe

********************Script mkrcmd5f version 1.0 ***********

#!/bin/bash
VERSION=1.0
# mkrcfmd5 : version 1.0
# Make md5sums of files, recursively in a directory tree, from the root of it,
# and for each files which is not a directory or a "special file".
# (c) Philippe Neyrat 2010 [philippe DOT neyrat AT sfr DOT fr]
# Execute this scrip as root, as it writes in the directory tree.
# You MUST run it at the root of the directories you want to proceed in.
# If there is already a "md5sums.txt" file in the directory, it is replaced by
the new one.
# The md5sums.txt files which are created are readable by normal user...

# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at
# your option) any later version.

# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see http://www.gnu.org/licenses/.

# Change the followings according to your needs, for example if you prefer SHA1
encryption,
# or if you prefer your files named like "SHA256sums_of_all_that_stuff.txt"...

ROOT_UID=0                  # Only users with $UID 0 have root privileges.
E_NOTROOT=87                # Non-root exit error.
E_WRONGARGS=89              # Invalid arguments error.
TMP_FILE_NAME=/tmp/md5sum   # Temporary file name part to collect md5sums.
CYPHER=/usr/bin/md5sum      # Commant to be executed on each file.
MD5FILENAME="md5sums.txt"   # Name of the created md5sums file in each 
directory.

# function treat () : accepts only one argument : a path to a directory.
# If it's a non-empty directory, executes the function on the directory.
# If it finds a "normal" file, executes CYPHER on it and saves the result in a
new file,
# but if it's a link, a pipe, a block, an already existing "md5sum.txt" file,
# or some other special file or socket, don't do anything...
treat ()
{
   WRITE_IN=`basename $1`
   cd $1

   # Creates a new unique temporary file.
   TMP_FILE=${TMP_FILE_NAME}${WRITE_IN}
   touch "$TMP_FILE"

   for file in *
   do
      if [[ -d "$file" && -s "$file" ]]
      then 
      {
         ( treat $file )
      }
      elif [[ -f "$file" && -s "$file" && ! -h "$file" && ! -p "$file" && ! -b
"$file" && ! -S "$file" && ! -c "$file" ]]
      then
      {
         if [[ ! "$file" == "$MD5FILENAME" ]]
         then
         {
            $CYPHER "$file" >> $TMP_FILE
         }
         fi
      }
      fi
   done
   # When it's done, copies the tmp file, if not empty, in the current 
directory,
   # and erases it from the tmp directory. If empty, erases it.
   if [[ -s "$TMP_FILE" ]]
   then
   {
       cp "$TMP_FILE" "$MD5FILENAME" && rm -f "$TMP_FILE" && chmod go-wx
"$MD5FILENAME" && chmod go+r "$MD5FILENAME"
   }
   else
   {
      rm -f "$TMP_FILE"
   }
   fi
cd ..
} # end of function treat.

# Run as root, of course.
if [ "$UID" -ne "$ROOT_UID" ]
then
  echo -e "`basename $0` (version $VERSION)\nYou must be root to run this
script.\nYou better use \"sudo\" at least\nExiting...\n"
  exit $E_NOTROOT
fi

# If argument is missing or invalid, exit.
if [[ -z "$1" || "$#" -ne 1 || ! -d "$1" ]]
   then echo -e "`basename $0` (version $VERSION)\nUSAGE : `basename $0`
<Directory>\nUse a complete path, or launch it at the root of the directory you
want to proceed in.\nExiting...\n" >&2 && exit $E_WRONGARGS
   else ( echo -e "`basename $0` (version $VERSION)\n" ; treat $1 )
fi

# Hope this helps... 

exit 0

****************End Script mkrcmd5f version 1.0 ***********




reply via email to

[Prev in Thread] Current Thread [Next in Thread]