WIP src
This commit is contained in:
parent
33a8fefcfc
commit
e162e41ee2
1 changed files with 26 additions and 5 deletions
31
src
31
src
|
|
@ -1,11 +1,19 @@
|
|||
#!/bin/sh
|
||||
|
||||
srcfile=$(pwd)/.srcfile
|
||||
|
||||
usage() {
|
||||
cat <<EOF
|
||||
src
|
||||
manages source directories
|
||||
|
||||
Usage: src
|
||||
Usage: src [COMMAND]
|
||||
|
||||
Commands:
|
||||
update Update source directory
|
||||
ls List managed directories
|
||||
add Add a source
|
||||
rm Remove a source directory
|
||||
|
||||
Flags:
|
||||
--help, -h Displays this help
|
||||
|
|
@ -13,7 +21,20 @@ Flags:
|
|||
EOF
|
||||
}
|
||||
|
||||
gitrepo() {
|
||||
add_gitrepo() {
|
||||
## Add this git repo to the srcfile
|
||||
echo "git" "$1" "$2" >> "$srcfile"
|
||||
}
|
||||
|
||||
rm_entry() {
|
||||
## Remove this entry from the srcfile
|
||||
tmp="$srcfile.tmp"
|
||||
|
||||
awk "\$3 == $1 { print }" "$srcfile" > "$tmp"
|
||||
mv "$tmp" "$srcfile"
|
||||
}
|
||||
|
||||
update_gitrepo() {
|
||||
## Update/clone this git repo
|
||||
if ! [ -d "$2" ] ; then
|
||||
git clone "$1" "$2"
|
||||
|
|
@ -23,7 +44,7 @@ gitrepo() {
|
|||
fi
|
||||
}
|
||||
|
||||
tarfile() {
|
||||
update_tarfile() {
|
||||
## Download and extract this tarfile if it
|
||||
## doesn't exist yet
|
||||
if ! [ -d "$2" ] ; then
|
||||
|
|
@ -48,11 +69,11 @@ parse() {
|
|||
case "$type" in
|
||||
"git")
|
||||
echo "Updating: $path"
|
||||
gitrepo "$url" "$path"
|
||||
update_gitrepo "$url" "$path"
|
||||
;;
|
||||
"tar")
|
||||
echo "Updating: $path"
|
||||
#tarfile "$url" "$path"
|
||||
#update_tarfile "$url" "$path"
|
||||
;;
|
||||
*)
|
||||
echo "Not a valid source type: $type"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue