Skip to content

Commit

Permalink
..
Browse files Browse the repository at this point in the history
  • Loading branch information
Skycoder42 committed Dec 3, 2024
1 parent 679cc46 commit d0e664c
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 23 deletions.
9 changes: 7 additions & 2 deletions packages/sodium_libs/android/libsodium/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,13 @@ cleanup() {
}

validate_checksum() {
sha512sum -c "$archive_hash_file"
return $?
if [ "$(uname)" = "Darwin" ]; then
shasum -a512 -c "$archive_hash_file"
return $?
else
sha512sum -c "$archive_hash_file"
return $?
fi
}

if [ -f "$archive_file" ]; then
Expand Down
19 changes: 0 additions & 19 deletions packages/sodium_libs/darwin/download_libsodium.sh

This file was deleted.

38 changes: 38 additions & 0 deletions packages/sodium_libs/darwin/libsodium/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/sh
set -e

cd libsodium

output_dir=../Libraries
archive_file=libsodium-1.0.20-darwin.tar.xz
archive_hash_file=$archive_file.sha512
archive_url_file=$archive_file.url
archive_url=$(cat "$archive_url_file")

cleanup() {
rm -f "$archive_file"
}

validate_checksum() {
shasum -a512 -c "$archive_hash_file"
return $?
}

if [ -f "$archive_file" ]; then
if validate_checksum; then
exit 0
fi
cleanup
fi

# add trap do delete the downloaded file if hash validation or extraction fail
trap cleanup EXIT

curl -sSLfo "$archive_file" "$archive_url"
validate_checksum

rm -rf "$output_dir"
mkdir -p "$output_dir"
tar -xf "$archive_file" -C "$output_dir"

trap '' EXIT
2 changes: 1 addition & 1 deletion packages/sodium_libs/darwin/sodium_libs.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ Flutter companion package to sodium that provides the low-level libsodium binari
s.swift_version = '5.0'

# libsodium
s.prepare_command = './download_libsodium.sh'
s.prepare_command = 'libsodium/setup.sh'
s.vendored_frameworks = "Libraries/libsodium.xcframework"
end
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ abstract class PluginTargets {
),
PluginTargetGroup(
'darwin',
'Libraries',
'libsodium',
_darwinTargets,
publish: DarwinTarget.createXcFramework,
extract: DarwinTarget.createChecksum,
Expand Down

0 comments on commit d0e664c

Please sign in to comment.