auto_ninja.sh
                        
                             · 1.0 KiB · Bash
                        
                    
                    
                      
                        Brut
                      
                    
                      
                    
                        
                          
                        
                    
                    
                
                
                
            repos=(
  cstools
  webtools
  docgenerator
  dbtools
  commandframework
  static
  ipmicontroller
  gitrunner
  aiurobserver
  cpprunner
  arraydb
  inmemorykvdb
  gptclient
  gitmirrorserver
  internalimages
  warp
  infrastructures
)
current_dir=$(pwd)
for repo in "${repos[@]}"; do
    # make sure the directory exists
    if [ ! -d "$repo" ]; then
        echo "Cloning $repo..."
        git clone "ssh://git@gitlab.aiursoft.cn:2202/aiursoft/$repo.git" || {
            echo "Error: failed to clone $repo" >&2
            exit 1
        }
    else
        echo "Skipping existing $repo"
    fi
    cd "$repo" || exit 1
    # make sure the branch is master
    git checkout master || {
        echo "Error: failed to checkout master branch for $repo" >&2
        exit 1
    }
    # pull the latest changes
    git pull origin master || {
        echo "Error: failed to pull latest changes for $repo" >&2
        exit 1
    }
    # execute the ninja command
    ninja all --path .
    
    # return to the original directory
    cd $current_dir || exit 1
done
                | 1 | repos=( | 
| 2 | cstools | 
| 3 | webtools | 
| 4 | docgenerator | 
| 5 | dbtools | 
| 6 | commandframework | 
| 7 | static | 
| 8 | ipmicontroller | 
| 9 | gitrunner | 
| 10 | aiurobserver | 
| 11 | cpprunner | 
| 12 | arraydb | 
| 13 | inmemorykvdb | 
| 14 | gptclient | 
| 15 | gitmirrorserver | 
| 16 | internalimages | 
| 17 | warp | 
| 18 | infrastructures | 
| 19 | ) | 
| 20 | |
| 21 | current_dir=$(pwd) | 
| 22 | for repo in "${repos[@]}"; do | 
| 23 | |
| 24 | # make sure the directory exists | 
| 25 | if [ ! -d "$repo" ]; then | 
| 26 | echo "Cloning $repo..." | 
| 27 | git clone "ssh://git@gitlab.aiursoft.cn:2202/aiursoft/$repo.git" || { | 
| 28 | echo "Error: failed to clone $repo" >&2 | 
| 29 | exit 1 | 
| 30 | } | 
| 31 | else | 
| 32 | echo "Skipping existing $repo" | 
| 33 | fi | 
| 34 | |
| 35 | cd "$repo" || exit 1 | 
| 36 | |
| 37 | # make sure the branch is master | 
| 38 | git checkout master || { | 
| 39 | echo "Error: failed to checkout master branch for $repo" >&2 | 
| 40 | exit 1 | 
| 41 | } | 
| 42 | |
| 43 | # pull the latest changes | 
| 44 | git pull origin master || { | 
| 45 | echo "Error: failed to pull latest changes for $repo" >&2 | 
| 46 | exit 1 | 
| 47 | } | 
| 48 | |
| 49 | # execute the ninja command | 
| 50 | ninja all --path . | 
| 51 | |
| 52 | # return to the original directory | 
| 53 | cd $current_dir || exit 1 | 
| 54 | |
| 55 | done | 
| 56 |