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.

75 lines
2.0 KiB

9 years ago
9 years ago
9 years ago
9 years ago
9 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 fetch
  16. git checkout $openbsd_branch
  17. git pull --rebase)
  18. # setup source paths
  19. dir=`pwd`
  20. patches=$dir/patches
  21. etc_src=$dir/openbsd/src/etc
  22. libc_inc=$dir/openbsd/src/include
  23. libc_src=$dir/openbsd/src/lib/libc
  24. arc4random_src=$dir/openbsd/src/lib/libcrypto/arc4random
  25. libutil_src=$dir/openbsd/src/lib/libutil
  26. ntpd_src=$dir/openbsd/src/usr.sbin/ntpd
  27. do_cp_libc() {
  28. sed "/DEF_WEAK/d" < "$1" > "$2"/`basename "$1"`
  29. }
  30. CP_LIBC='do_cp_libc'
  31. CP='cp -p'
  32. PATCH='patch -p0 -s'
  33. $CP $etc_src/ntpd.conf ./
  34. sed '/DECLS/d' $libc_inc/md5.h > include/md5.h
  35. sed '/DECLS/d' $libc_inc/sha2.h > include/sha2_openbsd.h
  36. $CP $libutil_src/imsg.h include/
  37. $CP $libutil_src/imsg.c compat/
  38. $CP $libutil_src/imsg-buffer.c compat/
  39. (cd compat; $PATCH < $patches/patch-imsg.c)
  40. for i in explicit_bzero.c strlcpy.c strlcat.c; do
  41. $CP_LIBC $libc_src/string/$i compat
  42. done
  43. $CP_LIBC $libc_src/stdlib/reallocarray.c compat
  44. $CP_LIBC $libc_src/stdlib/recallocarray.c compat
  45. $CP_LIBC $libc_src/stdlib/strtonum.c compat
  46. $CP_LIBC $libc_src/crypt/arc4random.c compat
  47. $CP_LIBC $libc_src/crypt/arc4random_uniform.c compat
  48. $CP_LIBC $libc_src/crypt/chacha_private.h compat
  49. $CP_LIBC $libc_src/hash/md5.c compat
  50. $CP_LIBC $libc_src/hash/sha2.c compat
  51. for i in $arc4random_src/getentropy_*.c; do
  52. sed -e 's/openssl\/sha.h/sha2.h/' < $i > compat/`basename $i`
  53. done
  54. $CP $arc4random_src/arc4random_*.h compat
  55. for i in client.c config.c constraint.c control.c log.c ntp.c ntp.h \
  56. ntp_dns.c ntp_msg.c ntpd.c ntpd.h parse.y sensors.c server.c util.c \
  57. ntpctl.8 ntpd.8 ntpd.conf.5 ; do
  58. file=`basename $i`
  59. echo Copying $file
  60. $CP $ntpd_src/$i src
  61. done
  62. (cd src
  63. for i in ../patches/*.patch; do
  64. echo Patching $i
  65. $PATCH -p4 < $i
  66. done
  67. )