├── .gitignore ├── LICENSE ├── README.md ├── dokany ├── mkbuild └── toolchain │ ├── i686-w64-mingw32.cmake │ └── x86_64-w64-mingw32.cmake ├── fuse-nfs ├── dpa.target ├── mkbuild └── normal.target ├── libnfs └── mkbuild └── mkbuild /.gitignore: -------------------------------------------------------------------------------- 1 | */out 2 | */build 3 | */src 4 | *~ 5 | out 6 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Daniel Abrecht 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Build scripts for fuse-nfs 2 | 3 | This reposiory contains build scripts for https://github.com/sahlberg/fuse-nfs 4 | 5 | ## How to use these build scripts 6 | 7 | Each folder in the project root directory contains a shell script called `mkbuild`. 8 | This script clones/pulls the corresponding git repository and builds the programm/lib. 9 | Each `mkbuild` script will create the following directories: 10 | * `src`: The source/cloned repo 11 | * `build`: The source is built in this folder 12 | * `out`: The resulting binaries 13 | 14 | The commit and repo url using which `fuse-nfs` is built when using this build scripts 15 | can be changed using the environment variables `{LIBNFS,FUSENFS,DOKANY}_{URL,CHECKOUT}` 16 | These build scripts have been tested on a devuan linux distrbution. The following 17 | packages are required to build `fuse-nfs` using the provided build scripts: 18 | `gcc mingw-w64 git libfuse-dev automake libtool make cmake` 19 | 20 | If you just want to build `fuse-nfs`, use the script `/fuse-nfs/mkbuild`. 21 | 22 | The script `/mkbuild` (,the one in the project root directory), tries to build `fuse-nfs` 23 | using a lot of different repo versions, which ones is specified in `/fuse-nfs/.target`, 24 | and uploads these builds as github releases to https://github.com/Daniel-Abrecht/fuse-nfs-crossbuild-scripts/releases. 25 | The releses in this repo are updated each hour if necessary. 26 | 27 | 28 | ## How to install a release in Windows 29 | 30 | The first step is to choose a release. The releases are named `repo1=ref1 repo2=ref2 ...`. If `ref` is `master`, the latest commit has been used for the release. Therefore, the newest release is always `libnfs=master fuse-nfs=master dokany=master`. However, this may not be the most stable release. If you want the newest stable release, choose the one with the most and highest version numbers. 31 | The versions with fuse-nfs=dpa are a fork of fuse-nfs which change the syntax of fuse-nfs to make it work in an fstab and to allow specifying arbitrary fuse options, which allows things like specifying the volume name in dokany, for example. 32 | 33 | The next step is to download the correct zip archive: 34 | * x86_64.zip => linux amd64 35 | * x86_64-w64-mingw32.zip => Windows 64bit 36 | * i686-w64-mingw32.zip => Windows 32bit 37 | 38 | Then download & install the correct dokany driver from https://github.com/dokan-dev/dokany/releases 39 | Usually, the latest release will work just fine. If it doesn't try to use the version matching 40 | the one specified in the release of this repo. 41 | 42 | Now, just unzip the downloaded folder. I recommand renaming the folder fuse-nfs and moving it to `C:\Program Files\`. 43 | You can now use fuse-nfs by opening a CMD Window and navigating into the unzipped folder, or if it is too inconvinient 44 | to switch into the folder, you can just add the folder to the system path. You can now type `fuse-nfs.exe -h` to display all available options. To mount a network share, the command could look like this: `fuse-nfs.exe -n nfs://share-name-or-ip/your-export -m R`. This would mount the export `your-export` from NFS share `share-name-or-ip` at Drive letter `R`. 45 | -------------------------------------------------------------------------------- /dokany/mkbuild: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | src=src 4 | build=build 5 | out=out 6 | uri=https://github.com/dokan-dev/dokany.git 7 | checkout=origin/master 8 | 9 | root="$(realpath "$(dirname "$0")")" 10 | 11 | if [ -n "$DOKANY_URI" ]; then uri="$DOKANY_URI"; fi 12 | if [ -n "$DOKANY_CHECKOUT" ]; then checkout="$DOKANY_CHECKOUT"; fi 13 | 14 | src="$root/$src" 15 | build="$root/$build" 16 | out="$root/$out" 17 | 18 | function update { 19 | if [ ! -d "$src" ] 20 | then 21 | git clone --no-checkout -- "$uri" "$src" 22 | cd -- "$src" 23 | else 24 | cd -- "$src" 25 | git remote set-url origin "$uri" 26 | find -maxdepth 1 -not -name .git -not -name . -exec rm -rf {} \; 27 | git fetch 28 | fi 29 | git checkout "$checkout" >/dev/null 30 | git reset --hard; 31 | cd -- "$root" 32 | } 33 | 34 | function compile { 35 | rm -rf -- "$build" 36 | mkdir -p -- "$build" 37 | cd -- "$build" 38 | chmod -w "$root" 39 | cmake -DCMAKE_TOOLCHAIN_FILE="$root/toolchain/$1.cmake" "$src"/dokan_fuse/ 40 | make 41 | chmod u+w "$root" 42 | mkdir -p "$out/$1" 43 | cp "$build"/libdokanfuse?.dll{,.a} "$out/$1/" 44 | cd -- "$root" 45 | } 46 | 47 | set -ex 48 | 49 | chmod u+w "$root" 50 | 51 | rm -rf -- "$out" 52 | mkdir -p -- "$out" 53 | 54 | update 55 | 56 | if [ "$1" = "update" ] 57 | then exit 0 58 | fi 59 | 60 | compile i686-w64-mingw32 61 | compile x86_64-w64-mingw32 62 | -------------------------------------------------------------------------------- /dokany/toolchain/i686-w64-mingw32.cmake: -------------------------------------------------------------------------------- 1 | set(CMAKE_SYSTEM_NAME Windows) 2 | set(TOOLCHAIN_PREFIX i686-w64-mingw32) 3 | 4 | set(CMAKE_SHARED_LINKER_FLAGS "-static -static-libgcc -static-libstdc++" CACHE STRING "" FORCE) 5 | 6 | set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-gcc) 7 | set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}-g++) 8 | set(CMAKE_RC_COMPILER ${TOOLCHAIN_PREFIX}-windres) 9 | -------------------------------------------------------------------------------- /dokany/toolchain/x86_64-w64-mingw32.cmake: -------------------------------------------------------------------------------- 1 | set(CMAKE_SYSTEM_NAME Windows) 2 | set(TOOLCHAIN_PREFIX x86_64-w64-mingw32) 3 | 4 | set(CMAKE_SHARED_LINKER_FLAGS "-static -static-libgcc -static-libstdc++" CACHE STRING "" FORCE) 5 | 6 | set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-gcc) 7 | set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}-g++) 8 | set(CMAKE_RC_COMPILER ${TOOLCHAIN_PREFIX}-windres) 9 | -------------------------------------------------------------------------------- /fuse-nfs/dpa.target: -------------------------------------------------------------------------------- 1 | fuse-nfs 2 | Daniel-Abrecht/fuse-nfs-crossbuild-scripts 3 | 4 | libnfs https://github.com/sahlberg/libnfs.git +refs/tags/libnfs-{3.0.0<} +master 5 | fuse-nfs https://github.com/Daniel-Abrecht/fuse-nfs.git +dpa 6 | dokany https://github.com/dokan-dev/dokany.git +refs/tags/v{1.4.0.0<} +refs/tags/v{2.0.0-BETA0<} master 7 | 8 | out/ */* 9 | ../dokany/out/ */*.dll 10 | -------------------------------------------------------------------------------- /fuse-nfs/mkbuild: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | src=src 4 | build=build 5 | out=out 6 | uri=https://github.com/sahlberg/fuse-nfs.git 7 | checkout=origin/master 8 | 9 | root="$(realpath "$(dirname "$0")")" 10 | parent="$(realpath "$root"/..)" 11 | 12 | if [ -n "$FUSENFS_URI" ]; then uri="$FUSENFS_URI"; fi 13 | if [ -n "$FUSENFS_CHECKOUT" ]; then checkout="$FUSENFS_CHECKOUT"; fi 14 | 15 | src="$root/$src" 16 | build="$root/$build" 17 | out="$root/$out" 18 | 19 | function update { 20 | if [ ! -d "$src" ] 21 | then 22 | git clone --no-checkout -- "$uri" "$src" 23 | cd -- "$src" 24 | else 25 | cd -- "$src" 26 | git remote set-url origin "$uri" 27 | find -maxdepth 1 -not -name .git -not -name . -exec rm -rf {} \; 28 | git fetch 29 | fi 30 | git checkout "$checkout" >/dev/null 31 | git reset --hard; 32 | autoreconf --install 33 | cd -- "$root" 34 | } 35 | 36 | function compile { 37 | rm -rf -- "$build" 38 | mkdir -p -- "$build" 39 | cd -- "$build" 40 | chmod -w "$root" 41 | incs=( "${INCLUDES[@]/#/-I}" ) 42 | libs=( "${LIBS[@]/\%ARCH\%/"$1"}" ) 43 | libs=( "${libs[@]/#/-L}" ) 44 | "$src"/configure --host="$1" CPPFLAGS="${incs[*]} $FLAGS" CFLAGS="${incs[*]} $FLAGS" LDFLAGS="${libs[*]}" 45 | make 46 | chmod u+w "$root" 47 | cd -- "$root" 48 | mkdir -p "$out/$1" 49 | cp "$build"/fuse/$2 "$out/$1" 50 | } 51 | 52 | set -ex 53 | 54 | chmod u+w "$root" 55 | 56 | rm -rf -- "$out" 57 | mkdir -p -- "$out" 58 | 59 | "$parent"/libnfs/mkbuild 60 | "$parent"/dokany/mkbuild 61 | 62 | update 63 | 64 | INCLUDES=( "$parent"/libnfs/src/include/ ) 65 | LIBS=( "$parent"/libnfs/out/%ARCH%/ ) 66 | 67 | compile "x86_64" fuse-nfs 68 | 69 | FLAGS=" -static -static-libgcc -static-libstdc++ -pthread -l:libpthread.a" 70 | LIBS+=( "$parent"/dokany/out/%ARCH%/ ) 71 | INCLUDES+=( "$parent"/dokany/src/dokan_fuse/include/ ) 72 | 73 | compile "i686-w64-mingw32" fuse-nfs.exe 74 | compile "x86_64-w64-mingw32" fuse-nfs.exe 75 | -------------------------------------------------------------------------------- /fuse-nfs/normal.target: -------------------------------------------------------------------------------- 1 | fuse-nfs 2 | Daniel-Abrecht/fuse-nfs-crossbuild-scripts 3 | 4 | libnfs https://github.com/sahlberg/libnfs.git +refs/tags/libnfs-{1.11.0<} +master 5 | fuse-nfs https://github.com/sahlberg/fuse-nfs.git +master 6 | dokany https://github.com/dokan-dev/dokany.git +refs/tags/v{1.2.0.1000<} +refs/tags/v{2.0.0-BETA0<} master 7 | 8 | out/ */* 9 | ../dokany/out/ */*.dll 10 | -------------------------------------------------------------------------------- /libnfs/mkbuild: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | src=src 4 | build=build 5 | out=out 6 | uri=https://github.com/sahlberg/libnfs.git 7 | checkout=origin/master 8 | 9 | root="$(realpath "$(dirname "$0")")" 10 | parent="$(realpath "$root"/..)" 11 | 12 | if [ -n "$LIBNFS_URI" ]; then uri="$LIBNFS_URI"; fi 13 | if [ -n "$LIBNFS_CHECKOUT" ]; then checkout="$LIBNFS_CHECKOUT"; fi 14 | 15 | src="$root/$src" 16 | build="$root/$build" 17 | out="$root/$out" 18 | 19 | function update { 20 | if [ ! -d "$src" ] 21 | then 22 | git clone --no-checkout -- "$uri" "$src" 23 | cd -- "$src" 24 | else 25 | cd -- "$src" 26 | git remote set-url origin "$uri" 27 | find -maxdepth 1 -not -name .git -not -name . -exec rm -rf {} \; 28 | git fetch 29 | fi 30 | git checkout "$checkout" >/dev/null 31 | git reset --hard; 32 | autoreconf --install 33 | cd -- "$root" 34 | } 35 | 36 | function compile { 37 | rm -rf -- "$build" 38 | mkdir -p -- "$build" 39 | cd -- "$build" 40 | chmod -w "$root" 41 | incs=( "${INCLUDES[@]/#/-I}" ) 42 | libs=( "${LIBS[@]/\%ARCH\%/"$1"}" ) 43 | libs=( "${libs[@]/#/-L}" ) 44 | "$src"/configure --host="$1" CPPFLAGS="${incs[*]} $FLAGS" CFLAGS="${incs[*]} $FLAGS" LDFLAGS="${libs[*]}" 45 | make 46 | chmod u+w "$root" 47 | cd -- "$root" 48 | mkdir -p "$out/$1" 49 | cp "$build"/lib/.libs/libnfs.a "$out/$1" 50 | } 51 | 52 | set -ex 53 | 54 | chmod u+w "$root" 55 | 56 | rm -rf -- "$out" 57 | mkdir -p -- "$out" 58 | 59 | "$parent"/dokany/mkbuild update 60 | 61 | update 62 | 63 | compile "x86_64" 64 | 65 | LIBS=( "$parent"/dokany/out/%ARCH%/ ) 66 | INCLUDES=( "$parent"/dokany/src/dokan_fuse/include/ ) 67 | 68 | compile "i686-w64-mingw32" 69 | compile "x86_64-w64-mingw32" 70 | -------------------------------------------------------------------------------- /mkbuild: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | PATH="$PATH:/usr/sbin:/usr/bin:/sbin:/bin" 4 | 5 | root="$(realpath "$(dirname "$0")")" 6 | out="$root"/out 7 | token=$(/dev/null 167 | then 168 | printf "%smatch %s %s\n" "$opts" "$hash" "$ref" 169 | if ref_version_lt "$latest_ref" "$ref" "${t_ref_parts[@]}" 170 | then 171 | latest_ref="$ref" 172 | latest_hash="$hash" 173 | fi 174 | fi 175 | done 176 | if [ -n "$latest_hash" ] 177 | then printf "latest %s %s\n" "$latest_hash" "$latest_ref" 178 | fi 179 | done 180 | } 181 | 182 | function combine { 183 | if [ -z "$1" ] 184 | then printf "%s\n" "$2" 185 | fi 186 | if [ -z "$2" ] 187 | then printf "%s\n" "$1" 188 | fi 189 | IFS=$'\n' 190 | a=($1) 191 | b=($2) 192 | for x in "${a[@]}" 193 | do for y in "${b[@]}" 194 | do printf "%s\t%s\n" "$x" "$y" 195 | done; done 196 | } 197 | 198 | function build_prepare { 199 | tfile="$1" 200 | base="$(dirname "$tfile")" 201 | { 202 | 203 | IFS= read name 204 | IFS= read github_release 205 | tfile_skip 206 | 207 | target_root="$out/$name" 208 | 209 | IFS=$'\n' 210 | repos=($(read_section)) 211 | out_files=($(read_section)) 212 | matches=() 213 | 214 | if [ "${#repos[@]}" = 0 ] 215 | then 216 | printf 'Error: Build failed for "%s". No repos specified\n' "$base" 1>&2 217 | return 1 218 | fi 219 | 220 | i=0 221 | for repo in "${repos[@]}" 222 | do 223 | IFS=' ' 224 | refs="$(get_matching_refs "$target_root" $repo|sed -e "s/^/$i /")" 225 | matches+=("$refs") 226 | if [ -z "$refs" ] 227 | then 228 | printf 'Error: Build failed for "%s". No match for repo "%s"\n' "$base" "$repo" 1>&2 229 | return 1 230 | fi 231 | i="$(expr "$i" + 1)" 232 | done 233 | 234 | mandatory= 235 | latest= 236 | i=0 237 | while [ "$i" -lt "${#repos[@]}" ] 238 | do 239 | m="$(printf "%s" "${matches[$i]}" | grep -E "[0-9]+ [^ ]*mandatory" | cut -d ' ' -f1,3,4 | sort -u)" 240 | l="$(printf "%s" "${matches[$i]}" | grep -E "[0-9]+ [^ ]*latest" | cut -d ' ' -f1,3,4 | sort -u)" 241 | if [ -z "$l" ] 242 | then l="*$(printf "%s" "${matches[$i]}" | head -n 1)" 243 | fi 244 | if [ -z "$m" ]; then 245 | if printf '%s' "$l" | grep -Evq "[0-9]+ [^ ]+ [^ ]+ master " 246 | then m="$(printf '%s' "$l" | grep -Ev "[0-9]+ [^ ]+ [^ ]+ master " | head -n 1)" 247 | else m="$(printf '%s' "$l" | head -n 1)" 248 | fi 249 | if [ "${m::1}" != '*' ] 250 | then m="*$m" 251 | fi 252 | fi 253 | mandatory="$(combine "$mandatory" "$m")" 254 | latest="$(combine "$latest" "$l")" 255 | i="$(expr "$i" + 1)" 256 | done 257 | 258 | tmp="$(printf '%s\n%s\n' "$mandatory" "$latest" | sort -u)" 259 | all="$({ 260 | printf '%s\n' "$tmp" | 261 | while IFS= read -r line 262 | do 263 | if ! printf '%s' "$line" | grep -Eq $'\\*[0-9]+ [0-9a-zA-Z]+ [^\t]+' 264 | then 265 | printf '%s\n' "$line" 266 | continue 267 | fi 268 | regex="$({ 269 | IFS=$'\t' dep=($line) 270 | printf '^' 271 | i=0 272 | for d in "${dep[@]}" 273 | do 274 | if [ "$i" = 1 ] 275 | then printf '\t' 276 | fi 277 | printf '[0-9]+ ' 278 | IFS=$' ' d=($d) 279 | if [ "${d[0]::1}" = '*' ] 280 | then printf '[0-9a-zA-Z]+' 281 | else printf '%s' "${d[1]}" 282 | fi 283 | printf ' [^\t]+' 284 | i=1 285 | done 286 | printf '$\n' 287 | })" 288 | printf "%s" "$tmp" | 289 | if ! grep -Eq "$regex" 290 | then printf "%s\n" "$line" 291 | fi 292 | done 293 | })" 294 | unset tmp 295 | 296 | IFS=$'\n' 297 | for target in $all 298 | do 299 | np= 300 | hash= 301 | vars= 302 | desc="$(date -u '+%Y-%m-%d %H:%M:%S') UTC"$'\1\1' 303 | IFS=$'\t' 304 | for part in $target 305 | do 306 | IFS=' ' 307 | p=($part) 308 | if [ "${p[0]::1}" = '*' ] 309 | then rnr=${p[0]:1} 310 | else rnr=${p[0]} 311 | fi 312 | r=(${repos[$rnr]}) 313 | const="$(printf '%s' "${r[0]}" | tr /a-z/ /A-Z/ | sed 's/[^A-Z0-9]*//g')" 314 | vars+="${const}_CHECKOUT=${p[1]} ${const}_URI=${r[1]} " 315 | desc+="${r[0]} repo=${r[1]} ref=${p[2]} commit=${p[1]}"$'\1' 316 | if [ "${p[0]::1}" = '*' ] 317 | then continue 318 | fi 319 | hash+="-${p[1]}" 320 | np+="${r[0]}=$(printf '%s' "${p[2]}" | grep -o '[^/]*$')_" 321 | done 322 | suffix="$(printf "%s" "$hash" | md5sum - | grep -o '^[^ ]*')" 323 | target_list+=("$(printf "%s\n%s\n%s\n%s" "${vars[*]}" "$(basename "$np$suffix")" "${np::${#np}-1}" "$desc")") 324 | done 325 | unset target; 326 | 327 | } < "$tfile" 328 | } 329 | 330 | function remove_from_github { 331 | if [ ! -f "$2"/.id ]; then return; fi 332 | id=$(<"$2"/.id) 333 | if [ -z "$id" ]; then return; fi 334 | if ! rcurl -H 'Authorization: token '"$token" --url "https://api.github.com/repos/$1/releases/$id" -X DELETE >/dev/null 335 | then return 1 336 | fi 337 | git push origin ":$3" &>/dev/null 338 | return 0 339 | } 340 | 341 | function github_create_release_asset { 342 | uri="https://uploads.github.com/repos/$1/releases/$2/assets?name=$4" 343 | file="$3" 344 | mime="$(file --mime-type "$file" | grep -o '[^ ]*$')" 345 | rcurl -X POST -H 'Authorization: token '"$token" -H "Content-Type: $mime" -H "Accept: application/vnd.github.manifold-preview" --url "$uri" --data-binary "@$file" >/dev/null 346 | return $? 347 | } 348 | 349 | function github_create_release { 350 | id="$( 351 | json_escape '{ 352 | "tag_name": %s, 353 | "target_commitish": "release", 354 | "name": %s, 355 | "body": %s, 356 | "draft": false, 357 | "prerelease": false 358 | } 359 | ' "$2" "$(printf '%s' "$2" | tr '_' ' ' )" "$3" | 360 | rcurl -H 'Authorization: token '"$token" --url "https://api.github.com/repos/$1/releases" -d "@-" | 361 | grep -o '"id": [0-9][0-9]*' | head -n 1 | grep -o '[0-9]*$' 362 | )" 363 | printf '%s' "$2" > "$4"/.tag 364 | if [ -z "$id" ] 365 | then 366 | return 1 367 | fi 368 | printf '%s' "$id" > "$4"/.id 369 | IFS=$'\n' 370 | for file in "$4"/* 371 | do 372 | if [ -d "$file" ] 373 | then 374 | zip="$file.zip" 375 | pushd "$4" 376 | zip -r "$zip" "$(basename "$file")" 377 | popd 378 | github_create_release_asset "$1" "$id" "$zip" "$(basename "$zip")" 379 | if [ "$?" != "0" ] 380 | then return 1 381 | fi 382 | rm "$zip" 383 | elif [ -f "$file" ] 384 | then 385 | github_create_release_asset "$1" "$id" "$file" "$(basename "$file")" 386 | if [ "$?" != "0" ] 387 | then return 1 388 | fi 389 | fi 390 | done 391 | printf 'Released: %s\n' "$2" 392 | return 0 393 | } 394 | 395 | function remove_old { 396 | for build_dir in "$target_root"/*/ 397 | do if ! [ -d "$build_dir" ]; then break; fi 398 | name="$(basename "$build_dir")" 399 | found=false 400 | for it in "${target_list[@]}" 401 | do 402 | IFS=$'\n' params=($it) 403 | if [ "${params[1]}" = "$name" ] 404 | then 405 | found=true 406 | break 407 | fi 408 | done 409 | if [ "$found" = false ] 410 | then 411 | if remove_from_github "$github_release" "$build_dir" "$(printf '%s' "$name" | sed 's/-[^-]*$//')" 412 | then rm -rf -- "$build_dir" 413 | fi 414 | fi 415 | done 416 | } 417 | 418 | function create { 419 | base="$1" 420 | for target in "${target_list[@]}" 421 | do 422 | IFS=$'\n' target=($target) 423 | if [ -d "$target_root/${target[1]}" ]; then continue; fi 424 | if [ -f "$target_root/${target[1]}.log" ]; then continue; fi 425 | IFS=' ' 426 | export ${target[0]} 427 | if ! "$base/mkbuild" &> "$target_root/${target[1]}.log" 428 | then continue 429 | fi 430 | for output in "${out_files[@]}" 431 | do ( 432 | set -f 433 | p=($output) 434 | file_root="$base/${p[0]}" 435 | set +f 436 | for files in "${p[@]:1}" 437 | do for file in "$file_root"/$files 438 | do 439 | dest="$target_root/${target[1]}/${file:${#file_root}}" 440 | src="$(realpath "$file")" 441 | mkdir -p "$(dirname "$dest")" 442 | cp -a "$src" "$dest" 443 | done 444 | done 445 | ) done 446 | mv "$target_root/${target[1]}.log" "$target_root/${target[1]}/build.log" 447 | if ! github_create_release "$github_release" "${target[2]}" "${target[3]}" "$target_root/${target[1]}" 448 | then mv "$target_root/${target[1]}" "$target_root/${target[1]}-uploadfail-$(date -u +%s)" 449 | fi 450 | done 451 | } 452 | 453 | function json_escape { 454 | format="$1" 455 | shift 456 | args=() 457 | for x in "$@" 458 | do 459 | args+=("$({ 460 | printf '"' 461 | printf "%s" "$x" | tr '\n' '\1' | sed $'s/\1/\\\\n/g' | sed 's/"/\\"/g' 462 | printf '"' 463 | })") 464 | done 465 | printf "$format" "${args[@]}" 466 | } 467 | 468 | function build { 469 | 470 | target_list=() 471 | target_root= 472 | out_files=() 473 | github_release= 474 | base="$(dirname "$1")" 475 | 476 | build_prepare "$@" 477 | if [ "$?" != 0 ] || [ "${#target_list[@]}" == 0 ] 478 | then return 1 479 | fi 480 | mkdir -p "$target_root" 481 | remove_old 482 | create "$base" 483 | 484 | } 485 | 486 | target_list= 487 | target_root= 488 | out_files= 489 | github_release= 490 | 491 | rout="$out" 492 | 493 | if [ -e "$root/mkbuild_lock" ] 494 | then exit 1 495 | fi 496 | 497 | touch "$root/mkbuild_lock" 498 | 499 | find "$root" -name '*.target' -type f | while IFS= read -r target 500 | do 501 | out="$rout/$target" 502 | mkdir -p "$out" 503 | build "$(realpath "$target")" 504 | done 505 | 506 | rm "$root/mkbuild_lock" 507 | --------------------------------------------------------------------------------