install.sh 738 B

123456789101112131415161718192021222324252627282930313233
  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. check_and_install liblapack-dev libsuitesparse-dev libcxsparse3
  26. cd_dir build
  27. cmake ..
  28. make -j7
  29. sudo make install
  30. cd ..