Git-Url: 
http://git.frugalware.org/gitweb/gitweb.cgi?p=frugalware-current.git;a=commitdiff;h=f9e75b9aeb36a1db625a3e89faacbc23a5748e7a

commit f9e75b9aeb36a1db625a3e89faacbc23a5748e7a
Author: DeX77 <[email protected]>
Date:   Fri Aug 12 12:17:42 2016 +0200

ca-certificates-20160104-5-x86_64

* replace perl c_rehash with pure bash

diff --git a/source/base/ca-certificates/FrugalBuild 
b/source/base/ca-certificates/FrugalBuild
index 523a729..39426e9 100644
--- a/source/base/ca-certificates/FrugalBuild
+++ b/source/base/ca-certificates/FrugalBuild
@@ -3,21 +3,23 @@

pkgname=ca-certificates
pkgver=20160104
-pkgrel=4
+pkgrel=5
pkgdesc='Common CA certificates'
archs=('i686' 'x86_64' 'arm')
groups=('base' 'chroot-core')
-depends=('openssl' 'scriptlet-core' 'perl')
+depends=('openssl' 'scriptlet-core')
[ "$CARCH" != "arm" ] && makedepends=('openjdk')
url='http://packages.qa.debian.org/c/ca-certificates.html'
_F_cd_path="$pkgname"
Fpkgversep="_"
source=("ftp://ftp.debian.org/debian/pool/main/c/${pkgname}/${pkgname}_${pkgver}.tar.xz";
 \
-       updatekeystore)
+       updatekeystore \
+       openssl-c_rehash.sh )
up2date="Flasttar ftp://ftp.debian.org/debian/pool/main/c/ca-certificates/ 
.tar.xz"
backup=('etc/ca-certificates.conf')
sha1sums=('4525a194736c6691dbd59fa87281b722837b4768' \
-          'd163dbee8ee0c8b1be1e93fe1adf79e231a6db05')
+          'd163dbee8ee0c8b1be1e93fe1adf79e231a6db05' \
+          'bd5fae59161d1a970e2797a99021dc16ed0e11e2')

subpkgs=('ca-certificates-java')
subdescs=('Java Keystore of common CA certificates')
@@ -30,6 +32,7 @@ 
subremoves=('usr/lib/jvm/java-7-openjdk/jre/lib/security/cacerts')
build() {
Fmkdir usr/share/ca-certificates
Fmkdir usr/sbin
+       Fsed 'c_rehash' 'openssl-c_rehash.sh' sbin/update-ca-certificates
Fbuild
Fmkdir /etc
echo "# Automatically generated by ${pkgname}-${pkgver}-${pkgrel}" > 
$Fdestdir/etc/ca-certificates.conf || Fdie
@@ -54,4 +57,7 @@ build() {
#Fsplit ca-certificates-java /etc/cron.daily/updatekeystore
Fsplit ca-certificates-java /usr/lib/jvm/java-8-openjdk/jre/lib/security/cacerts
fi
+
+       # Install pure bash implementation for c_rehash
+       Fexe usr/bin/openssl-c_rehash.sh
}
diff --git a/source/base/ca-certificates/openssl-c_rehash.sh 
b/source/base/ca-certificates/openssl-c_rehash.sh
new file mode 100644
index 0000000..0ea2263
--- /dev/null
+++ b/source/base/ca-certificates/openssl-c_rehash.sh
@@ -0,0 +1,210 @@
+#!/bin/sh
+#
+# Ben Secrest <[email protected]>
+#
+# sh c_rehash script, scan all files in a directory
+# and add symbolic links to their hash values.
+#
+# based on the c_rehash perl script distributed with openssl
+#
+# LICENSE: See OpenSSL license
+# ^^acceptable?^^
+#
+
+# default certificate location
+DIR=/etc/openssl
+
+# for filetype bitfield
+IS_CERT=$(( 1 << 0 ))
+IS_CRL=$(( 1 << 1 ))
+
+
+# check to see if a file is a certificate file or a CRL file
+# arguments:
+#       1. the filename to be scanned
+# returns:
+#       bitfield of file type; uses ${IS_CERT} and ${IS_CRL}
+#
+check_file()
+{
+    local IS_TYPE=0
+
+    # make IFS a newline so we can process grep output line by line
+    local OLDIFS=${IFS}
+    IFS=$( printf "\n" )
+
+    # XXX: could be more efficient to have two 'grep -m' but is -m portable?
+    for LINE in $( grep '^-----BEGIN .*-----' ${1} )
+    do
+       if echo ${LINE} \
+           | grep -q -E '^-----BEGIN (X509 |TRUSTED )?CERTIFICATE-----'
+       then
+           IS_TYPE=$(( ${IS_TYPE} | ${IS_CERT} ))
+
+           if [ $(( ${IS_TYPE} & ${IS_CRL} )) -ne 0 ]
+           then
+               break
+           fi
+       elif echo ${LINE} | grep -q '^-----BEGIN X509 CRL-----'
+       then
+           IS_TYPE=$(( ${IS_TYPE} | ${IS_CRL} ))
+
+           if [ $(( ${IS_TYPE} & ${IS_CERT} )) -ne 0 ]
+           then
+               break
+           fi
+       fi
+    done
+
+    # restore IFS
+    IFS=${OLDIFS}
+
+    return ${IS_TYPE}
+}
+
+
+#
+# use openssl to fingerprint a file
+#    arguments:
+#      1. the filename to fingerprint
+#      2. the method to use (x509, crl)
+#    returns:
+#      none
+#    assumptions:
+#      user will capture output from last stage of pipeline
+#
+fingerprint()
+{
+    ${SSL_CMD} ${2} -fingerprint -noout -in ${1} | sed 's/^.*=//' | tr -d ':'
+}
+
+
+#
+# link_hash - create links to certificate files
+#    arguments:
+#       1. the filename to create a link for
+#      2. the type of certificate being linked (x509, crl)
+#    returns:
+#      0 on success, 1 otherwise
+#
+link_hash()
+{
+    local FINGERPRINT=$( fingerprint ${1} ${2} )
+    local HASH=$( ${SSL_CMD} ${2} -hash -noout -in ${1} )
+    local SUFFIX=0
+    local LINKFILE=''
+    local TAG=''
+
+    if [ ${2} = "crl" ]
+    then
+       TAG='r'
+    fi
+
+    LINKFILE=${HASH}.${TAG}${SUFFIX}
+
+    while [ -f ${LINKFILE} ]
+    do
+       if [ ${FINGERPRINT} = $( fingerprint ${LINKFILE} ${2} ) ]
+       then
+           echo "WARNING: Skipping duplicate file ${1}" >&2
+           return 1
+       fi
+
+       SUFFIX=$(( ${SUFFIX} + 1 ))
+       LINKFILE=${HASH}.${TAG}${SUFFIX}
+    done
+
+    echo "${1} => ${LINKFILE}"
+
+    # assume any system with a POSIX shell will either support symlinks or
+    # do something to handle this gracefully
+    ln -s ${1} ${LINKFILE}
+
+    return 0
+}
+
+
+# hash_dir create hash links in a given directory
+hash_dir()
+{
+    echo "Doing ${1}"
+
+    cd ${1}
+
+    ls -1 * 2>/dev/null | while read FILE
+    do
+        if echo ${FILE} | grep -q -E '^[[:xdigit:]]{8}\.r?[[:digit:]]+$' \
+               && [ -h "${FILE}" ]
+        then
+            rm ${FILE}
+        fi
+    done
+
+    ls -1 *.pem *.cer *.crt *.crl 2>/dev/null | while read FILE
+    do
+       check_file ${FILE}
+        local FILE_TYPE=${?}
+       local TYPE_STR=''
+
+        if [ $(( ${FILE_TYPE} & ${IS_CERT} )) -ne 0 ]
+        then
+            TYPE_STR='x509'
+        elif [ $(( ${FILE_TYPE} & ${IS_CRL} )) -ne 0 ]
+        then
+            TYPE_STR='crl'
+        else
+            echo "WARNING: ${FILE} does not contain a certificate or CRL: 
skipping" >&2
+           continue
+        fi
+
+       link_hash ${FILE} ${TYPE_STR}
+    done
+}
+
+
+# choose the name of an ssl application
+if [ -n "${OPENSSL}" ]
+then
+    SSL_CMD=$(which ${OPENSSL} 2>/dev/null)
+else
+    SSL_CMD=/usr/bin/openssl
+    OPENSSL=${SSL_CMD}
+    export OPENSSL
+fi
+
+# fix paths
+PATH=${PATH}:${DIR}/bin
+export PATH
+
+# confirm existance/executability of ssl command
+if ! [ -x ${SSL_CMD} ]
+then
+    echo "${0}: rehashing skipped ('openssl' program not available)" >&2
+    exit 0
+fi
+
+# determine which directories to process
+old_IFS=$IFS
+if [ ${#} -gt 0 ]
+then
+    IFS=':'
+    DIRLIST=${*}
+elif [ -n "${SSL_CERT_DIR}" ]
+then
+    DIRLIST=$SSL_CERT_DIR
+else
+    DIRLIST=${DIR}/certs
+fi
+
+IFS=':'
+
+# process directories
+for CERT_DIR in ${DIRLIST}
+do
+    if [ -d ${CERT_DIR} -a -w ${CERT_DIR} ]
+    then
+        IFS=$old_IFS
+        hash_dir ${CERT_DIR}
+        IFS=':'
+    fi
+done
_______________________________________________
Frugalware-git mailing list
[email protected]
http://frugalware.org/mailman/listinfo/frugalware-git

Reply via email to