1#!/bin/bash 2# 3# zipman.sh - Compress man and info pages 4# 5# Copyright (c) 2011-2018 Pacman Development Team <pacman-dev@archlinux.org> 6# 7# This program is free software; you can redistribute it and/or modify 8# it under the terms of the GNU General Public License as published by 9# the Free Software Foundation; either version 2 of the License, or 10# (at your option) any later version. 11# 12# This program is distributed in the hope that it will be useful, 13# but WITHOUT ANY WARRANTY; without even the implied warranty of 14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15# GNU General Public License for more details. 16# 17# You should have received a copy of the GNU General Public License 18# along with this program. If not, see <http://www.gnu.org/licenses/>. 19# 20 21[[ -n "$LIBMAKEPKG_TIDY_ZIPMAN_SH" ]] && return 22LIBMAKEPKG_TIDY_ZIPMAN_SH=1 23 24LIBRARY=${LIBRARY:-'@libmakepkgdir@'} 25 26source "$LIBRARY/util/message.sh" 27source "$LIBRARY/util/option.sh" 28 29 30packaging_options+=('zipman') 31tidy_modify+=('tidy_zipman') 32 33tidy_zipman() { 34 if check_option "zipman" "y" && [[ -n ${MAN_DIRS[*]} ]]; then 35 msg2 "$(gettext "Compressing man and info pages...")" 36 local file files inode link 37 while read -rd ' ' inode; do 38 read file 39 find ${MAN_DIRS[@]} -type l 2>/dev/null | 40 while read -r link ; do 41 if [[ "${file}" -ef "${link}" ]] ; then 42 rm -f "$link" "${link}.gz" 43 if [[ ${file%/*} = ${link%/*} ]]; then 44 ln -s -- "${file##*/}.gz" "${link}.gz" 45 else 46 ln -s -- "/${file}.gz" "${link}.gz" 47 fi 48 fi 49 done 50 if [[ -z ${files[$inode]} ]]; then 51 files[$inode]=$file 52 gzip -9 -n -f "$file" 53 else 54 rm -f "$file" 55 ln "${files[$inode]}.gz" "${file}.gz" 56 chmod 644 "${file}.gz" 57 fi 58 done < <(find ${MAN_DIRS[@]} -type f \! -name "*.gz" \! -name "*.bz2" \ 59 -exec @INODECMD@ '{}' + 2>/dev/null) 60 fi 61} 62