Admin/filesizes
author wenzelm
Mon, 13 Mar 2000 13:21:39 +0100
changeset 8434 5e4bba59bfaa
parent 8071 49dfba2f2325
child 8852 0a129bdd77d7
permissions -rwxr-xr-x
use HOLogic.Not; export indexify_names;

#!/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/smlnj-110.0-3.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