Admin/filesizes
author paulson
Fri, 16 Jun 2000 13:39:21 +0200
changeset 9083 b36787a56a1f
parent 8852 0a129bdd77d7
permissions -rwxr-xr-x
this proof needs more detail

#!/bin/bash
#
# $Id$
#
# filesizes -- calculate and substitute file sizes in isabelle web pages
#
# needs:
# working directory in dist, rpms + webpages generated and copied to dist
# $DISTNAME
# 
# substitutes:
# -norpm:
# {PACKED_SIZE} {PACKED_SIZE_PDF} {UNPACKED_SIZE}
# -rpm:
# {RPM_SML_SIZE} {RPM_BASE_SIZE} {RPM_HOL_SIZE} {RPM_REAL_SIZE}
# {RPM_ZF_SIZE} {RPM_DOCS_SIZE}


PRG=$(basename $0)

function usage()
{
  echo
  echo "Usage: $PRG [-rpm|-norpm]"
  echo
  echo "fill in file sizes and distname in isabelle dist web pages"
  echo
  echo "  Options are:"
  echo "    -rpm     only fill in rpm sizes"
  echo "    -norpm   only fille in other sizes"
  echo "  (do both by default)" 
  echo 
  echo "needs \$DISTNAME environment variable"
  echo "expects to be startet in isabelle dist dir"
  echo
  exit 1
}

function fail()
{
  echo "$1" >&2
  exit 2
}

# check options

if [ $# -ge 2 ]; then
  usage
fi

if [ $# -eq 1 -a "$1" != "-rpm" -a "$1" != "-norpm" ]; then
  usage
fi


# begin work

if [ $# -eq 0 -o "$1" = "-norpm" ]; then

  # check for $DISTNAME
  if [ "$DISTNAME" = "" ]; then    
    echo "Error: \$DISTNAME not set"
    usage
  fi

  PACKED_SIZE=$[ $(wc -c < $DISTNAME.tar.gz) / 1024 ]
  PACKED_SIZE_PDF=$[ $(wc -c < ${DISTNAME}_pdf.tar.gz) / 1024 ]

  UNPACKED_SIZE=$[ $(cat $DISTNAME.tar.gz ${DISTNAME}_pdf.tar.gz | gunzip | wc -c) / 1024 ]

  perl -pi -e \
   "s/{UNPACKED_SIZE}/$UNPACKED_SIZE/g; \ 
    s/{PACKED_SIZE}/$PACKED_SIZE/g; \
    s/{PACKED_SIZE_PDF}/$PACKED_SIZE_PDF/g;" \
      *.html
fi

if [ $# -eq 0 -o "$1" = "-rpm" ]; then
  RPM_SML_SIZE=$[ $(wc -c < rpm/polyml-3X-1.i386.rpm) / 1024 ]
  RPM_BASE_SIZE=$[ $(wc -c < rpm/isabelle.rpm) / 1024 ]
  RPM_HOL_SIZE=$[ $(wc -c < rpm/isabelle-HOL.i386.rpm) / 1024 ]
  RPM_REAL_SIZE=$[ $(wc -c < rpm/isabelle-HOL-Real.i386.rpm) / 1024 ]
  RPM_ZF_SIZE=$[ $(wc -c < rpm/isabelle-ZF.i386.rpm) / 1024 ]
  RPM_DOCS_SIZE=$[ $(wc -c < rpm/isabelle-pdfdocs.rpm) / 1024 ]

  perl -pi -e \
   "s/{RPM_SML_SIZE}/$RPM_SML_SIZE/g; \
    s/{RPM_BASE_SIZE}/$RPM_BASE_SIZE/g; \
    s/{RPM_HOL_SIZE}/$RPM_HOL_SIZE/g; \
    s/{RPM_REAL_SIZE}/$RPM_REAL_SIZE/g; \
    s/{RPM_ZF_SIZE}/$RPM_ZF_SIZE/g; \
    s/{RPM_DOCS_SIZE}/$RPM_DOCS_SIZE/g;" \
      *.html
fi