mbed-os
Fork of mbed-os by
features/nanostack/FEATURE_NANOSTACK/clone_nanostack.sh@0:f269e3021894, 2016-10-23 (annotated)
- Committer:
- elessair
- Date:
- Sun Oct 23 15:10:02 2016 +0000
- Revision:
- 0:f269e3021894
Initial commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
elessair | 0:f269e3021894 | 1 | #!/bin/bash |
elessair | 0:f269e3021894 | 2 | |
elessair | 0:f269e3021894 | 3 | # |
elessair | 0:f269e3021894 | 4 | # Export FEATURE_NANOSTACK libraries into mbed OS |
elessair | 0:f269e3021894 | 5 | # |
elessair | 0:f269e3021894 | 6 | # Usage: |
elessair | 0:f269e3021894 | 7 | # |
elessair | 0:f269e3021894 | 8 | # To remove all repositories call: ./clone_client.sh clean |
elessair | 0:f269e3021894 | 9 | # To replace all with clone repositores: ./clone_client.sh clone |
elessair | 0:f269e3021894 | 10 | # To export from cloned repositories: ./clone_client.sh export |
elessair | 0:f269e3021894 | 11 | # |
elessair | 0:f269e3021894 | 12 | # For developers: |
elessair | 0:f269e3021894 | 13 | # Use "clone" functionality to get master repositories to work with. |
elessair | 0:f269e3021894 | 14 | # |
elessair | 0:f269e3021894 | 15 | # For maintainers: Creating a release |
elessair | 0:f269e3021894 | 16 | # Use "clone" to get master repositories. |
elessair | 0:f269e3021894 | 17 | # For every directory checkout the release branch. |
elessair | 0:f269e3021894 | 18 | # Now use "export" function to flatten the git repositories into bare directories |
elessair | 0:f269e3021894 | 19 | # Now you can "git add" each directory and do "git commit" |
elessair | 0:f269e3021894 | 20 | # |
elessair | 0:f269e3021894 | 21 | # Note "clone" does implicit "clean" so you lose all changes done into directories. |
elessair | 0:f269e3021894 | 22 | |
elessair | 0:f269e3021894 | 23 | |
elessair | 0:f269e3021894 | 24 | # REPOSITORIES and DIRECTORIES are array of repositories where to clone |
elessair | 0:f269e3021894 | 25 | # and directories where to clone |
elessair | 0:f269e3021894 | 26 | # these arrays MUST be in sync |
elessair | 0:f269e3021894 | 27 | # * Same number of elements |
elessair | 0:f269e3021894 | 28 | # * Same order. Each line should have maching pair in same index at other array |
elessair | 0:f269e3021894 | 29 | REPOSITORIES=( |
elessair | 0:f269e3021894 | 30 | git@github.com:ARMmbed/sal-stack-nanostack.git |
elessair | 0:f269e3021894 | 31 | git@github.com:ARMmbed/coap-service.git |
elessair | 0:f269e3021894 | 32 | ) |
elessair | 0:f269e3021894 | 33 | |
elessair | 0:f269e3021894 | 34 | DIRECTORIES=( |
elessair | 0:f269e3021894 | 35 | sal-stack-nanostack |
elessair | 0:f269e3021894 | 36 | coap-service |
elessair | 0:f269e3021894 | 37 | ) |
elessair | 0:f269e3021894 | 38 | |
elessair | 0:f269e3021894 | 39 | # Exit immediately on fail, thread unset variables as error |
elessair | 0:f269e3021894 | 40 | set -eu |
elessair | 0:f269e3021894 | 41 | |
elessair | 0:f269e3021894 | 42 | # Count number of repositories |
elessair | 0:f269e3021894 | 43 | N=0 |
elessair | 0:f269e3021894 | 44 | for repo in ${REPOSITORIES[*]}; do |
elessair | 0:f269e3021894 | 45 | let N=N+1 |
elessair | 0:f269e3021894 | 46 | done |
elessair | 0:f269e3021894 | 47 | let N=N-1 # Substract one, because indexes start from 0 |
elessair | 0:f269e3021894 | 48 | |
elessair | 0:f269e3021894 | 49 | print_usage() { |
elessair | 0:f269e3021894 | 50 | echo -e "Usage: $0 [clean | clone | export ]" |
elessair | 0:f269e3021894 | 51 | echo -e "\tclean : Remove all repositories" |
elessair | 0:f269e3021894 | 52 | echo -e "\tclone : Replace repositories with Git cone" |
elessair | 0:f269e3021894 | 53 | echo -e "\texport : Export cloned Git repositories" |
elessair | 0:f269e3021894 | 54 | } |
elessair | 0:f269e3021894 | 55 | |
elessair | 0:f269e3021894 | 56 | clean() { |
elessair | 0:f269e3021894 | 57 | for dir in ${DIRECTORIES[*]}; do |
elessair | 0:f269e3021894 | 58 | rm -rf $dir |
elessair | 0:f269e3021894 | 59 | done |
elessair | 0:f269e3021894 | 60 | clean_nanostack_binaries |
elessair | 0:f269e3021894 | 61 | clean_nanostack_licenses |
elessair | 0:f269e3021894 | 62 | } |
elessair | 0:f269e3021894 | 63 | |
elessair | 0:f269e3021894 | 64 | clone() { |
elessair | 0:f269e3021894 | 65 | for i in $(seq 0 $N); do |
elessair | 0:f269e3021894 | 66 | git clone ${REPOSITORIES[$i]} ${DIRECTORIES[$i]} |
elessair | 0:f269e3021894 | 67 | done |
elessair | 0:f269e3021894 | 68 | } |
elessair | 0:f269e3021894 | 69 | |
elessair | 0:f269e3021894 | 70 | export_repos() { |
elessair | 0:f269e3021894 | 71 | for i in $(seq 0 $N); do |
elessair | 0:f269e3021894 | 72 | echo "Exporting ${DIRECTORIES[$i]}" |
elessair | 0:f269e3021894 | 73 | cd ${DIRECTORIES[$i]} |
elessair | 0:f269e3021894 | 74 | git archive HEAD -o ../${DIRECTORIES[$i]}.tar.gz |
elessair | 0:f269e3021894 | 75 | cd .. |
elessair | 0:f269e3021894 | 76 | rm -rf ${DIRECTORIES[$i]} |
elessair | 0:f269e3021894 | 77 | mkdir ${DIRECTORIES[$i]} |
elessair | 0:f269e3021894 | 78 | tar xzf ${DIRECTORIES[$i]}.tar.gz -C ${DIRECTORIES[$i]} |
elessair | 0:f269e3021894 | 79 | rm ${DIRECTORIES[$i]}.tar.gz |
elessair | 0:f269e3021894 | 80 | done |
elessair | 0:f269e3021894 | 81 | } |
elessair | 0:f269e3021894 | 82 | |
elessair | 0:f269e3021894 | 83 | copy_nanostack_binaries() { |
elessair | 0:f269e3021894 | 84 | mv sal-stack-nanostack/FEATURE_* ../ |
elessair | 0:f269e3021894 | 85 | } |
elessair | 0:f269e3021894 | 86 | |
elessair | 0:f269e3021894 | 87 | clean_nanostack_binaries() { |
elessair | 0:f269e3021894 | 88 | for binaries in ../FEATURE_*; do |
elessair | 0:f269e3021894 | 89 | if [ "$binaries" != "../FEATURE_NANOSTACK" ]; then |
elessair | 0:f269e3021894 | 90 | rm -rf $binaries |
elessair | 0:f269e3021894 | 91 | fi |
elessair | 0:f269e3021894 | 92 | done |
elessair | 0:f269e3021894 | 93 | } |
elessair | 0:f269e3021894 | 94 | |
elessair | 0:f269e3021894 | 95 | copy_nanostack_licenses() { |
elessair | 0:f269e3021894 | 96 | mv sal-stack-nanostack/LICENSE* ../ |
elessair | 0:f269e3021894 | 97 | } |
elessair | 0:f269e3021894 | 98 | |
elessair | 0:f269e3021894 | 99 | clean_nanostack_licenses() { |
elessair | 0:f269e3021894 | 100 | rm -rf ../LICENSE* |
elessair | 0:f269e3021894 | 101 | } |
elessair | 0:f269e3021894 | 102 | |
elessair | 0:f269e3021894 | 103 | case "${1-}" in |
elessair | 0:f269e3021894 | 104 | clean) |
elessair | 0:f269e3021894 | 105 | clean |
elessair | 0:f269e3021894 | 106 | ;; |
elessair | 0:f269e3021894 | 107 | clone) |
elessair | 0:f269e3021894 | 108 | clean |
elessair | 0:f269e3021894 | 109 | clone |
elessair | 0:f269e3021894 | 110 | ;; |
elessair | 0:f269e3021894 | 111 | export) |
elessair | 0:f269e3021894 | 112 | export_repos |
elessair | 0:f269e3021894 | 113 | copy_nanostack_binaries |
elessair | 0:f269e3021894 | 114 | copy_nanostack_licenses |
elessair | 0:f269e3021894 | 115 | ;; |
elessair | 0:f269e3021894 | 116 | *) |
elessair | 0:f269e3021894 | 117 | print_usage |
elessair | 0:f269e3021894 | 118 | exit 1 |
elessair | 0:f269e3021894 | 119 | ;; |
elessair | 0:f269e3021894 | 120 | esac |