-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmake-submission.sh
executable file
·93 lines (72 loc) · 3.11 KB
/
make-submission.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/bin/bash
# make-submission.sh
# This script is for pulling together the files needed to submit our
# paper to the arXiv, and stripping out the LaTeX comments to avoid
# and potential embarrassment or secrets.
# USAGE
# Since we send .bbl files to the arXiv, make sure that you've
# successfully compiled the paper first before running this script
#
# If there are files for inclusion that are not in the directory or
# below (i.e. the relative path starts with ..) then we assume it's a
# figure and don't try to preserve the relative path.
# Therefore make sure you're using a \graphicspath{{a/}{b/}} directive
# so that figures can be moved!
# 26 Jan 2015 - Leo C. Stein <[email protected]>
# 16 Dec 2015 - edited by LCS
# 9 Feb 2017 - LCS: also ignore commas in "<use ..." strings.
# 14 Nov 2018 - LCS: Switch from stripcomments.pl to latexpand
# 2 Feb 2019 - LCS: Use mkjobtexmf for list of figures, add flattening of above-dir files
TEMP=`mktemp /tmp/temp.XXXX`
MASTER='polpars'
############################################################
echo ${MASTER}.tex > cp-files
echo ${MASTER}.bbl >> cp-files
# Anything that isn't caught by the code below
cat extra-files >> cp-files
# get list of figures and other files we need
mkjobtexmf --jobname ${MASTER} --cmd-tex pdflatex 2>&1 > /dev/null
grep INPUT ${MASTER}.fls | sed -e '/texmf/d' \
-e '/.out/d' \
-e '/.aux/d' \
-e 's/INPUT //' \
-e "/${MASTER}.tex/d" \
-e "/${MASTER}.bbl/d" | sort | uniq >> cp-files
############################################################
# make subdirs
grep -o -E '^.+/' cp-files | sort | uniq > subdirs
mkdir -p submission;
for i in `cat subdirs`; do mkdir -p submission/$i; done;
# copy everything over
rm -f tar-files
for i in `cat cp-files`; do
j=$i;
if [[ $i == ..* ]]; then
j=$(basename $i);
fi
cp -af $i submission/$j;
echo $j >> tar-files
done
############################################################
# Add our ancillary files by hand
############################################################
# strip the tex files
for i in `find submission -name '*.tex'`; do
latexpand $i --keep-includes --empty-comments -o $TEMP;
mv $TEMP $i;
done
############################################################
# wrap it up
# The COPYFILE_DISABLE environment variable is for mac os x's version
# of tar, which otherwise would include stupid hidden attribute files.
COPYFILE_DISABLE=true tar -c -C submission -T tar-files -z -f ${MASTER}.tar.gz
############################################################
# # For making submission a little easier: prepare some arXiv metadata into a text file
# echo "Title:" > arXiv-metadata.txt
# grep '\\title' ${MASTER}.tex | head -1 | sed -e 's/\\title{//' -e 's/}//' >> arXiv-metadata.txt
# echo "Authors:" >> arXiv-metadata.txt
# echo "Comments:" >> arXiv-metadata.txt
# echo "" >> arXiv-metadata.txt
############################################################
# Remove sideproducts
rm -r cp-files ${MASTER}.mjt tar-files submission subdirs