安裝包的列表,請與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
你的解決方案是出衆!正是我在找的東西。我只需編輯生成的批處理以添加我最喜歡的網站'-s'和我的LAN的cygwin local-package-dir'-l'。如果您可以在構建列表之前編輯您的腳本以詢問這些細節,那麼這將是完美的,因爲此時可以添加無人值守的'-q'。此外,批處理在可執行文件名稱和第一個「-P」開關之間生成了三個空格,但這是純粹的形式。 – Marco
我已經在第52行添加了我的個人喜好,例如本地目錄和首選本地鏡像:您的腳本的「回聲...」。它像一個魅力。 – Marco