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
|
#!/bin/sh
|
||||||
|
|
||||||
|
srcfile=$(pwd)/.srcfile
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
src
|
src
|
||||||
manages source directories
|
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:
|
Flags:
|
||||||
--help, -h Displays this help
|
--help, -h Displays this help
|
||||||
|
|
@ -13,7 +21,20 @@ Flags:
|
||||||
EOF
|
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
|
## Update/clone this git repo
|
||||||
if ! [ -d "$2" ] ; then
|
if ! [ -d "$2" ] ; then
|
||||||
git clone "$1" "$2"
|
git clone "$1" "$2"
|
||||||
|
|
@ -23,7 +44,7 @@ gitrepo() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
tarfile() {
|
update_tarfile() {
|
||||||
## Download and extract this tarfile if it
|
## Download and extract this tarfile if it
|
||||||
## doesn't exist yet
|
## doesn't exist yet
|
||||||
if ! [ -d "$2" ] ; then
|
if ! [ -d "$2" ] ; then
|
||||||
|
|
@ -48,11 +69,11 @@ parse() {
|
||||||
case "$type" in
|
case "$type" in
|
||||||
"git")
|
"git")
|
||||||
echo "Updating: $path"
|
echo "Updating: $path"
|
||||||
gitrepo "$url" "$path"
|
update_gitrepo "$url" "$path"
|
||||||
;;
|
;;
|
||||||
"tar")
|
"tar")
|
||||||
echo "Updating: $path"
|
echo "Updating: $path"
|
||||||
#tarfile "$url" "$path"
|
#update_tarfile "$url" "$path"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Not a valid source type: $type"
|
echo "Not a valid source type: $type"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue