-
Notifications
You must be signed in to change notification settings - Fork 1
/
package.sh
executable file
·162 lines (132 loc) · 3.33 KB
/
package.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
#!/bin/sh -e
#
# Copyright 2023, Roger Brown
#
# This file is part of rhubarb-geek-nz/SQLite.Interop.
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation, either version 3 of the License, or (at your
# option) any later version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>
#
VERSION=1.0.118.0
SHA256=bb599fa265088abb8a7d4af6218cae97df8b9c8ed6f04fb940a5d564920ee6a1
ZIPNAME="sqlite-netFx-source-$VERSION.zip"
DOTNET=dotnet
DOTNET_CLI_TELEMETRY_OPTOUT=true
export DOTNET_CLI_TELEMETRY_OPTOUT
cleanup()
{
rm -rf src pkg "$ZIPNAME" rid/bin rid/obj dotnet-sdk dotnet-install.sh
}
trap cleanup 0
rm -rf *.zip
cleanup
if "$DOTNET" --version
then
:
else
curl --location --fail --silent --output dotnet-install.sh https://dot.net/v1/dotnet-install.sh
chmod +x dotnet-install.sh
./dotnet-install.sh --install-dir dotnet-sdk --channel 6.0
DOTNET="dotnet-sdk/dotnet"
fi
"$DOTNET" build rid/rid.csproj --configuration Release
RID=$("$DOTNET" rid/bin/Release/net6.0/rid.dll)
RIDOS=$(
echo $RID | sed y/-/\ / | while read A
do
RIDBASE=
RIDLAST=
for D in $A
do
if test -n "$RIDLAST"
then
if test -z "$RIDBASE"
then
RIDBASE="$RIDLAST"
else
RIDBASE="$RIDBASE-$RIDLAST"
fi
fi
RIDLAST=$D
done
echo $RIDBASE
done
)
echo RID=$RID
echo RIDOS=$RIDOS
cleanup
curl --silent --fail --output "$ZIPNAME" --location "https://system.data.sqlite.org/blobs/$VERSION/$ZIPNAME"
case $(uname) in
Darwin )
shasum -a 256 "$ZIPNAME" | grep "^$SHA256"
;;
* )
sha256sum "$ZIPNAME" | grep "^$SHA256"
;;
esac
mkdir src
(
set -e
cd src
unzip -q "../$ZIPNAME"
cd Setup
case $(uname) in
Darwin )
if grep "arch arm64" compile-interop-assembly-release.sh
then
:
else
sed "s/-arch x86_64/-arch x86_64 -arch arm64/g" < compile-interop-assembly-release.sh > compile-interop-assembly-osx.sh
mv compile-interop-assembly-osx.sh compile-interop-assembly-release.sh
fi
;;
* )
;;
esac
chmod +x compile-interop-assembly-release.sh
./compile-interop-assembly-release.sh
)
DLLNAME=SQLite.Interop
DLLPATH="src/bin/2013/Release/bin/$DLLNAME.dll"
ls -ld $(dirname "$DLLPATH")/*
if strip "$DLLPATH" 2>/dev/null
then
ls -ld "$DLLPATH"
fi
case $(uname) in
Darwin )
while read SRC DEST
do
DLL="pkg/runtimes/$RIDOS-$DEST/native/$DLLNAME.dll"
mkdir -p $(dirname $DLL)
lipo "$DLLPATH" -extract $SRC -output "$DLL"
codesign --timestamp --sign "Developer ID Application: $APPLE_DEVELOPER" "$DLL"
done <<EOF
arm64 arm64
x86_64 x64
EOF
mkdir -p "pkg/runtimes/$RIDOS/native"
lipo "pkg/runtimes/$RIDOS-"*"/native/$DLLNAME.dll" -create -output "pkg/runtimes/$RIDOS/native/$DLLNAME.dll"
;;
* )
RUNTIME="runtimes/$RID/native"
mkdir -p "pkg/$RUNTIME"
mv "$DLLPATH" "pkg/$RUNTIME/"
;;
esac
(
set -e
cd pkg
find runtimes -type f | xargs chmod -x
zip "../$DLLNAME-$VERSION-$RIDOS.zip" $(find runtimes -type f -name "$DLLNAME.dll")
)