5269492 [rkeene@sledge /home/rkeene/tmp/fossil-static-build]$ cat -n build-fossil-static.sh
 1 #! /usr/bin/env bash
 2 
 3 workdir="${TMPDIR:-/tmp}/build-fossil-static.$$${RANDOM}${RANDOM}${RANDOM}"
 4 
 5 target='x86_64-generic-linux-musl'
 6 
 7 fossil_version='2.12.1'
 8 fossil_url="https://fossil-scm.org/home/uv/fossil-src-${fossil_version}.tar.gz"
 9 fossil_sha256='822326ffcfed3748edaf4cfd5ab45b23225dea840304f765d1d55d2e6c7d6603'
10 fossil_archive="fossil-${fossil_version}.tar.gz"
11 
12 # Base options
13 fossil_configure_options=( --json )
14 
15 # Platform-specific options
16 case "${target}" in
17     x86_64-*-linux-musl)
18         fossil_configure_options=( "${fossil_configure_options[@]}" --static --disable-fusefs --with-openssl=auto )
19         ;;
20 esac
21 
22 # File to create
23 result="fossil-${fossil_version}-${target}"
24 
25 # Clean-up the result file before starting
26 rm -f "${result}" "${result}.info" "${result}.log"
27 
28 # Begin the build
29 retval='0'
30 
31 ## Give status
32 echo -n 'Building...'
33 
34 ## Really build
35 (
36     # Create the build directory, atomically
37     rm -rf "${workdir}"
38     mkdir "${workdir}" || exit 1
39 
40     # Operate this sub-shell in that directory
41     cd "${workdir}"
42 
43     # Download the archive
44     curl "${fossil_url}" > "${fossil_archive}"
45 
46     # Verify it is what we expected
47     fossil_sha256_chk="$(openssl sha256 "${fossil_archive}" | sed 's@^.*= *@@')"
48     if [ "${fossil_sha256_chk}" != "${fossil_sha256}" ]; then
49         echo "Unable to verify Fossil SHA1.  Got: ${fossil_sha256_chk}, expected: ${fossil_sha256}" >&2
50 
51         exit 1
52     fi
53 
54     # Extract the archive
55     gzip -dc "${fossil_archive}" | tar -xf - || exit 1
56 
57     # Change to the fossil source directory
58     cd fossil-*/ || exit 1
59 
60     # Setup cross-compiler
61     ## From Build-CC 0.9+
62     eval $(~/root/cross-compilers/setup-cc "${target}") || exit 1
63 
64     # Configure fossil as required for this platform
65     ./configure --host="${target}" "${fossil_configure_options[@]}" || exit 1
66 
67     # Build fossil
68     make || exit 1
69 
70     # Strip executable of debugging symbols
71     "${target}-strip" fossil
72 ) > "${result}.log" 2>&1 || retval='1'
73 
74 if [ "${retval}" = '0' ]; then
75     # Notify of success
76     echo ' success!'
77 
78     # Copy built executable to current directory
79     cp "${workdir}"/fossil-*/fossil "${result}" || exit 1
80 
81     # Print out information related to the build
82     (
83         ls -lh "${result}" || exit 1
84         file "${result}" || exit 1
85         openssl sha256 "${result}" || exit 1
86         strings "${result}" | egrep '^(TLSv1 part of |LibreSSL)' | head -n 1
87     ) | tee "${result}.info"
88 else
89     # Notify of failure
90     echo ' failed.'
91 fi
92 
93 # Cleanup
94 rm -rf "${workdir}"
95 
96 # Exit
97 exit "${retval}"
5269493 [rkeene@sledge /home/rkeene/tmp/fossil-static-build]$

Click here to go back to the directory listing.
Click here to download this file.
last modified: 2020-08-20 18:53:30