在我的 ARM 设备上运行 ntp-keygen(或 ntpd)时收到的错误消息是:
./ntp-keygen: relocation error: ./ntp-keygen: symbol DSA_generate_parameters_ex, version OPENSSL_1_1_0 not defined in file libcrypto.so.1.1 with link time reference
配置、构建和安装 OpenSSL 的脚本如下:
#!/bin/bash
# Build dependencies if any.
depends()
{
cd $buildDir
if [ "x${PERL}" = "x" ]; then
export PERL=`which perl`
fi
return $?
}
# Configure software package.
configure()
{
depends
cd $packageDir
# Available ciphers:
# DES, AES, CAMELLIA, MD2, MDC2, MD4, MD5, HMAC, SHA, RIPEMD, WHIRLPOOL,
# RC4, RC5, RC2, IDEA, SEED, BF(blowfish), CAST, RSA, DSA, ECDSA, ECDH
# We use:
# DES, AES, MD4, MD5, HMAC, SHA, RSA, ECDSA, ECDH
./Configure shared threads --prefix=$PWD/install-arm linux-armv4
return $?
}
# Build the software package.
compile()
{
local mmx_machine_type=`echo $MMX_MACHINE_TYPE | tr '[:upper:]' '[:lower:]'`
depends
cd $packageDir
export CFLAGS="$CFLAGS -DCONFIG_MACHINE_${MMX_MACHINE_TYPE}"
configure
if [ "$?" -ne "0" ]; then return 1; fi
make CC=$CC AR=$AR NM=$NM RANLIB=$RANLIB
if [ "$?" -ne "0" ]; then return 1; fi
make CC=$CC AR=$AR NM=$NM RANLIB=$RANLIB install
if [ "$?" -ne "0" ]; then return 1; fi
return 0
}
# Clean-up.
clean()
{
depends
cd $packageDir
rm -rf install-arm/*
rm -rf install-i386/*
make clean
}
# Install to rootfs the necessary pieces (e.g. directories, links...)
install()
{
targetPath=${buildDir}/.tmp.rootfs/rootfs
local openssl="bin/openssl"
local libssl="lib/libssl.so.1.1"
local libcrypto="lib/libcrypto.so.1.1"
cd ${packageDir}/install-arm
if [ -f ${openssl} -a -f ${libssl} -a -f ${libcrypto} ]
then
cp ${openssl} ${targetPath}/sbin/
cp ${libssl} ${targetPath}/lib/
cp ${libcrypto} ${targetPath}/lib/
else
printf " $package not built.\n"
fi
return 0
}
对于 ntp 包,对 OpenSSL 的唯一引用是在配置选项中。下面是完整的 ntp 包配置:
#!/bin/sh
# Configure software package.
configure()
{
cd $packageDir
./bootstrap
./configure --host=arm-linux --with-yielding-select=yes --with-crypto=openssl \
--with-openssl-incdir=$OPENSSL_DIR/install-arm/include/ \
--with-openssl-libdir=$OPENSSL_DIR/install-arm/lib/ \
return $?
}
# Build the software package.
compile()
{
cd $packageDir
# make PROJECT_NAME=$project
make
if [ "$?" -ne "0" ]; then return 1; fi
return 0
}
# Clean-up.
clean()
{
cd $packageDir
make clean
}
# Install to rootfs the necessary pieces (e.g. directories, links...)
install()
{
cd $packageDir
sourcePath=.
targetPath=$buildDir/.tmp.rootfs/rootfs
if [[ -f $sourcePath/ntpclient ]]; then
cp $sourcePath/$package $targetPath/sbin/
else
printf " $package not built.\n"
return 1
fi
return 0
}