blob: f12bb9bf92f23c5b6e4ec7373108767e1bad2524 (
plain)
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
#!/bin/sh
set -e
fromrepo=
if [ "$1" = -r ]; then shift; fromrepo=1; fi
top=$(pwd)
jar=$1
bases=$2
dirs=$3
text=$4
bin=$5
shift 5;
files="$@"
HG=${HG:-hg}
stage="$top/${jar%.*}"
mkdir -p "$stage"
sed=$(which sed)
if [ "xoo" = x$(echo foo | sed -E 's/f(o)/\1/' 2>/dev/null) ]
then sed() { $sed -E "$@"; }
else sed() { $sed -r "$@"; }
fi
if test -n "$fromrepo" && $HG root >/dev/null 2>&1
then
root="$($HG root)"
which cygpath >/dev/null 2>&1 && root=$(cygpath $root)
mf="$($HG --config ui.debug=false --config ui.verbose=false manifest)"
find=$(which find)
find() {
echo "$mf" | sed -n "s!$(pwd | sed "s!$root/?!!")/?!!p" |
grep "^$1"
exit 1
}
fi
mungeliterals=$(cat <<'!'
local $/;
$_ = <>;
s{(?<!function )\bliteral\(/\*(.*?)\*/\)}{
my $s = $1;
$s =~ s/[\\']/\\$&/g;
$s =~ s/\n/\\n\\$&/g;
"/* Preprocessors FTW. */ '$s'";
}ges;
print;
!
)
mungeliterals() {
if which perl >/dev/null 2>&1
then perl -e "$mungeliterals"
else cat
fi
}
getfiles() {
filter="\.($(echo $1 | tr ' ' '|'))$"; shift
find "$@" -not -path '*\.hg*' 2>/dev/null | grep -E "$filter" || true
}
copytext() {
mungeliterals <"$1" |
sed -e "s,@VERSION@,$VERSION,g" \
-e "s,@DATE@,$BUILD_DATE,g" \
>"$2"
cmp -s -- "$1" "$2" ||
( echo "modified: $1"; diff -u -- "$1" "$2" | grep '^[-+][^-+]' )
}
[ -f "$jar" ] && rm -f "$jar"
case "$jar" in
/*) ;;
*)
[ -d "$jar" ] && rm -rf "$jar"
jar="$top/$jar";;
esac
for base in $bases
do
(
set -e
cd $base
[ ${jar##*.} != xpi ] && stage="$stage/${base##*/}"
for dir in $dirs
do
for f in $(getfiles "$bin" "$dir")
do
mkdir -p "$stage/${f%/*}"
cp -- "$f" "$stage/$f"
done
for f in $(getfiles "$text" "$dir")
do
mkdir -p "$stage/${f%/*}"
copytext "$f" "$stage/$f"
done
done
for f in $files
do
if [ -f "$f" ]
then
case "$f" in
*.js|*.jsm|*.css|*.dtd|*.xml|*.xul|*.html|*.xhtml|*.xsl|*.properties|*.json)
copytext "$f" "$stage/$f";;
*)
cp -- "$f" "$stage/$f";;
esac
fi
done
true
) || exit 1
done
(
set -e;
cd "$stage";
case "$jar" in
(*/) if [ "$stage" != "$jar" ]; then mv -- * "$jar"; fi;;
(*) zip -9r "$jar" -- *;;
esac
) || exit 1
[ "$stage" != "$jar" ] && rm -rf "$stage"
true
# vim:se ft=sh sts=4 sw=4 et:
|