forked from PauloLeca/glide-link
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathglide-unlink
executable file
·34 lines (28 loc) · 1.17 KB
/
glide-unlink
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
#!/bin/bash
# ---
# Usage: glide-unlink <package>
# Description: Un-link a dependent Go package from the current package.
# Author: https://github.com/jbarefoot
# ---
BACKUP_SUFFIX=_glide-link_bak
if [ -z "$1" ] ; then
echo "1 argument required, the go package import path, e.g. github.com/organization/repository; $# arguments provided."
exit 1
fi
ABS_DEPENDENCY_PATH=$GOPATH/src/$1
REL_VENDOR_PATH=vendor/$1
REL_VENDOR_BACKUP_PATH=$REL_VENDOR_PATH$BACKUP_SUFFIX
if [ ! -e $REL_VENDOR_BACKUP_PATH ] ; then
echo "Nothing to do: $REL_VENDOR_BACKUP_PATH does not exist, meaning $1 is NOT linked."
exit 1
fi
ABS_DEPENDENCY_VENDOR_BACKUP_PATH=$ABS_DEPENDENCY_PATH/vendor$BACKUP_SUFFIX
if [ -e $ABS_DEPENDENCY_VENDOR_BACKUP_PATH ] ; then
mv $ABS_DEPENDENCY_VENDOR_BACKUP_PATH $ABS_DEPENDENCY_PATH/vendor
else
echo "Notice: No backup of /vendor directory in dependent package path: $ABS_DEPENDENCY_VENDOR_BACKUP_PATH does not exist. Proceeding with unlink anyway..."
fi
# Remove the symbolic link to the dependent package on the GOPATH first then restore the backup directory
rm -rf $REL_VENDOR_PATH
mv $REL_VENDOR_BACKUP_PATH $REL_VENDOR_PATH
rm -v `pwd`/`basename $1`.softlinked