my xfce4 dotfiles
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.

637 lines
19 KiB

3 years ago
  1. #!/bin/sh
  2. #
  3. # Type `build -h` for help and see https://github.com/romkatv/gitstatus
  4. # for full documentation.
  5. set -ue
  6. if [ -n "${ZSH_VERSION:-}" ]; then
  7. emulate sh -o err_exit -o no_unset
  8. fi
  9. export LC_ALL=C
  10. if [ -z "${ZSH_VERSION-}" ] && command -v zsh >/dev/null 2>&1; then
  11. # Avoid bash 3.*.
  12. case "${BASH_VERSION-}" in
  13. [0-3].*) exec zsh "$0" "$@";;
  14. esac
  15. fi
  16. # Avoid ksh: https://github.com/romkatv/gitstatus/issues/282.
  17. if [ -n "${KSH_VERSION-}" ]; then
  18. if [ -z "${ZSH_VERSION-}" ] && command -v zsh >/dev/null 2>&1; then
  19. exec zsh "$0" "$@"
  20. elif [ -z "${BASH_VERSION-}" ] && command -v bash >/dev/null 2>&1 &&
  21. bash_version="$(bash --version 2>&1)"; then
  22. case "$bash_version" in
  23. *version\ [4-9]*|*version\ [1-9][0-9]*) exec bash "$0" "$@";;
  24. esac
  25. fi
  26. fi
  27. usage="$(command cat <<\END
  28. Usage: build [-m ARCH] [-c CPU] [-d CMD] [-i IMAGE] [-s] [-w]
  29. Options:
  30. -m ARCH `uname -m` from the target machine; defaults to `uname -m`
  31. from the local machine
  32. -c CPU generate machine instructions for CPU of this type; this
  33. value gets passed as `-march` (or `-mcpu` for ppc64le) to gcc;
  34. inferred from ARCH if not set explicitly
  35. -d CMD build in a Docker container and use CMD as the `docker`
  36. command; e.g., `-d docker` or `-d podman`
  37. -i IMAGE build in this Docker image; inferred from ARCH if not set
  38. explicitly
  39. -s install whatever software is necessary for build to
  40. succeed; on some operating systems this option is not
  41. supported; on others it can have partial effect
  42. -w automatically download tarballs for dependencies if they
  43. do not already exist in ./deps; dependencies are described
  44. in ./build.info
  45. END
  46. )"
  47. build="$(command cat <<\END
  48. outdir="$(command pwd)"
  49. if command -v mktemp >/dev/null 2>&1; then
  50. workdir="$(command mktemp -d "${TMPDIR:-/tmp}"/gitstatus-build.XXXXXXXXXX)"
  51. else
  52. workdir="${TMPDIR:-/tmp}/gitstatus-build.tmp.$$"
  53. command mkdir -- "$workdir"
  54. fi
  55. cd -- "$workdir"
  56. workdir="$(command pwd)"
  57. narg() { echo $#; }
  58. if [ "$(narg $workdir)" != 1 -o -z "${workdir##*:*}" -o -z "${workdir##*=*}" ]; then
  59. >&2 echo "[error] cannot build in this directory: $workdir"
  60. exit 1
  61. fi
  62. appname=gitstatusd
  63. libgit2_tmp="$outdir"/deps/"$appname".libgit2.tmp
  64. cleanup() {
  65. trap - INT QUIT TERM ILL PIPE
  66. cd /
  67. if ! command rm -rf -- "$workdir" "$outdir"/usrbin/"$appname".tmp "$libgit2_tmp"; then
  68. command sleep 5
  69. command rm -rf -- "$workdir" "$outdir"/usrbin/"$appname".tmp "$libgit2_tmp"
  70. fi
  71. }
  72. trap cleanup INT QUIT TERM ILL PIPE
  73. if [ -n "$gitstatus_install_tools" ]; then
  74. case "$gitstatus_kernel" in
  75. linux)
  76. if command -v apk >/dev/null 2>&1; then
  77. command apk update
  78. command apk add binutils cmake gcc g++ git make musl-dev perl-utils
  79. elif command -v apt-get >/dev/null 2>&1; then
  80. apt-get update
  81. apt-get install -y binutils cmake gcc g++ make wget
  82. else
  83. >&2 echo "[error] -s is not supported on this system"
  84. exit 1
  85. fi
  86. ;;
  87. freebsd)
  88. command pkg install -y cmake gmake binutils git perl5 wget
  89. ;;
  90. openbsd)
  91. command pkg_add cmake gmake gcc g++ git wget
  92. ;;
  93. netbsd)
  94. command pkgin -y install cmake gmake binutils git
  95. ;;
  96. darwin)
  97. if ! command -v make >/dev/null 2>&1 || ! command -v gcc >/dev/null 2>&1; then
  98. >&2 echo "[error] please run 'xcode-select --install' and retry"
  99. exit 1
  100. fi
  101. if command -v port >/dev/null 2>&1; then
  102. sudo port -N install libiconv cmake wget
  103. elif command -v brew >/dev/null 2>&1; then
  104. for formula in libiconv cmake git wget; do
  105. if command brew ls --version "$formula" &>/dev/null; then
  106. command brew upgrade "$formula"
  107. else
  108. command brew install "$formula"
  109. fi
  110. done
  111. else
  112. >&2 echo "[error] please install MacPorts or Homebrew and retry"
  113. exit 1
  114. fi
  115. ;;
  116. msys*|mingw*)
  117. command pacman -Syu --noconfirm
  118. command pacman -S --needed --noconfirm binutils cmake gcc git make perl
  119. ;;
  120. *)
  121. >&2 echo "[internal error] unhandled kernel: $gitstatus_kernel"
  122. exit 1
  123. ;;
  124. esac
  125. fi
  126. cpus="$(command getconf _NPROCESSORS_ONLN 2>/dev/null)" ||
  127. cpus="$(command sysctl -n hw.ncpu 2>/dev/null)" ||
  128. cpus=8
  129. case "$gitstatus_cpu" in
  130. powerpc64le) archflag="-mcpu";;
  131. *) archflag="-march";;
  132. esac
  133. cflags="$archflag=$gitstatus_cpu -fno-plt -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -fpie"
  134. ldflags=
  135. static_pie=
  136. if [ -z "${CC-}" ]; then
  137. case "$gitstatus_kernel" in
  138. freebsd) export CC=clang;;
  139. *) export CC=cc;;
  140. esac
  141. fi
  142. printf 'int main() {}\n' >"$workdir"/cc-test.c
  143. if 2>/dev/null "$CC" \
  144. -ffile-prefix-map=x=y \
  145. -Werror \
  146. -c "$workdir"/cc-test.c \
  147. -o "$workdir"/cc-test.o; then
  148. cflags="$cflags -ffile-prefix-map=$workdir/="
  149. fi
  150. command rm -f -- "$workdir"/cc-test "$workdir"/cc-test.o
  151. if 2>/dev/null "$CC" \
  152. -fstack-clash-protection -fcf-protection \
  153. -Werror \
  154. -c "$workdir"/cc-test.c \
  155. -o "$workdir"/cc-test.o; then
  156. cflags="$cflags -fstack-clash-protection -fcf-protection"
  157. fi
  158. command rm -f -- "$workdir"/cc-test "$workdir"/cc-test.o
  159. if 2>/dev/null "$CC" \
  160. -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now \
  161. -Werror \
  162. "$workdir"/cc-test.c \
  163. -o "$workdir"/cc-test; then
  164. ldflags="$ldflags -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now"
  165. fi
  166. command rm -f -- "$workdir"/cc-test "$workdir"/cc-test.o
  167. if 2>/dev/null "$CC" \
  168. -fpie -static-pie \
  169. -Werror \
  170. "$workdir"/cc-test.c \
  171. -o "$workdir"/cc-test; then
  172. static_pie='-static-pie'
  173. fi
  174. if [ "$gitstatus_cpu" = x86-64 ]; then
  175. cflags="$cflags -mtune=generic"
  176. fi
  177. libgit2_cmake_flags=
  178. libgit2_cflags="${CFLAGS-} $cflags -O3 -DNDEBUG"
  179. gitstatus_cxx=g++
  180. gitstatus_cxxflags="${CXXFLAGS-} $cflags -I${workdir}/libgit2/include -DGITSTATUS_ZERO_NSEC -D_GNU_SOURCE -D_GLIBCXX_ASSERTIONS"
  181. gitstatus_ldflags="${LDFLAGS-} $ldflags -L${workdir}/libgit2/build"
  182. gitstatus_ldlibs=
  183. gitstatus_make=make
  184. case "$gitstatus_kernel" in
  185. linux)
  186. gitstatus_ldflags="$gitstatus_ldflags ${static_pie:--static}"
  187. libgit2_cmake_flags="$libgit2_cmake_flags -DENABLE_REPRODUCIBLE_BUILDS=ON"
  188. ;;
  189. freebsd)
  190. gitstatus_cxx=clang++
  191. gitstatus_make=gmake
  192. gitstatus_ldflags="$gitstatus_ldflags ${static_pie:--static}"
  193. libgit2_cmake_flags="$libgit2_cmake_flags -DENABLE_REPRODUCIBLE_BUILDS=ON"
  194. ;;
  195. openbsd)
  196. gitstatus_cxx=eg++
  197. gitstatus_make=gmake
  198. gitstatus_ldflags="$gitstatus_ldflags ${static_pie:--static}"
  199. libgit2_cmake_flags="$libgit2_cmake_flags -DENABLE_REPRODUCIBLE_BUILDS=ON"
  200. ;;
  201. netbsd)
  202. gitstatus_make=gmake
  203. gitstatus_ldflags="$gitstatus_ldflags ${static_pie:--static}"
  204. libgit2_cmake_flags="$libgit2_cmake_flags -DENABLE_REPRODUCIBLE_BUILDS=ON"
  205. ;;
  206. darwin)
  207. command mkdir -- "$workdir"/lib
  208. if [ -e /opt/local/lib/libiconv.a ]; then
  209. command ln -s -- /opt/local/lib/libiconv.a "$workdir"/lib
  210. libgit2_cflags="$libgit2_cflags -I/opt/local/include"
  211. gitstatus_cxxflags="$gitstatus_cxxflags -I/opt/local/include"
  212. else
  213. brew_prefix="$(command brew --prefix)"
  214. command ln -s -- "$brew_prefix"/opt/libiconv/lib/libiconv.a "$workdir"/lib
  215. libgit2_cflags="$libgit2_cflags -I"$brew_prefix"/opt/libiconv/include"
  216. gitstatus_cxxflags="$gitstatus_cxxflags -I"$brew_prefix"/opt/libiconv/include"
  217. fi
  218. libgit2_cmake_flags="$libgit2_cmake_flags -DUSE_ICONV=ON"
  219. gitstatus_ldlibs="$gitstatus_ldlibs -liconv"
  220. gitstatus_ldflags="$gitstatus_ldflags -L${workdir}/lib"
  221. libgit2_cmake_flags="$libgit2_cmake_flags -DENABLE_REPRODUCIBLE_BUILDS=OFF"
  222. ;;
  223. msys*|mingw*)
  224. gitstatus_ldflags="$gitstatus_ldflags ${static_pie:--static}"
  225. libgit2_cmake_flags="$libgit2_cmake_flags -DENABLE_REPRODUCIBLE_BUILDS=ON"
  226. ;;
  227. cygwin*)
  228. gitstatus_ldflags="$gitstatus_ldflags ${static_pie:--static}"
  229. libgit2_cmake_flags="$libgit2_cmake_flags -DENABLE_REPRODUCIBLE_BUILDS=ON"
  230. ;;
  231. *)
  232. >&2 echo "[internal error] unhandled kernel: $gitstatus_kernel"
  233. exit 1
  234. ;;
  235. esac
  236. for cmd in cat cmake git ld ln mkdir rm strip tar "$gitstatus_make"; do
  237. if ! command -v "$cmd" >/dev/null 2>&1; then
  238. if [ -n "$gitstatus_install_tools" ]; then
  239. >&2 echo "[internal error] $cmd not found"
  240. exit 1
  241. else
  242. >&2 echo "[error] command not found: $cmd"
  243. exit 1
  244. fi
  245. fi
  246. done
  247. . "$outdir"/build.info
  248. if [ -z "${libgit2_version:-}" ]; then
  249. >&2 echo "[internal error] libgit2_version not set"
  250. exit 1
  251. fi
  252. if [ -z "${libgit2_sha256:-}" ]; then
  253. >&2 echo "[internal error] libgit2_sha256 not set"
  254. exit 1
  255. fi
  256. libgit2_tarball="$outdir"/deps/libgit2-"$libgit2_version".tar.gz
  257. if [ ! -e "$libgit2_tarball" ]; then
  258. if [ -n "$gitstatus_download_deps" ]; then
  259. if ! command -v wget >/dev/null 2>&1; then
  260. if [ -n "$gitstatus_install_tools" ]; then
  261. >&2 echo "[internal error] wget not found"
  262. exit 1
  263. else
  264. >&2 echo "[error] command not found: wget"
  265. exit 1
  266. fi
  267. fi
  268. libgit2_url=https://github.com/romkatv/libgit2/archive/"$libgit2_version".tar.gz
  269. if ! >"$libgit2_tmp" command wget --no-config -qO- -- "$libgit2_url" &&
  270. ! >"$libgit2_tmp" command wget -qO- -- "$libgit2_url"; then
  271. set -x
  272. >&2 command which wget
  273. >&2 command ls -lAd -- "$(command which wget)"
  274. >&2 command ls -lAd -- "$outdir"
  275. >&2 command ls -lA -- "$outdir"
  276. >&2 command ls -lAd -- "$outdir"/deps
  277. >&2 command ls -lA -- "$outdir"/deps
  278. set +x
  279. exit 1
  280. fi
  281. command mv -f -- "$libgit2_tmp" "$libgit2_tarball"
  282. else
  283. >&2 echo "[error] file not found: deps/libgit2-"$libgit2_version".tar.gz"
  284. exit 1
  285. fi
  286. fi
  287. libgit2_actual_sha256=
  288. if command -v shasum >/dev/null 2>/dev/null; then
  289. libgit2_actual_sha256="$(command shasum -b -a 256 -- "$libgit2_tarball")"
  290. libgit2_actual_sha256="${libgit2_actual_sha256%% *}"
  291. elif command -v sha256sum >/dev/null 2>/dev/null; then
  292. libgit2_actual_sha256="$(command sha256sum -b -- "$libgit2_tarball")"
  293. libgit2_actual_sha256="${libgit2_actual_sha256%% *}"
  294. elif command -v sha256 >/dev/null 2>/dev/null; then
  295. libgit2_actual_sha256="$(command sha256 -- "$libgit2_tarball" </dev/null)"
  296. # Ignore sha256 output if it's from hashalot. It's incompatible.
  297. if [ ${#libgit2_actual_sha256} -lt 64 ]; then
  298. libgit2_actual_sha256=
  299. else
  300. libgit2_actual_sha256="${libgit2_actual_sha256##* }"
  301. fi
  302. fi
  303. if [ -z "$libgit2_actual_sha256" ]; then
  304. >&2 echo "[error] command not found: shasum or sha256sum"
  305. exit 1
  306. fi
  307. if [ "$libgit2_actual_sha256" != "$libgit2_sha256" ]; then
  308. >&2 echo "[error] sha256 mismatch"
  309. >&2 echo ""
  310. >&2 echo " file : deps/libgit2-$libgit2_version.tar.gz"
  311. >&2 echo " expected: $libgit2_sha256"
  312. >&2 echo " actual : $libgit2_actual_sha256"
  313. exit 1
  314. fi
  315. cd -- "$workdir"
  316. command tar -xzf "$libgit2_tarball"
  317. command mv -- libgit2-"$libgit2_version" libgit2
  318. command mkdir libgit2/build
  319. cd libgit2/build
  320. CFLAGS="$libgit2_cflags" command cmake \
  321. -DCMAKE_BUILD_TYPE=None \
  322. -DZERO_NSEC=ON \
  323. -DTHREADSAFE=ON \
  324. -DUSE_BUNDLED_ZLIB=ON \
  325. -DREGEX_BACKEND=builtin \
  326. -DUSE_HTTP_PARSER=builtin \
  327. -DUSE_SSH=OFF \
  328. -DUSE_HTTPS=OFF \
  329. -DBUILD_CLAR=OFF \
  330. -DUSE_GSSAPI=OFF \
  331. -DUSE_NTLMCLIENT=OFF \
  332. -DBUILD_SHARED_LIBS=OFF \
  333. $libgit2_cmake_flags \
  334. ..
  335. command make -j "$cpus" VERBOSE=1
  336. APPNAME="$appname".tmp \
  337. OBJDIR="$workdir"/gitstatus \
  338. CXX="${CXX:-$gitstatus_cxx}" \
  339. CXXFLAGS="$gitstatus_cxxflags" \
  340. LDFLAGS="$gitstatus_ldflags" \
  341. LDLIBS="$gitstatus_ldlibs" \
  342. command "$gitstatus_make" -C "$outdir" -j "$cpus"
  343. app="$outdir"/usrbin/"$appname"
  344. command strip "$app".tmp
  345. command mkdir -- "$workdir"/repo
  346. printf '[init]\n defaultBranch = master\n' >"$workdir"/.gitconfig
  347. (
  348. cd -- "$workdir"/repo
  349. GIT_CONFIG_NOSYSTEM=1 HOME="$workdir" command git init
  350. GIT_CONFIG_NOSYSTEM=1 HOME="$workdir" command git config user.name "Your Name"
  351. GIT_CONFIG_NOSYSTEM=1 HOME="$workdir" command git config user.email "[email protected]"
  352. GIT_CONFIG_NOSYSTEM=1 HOME="$workdir" command git commit \
  353. --allow-empty --allow-empty-message --no-gpg-sign -m ''
  354. )
  355. resp="$(printf "hello\037$workdir/repo\036" | "$app".tmp)"
  356. case "$resp" in
  357. hello*1*/repo*master*);;
  358. *)
  359. >&2 echo 'error: invalid gitstatusd response for a git repo'
  360. exit 1
  361. ;;
  362. esac
  363. resp="$(printf 'hello\037\036' | "$app".tmp)"
  364. case "$resp" in
  365. hello*0*);;
  366. *)
  367. >&2 echo 'error: invalid gitstatusd response for a non-repo'
  368. exit 1
  369. ;;
  370. esac
  371. command mv -f -- "$app".tmp "$app"
  372. cleanup
  373. command cat >&2 <<-END
  374. -------------------------------------------------
  375. SUCCESS: created usrbin/$appname
  376. END
  377. END
  378. )"
  379. docker_image=
  380. docker_cmd=
  381. gitstatus_arch=
  382. gitstatus_cpu=
  383. gitstatus_install_tools=
  384. gitstatus_download_deps=
  385. while getopts ':m:c:i:d:swh' opt "$@"; do
  386. case "$opt" in
  387. h)
  388. printf '%s\n' "$usage"
  389. exit
  390. ;;
  391. m)
  392. if [ -n "$gitstatus_arch" ]; then
  393. >&2 echo "[error] duplicate option: -$opt"
  394. exit 1
  395. fi
  396. if [ -z "$OPTARG" ]; then
  397. >&2 echo "[error] incorrect value of -$opt: $OPTARG"
  398. exit 1
  399. fi
  400. gitstatus_arch="$OPTARG"
  401. ;;
  402. c)
  403. if [ -n "$gitstatus_cpu" ]; then
  404. >&2 echo "[error] duplicate option: -$opt"
  405. exit 1
  406. fi
  407. if [ -z "$OPTARG" ]; then
  408. >&2 echo "[error] incorrect value of -$opt: $OPTARG"
  409. exit 1
  410. fi
  411. gitstatus_cpu="$OPTARG"
  412. ;;
  413. i)
  414. if [ -n "$docker_image" ]; then
  415. >&2 echo "[error] duplicate option: -$opt"
  416. exit 1
  417. fi
  418. if [ -z "$OPTARG" ]; then
  419. >&2 echo "[error] incorrect value of -$opt: $OPTARG"
  420. exit 1
  421. fi
  422. docker_image="$OPTARG"
  423. ;;
  424. d)
  425. if [ -n "$docker_cmd" ]; then
  426. >&2 echo "[error] duplicate option: -$opt"
  427. exit 1
  428. fi
  429. if [ -z "$OPTARG" ]; then
  430. >&2 echo "[error] incorrect value of -$opt: $OPTARG"
  431. exit 1
  432. fi
  433. docker_cmd="$OPTARG"
  434. ;;
  435. s)
  436. if [ -n "$gitstatus_install_tools" ]; then
  437. >&2 echo "[error] duplicate option: -$opt"
  438. exit 1
  439. fi
  440. gitstatus_install_tools=1
  441. ;;
  442. w)
  443. if [ -n "$gitstatus_download_deps" ]; then
  444. >&2 echo "[error] duplicate option: -$opt"
  445. exit 1
  446. fi
  447. gitstatus_download_deps=1
  448. ;;
  449. \?) >&2 echo "[error] invalid option: -$OPTARG" ; exit 1;;
  450. :) >&2 echo "[error] missing required argument: -$OPTARG"; exit 1;;
  451. *) >&2 echo "[internal error] unhandled option: -$opt" ; exit 1;;
  452. esac
  453. done
  454. if [ "$OPTIND" -le $# ]; then
  455. >&2 echo "[error] unexpected positional argument"
  456. exit 1
  457. fi
  458. if [ -n "$docker_image" -a -z "$docker_cmd" ]; then
  459. >&2 echo "[error] cannot use -i without -d"
  460. exit 1
  461. fi
  462. if [ -z "$gitstatus_arch" ]; then
  463. gitstatus_arch="$(uname -m)"
  464. gitstatus_arch="$(printf '%s' "$gitstatus_arch" | tr '[A-Z]' '[a-z]')"
  465. fi
  466. if [ -z "$gitstatus_cpu" ]; then
  467. case "$gitstatus_arch" in
  468. armel) gitstatus_cpu=armv5;;
  469. armv6l|armhf) gitstatus_cpu=armv6;;
  470. armv7l) gitstatus_cpu=armv7;;
  471. arm64|aarch64) gitstatus_cpu=armv8-a;;
  472. ppc64le) gitstatus_cpu=powerpc64le;;
  473. riscv64) gitstatus_cpu=rv64imafdc;;
  474. loongarch64) gitstatus_cpu=loongarch64;;
  475. x86_64|amd64) gitstatus_cpu=x86-64;;
  476. x86) gitstatus_cpu=i586;;
  477. s390x) gitstatus_cpu=z900;;
  478. i386|i586|i686) gitstatus_cpu="$gitstatus_arch";;
  479. *)
  480. >&2 echo '[error] unable to infer target CPU architecture'
  481. >&2 echo 'Please specify explicitly with `-c CPU`.'
  482. exit 1
  483. ;;
  484. esac
  485. fi
  486. gitstatus_kernel="$(uname -s)"
  487. gitstatus_kernel="$(printf '%s' "$gitstatus_kernel" | tr '[A-Z]' '[a-z]')"
  488. case "$gitstatus_kernel" in
  489. linux)
  490. if [ -n "$docker_cmd" ]; then
  491. if [ -z "${docker_cmd##*/*}" ]; then
  492. if [ ! -x "$docker_cmd" ]; then
  493. >&2 echo "[error] not an executable file: $docker_cmd"
  494. exit 1
  495. fi
  496. else
  497. if ! command -v "$docker_cmd" >/dev/null 2>&1; then
  498. >&2 echo "[error] command not found: $docker_cmd"
  499. exit 1
  500. fi
  501. fi
  502. if [ -z "$docker_image" ]; then
  503. case "$gitstatus_arch" in
  504. x86_64) docker_image=alpine:3.11.6;;
  505. x86|i386|i586|i686) docker_image=i386/alpine:3.11.6;;
  506. armv6l|armhf) docker_image=arm32v6/alpine:3.11.6;;
  507. armv7l) docker_image=arm32v7/alpine:3.11.6;;
  508. aarch64) docker_image=arm64v8/alpine:3.11.6;;
  509. ppc64le) docker_image=ppc64le/alpine:3.11.6;;
  510. s390x) docker_image=s390x/alpine:3.11.6;;
  511. *)
  512. >&2 echo '[error] unable to infer docker image'
  513. >&2 echo 'Please specify explicitly with `-i IMAGE`.'
  514. exit 1
  515. ;;
  516. esac
  517. fi
  518. fi
  519. ;;
  520. freebsd|openbsd|netbsd|darwin)
  521. if [ -n "$docker_cmd" ]; then
  522. >&2 echo "[error] docker (-d) is not supported on $gitstatus_kernel"
  523. exit 1
  524. fi
  525. ;;
  526. msys_nt-*|mingw32_nt-*|mingw64_nt-*|cygwin_nt-*)
  527. if ! printf '%s' "$gitstatus_kernel" | grep -Eqx '[^-]+-[0-9]+\.[0-9]+(-.*)?'; then
  528. >&2 echo '[error] unsupported kernel, sorry!'
  529. exit 1
  530. fi
  531. gitstatus_kernel="$(printf '%s' "$gitstatus_kernel" | sed 's/^\([^-]*-[0-9]*\.[0-9]*\).*/\1/')"
  532. if [ -n "$docker_cmd" ]; then
  533. >&2 echo '[error] docker (-d) is not supported on windows'
  534. exit 1
  535. fi
  536. if [ -n "$gitstatus_install_tools" -a -z "${gitstatus_kernel##cygwin_nt-*}" ]; then
  537. >&2 echo '[error] -s is not supported on cygwin'
  538. exit 1
  539. fi
  540. ;;
  541. *)
  542. >&2 echo '[error] unsupported kernel, sorry!'
  543. exit 1
  544. ;;
  545. esac
  546. dir="$(dirname -- "$0")"
  547. cd -- "$dir"
  548. dir="$(pwd)"
  549. >&2 echo "Building gitstatusd..."
  550. >&2 echo ""
  551. >&2 echo " kernel := $gitstatus_kernel"
  552. >&2 echo " arch := $gitstatus_arch"
  553. >&2 echo " cpu := $gitstatus_cpu"
  554. [ -z "$docker_cmd" ] || >&2 echo " docker command := $docker_cmd"
  555. [ -z "$docker_image" ] || >&2 echo " docker image := $docker_image"
  556. if [ -n "$gitstatus_install_tools" ]; then
  557. >&2 echo " install tools := yes"
  558. else
  559. >&2 echo " install tools := no"
  560. fi
  561. if [ -n "$gitstatus_download_deps" ]; then
  562. >&2 echo " download deps := yes"
  563. else
  564. >&2 echo " download deps := no"
  565. fi
  566. if [ -n "$docker_cmd" ]; then
  567. "$docker_cmd" run \
  568. -e docker_cmd="$docker_cmd" \
  569. -e docker_image="$docker_image" \
  570. -e gitstatus_kernel="$gitstatus_kernel" \
  571. -e gitstatus_arch="$gitstatus_arch" \
  572. -e gitstatus_cpu="$gitstatus_cpu" \
  573. -e gitstatus_install_tools="$gitstatus_install_tools" \
  574. -e gitstatus_download_deps="$gitstatus_download_deps" \
  575. -v "$dir":/out \
  576. -w /out \
  577. --rm \
  578. -- "$docker_image" /bin/sh -uexc "$build"
  579. else
  580. eval "$build"
  581. fi