Portable build framework for OpenNTPD
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

71 lines
1.9 KiB

8 years ago
8 years ago
8 years ago
8 years ago
  1. #!/bin/sh
  2. set -e
  3. openbsd_branch=`cat OPENBSD_BRANCH`
  4. openntpd_version=`cat VERSION`
  5. # pull in latest upstream code
  6. echo "pulling upstream openbsd source"
  7. if [ ! -d openbsd ]; then
  8. if [ -z "$OPENNTPD_GIT" ]; then
  9. git clone https://github.com/openntpd-portable/openntpd-openbsd.git openbsd
  10. else
  11. git clone $OPENNTPD_GIT/openbsd
  12. fi
  13. fi
  14. (cd openbsd
  15. git checkout $openbsd_branch
  16. git pull --rebase)
  17. # setup source paths
  18. dir=`pwd`
  19. patches=$dir/patches
  20. libc_inc=$dir/openbsd/src/include
  21. libc_src=$dir/openbsd/src/lib/libc
  22. libcrypto_src=$dir/openbsd/src/lib/libcrypto
  23. libutil_src=$dir/openbsd/src/lib/libutil
  24. ntpd_src=$dir/openbsd/src/usr.sbin/ntpd
  25. do_cp_libc() {
  26. sed "/DEF_WEAK/d" < "$1" > "$2"/`basename "$1"`
  27. }
  28. CP_LIBC='do_cp_libc'
  29. CP='cp -p'
  30. PATCH='patch -p0 -s'
  31. sed '/DECLS/d' $libc_inc/md5.h > include/md5.h
  32. sed '/DECLS/d' $libc_inc/sha2.h > include/sha2_openbsd.h
  33. cp $libutil_src/imsg.h include/
  34. cp $libutil_src/imsg.c compat/
  35. cp $libutil_src/imsg-buffer.c compat/
  36. (cd compat; $PATCH < $patches/patch-imsg.c)
  37. for i in explicit_bzero.c strlcpy.c strlcat.c; do
  38. $CP_LIBC $libc_src/string/$i compat
  39. done
  40. $CP_LIBC $libc_src/stdlib/reallocarray.c compat
  41. $CP_LIBC $libc_src/stdlib/strtonum.c compat
  42. $CP $libc_src/crypt/arc4random.c compat
  43. $CP_LIBC $libc_src/crypt/arc4random_uniform.c compat
  44. $CP_LIBC $libc_src/crypt/chacha_private.h compat
  45. $CP_LIBC $libc_src/hash/md5.c compat
  46. $CP_LIBC $libc_src/hash/sha2.c compat
  47. for i in $libcrypto_src/crypto/getentropy_*.c; do
  48. sed -e 's/openssl\/sha.h/sha2.h/' < $i > compat/`basename $i`
  49. done
  50. $CP $libcrypto_src/crypto/arc4random_*.h compat
  51. for i in client.c config.c constraint.c control.c log.c log.h ntp.c ntp.h \
  52. ntp_dns.c ntp_msg.c ntpd.c ntpd.h parse.y sensors.c server.c util.c \
  53. ntpctl.8 ntpd.8 ntpd.conf.5 ; do
  54. file=`basename $i`
  55. echo Copying $file
  56. $CP $ntpd_src/$i src
  57. done
  58. (cd src
  59. for i in ../patches/*.patch; do
  60. echo Patching $i
  61. $PATCH -p4 < $i
  62. done
  63. )