man_rebrand.sh 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. #!/bin/sh
  2. ########################################
  3. # name: man_rebrand.sh
  4. # main: jadedctrl
  5. # lisc: isc
  6. # desc: rebranding obsd man pages for
  7. # use in lbsd.
  8. ########################################
  9. . ./libdeblob.sh
  10. if test -z "$1"; then
  11. echo "usage: man_rebrand.sh src_path"
  12. exit 2
  13. else
  14. SRC_DIR="$1"
  15. fi
  16. PATCH_DIR=/tmp/man_rebrand
  17. mkdir "$PATCH_DIR" 2> /dev/null
  18. # --------------------------------------
  19. function ox_replace {
  20. local file rfile
  21. for file in "$SRC_DIR/$1"/*
  22. do
  23. if echo "$file" | grep -q "\.[1-9]$"
  24. then
  25. rfile="${file#$SRC_DIR/}"
  26. if grep -q ".Ox \." "$file"; then
  27. rep ".Ox \." "LibertyBSD\." "$rfile"
  28. fi
  29. if grep -q ".Ox \," "$file"; then
  30. rep ".Ox \," "LibertyBSD\," "$rfile"
  31. fi
  32. if grep -q ".Ox \:" "$file"; then
  33. rep ".Ox \:" "LibertyBSD\:" "$rfile"
  34. fi
  35. if grep -q ".Ox$" "$file"; then
  36. rep ".Ox$" "LibertyBSD" "$rfile"
  37. fi
  38. if grep -q "ftp.openbsd.org" "$file"; then
  39. rep "ftp.openbsd.org" "ftp.libertybsd.net" "$rfile"
  40. fi
  41. if grep -q "http://openbsd.org" "$file"; then
  42. rep "http://libertybsd.net" "$rfile"
  43. fi
  44. if grep -q "https://openbsd.org" "$file"; then
  45. rep "https://libertybsd.net" "$rfile"
  46. fi
  47. fi
  48. done
  49. }
  50. mandirectories="man0 man1 man3 man4 man5 man6 man7 man8 man9"
  51. for mandir in $mandirectories; do
  52. echo
  53. ox_replace "share/man/$mandir"
  54. done
  55. echo
  56. bindirectories="bin sbin usr.bin usr.sbin"
  57. for bindir in $bindirectories; do
  58. for dir in "$SRC_DIR/$bindir"/*; do
  59. echo
  60. if test -d "$dir"; then
  61. fixdir="${dir#$SRC_DIR/}"
  62. ox_replace "$fixdir"
  63. fi
  64. done
  65. done
  66. echo
  67. filecp files/man/release.8 share/man/man8/release.8
  68. filecp files/man/sendbug.1 share/man/man1/sendbug.1
  69. # Add Free Software-related man pages
  70. echo
  71. filecp files/man/fsdg.7 share/man/man7/fsdg.7
  72. filecp files/man/free-software.7 share/man/man7/free-software.7
  73. rep "environ.7 glob.7 hier.7 hostname.7 intro.7" \
  74. "environ.7 free-software.7 fsdg.7 glob.7 hier.7 " \
  75. share/man/man7/Makefile
  76. rep "library-specs.7" \
  77. "hostname.7 intro.7 library-specs.7" \
  78. share/man/man7/Makefile
  79. lineadd "./usr/share/man/man7/eqn.7" \
  80. "./usr/share/man/man7/fsdg.7" \
  81. distrib/sets/lists/man/mi
  82. lineadd "./usr/share/man/man7/eqn.7" \
  83. "./usr/share/man/man7/free-software.7" \
  84. distrib/sets/lists/man/mi
  85. rep "mandoc_asprintf(\&defbuf, \"%s %s\"," \
  86. "mandoc_asprintf(\&defbuf, \"LibertyBSD %s\"," \
  87. usr.bin/mandoc/mdoc_validate.c
  88. rep "utsname.sysname, utsname.release);" \
  89. "utsname.release);" \
  90. usr.bin/mandoc/mdoc_validate.c
  91. echo
  92. echo "Applying..."
  93. apply