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.

72 lines
1.9 KiB

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