-
Notifications
You must be signed in to change notification settings - Fork 76
/
synclibs.sh
executable file
·204 lines (164 loc) · 4.93 KB
/
synclibs.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
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
#!/bin/sh
# Script that synchronizes the local library dependencies
#
# Version: 20240414
EXIT_SUCCESS=0;
EXIT_FAILURE=1;
GIT_URL_PREFIX="https://github.com/libyal";
LOCAL_LIBS="libbfio libcaes libcdata libcdatetime libcerror libcfile libclocale libcnotify libcpath libcsplit libcthreads libfcache libfdata libfdatetime libfguid libfvalue libhmac libodraw libsmdev libsmraw libuna";
OLDIFS=$IFS;
IFS=" ";
for LOCAL_LIB in ${LOCAL_LIBS};
do
GIT_URL="${GIT_URL_PREFIX}/${LOCAL_LIB}.git";
git clone --quiet ${GIT_URL} ${LOCAL_LIB}-$$;
if ! test -d ${LOCAL_LIB}-$$;
then
echo "Unable to git clone: ${GIT_URL}";
IFS=$OLDIFS;
exit ${EXIT_FAILURE};
fi
(cd ${LOCAL_LIB}-$$ && git fetch --quiet --all --tags --prune)
LATEST_TAG=`cd ${LOCAL_LIB}-$$ && git describe --tags --abbrev=0`;
if test -n ${LATEST_TAG} && test "$1" != "--use-head";
then
echo "Synchronizing: ${LOCAL_LIB} from ${GIT_URL} tag ${LATEST_TAG}";
(cd ${LOCAL_LIB}-$$ && git checkout --quiet tags/${LATEST_TAG});
else
echo "Synchronizing: ${LOCAL_LIB} from ${GIT_URL} HEAD";
fi
rm -rf ${LOCAL_LIB};
mkdir ${LOCAL_LIB};
if ! test -d ${LOCAL_LIB};
then
echo "Missing directory: ${LOCAL_LIB}";
IFS=$OLDIFS;
exit ${EXIT_FAILURE};
fi
LOCAL_LIB_UPPER=`echo "${LOCAL_LIB}" | tr "[a-z]" "[A-Z]"`;
# Note that sed on FreeBSD does not support \s hence that we use [[:space:]] instead.
LOCAL_LIB_VERSION=`grep -A 2 AC_INIT ${LOCAL_LIB}-$$/configure.ac | tail -n 1 | sed 's/^[[:space:]]*\[\([0-9]*\)\],[[:space:]]*$/\1/'`;
LOCAL_LIB_MAKEFILE_AM="${LOCAL_LIB}/Makefile.am";
cp ${LOCAL_LIB}-$$/${LOCAL_LIB}/*.[chly] ${LOCAL_LIB};
cp ${LOCAL_LIB}-$$/${LOCAL_LIB_MAKEFILE_AM} ${LOCAL_LIB_MAKEFILE_AM};
# Make the necessary changes to libyal/Makefile.am
SED_SCRIPT="/AM_CPPFLAGS = / {
i\\
if HAVE_LOCAL_${LOCAL_LIB_UPPER}
}
/lib_LTLIBRARIES = / {
s/lib_LTLIBRARIES/noinst_LTLIBRARIES/
}
/${LOCAL_LIB}\.c/ {
d
}
/${LOCAL_LIB}_la_LIBADD/ {
:loop1
/${LOCAL_LIB}_la_LDFLAGS/ {
N
i\\
endif
d
}
/${LOCAL_LIB}_la_LDFLAGS/ !{
N
b loop1
}
}
/${LOCAL_LIB}_la_LDFLAGS/ {
N
i\\
endif
d
}
/DISTCLEANFILES = / {
n
/${LOCAL_LIB}_definitions.h/ {
d
}
}";
echo "${SED_SCRIPT}" >> ${LOCAL_LIB}-$$.sed;
sed -i'~' -f ${LOCAL_LIB}-$$.sed ${LOCAL_LIB_MAKEFILE_AM};
rm -f ${LOCAL_LIB}-$$.sed;
sed -i'~' "/AM_CPPFLAGS = /,/noinst_LTLIBRARIES = / { N; s/\\\\\\n.@${LOCAL_LIB_UPPER}_DLL_EXPORT@//; P; D; }" ${LOCAL_LIB_MAKEFILE_AM};
sed -i'~' "/${LOCAL_LIB}_definitions.h.in/d" ${LOCAL_LIB_MAKEFILE_AM};
sed -i'~' "/${LOCAL_LIB}\\.rc/d" ${LOCAL_LIB_MAKEFILE_AM};
if test ${LOCAL_LIB} = "libfplist";
then
# TODO: make this more generic to strip the last \\
sed -i'~' '/EXTRA_DIST = /,/^$/s/libfplist_xml_scanner.c \\/libfplist_xml_scanner.c/' ${LOCAL_LIB_MAKEFILE_AM};
elif test ${LOCAL_LIB} = "libodraw";
then
# TODO: make this more generic to strip the last \\
sed -i'~' '/EXTRA_DIST = /,/^$/s/libodraw_cue_scanner.c \\/libodraw_cue_scanner.c/' ${LOCAL_LIB_MAKEFILE_AM};
else
sed -i'~' '/EXTRA_DIST = /,/^$/d' ${LOCAL_LIB_MAKEFILE_AM};
fi
SED_SCRIPT="/^$/ {
x
N
/endif$/ {
a\\
D
}
}";
echo "${SED_SCRIPT}" >> ${LOCAL_LIB}-$$.sed;
sed -i'~' -f ${LOCAL_LIB}-$$.sed ${LOCAL_LIB_MAKEFILE_AM};
rm -f ${LOCAL_LIB}-$$.sed;
# Make the necessary changes to libcfile/Makefile.am
if test ${LOCAL_LIB} = "libcfile";
then
if ! test -f "m4/libuna.m4";
then
sed -i'~' 's?@LIBUNA_CPPFLAGS@?-I../libuna -I$(top_srcdir)/libuna?' ${LOCAL_LIB_MAKEFILE_AM};
fi
fi
# Make the necessary changes to libfplist/Makefile.am
if test ${LOCAL_LIB} = "libfplist";
then
if test -f "m4/libfdatetime.m4";
then
sed -i'~' '/@LIBFGUID_CPPFLAGS@/{h; s/FGUID/FDATETIME/; p; g;}' ${LOCAL_LIB_MAKEFILE_AM};
fi
fi
# Make the necessary changes to libfvalue/Makefile.am
if test ${LOCAL_LIB} = "libfvalue";
then
if ! test -f "m4/libfdatetime.m4";
then
sed -i'~' '/@LIBFDATETIME_CPPFLAGS@/d' ${LOCAL_LIB_MAKEFILE_AM};
fi
if ! test -f "m4/libfguid.m4";
then
sed -i'~' '/@LIBFGUID_CPPFLAGS@/d' ${LOCAL_LIB_MAKEFILE_AM};
fi
if ! test -f "m4/libfwnt.m4";
then
sed -i'~' '/@LIBFWNT_CPPFLAGS@/d' ${LOCAL_LIB_MAKEFILE_AM};
fi
if ! test -f "m4/libuna.m4";
then
sed -i'~' '/@LIBUNA_CPPFLAGS@/d' ${LOCAL_LIB_MAKEFILE_AM};
fi
fi
# Make the necessary changes to libsmraw/Makefile.am
if test ${LOCAL_LIB} = "libsmraw";
then
if test -f "m4/libfdatetime.m4";
then
sed -i'~' '/@LIBFVALUE_CPPFLAGS@/{h; s/FVALUE/FDATETIME/; p; g;}' ${LOCAL_LIB_MAKEFILE_AM};
fi
if test -f "m4/libfguid.m4";
then
sed -i'~' '/@LIBFVALUE_CPPFLAGS@/{h; s/FVALUE/FGUID/; p; g;}' ${LOCAL_LIB_MAKEFILE_AM};
fi
fi
# Remove libyal/libyal.c
rm -f ${LOCAL_LIB}/${LOCAL_LIB}.c;
# Make the necessary changes to libyal/libyal_defitions.h
cp ${LOCAL_LIB}-$$/${LOCAL_LIB}/${LOCAL_LIB}_definitions.h.in ${LOCAL_LIB}/${LOCAL_LIB}_definitions.h;
sed -i'~' "s/@VERSION@/${LOCAL_LIB_VERSION}/" ${LOCAL_LIB}/${LOCAL_LIB}_definitions.h;
rm -rf ${LOCAL_LIB}-$$;
done
IFS=$OLDIFS;
exit ${EXIT_SUCCESS};