Skip to content

Commit d7f0c4f

Browse files
committed
utils/aosp: Refactor code to display status message and remove chmod call
Now directories are owned by aosp user, there is not need to explicitly chmod to 777. Current user will create and own the folder.
1 parent d47f14d commit d7f0c4f

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

utils/aosp

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,30 @@ AOSP_VOL_AOSP=${AOSP_VOL_AOSP%/} # Trim trailing slash if needed
1919
AOSP_VOL_CCACHE=${AOSP_VOL_CCACHE:-$AOSP_VOL/ccache}
2020
AOSP_VOL_CCACHE=${AOSP_VOL_CCACHE%/} # Trim trailing slash if needed
2121

22-
if [ ! -d "$AOSP_VOL_AOSP" -o ! -d "$AOSP_VOL_CCACHE" ]; then
23-
sudo mkdir -p $AOSP_VOL_AOSP $AOSP_VOL_CCACHE
24-
sudo chmod 777 $AOSP_VOL_AOSP $AOSP_VOL_CCACHE
25-
fi
22+
# Convenience function
23+
function aosp_create_dir_if_needed {
24+
directory=$1
25+
msg="Checking if $directory exists"
26+
echo "$msg"
27+
if [ ! -d "$directory" ]; then
28+
echo "$msg - unexistent"
29+
msg="Creating $directory"
30+
echo "$msg"
31+
mkdir -p $directory
32+
fi
33+
echo "$msg - ok"
34+
}
35+
36+
# Create AOSP_VOL_AOSP
37+
aosp_create_dir_if_needed $AOSP_VOL_AOSP
38+
aosp_create_dir_if_needed $AOSP_VOL_CCACHE
2639

2740
if [ -n "$SSH_AUTH_SOCK" ]; then
2841
SSH_AUTH_ARGS="-v $SSH_AUTH_SOCK:/tmp/ssh_auth -e SSH_AUTH_SOCK=/tmp/ssh_auth"
2942
fi
3043

44+
echo ""
45+
3146
docker run $AOSP_ARGS $SSH_AUTH_ARGS $AOSP_EXTRA_ARGS \
3247
-v "$AOSP_VOL_AOSP:/aosp" -v "$AOSP_VOL_CCACHE:/tmp/ccache" \
3348
$AOSP_IMAGE $@

0 commit comments

Comments
 (0)