Use HG revision, fallback to date for local files

This commit is contained in:
DJ Lucas 2017-09-22 11:50:47 -05:00
parent 1a1f396832
commit 0adb08d7e8
2 changed files with 18 additions and 9 deletions

View File

@ -2,6 +2,7 @@
- Provide -r/--rebuild option - Provide -r/--rebuild option
- Add -g/--get option to download using only s_client - Add -g/--get option to download using only s_client
- Always add REVISION value to installed certdata.txt - Always add REVISION value to installed certdata.txt
- Use HG revision value (fall back to date for local files)
0.1 - Check executable bit for CERTUTIL, KEYTOOL, and OPENSSL 0.1 - Check executable bit for CERTUTIL, KEYTOOL, and OPENSSL
- Allow global configuration file - Allow global configuration file
- Use correct license text (MIT) - Use correct license text (MIT)

26
make-ca
View File

@ -405,8 +405,16 @@ mkdir -p "${TEMPDIR}"/{certs,ssl/{certs,java},pki/{nssdb,anchors},work}
# Download certdata.txt if selected # Download certdata.txt if selected
if test "${GET}" == "1"; then if test "${GET}" == "1"; then
HOST=$(echo "${URL}" | /usr/bin/cut -d / -f 3) HOST=$(echo "${URL}" | /usr/bin/cut -d / -f 3)
_url=$(echo "${URL}" | sed 's@raw-file@log@')
echo GET ${_url} | \
${OPENSSL} s_client -ign_eof -connect ${HOST}:443 2>/dev/null > "${TEMPDIR}/certdata.txt.log"
unset _url
REVISION=$(grep -m1 "<i>" "${TEMPDIR}/certdata.txt.log" | cut -d "<" -f 1)
echo GET ${URL} | \ echo GET ${URL} | \
${OPENSSL} s_client -ign_eof -connect ${HOST}:443 2>/dev/null > "${CERTDATA}" ${OPENSSL} s_client -ign_eof -connect ${HOST}:443 2>/dev/null >> "${CERTDATA}"
_line=$(( $(grep -n "certdata.txt" "${CERTDATA}" | cut -d ":" -f 1) - 1))
sed -e "1,${_line}d" -i "${CERTDATA}"
sed "1i # Revision:${REVISION}" -i "${CERTDATA}"
fi fi
if test ! -r "${CERTDATA}"; then if test ! -r "${CERTDATA}"; then
@ -416,14 +424,14 @@ if test ! -r "${CERTDATA}"; then
exit 1 exit 1
fi fi
VERSION=$(grep CVS_ID "${CERTDATA}" | cut -d " " -f 8) REVISION=$(grep "^# Revision" "${CERTDATA}" | cut -d ":" -f 2)
if test "${VERSION}x" == "x"; then if test "${REVISION}x" == "x"; then
echo "WARNING! ${CERTDATA} has no 'Revision' in CVS_ID" echo "WARNING! ${CERTDATA} has no 'Revision' value."
echo "Will run conversion unconditionally." echo "Will run conversion unconditionally."
sleep 2 sleep 2
VERSION="$(date -u +%Y%m%d-%H%M)" REVISION="$(date -u +%Y%m%d-%H%M)"
echo "#CVS_ID @# \$ RCSfile: certdata.txt \$ \$Revision: ${VERSION} \$ \$Date: \$" > "${WORKDIR}/certdata.txt" echo "# Revision:${REVISION}" > "${WORKDIR}/certdata.txt"
else else
if test "${FORCE}" == "1"; then if test "${FORCE}" == "1"; then
@ -431,11 +439,11 @@ else
sleep 2 sleep 2
elif test "${DESTDIR}x" == "x"; then elif test "${DESTDIR}x" == "x"; then
test -f "${CABUNDLE}" && test -f "${CABUNDLE}" &&
OLDVERSION=$(grep "^VERSION:" "${CABUNDLE}" | cut -d ":" -f 2) OLDVERSION=$(grep "^# Revision:" "${CABUNDLE}" | cut -d ":" -f 2)
fi fi
fi fi
if test "${OLDVERSION}x" == "${VERSION}x"; then if test "${OLDVERSION}x" == "${REVISION}x"; then
echo "No update required! Use --force to update anyway." echo "No update required! Use --force to update anyway."
exit 0 exit 0
fi fi
@ -606,7 +614,7 @@ bundledir=`echo "${CABUNDLE}" | sed "s@/${bundlefile}@@"`
install -vdm755 "${DESTDIR}${bundledir}" 2>&1>/dev/null install -vdm755 "${DESTDIR}${bundledir}" 2>&1>/dev/null
test -f "${DESTDIR}${CABUNDLE}" && mv "${DESTDIR}${CABUNDLE}" \ test -f "${DESTDIR}${CABUNDLE}" && mv "${DESTDIR}${CABUNDLE}" \
"${DESTDIR}${CABUNDLE}.old" "${DESTDIR}${CABUNDLE}.old"
echo "VERSION:${VERSION}" > "${DESTDIR}${CABUNDLE}" echo "# Revision:${REVISION}" > "${DESTDIR}${CABUNDLE}"
cat "${TEMPDIR}/ssl/ca-bundle.crt.tmp" >> "${DESTDIR}${CABUNDLE}" && cat "${TEMPDIR}/ssl/ca-bundle.crt.tmp" >> "${DESTDIR}${CABUNDLE}" &&
rm -f "${DESTDIR}${CABUNDLE}.old" rm -f "${DESTDIR}${CABUNDLE}.old"
unset bundlefile bundledir unset bundlefile bundledir