install.sh 683 B

1234567891011121314151617181920212223242526272829303132
  1. #!/bin/bash
  2. function cd_dir {
  3. local dir_path=$1
  4. # 检查目录是否存在
  5. if [ ! -d "$dir_path" ]; then
  6. echo "Directory $dir_path does not exist. Creating..."
  7. mkdir -p "$dir_path"
  8. fi
  9. cd "$dir_path" || exit
  10. }
  11. # 安装包检测
  12. function check_and_install {
  13. for package_name in "$@"
  14. do
  15. if ! dpkg -l $package_name &> /dev/null
  16. then
  17. echo "$package_name not found. Installing..."
  18. sudo apt-get update
  19. sudo apt-get install $package_name -y
  20. else
  21. echo "$package_name already installed."
  22. fi
  23. done
  24. }
  25. cd_dir build
  26. cmake ..
  27. sudo make install -j8
  28. sudo ldconfig
  29. cd ..