Cygwin 保存软件包选择以供以后重新安装 [英] Cygwin save package selections for later reinstall

查看:16
本文介绍了Cygwin 保存软件包选择以供以后重新安装的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I was wondering if there is a way to save the current package selections for cygwin for a later reinstall or porting on a different system.

如果能够:

  • 运行命令以导出现有系统上已安装软件包的列表
  • setup-x86_64.exe --list list.txt
  • 等方式将列表传递给另一个系统上的安装程序
  • run a command to export a list of installed packages on an existing system
  • pass the list to the installer on another system in a way such as setup-x86_64.exe --list list.txt

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

I don't think the setup has such a switch, so even any type of script or batch working in this direction would be just fine.

由于需要的包数量非常多,应该是无人看管,才算是一个不错的解决方案!

Since the number of needed packages is very high, it should be unattended in order to consider it as a good solution!

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

推荐答案

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

The list of installed packages is available with cygcheck. Setup does not accept a list option but you can specific the list with -P

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

The following code, when used with -A option will create a crafted cyg-reinstall-${Arch}.bat batch file to install all packages existing in a system.

#!/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 "
 pause "}' ${lista} >> cyg-reinstall-${A}.bat

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

这篇关于Cygwin 保存软件包选择以供以后重新安装的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆