Cygwin保存包选择以便以后重新安装

Mar*_*rco 8 windows scripting cygwin

我想知道是否有办法保存当前的cygwin包选择,以便以后重新安装/移植到不同的(或同一个但擦除的)系统上.

这样做真的很棒:

  • 运行命令以导出现有系统上已安装的软件包列表
  • 以一种方式将列表传递给另一个系统上的安装程序 setup-x86_64.exe --list list.txt

我不认为设置有这样的开关,所以即使是在这个方向上工作的任何类型的脚本或批处理都可以.由于所需包装的数量非常多,因此应该无人看管,以便将其视为一个好的解决方案!

完成这样快速重新安装的最佳方法是什么?

mat*_*eri 10

已安装的软件包列表可用cygcheck.Setup不接受列表选项,但您可以使用列表特定-P

以下代码与-A选项一起使用时将创建精心设计的cyg-reinstall-${Arch}.bat批处理文件,以安装系统中存在的所有包.

#!/bin/bash
# Create a batch file to reinstall using setup-{ARCH}.exe
# all packages reported as incomplete

print_error=1

if [ $# -eq 1 ]
  then
    if [ $1 == "-I" ]
    then
      lista=$(mktemp)
      cygcheck -c | grep "Incomplete" > $lista
      print_error=0
    fi
    if [ $1 == "-A" ]
    then
      lista=$(mktemp)
      cygcheck -cd | sed -e "1,2d" > $lista
      print_error=0
    fi
fi

if [ $# -eq 2 ]
  then
    if [ $1 == "-f" ]
    then
      lista=$2
      print_error=0
    fi
fi

# error message if options are incorrect.
if [ $print_error -eq 1 ]
then
        echo -n "Usage : " $(basename $0)
        echo " [ -A | -I | -f filelist ]"
        echo "  create cyg-reinstall-{ARC}.bat from"
        echo "  options"
        echo "    -A  :  All packages as reported by cygcheck"
        echo "    -I  :  incomplete packages as reported by cygcheck"
        echo "    -f  :  packages in filelist (one per raw)"
        exit 1
fi

if [ $(arch) == "x86_64" ]
then
  A="x86_64"
else
  A="x86"
fi
# writing header
echo -n -e "setup-${A}.exe  " > cyg-reinstall-${A}.bat

# option  -x remove and  -P install
# for re-install packages we need both
if [ $1 == "-I" ]
then
  awk 'BEGIN{printf(" -x ")} NR==1{printf $1}{printf ",%s", $1}' ${lista} >> cyg-reinstall-${A}.bat
fi

awk 'BEGIN{printf(" -P ")} NR==1{printf $1}{printf ",%s", $1} END { printf "\r\n pause "}' ${lista} >> cyg-reinstall-${A}.bat

# execution permission for the script
chmod +x cyg-reinstall-${A}.bat
Run Code Online (Sandbox Code Playgroud)