2
# vim: set foldmethod=marker tw=0 commentstring=\ #%s :
4
########################################################################
6
# export-texmf_files : Generate flat data file, for texmfind utility, on
7
# a Gentoo box with integral dev-texlive/dev-tex installation . Not
8
# intended for end users.
10
# Copyright (C) 2008 Alexandre
12
# This program is free software: you can redistribute it and/or modify
13
# it under the terms of the GNU General Public License as published by
14
# the Free Software Foundation, either version 3 of the License, or
15
# (at your option) any later version.
17
# This program is distributed in the hope that it will be useful,
18
# but WITHOUT ANY WARRANTY; without even the implied warranty of
19
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20
# GNU General Public License for more details.
22
# You should have received a copy of the GNU General Public License
23
# along with this program, located in /usr/share/doc/texmfind/licence.
24
# If not, see <http://www.gnu.org/licenses/>.
26
# The author can be contacted by email : etux@bluewin.ch
28
#########################################################################
30
# Intermediary output list files to... ?
32
# Pattern for texmf installed files ?
33
texmf_path_pattern="/usr/share/texmf*"
36
# Each file should have an associated function sharing the same name.
37
# Files will be built by those functions in the order they appear here,
40
files=( "texmf_all" # List of all texmf regular files.
41
"texmf_qfiles" # Add corresponding ebuild to file list.
42
"texmf_format" # Format previous file for further processing.
43
"texmf_noboring" # Boring files removed from previous file.
44
"texmf_files" # Last format. Ready for production :p
48
echo "${tmp_files_path}/${1}"
51
# Prepend files with tmp path
52
for (( i=0; i < ${#files[@]}; i++ )); do
53
files[${i}]=$(tmp ${files[${i}]})
58
previous_file () { #{{{
59
# Given a (fullpath) filename existing in ${files}, will return the
60
# previous (fullpath) filename in the list.
62
for (( i=0; i < ${#files[@]}; i++ )); do
63
if [[ ${file} == ${files[${i}]} ]]; then
66
elif [[ ${file} == ${files[(${i}+1)]} ]]; then
73
texmf_common () { #{{{
75
if [[ -e ${file} ]]; then
77
"* File \"%s\" allready exists; Skipping.\n\t-> (To rebuild, just delete it).\n\n" \
81
prev=$(previous_file ${file})
82
eval "${func} ${file} ${prev}"
88
find ${texmf_path_pattern} -type f > ${file}
90
"* Found %d texmf regular files.\n\t-> %s\n\n" \
91
$(cat ${file} | wc -l) \
95
texmf_qfiles () { #{{{
98
printf "* Appending ebuild to each file (might take some time).\n\t-> %s\n\n" ${file}
99
qfile -Cf ${prev} > ${file}
102
texmf_format () { #{{{
105
printf "* Format output to new file\n\t -> %s\n\n" ${file}
106
sedex="(.*)[[:space:]]\((.*\/(.*))\)"
107
sed -re "s/${sedex}/\2 \1 \3/" ${prev} > ${file}
110
texmf_noboring () { #{{{
111
# Using sed to remove some boring files from list.
114
# Boring pattern #{{{
116
"[0-9]{0,2}read\.*me|"\
125
"img[0-9]{0,2}\.gif|"\
145
boring_file=$(tmp "texmf_boring")
146
sed -r -e "\@(.*[[:space:]]){2}(${boring_pattern}).*@Id" ${prev} > ${file}
147
diff ${prev} ${file} > ${boring_file}
148
removed=$(cat ${boring_file} | sed "\@^[0-9]@d" | wc -l)
150
"* Removed %d boring files from list.\n\t -> %s\n\t -> %s\n\n" \
156
texmf_files () { #{{{
159
awk '{ print $3, $2 }' ${prev} > ${file}
160
supertmp="${tmp_files_path}/supertmp"
161
sort ${file} > ${supertmp}
162
# Remove files duplicated in different places by the same ebuild
163
uniq ${supertmp} > ${file}
164
removed=$(( $(cat ${supertmp} | wc -l) - $(cat ${file} | wc -l) ))
167
printf "* Removed %d dups from list. " ${removed}
169
"Final output (copied to \$HOME).\n\t -> %s\n\n" \
174
# For each file, trigger its associated function.#{{{
175
for f in ${files[@]}; do
176
eval "texmf_common ${f}"
180
printf "If you dont need to keep tmp files for posterity, you can remove \"texmf_*\" files from %s.\n" ${tmp_files_path}