Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
bcdbed96
Unverified
Commit
bcdbed96
authored
Mar 02, 2018
by
jcollins-g
Committed by
GitHub
Mar 02, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add upgrade locking for macs (#15038)
parent
1a7eeb34
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
10 deletions
+25
-10
flutter
bin/flutter
+25
-10
No files found.
bin/flutter
View file @
bcdbed96
...
@@ -33,7 +33,13 @@ function path_uri() {
...
@@ -33,7 +33,13 @@ function path_uri() {
echo
"
$1
"
|
sed
-E
-e
"s,^/+,/,"
echo
"
$1
"
|
sed
-E
-e
"s,^/+,/,"
}
}
function
_rmlock
()
{
[
-n
"
$FLUTTER_UPGRADE_LOCK
"
]
&&
rm
-f
"
$FLUTTER_UPGRADE_LOCK
"
}
function
upgrade_flutter
()
{
function
upgrade_flutter
()
{
mkdir
-p
"
$FLUTTER_ROOT
/bin/cache"
# This function is executed with a redirect that pipes the source of
# This function is executed with a redirect that pipes the source of
# this script into file descriptor 3.
# this script into file descriptor 3.
#
#
...
@@ -47,14 +53,14 @@ function upgrade_flutter () {
...
@@ -47,14 +53,14 @@ function upgrade_flutter () {
# file, having inherited the file descriptor from the shell.
# file, having inherited the file descriptor from the shell.
#
#
# Complicating matters, there are two major scenarios where this
# Complicating matters, there are two major scenarios where this
# will not work. The first is if the platform doesn't have "flock",
# will not work.
# for example on Mac. There does not appear to be any sort of other
# equivalent, so on platforms that don't have flock, we just don't
# do anything.
#
#
# To determine if we have "flock" available, we abuse the "hash"
# The first is if the platform doesn't have "flock", for example on Mac.
# shell built-in to determine if "flock" resolves to anything. If it
# There is not a direct equivalent, so on platforms that don't have flock,
# does, we call it, otherwise we forget the whole thing.
# we fall back to using a lockfile and spinlock with "shlock". This
# doesn't work as well over NFS as it relies on PIDs. Any platform
# without either of these tools has no locking at all. To determine if we
# have "flock" or "shlock" available, we abuse the "hash" shell built-in.
#
#
# The second complication is NFS. On NFS, to obtain an exclusive
# The second complication is NFS. On NFS, to obtain an exclusive
# lock you need a file descriptor that is open for writing, because
# lock you need a file descriptor that is open for writing, because
...
@@ -65,16 +71,20 @@ function upgrade_flutter () {
...
@@ -65,16 +71,20 @@ function upgrade_flutter () {
# users will typically not care about errors from flock and are
# users will typically not care about errors from flock and are
# more likely to be confused by them than helped.
# more likely to be confused by them than helped.
#
#
# The lock is released when the file descriptor goes out of scope,
# For "flock", the lock is released when the file descriptor goes out of
# i.e. when this function returns.
# scope, i.e. when this function returns. The lock is released via
# a trap when using "shlock".
if
hash
flock 2>/dev/null
;
then
if
hash
flock 2>/dev/null
;
then
flock 3 2>/dev/null
||
true
flock 3 2>/dev/null
||
true
elif
hash
shlock 2>/dev/null
;
then
FLUTTER_UPGRADE_LOCK
=
"
$FLUTTER_ROOT
/bin/cache/.upgrade_lock"
while
!
shlock
-f
"
$FLUTTER_UPGRADE_LOCK
"
-p
$$
;
do
sleep
.1
;
done
trap
_rmlock EXIT
fi
fi
local
revision
=
`
(
cd
"
$FLUTTER_ROOT
"
;
git rev-parse HEAD
)
`
local
revision
=
`
(
cd
"
$FLUTTER_ROOT
"
;
git rev-parse HEAD
)
`
if
[
!
-f
"
$SNAPSHOT_PATH
"
]
||
[
!
-s
"
$STAMP_PATH
"
]
||
[
`
cat
"
$STAMP_PATH
"
`
!=
"
$revision
"
]
||
[
"
$FLUTTER_TOOLS_DIR
/pubspec.yaml"
-nt
"
$FLUTTER_TOOLS_DIR
/pubspec.lock"
]
;
then
if
[
!
-f
"
$SNAPSHOT_PATH
"
]
||
[
!
-s
"
$STAMP_PATH
"
]
||
[
`
cat
"
$STAMP_PATH
"
`
!=
"
$revision
"
]
||
[
"
$FLUTTER_TOOLS_DIR
/pubspec.yaml"
-nt
"
$FLUTTER_TOOLS_DIR
/pubspec.lock"
]
;
then
rm
-f
"
$FLUTTER_ROOT
/version"
rm
-f
"
$FLUTTER_ROOT
/version"
mkdir
-p
"
$FLUTTER_ROOT
/bin/cache"
touch
"
$FLUTTER_ROOT
/bin/cache/.dartignore"
touch
"
$FLUTTER_ROOT
/bin/cache/.dartignore"
"
$FLUTTER_ROOT
/bin/internal/update_dart_sdk.sh"
"
$FLUTTER_ROOT
/bin/internal/update_dart_sdk.sh"
...
@@ -97,6 +107,11 @@ function upgrade_flutter () {
...
@@ -97,6 +107,11 @@ function upgrade_flutter () {
"
$DART
"
--snapshot
=
"
$SNAPSHOT_PATH
"
--packages
=
"
$FLUTTER_TOOLS_DIR
/.packages"
"
$SCRIPT_PATH
"
"
$DART
"
--snapshot
=
"
$SNAPSHOT_PATH
"
--packages
=
"
$FLUTTER_TOOLS_DIR
/.packages"
"
$SCRIPT_PATH
"
echo
"
$revision
"
>
"
$STAMP_PATH
"
echo
"
$revision
"
>
"
$STAMP_PATH
"
fi
fi
# The exit here is duplicitous since the function is run in a subshell,
# but this serves as documentation that running the function in a
# subshell is required to make sure any lockfile created by shlock
# is cleaned up.
exit
$?
}
}
PROG_NAME
=
"
$(
path_uri
"
$(
follow_links
"
$BASH_SOURCE
"
)
"
)
"
PROG_NAME
=
"
$(
path_uri
"
$(
follow_links
"
$BASH_SOURCE
"
)
"
)
"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment