]> git.pld-linux.org Git - packages/rpm.git/blob - rpm-compress-doc
- added *.css to files excluded from compression
[packages/rpm.git] / rpm-compress-doc
1 #!/bin/sh
2 #
3 # Compress documentation files found in $DOCDIR. Omit some files we don't
4 # want to get compressed.
5 #
6 # $RPM_BUILD_DIR/__rpm_noautocompressdoc can contain whitespace delimated
7 # list of patters to ommit.
8 #
9
10 #set -x
11
12 COMPRESS_CMD="gzip -9nf"
13 EXCLUDE_SUFFIXES="htm html jpg jpeg png gif pdf css"
14 EXCLUDE_MASKS=
15 RECOMPRESS_BZIP2=yes
16
17 if test -f $RPM_BUILD_DIR/__rpm_noautocompressdoc ; then
18         EXCLUDE_MASKS=$(cat $RPM_BUILD_DIR/__rpm_noautocompressdoc | \
19                         xargs echo | sed -e 's/^ *//; s/ *$//; s/ \+/|/g')
20 fi
21
22 if [ "$DOCDIR" = "" ] ; then
23         echo '$DOCDIR not set; exiting.'
24         exit 1
25 fi
26
27 cd $DOCDIR
28
29 echo "Compressing documentation in $DOCDIR..."
30
31 if test "$EXCLUDE_MASKS" ; then
32         echo "Excluding pattern '$EXCLUDE_MASKS'"
33 fi
34
35 FIND_CMD="find . -type f "
36 for SUF in $EXCLUDE_SUFFIXES ; do
37         FIND_CMD="$FIND_CMD -a -not -name '*.$SUF'"
38 done
39
40 eval $FIND_CMD | while read FILENAME ; do
41         if test -n "$EXCLUDE_MASKS" ; then
42                 if eval "case \$(basename \"$FILENAME\") in
43                          $EXCLUDE_MASKS ) true ;;
44                          * ) false ;;
45                          esac" ; then
46                         continue
47                 fi
48         fi
49         case $FILENAME in
50         *.gz | *.Z)
51                 gzip -d $FILENAME
52                 FILENAME=$(echo $FILENAME | sed -e 's/\.gz$//; s/\.Z$//')
53                 ;;
54         *.bz2)
55                 if [ "$RECOMPRESS_BZIP2" = yes ] ; then
56                         bzip2 -d $FILENAME
57                         FILENAME=$(echo $FILENAME | sed -e 's/\.bz2$//')
58                 else
59                         continue
60                 fi
61                 ;;
62         esac
63
64         $COMPRESS_CMD $FILENAME
65
66         echo -n "$FILENAME "
67 done
68
69 echo
70 echo "Documentation compressed."
This page took 0.066193 seconds and 4 git commands to generate.