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

Cygwin save package selections for later reinstall

我想知道是否有办法为 cygwin 保存当前的软件包选择,以便以后在不同的系统上重新安装或移植。

真的很棒:

我不认为设置有这样的开关,所以即使任何类型的脚本或批处理都可以在这个方向上工作。

由于需要的包数非常多,应该是无人值守才算是一个好的解决方案!

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

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

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

# error message if options are incorrect.
if [ $print_error -eq 1 ]
then
        echo -n "Usage : " $(basename [=10=])
        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 [  == "-I" ]
then
  awk 'BEGIN{printf(" -x ")} NR==1{printf }{printf ",%s", }' ${lista} >> cyg-reinstall-${A}.bat
fi

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

# execution permission for the script
chmod +x cyg-reinstall-${A}.bat