Created
May 12, 2011 19:01
-
-
Save jersub/969204 to your computer and use it in GitHub Desktop.
Set of Bazaar scripts for another agile development process.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
SCRIPT_NAME="agile_create-repo" | |
USERS_REPO="users" | |
usage() { | |
cat << EOF | |
Usage: $SCRIPT_NAME PATH | |
Create a Bazaar repository at the given PATH. | |
EOF | |
} | |
check_env() { | |
if [ -z "$AGILE_USERS" ] | |
then | |
echo "Environment variable AGILE_USERS is not set" 1>&2 | |
echo "" | |
usage | |
exit 2 | |
fi | |
declare -g AGILE_USERS=($AGILE_USERS) | |
} | |
parse_args() { | |
if [ $# -ne 1 ] | |
then | |
usage | |
exit 1 | |
fi | |
shared_repo="$1" | |
} | |
handle_error() { | |
if [ $1 -ne 0 ] | |
then | |
exit 1 | |
fi | |
} | |
create_repo() { | |
repo="$1" | |
repo_path="$shared_repo/$repo" | |
if [ -z "$repo" ] | |
then | |
return 1 | |
fi | |
echo "Creating repository $repo_path..." | |
bzr init "$repo_path" 1>/dev/null | |
handle_error $? | |
return 0 | |
} | |
create_dir() { | |
dir="$1" | |
dir_path="$shared_repo/$dir" | |
if [ -z "$dir" ] | |
then | |
return 1 | |
fi | |
echo "Creating container directory $dir_path..." | |
mkdir "$dir_path" | |
handle_error $? | |
return 0 | |
} | |
check_env | |
parse_args $@ | |
echo "Creating shared repository $shared_repo..." | |
bzr init-repo --no-trees "$shared_repo" 1>/dev/null | |
handle_error $? | |
echo "" | |
create_repo "design" | |
create_repo "mockups" | |
create_repo "trunk" | |
create_dir "releases" | |
echo "" | |
echo "Creating user repositories:" | |
create_dir "$USERS_REPO" | |
for user in ${AGILE_USERS[@]} | |
do | |
create_dir "$USERS_REPO/$user" | |
done | |
echo "" | |
echo "Successfully created the whole $shared_repo repository!" | |
exit 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
REPO_PATH="/srv/bzr" | |
MIRROR_PATH="/srv/bzr-mirrors" | |
check_env() { | |
if [ -z "$MIRRORED_REPOS" ] | |
then | |
echo "Environment variable MIRRORED_REPOS is not set" 1>&2 | |
exit 2 | |
fi | |
declare -g MIRRORED_REPOS=($MIRRORED_REPOS) | |
} | |
init_mirror() { | |
repo="$1" | |
echo ">> Create $repo mirror" | |
cd "$MIRROR_PATH" | |
bzr branch "$REPO_PATH/$repo/trunk" "$repo" | |
echo "" | |
} | |
pull_mirror() { | |
mirror="$1" | |
echo ">> Update $repo mirror" | |
cd "$MIRROR_PATH/$mirror" | |
bzr pull --overwrite | |
echo "" | |
} | |
check_env | |
for repo in ${MIRRORED_REPOS[@]} | |
do | |
if [ -d "$MIRROR_PATH/$repo" ] | |
then | |
pull_mirror $repo | |
else | |
init_mirror $repo | |
fi | |
done | |
exit 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BIN=agile_create-repo agile_update-mirrors | |
PREFIX=/usr/local | |
install: | |
@install -v $(BIN) $(PREFIX)/bin | |
uninstall: | |
@for bin in $(BIN); do \ | |
rm -fv $(PREFIX)/bin/$$bin; \ | |
done; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment