From 7ae6b54360ac8859635757c46c949fdf659ee7aa Mon Sep 17 00:00:00 2001 From: James Booth Date: Thu, 8 Aug 2013 23:35:46 +0100 Subject: [PATCH 001/309] Hard coded x86 to path --- apt-cyg | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apt-cyg b/apt-cyg index 59e9522..1230e2f 100644 --- a/apt-cyg +++ b/apt-cyg @@ -103,14 +103,14 @@ function getsetup() then touch setup.ini mv setup.ini setup.ini-save - wget -N $mirror/setup.bz2 + wget -N $mirror/x86/setup.bz2 if test -e setup.bz2 && test $? -eq 0 then bunzip2 setup.bz2 mv setup setup.ini echo Updated setup.ini else - wget -N $mirror/setup.ini + wget -N $mirror/x86/setup.ini if test -e setup.ini && test $? -eq 0 then echo Updated setup.ini @@ -346,7 +346,7 @@ case "$command" in file=`basename $install` cd "release/$pkg" - wget -nc $mirror/$install + wget -nc $mirror/x86/$install # check the md5 digest=`cat "desc" | awk '/^install: / { print $4; exit }'` From 7c381ca1e3a755e11912d9a326b60e3e7f564e99 Mon Sep 17 00:00:00 2001 From: James Booth Date: Thu, 8 Aug 2013 23:45:57 +0100 Subject: [PATCH 002/309] Removed arch from package download paths --- apt-cyg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apt-cyg b/apt-cyg index 1230e2f..01623a7 100644 --- a/apt-cyg +++ b/apt-cyg @@ -346,7 +346,7 @@ case "$command" in file=`basename $install` cd "release/$pkg" - wget -nc $mirror/x86/$install + wget -nc $mirror/$install # check the md5 digest=`cat "desc" | awk '/^install: / { print $4; exit }'` From 21c48b56b0d946213f87a2ee5b9a6ca2fe8931e6 Mon Sep 17 00:00:00 2001 From: James Booth Date: Fri, 9 Aug 2013 00:29:26 +0100 Subject: [PATCH 003/309] Check for arch value --- apt-cyg | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/apt-cyg b/apt-cyg index 01623a7..e5066b6 100644 --- a/apt-cyg +++ b/apt-cyg @@ -71,10 +71,17 @@ function version() function findworkspace() { - # default working directory and mirror + # default working directory, mirror and architecture mirror=ftp://mirror.mcs.anl.gov/pub/cygwin + arch=x86 + if test "arch" == "x86_64" + then + arch=x86_64 + fi cache=/setup + + # work wherever setup worked last, if possible @@ -103,14 +110,14 @@ function getsetup() then touch setup.ini mv setup.ini setup.ini-save - wget -N $mirror/x86/setup.bz2 + wget -N $mirror/$arch/setup.bz2 if test -e setup.bz2 && test $? -eq 0 then bunzip2 setup.bz2 mv setup setup.ini echo Updated setup.ini else - wget -N $mirror/x86/setup.ini + wget -N $mirror/$arch/setup.ini if test -e setup.ini && test $? -eq 0 then echo Updated setup.ini From b29ec29c62b01d22492ef8e34d27fd31a6cb25db Mon Sep 17 00:00:00 2001 From: Ryan Duryea Date: Fri, 9 Aug 2013 11:37:16 -0700 Subject: [PATCH 004/309] Handle the x86/x86_64 split when downloading setup.ini Cygwin recently introduced an x86_64 version and so all the mirrors now have x86 or x86_64 in their paths, depending on which version you've installed. The only change required is when the setup file is fetched. The setup file itself contains the paths prefixed with either x86 or x86_64 --- apt-cyg | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/apt-cyg b/apt-cyg index 59e9522..f713d37 100644 --- a/apt-cyg +++ b/apt-cyg @@ -99,11 +99,20 @@ function findworkspace() function getsetup() { + + ARCH=`uname -m | grep _64` + if test "-$ARCH-" = "--" + then + arch="x86" + else + arch="x86_64" + fi + if test "$noscripts" == "0" -a "$noupdate" == "0" then touch setup.ini mv setup.ini setup.ini-save - wget -N $mirror/setup.bz2 + wget -N $mirror/$arch/setup.bz2 if test -e setup.bz2 && test $? -eq 0 then bunzip2 setup.bz2 From d05f1497d4079836eecc987fd8f11b9e9787e494 Mon Sep 17 00:00:00 2001 From: James Booth Date: Sat, 10 Aug 2013 23:22:48 +0100 Subject: [PATCH 005/309] Fix calling arch command --- apt-cyg | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/apt-cyg b/apt-cyg index e5066b6..3b63ef2 100644 --- a/apt-cyg +++ b/apt-cyg @@ -72,16 +72,14 @@ function version() function findworkspace() { # default working directory, mirror and architecture - + mirror=ftp://mirror.mcs.anl.gov/pub/cygwin arch=x86 - if test "arch" == "x86_64" + if test `arch` == "x86_64" then arch=x86_64 fi cache=/setup - - # work wherever setup worked last, if possible From 4c961d1a3eac9d0e54a5d888913277f3bb062d6c Mon Sep 17 00:00:00 2001 From: Ryan Duryea Date: Thu, 15 Aug 2013 14:58:04 -0700 Subject: [PATCH 006/309] fetch setup.ini using $arch in mirror path as well boothj5 pointed out that the script also needs the $arch in the URL when fetching setup.ini as a fall back to fetching setup.bz2 --- apt-cyg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apt-cyg b/apt-cyg index f713d37..d942fba 100644 --- a/apt-cyg +++ b/apt-cyg @@ -119,7 +119,7 @@ function getsetup() mv setup setup.ini echo Updated setup.ini else - wget -N $mirror/setup.ini + wget -N $mirror/$arch/setup.ini if test -e setup.ini && test $? -eq 0 then echo Updated setup.ini From d0bb8af694beacab519a2d4ea8b5fba26c95ef3d Mon Sep 17 00:00:00 2001 From: sieste31 Date: Fri, 27 Sep 2013 01:41:11 +0900 Subject: [PATCH 007/309] deal with *.tar.gz package --- apt-cyg | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) mode change 100644 => 100755 apt-cyg diff --git a/apt-cyg b/apt-cyg old mode 100644 new mode 100755 index 59e9522..a92f519 --- a/apt-cyg +++ b/apt-cyg @@ -358,7 +358,11 @@ case "$command" in fi echo "Unpacking..." - cat $file | bunzip2 | tar > "/etc/setup/$pkg.lst" xvf - -C / + case "$file" in + *.tar.bz2) cat $file | bunzip2 | tar > "/etc/setup/$pkg.lst" xvf - -C / ;; + *.tar.xz) cat $file | xz -dv | tar > "/etc/setup/$pkg.lst" xvf - -C / ;; + *) echo Unknown extension, exiting : $file; exit 1 ;; + esac gzip -f "/etc/setup/$pkg.lst" cd ../.. From 921e994b986b050ca68f86cf23fdc4bfc603ced6 Mon Sep 17 00:00:00 2001 From: kou1ikada Date: Fri, 18 Oct 2013 22:55:52 +0900 Subject: [PATCH 008/309] multi-architecture support for cache directory --- apt-cyg | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apt-cyg b/apt-cyg index 7686264..7a0e8e9 100755 --- a/apt-cyg +++ b/apt-cyg @@ -97,8 +97,8 @@ function findworkspace() echo Working directory is $cache echo Mirror is $mirror - mkdir -p "$cache/$mirrordir" - cd "$cache/$mirrordir" + mkdir -p "$cache/$mirrordir/$arch" + cd "$cache/$mirrordir/$arch" } From f3b59ea2d9cb496040bb9247bcdb08da91637569 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Thu, 24 Oct 2013 18:43:08 +0900 Subject: [PATCH 009/309] The shebang line should be written using env command. --- apt-cyg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apt-cyg b/apt-cyg index 7a0e8e9..3c4c5bf 100755 --- a/apt-cyg +++ b/apt-cyg @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # apt-cyg: install tool for cygwin similar to debian apt-get From 70f16f90d8fe5ff0c32f3482c5a11be56e0fd5a1 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Thu, 24 Oct 2013 18:55:58 +0900 Subject: [PATCH 010/309] Deletion of unnecessary confirmation about the installation state of the bzip2 package. --- apt-cyg | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/apt-cyg b/apt-cyg index 3c4c5bf..2fbe2a1 100755 --- a/apt-cyg +++ b/apt-cyg @@ -28,13 +28,10 @@ # this script requires some packages WGET=`which wget 2> /dev/null` -BZIP2=`which bzip2 2> /dev/null` TAR=`which tar 2> /dev/null` GAWK=`which awk 2> /dev/null` -if test "-$WGET-" = "--" || test "-$BZIP2-" = "--" || test "-$TAR-" = "--" \ - || test "-$GAWK-" = "--" -then - echo You must install wget, tar, gawk and bzip2 to use apt-cyg. +if [ "$WGET" = "" -a "$TAR" = "" -a "$GAWK" = "" ]; then + echo You must install wget, tar and gawk to use apt-cyg. exit 1 fi From 38fd18b73d7177f7177ba69c5933e12f4f2d52d9 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Fri, 25 Oct 2013 18:38:47 +0900 Subject: [PATCH 011/309] True multiarch support with chroot --- apt-cyg | 50 +++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 45 insertions(+), 5 deletions(-) diff --git a/apt-cyg b/apt-cyg index 2fbe2a1..30ef0a4 100755 --- a/apt-cyg +++ b/apt-cyg @@ -47,6 +47,7 @@ function usage() echo " \"apt-cyg describe \" to describe packages matching patterns" echo " \"apt-cyg packageof \" to locate parent packages" echo "Options:" + echo " --charch : change archetecture (must appear first)" echo " --mirror, -m : set mirror" echo " --cache, -c : set cache" echo " --file, -f : read package names from file" @@ -65,17 +66,17 @@ function version() echo "Copyright (c) 2005-9 Stephen Jungels. Released under the GPL." } +function current_cygarch () +{ + arch | sed -e 's/^i686$/x86/g' +} function findworkspace() { # default working directory, mirror and architecture mirror=ftp://mirror.mcs.anl.gov/pub/cygwin - arch=x86 - if test `arch` == "x86_64" - then - arch=x86_64 - fi + arch=`current_cygarch` cache=/setup # work wherever setup worked last, if possible @@ -134,6 +135,35 @@ function checkpackages() fi } +# Usage: getrootdir arch +function getrootdir () +{ + case "$1" in + x86) + cygpath -u "$(cat /proc/registry32/HKEY_LOCAL_MACHINE/SOFTWARE/Cygwin/setup/rootdir)" ;; + x86_64) + cygpath -u "$(cat /proc/registry64/HKEY_LOCAL_MACHINE/SOFTWARE/Cygwin/setup/rootdir)" ;; + *) + echo "Error: unknown arch $1" >&2 ;; + esac +} + +# Usage: charch arch apt-cyg_parms ... +function charch () +{ + local rootdir + if [ "`current_cygarch`" != "$1" ]; then + echo -e "\e[32;1mcharch to:\e[30;0m $1" + rootdir="`getrootdir "$1"`" + shift + chroot "$rootdir" "$rootdir/bin/bash" -lc \ + 'cd "$1"; shift ; "$0" "$@"' \ + "$(which "$0" | xargs cygpath -aml | xargs cygpath -u)" \ + "$(cygpath -aml "`pwd`" | xargs cygpath -u)" \ + "$@" + exit $? + fi +} # process options @@ -144,11 +174,21 @@ dofile=0 command="" filepackages="" packages="" +nargs=$# while test $# -gt 0 do case "$1" in + --charch) + if [ "$#" -lt "$nargs" ]; then + echo "Error: $1 $2 option must appear first." >&2 + exit 1 + fi + charch "$2" "$@" + shift ; shift + ;; + --mirror|-m) echo "$2" > /etc/setup/last-mirror shift ; shift From 753086fee7250a642cf2d97c6a51be3febaff6b0 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Fri, 25 Oct 2013 20:07:00 +0900 Subject: [PATCH 012/309] Documentation of the multi-architecture support. --- README.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/README.md b/README.md index 6e96d5a..9a4250d 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,18 @@ Then use apt-cyg, for example: # apt-cyg install nano +True multi-architecture support +------------ + +Let think a case that you want to install the x86 package when you are working under the x86_64 environment. +In this case, You must only append a --charch option to the first parameter of apt-cyg. +For example: + + # apt-cyg --charch x86 install lv + +Remarks: +Of course, you must install both environments of x86_64 and x86, beforehand. + Contributing ------------ From 55fc57f4393de903bac0f12fd431daf7a04b008c Mon Sep 17 00:00:00 2001 From: kou1okada Date: Sat, 26 Oct 2013 13:40:48 +0900 Subject: [PATCH 013/309] More appropriate example for multiarch. --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 9a4250d..f977bba 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,9 @@ Let think a case that you want to install the x86 package when you are working u In this case, You must only append a --charch option to the first parameter of apt-cyg. For example: - # apt-cyg --charch x86 install lv + # apt-cyg --charch x86 install chere + +As of 2013-10-26, chere package is provided for only the repository for x86. Remarks: Of course, you must install both environments of x86_64 and x86, beforehand. From 177594d8e5fcf141fdb839a71593652c7ff141bb Mon Sep 17 00:00:00 2001 From: kou1okada Date: Tue, 29 Oct 2013 16:24:15 +0900 Subject: [PATCH 014/309] Simplification of the routine to extract required packages. Previous code didn't remove "/tmp/awk.$$" file. --- apt-cyg | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/apt-cyg b/apt-cyg index 30ef0a4..3baaeca 100755 --- a/apt-cyg +++ b/apt-cyg @@ -420,8 +420,7 @@ case "$command" in # recursively install required packages - echo > /tmp/awk.$$ '/^requires: / {s=gensub("(requires: )?([^ ]+) ?", "\\2 ", "g", $0); print s}' - requires=`cat "release/$pkg/desc" | awk -f /tmp/awk.$$` + requires=`grep "^requires: " "release/$pkg/desc" | sed -re 's/^requires: *(.*[^ ]) */\1/g' -e 's/ +/ /g'` warn=0 if ! test "-$requires-" = "--" From debc14cb0d39d81dddd42018d2fb570fced6059a Mon Sep 17 00:00:00 2001 From: kou1okada Date: Tue, 29 Oct 2013 21:18:32 +0900 Subject: [PATCH 015/309] Unification of the style for parameters of chroot command. --- apt-cyg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apt-cyg b/apt-cyg index 3baaeca..86923f3 100755 --- a/apt-cyg +++ b/apt-cyg @@ -159,7 +159,7 @@ function charch () chroot "$rootdir" "$rootdir/bin/bash" -lc \ 'cd "$1"; shift ; "$0" "$@"' \ "$(which "$0" | xargs cygpath -aml | xargs cygpath -u)" \ - "$(cygpath -aml "`pwd`" | xargs cygpath -u)" \ + "$(pwd | xargs cygpath -aml | xargs cygpath -u)" \ "$@" exit $? fi From 2d5a2ddaa9c64d896ac1cc430eeddb9f360a9acb Mon Sep 17 00:00:00 2001 From: kou1okada Date: Tue, 29 Oct 2013 21:53:39 +0900 Subject: [PATCH 016/309] Add "--use-setuprc" option --- apt-cyg | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/apt-cyg b/apt-cyg index 86923f3..798b96f 100755 --- a/apt-cyg +++ b/apt-cyg @@ -48,6 +48,7 @@ function usage() echo " \"apt-cyg packageof \" to locate parent packages" echo "Options:" echo " --charch : change archetecture (must appear first)" + echo " --use-setuprc : set cache and mirror with /etc/setup/setup.rc" echo " --mirror, -m : set mirror" echo " --cache, -c : set cache" echo " --file, -f : read package names from file" @@ -189,6 +190,12 @@ do shift ; shift ;; + --use-setuprc) + apt-cyg -c "$(grep -A1 last-cache /etc/setup/setup.rc | tail -n1 | sed -r 's/^\s*|\s*$//g')" > /dev/null + apt-cyg -m "$(grep -A1 last-mirror /etc/setup/setup.rc | tail -n1 | sed -r 's/^\s*|\s*$//g')" > /dev/null + shift + ;; + --mirror|-m) echo "$2" > /etc/setup/last-mirror shift ; shift From e6a38dcf0f10fc1ecbfdbafc87ec8a94ff3b7808 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Fri, 1 Nov 2013 20:33:04 +0900 Subject: [PATCH 017/309] Add "--ignore-case" option for --- apt-cyg | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/apt-cyg b/apt-cyg index 798b96f..fac2107 100755 --- a/apt-cyg +++ b/apt-cyg @@ -49,6 +49,7 @@ function usage() echo "Options:" echo " --charch : change archetecture (must appear first)" echo " --use-setuprc : set cache and mirror with /etc/setup/setup.rc" + echo " --ignore-case,-i : ignore case distinctions for " echo " --mirror, -m : set mirror" echo " --cache, -c : set cache" echo " --file, -f : read package names from file" @@ -175,6 +176,7 @@ dofile=0 command="" filepackages="" packages="" +ignore_case="" nargs=$# while test $# -gt 0 @@ -196,6 +198,11 @@ do shift ;; + --ignore-case|-i) + ignore_case="$1" + shift + ;; + --mirror|-m) echo "$2" > /etc/setup/last-mirror shift ; shift @@ -299,10 +306,10 @@ case "$command" in do echo "" echo Searching for installed packages matching $pkg: - awk '/[^ ]+ [^ ]+ 0/ {if ($1 ~ query) print $1}' query="$pkg" /etc/setup/installed.db + awk '/[^ ]+ [^ ]+ 0/ {if ($1 ~ query) print $1}' query="$pkg" IGNORECASE="$ignore_case" /etc/setup/installed.db echo "" echo Searching for installable packages matching $pkg: - cat setup.ini | awk -v query="$pkg" \ + cat setup.ini | awk -v query="$pkg" -v IGNORECASE="$ignore_case" \ 'BEGIN{RS="\n\n@ "; FS="\n"; ORS="\n"} {if ($1 ~ query) {print $1}}' done @@ -317,7 +324,7 @@ case "$command" in for pkg in $packages do echo "" - cat setup.ini | awk -v query="$pkg" \ + cat setup.ini | awk -v query="$pkg" -v IGNORECASE="$ignore_case" \ 'BEGIN{RS="\n\n@ "; FS="\n"; ORS="\n"} {if ($1 ~ query) {print $0 "\n"}}' done From 5d918c0f67095a668e94e6dba2a893cb76bbf431 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Mon, 4 Nov 2013 03:29:58 +0900 Subject: [PATCH 018/309] Add "--force-remove" option." --- apt-cyg | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/apt-cyg b/apt-cyg index fac2107..7778cf0 100755 --- a/apt-cyg +++ b/apt-cyg @@ -50,6 +50,7 @@ function usage() echo " --charch : change archetecture (must appear first)" echo " --use-setuprc : set cache and mirror with /etc/setup/setup.rc" echo " --ignore-case,-i : ignore case distinctions for " + echo " --force-remove : force remove" echo " --mirror, -m : set mirror" echo " --cache, -c : set cache" echo " --file, -f : read package names from file" @@ -177,6 +178,7 @@ command="" filepackages="" packages="" ignore_case="" +force_remove="" nargs=$# while test $# -gt 0 @@ -203,6 +205,11 @@ do shift ;; + --force-remove) + force_remove=1 + shift + ;; + --mirror|-m) echo "$2" > /etc/setup/last-mirror shift ; shift @@ -501,7 +508,7 @@ case "$command" in fi done - if ! test -e "/etc/setup/$pkg.lst.gz" + if test ! -e "/etc/setup/$pkg.lst.gz" -a "$force_remove" = "" then echo Package manifest missing, cannot remove $pkg. Exiting exit 1 From 99f7a36d866691155bce98dbd72a343320c0f16e Mon Sep 17 00:00:00 2001 From: kou1okada Date: Mon, 4 Nov 2013 11:59:58 +0900 Subject: [PATCH 019/309] Reliability improvement in the remove subcommand. --- apt-cyg | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/apt-cyg b/apt-cyg index 7778cf0..22bdee3 100755 --- a/apt-cyg +++ b/apt-cyg @@ -520,13 +520,11 @@ case "$command" in if test -e "/etc/preremove/$pkg.sh" then "/etc/preremove/$pkg.sh" - rm "/etc/preremove/$pkg.sh" fi cat "/etc/setup/$pkg.lst.gz" | gzip -d | awk '/[^\/]$/ {print "rm -f \"/" $0 "\""}' | sh - rm "/etc/setup/$pkg.lst.gz" - rm -f /etc/postinstall/$pkg.sh.done cat /etc/setup/installed.db | awk > /tmp/awk.$$ -v pkg="$pkg" '{if (pkg != $1) print $0}' + rm -f "/etc/postinstall/$pkg.sh.done" "/etc/preremove/$pkg.sh" "/etc/setup/$pkg.lst.gz" mv /etc/setup/installed.db /etc/setup/installed.db-save mv /tmp/awk.$$ /etc/setup/installed.db echo Package $pkg removed From cbee1675c01c4102899be1d9444719a9a4ce30c4 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Tue, 5 Nov 2013 11:17:03 +0900 Subject: [PATCH 020/309] Update README.md Added links to useful forks. --- README.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/README.md b/README.md index f977bba..4ad0834 100644 --- a/README.md +++ b/README.md @@ -44,3 +44,19 @@ Contributing This project has been re-published on GitHub to make contributing easier. Feel free to fork and modify this script. The [Google Code project](https://code.google.com/p/apt-cyg/) has a list of open issues. + +### Forks on the github + +Caution: +Please do not merge forks that have incompatible licenses. + +Ex.) Merging to the GPL from the MIT is possible. But merging to the MIT from the GPL is impossible. + +#### Official + +* [transcodes-open / apt-cyg](https://github.com/transcode-open/apt-cyg/network) (MIT license) + +#### Unofficial + +* [cfg / apt-cyg](https://github.com/cfg/apt-cyg/network) (GPLv2) +* [ashumkin / apt-cyg](https://github.com/ashumkin/apt-cyg/network) (GPLv2) From 70786c03048a357992c8baae253397e498b19cda Mon Sep 17 00:00:00 2001 From: kou1okada Date: Thu, 7 Nov 2013 19:12:35 +0900 Subject: [PATCH 021/309] Update README.md --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index 4ad0834..8db439d 100644 --- a/README.md +++ b/README.md @@ -60,3 +60,11 @@ Ex.) Merging to the GPL from the MIT is possible. But merging to the MIT from th * [cfg / apt-cyg](https://github.com/cfg/apt-cyg/network) (GPLv2) * [ashumkin / apt-cyg](https://github.com/ashumkin/apt-cyg/network) (GPLv2) + +Known Problem +------------ +### Check setup (cygcheck -c) can not detect .tar.xz packages +At cygwin 1.7.25, cygcheck is hardcoded for .tar.gz and .tar.bz2. +So check setup (cygcheck -c) can not detect .tar.xz packages. +This bug was already fixed with [src/winsup/utils/dump_setup.cc#rev1.28](http://cygwin.com/cgi-bin/cvsweb.cgi/src/winsup/utils/dump_setup.cc?cvsroot=src#rev1.28). +Please wait a release of cygwin 1.7.26. From b0ce6a6fad7d2ce27725cd38a601738fe5863fef Mon Sep 17 00:00:00 2001 From: JuanPablo Date: Tue, 12 Nov 2013 15:28:29 -0300 Subject: [PATCH 022/309] option -4 : wget prefer ipv4 --- apt-cyg | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/apt-cyg b/apt-cyg index 22bdee3..4ef5f3a 100755 --- a/apt-cyg +++ b/apt-cyg @@ -35,6 +35,7 @@ if [ "$WGET" = "" -a "$TAR" = "" -a "$GAWK" = "" ]; then exit 1 fi +WGET=wget function usage() { @@ -109,14 +110,14 @@ function getsetup() then touch setup.ini mv setup.ini setup.ini-save - wget -N $mirror/$arch/setup.bz2 + $WGET -N $mirror/$arch/setup.bz2 if test -e setup.bz2 && test $? -eq 0 then bunzip2 setup.bz2 mv setup setup.ini echo Updated setup.ini else - wget -N $mirror/$arch/setup.ini + $WGET -N $mirror/$arch/setup.ini if test -e setup.ini && test $? -eq 0 then echo Updated setup.ini @@ -230,6 +231,11 @@ do shift ;; + --ipv4|-4) + WGET="$WGET --prefer-family=IPv4" + shift + ;; + --help) usage exit 0 @@ -409,7 +415,7 @@ case "$command" in file=`basename $install` cd "release/$pkg" - wget -nc $mirror/$install + $WGET -nc $mirror/$install # check the md5 digest=`cat "desc" | awk '/^install: / { print $4; exit }'` From e02f27b8991472882eb7f5d8afaec174a877e154 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Wed, 13 Nov 2013 15:08:16 +0900 Subject: [PATCH 023/309] Reliability improvements for parameter expansion. --- apt-cyg | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/apt-cyg b/apt-cyg index 4ef5f3a..141c0ee 100755 --- a/apt-cyg +++ b/apt-cyg @@ -27,16 +27,14 @@ # this script requires some packages -WGET=`which wget 2> /dev/null` -TAR=`which tar 2> /dev/null` -GAWK=`which awk 2> /dev/null` +WGET="`which wget 2> /dev/null`" +TAR="`which tar 2> /dev/null`" +GAWK="`which awk 2> /dev/null`" if [ "$WGET" = "" -a "$TAR" = "" -a "$GAWK" = "" ]; then echo You must install wget, tar and gawk to use apt-cyg. exit 1 fi -WGET=wget - function usage() { echo apt-cyg: Installs and removes Cygwin packages. @@ -110,14 +108,14 @@ function getsetup() then touch setup.ini mv setup.ini setup.ini-save - $WGET -N $mirror/$arch/setup.bz2 + "${WGET[@]}" -N $mirror/$arch/setup.bz2 if test -e setup.bz2 && test $? -eq 0 then bunzip2 setup.bz2 mv setup setup.ini echo Updated setup.ini else - $WGET -N $mirror/$arch/setup.ini + "${WGET[@]}" -N $mirror/$arch/setup.ini if test -e setup.ini && test $? -eq 0 then echo Updated setup.ini @@ -232,7 +230,7 @@ do ;; --ipv4|-4) - WGET="$WGET --prefer-family=IPv4" + WGET=( "${WGET[@]}" "--prefer-family=IPv4" ) shift ;; @@ -415,7 +413,7 @@ case "$command" in file=`basename $install` cd "release/$pkg" - $WGET -nc $mirror/$install + "${WGET[@]}" -nc $mirror/$install # check the md5 digest=`cat "desc" | awk '/^install: / { print $4; exit }'` From 4471ab7a4a0d3bf4b5033455781e66f0ad15b930 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Wed, 13 Nov 2013 15:13:34 +0900 Subject: [PATCH 024/309] Add help for --ipv4, -4 option --- apt-cyg | 1 + 1 file changed, 1 insertion(+) diff --git a/apt-cyg b/apt-cyg index 141c0ee..7503831 100755 --- a/apt-cyg +++ b/apt-cyg @@ -54,6 +54,7 @@ function usage() echo " --cache, -c : set cache" echo " --file, -f : read package names from file" echo " --noupdate, -u : don't update setup.ini from mirror" + echo " --ipv4, -4 : wget prefer ipv4" echo " --help" echo " --version" } From 399eb84f89d9733564a9e24bd5c14aaa9abc142b Mon Sep 17 00:00:00 2001 From: James Booth Date: Wed, 20 Nov 2013 22:06:50 +0000 Subject: [PATCH 025/309] Added .xz archive support --- apt-cyg | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/apt-cyg b/apt-cyg index 3b63ef2..f04909b 100644 --- a/apt-cyg +++ b/apt-cyg @@ -29,12 +29,13 @@ WGET=`which wget 2> /dev/null` BZIP2=`which bzip2 2> /dev/null` +XZ=`which xz 2> /dev/null` TAR=`which tar 2> /dev/null` GAWK=`which awk 2> /dev/null` if test "-$WGET-" = "--" || test "-$BZIP2-" = "--" || test "-$TAR-" = "--" \ - || test "-$GAWK-" = "--" + || test "-$GAWK-" = "--" || test "-$XZ-" = "--" then - echo You must install wget, tar, gawk and bzip2 to use apt-cyg. + echo You must install wget, tar, gawk, xz and bzip2 to use apt-cyg. exit 1 fi @@ -363,7 +364,14 @@ case "$command" in fi echo "Unpacking..." - cat $file | bunzip2 | tar > "/etc/setup/$pkg.lst" xvf - -C / + + if test "-${file##*.}-" = "-xz-" + then + cat $file | xz -d | tar > "/etc/setup/$pkg.lst" xvf - -C / + else + cat $file | bunzip2 | tar > "/etc/setup/$pkg.lst" xvf - -C / + fi + gzip -f "/etc/setup/$pkg.lst" cd ../.. @@ -437,7 +445,7 @@ case "$command" in continue fi - dontremove="cygwin coreutils gawk bzip2 tar wget bash" + dontremove="cygwin coreutils gawk bzip2 tar xz wget bash" for req in $dontremove do if test "-$pkg-" = "-$req-" From 3d67e120607a94e887ce1f225b95fa1b2b68aedf Mon Sep 17 00:00:00 2001 From: Jack Zhou Date: Thu, 28 Nov 2013 23:16:21 -0800 Subject: [PATCH 026/309] Fixed .tar.xz (e.g. curl) packages not working. --- apt-cyg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apt-cyg b/apt-cyg index d942fba..9f6618e 100644 --- a/apt-cyg +++ b/apt-cyg @@ -367,7 +367,7 @@ case "$command" in fi echo "Unpacking..." - cat $file | bunzip2 | tar > "/etc/setup/$pkg.lst" xvf - -C / + tar > "/etc/setup/$pkg.lst" xvf "$file" -C / gzip -f "/etc/setup/$pkg.lst" cd ../.. From 7e96f0e66231b30b5dcc6a87b1799a79a1014501 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Mon, 2 Dec 2013 00:20:59 +0900 Subject: [PATCH 027/309] Bugfix: logic of requirements check. --- apt-cyg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apt-cyg b/apt-cyg index d4524ac..122c320 100755 --- a/apt-cyg +++ b/apt-cyg @@ -30,7 +30,7 @@ WGET="`which wget 2> /dev/null`" TAR="`which tar 2> /dev/null`" GAWK="`which awk 2> /dev/null`" -if [ "$WGET" = "" -a "$TAR" = "" -a "$GAWK" = "" ]; then +if [ "$WGET" = "" -o "$TAR" = "" -o "$GAWK" = "" ]; then echo You must install wget, tar and gawk to use apt-cyg. exit 1 fi From 16411040365c1bb6efdf036a4b6bfc55d98eafdb Mon Sep 17 00:00:00 2001 From: kou1ikada Date: Thu, 5 Dec 2013 15:45:22 +0900 Subject: [PATCH 028/309] Bugfix: "--use-setuprc" option couldn't call apt-cyg if path isn't set. --- apt-cyg | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apt-cyg b/apt-cyg index 124aec3..fe4f84d 100755 --- a/apt-cyg +++ b/apt-cyg @@ -195,8 +195,8 @@ do ;; --use-setuprc) - apt-cyg -c "$(grep -A1 last-cache /etc/setup/setup.rc | tail -n1 | sed -r 's/^\s*|\s*$//g')" > /dev/null - apt-cyg -m "$(grep -A1 last-mirror /etc/setup/setup.rc | tail -n1 | sed -r 's/^\s*|\s*$//g')" > /dev/null + "$0" -c "$(grep -A1 last-cache /etc/setup/setup.rc | tail -n1 | sed -r 's/^\s*|\s*$//g')" > /dev/null + "$0" -m "$(grep -A1 last-mirror /etc/setup/setup.rc | tail -n1 | sed -r 's/^\s*|\s*$//g')" > /dev/null shift ;; From 4d1f726c4f4b2f5c2d4145df794d851de4547d44 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Thu, 19 Dec 2013 15:31:40 +0900 Subject: [PATCH 029/309] Verify setup.ini signatures by GnuPG. --- apt-cyg | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 68 insertions(+), 6 deletions(-) diff --git a/apt-cyg b/apt-cyg index fe4f84d..1bbae1f 100755 --- a/apt-cyg +++ b/apt-cyg @@ -25,11 +25,21 @@ # THE SOFTWARE. # +# ./cygwin.pub +# ------------ +# pub 1024D/676041BA 2008-06-13 +# uid Cygwin +# sub 1024g/A1DB7B5C 2008-06-13 +CYGWIN_PKEY_URL_LATEST="https://sourceware.org/cgi-bin/cvsweb.cgi/~checkout~/setup/cygwin.pub?cvsroot=cygwin-apps" +CYGWIN_PKEY_URL="https://sourceware.org/cgi-bin/cvsweb.cgi/~checkout~/setup/cygwin.pub?rev=2.1&cvsroot=cygwin-apps" +CYGWIN_PKEY_MD5="8fe5366fc82289578ab9b6e3c9f1bff9" + # this script requires some packages WGET="`which wget 2> /dev/null`" TAR="`which tar 2> /dev/null`" GAWK="`which awk 2> /dev/null`" +GPGV="`which gpgv 2> /dev/null`" if [ "$WGET" = "" -o "$TAR" = "" -o "$GAWK" = "" ]; then echo You must install wget, tar and gawk to use apt-cyg. exit 1 @@ -50,6 +60,8 @@ function usage() echo " --use-setuprc : set cache and mirror with /etc/setup/setup.rc" echo " --ignore-case,-i : ignore case distinctions for " echo " --force-remove : force remove" + echo " --force-update-pkey: force update public key of cygwin" + echo " --no-verify, -X : Don't verify setup.ini signatures" echo " --mirror, -m : set mirror" echo " --cache, -c : set cache" echo " --file, -f : read package names from file" @@ -100,6 +112,8 @@ function findworkspace() echo Mirror is $mirror mkdir -p "$cache/$mirrordir/$arch" cd "$cache/$mirrordir/$arch" + + update_cygwin_pkey } @@ -109,16 +123,16 @@ function getsetup() then touch setup.ini mv setup.ini setup.ini-save - "${WGET[@]}" -N $mirror/$arch/setup.bz2 - if test -e setup.bz2 && test $? -eq 0 - then + "${WGET[@]}" -N "$mirror/$arch/setup.bz2" "$mirror/$arch/setup.bz2.sig" + if [[ -e setup.bz2 && -e setup.bz2.sig && $? -eq 0 ]]; then + [[ "$no_verify" == "" ]] && verify_signatures setup.bz2.sig bunzip2 setup.bz2 mv setup setup.ini echo Updated setup.ini else - "${WGET[@]}" -N $mirror/$arch/setup.ini - if test -e setup.ini && test $? -eq 0 - then + "${WGET[@]}" -N "$mirror/$arch/setup.ini" "$mirror/$arch/setup.ini.sig" + if [[ -e setup.ini && -e setup.ini.sig && $? -eq 0 ]]; then + [[ "$no_verify" == "" ]] && verify_signatures setup.ini.sig echo Updated setup.ini else mv setup.ini-save setup.ini @@ -168,6 +182,38 @@ function charch () fi } +function update_cygwin_pkey () +{ + pkey_latest="$cache/cygwin_latest.pub" + pkey="$cache/cygwin.pub" + [[ "$force_update_pkey" != "" || ! -e "$pkey_latest" ]] && "${WGET[@]}" "$CYGWIN_PKEY_URL_LATEST" -O "$pkey_latest" + [[ "$force_update_pkey" != "" || ! -e "$pkey" ]] && "${WGET[@]}" "$CYGWIN_PKEY_URL" -O "$pkey" + check_cygwin_pkey +} + +function check_cygwin_pkey () +{ + if ! echo "$CYGWIN_PKEY_MD5 *$pkey" | md5sum -c; then + echo "Warning: Maybe CSV repository of cygwin has been cracked !!!" + exit 1 + fi + if ! echo "$CYGWIN_PKEY_MD5 *$pkey_latest" | md5sum -c; then + echo "Warning: Maybe public key of cygwin has been updated." + fi +} + +# Usage: verify_signatures files ... +function verify_signatures () +{ + while [[ $# -gt 0 ]]; do + if ! "$GPGV" --keyring "$pkey" "$1"; then + echo "Error: BAD signature: $1" + exit 1 + fi + shift + done +} + # process options noscripts=0 @@ -179,6 +225,8 @@ filepackages="" packages="" ignore_case="" force_remove="" +force_update_pkey="" +no_verify="" nargs=$# while test $# -gt 0 @@ -210,6 +258,16 @@ do shift ;; + --force-update-pkey) + force_update_pkey=1 + shift + ;; + + --no-verify|-X) + no_verify=1 + shift + ;; + --mirror|-m) echo "$2" > /etc/setup/last-mirror shift ; shift @@ -277,6 +335,10 @@ do esac done +if [[ "$GPGV" == "" && "$no_verify" == "" ]]; then + echo "Error: GnuPG is not installed. Prease install gnupg package or use -X option." + exit 1 +fi if test $dofile = 1 then From 20dcd3ab68db25732ce90ad190d56365ceedf248 Mon Sep 17 00:00:00 2001 From: Jon Date: Fri, 20 Dec 2013 04:55:24 -0800 Subject: [PATCH 030/309] added cygwinports to Verify setup.ini signatures by GnuPG, setup_release_name func to setup key urls and md5 --- apt-cyg | 37 ++++++++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/apt-cyg b/apt-cyg index 1bbae1f..1b7a4ba 100755 --- a/apt-cyg +++ b/apt-cyg @@ -34,6 +34,8 @@ CYGWIN_PKEY_URL_LATEST="https://sourceware.org/cgi-bin/cvsweb.cgi/~checkout~/set CYGWIN_PKEY_URL="https://sourceware.org/cgi-bin/cvsweb.cgi/~checkout~/setup/cygwin.pub?rev=2.1&cvsroot=cygwin-apps" CYGWIN_PKEY_MD5="8fe5366fc82289578ab9b6e3c9f1bff9" +CYGWINPORTS_PKEY_URL="http://cygwinports.org/ports.gpg" +CYGWINPORTS_PKEY_MD5="4c7904807340411f48f7519173cd600d" # this script requires some packages WGET="`which wget 2> /dev/null`" @@ -116,7 +118,6 @@ function findworkspace() update_cygwin_pkey } - function getsetup() { if test "$noscripts" == "0" -a "$noupdate" == "0" @@ -142,6 +143,29 @@ function getsetup() fi } +setup_release_name() +{ + release_name="`cat setup.ini | awk '/release:/ {print $2}'`" + case "$release_name" in + cygwin) + PKEY_URL_LATEST="$CYGWIN_PKEY_URL_LATEST" + PKEY_URL="$CYGWIN_PKEY_URL" + PKEY_MD5="$CYGWIN_PKEY_MD5" + pkey_latest="$cache/cygwin_latest.pub" + pkey="$cache/cygwin.pub" + ;; + cygwinports) + PKEY_URL_LATEST="$CYGWINPORTS_PKEY_URL" + PKEY_URL="$CYGWINPORTS_PKEY_URL" + PKEY_MD5="$CYGWINPORTS_PKEY_MD5" + pkey_latest="$cache/ports.gpg" + pkey="$cache/ports.gpg" + ;; + *) + echo "Error: unknown release name $release_name" + exit 1 + esac +} function checkpackages() { @@ -184,20 +208,19 @@ function charch () function update_cygwin_pkey () { - pkey_latest="$cache/cygwin_latest.pub" - pkey="$cache/cygwin.pub" - [[ "$force_update_pkey" != "" || ! -e "$pkey_latest" ]] && "${WGET[@]}" "$CYGWIN_PKEY_URL_LATEST" -O "$pkey_latest" - [[ "$force_update_pkey" != "" || ! -e "$pkey" ]] && "${WGET[@]}" "$CYGWIN_PKEY_URL" -O "$pkey" + setup_release_name + [[ "$force_update_pkey" != "" || ! -e "$pkey_latest" ]] && "${WGET[@]}" "$PKEY_URL_LATEST" -O "$pkey_latest" + [[ "$force_update_pkey" != "" || ! -e "$pkey" ]] && "${WGET[@]}" "$PKEY_URL" -O "$pkey" check_cygwin_pkey } function check_cygwin_pkey () { - if ! echo "$CYGWIN_PKEY_MD5 *$pkey" | md5sum -c; then + if ! echo "$PKEY_MD5 *$pkey" | md5sum -c; then echo "Warning: Maybe CSV repository of cygwin has been cracked !!!" exit 1 fi - if ! echo "$CYGWIN_PKEY_MD5 *$pkey_latest" | md5sum -c; then + if ! echo "$PKEY_MD5 *$pkey_latest" | md5sum -c; then echo "Warning: Maybe public key of cygwin has been updated." fi } From d141d8078e77c00ebcf694751027b58c043de5d6 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Mon, 23 Dec 2013 06:05:47 +0900 Subject: [PATCH 031/309] Manage public keys, Call subcommand as function. --- apt-cyg | 218 ++++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 158 insertions(+), 60 deletions(-) diff --git a/apt-cyg b/apt-cyg index 1b7a4ba..2dd2c32 100755 --- a/apt-cyg +++ b/apt-cyg @@ -25,23 +25,32 @@ # THE SOFTWARE. # +TRUSTEDKEYS=( CYGWIN CYGWINPORTS ); # ./cygwin.pub # ------------ # pub 1024D/676041BA 2008-06-13 # uid Cygwin # sub 1024g/A1DB7B5C 2008-06-13 -CYGWIN_PKEY_URL_LATEST="https://sourceware.org/cgi-bin/cvsweb.cgi/~checkout~/setup/cygwin.pub?cvsroot=cygwin-apps" -CYGWIN_PKEY_URL="https://sourceware.org/cgi-bin/cvsweb.cgi/~checkout~/setup/cygwin.pub?rev=2.1&cvsroot=cygwin-apps" -CYGWIN_PKEY_MD5="8fe5366fc82289578ab9b6e3c9f1bff9" +TRUSTEDKEY_CYGWIN_MD5="8fe5366fc82289578ab9b6e3c9f1bff9" +TRUSTEDKEY_CYGWIN_FPR="1169DF9F22734F743AA59232A9A262FF676041BA" +TRUSTEDKEY_CYGWIN_URL="https://sourceware.org/cgi-bin/cvsweb.cgi/~checkout~/setup/cygwin.pub?rev=2.1&cvsroot=cygwin-apps" +TRUSTEDKEY_CYGWIN_URL_LATEST="https://sourceware.org/cgi-bin/cvsweb.cgi/~checkout~/setup/cygwin.pub?cvsroot=cygwin-apps" +# ./ports.gpg +# ----------- +# pub 1024D/66EE1F94 2008-10-27 +# uid Yaakov Selkowitz (Cygwin Ports) +# sub 4096g/7D66B0D2 2008-10-27 +TRUSTEDKEY_CYGWINPORTS_MD5="4c7904807340411f48f7519173cd600d" +TRUSTEDKEY_CYGWINPORTS_FPR="45600BB98CA878AA97A70119FF20AF9A66EE1F94" +TRUSTEDKEY_CYGWINPORTS_URL_LATEST="http://cygwinports.org/ports.gpg" -CYGWINPORTS_PKEY_URL="http://cygwinports.org/ports.gpg" -CYGWINPORTS_PKEY_MD5="4c7904807340411f48f7519173cd600d" # this script requires some packages WGET="`which wget 2> /dev/null`" TAR="`which tar 2> /dev/null`" GAWK="`which awk 2> /dev/null`" GPGV="`which gpgv 2> /dev/null`" +GPG="`which gpg 2> /dev/null`" if [ "$WGET" = "" -o "$TAR" = "" -o "$GAWK" = "" ]; then echo You must install wget, tar and gawk to use apt-cyg. exit 1 @@ -57,18 +66,22 @@ function usage() echo " \"apt-cyg find \" to find packages matching patterns" echo " \"apt-cyg describe \" to describe packages matching patterns" echo " \"apt-cyg packageof \" to locate parent packages" + echo " \"apt-cyg key-add ...\" to add keys contained in " + echo " \"apt-cyg key-del ...\" to remove keys " + echo " \"apt-cyg key-list\" to list keys" + echo " \"apt-cyg key-finger\" to list fingerprints" echo "Options:" - echo " --charch : change archetecture (must appear first)" - echo " --use-setuprc : set cache and mirror with /etc/setup/setup.rc" - echo " --ignore-case,-i : ignore case distinctions for " - echo " --force-remove : force remove" - echo " --force-update-pkey: force update public key of cygwin" - echo " --no-verify, -X : Don't verify setup.ini signatures" - echo " --mirror, -m : set mirror" - echo " --cache, -c : set cache" - echo " --file, -f : read package names from file" - echo " --noupdate, -u : don't update setup.ini from mirror" - echo " --ipv4, -4 : wget prefer ipv4" + echo " --charch : change archetecture (must appear first)" + echo " --use-setuprc : set cache and mirror with /etc/setup/setup.rc" + echo " --ignore-case,-i : ignore case distinctions for " + echo " --force-remove : force remove" + echo " --force-fetch-trustedkeys: force fetch tristedkeys" + echo " --no-verify, -X : Don't verify setup.ini signatures" + echo " --mirror, -m : set mirror" + echo " --cache, -c : set cache" + echo " --file, -f : read package names from file" + echo " --noupdate, -u : don't update setup.ini from mirror" + echo " --ipv4, -4 : wget prefer ipv4" echo " --help" echo " --version" } @@ -115,7 +128,8 @@ function findworkspace() mkdir -p "$cache/$mirrordir/$arch" cd "$cache/$mirrordir/$arch" - update_cygwin_pkey + init_gnupg + fetch_trustedkeys } function getsetup() @@ -143,30 +157,6 @@ function getsetup() fi } -setup_release_name() -{ - release_name="`cat setup.ini | awk '/release:/ {print $2}'`" - case "$release_name" in - cygwin) - PKEY_URL_LATEST="$CYGWIN_PKEY_URL_LATEST" - PKEY_URL="$CYGWIN_PKEY_URL" - PKEY_MD5="$CYGWIN_PKEY_MD5" - pkey_latest="$cache/cygwin_latest.pub" - pkey="$cache/cygwin.pub" - ;; - cygwinports) - PKEY_URL_LATEST="$CYGWINPORTS_PKEY_URL" - PKEY_URL="$CYGWINPORTS_PKEY_URL" - PKEY_MD5="$CYGWINPORTS_PKEY_MD5" - pkey_latest="$cache/ports.gpg" - pkey="$cache/ports.gpg" - ;; - *) - echo "Error: unknown release name $release_name" - exit 1 - esac -} - function checkpackages() { if test "-$packages-" = "--" @@ -206,30 +196,102 @@ function charch () fi } -function update_cygwin_pkey () +function init_gnupg () { - setup_release_name - [[ "$force_update_pkey" != "" || ! -e "$pkey_latest" ]] && "${WGET[@]}" "$PKEY_URL_LATEST" -O "$pkey_latest" - [[ "$force_update_pkey" != "" || ! -e "$pkey" ]] && "${WGET[@]}" "$PKEY_URL" -O "$pkey" - check_cygwin_pkey + export GNUPGHOME="$cache/apt-cyg/.gnupg" + echo $GNUPGHOME + if ! [ -d "$GNUPGHOME" ]; then + mkdir -p "$GNUPGHOME" + chmod 700 "$GNUPGHOME" + fi + GPG_KEYRING=( --keyring pubring.gpg ) } -function check_cygwin_pkey () +# Usage: check_md5sum label hash url file +function wget_and_check_md5sum () { - if ! echo "$PKEY_MD5 *$pkey" | md5sum -c; then - echo "Warning: Maybe CSV repository of cygwin has been cracked !!!" - exit 1 + local LABEL="$1" + local MD5="$2" + local URL="$3" + local FILE="$4" + if ! "${WGET[@]}" "$URL" -O "$FILE"; then + echo "$LABEL: FAILED: Could not download $URL." + return 1 fi - if ! echo "$PKEY_MD5 *$pkey_latest" | md5sum -c; then - echo "Warning: Maybe public key of cygwin has been updated." + if ! echo "$MD5 *$FILE" | md5sum -c >& /dev/null; then + echo "$LABEL: FAILED: MD5 hash is not match." + return 2 fi + echo "$LABEL: OK" +} + +function fetch_trustedkeys () +{ + local FILE="$(mktemp)" + local FILE_LATEST="$(mktemp)" + for i in "${TRUSTEDKEYS[@]}"; do + local LABEL="TRUSTEDKEY_${i}" + local MD5="$(eval echo "\$${LABEL}_MD5")" + local FPR="$(eval echo "\$${LABEL}_FPR")" + local URL="$(eval echo "\$${LABEL}_URL")" + local URL_LATEST="$(eval echo "\$${LABEL}_URL_LATEST")" + local CASE="" + if [[ -z "$force_fetch_trustedkeys" ]] && "${GPG[@]}" --fingerprint --with-colons | grep -q "$FPR"; then + continue + fi + if [ -n "$URL" ]; then + wget_and_check_md5sum "$LABEL" "$MD5" "$URL" "$FILE" + CASE+="$?" + else + CASE+="-" + fi + if [ -n "$URL_LATEST" ]; then + wget_and_check_md5sum "$LABEL" "$MD5" "$URL_LATEST" "$FILE_LATEST" + CASE+="$?" + else + CASE+="-" + fi + case "$CASE" in + 00|01|0-) + "${GPG[@]}" --import "$FILE" + ;; + 02) + echo "Warning: ${LABEL} has been updated." + "${GPG[@]}" --import "$FILE" + ;; + -0) + "${GPG[@]}" --import "$FILE_LATEST" + ;; + 10|20) + echo "Error: ${LABEL} has miss configuration." + exit 1 + ;; + 11|1-|-1) + echo "Error: Could not download ${LABEL}." + exit 1 + ;; + 12|-2) + echo "Error: ${LABEL} has been updated, maybe. But sometimes it may has been cracked. Be careful !!!" + exit 1 + ;; + 21|22|2-) + echo "Error: ${LABEL} has been cracked, maybe" + exit 1 + ;; + --) + echo "Error: ${LABEL} has no URL." + exit 1 + ;; + esac + done + rm "$FILE" "$FILE_LATEST" } # Usage: verify_signatures files ... function verify_signatures () { while [[ $# -gt 0 ]]; do - if ! "$GPGV" --keyring "$pkey" "$1"; then + if ! "${GPGV[@]}" "${GPG_KEYRING[@]}" "$1"; then echo "Error: BAD signature: $1" exit 1 fi @@ -237,6 +299,40 @@ function verify_signatures () done } +# Usage: apt-cyg-key-add pkey ... +function apt-cyg-key-add () +{ + local pkeys + for pkey; do + pkeys+=( "$(cygpath -a "$pkey" )" ) + done + findworkspace + for pkey in "${pkeys[@]}"; do + "${GPG[@]}" --import "$pkey" + done +} + +# Usage: apt-cyg-key-add keyid ... +function apt-cyg-key-del () +{ + findworkspace + for keyid; do + "${GPG[@]}" --batch --yes --delete-key "$keyid" + done +} + +function apt-cyg-key-list () +{ + findworkspace + "${GPG[@]}" --list-keys +} + +function apt-cyg-key-finger () +{ + findworkspace + "${GPG[@]}" --fingerprint +} + # process options noscripts=0 @@ -248,7 +344,7 @@ filepackages="" packages="" ignore_case="" force_remove="" -force_update_pkey="" +force_fetch_trustedkeys="" no_verify="" nargs=$# @@ -281,8 +377,8 @@ do shift ;; - --force-update-pkey) - force_update_pkey=1 + --force-fetch-trustedkeys) + force_fetch_trustedkeys=1 shift ;; @@ -338,7 +434,7 @@ do shift ;; - update|show|find|describe|packageof|install|remove) + update|show|find|describe|packageof|install|remove|key-add|key-del|key-finger|key-list) if test "-$command-" = "--" then command=$1 @@ -620,9 +716,11 @@ case "$command" in ;; *) - - usage - + if type "apt-cyg-$command" >/dev/null; then + "apt-cyg-$command" $packages + else + usage + fi ;; esac From 38e725dbded1e2d02b84d4c1f31e50710e196742 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Mon, 23 Dec 2013 06:48:21 +0900 Subject: [PATCH 032/309] Check GnuPG installation at some functions. --- apt-cyg | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/apt-cyg b/apt-cyg index 2dd2c32..f99a73a 100755 --- a/apt-cyg +++ b/apt-cyg @@ -198,6 +198,7 @@ function charch () function init_gnupg () { + [ -z "$GPG" ] && return export GNUPGHOME="$cache/apt-cyg/.gnupg" echo $GNUPGHOME if ! [ -d "$GNUPGHOME" ]; then @@ -227,6 +228,7 @@ function wget_and_check_md5sum () function fetch_trustedkeys () { + [ -z "$GPG" ] && return local FILE="$(mktemp)" local FILE_LATEST="$(mktemp)" for i in "${TRUSTEDKEYS[@]}"; do @@ -302,6 +304,7 @@ function verify_signatures () # Usage: apt-cyg-key-add pkey ... function apt-cyg-key-add () { + [ -z "$GPG" ] && { echo "Error: GnuPG is not installed. Prease install gnupg package"; exit 1; } local pkeys for pkey; do pkeys+=( "$(cygpath -a "$pkey" )" ) @@ -315,6 +318,7 @@ function apt-cyg-key-add () # Usage: apt-cyg-key-add keyid ... function apt-cyg-key-del () { + [ -z "$GPG" ] && { echo "Error: GnuPG is not installed. Prease install gnupg package"; exit 1; } findworkspace for keyid; do "${GPG[@]}" --batch --yes --delete-key "$keyid" @@ -323,12 +327,14 @@ function apt-cyg-key-del () function apt-cyg-key-list () { + [ -z "$GPG" ] && { echo "Error: GnuPG is not installed. Prease install gnupg package"; exit 1; } findworkspace "${GPG[@]}" --list-keys } function apt-cyg-key-finger () { + [ -z "$GPG" ] && { echo "Error: GnuPG is not installed. Prease install gnupg package"; exit 1; } findworkspace "${GPG[@]}" --fingerprint } From f4a2709a62c42e0142944d0248beeaec35cd479f Mon Sep 17 00:00:00 2001 From: Jon Date: Mon, 23 Dec 2013 21:01:57 -0800 Subject: [PATCH 033/309] fix unquoted echoes breaking command case sate --- apt-cyg | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apt-cyg b/apt-cyg index f99a73a..2ca09c4 100755 --- a/apt-cyg +++ b/apt-cyg @@ -504,10 +504,10 @@ case "$command" in for pkg in $packages do echo "" - echo Searching for installed packages matching $pkg: + echo "Searching for installed packages matching $pkg:" awk '/[^ ]+ [^ ]+ 0/ {if ($1 ~ query) print $1}' query="$pkg" IGNORECASE="$ignore_case" /etc/setup/installed.db echo "" - echo Searching for installable packages matching $pkg: + echo "Searching for installable packages matching $pkg:" cat setup.ini | awk -v query="$pkg" -v IGNORECASE="$ignore_case" \ 'BEGIN{RS="\n\n@ "; FS="\n"; ORS="\n"} {if ($1 ~ query) {print $1}}' done From e21c60e790998531e84f64a623d4ee75f54d93cb Mon Sep 17 00:00:00 2001 From: kou1okada Date: Wed, 25 Dec 2013 13:29:17 +0900 Subject: [PATCH 034/309] Change place of GUNPGHOME for apt-cyg. In previous version, GNUPGHOME for apt-cyg had been set "$cache/apt-cyg/.gnupg". But there are some inconveniences. For example, if you downloaded apt-cyg into "$cache/", GNUPGHOME could not be initialized. So this patch change GNUPGHOME for apt-cyg from "$cache/apt-cyg/.gnupg" to "$cache/.apt-cyg" In additionally, a error handler for initializing GNUPGHOME is added. --- apt-cyg | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/apt-cyg b/apt-cyg index 2ca09c4..86104bf 100755 --- a/apt-cyg +++ b/apt-cyg @@ -199,11 +199,12 @@ function charch () function init_gnupg () { [ -z "$GPG" ] && return - export GNUPGHOME="$cache/apt-cyg/.gnupg" - echo $GNUPGHOME + export GNUPGHOME="$cache/.apt-cyg" if ! [ -d "$GNUPGHOME" ]; then - mkdir -p "$GNUPGHOME" - chmod 700 "$GNUPGHOME" + if ! { mkdir -p "$GNUPGHOME" && chmod 700 "$GNUPGHOME"; } then + echo -e "\e[31;1mError:\e[30;0m cannot initialize directory $GNUPGHOME" + exit 1 + fi fi GPG_KEYRING=( --keyring pubring.gpg ) } From 2a86fedb1d7946e2e2ebca2ea61c3d1b35c2c862 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Wed, 25 Dec 2013 17:05:56 +0900 Subject: [PATCH 035/309] Discard unnecessary console outputs of subcommand lookup. --- apt-cyg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apt-cyg b/apt-cyg index 86104bf..07b0798 100755 --- a/apt-cyg +++ b/apt-cyg @@ -723,7 +723,7 @@ case "$command" in ;; *) - if type "apt-cyg-$command" >/dev/null; then + if type "apt-cyg-$command" >& /dev/null; then "apt-cyg-$command" $packages else usage From 1d91f24b98e0dfc4b5634b7ce30fedd667de24aa Mon Sep 17 00:00:00 2001 From: kou1okada Date: Fri, 27 Dec 2013 10:50:51 +0900 Subject: [PATCH 036/309] Pay attention to the string termination for cache and mirror with the aim of improving compatibility with setup.exe. --- apt-cyg | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/apt-cyg b/apt-cyg index 07b0798..e56b2e4 100755 --- a/apt-cyg +++ b/apt-cyg @@ -116,12 +116,14 @@ function findworkspace() tmp="`head -1 /etc/setup/last-cache`" cache="`cygpath -au "$tmp"`" fi + cache="${cache%/}" if test -e /etc/setup/last-mirror then mirror="`head -1 /etc/setup/last-mirror`" fi - mirrordir="`echo "$mirror" | sed -e "s/:/%3a/g" -e "s:/:%2f:g"`" + mirror="${mirror%/}" + mirrordir="`echo "$mirror/" | sed -e "s/:/%3a/g" -e "s:/:%2f:g"`" echo Working directory is $cache echo Mirror is $mirror @@ -395,7 +397,7 @@ do ;; --mirror|-m) - echo "$2" > /etc/setup/last-mirror + echo "${2%/}/" > /etc/setup/last-mirror shift ; shift ;; From e7a277409605ac3457027ef3c907b87f78adc471 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Sat, 28 Dec 2013 17:51:03 +0900 Subject: [PATCH 037/309] Update README.md --- README.md | 53 ++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 42 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 8db439d..bf7e1d5 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ apt-cyg ======= -apt-cyg is a command-line installer for Cygwin which cooperates with Cygwin Setup and uses the same repository. The syntax is similar to apt-get. Usage examples: +apt-cyg is a command-line installer for [Cygwin](http://cygwin.com/) which cooperates with Cygwin Setup and uses the same repository. The syntax is similar to apt-get. Usage examples: * "apt-cyg install " to install packages * "apt-cyg remove " to remove packages @@ -10,34 +10,47 @@ apt-cyg is a command-line installer for Cygwin which cooperates with Cygwin Setu * "apt-cyg find " to find packages matching patterns * "apt-cyg describe " to describe packages matching patterns * "apt-cyg packageof " to locate parent packages +* "apt-cyg key-add ..." to add keys contained in +* "apt-cyg key-del ..." to remove keys +* "apt-cyg key-list" to list keys +* "apt-cyg key-finger" to list fingerprints Quick start ----------- apt-cyg is a simple script. Once you have a copy, make it executable: - # chmod +x /bin/apt-cyg + # chmod +x /bin/apt-cyg Optionally place apt-cyg in a bin/ folder on your path. Then use apt-cyg, for example: - # apt-cyg install nano + # apt-cyg install nano -True multi-architecture support +New features ------------ +### True multi-architecture support + Let think a case that you want to install the x86 package when you are working under the x86_64 environment. In this case, You must only append a --charch option to the first parameter of apt-cyg. For example: - # apt-cyg --charch x86 install chere + # apt-cyg --charch x86 install chere As of 2013-10-26, chere package is provided for only the repository for x86. Remarks: Of course, you must install both environments of x86_64 and x86, beforehand. +### Signature check and key management by GnuPG + +The default action of apt-cyg has been changed to check signature for 'setup.ini'. +Of course you can also avoid signature check by using --no-verify or -X options. +Public keys of cygwin and cygwinports are already registered to trusted keys of embeded. +If you want to use some other public keys, please use key-* subcommands. + Contributing ------------ @@ -52,19 +65,37 @@ Please do not merge forks that have incompatible licenses. Ex.) Merging to the GPL from the MIT is possible. But merging to the MIT from the GPL is impossible. -#### Official +#### Official (MIT license) -* [transcodes-open / apt-cyg](https://github.com/transcode-open/apt-cyg/network) (MIT license) +* [transcodes-open / apt-cyg](https://github.com/transcode-open/apt-cyg/network) -#### Unofficial +#### Unofficial (GPLv2) -* [cfg / apt-cyg](https://github.com/cfg/apt-cyg/network) (GPLv2) -* [ashumkin / apt-cyg](https://github.com/ashumkin/apt-cyg/network) (GPLv2) +* [cfg / apt-cyg](https://github.com/cfg/apt-cyg/network) +* [ashumkin / apt-cyg](https://github.com/ashumkin/apt-cyg/network) +* [svn2github / apt-cyg](https://github.com/svn2github/apt-cyg/network) +* [nosuchuser / apt-cyg](https://github.com/nosuchuser/apt-cyg/network) +* [kazuhisya / apt-cyg64](https://github.com/kazuhisya/apt-cyg64/network) +* [bnormsoftware / apt-cyg](https://github.com/bnormsoftware/apt-cyg/network) +* [rcmdnk / apt-cyg](https://github.com/rcmdnk/apt-cyg/network) +* [buzain / apt-cyg](https://github.com/buzain/apt-cyg/network) +* [wuyangnju / apt-cyg](https://github.com/wuyangnju/apt-cyg/network) +* [takuya / apt-cyg](https://github.com/takuya/apt-cyg/network) + +Todo +------------ + +* Support multi mirrors: Cygwin setup can use multi mirrors. They are recorded at last-mirror section in '/etc/setup/setup.rc'. It's useful for using [Cygwinports](http://cygwinports.org/). +* Support completion: Some other forks already supported it. For example, [Milly / apt-cyg](https://github.com/Milly/apt-cyg) under the cfg / apt-cyg fork, [ashumukin / apt-cyg](https://github.com/ashumkin/apt-cyg) and etc supported it. +* Support upgrade: But maybe, busy resources can not be upgraded, and rebase problem will happen. Cygwin setup resolves by replacing them at next reboot. +* Support dependency check for remove subcommand. Known Problem ------------ -### Check setup (cygcheck -c) can not detect .tar.xz packages +### FIXED: Check setup (cygcheck -c) can not detect .tar.xz packages At cygwin 1.7.25, cygcheck is hardcoded for .tar.gz and .tar.bz2. So check setup (cygcheck -c) can not detect .tar.xz packages. This bug was already fixed with [src/winsup/utils/dump_setup.cc#rev1.28](http://cygwin.com/cgi-bin/cvsweb.cgi/src/winsup/utils/dump_setup.cc?cvsroot=src#rev1.28). Please wait a release of cygwin 1.7.26. + +This Problem was fixed [cygwin 1.7.26](http://cygwin.com/ml/cygwin-announce/2013-11/msg00027.html) which released at 2013-11-29. From 06be2a2e0149052b03c47d32089587a280edb839 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Sat, 28 Dec 2013 19:13:49 +0900 Subject: [PATCH 038/309] Add pathof subcommand. --- README.md | 3 ++- apt-cyg | 20 +++++++++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index bf7e1d5..a693b32 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,8 @@ apt-cyg is a command-line installer for [Cygwin](http://cygwin.com/) which coope * "apt-cyg show" to show installed packages * "apt-cyg find " to find packages matching patterns * "apt-cyg describe " to describe packages matching patterns -* "apt-cyg packageof " to locate parent packages +* "apt-cyg packageof " to locate parent packages +* "apt-cyg pathof " to show path" * "apt-cyg key-add ..." to add keys contained in * "apt-cyg key-del ..." to remove keys * "apt-cyg key-list" to list keys diff --git a/apt-cyg b/apt-cyg index e56b2e4..26dc5c9 100755 --- a/apt-cyg +++ b/apt-cyg @@ -66,6 +66,7 @@ function usage() echo " \"apt-cyg find \" to find packages matching patterns" echo " \"apt-cyg describe \" to describe packages matching patterns" echo " \"apt-cyg packageof \" to locate parent packages" + echo " \"apt-cyg pathof \" to show path" echo " \"apt-cyg key-add ...\" to add keys contained in " echo " \"apt-cyg key-del ...\" to remove keys " echo " \"apt-cyg key-list\" to list keys" @@ -342,6 +343,23 @@ function apt-cyg-key-finger () "${GPG[@]}" --fingerprint } +function apt-cyg-pathof () +{ + findworkspace >& /dev/null + while [ "$#" -gt 0 ]; do + case "$1" in + cache) echo "$cache" ;; + mirror) echo "$mirror" ;; + mirrordir) echo "$mirrordir" ;; + cache/mirrordir) echo "$cache/$mirrordir" ;; + *) + echo -e "\e[31;1mError: in function $FUNCNAME: \e[30;0m unknown parameter '$1'." + exit 1 + esac + shift + done +} + # process options noscripts=0 @@ -443,7 +461,7 @@ do shift ;; - update|show|find|describe|packageof|install|remove|key-add|key-del|key-finger|key-list) + update|show|find|describe|packageof|install|remove|key-add|key-del|key-finger|key-list|pathof) if test "-$command-" = "--" then command=$1 From b63ba92bbc7e78df033130d165780f807b1c67e9 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Sat, 28 Dec 2013 21:05:18 +0900 Subject: [PATCH 039/309] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a693b32..cd9bea2 100644 --- a/README.md +++ b/README.md @@ -87,7 +87,7 @@ Todo ------------ * Support multi mirrors: Cygwin setup can use multi mirrors. They are recorded at last-mirror section in '/etc/setup/setup.rc'. It's useful for using [Cygwinports](http://cygwinports.org/). -* Support completion: Some other forks already supported it. For example, [Milly / apt-cyg](https://github.com/Milly/apt-cyg) under the cfg / apt-cyg fork, [ashumukin / apt-cyg](https://github.com/ashumkin/apt-cyg) and etc supported it. +* Support completion: Some other forks already supported it. For example, [Milly / apt-cyg](https://github.com/Milly/apt-cyg) under the cfg / apt-cyg fork, [ashumkin / apt-cyg](https://github.com/ashumkin/apt-cyg) and etc supported it. * Support upgrade: But maybe, busy resources can not be upgraded, and rebase problem will happen. Cygwin setup resolves by replacing them at next reboot. * Support dependency check for remove subcommand. From 0ab56211a5cc3c724664b68a1a78e7f5ea7e4eb9 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Mon, 30 Dec 2013 15:09:30 +0900 Subject: [PATCH 040/309] Refactoring: Hold list of packages to array. --- apt-cyg | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/apt-cyg b/apt-cyg index 26dc5c9..6b4d259 100755 --- a/apt-cyg +++ b/apt-cyg @@ -162,8 +162,7 @@ function getsetup() function checkpackages() { - if test "-$packages-" = "--" - then + if [ ${#packages[@]} -eq 0 ]; then echo Nothing to do, exiting exit 0 fi @@ -368,7 +367,7 @@ file="" dofile=0 command="" filepackages="" -packages="" +packages=() ignore_case="" force_remove="" force_fetch_trustedkeys="" @@ -466,14 +465,14 @@ do then command=$1 else - packages="$packages $1" + packages+=( "$1" ) fi shift ;; *) - packages="$packages $1" + packages+=( "$1" ) shift ;; @@ -494,7 +493,7 @@ then else echo File $file not found, skipping fi - packages="$packages $filepackages" + packages+=( $filepackages ) fi @@ -522,7 +521,7 @@ case "$command" in findworkspace getsetup - for pkg in $packages + for pkg in "${packages[@]}" do echo "" echo "Searching for installed packages matching $pkg:" @@ -541,7 +540,7 @@ case "$command" in checkpackages findworkspace getsetup - for pkg in $packages + for pkg in "${packages[@]}" do echo "" cat setup.ini | awk -v query="$pkg" -v IGNORECASE="$ignore_case" \ @@ -554,7 +553,7 @@ case "$command" in packageof) checkpackages - for pkg in $packages + for pkg in "${packages[@]}" do key=`which "$pkg" 2>/dev/null | sed "s:^/::"` if test "-$key-" = "--" @@ -581,7 +580,7 @@ case "$command" in findworkspace getsetup - for pkg in $packages + for pkg in "${packages[@]}" do already=`grep -c "^$pkg " /etc/setup/installed.db` @@ -697,7 +696,7 @@ case "$command" in remove) checkpackages - for pkg in $packages + for pkg in "${packages[@]}" do already=`grep -c "^$pkg " /etc/setup/installed.db` @@ -744,7 +743,7 @@ case "$command" in *) if type "apt-cyg-$command" >& /dev/null; then - "apt-cyg-$command" $packages + "apt-cyg-$command" "${packages[@]}" else usage fi From 75cbefb83d56cb5f46f9b766131f8b15bb6befdf Mon Sep 17 00:00:00 2001 From: kou1okada Date: Mon, 30 Dec 2013 15:18:39 +0900 Subject: [PATCH 041/309] Allow multiple --file and -f options. --- apt-cyg | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/apt-cyg b/apt-cyg index 6b4d259..d4634d2 100755 --- a/apt-cyg +++ b/apt-cyg @@ -363,10 +363,8 @@ function apt-cyg-pathof () noscripts=0 noupdate=0 -file="" -dofile=0 +OPT_FILES=() command="" -filepackages="" packages=() ignore_case="" force_remove="" @@ -451,8 +449,7 @@ do --file|-f) if ! test "-$2-" = "--" then - file="$2" - dofile=1 + OPT_FILES+=( "$2" ) shift else echo 1>&2 No file name provided, ignoring $1 @@ -485,16 +482,14 @@ if [[ "$GPGV" == "" && "$no_verify" == "" ]]; then exit 1 fi -if test $dofile = 1 -then +for file in "${OPT_FILES[@]}"; do if test -f "$file" then - filepackages="$filepackages `cat "$file" | awk '{printf "%s ", $0}'`" + readarray -t -O ${#packages[@]} packages < "$file" else echo File $file not found, skipping fi - packages+=( $filepackages ) -fi +done case "$command" in From df805fbe8ba3ba989a1cee35b720cf9a0fda87b8 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Mon, 30 Dec 2013 18:19:29 +0900 Subject: [PATCH 042/309] Remove the constraint about the order of '--charch' option. --- README.md | 1 - apt-cyg | 10 +++------- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index cd9bea2..acb98a4 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,6 @@ New features ### True multi-architecture support Let think a case that you want to install the x86 package when you are working under the x86_64 environment. -In this case, You must only append a --charch option to the first parameter of apt-cyg. For example: # apt-cyg --charch x86 install chere diff --git a/apt-cyg b/apt-cyg index d4634d2..69a3b5d 100755 --- a/apt-cyg +++ b/apt-cyg @@ -72,7 +72,7 @@ function usage() echo " \"apt-cyg key-list\" to list keys" echo " \"apt-cyg key-finger\" to list fingerprints" echo "Options:" - echo " --charch : change archetecture (must appear first)" + echo " --charch : change archetecture" echo " --use-setuprc : set cache and mirror with /etc/setup/setup.rc" echo " --ignore-case,-i : ignore case distinctions for " echo " --force-remove : force remove" @@ -370,18 +370,14 @@ ignore_case="" force_remove="" force_fetch_trustedkeys="" no_verify="" -nargs=$# +INITIAL_ARGS=( "$@" ) while test $# -gt 0 do case "$1" in --charch) - if [ "$#" -lt "$nargs" ]; then - echo "Error: $1 $2 option must appear first." >&2 - exit 1 - fi - charch "$2" "$@" + charch "$2" "${INITIAL_ARGS[@]}" shift ; shift ;; From bf20aa30b1aa43adec7f4aea9354dc0c6d67e1bb Mon Sep 17 00:00:00 2001 From: kou1okada Date: Tue, 31 Dec 2013 16:48:37 +0900 Subject: [PATCH 043/309] Refactoring: Subcommands are separated into the function. --- apt-cyg | 106 +++++++++++++++++++++++++++++--------------------------- 1 file changed, 55 insertions(+), 51 deletions(-) diff --git a/apt-cyg b/apt-cyg index 69a3b5d..3ea0d3e 100755 --- a/apt-cyg +++ b/apt-cyg @@ -162,7 +162,7 @@ function getsetup() function checkpackages() { - if [ ${#packages[@]} -eq 0 ]; then + if [ $# -eq 0 ]; then echo Nothing to do, exiting exit 0 fi @@ -359,18 +359,23 @@ function apt-cyg-pathof () done } +function apt-cyg-help () +{ + usage +} + # process options noscripts=0 noupdate=0 OPT_FILES=() -command="" -packages=() +SUBCOMMAND="" ignore_case="" force_remove="" force_fetch_trustedkeys="" no_verify="" INITIAL_ARGS=( "$@" ) +ARGS=() while test $# -gt 0 do @@ -453,23 +458,16 @@ do shift ;; - update|show|find|describe|packageof|install|remove|key-add|key-del|key-finger|key-list|pathof) - if test "-$command-" = "--" - then - command=$1 + *) + if [ -z "$SUBCOMMAND" ]; then + SUBCOMMAND="$1" else - packages+=( "$1" ) + ARGS+=( "$1" ) fi shift ;; - *) - packages+=( "$1" ) - shift - - ;; - esac done @@ -481,39 +479,40 @@ fi for file in "${OPT_FILES[@]}"; do if test -f "$file" then - readarray -t -O ${#packages[@]} packages < "$file" + readarray -t -O ${#ARGS[@]} ARGS < "$file" else echo File $file not found, skipping fi done -case "$command" in - update) +function apt-cyg-update () +{ findworkspace getsetup - ;; +} - show) +function apt-cyg-show () +{ echo 1>&2 The following packages are installed: cat /etc/setup/installed.db | awk '/[^ ]+ [^ ]+ 0/ {print $1}' - ;; +} - find) +function apt-cyg-find () +{ - checkpackages + checkpackages "$@" findworkspace getsetup - for pkg in "${packages[@]}" - do + for pkg do echo "" echo "Searching for installed packages matching $pkg:" awk '/[^ ]+ [^ ]+ 0/ {if ($1 ~ query) print $1}' query="$pkg" IGNORECASE="$ignore_case" /etc/setup/installed.db @@ -523,29 +522,29 @@ case "$command" in 'BEGIN{RS="\n\n@ "; FS="\n"; ORS="\n"} {if ($1 ~ query) {print $1}}' done - ;; +} - describe) +function apt-cyg-describe () +{ - checkpackages + checkpackages "$@" findworkspace getsetup - for pkg in "${packages[@]}" - do + for pkg do echo "" cat setup.ini | awk -v query="$pkg" -v IGNORECASE="$ignore_case" \ 'BEGIN{RS="\n\n@ "; FS="\n"; ORS="\n"} {if ($1 ~ query) {print $0 "\n"}}' done - ;; +} - packageof) +function apt-cyg-packageof () +{ - checkpackages - for pkg in "${packages[@]}" - do + checkpackages "$@" + for pkg do key=`which "$pkg" 2>/dev/null | sed "s:^/::"` if test "-$key-" = "--" then @@ -562,17 +561,17 @@ case "$command" in done done - ;; +} - install) +function apt-cyg-install () +{ - checkpackages + checkpackages "$@" findworkspace getsetup - for pkg in "${packages[@]}" - do + for pkg do already=`grep -c "^$pkg " /etc/setup/installed.db` if test $already -ge 1 @@ -681,14 +680,14 @@ case "$command" in done - ;; +} - remove) +function apt-cyg-remove() +{ - checkpackages - for pkg in "${packages[@]}" - do + checkpackages "$@" + for pkg do already=`grep -c "^$pkg " /etc/setup/installed.db` if test $already = 0 @@ -730,15 +729,20 @@ case "$command" in done - ;; +} - *) - if type "apt-cyg-$command" >& /dev/null; then - "apt-cyg-$command" "${packages[@]}" +function invoke_subcommand () +{ + local SUBCOMMAND="${@:1:1}" + local ARGS=( "${@:2}" ) + local ACTION="apt-cyg-${SUBCOMMAND:-help}" + if type "$ACTION" >& /dev/null; then + "$ACTION" "${ARGS[@]}" else - usage + echo -e "\e[31;1mError: \e[30;0m unknown subcommand '$SUBCOMMAND'." + exit 1 fi - ;; +} -esac +invoke_subcommand "$SUBCOMMAND" "${ARGS[@]}" From 1108780f7fdc7bbcd01f0d0ea85526f983849f9d Mon Sep 17 00:00:00 2001 From: kou1okada Date: Tue, 31 Dec 2013 17:30:14 +0900 Subject: [PATCH 044/309] Refactoring: Change the scope of variables to local as much as possible. --- apt-cyg | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/apt-cyg b/apt-cyg index 3ea0d3e..8cce42f 100755 --- a/apt-cyg +++ b/apt-cyg @@ -232,6 +232,7 @@ function wget_and_check_md5sum () function fetch_trustedkeys () { [ -z "$GPG" ] && return + local i local FILE="$(mktemp)" local FILE_LATEST="$(mktemp)" for i in "${TRUSTEDKEYS[@]}"; do @@ -322,6 +323,7 @@ function apt-cyg-key-add () function apt-cyg-key-del () { [ -z "$GPG" ] && { echo "Error: GnuPG is not installed. Prease install gnupg package"; exit 1; } + local keyid findworkspace for keyid; do "${GPG[@]}" --batch --yes --delete-key "$keyid" @@ -507,6 +509,7 @@ function apt-cyg-show () function apt-cyg-find () { + local pkg checkpackages "$@" findworkspace @@ -527,6 +530,7 @@ function apt-cyg-find () function apt-cyg-describe () { + local pkg checkpackages "$@" findworkspace @@ -542,20 +546,22 @@ function apt-cyg-describe () function apt-cyg-packageof () { + local pkg + local manifest checkpackages "$@" for pkg do - key=`which "$pkg" 2>/dev/null | sed "s:^/::"` + local key=`which "$pkg" 2>/dev/null | sed "s:^/::"` if test "-$key-" = "--" then key="$pkg" fi for manifest in /etc/setup/*.lst.gz do - found=`cat $manifest | gzip -d | grep -c "$key"` + local found=`cat $manifest | gzip -d | grep -c "$key"` if test $found -gt 0 then - package=`echo $manifest | sed -e "s:/etc/setup/::" -e "s/.lst.gz//"` + local package=`echo $manifest | sed -e "s:/etc/setup/::" -e "s/.lst.gz//"` echo Found $key in the package $package fi done @@ -566,6 +572,8 @@ function apt-cyg-packageof () function apt-cyg-install () { + local pkg + local script checkpackages "$@" findworkspace @@ -589,7 +597,7 @@ function apt-cyg-install () 'BEGIN{RS="\n\n@ "; FS="\n"} {if ($1 == package) {desc = $0; px++}} \ END {if (px == 1 && desc != "") print desc; else print "Package not found"}' - desc=`cat "release/$pkg/desc"` + local desc=`cat "release/$pkg/desc"` if test "-$desc-" = "-Package not found-" then echo Package $pkg not found or ambiguous name, exiting @@ -601,7 +609,7 @@ function apt-cyg-install () # download and unpack the bz2 file # pick the latest version, which comes first - install=`cat "release/$pkg/desc" | awk '/^install: / { print $2; exit }'` + local install=`cat "release/$pkg/desc" | awk '/^install: / { print $2; exit }'` if test "-$install-" = "--" then @@ -609,13 +617,13 @@ function apt-cyg-install () exit 1 fi - file=`basename $install` + local file=`basename $install` cd "release/$pkg" "${WGET[@]}" -nc $mirror/$install # check the md5 - digest=`cat "desc" | awk '/^install: / { print $4; exit }'` - digactual=`md5sum $file | awk '{print $1}'` + local digest=`cat "desc" | awk '/^install: / { print $4; exit }'` + local digactual=`md5sum $file | awk '{print $1}'` if ! test $digest = $digactual then echo MD5 sum did not match, exiting @@ -639,7 +647,7 @@ function apt-cyg-install () # recursively install required packages - requires=`grep "^requires: " "release/$pkg/desc" | sed -re 's/^requires: *(.*[^ ]) */\1/g' -e 's/ +/ /g'` + local requires=`grep "^requires: " "release/$pkg/desc" | sed -re 's/^requires: *(.*[^ ]) */\1/g' -e 's/ +/ /g'` warn=0 if ! test "-$requires-" = "--" @@ -648,7 +656,7 @@ function apt-cyg-install () echo $requires for package in $requires do - already=`grep -c "^$package " /etc/setup/installed.db` + local already=`grep -c "^$package " /etc/setup/installed.db` if test $already -ge 1 then echo Package $package is already installed, skipping @@ -665,7 +673,7 @@ function apt-cyg-install () # run all postinstall scripts - pis=`ls /etc/postinstall/*.sh 2>/dev/null | wc -l` + local pis=`ls /etc/postinstall/*.sh 2>/dev/null | wc -l` if test $pis -gt 0 && ! test $noscripts -eq 1 then echo Running postinstall scripts @@ -685,18 +693,20 @@ function apt-cyg-install () function apt-cyg-remove() { + local pkg + local req checkpackages "$@" for pkg do - already=`grep -c "^$pkg " /etc/setup/installed.db` + local already=`grep -c "^$pkg " /etc/setup/installed.db` if test $already = 0 then echo Package $pkg is not installed, skipping continue fi - dontremove="cygwin coreutils gawk bzip2 tar xz wget bash" + local dontremove="cygwin coreutils gawk bzip2 tar xz wget bash" for req in $dontremove do if test "-$pkg-" = "-$req-" From 37714713e2ec87c319dd98c79ddc018a7f0e6f4b Mon Sep 17 00:00:00 2001 From: kou1okada Date: Fri, 3 Jan 2014 11:24:35 +0900 Subject: [PATCH 045/309] Update README.md --- README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/README.md b/README.md index acb98a4..6c2935f 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,20 @@ apt-cyg is a command-line installer for [Cygwin](http://cygwin.com/) which coope * "apt-cyg key-list" to list keys * "apt-cyg key-finger" to list fingerprints +Requirements +----------- + +apt-cyg requires the cygwin default environment and optional packages below. + +* wget,ca-certificates,gnupg + +In 32bit version of cygwin, wget requires additional setting for ca-certificates package. +Choose one of below. + + ln -s /usr/ssl /etc/ + + echo "ca-directory = /usr/ssl/certs" >> ~/.wgetrc + Quick start ----------- From b212f9701f45096f465c0caf34ca1cb628e73526 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Fri, 3 Jan 2014 11:31:36 +0900 Subject: [PATCH 046/309] Update README.md --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 6c2935f..21c995c 100644 --- a/README.md +++ b/README.md @@ -26,8 +26,12 @@ apt-cyg requires the cygwin default environment and optional packages below. In 32bit version of cygwin, wget requires additional setting for ca-certificates package. Choose one of below. +1. Create symbolic link for the default ca-directory of wget. + ln -s /usr/ssl /etc/ +2. Set ca-directory paramete in '.wgetrc'. + echo "ca-directory = /usr/ssl/certs" >> ~/.wgetrc Quick start From aa7c5df76f3a828522c0d2392f85658a8369ed14 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Fri, 3 Jan 2014 13:49:45 +0900 Subject: [PATCH 047/309] Update README.md --- README.md | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 21c995c..2113af8 100644 --- a/README.md +++ b/README.md @@ -23,17 +23,23 @@ apt-cyg requires the cygwin default environment and optional packages below. * wget,ca-certificates,gnupg -In 32bit version of cygwin, wget requires additional setting for ca-certificates package. -Choose one of below. - -1. Create symbolic link for the default ca-directory of wget. +In 32bit version of cygwin, wget requires an additional setting for ca-certificates package. +Choose one of below settings. + # 1. Create symbolic link for the default ca-directory of wget. ln -s /usr/ssl /etc/ - -2. Set ca-directory paramete in '.wgetrc'. - + + # or + # 2. Set ca-directory paramete in '/etc/wgetrc'. + echo "ca-directory = /usr/ssl/certs" >> /etc/wgetrc + + # or + # 3. Set ca-directory paramete in '~/.wgetrc'. echo "ca-directory = /usr/ssl/certs" >> ~/.wgetrc +Remarks: +Above additional settings for wget is not required for 64bit version of cygwin. + Quick start ----------- From 878a9bf4c687e3468091771c5da65d137d6804b1 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Fri, 3 Jan 2014 14:12:00 +0900 Subject: [PATCH 048/309] Update README.md The less-than sign and the greater-than sign had not been displayed. Rewrite them by character entity references. --- README.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 2113af8..dc4fa1f 100644 --- a/README.md +++ b/README.md @@ -3,16 +3,16 @@ apt-cyg apt-cyg is a command-line installer for [Cygwin](http://cygwin.com/) which cooperates with Cygwin Setup and uses the same repository. The syntax is similar to apt-get. Usage examples: -* "apt-cyg install " to install packages -* "apt-cyg remove " to remove packages +* "apt-cyg install <package names>" to install packages +* "apt-cyg remove <package names>" to remove packages * "apt-cyg update" to update setup.ini * "apt-cyg show" to show installed packages -* "apt-cyg find " to find packages matching patterns -* "apt-cyg describe " to describe packages matching patterns -* "apt-cyg packageof " to locate parent packages -* "apt-cyg pathof " to show path" -* "apt-cyg key-add ..." to add keys contained in -* "apt-cyg key-del ..." to remove keys +* "apt-cyg find <pattern(s)>" to find packages matching patterns +* "apt-cyg describe <pattern(s)>" to describe packages matching patterns +* "apt-cyg packageof <commands or files>" to locate parent packages +* "apt-cyg pathof <cache|mirror|mirrordir|cache/mirrordir>" to show path" +* "apt-cyg key-add <files> ..." to add keys contained in <files> +* "apt-cyg key-del <keyids> ..." to remove keys <keyids> * "apt-cyg key-list" to list keys * "apt-cyg key-finger" to list fingerprints From 3e8de9c950593785cad26ecb5930af5913398635 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Sun, 5 Jan 2014 10:27:48 +0900 Subject: [PATCH 049/309] Refactoring: Change the scope of variables to local as much as possible. --- apt-cyg | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/apt-cyg b/apt-cyg index 8cce42f..220f1e1 100755 --- a/apt-cyg +++ b/apt-cyg @@ -114,8 +114,7 @@ function findworkspace() if test -e /etc/setup/last-cache then - tmp="`head -1 /etc/setup/last-cache`" - cache="`cygpath -au "$tmp"`" + cache="$(cygpath -au "$(head -1 /etc/setup/last-cache)")" fi cache="${cache%/}" @@ -581,7 +580,7 @@ function apt-cyg-install () for pkg do - already=`grep -c "^$pkg " /etc/setup/installed.db` + local already=`grep -c "^$pkg " /etc/setup/installed.db` if test $already -ge 1 then echo Package $pkg is already installed, skipping @@ -649,7 +648,7 @@ function apt-cyg-install () local requires=`grep "^requires: " "release/$pkg/desc" | sed -re 's/^requires: *(.*[^ ]) */\1/g' -e 's/ +/ /g'` - warn=0 + local warn=0 if ! test "-$requires-" = "--" then echo Package $pkg requires the following packages, installing: From 482ac5c8c491c54ded7328c929469ae0045f5b75 Mon Sep 17 00:00:00 2001 From: Jon Date: Thu, 9 Jan 2014 02:28:31 -0800 Subject: [PATCH 050/309] add wget md5 return case func, add ask user func, ask user to issue wget no check ssl if gpg url has invalid or expired cert. Fix format and typo in usage. Not fully tested, need came from trying apt-cyg on clean installs of cygwin, sourceware currently has an invalid ssl according to wgets strict checking --- apt-cyg | 44 ++++++++++++++++++++++++++++++++++++++------ 1 file changed, 38 insertions(+), 6 deletions(-) diff --git a/apt-cyg b/apt-cyg index 220f1e1..f447df7 100755 --- a/apt-cyg +++ b/apt-cyg @@ -69,14 +69,14 @@ function usage() echo " \"apt-cyg pathof \" to show path" echo " \"apt-cyg key-add ...\" to add keys contained in " echo " \"apt-cyg key-del ...\" to remove keys " - echo " \"apt-cyg key-list\" to list keys" + echo " \"apt-cyg key-list\" to list keys" echo " \"apt-cyg key-finger\" to list fingerprints" echo "Options:" echo " --charch : change archetecture" echo " --use-setuprc : set cache and mirror with /etc/setup/setup.rc" echo " --ignore-case,-i : ignore case distinctions for " echo " --force-remove : force remove" - echo " --force-fetch-trustedkeys: force fetch tristedkeys" + echo " --force-fetch-trustedkeys: force fetch trustedkeys" echo " --no-verify, -X : Don't verify setup.ini signatures" echo " --mirror, -m : set mirror" echo " --cache, -c : set cache" @@ -210,6 +210,40 @@ function init_gnupg () GPG_KEYRING=( --keyring pubring.gpg ) } +# Usage: ask_user "question?" (optional recognition of YES_TO_ALL=true auto yes) +ask_user () +{ + while true; do + [ "$2" ] && { local pmt="$2";local def=; } + [ "$2" ] || { local pmt="y/n";local def=; } + $YES_TO_ALL && { local RPY=Y;local def=Y; } + [ -z "$def" ] && { echo -ne "$1 ";read -p "[$pmt] " RPY; } + [ -z "$RPY" ] && local RPY=$def; + case "$RPY" in + Y*|y*) return 0 ;; + N*|n*) return 1 ;; + 1*) return 0 ;; + 2*) return 1 ;; + esac + done +} + +# Usage: wget_return_case_md5sum returncode +wget_return_case_md5sum () +{ + case "$1" in + 1) echo "$LABEL: FAILED: Could not download $URL."; return 1 ;; + 5) echo "$LABEL: WARNING: The SSL certificate is invalid $URL." + ask_user "Continue regardless of invalid SSL certificate?" || return 1 + "${WGET[@]}" --no-check-certificate "$URL" -O "$FILE" + return 0 + ;; + 8) echo "$LABEL: FAILED: 404 Not Found $URL." return 1 ;; + 0) return 0 ;; + *) echo "Error: FATAL: wget returned unkown value"; return 1 ;; + esac +} + # Usage: check_md5sum label hash url file function wget_and_check_md5sum () { @@ -217,10 +251,8 @@ function wget_and_check_md5sum () local MD5="$2" local URL="$3" local FILE="$4" - if ! "${WGET[@]}" "$URL" -O "$FILE"; then - echo "$LABEL: FAILED: Could not download $URL." - return 1 - fi + "${WGET[@]}" "$URL" -O "$FILE" + wget_return_case_md5sum "$?" || return 1 if ! echo "$MD5 *$FILE" | md5sum -c >& /dev/null; then echo "$LABEL: FAILED: MD5 hash is not match." return 2 From a1018089cc74401b33b16ee24d1aa58b71805333 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Wed, 15 Jan 2014 01:34:28 +0900 Subject: [PATCH 051/309] Update README.md --- README.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/README.md b/README.md index dc4fa1f..c21a8dd 100644 --- a/README.md +++ b/README.md @@ -116,6 +116,22 @@ Todo Known Problem ------------ +### 2014-01-15: Signature check failed at cygwinports x86_64. +Oops, setup.bz2 is newer than setup.bz2.sig. + + $ date + Wed Jan 15 01:30:19 JST 2014 + $ w3m -dump ftp://ftp.cygwinports.org/pub/cygwinports/x86_64/ + Index of ftp://ftp.cygwinports.org/pub/cygwinports/x86_64/ + + [Upper Directory] + md5.sum. . . . . . . Jan 10 14:24 184 + release/ . . . . . . Jan 10 18:00 + setup.bz2. . . . . . Jan 10 13:59 579K + setup.bz2.sig. . . . Dec 6 11:28 72 + setup.ini. . . . . . Dec 6 11:28 3.20M + setup.ini.sig. . . . Dec 6 11:28 72 + ### FIXED: Check setup (cygcheck -c) can not detect .tar.xz packages At cygwin 1.7.25, cygcheck is hardcoded for .tar.gz and .tar.bz2. So check setup (cygcheck -c) can not detect .tar.xz packages. From b4a2336d0c6a9112b965c643a31f066d6470cdeb Mon Sep 17 00:00:00 2001 From: kou1okada Date: Wed, 15 Jan 2014 02:36:30 +0900 Subject: [PATCH 052/309] Update README.md --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index c21a8dd..43513c3 100644 --- a/README.md +++ b/README.md @@ -118,6 +118,7 @@ Known Problem ------------ ### 2014-01-15: Signature check failed at cygwinports x86_64. Oops, setup.bz2 is newer than setup.bz2.sig. +And it seems to be corrupted. $ date Wed Jan 15 01:30:19 JST 2014 @@ -131,6 +132,14 @@ Oops, setup.bz2 is newer than setup.bz2.sig. setup.bz2.sig. . . . Dec 6 11:28 72 setup.ini. . . . . . Dec 6 11:28 3.20M setup.ini.sig. . . . Dec 6 11:28 72 + + $ wget -q -O - ftp://ftp.cygwinports.org/pub/cygwinports/x86_64/setup.bz2 | bzip2 -tvv + (stdin): + [1: huff+mtf rt+rld] + [2: huff+mtf data integrity (CRC) error in data + + You can use the `bzip2recover' program to attempt to recover + data from undamaged sections of corrupted files. ### FIXED: Check setup (cygcheck -c) can not detect .tar.xz packages At cygwin 1.7.25, cygcheck is hardcoded for .tar.gz and .tar.bz2. From 8440a8250beb36f5ae1a1c99c35e945f048e8475 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Fri, 17 Jan 2014 20:04:42 +0900 Subject: [PATCH 053/309] Update README.md --- README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/README.md b/README.md index 43513c3..7ea37d4 100644 --- a/README.md +++ b/README.md @@ -116,6 +116,20 @@ Todo Known Problem ------------ +### 2014-01-17: ca-certificates package is not setup correct at x86_64 with Windows 8. + +After clean installing with setup-x86_64, there are something wrong about ca-certificate package as below: + + $ ls -lnG \ + /cygdrive/c/cygwin/etc/pki/ca-trust/extracted/openssl/ca-bundle.trust.crt \ + /cygdrive/c/cygwin64/etc/pki/ca-trust/extracted/openssl/ca-bundle.trust.crt + -r--r--r-- 1 1001 314336 Jan 17 18:17 /cygdrive/c/cygwin/etc/pki/ca-trust/extracted/openssl/ca-bundle.trust.crt + -rw-r--r-- 1 1001 0 Oct 16 12:35 /cygdrive/c/cygwin64/etc/pki/ca-trust/extracted/openssl/ca-bundle.trust.crt + +The x86 environment seems no problem except that need an additional setting for wget and ca-certificate. Hmm,,, + +It seems that /usr/bin/update-ca-trust is failed at x86_64. + ### 2014-01-15: Signature check failed at cygwinports x86_64. Oops, setup.bz2 is newer than setup.bz2.sig. And it seems to be corrupted. From f63fbc083a48c557d89e9904d4ce89cd924f61c5 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Fri, 17 Jan 2014 22:13:28 +0900 Subject: [PATCH 054/309] Update README.md --- README.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/README.md b/README.md index 7ea37d4..5719ac5 100644 --- a/README.md +++ b/README.md @@ -125,11 +125,23 @@ After clean installing with setup-x86_64, there are something wrong about ca-cer /cygdrive/c/cygwin64/etc/pki/ca-trust/extracted/openssl/ca-bundle.trust.crt -r--r--r-- 1 1001 314336 Jan 17 18:17 /cygdrive/c/cygwin/etc/pki/ca-trust/extracted/openssl/ca-bundle.trust.crt -rw-r--r-- 1 1001 0 Oct 16 12:35 /cygdrive/c/cygwin64/etc/pki/ca-trust/extracted/openssl/ca-bundle.trust.crt + $ ls -lnG \ + /cygdrive/c/cygwin/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem \ + /cygdrive/c/cygwin64/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem + -r--r--r-- 1 1001 232342 Jan 17 18:17 /cygdrive/c/cygwin/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem + -rw-r--r-- 1 1001 0 Oct 16 12:35 /cygdrive/c/cygwin64/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem The x86 environment seems no problem except that need an additional setting for wget and ca-certificate. Hmm,,, It seems that /usr/bin/update-ca-trust is failed at x86_64. +It's ad hoc, but effective way to fix it, is to copy files from cygwin32 to cygwin64, as below: + + cp -a /cygdrive/c/cygwin/etc/pki/ca-trust/extracted/openssl/ca-bundle.trust.crt \ + /cygdrive/c/cygwin64/etc/pki/ca-trust/extracted/openssl/ca-bundle.trust.crt + cp -a /cygdrive/c/cygwin/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem \ + /cygdrive/c/cygwin64/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem + ### 2014-01-15: Signature check failed at cygwinports x86_64. Oops, setup.bz2 is newer than setup.bz2.sig. And it seems to be corrupted. From 69e984e3650ceb2a09a4b0e069f58936de0a863c Mon Sep 17 00:00:00 2001 From: kou1okada Date: Fri, 17 Jan 2014 22:45:51 +0900 Subject: [PATCH 055/309] Update README.md --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 5719ac5..3c13cd8 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,9 @@ Choose one of below settings. Remarks: Above additional settings for wget is not required for 64bit version of cygwin. +But, as of 2014-01-17, perhaps ca-certificates package makes fail of certification in 64bit version of cygwin with Windows 8. See below: + +* Known Problem / [2014-01-17: ca-certificates package is not setup correct at x86_64 with Windows 8.](#20140117-ca-certificates) Quick start ----------- @@ -116,7 +119,7 @@ Todo Known Problem ------------ -### 2014-01-17: ca-certificates package is not setup correct at x86_64 with Windows 8. +### 2014-01-17: ca-certificates package is not setup correct at x86_64 with Windows 8. After clean installing with setup-x86_64, there are something wrong about ca-certificate package as below: From afb6c938486aaf108f1a341084a9af133687acbf Mon Sep 17 00:00:00 2001 From: kou1okada Date: Tue, 21 Jan 2014 15:41:04 +0900 Subject: [PATCH 056/309] Add "--no-check-certificate" option. --- apt-cyg | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/apt-cyg b/apt-cyg index a424aee..ba96817 100755 --- a/apt-cyg +++ b/apt-cyg @@ -78,6 +78,7 @@ function usage() echo " --force-remove : force remove" echo " --force-fetch-trustedkeys: force fetch trustedkeys" echo " --no-verify, -X : Don't verify setup.ini signatures" + echo " --no-check-certificate : Don't validate the server's certificate" echo " --mirror, -m : set mirror" echo " --cache, -c : set cache" echo " --file, -f : read package names from file" @@ -446,6 +447,11 @@ do shift ;; + --no-check-certificate) + WGET+=( "--no-check-certificate" ) + shift + ;; + --mirror|-m) echo "${2%/}/" > /etc/setup/last-mirror shift ; shift From afa3f259ba86f7ea0848f12c4bbec08a44484d43 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Fri, 24 Jan 2014 03:09:48 +0900 Subject: [PATCH 057/309] Add a keyword "setup.ini" to a subcommand "pathof". --- apt-cyg | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/apt-cyg b/apt-cyg index ba96817..c7899a9 100755 --- a/apt-cyg +++ b/apt-cyg @@ -66,7 +66,8 @@ function usage() echo " \"apt-cyg find \" to find packages matching patterns" echo " \"apt-cyg describe \" to describe packages matching patterns" echo " \"apt-cyg packageof \" to locate parent packages" - echo " \"apt-cyg pathof \" to show path" + echo " \"apt-cyg pathof \"" + echo " to show path" echo " \"apt-cyg key-add ...\" to add keys contained in " echo " \"apt-cyg key-del ...\" to remove keys " echo " \"apt-cyg key-list\" to list keys" @@ -74,7 +75,7 @@ function usage() echo "Options:" echo " --charch : change archetecture" echo " --use-setuprc : set cache and mirror with /etc/setup/setup.rc" - echo " --ignore-case,-i : ignore case distinctions for " + echo " --ignore-case, -i : ignore case distinctions for " echo " --force-remove : force remove" echo " --force-fetch-trustedkeys: force fetch trustedkeys" echo " --no-verify, -X : Don't verify setup.ini signatures" @@ -385,6 +386,7 @@ function apt-cyg-pathof () mirror) echo "$mirror" ;; mirrordir) echo "$mirrordir" ;; cache/mirrordir) echo "$cache/$mirrordir" ;; + setup.ini) echo "$cache/$mirrordir/$arch/setup.ini" ;; *) echo -e "\e[31;1mError: in function $FUNCNAME: \e[30;0m unknown parameter '$1'." exit 1 From 4ceed03db6689dd78a33b3c438b64ee9821f379a Mon Sep 17 00:00:00 2001 From: kou1okada Date: Fri, 24 Jan 2014 22:22:18 +0900 Subject: [PATCH 058/309] Update README.md --- README.md | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 3c13cd8..30985d2 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ Remarks: Above additional settings for wget is not required for 64bit version of cygwin. But, as of 2014-01-17, perhaps ca-certificates package makes fail of certification in 64bit version of cygwin with Windows 8. See below: -* Known Problem / [2014-01-17: ca-certificates package is not setup correct at x86_64 with Windows 8.](#20140117-ca-certificates) +* Known Problem / [2014-01-17: ca-certificates package is not setup correct at x86_64 with Windows 8.](#2014-01-17-ca-certificates-package-is-not-setup-correct-at-x86_64-with-windows-8) Quick start ----------- @@ -119,7 +119,7 @@ Todo Known Problem ------------ -### 2014-01-17: ca-certificates package is not setup correct at x86_64 with Windows 8. +### 2014-01-17: ca-certificates package is not setup correct at x86_64 with Windows 8. After clean installing with setup-x86_64, there are something wrong about ca-certificate package as below: @@ -145,6 +145,14 @@ It's ad hoc, but effective way to fix it, is to copy files from cygwin32 to cygw cp -a /cygdrive/c/cygwin/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem \ /cygdrive/c/cygwin64/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem +This problem is fixed at 2014-01-24. +version 0.18.7-1 of p11-kit, p11-kit-trust and libp11-kit0 did not work at the cygwin64 under the Windows 8. +If you face the above problem, please upgrade these three packages from version 0.18.7-1 to version 0.18.7-2. + +For more details, see a thread of below: + +* Cygwin mailing list / cygwin / [Re: Is there someone who have a same problem ?](http://cygwin.com/ml/cygwin/2014-01/msg00368.html) + ### 2014-01-15: Signature check failed at cygwinports x86_64. Oops, setup.bz2 is newer than setup.bz2.sig. And it seems to be corrupted. @@ -170,6 +178,8 @@ And it seems to be corrupted. You can use the `bzip2recover' program to attempt to recover data from undamaged sections of corrupted files. +As of 2014-01-24, above problem is recovered at least. + ### FIXED: Check setup (cygcheck -c) can not detect .tar.xz packages At cygwin 1.7.25, cygcheck is hardcoded for .tar.gz and .tar.bz2. So check setup (cygcheck -c) can not detect .tar.xz packages. From 9507ced2913e33fd8dd10ce327b521a40ca15ee1 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Mon, 24 Feb 2014 13:41:59 +0900 Subject: [PATCH 059/309] Unified the notation of the command substitution. From `command` to $(command). From $(cat file) to $(< file). --- apt-cyg | 82 +++++++++++++++++++++++++++++++-------------------------- 1 file changed, 45 insertions(+), 37 deletions(-) diff --git a/apt-cyg b/apt-cyg index c7899a9..cb7eca0 100755 --- a/apt-cyg +++ b/apt-cyg @@ -46,11 +46,11 @@ TRUSTEDKEY_CYGWINPORTS_URL_LATEST="http://cygwinports.org/ports.gpg" # this script requires some packages -WGET="`which wget 2> /dev/null`" -TAR="`which tar 2> /dev/null`" -GAWK="`which awk 2> /dev/null`" -GPGV="`which gpgv 2> /dev/null`" -GPG="`which gpg 2> /dev/null`" +WGET="$( which wget 2>/dev/null )" +TAR="$( which tar 2>/dev/null )" +GAWK="$( which awk 2>/dev/null )" +GPGV="$( which gpgv 2>/dev/null )" +GPG="$( which gpg 2>/dev/null )" if [ "$WGET" = "" -o "$TAR" = "" -o "$GAWK" = "" ]; then echo You must install wget, tar and gawk to use apt-cyg. exit 1 @@ -104,12 +104,17 @@ function current_cygarch () arch | sed -e 's/^i686$/x86/g' } +function mirror_to_mirrordir () +{ + echo "$1" | sed -e "s/:/%3a/g" -e "s:/:%2f:g" +} + function findworkspace() { # default working directory, mirror and architecture mirror=ftp://mirror.mcs.anl.gov/pub/cygwin - arch=`current_cygarch` + arch="$(current_cygarch)" cache=/setup # work wherever setup worked last, if possible @@ -122,10 +127,10 @@ function findworkspace() if test -e /etc/setup/last-mirror then - mirror="`head -1 /etc/setup/last-mirror`" + mirror="$(head -1 /etc/setup/last-mirror)" fi mirror="${mirror%/}" - mirrordir="`echo "$mirror/" | sed -e "s/:/%3a/g" -e "s:/:%2f:g"`" + mirrordir="$(mirror_to_mirrordir "$mirror/")" echo Working directory is $cache echo Mirror is $mirror @@ -174,9 +179,9 @@ function getrootdir () { case "$1" in x86) - cygpath -u "$(cat /proc/registry32/HKEY_LOCAL_MACHINE/SOFTWARE/Cygwin/setup/rootdir)" ;; + cygpath -u "$(< /proc/registry32/HKEY_LOCAL_MACHINE/SOFTWARE/Cygwin/setup/rootdir)" ;; x86_64) - cygpath -u "$(cat /proc/registry64/HKEY_LOCAL_MACHINE/SOFTWARE/Cygwin/setup/rootdir)" ;; + cygpath -u "$(< /proc/registry64/HKEY_LOCAL_MACHINE/SOFTWARE/Cygwin/setup/rootdir)" ;; *) echo "Error: unknown arch $1" >&2 ;; esac @@ -186,9 +191,9 @@ function getrootdir () function charch () { local rootdir - if [ "`current_cygarch`" != "$1" ]; then + if [ "$(current_cygarch)" != "$1" ]; then echo -e "\e[32;1mcharch to:\e[30;0m $1" - rootdir="`getrootdir "$1"`" + rootdir="$(getrootdir "$1")" shift chroot "$rootdir" "$rootdir/bin/bash" -lc \ 'cd "$1"; shift ; "$0" "$@"' \ @@ -542,7 +547,7 @@ function apt-cyg-show () { echo 1>&2 The following packages are installed: - cat /etc/setup/installed.db | awk '/[^ ]+ [^ ]+ 0/ {print $1}' + awk '/[^ ]+ [^ ]+ 0/ {print $1}' /etc/setup/installed.db } @@ -561,8 +566,9 @@ function apt-cyg-find () awk '/[^ ]+ [^ ]+ 0/ {if ($1 ~ query) print $1}' query="$pkg" IGNORECASE="$ignore_case" /etc/setup/installed.db echo "" echo "Searching for installable packages matching $pkg:" - cat setup.ini | awk -v query="$pkg" -v IGNORECASE="$ignore_case" \ - 'BEGIN{RS="\n\n@ "; FS="\n"; ORS="\n"} {if ($1 ~ query) {print $1}}' + awk -v query="$pkg" -v IGNORECASE="$ignore_case" \ + 'BEGIN{RS="\n\n@ "; FS="\n"; ORS="\n"} {if ($1 ~ query) {print $1}}' \ + setup.ini done } @@ -577,8 +583,9 @@ function apt-cyg-describe () getsetup for pkg do echo "" - cat setup.ini | awk -v query="$pkg" -v IGNORECASE="$ignore_case" \ - 'BEGIN{RS="\n\n@ "; FS="\n"; ORS="\n"} {if ($1 ~ query) {print $0 "\n"}}' + awk -v query="$pkg" -v IGNORECASE="$ignore_case" \ + 'BEGIN{RS="\n\n@ "; FS="\n"; ORS="\n"} {if ($1 ~ query) {print $0 "\n"}}' \ + setup.ini done } @@ -591,17 +598,17 @@ function apt-cyg-packageof () checkpackages "$@" for pkg do - local key=`which "$pkg" 2>/dev/null | sed "s:^/::"` + local key="$(which "$pkg" 2>/dev/null | sed "s:^/::")" if test "-$key-" = "--" then key="$pkg" fi for manifest in /etc/setup/*.lst.gz do - local found=`cat $manifest | gzip -d | grep -c "$key"` + local found="$(gzip -cd "$manifest" | grep -c "$key")" if test $found -gt 0 then - local package=`echo $manifest | sed -e "s:/etc/setup/::" -e "s/.lst.gz//"` + local package="$(echo $manifest | sed -e "s:/etc/setup/::" -e "s/.lst.gz//")" echo Found $key in the package $package fi done @@ -621,7 +628,7 @@ function apt-cyg-install () for pkg do - local already=`grep -c "^$pkg " /etc/setup/installed.db` + local already="$(grep -c "^$pkg " /etc/setup/installed.db)" if test $already -ge 1 then echo Package $pkg is already installed, skipping @@ -633,11 +640,11 @@ function apt-cyg-install () # look for package and save desc file mkdir -p "release/$pkg" - cat setup.ini | awk > "release/$pkg/desc" -v package="$pkg" \ + awk > "release/$pkg/desc" -v package="$pkg" \ 'BEGIN{RS="\n\n@ "; FS="\n"} {if ($1 == package) {desc = $0; px++}} \ - END {if (px == 1 && desc != "") print desc; else print "Package not found"}' - - local desc=`cat "release/$pkg/desc"` + END {if (px == 1 && desc != "") print desc; else print "Package not found"}' \ + setup.ini + local desc="$(< "release/$pkg/desc")" if test "-$desc-" = "-Package not found-" then echo Package $pkg not found or ambiguous name, exiting @@ -649,7 +656,7 @@ function apt-cyg-install () # download and unpack the bz2 file # pick the latest version, which comes first - local install=`cat "release/$pkg/desc" | awk '/^install: / { print $2; exit }'` + local install="$(awk '/^install: / { print $2; exit }' "release/$pkg/desc")" if test "-$install-" = "--" then @@ -657,13 +664,13 @@ function apt-cyg-install () exit 1 fi - local file=`basename $install` + local file="$(basename "$install")" cd "release/$pkg" "${WGET[@]}" -nc $mirror/$install # check the md5 - local digest=`cat "desc" | awk '/^install: / { print $4; exit }'` - local digactual=`md5sum $file | awk '{print $1}'` + local digest="$(awk '/^install: / { print $4; exit }' "desc")" + local digactual="$(md5sum $file | awk '{print $1}')" if ! test $digest = $digactual then echo MD5 sum did not match, exiting @@ -678,16 +685,17 @@ function apt-cyg-install () # update the package database - cat /etc/setup/installed.db | awk > /tmp/awk.$$ -v pkg="$pkg" -v bz=$file \ + awk > /tmp/awk.$$ -v pkg="$pkg" -v bz=$file \ '{if (ins != 1 && pkg < $1) {print pkg " " bz " 0"; ins=1}; print $0} \ - END{if (ins != 1) print pkg " " bz " 0"}' + END{if (ins != 1) print pkg " " bz " 0"}' \ + /etc/setup/installed.db mv /etc/setup/installed.db /etc/setup/installed.db-save mv /tmp/awk.$$ /etc/setup/installed.db # recursively install required packages - local requires=`grep "^requires: " "release/$pkg/desc" | sed -re 's/^requires: *(.*[^ ]) */\1/g' -e 's/ +/ /g'` + local requires="$(grep "^requires: " "release/$pkg/desc" | sed -re 's/^requires: *(.*[^ ]) */\1/g' -e 's/ +/ /g')" local warn=0 if ! test "-$requires-" = "--" @@ -696,7 +704,7 @@ function apt-cyg-install () echo $requires for package in $requires do - local already=`grep -c "^$package " /etc/setup/installed.db` + local already="$(grep -c "^$package " /etc/setup/installed.db)" if test $already -ge 1 then echo Package $package is already installed, skipping @@ -713,7 +721,7 @@ function apt-cyg-install () # run all postinstall scripts - local pis=`ls /etc/postinstall/*.sh 2>/dev/null | wc -l` + local pis="$(ls /etc/postinstall/*.sh 2>/dev/null | wc -l)" if test $pis -gt 0 && ! test $noscripts -eq 1 then echo Running postinstall scripts @@ -739,7 +747,7 @@ function apt-cyg-remove() checkpackages "$@" for pkg do - local already=`grep -c "^$pkg " /etc/setup/installed.db` + local already="$(grep -c "^$pkg " /etc/setup/installed.db)" if test $already = 0 then echo Package $pkg is not installed, skipping @@ -770,8 +778,8 @@ function apt-cyg-remove() "/etc/preremove/$pkg.sh" fi - cat "/etc/setup/$pkg.lst.gz" | gzip -d | awk '/[^\/]$/ {print "rm -f \"/" $0 "\""}' | sh - cat /etc/setup/installed.db | awk > /tmp/awk.$$ -v pkg="$pkg" '{if (pkg != $1) print $0}' + gzip -cd "/etc/setup/$pkg.lst.gz" | awk '/[^\/]$/ {print "rm -f \"/" $0 "\""}' | sh + awk > /tmp/awk.$$ -v pkg="$pkg" '{if (pkg != $1) print $0}' /etc/setup/installed.db rm -f "/etc/postinstall/$pkg.sh.done" "/etc/preremove/$pkg.sh" "/etc/setup/$pkg.lst.gz" mv /etc/setup/installed.db /etc/setup/installed.db-save mv /tmp/awk.$$ /etc/setup/installed.db From 20399a5fc86b9dc00eac2849d8666f0c9b98d87c Mon Sep 17 00:00:00 2001 From: kou1okada Date: Mon, 24 Feb 2014 14:33:42 +0900 Subject: [PATCH 060/309] Unified the notations of the if statement. Also fixed the notations of some other statements. --- apt-cyg | 104 ++++++++++++++++++++++---------------------------------- 1 file changed, 40 insertions(+), 64 deletions(-) diff --git a/apt-cyg b/apt-cyg index cb7eca0..9ecf5e6 100755 --- a/apt-cyg +++ b/apt-cyg @@ -119,14 +119,12 @@ function findworkspace() # work wherever setup worked last, if possible - if test -e /etc/setup/last-cache - then + if [ -e /etc/setup/last-cache ]; then cache="$(cygpath -au "$(head -1 /etc/setup/last-cache)")" fi cache="${cache%/}" - if test -e /etc/setup/last-mirror - then + if [ -e /etc/setup/last-mirror ]; then mirror="$(head -1 /etc/setup/last-mirror)" fi mirror="${mirror%/}" @@ -143,20 +141,19 @@ function findworkspace() function getsetup() { - if test "$noscripts" == "0" -a "$noupdate" == "0" - then + if [ "$noscripts" == "0" -a "$noupdate" == "0" ]; then touch setup.ini mv setup.ini setup.ini-save "${WGET[@]}" -N "$mirror/$arch/setup.bz2" "$mirror/$arch/setup.bz2.sig" - if [[ -e setup.bz2 && -e setup.bz2.sig && $? -eq 0 ]]; then - [[ "$no_verify" == "" ]] && verify_signatures setup.bz2.sig + if [ -e setup.bz2 -a -e setup.bz2.sig -a $? -eq 0 ]; then + [ -z "$no_verify" ] && verify_signatures setup.bz2.sig bunzip2 setup.bz2 mv setup setup.ini echo Updated setup.ini else "${WGET[@]}" -N "$mirror/$arch/setup.ini" "$mirror/$arch/setup.ini.sig" - if [[ -e setup.ini && -e setup.ini.sig && $? -eq 0 ]]; then - [[ "$no_verify" == "" ]] && verify_signatures setup.ini.sig + if [ -e setup.ini -a -e setup.ini.sig -a $? -eq 0 ]; then + [ -z "$no_verify" ] && verify_signatures setup.ini.sig echo Updated setup.ini else mv setup.ini-save setup.ini @@ -208,7 +205,7 @@ function init_gnupg () { [ -z "$GPG" ] && return export GNUPGHOME="$cache/.apt-cyg" - if ! [ -d "$GNUPGHOME" ]; then + if [ ! -d "$GNUPGHOME" ]; then if ! { mkdir -p "$GNUPGHOME" && chmod 700 "$GNUPGHOME"; } then echo -e "\e[31;1mError:\e[30;0m cannot initialize directory $GNUPGHOME" exit 1 @@ -218,16 +215,16 @@ function init_gnupg () } # Usage: ask_user "question?" (optional recognition of YES_TO_ALL=true auto yes) -ask_user () +function ask_user () { while true; do - [ "$2" ] && { local pmt="$2";local def=; } - [ "$2" ] || { local pmt="y/n";local def=; } + [ -n "$2" ] && { local pmt="$2"; local def=; } + [ -n "$2" ] || { local pmt="y/n";local def=; } $YES_TO_ALL && { local RPY=Y;local def=Y; } [ -z "$def" ] && { echo -ne "$1 ";read -p "[$pmt] " RPY; } - [ -z "$RPY" ] && local RPY=$def; + [ -z "$RPY" ] && { local RPY=$def; } case "$RPY" in - Y*|y*) return 0 ;; + Y*|y*) return 0 ;; N*|n*) return 1 ;; 1*) return 0 ;; 2*) return 1 ;; @@ -236,7 +233,7 @@ ask_user () } # Usage: wget_return_case_md5sum returncode -wget_return_case_md5sum () +function wget_return_case_md5sum () { case "$1" in 1) echo "$LABEL: FAILED: Could not download $URL."; return 1 ;; @@ -260,7 +257,7 @@ function wget_and_check_md5sum () local FILE="$4" "${WGET[@]}" "$URL" -O "$FILE" wget_return_case_md5sum "$?" || return 1 - if ! echo "$MD5 *$FILE" | md5sum -c >& /dev/null; then + if ! { echo "$MD5 *$FILE" | md5sum -c >& /dev/null; } then echo "$LABEL: FAILED: MD5 hash is not match." return 2 fi @@ -280,7 +277,7 @@ function fetch_trustedkeys () local URL="$(eval echo "\$${LABEL}_URL")" local URL_LATEST="$(eval echo "\$${LABEL}_URL_LATEST")" local CASE="" - if [[ -z "$force_fetch_trustedkeys" ]] && "${GPG[@]}" --fingerprint --with-colons | grep -q "$FPR"; then + if [ -z "$force_fetch_trustedkeys" ] && { "${GPG[@]}" --fingerprint --with-colons | grep -q "$FPR"; } then continue fi if [ -n "$URL" ]; then @@ -334,7 +331,7 @@ function fetch_trustedkeys () # Usage: verify_signatures files ... function verify_signatures () { - while [[ $# -gt 0 ]]; do + while [ $# -gt 0 ]; do if ! "${GPGV[@]}" "${GPG_KEYRING[@]}" "$1"; then echo "Error: BAD signature: $1" exit 1 @@ -419,8 +416,7 @@ YES_TO_ALL=false INITIAL_ARGS=( "$@" ) ARGS=() -while test $# -gt 0 -do +while [ $# -gt 0 ]; do case "$1" in --charch) @@ -495,8 +491,7 @@ do ;; --file|-f) - if ! test "-$2-" = "--" - then + if [ -n "$2" ]; then OPT_FILES+=( "$2" ) shift else @@ -518,14 +513,13 @@ do esac done -if [[ "$GPGV" == "" && "$no_verify" == "" ]]; then +if [ -z "$GPGV" -a -z "$no_verify" ]; then echo "Error: GnuPG is not installed. Prease install gnupg package or use -X option." exit 1 fi for file in "${OPT_FILES[@]}"; do - if test -f "$file" - then + if [ -f "$file" ]; then readarray -t -O ${#ARGS[@]} ARGS < "$file" else echo File $file not found, skipping @@ -599,15 +593,12 @@ function apt-cyg-packageof () checkpackages "$@" for pkg do local key="$(which "$pkg" 2>/dev/null | sed "s:^/::")" - if test "-$key-" = "--" - then + if [ -z "$key" ]; then key="$pkg" fi - for manifest in /etc/setup/*.lst.gz - do + for manifest in /etc/setup/*.lst.gz; do local found="$(gzip -cd "$manifest" | grep -c "$key")" - if test $found -gt 0 - then + if [ $found -gt 0 ]; then local package="$(echo $manifest | sed -e "s:/etc/setup/::" -e "s/.lst.gz//")" echo Found $key in the package $package fi @@ -629,8 +620,7 @@ function apt-cyg-install () for pkg do local already="$(grep -c "^$pkg " /etc/setup/installed.db)" - if test $already -ge 1 - then + if [ $already -ge 1 ]; then echo Package $pkg is already installed, skipping continue fi @@ -645,8 +635,7 @@ function apt-cyg-install () END {if (px == 1 && desc != "") print desc; else print "Package not found"}' \ setup.ini local desc="$(< "release/$pkg/desc")" - if test "-$desc-" = "-Package not found-" - then + if [ "$desc" = "Package not found" ]; then echo Package $pkg not found or ambiguous name, exiting rm -r "release/$pkg" exit 1 @@ -658,8 +647,7 @@ function apt-cyg-install () # pick the latest version, which comes first local install="$(awk '/^install: / { print $2; exit }' "release/$pkg/desc")" - if test "-$install-" = "--" - then + if [ -z "$install" ]; then echo "Could not find \"install\" in package description: obsolete package?" exit 1 fi @@ -671,8 +659,7 @@ function apt-cyg-install () # check the md5 local digest="$(awk '/^install: / { print $4; exit }' "desc")" local digactual="$(md5sum $file | awk '{print $1}')" - if ! test $digest = $digactual - then + if [ "$digest" != "$digactual" ]; then echo MD5 sum did not match, exiting exit 1 fi @@ -698,35 +685,29 @@ function apt-cyg-install () local requires="$(grep "^requires: " "release/$pkg/desc" | sed -re 's/^requires: *(.*[^ ]) */\1/g' -e 's/ +/ /g')" local warn=0 - if ! test "-$requires-" = "--" - then + if [ -z "$requires" ]; then echo Package $pkg requires the following packages, installing: echo $requires - for package in $requires - do + for package in $requires; do local already="$(grep -c "^$package " /etc/setup/installed.db)" - if test $already -ge 1 - then + if [ $already -ge 1 ]; then echo Package $package is already installed, skipping continue fi apt-cyg --noscripts install $package - if ! test $? = 0 ; then warn=1; fi + if [ $? -ne 0 ]; then warn=1; fi done fi - if ! test $warn = 0 - then + if [ $warn -nq 0 ]; then echo "Warning: some required packages did not install, continuing" fi # run all postinstall scripts local pis="$(ls /etc/postinstall/*.sh 2>/dev/null | wc -l)" - if test $pis -gt 0 && ! test $noscripts -eq 1 - then + if [ $pis -gt 0 -a "$noscripts" -ne 1 ]; then echo Running postinstall scripts - for script in /etc/postinstall/*.sh - do + for script in /etc/postinstall/*.sh; do $script mv $script $script.done done @@ -748,24 +729,20 @@ function apt-cyg-remove() for pkg do local already="$(grep -c "^$pkg " /etc/setup/installed.db)" - if test $already = 0 - then + if [ $already -eq 0 ]; then echo Package $pkg is not installed, skipping continue fi local dontremove="cygwin coreutils gawk bzip2 tar xz wget bash" - for req in $dontremove - do - if test "-$pkg-" = "-$req-" - then + for req in $dontremove; do + if [ "$pkg" = "$req" ]; then echo apt-cyg cannot remove package $pkg, exiting exit 1 fi done - if test ! -e "/etc/setup/$pkg.lst.gz" -a "$force_remove" = "" - then + if [ ! -e "/etc/setup/$pkg.lst.gz" -a "$force_remove" = "" ]; then echo Package manifest missing, cannot remove $pkg. Exiting exit 1 fi @@ -773,8 +750,7 @@ function apt-cyg-remove() # run preremove scripts - if test -e "/etc/preremove/$pkg.sh" - then + if [ -e "/etc/preremove/$pkg.sh" ]; then "/etc/preremove/$pkg.sh" fi From c851d65fee51c5fa84da6256609d3dec5db9c9b0 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Mon, 24 Feb 2014 18:24:54 +0900 Subject: [PATCH 061/309] Unified the notations of the if statement. Also fixed the notations of some other statements. --- apt-cyg | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/apt-cyg b/apt-cyg index 9ecf5e6..4e23166 100755 --- a/apt-cyg +++ b/apt-cyg @@ -51,7 +51,7 @@ TAR="$( which tar 2>/dev/null )" GAWK="$( which awk 2>/dev/null )" GPGV="$( which gpgv 2>/dev/null )" GPG="$( which gpg 2>/dev/null )" -if [ "$WGET" = "" -o "$TAR" = "" -o "$GAWK" = "" ]; then +if [ -z "$WGET" -o -z "$TAR" -o -z "$GAWK" ]; then echo You must install wget, tar and gawk to use apt-cyg. exit 1 fi @@ -141,7 +141,7 @@ function findworkspace() function getsetup() { - if [ "$noscripts" == "0" -a "$noupdate" == "0" ]; then + if [ $noscripts -eq 0 -a $noupdate -eq 0 ]; then touch setup.ini mv setup.ini setup.ini-save "${WGET[@]}" -N "$mirror/$arch/setup.bz2" "$mirror/$arch/setup.bz2.sig" @@ -215,7 +215,7 @@ function init_gnupg () } # Usage: ask_user "question?" (optional recognition of YES_TO_ALL=true auto yes) -function ask_user () +function ask_user () { while true; do [ -n "$2" ] && { local pmt="$2"; local def=; } @@ -705,7 +705,7 @@ function apt-cyg-install () # run all postinstall scripts local pis="$(ls /etc/postinstall/*.sh 2>/dev/null | wc -l)" - if [ $pis -gt 0 -a "$noscripts" -ne 1 ]; then + if [ $pis -gt 0 -a $noscripts -ne 1 ]; then echo Running postinstall scripts for script in /etc/postinstall/*.sh; do $script @@ -742,7 +742,7 @@ function apt-cyg-remove() fi done - if [ ! -e "/etc/setup/$pkg.lst.gz" -a "$force_remove" = "" ]; then + if [ ! -e "/etc/setup/$pkg.lst.gz" -a -z "$force_remove" ]; then echo Package manifest missing, cannot remove $pkg. Exiting exit 1 fi From c78babde262644451bc984b93920fbc8a074cfc0 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Tue, 25 Feb 2014 18:44:48 +0900 Subject: [PATCH 062/309] Fixed miss typing. --- apt-cyg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apt-cyg b/apt-cyg index 4e23166..6bcf87b 100755 --- a/apt-cyg +++ b/apt-cyg @@ -698,7 +698,7 @@ function apt-cyg-install () if [ $? -ne 0 ]; then warn=1; fi done fi - if [ $warn -nq 0 ]; then + if [ $warn -ne 0 ]; then echo "Warning: some required packages did not install, continuing" fi From 11cce3fed507b928342f1ddf46343af492488b93 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Sun, 2 Mar 2014 14:42:40 +0900 Subject: [PATCH 063/309] Colorized error messages. --- apt-cyg | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/apt-cyg b/apt-cyg index 6bcf87b..ea19712 100755 --- a/apt-cyg +++ b/apt-cyg @@ -157,7 +157,7 @@ function getsetup() echo Updated setup.ini else mv setup.ini-save setup.ini - echo Error updating setup.ini, reverting + echo -e "\e[31;1mError:\e[30;0m updating setup.ini, reverting" fi fi fi @@ -180,7 +180,7 @@ function getrootdir () x86_64) cygpath -u "$(< /proc/registry64/HKEY_LOCAL_MACHINE/SOFTWARE/Cygwin/setup/rootdir)" ;; *) - echo "Error: unknown arch $1" >&2 ;; + echo -e "\e[31;1mError:\e[30;0m unknown arch $1" >&2 ;; esac } @@ -244,7 +244,7 @@ function wget_return_case_md5sum () ;; 8) echo "$LABEL: FAILED: 404 Not Found $URL." return 1 ;; 0) return 0 ;; - *) echo "Error: FATAL: wget returned unkown value"; return 1 ;; + *) echo -e "\e[31;1mError:\e[30;0m FATAL: wget returned unkown value"; return 1 ;; esac } @@ -304,23 +304,23 @@ function fetch_trustedkeys () "${GPG[@]}" --import "$FILE_LATEST" ;; 10|20) - echo "Error: ${LABEL} has miss configuration." + echo -e "\e[31;1mError:\e[30;0m ${LABEL} has miss configuration." exit 1 ;; 11|1-|-1) - echo "Error: Could not download ${LABEL}." + echo -e "\e[31;1mError:\e[30;0m Could not download ${LABEL}." exit 1 ;; 12|-2) - echo "Error: ${LABEL} has been updated, maybe. But sometimes it may has been cracked. Be careful !!!" + echo -e "\e[31;1mError:\e[30;0m ${LABEL} has been updated, maybe. But sometimes it may has been cracked. Be careful !!!" exit 1 ;; 21|22|2-) - echo "Error: ${LABEL} has been cracked, maybe" + echo -e "\e[31;1mError:\e[30;0m ${LABEL} has been cracked, maybe" exit 1 ;; --) - echo "Error: ${LABEL} has no URL." + echo -e "\e[31;1mError:\e[30;0m ${LABEL} has no URL." exit 1 ;; esac @@ -333,7 +333,7 @@ function verify_signatures () { while [ $# -gt 0 ]; do if ! "${GPGV[@]}" "${GPG_KEYRING[@]}" "$1"; then - echo "Error: BAD signature: $1" + echo -e "\e[31;1mError:\e[30;0m BAD signature: $1" exit 1 fi shift @@ -343,7 +343,7 @@ function verify_signatures () # Usage: apt-cyg-key-add pkey ... function apt-cyg-key-add () { - [ -z "$GPG" ] && { echo "Error: GnuPG is not installed. Prease install gnupg package"; exit 1; } + [ -z "$GPG" ] && { echo -e "\e[31;1mError:\e[30;0m GnuPG is not installed. Prease install gnupg package"; exit 1; } local pkeys for pkey; do pkeys+=( "$(cygpath -a "$pkey" )" ) @@ -357,7 +357,7 @@ function apt-cyg-key-add () # Usage: apt-cyg-key-add keyid ... function apt-cyg-key-del () { - [ -z "$GPG" ] && { echo "Error: GnuPG is not installed. Prease install gnupg package"; exit 1; } + [ -z "$GPG" ] && { echo -e "\e[31;1mError:\e[30;0m GnuPG is not installed. Prease install gnupg package"; exit 1; } local keyid findworkspace for keyid; do @@ -367,14 +367,14 @@ function apt-cyg-key-del () function apt-cyg-key-list () { - [ -z "$GPG" ] && { echo "Error: GnuPG is not installed. Prease install gnupg package"; exit 1; } + [ -z "$GPG" ] && { echo -e "\e[31;1mError:\e[30;0m GnuPG is not installed. Prease install gnupg package"; exit 1; } findworkspace "${GPG[@]}" --list-keys } function apt-cyg-key-finger () { - [ -z "$GPG" ] && { echo "Error: GnuPG is not installed. Prease install gnupg package"; exit 1; } + [ -z "$GPG" ] && { echo -e "\e[31;1mError:\e[30;0m GnuPG is not installed. Prease install gnupg package"; exit 1; } findworkspace "${GPG[@]}" --fingerprint } @@ -390,7 +390,7 @@ function apt-cyg-pathof () cache/mirrordir) echo "$cache/$mirrordir" ;; setup.ini) echo "$cache/$mirrordir/$arch/setup.ini" ;; *) - echo -e "\e[31;1mError: in function $FUNCNAME: \e[30;0m unknown parameter '$1'." + echo -e "\e[31;1mError:\e[30;0m in function $FUNCNAME: unknown parameter: $1" exit 1 esac shift @@ -514,7 +514,7 @@ while [ $# -gt 0 ]; do done if [ -z "$GPGV" -a -z "$no_verify" ]; then - echo "Error: GnuPG is not installed. Prease install gnupg package or use -X option." + echo -e "\e[31;1mError:\e[30;0m GnuPG is not installed. Prease install gnupg package or use -X option." exit 1 fi @@ -773,7 +773,7 @@ function invoke_subcommand () if type "$ACTION" >& /dev/null; then "$ACTION" "${ARGS[@]}" else - echo -e "\e[31;1mError: \e[30;0m unknown subcommand '$SUBCOMMAND'." + echo -e "\e[31;1mError:\e[30;0m unknown subcommand: $SUBCOMMAND" exit 1 fi } From 7cefa161be2a5fecd053011fee7be6162934528b Mon Sep 17 00:00:00 2001 From: kou1okada Date: Mon, 3 Mar 2014 04:25:03 +0900 Subject: [PATCH 064/309] Refactoring: getsetup. setup.ini, setup.ini.sig, setup.bz2, and setup.bz2.sig became cacheable. --- apt-cyg | 87 ++++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 65 insertions(+), 22 deletions(-) diff --git a/apt-cyg b/apt-cyg index ea19712..9e28426 100755 --- a/apt-cyg +++ b/apt-cyg @@ -139,28 +139,71 @@ function findworkspace() fetch_trustedkeys } -function getsetup() -{ - if [ $noscripts -eq 0 -a $noupdate -eq 0 ]; then - touch setup.ini - mv setup.ini setup.ini-save - "${WGET[@]}" -N "$mirror/$arch/setup.bz2" "$mirror/$arch/setup.bz2.sig" - if [ -e setup.bz2 -a -e setup.bz2.sig -a $? -eq 0 ]; then - [ -z "$no_verify" ] && verify_signatures setup.bz2.sig - bunzip2 setup.bz2 - mv setup setup.ini - echo Updated setup.ini - else - "${WGET[@]}" -N "$mirror/$arch/setup.ini" "$mirror/$arch/setup.ini.sig" - if [ -e setup.ini -a -e setup.ini.sig -a $? -eq 0 ]; then - [ -z "$no_verify" ] && verify_signatures setup.ini.sig - echo Updated setup.ini - else - mv setup.ini-save setup.ini - echo -e "\e[31;1mError:\e[30;0m updating setup.ini, reverting" - fi - fi +function download_and_varify () +{ + "${WGET[@]}" -N "$1" || return 1 + [ -e "${1##*/}" ] || return 1 + if [ -z "$no_verify" ]; then + "${WGET[@]}" -N "${1}.sig" || return 1 + [ -e "${1##*/}.sig" ] && verify_signatures "${1##*/}.sig" || { rm -f "${1##*/}" "${1##*/}.sig"; return 1; } fi + return +} + +function files_backup () +{ + locale file + for file; do + [ -e "${file}~" ] && mv "${file}~" "${file}" + [ -e "${file}" ] && cp -a "${file}" "${file}~" + done +} + +function files_restore () +{ + locale file + for file; do + [ -e "${file}" ] && rm "${file}" + [ -e "${file}~" ] && mv "${file}~" "${file}" + done +} + +function files_backup_clean () +{ + locale file + for file; do + [ -e "${file}~" ] && rm "${file}~" + done +} + +function setupini_download () +{ + local BASEDIR="$cache/$mirrordir/$arch" + mkdir -p "$BASEDIR" || { echo -e "\e[31;1mError:\e[30;0m mkdir \"$BASEDIR\" failed."; exit 1; } + + [ $noscripts -ne 0 -o $noupdate -ne 0 ] && return + + pushd "$BASEDIR" + files_backup setup.ini setup.ini.sig setup.bz2 setup.bz2.sig + + while true; do + download_and_varify "$mirror/$arch/setup.bz2" && { bunzip2 -k setup.bz2 && mv setup setup.ini || rm -f setup.bz2; } + download_and_varify "$mirror/$arch/setup.ini" || break + + files_backup_clean setup.ini setup.ini.sig setup.bz2 setup.bz2.sig + popd + echo "Updated setup.ini" + return + done + files_restore setup.ini setup.ini.sig setup.bz2 setup.bz2.sig + popd + echo -e "\e[31;1mError:\e[30;0m updating setup.ini, reverting." + return 1 +} + +function getsetup () +{ + setupini_download || return 1 } function checkpackages() @@ -334,7 +377,7 @@ function verify_signatures () while [ $# -gt 0 ]; do if ! "${GPGV[@]}" "${GPG_KEYRING[@]}" "$1"; then echo -e "\e[31;1mError:\e[30;0m BAD signature: $1" - exit 1 + return 1 fi shift done From a0284ba02084651e59336bd9f821935ccad46cc9 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Mon, 3 Mar 2014 05:20:57 +0900 Subject: [PATCH 065/309] Fixed a wrong comment. --- apt-cyg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apt-cyg b/apt-cyg index 9e28426..a25b179 100755 --- a/apt-cyg +++ b/apt-cyg @@ -291,7 +291,7 @@ function wget_return_case_md5sum () esac } -# Usage: check_md5sum label hash url file +# Usage: wget_and_check_md5sum label hash url file function wget_and_check_md5sum () { local LABEL="$1" From c9a857826a23fcedbb79618020cd40f8d4eabbf2 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Fri, 11 Apr 2014 10:45:43 +0900 Subject: [PATCH 066/309] Bugfix: Package dependencies checker was corrupted. --- apt-cyg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apt-cyg b/apt-cyg index a25b179..71c37d3 100755 --- a/apt-cyg +++ b/apt-cyg @@ -728,7 +728,7 @@ function apt-cyg-install () local requires="$(grep "^requires: " "release/$pkg/desc" | sed -re 's/^requires: *(.*[^ ]) */\1/g' -e 's/ +/ /g')" local warn=0 - if [ -z "$requires" ]; then + if [ -n "$requires" ]; then echo Package $pkg requires the following packages, installing: echo $requires for package in $requires; do From 0aa17239c9cb0c8eaf3c08a6e02eabeb8b4d4285 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Fri, 11 Apr 2014 13:02:18 +0900 Subject: [PATCH 067/309] Add upgrade-self subcommand. --- apt-cyg | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/apt-cyg b/apt-cyg index 71c37d3..3710594 100755 --- a/apt-cyg +++ b/apt-cyg @@ -72,6 +72,7 @@ function usage() echo " \"apt-cyg key-del ...\" to remove keys " echo " \"apt-cyg key-list\" to list keys" echo " \"apt-cyg key-finger\" to list fingerprints" + echo " \"apt-cyg upgrade-self\" to upgrade apt-cyg" echo "Options:" echo " --charch : change archetecture" echo " --use-setuprc : set cache and mirror with /etc/setup/setup.rc" @@ -440,6 +441,19 @@ function apt-cyg-pathof () done } +function apt-cyg-upgrade-self () +{ + local basedir="$(dirname "$(readlink -f "$(which "$0")")")" + if [ ! -d "$basedir/.git" ]; then + echo -e "\e[31;1mError:\e[30;0m apt-get is not under the git version control." + exit 1 + fi + pushd "$basedir" + git pull -v + popd +} + + function apt-cyg-help () { usage From 0ab321c0ab2c756266dd696e0116635651f1c1ba Mon Sep 17 00:00:00 2001 From: kou1okada Date: Tue, 29 Apr 2014 11:44:55 +0900 Subject: [PATCH 068/309] Fixed misspelling. --- apt-cyg | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apt-cyg b/apt-cyg index 3710594..8437f88 100755 --- a/apt-cyg +++ b/apt-cyg @@ -140,7 +140,7 @@ function findworkspace() fetch_trustedkeys } -function download_and_varify () +function download_and_verify () { "${WGET[@]}" -N "$1" || return 1 [ -e "${1##*/}" ] || return 1 @@ -188,8 +188,8 @@ function setupini_download () files_backup setup.ini setup.ini.sig setup.bz2 setup.bz2.sig while true; do - download_and_varify "$mirror/$arch/setup.bz2" && { bunzip2 -k setup.bz2 && mv setup setup.ini || rm -f setup.bz2; } - download_and_varify "$mirror/$arch/setup.ini" || break + download_and_verify "$mirror/$arch/setup.bz2" && { bunzip2 -k setup.bz2 && mv setup setup.ini || rm -f setup.bz2; } + download_and_verify "$mirror/$arch/setup.ini" || break files_backup_clean setup.ini setup.ini.sig setup.bz2 setup.bz2.sig popd From cfcb150d218d672c49197d577b78875f93808ff8 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Sun, 4 May 2014 11:01:15 +0900 Subject: [PATCH 069/309] Add --proxy, -p option. --- README.md | 16 ++++++++++++++++ apt-cyg | 49 ++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 64 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 30985d2..e62f298 100644 --- a/README.md +++ b/README.md @@ -78,6 +78,22 @@ Of course you can also avoid signature check by using --no-verify or -X options. Public keys of cygwin and cygwinports are already registered to trusted keys of embeded. If you want to use some other public keys, please use key-* subcommands. +### Proxy support + +Use --proxy, -p option. +This option must take a parameter from one of "auto", "inherit", "none" and URL. + +* "auto" will determine a proxy using a part of the [Web Proxy Autodiscovery Protocol](http://en.wikipedia.org/wiki/Web_Proxy_Autodiscovery_Protocol). +The current implementation will look for a string of "PROXY URL" from "http://wpad/wpad.dat". +If "wpad.dat" could not be downloaded, the proxy settings are inherited from the parent environment. +* "inherit" will inherit the proxy settings from the parent environment. +* "none" will not use the proxy. +* URL can take a string like "protocol://hostname:port". + +For example: + + # apt-cyg --proxy http://proxy.home:8080 update + Contributing ------------ diff --git a/apt-cyg b/apt-cyg index 8437f88..6fbdbd6 100755 --- a/apt-cyg +++ b/apt-cyg @@ -81,6 +81,7 @@ function usage() echo " --force-fetch-trustedkeys: force fetch trustedkeys" echo " --no-verify, -X : Don't verify setup.ini signatures" echo " --no-check-certificate : Don't validate the server's certificate" + echo " --proxy, -p : set proxy (default: auto)" echo " --mirror, -m : set mirror" echo " --cache, -c : set cache" echo " --file, -f : read package names from file" @@ -453,6 +454,45 @@ function apt-cyg-upgrade-self () popd } +function proxy_auto () +{ + local proxy=$("${WGET[@]}" --no-proxy -q -O - wpad/wpad.dat \ + | grep PROXY \ + | sed -e 's/^.*PROXY\s*\([^"]*\).*$/http:\/\/\1/g') + + [ -n "$proxy" ] && proxy_set "$proxy" +} + +function proxy_set () +{ + export http_proxy="$1" + export https_proxy="$1" + export ftp_proxy="$1" +} + +function proxy_unset () +{ + export -n http_proxy + export -n https_proxy + export -n ftp_proxy +} + +function proxy_setup () +{ + case "$OPT_PROXY" in + auto) + proxy_auto + ;; + inherit) + ;; + none) + proxy_unset + ;; + *) + proxy_set "$OPT_PROXY" + ;; + esac +} function apt-cyg-help () { @@ -469,6 +509,7 @@ ignore_case="" force_remove="" force_fetch_trustedkeys="" no_verify="" +OPT_PROXY="auto" YES_TO_ALL=false INITIAL_ARGS=( "$@" ) ARGS=() @@ -512,6 +553,11 @@ while [ $# -gt 0 ]; do shift ;; + --proxy|-p) + OPT_PROXY="$2" + shift 2 + ;; + --mirror|-m) echo "${2%/}/" > /etc/setup/last-mirror shift ; shift @@ -751,7 +797,7 @@ function apt-cyg-install () echo Package $package is already installed, skipping continue fi - apt-cyg --noscripts install $package + apt-cyg --proxy inherit --noscripts install $package if [ $? -ne 0 ]; then warn=1; fi done fi @@ -835,5 +881,6 @@ function invoke_subcommand () fi } +proxy_setup invoke_subcommand "$SUBCOMMAND" "${ARGS[@]}" From a72d46e78287c0cb9e3ba02f1526285d221553fc Mon Sep 17 00:00:00 2001 From: kou1okada Date: Tue, 6 May 2014 01:12:36 +0900 Subject: [PATCH 070/309] Refactoring: "installed.db" handling is separated to functions. --- apt-cyg | 94 ++++++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 77 insertions(+), 17 deletions(-) diff --git a/apt-cyg b/apt-cyg index 6fbdbd6..7d62dbd 100755 --- a/apt-cyg +++ b/apt-cyg @@ -494,6 +494,76 @@ function proxy_setup () esac } +# PACKAGE_DB is defined at package_db.cc in the cygwin-app setup.exe +# See blow: +# https://www.sourceware.org/cygwin-apps/setup.html +# https://sourceware.org/cgi-bin/cvsweb.cgi/setup/package_db.cc?cvsroot=cygwin-apps +PACKAGE_DB="/etc/setup/installed.db" + +function package_db-version_check () +{ + local ver2hdr="INSTALLED.DB 2" + + if head -n1 "${PACKAGE_DB}" | grep -Fqvx "${ver2hdr}"; then + echo -e "\e[33;1mWarning:\e[30;0m ${PACKAGE_DB} is not version 2. The first line is below:" + echo -e "$(head -n1 "${PACKAGE_DB}")\n" >&2 + + # The previous version of apt-cyg was not treat version header correctly. + if grep -FHnx "${ver2hdr}" "${PACKAGE_DB}" >&2; then + echo -e "The above line looks like version header, but it is not the first line.\n" >&2 + fi + fi +} + +# Usage: package_db-is_registered PKGNAME +function package_db-is_registered () +{ + package_db-version_check + + awk ' + $1 == PKGNAME && NF != 2 {found = 1; exit} + END {exit !found} + ' PKGNAME="$1" "${PACKAGE_DB}" +} + +function package_db-list () +{ + package_db-version_check + + awk 'NF == 3 {print $1}' "${PACKAGE_DB}" +} + +# Usage: package_db-register PKGNAME PKGFILE +function package_db-register () +{ + local work="/tmp/apt-cyg.$$.${PACKAGE_DB##*/}" + + package_db-version_check + + awk ' + function register() {print PKGNAME " " PKGFILE " 0"; registered = 1;} + !registered && PKGNAME < $1 && NF != 2 {register()} + {print $0} + END {if (!registered) register()} + ' PKGNAME="$1" PKGFILE="$2" "${PACKAGE_DB}" > "${work}" + + mv "${PACKAGE_DB}" "${PACKAGE_DB}-save" + mv "${work}" "${PACKAGE_DB}" +} + +# Usage: package_db-unregister PKGNAME +function package_db-unregister () +{ + local work="/tmp/apt-cyg.$$.${PACKAGE_DB##*/}" + + package_db-version_check + + awk '!(PKGNAME == $1 && NF != 2) {print $0}' PKGNAME="$1" "${PACKAGE_DB}" > "${work}" + + mv "${PACKAGE_DB}" "${PACKAGE_DB}-save" + mv "${work}" "${PACKAGE_DB}" +} + function apt-cyg-help () { usage @@ -644,7 +714,7 @@ function apt-cyg-show () { echo 1>&2 The following packages are installed: - awk '/[^ ]+ [^ ]+ 0/ {print $1}' /etc/setup/installed.db + package_db-list } @@ -660,7 +730,7 @@ function apt-cyg-find () for pkg do echo "" echo "Searching for installed packages matching $pkg:" - awk '/[^ ]+ [^ ]+ 0/ {if ($1 ~ query) print $1}' query="$pkg" IGNORECASE="$ignore_case" /etc/setup/installed.db + package_db-list | awk '$1~query{print $1}' query="$pkg" IGNORECASE="$ignore_case" echo "" echo "Searching for installable packages matching $pkg:" awk -v query="$pkg" -v IGNORECASE="$ignore_case" \ @@ -722,8 +792,7 @@ function apt-cyg-install () for pkg do - local already="$(grep -c "^$pkg " /etc/setup/installed.db)" - if [ $already -ge 1 ]; then + if package_db-is_registered "$pkg"; then echo Package $pkg is already installed, skipping continue fi @@ -775,12 +844,7 @@ function apt-cyg-install () # update the package database - awk > /tmp/awk.$$ -v pkg="$pkg" -v bz=$file \ - '{if (ins != 1 && pkg < $1) {print pkg " " bz " 0"; ins=1}; print $0} \ - END{if (ins != 1) print pkg " " bz " 0"}' \ - /etc/setup/installed.db - mv /etc/setup/installed.db /etc/setup/installed.db-save - mv /tmp/awk.$$ /etc/setup/installed.db + package_db-register "$pkg" "$file" # recursively install required packages @@ -792,8 +856,7 @@ function apt-cyg-install () echo Package $pkg requires the following packages, installing: echo $requires for package in $requires; do - local already="$(grep -c "^$package " /etc/setup/installed.db)" - if [ $already -ge 1 ]; then + if package_db-is_registered "$pkg"; then echo Package $package is already installed, skipping continue fi @@ -831,8 +894,7 @@ function apt-cyg-remove() checkpackages "$@" for pkg do - local already="$(grep -c "^$pkg " /etc/setup/installed.db)" - if [ $already -eq 0 ]; then + if ! package_db-is_registered "$pkg"; then echo Package $pkg is not installed, skipping continue fi @@ -858,10 +920,8 @@ function apt-cyg-remove() fi gzip -cd "/etc/setup/$pkg.lst.gz" | awk '/[^\/]$/ {print "rm -f \"/" $0 "\""}' | sh - awk > /tmp/awk.$$ -v pkg="$pkg" '{if (pkg != $1) print $0}' /etc/setup/installed.db rm -f "/etc/postinstall/$pkg.sh.done" "/etc/preremove/$pkg.sh" "/etc/setup/$pkg.lst.gz" - mv /etc/setup/installed.db /etc/setup/installed.db-save - mv /tmp/awk.$$ /etc/setup/installed.db + package_db-unregister "$pkg" echo Package $pkg removed done From 8dd6ac273a24f897391b39e2f3c3b4999c46f6d4 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Tue, 6 May 2014 03:27:36 +0900 Subject: [PATCH 071/309] Add depends and rdepends subcommand. --- apt-cyg | 92 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) diff --git a/apt-cyg b/apt-cyg index 7d62dbd..c5ca6dd 100755 --- a/apt-cyg +++ b/apt-cyg @@ -73,6 +73,10 @@ function usage() echo " \"apt-cyg key-list\" to list keys" echo " \"apt-cyg key-finger\" to list fingerprints" echo " \"apt-cyg upgrade-self\" to upgrade apt-cyg" + echo " \"apt-cyg depends \"" + echo " to show forward dependency information for packages with depth." + echo " \"apt-cyg rdepends \"" + echo " to show reverse dependency information for packages with depth." echo "Options:" echo " --charch : change archetecture" echo " --use-setuprc : set cache and mirror with /etc/setup/setup.rc" @@ -564,6 +568,94 @@ function package_db-unregister () mv "${work}" "${PACKAGE_DB}" } +# Usage: dep_check_single DIR ROOTPKG +# Parameters: +# DIR is "depends" or "rdepends". +# ROOTPKG is a root package name to check dependency. +# Return: +# package_name available shallow_depth deep_depth +function dep_check_single () +{ + awk \ + ' + function update_result(dir, rootpkg, pkg, depth, _, i) { + if (0 + result[rootpkg, pkg, "deep"]) { + result[rootpkg, pkg, "deep"] = depth; + } else { + result[rootpkg, pkg, "deep"] = result[rootpkg, pkg, "shallow"] = depth; + result[rootpkg, pkg, "available"] = 0 + available[pkg]; + result[rootpkg, result[rootpkg, "n"]++] = pkg; + for (i = 0; i < dep[dir, pkg, "n"]; i++) { + update_result(dir, rootpkg, dep[dir, pkg, i], depth + 1); + } + } + } + $1 == "@" { + pkg = $2; + available[pkg] = 1; + } + $1 == "requires:" { + for (req = 2; req <= NF; req++) { + dep["rdepends", $req, dep["rdepends", $req, "n"]++] = pkg; + dep["depends" , pkg , dep["depends" , pkg , "n"]++] = $req; + } + } + END { + update_result(DIR, ROOTPKG, ROOTPKG, 1); + for(i = 0; i < result[ROOTPKG, "n"]; i++) { + printf("%-40s %d\t%d\t%d\n", + result[ROOTPKG, i], + result[ROOTPKG, result[ROOTPKG, i], "available"], + result[ROOTPKG, result[ROOTPKG, i], "shallow"], + result[ROOTPKG, result[ROOTPKG, i], "deep"]); + } + } + ' \ + DIR="$1" ROOTPKG="$2" "$(apt-cyg-pathof "setup.ini")" | sort -nrk4 +} + +function dep_check () +{ + local pkg + local dir="$1" + shift + for pkg; do + dep_check_single "$dir" "$pkg" + done | awk ' + function min(x,y) {return x < y ? x : y} + function max(x,y) {return x < y ? y : x} + { + packages[$1] = pkg = $1; + status[pkg, "available"] = $2; + status[pkg, "shallow" ] = 0 + status[pkg, "shallow"] == 0 ? $3 : min(status[pkg, "shallow"], $3); + status[pkg, "deep" ] = max(0 + status[pkg, "deep"], $4); + } + END { + for (pkg in packages) { + printf("%-40s %d\t%d\t%d\n", + pkg, + status[pkg, "available"], + status[pkg, "shallow"], + status[pkg, "deep"]) + } + } + ' | sort -nrk4 +} + +function apt-cyg-depends () +{ + local pkg + printf "%-40s %s\t%s\t%s\n" "PKGNAME" "AVAIL" "SHALLOW" "DEEP" + dep_check depends "$@" +} + +function apt-cyg-rdepends () +{ + local pkg + printf "%-40s %s\t%s\t%s\n" "PKGNAME" "AVAIL" "SHALLOW" "DEEP" + dep_check rdepends "$@" +} + function apt-cyg-help () { usage From d35cdbf614704984bc1b4707c5b86e138436f98f Mon Sep 17 00:00:00 2001 From: kou1okada Date: Tue, 6 May 2014 04:00:54 +0900 Subject: [PATCH 072/309] Update README.md --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index e62f298..ed571c9 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,9 @@ apt-cyg is a command-line installer for [Cygwin](http://cygwin.com/) which coope * "apt-cyg key-del <keyids> ..." to remove keys <keyids> * "apt-cyg key-list" to list keys * "apt-cyg key-finger" to list fingerprints +* "apt-cyg upgrade-self" to upgrade apt-cyg +* "apt-cyg depends <package names>" to show forward dependency information for packages with depth. +* "apt-cyg rdepends <package names>" to show reverse dependency information for packages with depth. Requirements ----------- From 8993e2ce355639aec0041e1aa517e5dd6f5a973b Mon Sep 17 00:00:00 2001 From: kou1okada Date: Tue, 6 May 2014 14:26:52 +0900 Subject: [PATCH 073/309] Modified the default parameter for --proxy option from "auto" to "${APT_CYG_PROXY:-auto}". --- README.md | 8 +++++++- apt-cyg | 5 +++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index ed571c9..23e635f 100644 --- a/README.md +++ b/README.md @@ -86,7 +86,7 @@ If you want to use some other public keys, please use key-* subcommands. Use --proxy, -p option. This option must take a parameter from one of "auto", "inherit", "none" and URL. -* "auto" will determine a proxy using a part of the [Web Proxy Autodiscovery Protocol](http://en.wikipedia.org/wiki/Web_Proxy_Autodiscovery_Protocol). +* "auto" will determine a proxy using a part of the [Web Proxy Auto-Discovery Protocol (WPAD)](http://en.wikipedia.org/wiki/Web_Proxy_Autodiscovery_Protocol). The current implementation will look for a string of "PROXY URL" from "http://wpad/wpad.dat". If "wpad.dat" could not be downloaded, the proxy settings are inherited from the parent environment. * "inherit" will inherit the proxy settings from the parent environment. @@ -97,6 +97,12 @@ For example: # apt-cyg --proxy http://proxy.home:8080 update +The default parameter is "${APT\_CYG\_PROXY:-auto}". +At the environment where is not provided the WPAD server, it makes the lag for a few seconds at startup. +So, if you don't want to use WPAD, please define APT\_CYG\_PROXY environment variable as below: + + # export APT_CYG_PROXY=none + Contributing ------------ diff --git a/apt-cyg b/apt-cyg index c5ca6dd..8242585 100755 --- a/apt-cyg +++ b/apt-cyg @@ -85,7 +85,8 @@ function usage() echo " --force-fetch-trustedkeys: force fetch trustedkeys" echo " --no-verify, -X : Don't verify setup.ini signatures" echo " --no-check-certificate : Don't validate the server's certificate" - echo " --proxy, -p : set proxy (default: auto)" + echo " --proxy, -p :" + echo " set proxy (default: \${APT_CYG_PROXY:-auto})" echo " --mirror, -m : set mirror" echo " --cache, -c : set cache" echo " --file, -f : read package names from file" @@ -671,7 +672,7 @@ ignore_case="" force_remove="" force_fetch_trustedkeys="" no_verify="" -OPT_PROXY="auto" +OPT_PROXY=${APT_CYG_PROXY:-auto} YES_TO_ALL=false INITIAL_ARGS=( "$@" ) ARGS=() From 21b204751cb91309dca2dd99ee1b660b3e3912bc Mon Sep 17 00:00:00 2001 From: kou1okada Date: Tue, 6 May 2014 14:35:22 +0900 Subject: [PATCH 074/309] Update README.md --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 23e635f..e22814d 100644 --- a/README.md +++ b/README.md @@ -51,13 +51,13 @@ Quick start apt-cyg is a simple script. Once you have a copy, make it executable: - # chmod +x /bin/apt-cyg + chmod +x /bin/apt-cyg Optionally place apt-cyg in a bin/ folder on your path. Then use apt-cyg, for example: - # apt-cyg install nano + apt-cyg install nano New features ------------ @@ -67,7 +67,7 @@ New features Let think a case that you want to install the x86 package when you are working under the x86_64 environment. For example: - # apt-cyg --charch x86 install chere + apt-cyg --charch x86 install chere As of 2013-10-26, chere package is provided for only the repository for x86. @@ -95,13 +95,13 @@ If "wpad.dat" could not be downloaded, the proxy settings are inherited from the For example: - # apt-cyg --proxy http://proxy.home:8080 update + apt-cyg --proxy http://proxy.home:8080 update The default parameter is "${APT\_CYG\_PROXY:-auto}". At the environment where is not provided the WPAD server, it makes the lag for a few seconds at startup. So, if you don't want to use WPAD, please define APT\_CYG\_PROXY environment variable as below: - # export APT_CYG_PROXY=none + export APT_CYG_PROXY=inherit Contributing ------------ From 02543849477f9818b8a5a979ccc8ccecd29331a8 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Tue, 6 May 2014 15:44:08 +0900 Subject: [PATCH 075/309] Update README.md (about Upgrade apt-cyg) --- README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/README.md b/README.md index e22814d..bef8cd6 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,9 @@ But, as of 2014-01-17, perhaps ca-certificates package makes fail of certificati Quick start ----------- +The most recommended way to deploy this fork can be seen from a link below: +* New features / [Upgrade apt-cyg](#upgrade-apt-cyg) + apt-cyg is a simple script. Once you have a copy, make it executable: chmod +x /bin/apt-cyg @@ -81,6 +84,17 @@ Of course you can also avoid signature check by using --no-verify or -X options. Public keys of cygwin and cygwinports are already registered to trusted keys of embeded. If you want to use some other public keys, please use key-* subcommands. +### Upgrade apt-cyg + +If apt-cyg is under the git version control, this fork can upgrade itself by "upgrade-self" subcommand. +Therefore, the most recommended way to deploy this fork is below: + + git clone HTTPS_clone_URL + ln -s "$(realpath apt-cyg/apt-cyg)" /usr/local/bin/ + +`HTTPS_clone_URL` is like a `https://github.com/USERNAME/apt-cyg.git`. +It can be found from the right side menu in each fork pages on github. + ### Proxy support Use --proxy, -p option. From d1744e50362e4c805913247e9435105838f9d1b5 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Sun, 11 May 2014 20:49:31 +0900 Subject: [PATCH 076/309] Add bash completion support. --- README.md | 11 +++- apt-cyg | 180 +++++++++++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 175 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index bef8cd6..4640312 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,8 @@ apt-cyg is a command-line installer for [Cygwin](http://cygwin.com/) which coope * "apt-cyg upgrade-self" to upgrade apt-cyg * "apt-cyg depends <package names>" to show forward dependency information for packages with depth. * "apt-cyg rdepends <package names>" to show reverse dependency information for packages with depth. +* "apt-cyg completion-install" to install completion. +* "apt-cyg completion-uninstall" to uninstall completion. Requirements ----------- @@ -117,6 +119,14 @@ So, if you don't want to use WPAD, please define APT\_CYG\_PROXY environment var export APT_CYG_PROXY=inherit +### Bash completion support + +Bash completion script can be installed to "/etc/bash_completion.d/apt-cyg" by `completion-install` subcommand. +It will be automatically updated when apt-cyg is upgraded to newer version. +If you don't want to update it automatically, execute `completion-install` subcommand in conjunction with `--completion-disable-autoupdate` option. + +Some other forks, [Milly / apt-cyg](https://github.com/Milly/apt-cyg) under the cfg / apt-cyg fork, [ashumkin / apt-cyg](https://github.com/ashumkin/apt-cyg) and etc, are also supported it. + Contributing ------------ @@ -152,7 +162,6 @@ Todo ------------ * Support multi mirrors: Cygwin setup can use multi mirrors. They are recorded at last-mirror section in '/etc/setup/setup.rc'. It's useful for using [Cygwinports](http://cygwinports.org/). -* Support completion: Some other forks already supported it. For example, [Milly / apt-cyg](https://github.com/Milly/apt-cyg) under the cfg / apt-cyg fork, [ashumkin / apt-cyg](https://github.com/ashumkin/apt-cyg) and etc supported it. * Support upgrade: But maybe, busy resources can not be upgraded, and rebase problem will happen. Cygwin setup resolves by replacing them at next reboot. * Support dependency check for remove subcommand. diff --git a/apt-cyg b/apt-cyg index 8242585..9ef7e6a 100755 --- a/apt-cyg +++ b/apt-cyg @@ -77,6 +77,8 @@ function usage() echo " to show forward dependency information for packages with depth." echo " \"apt-cyg rdepends \"" echo " to show reverse dependency information for packages with depth." + echo " \"apt-cyg completion-install\" to install completion." + echo " \"apt-cyg completion-uninstall\" to uninstall completion." echo "Options:" echo " --charch : change archetecture" echo " --use-setuprc : set cache and mirror with /etc/setup/setup.rc" @@ -87,6 +89,10 @@ function usage() echo " --no-check-certificate : Don't validate the server's certificate" echo " --proxy, -p :" echo " set proxy (default: \${APT_CYG_PROXY:-auto})" + echo " --completion-get-subcommand:" + echo " get subcommand (for completion internal use)" + echo " --completion-disable-autoupdate:" + echo " disable completion autoupdate" echo " --mirror, -m : set mirror" echo " --cache, -c : set cache" echo " --file, -f : read package names from file" @@ -657,6 +663,114 @@ function apt-cyg-rdepends () dep_check rdepends "$@" } +function apt-cyg-completion-install () +{ + if [ ! -d "/etc/bash_completion.d" ]; then + echo -e "\e[31;1mError:\e[30;0m /etc/bash_completion.d is not exist." + exit 1 + fi + + local SUBCMDS + local OPTIONS + local SCRIPTFILE="$(realpath "$(which apt-cyg)")" + local SCRIPTDIR="${SCRIPTNAME%/*}" + + readarray -t -O ${#SUBCMDS[@]} SUBCMDS < <(grep "^function " "$SCRIPTFILE" | awk 'match($2, /apt-cyg-([-_0-9A-Za-z]+)/,m){print m[1]}') + readarray -t -O ${#OPTIONS[@]} OPTIONS < <( + awk ' + /^function *parse_args *\(\)/ {proc=1} + /^} *# *\/parse_args( |$)/ {proc=0} + proc && match($0, /^ *(-[^()*]+)\)/, m) { + split(m[1], x, "|"); + for (i in x) print x[i]; + } + ' "$SCRIPTFILE" + ) +cat <<-EOD > /etc/bash_completion.d/apt-cyg +# bash completion for apt-cyg + +function __apt-cyg () +{ + local cur prev getsubcmd subcmd + + # Auto update for completion script. + if [ -z "$OPT_COMPLETION_DISABLE_AUTOUPDATE" -a "$SCRIPTFILE" -nt "/etc/bash_completion.d/apt-cyg" ]; then + apt-cyg completion-install >/dev/null 2>&1 + . /etc/bash_completion.d/apt-cyg + __apt-cyg "$@" + return + fi + + _get_comp_words_by_ref -n : cur prev + + getsubcmd=( apt-cyg --completion-get-subcommand \$(echo "\${COMP_LINE}" | sed -r -e 's/^[^ \t]+//g' -e 's/[^ \t]+\$//g') ) + subcmd="\$( "\${getsubcmd[@]}" )" + + case "\$subcmd" in + install|depends|rdepends|describe|find) + COMPREPLY=( \$(awk '/^@ /{print \$2}' "$(apt-cyg pathof setup.ini)") ) + ;; + remove) + COMPREPLY=( \$(apt-cyg show 2>/dev/null) ) + ;; + pathof) + COMPREPLY=( cache mirror mirrordir cache/mirrordir setup.ini ) + ;; + "") + COMPREPLY=( "${SUBCMDS[*]}" ) + ;; + esac + case "\$prev" in + --charch) + COMPREPLY=( x86 x86_64 ) + ;; + --cache|-c) + COMPREPLY=( \$(compgen -d -- "\$cur") ) + ;; + --mirror|-m) + COMPREPLY=( \$(awk '/^[^ \t]+/{section=\$1}section=="mirrors-lst"&&match(\$0,/^[ \t]+([^;]+);/,m){print "\""m[1]"\""}' "/etc/setup/setup.rc") ) + ;; + --file|-f) + COMPREPLY=( \$(compgen -f -- "\$cur") ) + ;; + --proxy|-p) + COMPREPLY=( auto inherit none http:// ) + ;; + *) + COMPREPLY+=( "${OPTIONS[*]}" ) + ;; + esac + if [ -n "\$DEBUG_COMPLETION" ]; then + echo + echo "COMP_WORDBREAKS: \$COMP_WORDBREAKS" + echo "getsubcmd: '\${getsubcmd[@]}'" + echo "subcmd: '\${subcmd[@]}'" + echo "COMP_LINE: '\${COMP_LINE}'" + echo "cur: \$cur" + echo "prev: \$prev" + echo "COMP_WORDS: \${COMP_WORDS[@]}" + echo + echo -n "\${COMP_LINE}" + fi + COMPREPLY=( \$(compgen -W "\${COMPREPLY[*]}" -- "\$cur") ) + __ltrim_colon_completions "\$cur" +} +complete -F __apt-cyg apt-cyg +EOD + touch -r "$SCRIPTFILE" "/etc/bash_completion.d/apt-cyg" + echo "A bash completion /etc/bash_completion.d/apt-cyg is installed" +} + +function apt-cyg-completion-uninstall () +{ + if [ ! -f /etc/bash_completion.d/apt-cyg ]; then + echo -e "\e[31;1mError:\e[30;0m /etc/bash_completion.d/apt-cyg is not exist." + exit 1 + fi + rm /etc/bash_completion.d/apt-cyg + echo "A bash completion /etc/bash_completion.d/apt-cyg is uninstalled" +} + function apt-cyg-help () { usage @@ -677,12 +791,16 @@ YES_TO_ALL=false INITIAL_ARGS=( "$@" ) ARGS=() +function parse_args () +{ +local unknown_option + while [ $# -gt 0 ]; do case "$1" in --charch) - charch "$2" "${INITIAL_ARGS[@]}" - shift ; shift + OPT_CHARCH="$2" + shift 2 || break ;; --use-setuprc) @@ -718,17 +836,27 @@ while [ $# -gt 0 ]; do --proxy|-p) OPT_PROXY="$2" - shift 2 + shift 2 || break + ;; + + --completion-get-subcommand) + OPT_COMPLETION_GET_SUBCOMMAND="$1" + shift + ;; + + --completion-disable-autoupdate) + OPT_COMPLETION_DISABLE_AUTOUPDATE="$1" + shift ;; --mirror|-m) - echo "${2%/}/" > /etc/setup/last-mirror - shift ; shift + OPT_MIRROR="$2" + shift 2 || break ;; --cache|-c) - cygpath -aw "$2" > /etc/setup/last-cache - shift ; shift + OPT_CACHE="$2" + shift 2 || break ;; --noscripts) @@ -757,15 +885,13 @@ while [ $# -gt 0 ]; do ;; --file|-f) - if [ -n "$2" ]; then - OPT_FILES+=( "$2" ) - shift - else - echo 1>&2 No file name provided, ignoring $1 - fi - shift + [ -n "$2" ] && OPT_FILES+=( "$2" ) + shift 2 || break + ;; + -*) + unknown_option="$1" + break ;; - *) if [ -z "$SUBCOMMAND" ]; then SUBCOMMAND="$1" @@ -779,6 +905,30 @@ while [ $# -gt 0 ]; do esac done +if [ -n "$OPT_COMPLETION_GET_SUBCOMMAND" ]; then + echo "$SUBCOMMAND" + exit +fi + +if [ -n "$unknown_option" ]; then + echo -e "\e[31;1mError:\e[30;0m Unknown option: $unknown_option" + exit 1 +fi + +if [ $# -gt 0 ]; then + echo -e "\e[31;1mError:\e[30;0m Number of parameters is not enough: $@" + exit 1 +fi + +} #/parse_args + +parse_args "$@" + +[ -n "$OPT_CHARCH" ] && charch "$OPT_CHARCH" "${INITIAL_ARGS[@]}" + +[ "${#OPT_MIRROR[@]}" -gt 0 ] && echo "${OPT_MIRROR%/}/" > /etc/setup/last-mirror +[ "${#OPT_CACHE[@]}" -gt 0 ] && echo "$(cygpath -aw "$OPT_CACHE")" > /etc/setup/last-cache + if [ -z "$GPGV" -a -z "$no_verify" ]; then echo -e "\e[31;1mError:\e[30;0m GnuPG is not installed. Prease install gnupg package or use -X option." exit 1 From c76e0a3976882927d620c3a5c9bb4abedf5fe98d Mon Sep 17 00:00:00 2001 From: kou1okada Date: Sun, 11 May 2014 20:54:47 +0900 Subject: [PATCH 077/309] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4640312..d8b53d2 100644 --- a/README.md +++ b/README.md @@ -123,7 +123,7 @@ So, if you don't want to use WPAD, please define APT\_CYG\_PROXY environment var Bash completion script can be installed to "/etc/bash_completion.d/apt-cyg" by `completion-install` subcommand. It will be automatically updated when apt-cyg is upgraded to newer version. -If you don't want to update it automatically, execute `completion-install` subcommand in conjunction with `--completion-disable-autoupdate` option. +If you don't want to update it automatically, execute `completion-install` subcommand in conjunction with `--completion-disable-autoupdate` option. And `completion-uninstall` subcommand removes "/etc/bash_completion.d/apt-cyg". Some other forks, [Milly / apt-cyg](https://github.com/Milly/apt-cyg) under the cfg / apt-cyg fork, [ashumkin / apt-cyg](https://github.com/ashumkin/apt-cyg) and etc, are also supported it. From fe5bc113ee19dc7542d259c8fb703cc865b6772b Mon Sep 17 00:00:00 2001 From: kou1okada Date: Mon, 12 May 2014 10:02:46 +0900 Subject: [PATCH 078/309] completion-install subcommand has been changed to require bash-completion package. --- apt-cyg | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/apt-cyg b/apt-cyg index 9ef7e6a..e6f87a3 100755 --- a/apt-cyg +++ b/apt-cyg @@ -669,6 +669,10 @@ function apt-cyg-completion-install () echo -e "\e[31;1mError:\e[30;0m /etc/bash_completion.d is not exist." exit 1 fi + if ! package_db-is_registered "bash-completion"; then + echo -e "\e[31;1mError:\e[30;0m bash-completion is not installed." + exit 1 + fi local SUBCMDS local OPTIONS From 124c3d7dc188d1cbec54610d46c973eda493863e Mon Sep 17 00:00:00 2001 From: kou1okada Date: Thu, 15 May 2014 02:51:52 +0900 Subject: [PATCH 079/309] Add mirrors-list subcommand. --- README.md | 1 + apt-cyg | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/README.md b/README.md index d8b53d2..3b0f0b1 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,7 @@ apt-cyg is a command-line installer for [Cygwin](http://cygwin.com/) which coope * "apt-cyg rdepends <package names>" to show reverse dependency information for packages with depth. * "apt-cyg completion-install" to install completion. * "apt-cyg completion-uninstall" to uninstall completion. +* "apt-cyg mirrors-list" to show list of mirrors. Requirements ----------- diff --git a/apt-cyg b/apt-cyg index e6f87a3..d247294 100755 --- a/apt-cyg +++ b/apt-cyg @@ -79,6 +79,7 @@ function usage() echo " to show reverse dependency information for packages with depth." echo " \"apt-cyg completion-install\" to install completion." echo " \"apt-cyg completion-uninstall\" to uninstall completion." + echo " \"apt-cyg mirrors-list\" to show list of mirros." echo "Options:" echo " --charch : change archetecture" echo " --use-setuprc : set cache and mirror with /etc/setup/setup.rc" @@ -775,6 +776,14 @@ function apt-cyg-completion-uninstall () echo "A bash completion /etc/bash_completion.d/apt-cyg is uninstalled" } +function apt-cyg-mirros-list () +{ + awk ' + /^[^ \t]+/ {section = $1} + section=="mirrors-lst" && match($0, /^[ \t]+([^;]+);/, m) {print m[1]} + ' "/etc/setup/setup.rc" +} + function apt-cyg-help () { usage From a5ed2e31ac8b1c40377379b5b1196144d2a8431f Mon Sep 17 00:00:00 2001 From: kou1okada Date: Thu, 15 May 2014 12:08:05 +0900 Subject: [PATCH 080/309] Fixed: calculations of dependency depth. --- apt-cyg | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/apt-cyg b/apt-cyg index d247294..9cfd86e 100755 --- a/apt-cyg +++ b/apt-cyg @@ -586,9 +586,12 @@ function dep_check_single () { awk \ ' + function min(x,y) {return x < y ? x : y} + function max(x,y) {return x < y ? y : x} function update_result(dir, rootpkg, pkg, depth, _, i) { if (0 + result[rootpkg, pkg, "deep"]) { - result[rootpkg, pkg, "deep"] = depth; + result[rootpkg, pkg, "shallow"] = min(depth, result[rootpkg, pkg, "shallow"]); + result[rootpkg, pkg, "deep"] = max(depth, result[rootpkg, pkg, "deep"]); } else { result[rootpkg, pkg, "deep"] = result[rootpkg, pkg, "shallow"] = depth; result[rootpkg, pkg, "available"] = 0 + available[pkg]; From 05bee810b87d48b1e76737b43a20800f6920eb03 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Sun, 18 May 2014 14:28:04 +0900 Subject: [PATCH 081/309] Refactoring: Performance improvement for dependency check. --- apt-cyg | 48 +++++++++++++++++++++++++++--------------------- 1 file changed, 27 insertions(+), 21 deletions(-) diff --git a/apt-cyg b/apt-cyg index 9cfd86e..06150e5 100755 --- a/apt-cyg +++ b/apt-cyg @@ -576,13 +576,25 @@ function package_db-unregister () mv "${work}" "${PACKAGE_DB}" } -# Usage: dep_check_single DIR ROOTPKG +# Usage: join FS fields ... +function join () +{ + local FS="$1" field="" result="" sep="" + shift + for field; do + result="$result$sep$field" + sep="$FS" + done + echo "$result" +} + +# Usage: dep_check DIR ROOTPKGS ... # Parameters: # DIR is "depends" or "rdepends". -# ROOTPKG is a root package name to check dependency. +# ROOTPKGS is root package names to check dependency. # Return: # package_name available shallow_depth deep_depth -function dep_check_single () +function dep_check () { awk \ ' @@ -612,27 +624,21 @@ function dep_check_single () } } END { - update_result(DIR, ROOTPKG, ROOTPKG, 1); - for(i = 0; i < result[ROOTPKG, "n"]; i++) { - printf("%-40s %d\t%d\t%d\n", - result[ROOTPKG, i], - result[ROOTPKG, result[ROOTPKG, i], "available"], - result[ROOTPKG, result[ROOTPKG, i], "shallow"], - result[ROOTPKG, result[ROOTPKG, i], "deep"]); + split(ROOTPKGS, rootpkgs, "\x1c"); + for (k in rootpkgs) { + update_result(DIR, rootpkgs[k], rootpkgs[k], 1); + for(i = 0; i < result[rootpkgs[k], "n"]; i++) { + printf("%-40s %d\t%d\t%d\n", + result[rootpkgs[k], i], + result[rootpkgs[k], result[rootpkgs[k], i], "available"], + result[rootpkgs[k], result[rootpkgs[k], i], "shallow"], + result[rootpkgs[k], result[rootpkgs[k], i], "deep"]); + } } } ' \ - DIR="$1" ROOTPKG="$2" "$(apt-cyg-pathof "setup.ini")" | sort -nrk4 -} - -function dep_check () -{ - local pkg - local dir="$1" - shift - for pkg; do - dep_check_single "$dir" "$pkg" - done | awk ' + DIR="$1" ROOTPKGS="$(join "\x1c" "${@:2}")" "$(apt-cyg-pathof "setup.ini")" \ + | awk ' function min(x,y) {return x < y ? x : y} function max(x,y) {return x < y ? y : x} { From c59f988ee2867982b2e4ddca16966567f310a19f Mon Sep 17 00:00:00 2001 From: kou1okada Date: Sun, 18 May 2014 15:14:47 +0900 Subject: [PATCH 082/309] Fixed misspelling. --- apt-cyg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apt-cyg b/apt-cyg index 06150e5..d086df5 100755 --- a/apt-cyg +++ b/apt-cyg @@ -785,7 +785,7 @@ function apt-cyg-completion-uninstall () echo "A bash completion /etc/bash_completion.d/apt-cyg is uninstalled" } -function apt-cyg-mirros-list () +function apt-cyg-mirrors-list () { awk ' /^[^ \t]+/ {section = $1} From 3441f00be14c468326618c1cfe0a13de878ba011 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Mon, 19 May 2014 04:26:04 +0900 Subject: [PATCH 083/309] Add benchmark-mirrors subcommand. --- apt-cyg | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/apt-cyg b/apt-cyg index d086df5..5b202ab 100755 --- a/apt-cyg +++ b/apt-cyg @@ -80,6 +80,7 @@ function usage() echo " \"apt-cyg completion-install\" to install completion." echo " \"apt-cyg completion-uninstall\" to uninstall completion." echo " \"apt-cyg mirrors-list\" to show list of mirros." + echo " \"apt-cyg benchmark-mirrors ...\" to benchmark mirrors." echo "Options:" echo " --charch : change archetecture" echo " --use-setuprc : set cache and mirror with /etc/setup/setup.rc" @@ -289,10 +290,30 @@ function ask_user () done } +# Reference: +# https://www.gnu.org/software/wget/manual/wget.html#Exit-Status +# Usage: wget-exitstatus EXITSTATUS +function wget-exitstatus () +{ + case $1 in + 0) echo "No problems occurred.";; + 1) echo "Generic error code.";; + 2) echo "Parse error?for instance, when parsing command-line options, the '.wgetrc' or '.netrc'...";; + 3) echo "File I/O error.";; + 4) echo "Network failure.";; + 5) echo "SSL verification failure.";; + 6) echo "Username/password authentication failure.";; + 7) echo "Protocol errors.";; + 8) echo "Server issued an error response.";; + *) echo "Unknown errors.";; + esac +} + # Usage: wget_return_case_md5sum returncode function wget_return_case_md5sum () { case "$1" in + 0) return 0 ;; 1) echo "$LABEL: FAILED: Could not download $URL."; return 1 ;; 5) echo "$LABEL: WARNING: The SSL certificate is invalid $URL." ask_user "Continue regardless of invalid SSL certificate?" || return 1 @@ -300,7 +321,6 @@ function wget_return_case_md5sum () return 0 ;; 8) echo "$LABEL: FAILED: 404 Not Found $URL." return 1 ;; - 0) return 0 ;; *) echo -e "\e[31;1mError:\e[30;0m FATAL: wget returned unkown value"; return 1 ;; esac } @@ -793,6 +813,20 @@ function apt-cyg-mirrors-list () ' "/etc/setup/setup.rc" } +function apt-cyg-benchmark-mirrors +{ + local mirror result exitcode + for mirror; do + result="$( { time wget -qO/dev/null -T3 -t 1 "${mirror%/}/$(current_cygarch)/setup.bz2"; } 2>&1 )" + exitcode=$? + if [ $exitcode -ne 0 ];then + echo -e "\e[33;1mWarning:\e[30;0m benchmark failed with wget exitcode $exitcode: $(wget-exitstatus $exitcode): $1" >&2 + continue + fi + echo -e "$(echo "$result" | grep real | cut -f 2 | tr -d "\n")\t${mirror}" + done +} + function apt-cyg-help () { usage From 905079f4bce65d7cf3447d2089e44593cc23d672 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Mon, 19 May 2014 04:27:50 +0900 Subject: [PATCH 084/309] Add benchmark-parallel-mirrors and benchmark-parallel-mirrors-list subcommand. --- apt-cyg | 99 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) diff --git a/apt-cyg b/apt-cyg index 5b202ab..ef17ac5 100755 --- a/apt-cyg +++ b/apt-cyg @@ -81,6 +81,8 @@ function usage() echo " \"apt-cyg completion-uninstall\" to uninstall completion." echo " \"apt-cyg mirrors-list\" to show list of mirros." echo " \"apt-cyg benchmark-mirrors ...\" to benchmark mirrors." + echo " \"apt-cyg benchmark-parallel-mirrors ...\" to benchmark mirrors in parallel." + echo " \"apt-cyg benchmark-parallel-mirrors-list\" to benchmark mirrors-list in parallel." echo "Options:" echo " --charch : change archetecture" echo " --use-setuprc : set cache and mirror with /etc/setup/setup.rc" @@ -95,6 +97,7 @@ function usage() echo " get subcommand (for completion internal use)" echo " --completion-disable-autoupdate:" echo " disable completion autoupdate" + echo " --max-jobs, -j : Run n jobs in parallel" echo " --mirror, -m : set mirror" echo " --cache, -c : set cache" echo " --file, -f : read package names from file" @@ -827,6 +830,97 @@ function apt-cyg-benchmark-mirrors done } +function apt-cyg-benchmark-parallel-mirrors +{ + local result="$(mktemp "${SCRIPTNAME}.$$.XXXXX")" + local mirror + for mirror; do echo $mirror; done | lesser-parallel apt-cyg-benchmark-mirrors {} | tee "$result" + echo Finished benchmark. + echo ======================================== + echo Sorted result. + sort -rV "$result" + rm "$result" + +} + +function apt-cyg-benchmark-parallel-mirrors-list +{ + local mirrors + readarray -t mirrors < <(apt-cyg-mirrors-list) + apt-cyg-benchmark-parallel-mirrors "${mirrors[@]}" +} + +# Lesser Parallel for Embedding +# Copyright (c) 2014 Koichi OKADA. All rights reserved. +# The official repository is: +# https://github.com/kou1okada/lesser-parallel +# This script is distributed under the MIT license. +# http://www.opensource.org/licenses/mit-license.php + +LESSER_PARALLEL_MAX_JOBS=${LESSER_PARALLEL_MAX_JOBS:-8} + +function lesser-parallel-get-jobs-count () +{ + jobs -l >/dev/null + jobs -l | wc -l +} + +# Usage: lesser-parallel-restrict-jobs-count MAXJOBS +function lesser-parallel-restrict-jobs-count () +{ + while [ $(lesser-parallel-get-jobs-count) -ge $1 ]; do + sleep 0.2 + done +} + +# Usage: lesser-parallel [command [arguments]] < list_ot_arguments +function lesser-parallel () +{ + local cmd arg lines line basename ext PARALLEL_SEQ=1 + readarray -t lines + for line in "${lines[@]}"; do + basename="$(basename "$line")" + ext="${basename##*.}" + [ "$ext" = "$basename" ] && ext="" + [ "$ext" != "" ] && ext=".$ext" + cmd=( ) + for arg; do + case "$arg" in + "{}") + cmd+=( "$line" ) + ;; + "{.}") + cmd+=( "$(basename "$line" "$ext")" ) + ;; + "{/}") + cmd+=( "$basename" ) + ;; + "{//}") + cmd+=( "$(dirname "$line")" ) + ;; + "{/.}") + cmd+=( "$(basename "$basename" "$ext")" ) + ;; + "{#}") + cmd+=( "$PARALLEL_SEQ" ) + ;; + *) + cmd+=( "$arg" ) + ;; + esac + done + + lesser-parallel-restrict-jobs-count $LESSER_PARALLEL_MAX_JOBS + + "${cmd[@]}" & + PARALLEL_SEQ=$[$PARALLEL_SEQ + 1] + done + + lesser-parallel-restrict-jobs-count 1 +} + +#/Lesser Parallel for Embedding + function apt-cyg-help () { usage @@ -905,6 +999,11 @@ while [ $# -gt 0 ]; do shift ;; + --max-jobs|-j) + LESSER_PARALLEL_MAX_JOBS="$2" + shift 2 || break + ;; + --mirror|-m) OPT_MIRROR="$2" shift 2 || break From 8dbe5652befe3b076b90d74fa3e1097358f8d9c2 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Thu, 22 May 2014 23:55:36 +0900 Subject: [PATCH 085/309] Bugfix: Package dependencies checker was corrupted. --- apt-cyg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apt-cyg b/apt-cyg index ef17ac5..930ab37 100755 --- a/apt-cyg +++ b/apt-cyg @@ -1254,7 +1254,7 @@ function apt-cyg-install () echo Package $pkg requires the following packages, installing: echo $requires for package in $requires; do - if package_db-is_registered "$pkg"; then + if package_db-is_registered "$package"; then echo Package $package is already installed, skipping continue fi From e39cbfd5403e14b5229135fa76bdeaf916f7f492 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Sun, 25 May 2014 02:14:33 +0900 Subject: [PATCH 086/309] Bugfix: The escape character must be decoded before passing to the join function. --- apt-cyg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apt-cyg b/apt-cyg index 930ab37..07c2b65 100755 --- a/apt-cyg +++ b/apt-cyg @@ -660,7 +660,7 @@ function dep_check () } } ' \ - DIR="$1" ROOTPKGS="$(join "\x1c" "${@:2}")" "$(apt-cyg-pathof "setup.ini")" \ + DIR="$1" ROOTPKGS="$(join $'\x1c' "${@:2}")" "$(apt-cyg-pathof "setup.ini")" \ | awk ' function min(x,y) {return x < y ? x : y} function max(x,y) {return x < y ? y : x} From 9b30b276a286acac2cb2cd453dce385bcecbd566 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Sat, 5 Jul 2014 17:22:49 +0900 Subject: [PATCH 087/309] Normalizing indent. For minimizing diff result, some of indent were not normalized. But now, the large part of trunk line is modifying and the reason to leave unnormalized indent has been disappeared. --- apt-cyg | 547 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 269 insertions(+), 278 deletions(-) diff --git a/apt-cyg b/apt-cyg index 07c2b65..704e020 100755 --- a/apt-cyg +++ b/apt-cyg @@ -322,7 +322,7 @@ function wget_return_case_md5sum () ask_user "Continue regardless of invalid SSL certificate?" || return 1 "${WGET[@]}" --no-check-certificate "$URL" -O "$FILE" return 0 - ;; + ;; 8) echo "$LABEL: FAILED: 404 Not Found $URL." return 1 ;; *) echo -e "\e[31;1mError:\e[30;0m FATAL: wget returned unkown value"; return 1 ;; esac @@ -375,34 +375,34 @@ function fetch_trustedkeys () case "$CASE" in 00|01|0-) "${GPG[@]}" --import "$FILE" - ;; + ;; 02) echo "Warning: ${LABEL} has been updated." "${GPG[@]}" --import "$FILE" - ;; + ;; -0) "${GPG[@]}" --import "$FILE_LATEST" - ;; + ;; 10|20) echo -e "\e[31;1mError:\e[30;0m ${LABEL} has miss configuration." exit 1 - ;; + ;; 11|1-|-1) echo -e "\e[31;1mError:\e[30;0m Could not download ${LABEL}." exit 1 - ;; + ;; 12|-2) echo -e "\e[31;1mError:\e[30;0m ${LABEL} has been updated, maybe. But sometimes it may has been cracked. Be careful !!!" exit 1 - ;; + ;; 21|22|2-) echo -e "\e[31;1mError:\e[30;0m ${LABEL} has been cracked, maybe" exit 1 - ;; + ;; --) echo -e "\e[31;1mError:\e[30;0m ${LABEL} has no URL." exit 1 - ;; + ;; esac done rm "$FILE" "$FILE_LATEST" @@ -472,6 +472,7 @@ function apt-cyg-pathof () *) echo -e "\e[31;1mError:\e[30;0m in function $FUNCNAME: unknown parameter: $1" exit 1 + ;; esac shift done @@ -515,17 +516,17 @@ function proxy_unset () function proxy_setup () { case "$OPT_PROXY" in - auto) - proxy_auto - ;; - inherit) - ;; - none) - proxy_unset - ;; - *) - proxy_set "$OPT_PROXY" - ;; + auto) + proxy_auto + ;; + inherit) + ;; + none) + proxy_unset + ;; + *) + proxy_set "$OPT_PROXY" + ;; esac } @@ -556,8 +557,8 @@ function package_db-is_registered () package_db-version_check awk ' - $1 == PKGNAME && NF != 2 {found = 1; exit} - END {exit !found} + $1 == PKGNAME && NF != 2 {found = 1; exit} + END {exit !found} ' PKGNAME="$1" "${PACKAGE_DB}" } @@ -576,10 +577,10 @@ function package_db-register () package_db-version_check awk ' - function register() {print PKGNAME " " PKGFILE " 0"; registered = 1;} - !registered && PKGNAME < $1 && NF != 2 {register()} - {print $0} - END {if (!registered) register()} + function register() {print PKGNAME " " PKGFILE " 0"; registered = 1;} + !registered && PKGNAME < $1 && NF != 2 {register()} + {print $0} + END {if (!registered) register()} ' PKGNAME="$1" PKGFILE="$2" "${PACKAGE_DB}" > "${work}" mv "${PACKAGE_DB}" "${PACKAGE_DB}-save" @@ -662,23 +663,23 @@ function dep_check () ' \ DIR="$1" ROOTPKGS="$(join $'\x1c' "${@:2}")" "$(apt-cyg-pathof "setup.ini")" \ | awk ' - function min(x,y) {return x < y ? x : y} - function max(x,y) {return x < y ? y : x} - { - packages[$1] = pkg = $1; - status[pkg, "available"] = $2; - status[pkg, "shallow" ] = 0 + status[pkg, "shallow"] == 0 ? $3 : min(status[pkg, "shallow"], $3); - status[pkg, "deep" ] = max(0 + status[pkg, "deep"], $4); - } - END { - for (pkg in packages) { - printf("%-40s %d\t%d\t%d\n", - pkg, - status[pkg, "available"], - status[pkg, "shallow"], - status[pkg, "deep"]) + function min(x,y) {return x < y ? x : y} + function max(x,y) {return x < y ? y : x} + { + packages[$1] = pkg = $1; + status[pkg, "available"] = $2; + status[pkg, "shallow" ] = 0 + status[pkg, "shallow"] == 0 ? $3 : min(status[pkg, "shallow"], $3); + status[pkg, "deep" ] = max(0 + status[pkg, "deep"], $4); + } + END { + for (pkg in packages) { + printf("%-40s %d\t%d\t%d\n", + pkg, + status[pkg, "available"], + status[pkg, "shallow"], + status[pkg, "deep"]) + } } - } ' | sort -nrk4 } @@ -715,15 +716,15 @@ function apt-cyg-completion-install () readarray -t -O ${#SUBCMDS[@]} SUBCMDS < <(grep "^function " "$SCRIPTFILE" | awk 'match($2, /apt-cyg-([-_0-9A-Za-z]+)/,m){print m[1]}') readarray -t -O ${#OPTIONS[@]} OPTIONS < <( awk ' - /^function *parse_args *\(\)/ {proc=1} - /^} *# *\/parse_args( |$)/ {proc=0} - proc && match($0, /^ *(-[^()*]+)\)/, m) { - split(m[1], x, "|"); - for (i in x) print x[i]; - } - ' "$SCRIPTFILE" - ) -cat <<-EOD > /etc/bash_completion.d/apt-cyg + /^function *parse_args *\(\)/ {proc=1} + /^} *# *\/parse_args( |$)/ {proc=0} + proc && match($0, /^ *(-[^()*]+)\)/, m) { + split(m[1], x, "|"); + for (i in x) print x[i]; + } + ' "$SCRIPTFILE" + ) + cat <<-EOD > /etc/bash_completion.d/apt-cyg # bash completion for apt-cyg function __apt-cyg () @@ -943,138 +944,140 @@ ARGS=() function parse_args () { -local unknown_option - -while [ $# -gt 0 ]; do - case "$1" in - - --charch) - OPT_CHARCH="$2" - shift 2 || break - ;; - - --use-setuprc) - "$0" -c "$(grep -A1 last-cache /etc/setup/setup.rc | tail -n1 | sed -r 's/^\s*|\s*$//g')" > /dev/null - "$0" -m "$(grep -A1 last-mirror /etc/setup/setup.rc | tail -n1 | sed -r 's/^\s*|\s*$//g')" > /dev/null - shift - ;; - - --ignore-case|-i) - ignore_case="$1" - shift - ;; - - --force-remove) - force_remove=1 - shift - ;; - - --force-fetch-trustedkeys) - force_fetch_trustedkeys=1 - shift - ;; - - --no-verify|-X) - no_verify=1 - shift - ;; - - --no-check-certificate) - WGET+=( "--no-check-certificate" ) - shift - ;; - - --proxy|-p) - OPT_PROXY="$2" - shift 2 || break - ;; - - --completion-get-subcommand) - OPT_COMPLETION_GET_SUBCOMMAND="$1" - shift - ;; - - --completion-disable-autoupdate) - OPT_COMPLETION_DISABLE_AUTOUPDATE="$1" - shift - ;; - - --max-jobs|-j) - LESSER_PARALLEL_MAX_JOBS="$2" - shift 2 || break - ;; - - --mirror|-m) - OPT_MIRROR="$2" - shift 2 || break - ;; - - --cache|-c) - OPT_CACHE="$2" - shift 2 || break - ;; - - --noscripts) - noscripts=1 - shift - ;; - - --noupdate|-u) - noupdate=1 - shift - ;; - - --ipv4|-4) - WGET=( "${WGET[@]}" "--prefer-family=IPv4" ) - shift - ;; - - --help) - usage - exit 0 - ;; - - --version) - version - exit 0 - ;; - - --file|-f) - [ -n "$2" ] && OPT_FILES+=( "$2" ) - shift 2 || break - ;; - -*) - unknown_option="$1" - break - ;; - *) - if [ -z "$SUBCOMMAND" ]; then - SUBCOMMAND="$1" - else - ARGS+=( "$1" ) - fi - shift - - ;; - - esac -done - -if [ -n "$OPT_COMPLETION_GET_SUBCOMMAND" ]; then - echo "$SUBCOMMAND" - exit -fi - -if [ -n "$unknown_option" ]; then - echo -e "\e[31;1mError:\e[30;0m Unknown option: $unknown_option" - exit 1 -fi - -if [ $# -gt 0 ]; then - echo -e "\e[31;1mError:\e[30;0m Number of parameters is not enough: $@" - exit 1 -fi - + local unknown_option + + while [ $# -gt 0 ]; do + case "$1" in + + --charch) + OPT_CHARCH="$2" + shift 2 || break + ;; + + --use-setuprc) + "$0" -c "$(grep -A1 last-cache /etc/setup/setup.rc | tail -n1 | sed -r 's/^\s*|\s*$//g')" > /dev/null + "$0" -m "$(grep -A1 last-mirror /etc/setup/setup.rc | tail -n1 | sed -r 's/^\s*|\s*$//g')" > /dev/null + shift + ;; + + --ignore-case|-i) + ignore_case="$1" + shift + ;; + + --force-remove) + force_remove=1 + shift + ;; + + --force-fetch-trustedkeys) + force_fetch_trustedkeys=1 + shift + ;; + + --no-verify|-X) + no_verify=1 + shift + ;; + + --no-check-certificate) + WGET+=( "--no-check-certificate" ) + shift + ;; + + --proxy|-p) + OPT_PROXY="$2" + shift 2 || break + ;; + + --completion-get-subcommand) + OPT_COMPLETION_GET_SUBCOMMAND="$1" + shift + ;; + + --completion-disable-autoupdate) + OPT_COMPLETION_DISABLE_AUTOUPDATE="$1" + shift + ;; + + --max-jobs|-j) + LESSER_PARALLEL_MAX_JOBS="$2" + shift 2 || break + ;; + + --mirror|-m) + OPT_MIRROR="$2" + shift 2 || break + ;; + + --cache|-c) + OPT_CACHE="$2" + shift 2 || break + ;; + + --noscripts) + noscripts=1 + shift + ;; + + --noupdate|-u) + noupdate=1 + shift + ;; + + --ipv4|-4) + WGET=( "${WGET[@]}" "--prefer-family=IPv4" ) + shift + ;; + + --help) + usage + exit 0 + ;; + + --version) + version + exit 0 + ;; + + --file|-f) + [ -n "$2" ] && OPT_FILES+=( "$2" ) + shift 2 || break + ;; + + -*) + unknown_option="$1" + break + ;; + + *) + if [ -z "$SUBCOMMAND" ]; then + SUBCOMMAND="$1" + else + ARGS+=( "$1" ) + fi + shift + + ;; + + esac + done + + if [ -n "$OPT_COMPLETION_GET_SUBCOMMAND" ]; then + echo "$SUBCOMMAND" + exit + fi + + if [ -n "$unknown_option" ]; then + echo -e "\e[31;1mError:\e[30;0m Unknown option: $unknown_option" + exit 1 + fi + + if [ $# -gt 0 ]; then + echo -e "\e[31;1mError:\e[30;0m Number of parameters is not enough: $@" + exit 1 + fi + } #/parse_args parse_args "$@" @@ -1101,104 +1104,96 @@ done function apt-cyg-update () { - - findworkspace - getsetup - + findworkspace + getsetup } function apt-cyg-show () { - - echo 1>&2 The following packages are installed: - package_db-list - + echo 1>&2 The following packages are installed: + package_db-list } function apt-cyg-find () { - local pkg - - checkpackages "$@" - findworkspace - getsetup - - for pkg do - echo "" - echo "Searching for installed packages matching $pkg:" - package_db-list | awk '$1~query{print $1}' query="$pkg" IGNORECASE="$ignore_case" - echo "" - echo "Searching for installable packages matching $pkg:" - awk -v query="$pkg" -v IGNORECASE="$ignore_case" \ - 'BEGIN{RS="\n\n@ "; FS="\n"; ORS="\n"} {if ($1 ~ query) {print $1}}' \ - setup.ini - done - + local pkg + + checkpackages "$@" + findworkspace + getsetup + + for pkg do + echo "" + echo "Searching for installed packages matching $pkg:" + package_db-list | awk '$1~query{print $1}' query="$pkg" IGNORECASE="$ignore_case" + echo "" + echo "Searching for installable packages matching $pkg:" + awk -v query="$pkg" -v IGNORECASE="$ignore_case" \ + 'BEGIN{RS="\n\n@ "; FS="\n"; ORS="\n"} {if ($1 ~ query) {print $1}}' \ + setup.ini + done } function apt-cyg-describe () { - local pkg - - checkpackages "$@" - findworkspace - getsetup - for pkg do - echo "" - awk -v query="$pkg" -v IGNORECASE="$ignore_case" \ - 'BEGIN{RS="\n\n@ "; FS="\n"; ORS="\n"} {if ($1 ~ query) {print $0 "\n"}}' \ - setup.ini - done - + local pkg + + checkpackages "$@" + findworkspace + getsetup + for pkg do + echo "" + awk -v query="$pkg" -v IGNORECASE="$ignore_case" \ + 'BEGIN{RS="\n\n@ "; FS="\n"; ORS="\n"} {if ($1 ~ query) {print $0 "\n"}}' \ + setup.ini + done } function apt-cyg-packageof () { - local pkg - local manifest - - checkpackages "$@" - for pkg do - local key="$(which "$pkg" 2>/dev/null | sed "s:^/::")" - if [ -z "$key" ]; then - key="$pkg" + local pkg + local manifest + + checkpackages "$@" + for pkg do + local key="$(which "$pkg" 2>/dev/null | sed "s:^/::")" + if [ -z "$key" ]; then + key="$pkg" + fi + for manifest in /etc/setup/*.lst.gz; do + local found="$(gzip -cd "$manifest" | grep -c "$key")" + if [ $found -gt 0 ]; then + local package="$(echo $manifest | sed -e "s:/etc/setup/::" -e "s/.lst.gz//")" + echo Found $key in the package $package fi - for manifest in /etc/setup/*.lst.gz; do - local found="$(gzip -cd "$manifest" | grep -c "$key")" - if [ $found -gt 0 ]; then - local package="$(echo $manifest | sed -e "s:/etc/setup/::" -e "s/.lst.gz//")" - echo Found $key in the package $package - fi - done done - + done } function apt-cyg-install () { - local pkg - local script - - checkpackages "$@" - findworkspace - getsetup - - for pkg do - + local pkg + local script + + checkpackages "$@" + findworkspace + getsetup + + for pkg do if package_db-is_registered "$pkg"; then echo Package $pkg is already installed, skipping continue fi echo "" echo Installing $pkg - + # look for package and save desc file - + mkdir -p "release/$pkg" awk > "release/$pkg/desc" -v package="$pkg" \ 'BEGIN{RS="\n\n@ "; FS="\n"} {if ($1 == package) {desc = $0; px++}} \ @@ -1211,17 +1206,17 @@ function apt-cyg-install () exit 1 fi echo Found package $pkg - + # download and unpack the bz2 file - + # pick the latest version, which comes first local install="$(awk '/^install: / { print $2; exit }' "release/$pkg/desc")" - + if [ -z "$install" ]; then echo "Could not find \"install\" in package description: obsolete package?" exit 1 fi - + local file="$(basename "$install")" cd "release/$pkg" "${WGET[@]}" -nc $mirror/$install @@ -1278,25 +1273,23 @@ function apt-cyg-install () fi echo Package $pkg installed - - done - + + done } function apt-cyg-remove() { - local pkg - local req - - checkpackages "$@" - for pkg do - + local pkg + local req + + checkpackages "$@" + for pkg do if ! package_db-is_registered "$pkg"; then echo Package $pkg is not installed, skipping continue fi - + local dontremove="cygwin coreutils gawk bzip2 tar xz wget bash" for req in $dontremove; do if [ "$pkg" = "$req" ]; then @@ -1304,41 +1297,39 @@ function apt-cyg-remove() exit 1 fi done - + if [ ! -e "/etc/setup/$pkg.lst.gz" -a -z "$force_remove" ]; then echo Package manifest missing, cannot remove $pkg. Exiting exit 1 fi echo Removing $pkg - + # run preremove scripts - + if [ -e "/etc/preremove/$pkg.sh" ]; then "/etc/preremove/$pkg.sh" fi - + gzip -cd "/etc/setup/$pkg.lst.gz" | awk '/[^\/]$/ {print "rm -f \"/" $0 "\""}' | sh rm -f "/etc/postinstall/$pkg.sh.done" "/etc/preremove/$pkg.sh" "/etc/setup/$pkg.lst.gz" package_db-unregister "$pkg" echo Package $pkg removed - - done - + + done } function invoke_subcommand () { - local SUBCOMMAND="${@:1:1}" - local ARGS=( "${@:2}" ) - local ACTION="apt-cyg-${SUBCOMMAND:-help}" - if type "$ACTION" >& /dev/null; then - "$ACTION" "${ARGS[@]}" - else - echo -e "\e[31;1mError:\e[30;0m unknown subcommand: $SUBCOMMAND" - exit 1 - fi + local SUBCOMMAND="${@:1:1}" + local ARGS=( "${@:2}" ) + local ACTION="apt-cyg-${SUBCOMMAND:-help}" + if type "$ACTION" >& /dev/null; then + "$ACTION" "${ARGS[@]}" + else + echo -e "\e[31;1mError:\e[30;0m unknown subcommand: $SUBCOMMAND" + exit 1 + fi } proxy_setup invoke_subcommand "$SUBCOMMAND" "${ARGS[@]}" - From 89afe352ae6047d43990ac74e46914eb1de9a6db Mon Sep 17 00:00:00 2001 From: kou1okada Date: Thu, 25 Sep 2014 09:27:44 +0900 Subject: [PATCH 088/309] Fixed: changed TRUSTEDKEY_CYGWIN location. Because of the CVS repository of Cygwin-apps can not be viewed on the web using CSVWeb. --- apt-cyg | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/apt-cyg b/apt-cyg index 704e020..8c04d4e 100755 --- a/apt-cyg +++ b/apt-cyg @@ -26,15 +26,14 @@ # TRUSTEDKEYS=( CYGWIN CYGWINPORTS ); -# ./cygwin.pub +# ./pubring.asc # ------------ # pub 1024D/676041BA 2008-06-13 # uid Cygwin # sub 1024g/A1DB7B5C 2008-06-13 -TRUSTEDKEY_CYGWIN_MD5="8fe5366fc82289578ab9b6e3c9f1bff9" +TRUSTEDKEY_CYGWIN_MD5="8555ea34b03d7b09b04886b08d310d8d" TRUSTEDKEY_CYGWIN_FPR="1169DF9F22734F743AA59232A9A262FF676041BA" -TRUSTEDKEY_CYGWIN_URL="https://sourceware.org/cgi-bin/cvsweb.cgi/~checkout~/setup/cygwin.pub?rev=2.1&cvsroot=cygwin-apps" -TRUSTEDKEY_CYGWIN_URL_LATEST="https://sourceware.org/cgi-bin/cvsweb.cgi/~checkout~/setup/cygwin.pub?cvsroot=cygwin-apps" +TRUSTEDKEY_CYGWIN_URL_LATEST="https://cygwin.com/key/pubring.asc" # ./ports.gpg # ----------- # pub 1024D/66EE1F94 2008-10-27 From 7ebc018b6373aea6f1423f7d13bcba9950203111 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Tue, 2 Dec 2014 17:57:38 +0900 Subject: [PATCH 089/309] Fixed: --no-verify and --no-check-certificate options are inherited for recursive install. --- apt-cyg | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/apt-cyg b/apt-cyg index 8c04d4e..2626a7f 100755 --- a/apt-cyg +++ b/apt-cyg @@ -937,6 +937,7 @@ force_remove="" force_fetch_trustedkeys="" no_verify="" OPT_PROXY=${APT_CYG_PROXY:-auto} +OPTS4INHERIT=() YES_TO_ALL=false INITIAL_ARGS=( "$@" ) ARGS=() @@ -975,11 +976,13 @@ function parse_args () ;; --no-verify|-X) + OPTS4INHERIT+=( "$1" ) no_verify=1 shift ;; --no-check-certificate) + OPTS4INHERIT+=( "$1" ) WGET+=( "--no-check-certificate" ) shift ;; @@ -1252,7 +1255,7 @@ function apt-cyg-install () echo Package $package is already installed, skipping continue fi - apt-cyg --proxy inherit --noscripts install $package + apt-cyg "${OPTS4INHERIT[@]}" --proxy inherit --noscripts install $package if [ $? -ne 0 ]; then warn=1; fi done fi From aba3ca4aa49d8d362e43257e38bf7afc02a0f6b5 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Sat, 6 Dec 2014 02:47:35 +0900 Subject: [PATCH 090/309] Update README.md --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 3b0f0b1..a6b6703 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ apt-cyg is a command-line installer for [Cygwin](http://cygwin.com/) which coope * "apt-cyg find <pattern(s)>" to find packages matching patterns * "apt-cyg describe <pattern(s)>" to describe packages matching patterns * "apt-cyg packageof <commands or files>" to locate parent packages -* "apt-cyg pathof <cache|mirror|mirrordir|cache/mirrordir>" to show path" +* "apt-cyg pathof <cache|mirror|mirrordir|cache/mirrordir|setup.ini>" to show path" * "apt-cyg key-add <files> ..." to add keys contained in <files> * "apt-cyg key-del <keyids> ..." to remove keys <keyids> * "apt-cyg key-list" to list keys @@ -21,6 +21,9 @@ apt-cyg is a command-line installer for [Cygwin](http://cygwin.com/) which coope * "apt-cyg completion-install" to install completion. * "apt-cyg completion-uninstall" to uninstall completion. * "apt-cyg mirrors-list" to show list of mirrors. +* "apt-cyg benchmark-mirrors <url> ..." to benchmark mirrors. +* "apt-cyg benchmark-parallel-mirrors <url> ..." to benchmark mirrors in parallel. +* "apt-cyg benchmark-parallel-mirrors-list" to benchmark mirrors-list in parallel. Requirements ----------- From 9eddf574e84ad7aac5c5489254fbf02c177118ea Mon Sep 17 00:00:00 2001 From: kou1okada Date: Sun, 11 Jan 2015 23:01:47 +0900 Subject: [PATCH 091/309] Add scriptinfo --- apt-cyg | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/apt-cyg b/apt-cyg index 2626a7f..877dd16 100755 --- a/apt-cyg +++ b/apt-cyg @@ -850,6 +850,20 @@ function apt-cyg-benchmark-parallel-mirrors-list apt-cyg-benchmark-parallel-mirrors "${mirrors[@]}" } +function apt-cyg-scriptinfo () +{ +cat< Date: Sun, 11 Jan 2015 23:05:54 +0900 Subject: [PATCH 092/309] Uniformed the format of the function definition. --- apt-cyg | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apt-cyg b/apt-cyg index 877dd16..f5eb2a1 100755 --- a/apt-cyg +++ b/apt-cyg @@ -816,7 +816,7 @@ function apt-cyg-mirrors-list () ' "/etc/setup/setup.rc" } -function apt-cyg-benchmark-mirrors +function apt-cyg-benchmark-mirrors () { local mirror result exitcode for mirror; do @@ -830,7 +830,7 @@ function apt-cyg-benchmark-mirrors done } -function apt-cyg-benchmark-parallel-mirrors +function apt-cyg-benchmark-parallel-mirrors () { local result="$(mktemp "${SCRIPTNAME}.$$.XXXXX")" local mirror @@ -843,7 +843,7 @@ function apt-cyg-benchmark-parallel-mirrors } -function apt-cyg-benchmark-parallel-mirrors-list +function apt-cyg-benchmark-parallel-mirrors-list () { local mirrors readarray -t mirrors < <(apt-cyg-mirrors-list) From 9625695c123c80b499cde702e2b546a3f27f291e Mon Sep 17 00:00:00 2001 From: kou1okada Date: Tue, 20 Jan 2015 04:45:59 +0900 Subject: [PATCH 093/309] Add show-packages-busyness subcommand. --- apt-cyg | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/apt-cyg b/apt-cyg index f5eb2a1..d773b62 100755 --- a/apt-cyg +++ b/apt-cyg @@ -81,7 +81,8 @@ function usage() echo " \"apt-cyg mirrors-list\" to show list of mirros." echo " \"apt-cyg benchmark-mirrors ...\" to benchmark mirrors." echo " \"apt-cyg benchmark-parallel-mirrors ...\" to benchmark mirrors in parallel." - echo " \"apt-cyg benchmark-parallel-mirrors-list\" to benchmark mirrors-list in parallel." + echo " \"apt-cyg scriptinfo\" to show script infomations." + echo " \"apt-cyg show-packages-busyness\" to show packages are busy or noe." echo "Options:" echo " --charch : change archetecture" echo " --use-setuprc : set cache and mirror with /etc/setup/setup.rc" @@ -864,6 +865,25 @@ SCRIPT_REALDIR = "$SCRIPT_REALDIR" EOD } +# Usage: isbusy [file ...] +function isbusy () +{ + perl -e 'foreach $i(@ARGV){if(-f $i){open(DATAFILE,"+<",$i)||exit(0);close(DATAFILE);}}exit(1);' -- "$@" +} + +function apt-cyg-show-packages-busyness () +{ + local pkg lst files + for pkg; do + lst="/etc/setup/${pkg}.lst.gz" + if [ -e "$lst" ]; then + readarray -t files < <(gzip -dc "$lst"|sed 's:^:/:g') + isbusy "${files[@]}" && echo -n "busy: " || echo -n "free: " + echo "$pkg" + fi + done +} + # Lesser Parallel for Embedding # Copyright (c) 2014 Koichi OKADA. All rights reserved. # The official repository is: From 296c1a76c916a38ee4ec039c9f5ccde757b800d6 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Sun, 25 Jan 2015 03:49:28 +0900 Subject: [PATCH 094/309] Update Readme.md and help message. --- README.md | 2 ++ apt-cyg | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a6b6703..e449428 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,8 @@ apt-cyg is a command-line installer for [Cygwin](http://cygwin.com/) which coope * "apt-cyg benchmark-mirrors <url> ..." to benchmark mirrors. * "apt-cyg benchmark-parallel-mirrors <url> ..." to benchmark mirrors in parallel. * "apt-cyg benchmark-parallel-mirrors-list" to benchmark mirrors-list in parallel. +* "apt-cyg scriptinfo" to show script infomations." +* "apt-cyg show-packages-busyness <package names> ..." to show packages are busy or noe." Requirements ----------- diff --git a/apt-cyg b/apt-cyg index d773b62..bc8f5c7 100755 --- a/apt-cyg +++ b/apt-cyg @@ -81,8 +81,9 @@ function usage() echo " \"apt-cyg mirrors-list\" to show list of mirros." echo " \"apt-cyg benchmark-mirrors ...\" to benchmark mirrors." echo " \"apt-cyg benchmark-parallel-mirrors ...\" to benchmark mirrors in parallel." + echo " \"apt-cyg benchmark-parallel-mirrors-list\" to benchmark mirrors-list in parallel." echo " \"apt-cyg scriptinfo\" to show script infomations." - echo " \"apt-cyg show-packages-busyness\" to show packages are busy or noe." + echo " \"apt-cyg show-packages-busyness ...\" to show packages are busy or noe." echo "Options:" echo " --charch : change archetecture" echo " --use-setuprc : set cache and mirror with /etc/setup/setup.rc" From e267ae71ed579c200c9aa12d5aede7144d3de96a Mon Sep 17 00:00:00 2001 From: kou1okada Date: Mon, 9 Feb 2015 11:00:12 +0900 Subject: [PATCH 095/309] Fixed: The "--use-setuprc" option became treat the multibyte name of "last-cache" correctly. The "last-cache" parameter in the "/etc/setup/setup.rc" is recorded by the codepage of Windows system locale. --- apt-cyg | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/apt-cyg b/apt-cyg index bc8f5c7..63e6ef8 100755 --- a/apt-cyg +++ b/apt-cyg @@ -885,6 +885,16 @@ function apt-cyg-show-packages-busyness () done } +function get_codepage () +{ + cmd.exe /c chcp | awk '{printf "CP"$NF;}' +} + +function cp2utf8 () +{ + iconv -f $(get_codepage) -t UTF-8 +} + # Lesser Parallel for Embedding # Copyright (c) 2014 Koichi OKADA. All rights reserved. # The official repository is: @@ -990,8 +1000,8 @@ function parse_args () ;; --use-setuprc) - "$0" -c "$(grep -A1 last-cache /etc/setup/setup.rc | tail -n1 | sed -r 's/^\s*|\s*$//g')" > /dev/null - "$0" -m "$(grep -A1 last-mirror /etc/setup/setup.rc | tail -n1 | sed -r 's/^\s*|\s*$//g')" > /dev/null + "$0" -c "$(grep -aA1 '^last-cache$' /etc/setup/setup.rc | tail -n1 | cp2utf8 | sed -r 's/^\s*|\s*$//g')" > /dev/null + "$0" -m "$(grep -aA1 '^last-mirror$' /etc/setup/setup.rc | tail -n1 | sed -r 's/^\s*|\s*$//g')" > /dev/null shift ;; From 3a43984274244dcf301078fbd2470935a78ae619 Mon Sep 17 00:00:00 2001 From: Alice Ferrazzi Date: Thu, 19 Feb 2015 13:35:41 +0900 Subject: [PATCH 096/309] Argonne software mirror will no longer be available. Public access to the Argonne software mirror will no longer be available as of February 1, 2015. The service will continue to be available onsite to Argonne employees, but offsite access will require an Argonne VPN connection. --- apt-cyg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apt-cyg b/apt-cyg index 63e6ef8..13c019e 100755 --- a/apt-cyg +++ b/apt-cyg @@ -132,7 +132,7 @@ function findworkspace() { # default working directory, mirror and architecture - mirror=ftp://mirror.mcs.anl.gov/pub/cygwin + mirror=ftp://ftp.jaist.ac.jp/pub/cygwin arch="$(current_cygarch)" cache=/setup From 83433b904f5757afa4108fa4c5b48112815d3e9b Mon Sep 17 00:00:00 2001 From: kou1okada Date: Fri, 20 Feb 2015 13:46:42 +0900 Subject: [PATCH 097/309] HTTP seems indicate better performance than FTP at ftp.jaist.ac.jp. --- apt-cyg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apt-cyg b/apt-cyg index 13c019e..10b6109 100755 --- a/apt-cyg +++ b/apt-cyg @@ -132,7 +132,7 @@ function findworkspace() { # default working directory, mirror and architecture - mirror=ftp://ftp.jaist.ac.jp/pub/cygwin + mirror=http://ftp.jaist.ac.jp/pub/cygwin arch="$(current_cygarch)" cache=/setup From 35b9e784ce90e4db0a9ef8e75ded43f302a8c090 Mon Sep 17 00:00:00 2001 From: "emmanuel.lebeaupin" Date: Thu, 19 Mar 2015 19:24:33 +0100 Subject: [PATCH 098/309] Display the package version with show command --- apt-cyg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apt-cyg b/apt-cyg index 10b6109..ac99de7 100755 --- a/apt-cyg +++ b/apt-cyg @@ -567,7 +567,7 @@ function package_db-list () { package_db-version_check - awk 'NF == 3 {print $1}' "${PACKAGE_DB}" + awk 'NF == 3 { $0=gensub(/(.*)-(.*)-(.*).*\..*\..*/, "\\1 \\2-\\3","g",$2) ; printf("%-45s %s\n",$1,$2) }' "${PACKAGE_DB}" } # Usage: package_db-register PKGNAME PKGFILE From 64542fd0025e8ad5d52e5903aaf455d01ed45af2 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Sat, 21 Mar 2015 10:17:46 +0900 Subject: [PATCH 099/309] An alignment of source code was adjusted. --- apt-cyg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apt-cyg b/apt-cyg index ac99de7..d94a597 100755 --- a/apt-cyg +++ b/apt-cyg @@ -718,7 +718,7 @@ function apt-cyg-completion-install () readarray -t -O ${#OPTIONS[@]} OPTIONS < <( awk ' /^function *parse_args *\(\)/ {proc=1} - /^} *# *\/parse_args( |$)/ {proc=0} + /^} *# *\/parse_args( |$)/ {proc=0} proc && match($0, /^ *(-[^()*]+)\)/, m) { split(m[1], x, "|"); for (i in x) print x[i]; From 05d4a5903a06a437c4a39d33abff4b37ac69ac0e Mon Sep 17 00:00:00 2001 From: kou1okada Date: Fri, 27 Mar 2015 04:37:22 +0900 Subject: [PATCH 100/309] Oops, now setup.ini seems to change the hash algorithm from md5 to sha512. I'd like to thank the following comments and commit. * https://github.com/transcode-open/apt-cyg/issues/37#issuecomment-85499851 * https://github.com/jfritz/apt-cyg/commit/97848cfa9ae05297c0b01daeb8ad08a70bc3b77b --- apt-cyg | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apt-cyg b/apt-cyg index d94a597..f89b2d6 100755 --- a/apt-cyg +++ b/apt-cyg @@ -1268,11 +1268,11 @@ function apt-cyg-install () cd "release/$pkg" "${WGET[@]}" -nc $mirror/$install - # check the md5 + # check the SHA512 hash local digest="$(awk '/^install: / { print $4; exit }' "desc")" - local digactual="$(md5sum $file | awk '{print $1}')" + local digactual="$(sha512sum $file | awk '{print $1}')" if [ "$digest" != "$digactual" ]; then - echo MD5 sum did not match, exiting + echo SHA512 sum did not match, exiting exit 1 fi From cd55c387056f46c4d2823367fc25caf1c122cbc9 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Mon, 30 Mar 2015 21:28:58 +0900 Subject: [PATCH 101/309] Now, hash checker determines hash algorithm automatically. This patch supports md5, sha1, sha224, sha256, sha384 and sha512. --- apt-cyg | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 52 insertions(+), 4 deletions(-) diff --git a/apt-cyg b/apt-cyg index f89b2d6..7890528 100755 --- a/apt-cyg +++ b/apt-cyg @@ -338,7 +338,7 @@ function wget_and_check_md5sum () local FILE="$4" "${WGET[@]}" "$URL" -O "$FILE" wget_return_case_md5sum "$?" || return 1 - if ! { echo "$MD5 *$FILE" | md5sum -c >& /dev/null; } then + if ! { echo "$MD5 *$FILE" | hash_check >& /dev/null; } then echo "$LABEL: FAILED: MD5 hash is not match." return 2 fi @@ -895,6 +895,55 @@ function cp2utf8 () iconv -f $(get_codepage) -t UTF-8 } +# dummy command for unknown sum. +# Usage: unknownsum +function unknownsum () +{ + return 1 +} + +# Determine the hash method from a HASH. +# Usage: hash_method HASH +function hash_method () +{ + case "${#1}" in + 32) echo md5 ;; + 40) echo sha1 ;; + 56) echo sha224 ;; + 64) echo sha256 ;; + 96) echo sha384 ;; + 128) echo sha512 ;; + *) echo unknown ;; + esac +} + +# Read md5 and sha{1,224,256,384,512} sums from the FILEs and check them. +# Usage: hash_check [FILE ...] +function hash_check () +{ + local f0 f1 f2 method count=0 + while true; do + while read f0; do + f1="${f0% *}" + f2="${f0#*\*}" + method="$(hash_method "$f1")sum" + if echo "$f0" | "$method" -c --status; then + echo "hash_check: $method: $f2: OK" + else + echo "hash_check: $method: $f2: FAILED" + count=$(( count + 1 )) + fi + done 0<${1:-/dev/stdin} + shift + (( $# <= 0 )) && break + done + if (( 0 < count )); then + echo "hash_check: WARNING: $count computed checksum did NOT match" + return 1 + fi + return 0 +} + # Lesser Parallel for Embedding # Copyright (c) 2014 Koichi OKADA. All rights reserved. # The official repository is: @@ -1270,9 +1319,8 @@ function apt-cyg-install () # check the SHA512 hash local digest="$(awk '/^install: / { print $4; exit }' "desc")" - local digactual="$(sha512sum $file | awk '{print $1}')" - if [ "$digest" != "$digactual" ]; then - echo SHA512 sum did not match, exiting + if ! echo "${digest} *${file}" | hash_check; then + echo "error: hash did not match: $file" exit 1 fi From f9bd517bbb0b162a9d51a4c0c30be891ee42c797 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Tue, 31 Mar 2015 18:07:50 +0900 Subject: [PATCH 102/309] FIXED: wget_return_case_md5sum had returned incorrect return code at case 8. --- apt-cyg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apt-cyg b/apt-cyg index 7890528..7ddc792 100755 --- a/apt-cyg +++ b/apt-cyg @@ -324,7 +324,7 @@ function wget_return_case_md5sum () "${WGET[@]}" --no-check-certificate "$URL" -O "$FILE" return 0 ;; - 8) echo "$LABEL: FAILED: 404 Not Found $URL." return 1 ;; + 8) echo "$LABEL: FAILED: 404 Not Found $URL."; return 1 ;; *) echo -e "\e[31;1mError:\e[30;0m FATAL: wget returned unkown value"; return 1 ;; esac } From 06c99c1aa75bc47fcf98dc01a0b999a8a67fe17b Mon Sep 17 00:00:00 2001 From: kou1okada Date: Tue, 31 Mar 2015 20:14:08 +0900 Subject: [PATCH 103/309] Refactoring: rewrite names about md5. --- apt-cyg | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/apt-cyg b/apt-cyg index 7ddc792..2743bf1 100755 --- a/apt-cyg +++ b/apt-cyg @@ -31,7 +31,7 @@ TRUSTEDKEYS=( CYGWIN CYGWINPORTS ); # pub 1024D/676041BA 2008-06-13 # uid Cygwin # sub 1024g/A1DB7B5C 2008-06-13 -TRUSTEDKEY_CYGWIN_MD5="8555ea34b03d7b09b04886b08d310d8d" +TRUSTEDKEY_CYGWIN_SUM="8555ea34b03d7b09b04886b08d310d8d" TRUSTEDKEY_CYGWIN_FPR="1169DF9F22734F743AA59232A9A262FF676041BA" TRUSTEDKEY_CYGWIN_URL_LATEST="https://cygwin.com/key/pubring.asc" # ./ports.gpg @@ -39,7 +39,7 @@ TRUSTEDKEY_CYGWIN_URL_LATEST="https://cygwin.com/key/pubring.asc" # pub 1024D/66EE1F94 2008-10-27 # uid Yaakov Selkowitz (Cygwin Ports) # sub 4096g/7D66B0D2 2008-10-27 -TRUSTEDKEY_CYGWINPORTS_MD5="4c7904807340411f48f7519173cd600d" +TRUSTEDKEY_CYGWINPORTS_SUM="4c7904807340411f48f7519173cd600d" TRUSTEDKEY_CYGWINPORTS_FPR="45600BB98CA878AA97A70119FF20AF9A66EE1F94" TRUSTEDKEY_CYGWINPORTS_URL_LATEST="http://cygwinports.org/ports.gpg" @@ -313,13 +313,13 @@ function wget-exitstatus () esac } -# Usage: wget_return_case_md5sum returncode -function wget_return_case_md5sum () +# Usage: wget_return_case returncode +function wget_return_case () { case "$1" in 0) return 0 ;; - 1) echo "$LABEL: FAILED: Could not download $URL."; return 1 ;; - 5) echo "$LABEL: WARNING: The SSL certificate is invalid $URL." + 1) echo "$LABEL: FAILED: Could not download: $URL."; return 1 ;; + 5) echo "$LABEL: WARNING: The SSL certificate is invalid: $URL." ask_user "Continue regardless of invalid SSL certificate?" || return 1 "${WGET[@]}" --no-check-certificate "$URL" -O "$FILE" return 0 @@ -329,17 +329,17 @@ function wget_return_case_md5sum () esac } -# Usage: wget_and_check_md5sum label hash url file -function wget_and_check_md5sum () +# Usage: wget_and_hash_check label hash url file +function wget_and_hash_check () { local LABEL="$1" - local MD5="$2" + local SUM="$2" local URL="$3" local FILE="$4" "${WGET[@]}" "$URL" -O "$FILE" - wget_return_case_md5sum "$?" || return 1 - if ! { echo "$MD5 *$FILE" | hash_check >& /dev/null; } then - echo "$LABEL: FAILED: MD5 hash is not match." + wget_return_case "$?" || return 1 + if ! echo "$SUM *$FILE" | hash_check >& /dev/null; then + echo "$LABEL: FAILED: Hash does not match $URL." return 2 fi echo "$LABEL: OK" @@ -353,7 +353,7 @@ function fetch_trustedkeys () local FILE_LATEST="$(mktemp)" for i in "${TRUSTEDKEYS[@]}"; do local LABEL="TRUSTEDKEY_${i}" - local MD5="$(eval echo "\$${LABEL}_MD5")" + local SUM="$(eval echo "\$${LABEL}_SUM")" local FPR="$(eval echo "\$${LABEL}_FPR")" local URL="$(eval echo "\$${LABEL}_URL")" local URL_LATEST="$(eval echo "\$${LABEL}_URL_LATEST")" @@ -362,13 +362,13 @@ function fetch_trustedkeys () continue fi if [ -n "$URL" ]; then - wget_and_check_md5sum "$LABEL" "$MD5" "$URL" "$FILE" + wget_and_hash_check "$LABEL" "$SUM" "$URL" "$FILE" CASE+="$?" else CASE+="-" fi if [ -n "$URL_LATEST" ]; then - wget_and_check_md5sum "$LABEL" "$MD5" "$URL_LATEST" "$FILE_LATEST" + wget_and_hash_check "$LABEL" "$SUM" "$URL_LATEST" "$FILE_LATEST" CASE+="$?" else CASE+="-" From 91a28fb7c7aea737a2dfa9292155fdbd2ca6927c Mon Sep 17 00:00:00 2001 From: kou1okada Date: Tue, 31 Mar 2015 20:23:42 +0900 Subject: [PATCH 104/309] Discard function wget_return_case. It's fungible by --no-certificate option. --- apt-cyg | 40 ++++------------------------------------ 1 file changed, 4 insertions(+), 36 deletions(-) diff --git a/apt-cyg b/apt-cyg index 2743bf1..76f85f0 100755 --- a/apt-cyg +++ b/apt-cyg @@ -276,24 +276,6 @@ function init_gnupg () GPG_KEYRING=( --keyring pubring.gpg ) } -# Usage: ask_user "question?" (optional recognition of YES_TO_ALL=true auto yes) -function ask_user () -{ - while true; do - [ -n "$2" ] && { local pmt="$2"; local def=; } - [ -n "$2" ] || { local pmt="y/n";local def=; } - $YES_TO_ALL && { local RPY=Y;local def=Y; } - [ -z "$def" ] && { echo -ne "$1 ";read -p "[$pmt] " RPY; } - [ -z "$RPY" ] && { local RPY=$def; } - case "$RPY" in - Y*|y*) return 0 ;; - N*|n*) return 1 ;; - 1*) return 0 ;; - 2*) return 1 ;; - esac - done -} - # Reference: # https://www.gnu.org/software/wget/manual/wget.html#Exit-Status # Usage: wget-exitstatus EXITSTATUS @@ -313,22 +295,6 @@ function wget-exitstatus () esac } -# Usage: wget_return_case returncode -function wget_return_case () -{ - case "$1" in - 0) return 0 ;; - 1) echo "$LABEL: FAILED: Could not download: $URL."; return 1 ;; - 5) echo "$LABEL: WARNING: The SSL certificate is invalid: $URL." - ask_user "Continue regardless of invalid SSL certificate?" || return 1 - "${WGET[@]}" --no-check-certificate "$URL" -O "$FILE" - return 0 - ;; - 8) echo "$LABEL: FAILED: 404 Not Found $URL."; return 1 ;; - *) echo -e "\e[31;1mError:\e[30;0m FATAL: wget returned unkown value"; return 1 ;; - esac -} - # Usage: wget_and_hash_check label hash url file function wget_and_hash_check () { @@ -336,8 +302,10 @@ function wget_and_hash_check () local SUM="$2" local URL="$3" local FILE="$4" - "${WGET[@]}" "$URL" -O "$FILE" - wget_return_case "$?" || return 1 + if ! "${WGET[@]}" "$URL" -O "$FILE"; then + echo "$LABEL: FAILED: Could not download $URL." + return 1 + fi if ! echo "$SUM *$FILE" | hash_check >& /dev/null; then echo "$LABEL: FAILED: Hash does not match $URL." return 2 From 33c97f073b084ae73e9f034df561bee7609e57db Mon Sep 17 00:00:00 2001 From: kou1okada Date: Tue, 31 Mar 2015 20:51:52 +0900 Subject: [PATCH 105/309] Add advice functions. --- apt-cyg | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/apt-cyg b/apt-cyg index 76f85f0..b0cc436 100755 --- a/apt-cyg +++ b/apt-cyg @@ -295,6 +295,39 @@ function wget-exitstatus () esac } +function wget_advice () +{ + local status=${1:-$?} + case $status in + 5) echo "If you can tolerate security risks, use --no-certification option." ;; + esac + return $status +} + +# Usage: get_advice cmd +function get_advice () +{ + local status=${2:-$?} + type "${1}_advice" >&/dev/nul && { ( exit $status ); "${1}_advice"; } + return $status +} + +# Usage: push_advice cmd +function push_advice () +{ + local status=${2:-$?} + ADVICE+=( "$( get_advice "${1}_advice")" ) + return $status +} + +function show_advice () +{ + local i + for i in "${ADVICE[@]}"; do + echo "$i" >&2 + done +} + # Usage: wget_and_hash_check label hash url file function wget_and_hash_check () { @@ -302,7 +335,7 @@ function wget_and_hash_check () local SUM="$2" local URL="$3" local FILE="$4" - if ! "${WGET[@]}" "$URL" -O "$FILE"; then + if ! { "${WGET[@]}" "$URL" -O "$FILE" || get_advice wget; }; then echo "$LABEL: FAILED: Could not download $URL." return 1 fi From 4061c38919d2da988290c880a2b9b9e6bf6df9bd Mon Sep 17 00:00:00 2001 From: kou1okada Date: Tue, 31 Mar 2015 20:57:50 +0900 Subject: [PATCH 106/309] Change the hash for the GnuPG publick key from md5 to sha512. --- apt-cyg | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apt-cyg b/apt-cyg index b0cc436..4d567de 100755 --- a/apt-cyg +++ b/apt-cyg @@ -31,7 +31,7 @@ TRUSTEDKEYS=( CYGWIN CYGWINPORTS ); # pub 1024D/676041BA 2008-06-13 # uid Cygwin # sub 1024g/A1DB7B5C 2008-06-13 -TRUSTEDKEY_CYGWIN_SUM="8555ea34b03d7b09b04886b08d310d8d" +TRUSTEDKEY_CYGWIN_SUM="e6630b94e6bf1afcc1b1054afa9994a423764d795b2a3a5e831fc658962905dcadf63c3a29155136f3138d6375176c9384de68d12a6dd4dde35b55c9b225cd7f" TRUSTEDKEY_CYGWIN_FPR="1169DF9F22734F743AA59232A9A262FF676041BA" TRUSTEDKEY_CYGWIN_URL_LATEST="https://cygwin.com/key/pubring.asc" # ./ports.gpg @@ -39,7 +39,7 @@ TRUSTEDKEY_CYGWIN_URL_LATEST="https://cygwin.com/key/pubring.asc" # pub 1024D/66EE1F94 2008-10-27 # uid Yaakov Selkowitz (Cygwin Ports) # sub 4096g/7D66B0D2 2008-10-27 -TRUSTEDKEY_CYGWINPORTS_SUM="4c7904807340411f48f7519173cd600d" +TRUSTEDKEY_CYGWINPORTS_SUM="ccf174d1e6ec20e50ff954e3d4a0c3de478032a100d26789c0190587ae80128e842ff5404ed3b48f8693c8803c88a3acbf8dca339edfdaab0f3c247fb6091e42" TRUSTEDKEY_CYGWINPORTS_FPR="45600BB98CA878AA97A70119FF20AF9A66EE1F94" TRUSTEDKEY_CYGWINPORTS_URL_LATEST="http://cygwinports.org/ports.gpg" From 58e8b916d0b0fac4677444a4411af2282338277d Mon Sep 17 00:00:00 2001 From: kou1okada Date: Thu, 9 Apr 2015 09:24:28 +0900 Subject: [PATCH 107/309] Add debug mode level 5. This level enables XXX, and it displays command for each line. To enable debug mode, execute apt-cyg as following. DEBUG=5 apt-cyg --- apt-cyg | 2 ++ 1 file changed, 2 insertions(+) diff --git a/apt-cyg b/apt-cyg index 4d567de..bddaee5 100755 --- a/apt-cyg +++ b/apt-cyg @@ -43,6 +43,8 @@ TRUSTEDKEY_CYGWINPORTS_SUM="ccf174d1e6ec20e50ff954e3d4a0c3de478032a100d26789c019 TRUSTEDKEY_CYGWINPORTS_FPR="45600BB98CA878AA97A70119FF20AF9A66EE1F94" TRUSTEDKEY_CYGWINPORTS_URL_LATEST="http://cygwinports.org/ports.gpg" +(( 5 <= "${DEBUG:-0}" )) && set -x + # this script requires some packages WGET="$( which wget 2>/dev/null )" From 01318a20afb311d5810af327e372025cb837e45a Mon Sep 17 00:00:00 2001 From: kou1okada Date: Thu, 9 Apr 2015 09:25:42 +0900 Subject: [PATCH 108/309] Add dist-upgrade subcommand. This subcommand calls `setup-x86.exe` and `setup-x86_64.exe`. --- apt-cyg | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/apt-cyg b/apt-cyg index bddaee5..5f8da3c 100755 --- a/apt-cyg +++ b/apt-cyg @@ -278,6 +278,28 @@ function init_gnupg () GPG_KEYRING=( --keyring pubring.gpg ) } +# Usage: ask_user [MESSAGE [OPTIONS]] +function ask_user () +{ + local answer retcode option + local MESSAGE="$1" + local OPTIONS="${2:-y/N}" + local DEFAULT="$(echo "$OPTIONS" | awk -v FS=/ '{for(i=1;i<=NF;i++)if(match(substr($i,1,1),/[A-Z]/)){print $i; exit}}')" + local SPLIT_OPTIONS + readarray -t SPLIT_OPTIONS < <(echo "$OPTIONS" | sed -e 's:/:\n:g') + while true; do + echo -n "${MESSAGE}${MESSAGE:+ }[${OPTIONS}] " + read answer + retcode=0 + for option in "${SPLIT_OPTIONS[@]}"; do + if [ "$option" = "${answer:-$DEFAULT}" ]; then + return $retcode + fi + retcode=$(( retcode + 1 )) + done + done +} + # Reference: # https://www.gnu.org/software/wget/manual/wget.html#Exit-Status # Usage: wget-exitstatus EXITSTATUS @@ -947,6 +969,54 @@ function hash_check () return 0 } +function kill_all_cygwin_process () +{ + local family + local pid=$BASHPID + local pslog=$(ps -f | tail -n +2 | awk '{print $2, $3}') + readarray -t family < <(echo "$pslog" | awk -v pid=$pid ' + {ppids[$1] = $2;} + END {while (1 < pid) {print "-e\n"pid; pid = ppids[pid];}} + ') + ps -f + "$pslog" + "${family[@]}" + kill -9 $(echo "$pslog" | grep -v "${family[@]}" | awk '{print $1}') ${family[$((${#family[@]} - 1))]} +} + +function apt-cyg-upgrade-no-ask () +{ + local ARCH="$(current_cygarch)" + local SETUP_EXE="setup-${ARCH}.exe" + + if [ -z "$ARCH" ]; then + echo -e "\e[31;1mError:\e[30;0m ARCH could not be resolved." + exit 1 + fi + + pushd "$(apt-cyg-pathof cache)" + "${WGET[@]}" -N "http://cygwin.com/${SETUP_EXE}" && chmod +x "${SETUP_EXE}" || { + echo -e "\e[31;1mError:\e[30;0m ${SETUP_EXE} could not be downloaded." + exit 1 + } + cygstart cmd /c 'CD '"$(cygpath -w "$(pwd)")"' && CD && ECHO Press any key to start upgrade && PAUSE && START /WAIT ./'"${SETUP_EXE}"' -B -q -g && C:\cygwin\bin\ash -c "/bin/rebaseall -v" && ECHO dist-upgrade is finished && ECHO Press any key to exit && PAUSE' + kill_all_cygwin_process + + popd +} + +function apt-cyg-dist-upgrade () +{ + echo "Kill all cygwin process and start dist-upgrade." + ask_user "Are you sure ?" && { + echo "Start dist-upgrade ..." + sleep 1 + apt-cyg-upgrade-no-ask + } || { + echo "Abort." + } +} + # Lesser Parallel for Embedding # Copyright (c) 2014 Koichi OKADA. All rights reserved. # The official repository is: From 06937ce60d0ad7bbea17a82f597289ad6495d87b Mon Sep 17 00:00:00 2001 From: kou1okada Date: Thu, 9 Apr 2015 09:26:35 +0900 Subject: [PATCH 109/309] Backend of verify_signatures functon is changed from gpgv to gpg. Under 32 bit environment, gpgv seems not work correctly. --- apt-cyg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apt-cyg b/apt-cyg index 5f8da3c..11ed653 100755 --- a/apt-cyg +++ b/apt-cyg @@ -438,7 +438,7 @@ function fetch_trustedkeys () function verify_signatures () { while [ $# -gt 0 ]; do - if ! "${GPGV[@]}" "${GPG_KEYRING[@]}" "$1"; then + if ! "${GPG[@]}" "${GPG_KEYRING[@]}" "$1"; then echo -e "\e[31;1mError:\e[30;0m BAD signature: $1" return 1 fi From 4857b10e5105ff58cf635902f0fc224fede6d936 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Thu, 9 Apr 2015 18:04:02 +0900 Subject: [PATCH 110/309] Update help and README.md. --- README.md | 20 +++++++++++++++++++- apt-cyg | 1 + 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e449428..a0758b4 100644 --- a/README.md +++ b/README.md @@ -26,9 +26,10 @@ apt-cyg is a command-line installer for [Cygwin](http://cygwin.com/) which coope * "apt-cyg benchmark-parallel-mirrors-list" to benchmark mirrors-list in parallel. * "apt-cyg scriptinfo" to show script infomations." * "apt-cyg show-packages-busyness <package names> ..." to show packages are busy or noe." +* "apt-cyg dist-upgrade" to upgrade all packages that is installed. This subcommand uses setup-*.exe Requirements ------------ +------------ apt-cyg requires the cygwin default environment and optional packages below. @@ -73,6 +74,17 @@ Then use apt-cyg, for example: New features ------------ +### dist-upgrade support + +This fork has achieved dist-upgrade command by using `setup-x86.exe` and `setup-x96_64.exe` as a backend. +Note that all of running tasks on the cygwin will be killed before starting dist-upgrade. + +### Multiple hash algorithms support + +After the middle of 2015-03, the cygwin project changed the hash algorithm for checking tarball from md5 to sha512. +But, as of 2015-04-09, the cygwinports project seems still using md5. +This fork is available for both of cygwin and cygwinports by supporting algorithm of md5, sha1, sha224, sha256 and sha512. + ### True multi-architecture support Let think a case that you want to install the x86 package when you are working under the x86_64 environment. @@ -173,6 +185,12 @@ Todo Known Problem ------------ + +### 2015-04-09: gpgv seems not work correctly on 32 bit environment + +To solve this problem, the backend of `verify_signatures` function was changed from `gpgv` to `gpg`. +thienhv reported this problem [#14](https://github.com/kou1okada/apt-cyg/issues/14). Thanks. + ### 2014-01-17: ca-certificates package is not setup correct at x86_64 with Windows 8. After clean installing with setup-x86_64, there are something wrong about ca-certificate package as below: diff --git a/apt-cyg b/apt-cyg index 11ed653..5ebfa7c 100755 --- a/apt-cyg +++ b/apt-cyg @@ -86,6 +86,7 @@ function usage() echo " \"apt-cyg benchmark-parallel-mirrors-list\" to benchmark mirrors-list in parallel." echo " \"apt-cyg scriptinfo\" to show script infomations." echo " \"apt-cyg show-packages-busyness ...\" to show packages are busy or noe." + echo " \"apt-cyg dist-upgrade\" to upgrade all packages that is installed. This subcommand uses setup-*.exe" echo "Options:" echo " --charch : change archetecture" echo " --use-setuprc : set cache and mirror with /etc/setup/setup.rc" From 1a2ad89a6852262dd5e1c74917716bd9465053d0 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Thu, 9 Apr 2015 23:50:58 +0900 Subject: [PATCH 111/309] Some minor changes for dist-upgrade. --- apt-cyg | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/apt-cyg b/apt-cyg index 5ebfa7c..69a46a6 100755 --- a/apt-cyg +++ b/apt-cyg @@ -979,27 +979,29 @@ function kill_all_cygwin_process () {ppids[$1] = $2;} END {while (1 < pid) {print "-e\n"pid; pid = ppids[pid];}} ') - ps -f - "$pslog" - "${family[@]}" kill -9 $(echo "$pslog" | grep -v "${family[@]}" | awk '{print $1}') ${family[$((${#family[@]} - 1))]} } -function apt-cyg-upgrade-no-ask () +function apt-cyg-update-setup () { - local ARCH="$(current_cygarch)" - local SETUP_EXE="setup-${ARCH}.exe" + pushd "$(apt-cyg-pathof cache)" - if [ -z "$ARCH" ]; then - echo -e "\e[31;1mError:\e[30;0m ARCH could not be resolved." + if "${WGET[@]}" -N "https://cygwin.com/${SETUP_EXE}"; then + chmod +x "${SETUP_EXE}" + ls -l + else + echo -e "\e[31;1mError:\e[30;0m ${SETUP_EXE} could not be downloaded." exit 1 fi + popd +} + +function apt-cyg-dist-upgrade-no-ask () +{ pushd "$(apt-cyg-pathof cache)" - "${WGET[@]}" -N "http://cygwin.com/${SETUP_EXE}" && chmod +x "${SETUP_EXE}" || { - echo -e "\e[31;1mError:\e[30;0m ${SETUP_EXE} could not be downloaded." - exit 1 - } + + apt-cyg-update-setup cygstart cmd /c 'CD '"$(cygpath -w "$(pwd)")"' && CD && ECHO Press any key to start upgrade && PAUSE && START /WAIT ./'"${SETUP_EXE}"' -B -q -g && C:\cygwin\bin\ash -c "/bin/rebaseall -v" && ECHO dist-upgrade is finished && ECHO Press any key to exit && PAUSE' kill_all_cygwin_process @@ -1012,7 +1014,7 @@ function apt-cyg-dist-upgrade () ask_user "Are you sure ?" && { echo "Start dist-upgrade ..." sleep 1 - apt-cyg-upgrade-no-ask + apt-cyg-dist-upgrade-no-ask } || { echo "Abort." } @@ -1106,6 +1108,7 @@ force_fetch_trustedkeys="" no_verify="" OPT_PROXY=${APT_CYG_PROXY:-auto} OPTS4INHERIT=() +SETUP_EXE="setup-$(current_cygarch).exe" YES_TO_ALL=false INITIAL_ARGS=( "$@" ) ARGS=() From 61e722265655e7cf8013f728488c99560460f4ba Mon Sep 17 00:00:00 2001 From: kou1okada Date: Fri, 10 Apr 2015 00:04:29 +0900 Subject: [PATCH 112/309] Add setup subcommand. It is just a wrapper to call setup.exe. --- apt-cyg | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/apt-cyg b/apt-cyg index 69a46a6..1625905 100755 --- a/apt-cyg +++ b/apt-cyg @@ -86,7 +86,9 @@ function usage() echo " \"apt-cyg benchmark-parallel-mirrors-list\" to benchmark mirrors-list in parallel." echo " \"apt-cyg scriptinfo\" to show script infomations." echo " \"apt-cyg show-packages-busyness ...\" to show packages are busy or noe." - echo " \"apt-cyg dist-upgrade\" to upgrade all packages that is installed. This subcommand uses setup-*.exe" + echo " \"apt-cyg dist-upgrade\" to upgrade all packages that is installed. This subcommand uses setup.exe" + echo " \"apt-cyg update-setup\" to update setup.exe" + echo " \"apt-cyg setup\" to call setup.exe" echo "Options:" echo " --charch : change archetecture" echo " --use-setuprc : set cache and mirror with /etc/setup/setup.rc" @@ -95,6 +97,7 @@ function usage() echo " --force-fetch-trustedkeys: force fetch trustedkeys" echo " --no-verify, -X : Don't verify setup.ini signatures" echo " --no-check-certificate : Don't validate the server's certificate" + echo " --no-update-setup : Don't update setup.exe" echo " --proxy, -p :" echo " set proxy (default: \${APT_CYG_PROXY:-auto})" echo " --completion-get-subcommand:" @@ -984,11 +987,13 @@ function kill_all_cygwin_process () function apt-cyg-update-setup () { + [ -n "$OPT_NO_UPDATE_SETUP" ] && return + pushd "$(apt-cyg-pathof cache)" if "${WGET[@]}" -N "https://cygwin.com/${SETUP_EXE}"; then chmod +x "${SETUP_EXE}" - ls -l + ls -l "${SETUP_EXE}" else echo -e "\e[31;1mError:\e[30;0m ${SETUP_EXE} could not be downloaded." exit 1 @@ -997,6 +1002,16 @@ function apt-cyg-update-setup () popd } +function apt-cyg-setup () +{ + pushd "$(apt-cyg pathof cache)" + + apt-cyg-update-setup + ./"${SETUP_EXE}" "$@" + + popd +} + function apt-cyg-dist-upgrade-no-ask () { pushd "$(apt-cyg-pathof cache)" @@ -1115,7 +1130,7 @@ ARGS=() function parse_args () { - local unknown_option + local unknown_option END_OPTS while [ $# -gt 0 ]; do case "$1" in @@ -1158,6 +1173,11 @@ function parse_args () shift ;; + --no-update-setup) + OPT_NO_UPDATE_SETUP="$1" + shift + ;; + --proxy|-p) OPT_PROXY="$2" shift 2 || break @@ -1218,6 +1238,12 @@ function parse_args () shift 2 || break ;; + --) + END_OPTS="$1" + shift + break + ;; + -*) unknown_option="$1" break @@ -1235,6 +1261,7 @@ function parse_args () esac done + [ -n "$END_OPTS" ] && while (( 0 < "$#" )); do ARGS+=( "$1" ); shift; done if [ -n "$OPT_COMPLETION_GET_SUBCOMMAND" ]; then echo "$SUBCOMMAND" From 08be8a0616b73e1c87a28f2783ffaef254a3a1ac Mon Sep 17 00:00:00 2001 From: kou1okada Date: Mon, 13 Apr 2015 03:27:32 +0900 Subject: [PATCH 113/309] Fixed misspelling. --- apt-cyg | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apt-cyg b/apt-cyg index 1625905..63a166e 100755 --- a/apt-cyg +++ b/apt-cyg @@ -177,7 +177,7 @@ function download_and_verify () function files_backup () { - locale file + local file for file; do [ -e "${file}~" ] && mv "${file}~" "${file}" [ -e "${file}" ] && cp -a "${file}" "${file}~" @@ -186,7 +186,7 @@ function files_backup () function files_restore () { - locale file + local file for file; do [ -e "${file}" ] && rm "${file}" [ -e "${file}~" ] && mv "${file}~" "${file}" @@ -195,7 +195,7 @@ function files_restore () function files_backup_clean () { - locale file + local file for file; do [ -e "${file}~" ] && rm "${file}~" done From 04f6cbef506b87e729547e7f457c0ac9a7e91b8b Mon Sep 17 00:00:00 2001 From: kou1okada Date: Wed, 15 Apr 2015 01:33:47 +0900 Subject: [PATCH 114/309] Update README.md --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index a0758b4..ddb12ba 100644 --- a/README.md +++ b/README.md @@ -163,6 +163,10 @@ Ex.) Merging to the GPL from the MIT is possible. But merging to the MIT from th * [transcodes-open / apt-cyg](https://github.com/transcode-open/apt-cyg/network) +#### Unofficial (MIT license) + +* [digitallamb / apt-cyg](https://github.com/digitallamb/apt-cyg) + #### Unofficial (GPLv2) * [cfg / apt-cyg](https://github.com/cfg/apt-cyg/network) From fc5b3feee45defa1f740c538e6acbde5579b5ceb Mon Sep 17 00:00:00 2001 From: kou1okada Date: Thu, 16 Apr 2015 13:26:19 +0900 Subject: [PATCH 115/309] FIXED: If here documents are used, 0<${1:-/dev/stdin} can not work. 0<${1:-<(cat)} seems well for here documents. --- apt-cyg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apt-cyg b/apt-cyg index 63a166e..b4a7854 100755 --- a/apt-cyg +++ b/apt-cyg @@ -962,7 +962,7 @@ function hash_check () echo "hash_check: $method: $f2: FAILED" count=$(( count + 1 )) fi - done 0<${1:-/dev/stdin} + done 0<${1:-<(cat)} shift (( $# <= 0 )) && break done From ccdb48a993c43d70ec89ec4a8fe28858ce47dd9c Mon Sep 17 00:00:00 2001 From: kou1okada Date: Thu, 16 Apr 2015 14:02:09 +0900 Subject: [PATCH 116/309] Changed arguments for hash_check from the pipe to the here documents. --- apt-cyg | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apt-cyg b/apt-cyg index b4a7854..da5b10b 100755 --- a/apt-cyg +++ b/apt-cyg @@ -367,7 +367,7 @@ function wget_and_hash_check () echo "$LABEL: FAILED: Could not download $URL." return 1 fi - if ! echo "$SUM *$FILE" | hash_check >& /dev/null; then + if ! hash_check <<<"$SUM *$FILE" >&/dev/null; then echo "$LABEL: FAILED: Hash does not match $URL." return 2 fi @@ -1423,7 +1423,7 @@ function apt-cyg-install () # check the SHA512 hash local digest="$(awk '/^install: / { print $4; exit }' "desc")" - if ! echo "${digest} *${file}" | hash_check; then + if ! hash_check <<<"${digest} *${file}" ; then echo "error: hash did not match: $file" exit 1 fi From 5b61ba2356d8b97477662f01e7964b871f33ec20 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Thu, 16 Apr 2015 19:39:28 +0900 Subject: [PATCH 117/309] FIXED: In some cases, version was not split correctly by the `package_db-list` function. Ex) ruby-2.0.0-p598-1, etc... --- apt-cyg | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/apt-cyg b/apt-cyg index da5b10b..51ed9a9 100755 --- a/apt-cyg +++ b/apt-cyg @@ -596,7 +596,12 @@ function package_db-list () { package_db-version_check - awk 'NF == 3 { $0=gensub(/(.*)-(.*)-(.*).*\..*\..*/, "\\1 \\2-\\3","g",$2) ; printf("%-45s %s\n",$1,$2) }' "${PACKAGE_DB}" + awk ' + NF == 3 { + version = gensub(/^(.*)\.(tgz|tbz|tbz2|tb2|taz|tz|tlz|txz|tar\.(gz|bz2|Z|lz|lzma|xz))$/, "\\1", 1, substr($2, length($1) + 2)); + printf("%-45s %s\n", $1, version); + } + ' "${PACKAGE_DB}" } # Usage: package_db-register PKGNAME PKGFILE From 2ecade0be594a1e0cf3f87ae5d8b234a8fc08c2f Mon Sep 17 00:00:00 2001 From: kou1okada Date: Sun, 19 Apr 2015 23:29:46 +0900 Subject: [PATCH 118/309] Performance improvement: proxy_auto became to cache a result. --- apt-cyg | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/apt-cyg b/apt-cyg index 51ed9a9..1b4d385 100755 --- a/apt-cyg +++ b/apt-cyg @@ -522,10 +522,21 @@ function apt-cyg-upgrade-self () function proxy_auto () { - local proxy=$("${WGET[@]}" --no-proxy -q -O - wpad/wpad.dat \ - | grep PROXY \ - | sed -e 's/^.*PROXY\s*\([^"]*\).*$/http:\/\/\1/g') + local hash="$(ipconfig 2>&1 | md5sum -b | awk '{print $1}')" + local cache="/tmp/apt-cyg.proxy.$hash" + local last="$(stat -c %Y "$cache" 2>/dev/null)" + local now="$(date +%s)" + local proxy + [ -n "$OPT_PROXY_FORCE_REFRESH" ] && last=0 + if (( (now - ${last:-0}) < OPT_PROXY_REFRESH_INTERVAL )); then + proxy="$(<"$cache")" + else + proxy=$("${WGET[@]}" --no-proxy -q -O - wpad/wpad.dat \ + | grep PROXY \ + | sed -e 's/^.*PROXY\s*\([^"]*\).*$/http:\/\/\1/g') + echo "$proxy" > "$cache" + fi [ -n "$proxy" ] && proxy_set "$proxy" } @@ -1127,6 +1138,7 @@ force_remove="" force_fetch_trustedkeys="" no_verify="" OPT_PROXY=${APT_CYG_PROXY:-auto} +OPT_PROXY_REFRESH_INTERVAL=${APT_CYG_PROXY_REFRESH_INTERVAL:-86400} # 86400s = 1day OPTS4INHERIT=() SETUP_EXE="setup-$(current_cygarch).exe" YES_TO_ALL=false @@ -1188,6 +1200,16 @@ function parse_args () shift 2 || break ;; + --proxy-force-refresh) + OPT_PROXY_FORCE_REFRESH="$1" + shift + ;; + + --proxy-refresh-interval) + OPT_PROXY_REFRESH_INTERVAL="$2" + shift 2 || break + ;; + --completion-get-subcommand) OPT_COMPLETION_GET_SUBCOMMAND="$1" shift From 1ba7c33ae89d776948cb45059b73fdf002fc8af3 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Sun, 24 May 2015 15:42:29 +0900 Subject: [PATCH 119/309] FIXED: MAnantharaman reported that `get_codepage` returns a "CP850." not a "CP850" at his environment. See [issue #15](https://github.com/kou1okada/apt-cyg/issues/15). --- apt-cyg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apt-cyg b/apt-cyg index 1b4d385..2b72a2b 100755 --- a/apt-cyg +++ b/apt-cyg @@ -932,7 +932,7 @@ function apt-cyg-show-packages-busyness () function get_codepage () { - cmd.exe /c chcp | awk '{printf "CP"$NF;}' + cmd.exe /c chcp | awk '{printf $NF;}' | sed -re 's/^[^0-9]*([0-9]+).*$/\CP\1/g' } function cp2utf8 () From efaf71b4c375224ba56f5cfe92b5d01e859e5c88 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Sun, 24 May 2015 16:05:57 +0900 Subject: [PATCH 120/309] FIXED: a mistyping. --- apt-cyg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apt-cyg b/apt-cyg index 2b72a2b..4ca7551 100755 --- a/apt-cyg +++ b/apt-cyg @@ -932,7 +932,7 @@ function apt-cyg-show-packages-busyness () function get_codepage () { - cmd.exe /c chcp | awk '{printf $NF;}' | sed -re 's/^[^0-9]*([0-9]+).*$/\CP\1/g' + cmd.exe /c chcp | awk '{printf $NF;}' | sed -re 's/^[^0-9]*([0-9]+).*$/CP\1/g' } function cp2utf8 () From 9f26da581d94d41cc4ab57307382febfd109226f Mon Sep 17 00:00:00 2001 From: kou1okada Date: Mon, 29 Jun 2015 04:39:34 +0900 Subject: [PATCH 121/309] Bugfix: The `dist-upgrade` sub-command fails `rebaseall` when the cygwin installed in other than `C:\cygwin`. I would like to thank Kazu who reported it. --- apt-cyg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apt-cyg b/apt-cyg index 4ca7551..639e584 100755 --- a/apt-cyg +++ b/apt-cyg @@ -1033,7 +1033,7 @@ function apt-cyg-dist-upgrade-no-ask () pushd "$(apt-cyg-pathof cache)" apt-cyg-update-setup - cygstart cmd /c 'CD '"$(cygpath -w "$(pwd)")"' && CD && ECHO Press any key to start upgrade && PAUSE && START /WAIT ./'"${SETUP_EXE}"' -B -q -g && C:\cygwin\bin\ash -c "/bin/rebaseall -v" && ECHO dist-upgrade is finished && ECHO Press any key to exit && PAUSE' + cygstart cmd /c 'ECHO Press any key to start dist-upgrade for cygwin '"$(current_cygarch)"' && PAUSE && START /WAIT .\'"${SETUP_EXE}"' -B -q -g && ash -c "/bin/rebaseall -v" && ECHO dist-upgrade is finished && ECHO Press any key to exit && PAUSE' # ' kill_all_cygwin_process popd From 96f17ceb665e072d928bebee4483658c6eafec81 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Sun, 2 Aug 2015 18:02:06 +0900 Subject: [PATCH 122/309] Add `--quiet` and `--verbose` options. --- apt-cyg | 112 ++++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 73 insertions(+), 39 deletions(-) diff --git a/apt-cyg b/apt-cyg index 639e584..9d10570 100755 --- a/apt-cyg +++ b/apt-cyg @@ -124,6 +124,21 @@ function version() echo "Copyright (c) 2005-9 Stephen Jungels. Released under the GPL." } +# Usage: verbose [level [msg ...]] +function verbose () +{ + (( "${OPT_VERBOSE_LEVEL:-1}" < "${1:-1}" )) && return + shift + (( 0 < $# )) && echo "$@" || cat +} >&2 + +# Usage: verbosefor [level] +function verbosefor () +{ + (( "${OPT_VERBOSE_LEVEL:-1}" < "${1:-1}" )) && { echo "/dev/null"; return; } + echo "/dev/stderr" +} + function current_cygarch () { arch | sed -e 's/^i686$/x86/g' @@ -155,8 +170,8 @@ function findworkspace() mirror="${mirror%/}" mirrordir="$(mirror_to_mirrordir "$mirror/")" - echo Working directory is $cache - echo Mirror is $mirror + verbose 1 "Cache directory is $cache" + verbose 1 "Mirror is $mirror" mkdir -p "$cache/$mirrordir/$arch" cd "$cache/$mirrordir/$arch" @@ -208,21 +223,22 @@ function setupini_download () [ $noscripts -ne 0 -o $noupdate -ne 0 ] && return - pushd "$BASEDIR" + pushd "$BASEDIR" > /dev/null files_backup setup.ini setup.ini.sig setup.bz2 setup.bz2.sig while true; do + verbose 1 "Updating setup.ini" download_and_verify "$mirror/$arch/setup.bz2" && { bunzip2 -k setup.bz2 && mv setup setup.ini || rm -f setup.bz2; } download_and_verify "$mirror/$arch/setup.ini" || break files_backup_clean setup.ini setup.ini.sig setup.bz2 setup.bz2.sig - popd - echo "Updated setup.ini" + popd > /dev/null + verbose 1 "Updated setup.ini" return done files_restore setup.ini setup.ini.sig setup.bz2 setup.bz2.sig - popd - echo -e "\e[31;1mError:\e[30;0m updating setup.ini, reverting." + popd > /dev/null + echo -e "\e[31;1mError:\e[30;0m updating setup.ini, reverting." >&2 return 1 } @@ -387,7 +403,7 @@ function fetch_trustedkeys () local URL="$(eval echo "\$${LABEL}_URL")" local URL_LATEST="$(eval echo "\$${LABEL}_URL_LATEST")" local CASE="" - if [ -z "$force_fetch_trustedkeys" ] && { "${GPG[@]}" --fingerprint --with-colons | grep -q "$FPR"; } then + if [ -z "$force_fetch_trustedkeys" ] && { "${GPG[@]}" --fingerprint --with-colons | grep -q "$FPR"; } &> $(verbosefor 2); then continue fi if [ -n "$URL" ]; then @@ -442,9 +458,11 @@ function fetch_trustedkeys () function verify_signatures () { while [ $# -gt 0 ]; do - if ! "${GPG[@]}" "${GPG_KEYRING[@]}" "$1"; then - echo -e "\e[31;1mError:\e[30;0m BAD signature: $1" + if ! "${GPG[@]}" "${GPG_KEYRING[@]}" "$1" &> $(verbosefor 2); then + echo -e "\e[31;1mError:\e[30;0m BAD signature: $1" >&2 return 1 + else + verbose 0 -e "\e[32;1msignature verified\e[30;0m: $1" fi shift done @@ -515,9 +533,9 @@ function apt-cyg-upgrade-self () echo -e "\e[31;1mError:\e[30;0m apt-get is not under the git version control." exit 1 fi - pushd "$basedir" + pushd "$basedir" > /dev/null git pull -v - popd + popd > /dev/null } function proxy_auto () @@ -973,9 +991,9 @@ function hash_check () f2="${f0#*\*}" method="$(hash_method "$f1")sum" if echo "$f0" | "$method" -c --status; then - echo "hash_check: $method: $f2: OK" + verbose 0 "hash_check: $method: $f2: OK" else - echo "hash_check: $method: $f2: FAILED" + verbose 0 "hash_check: $method: $f2: FAILED" count=$(( count + 1 )) fi done 0<${1:-<(cat)} @@ -983,7 +1001,7 @@ function hash_check () (( $# <= 0 )) && break done if (( 0 < count )); then - echo "hash_check: WARNING: $count computed checksum did NOT match" + verbose 0 "hash_check: WARNING: $count computed checksum did NOT match" return 1 fi return 0 @@ -1005,38 +1023,38 @@ function apt-cyg-update-setup () { [ -n "$OPT_NO_UPDATE_SETUP" ] && return - pushd "$(apt-cyg-pathof cache)" + pushd "$(apt-cyg-pathof cache)" > /dev/null if "${WGET[@]}" -N "https://cygwin.com/${SETUP_EXE}"; then chmod +x "${SETUP_EXE}" - ls -l "${SETUP_EXE}" + ls -l "${SETUP_EXE}" > $(verbosefor 2) else echo -e "\e[31;1mError:\e[30;0m ${SETUP_EXE} could not be downloaded." exit 1 fi - popd + popd > /dev/null } function apt-cyg-setup () { - pushd "$(apt-cyg pathof cache)" + pushd "$(apt-cyg pathof cache)" > /dev/null apt-cyg-update-setup ./"${SETUP_EXE}" "$@" - popd + popd > /dev/null } function apt-cyg-dist-upgrade-no-ask () { - pushd "$(apt-cyg-pathof cache)" + pushd "$(apt-cyg-pathof cache)" > /dev/null apt-cyg-update-setup cygstart cmd /c 'ECHO Press any key to start dist-upgrade for cygwin '"$(current_cygarch)"' && PAUSE && START /WAIT .\'"${SETUP_EXE}"' -B -q -g && ash -c "/bin/rebaseall -v" && ECHO dist-upgrade is finished && ECHO Press any key to exit && PAUSE' # ' kill_all_cygwin_process - popd + popd > /dev/null } function apt-cyg-dist-upgrade () @@ -1250,6 +1268,16 @@ function parse_args () shift ;; + --quiet|-q) + OPT_VERBOSE_LEVEL=-1 + shift + ;; + + --verbose|-v) + OPT_VERBOSE_LEVEL=2 + shift + ;; + --help) usage exit 0 @@ -1327,6 +1355,12 @@ for file in "${OPT_FILES[@]}"; do fi done +wget --help | grep -- --show-progress &>/dev/null && HAVE_SHOW_PROGRESS="--show-progress" +wget --help | grep -- --no-verbose &>/dev/null && HAVE_NO_VERBOSE="--no-verbose" +(( "${OPT_VERBOSE_LEVEL:-1}" < 0 )) && WGET+=( --quiet ) || \ +(( "${OPT_VERBOSE_LEVEL:-1}" < 1 )) && WGET+=( --quiet $HAVE_SHOW_PROGRESS ) || \ +(( "${OPT_VERBOSE_LEVEL:-1}" < 2 )) && WGET+=( $HAVE_NO_VERBOSE $HAVE_SHOW_PROGRESS ) + function apt-cyg-update () @@ -1416,8 +1450,8 @@ function apt-cyg-install () echo Package $pkg is already installed, skipping continue fi - echo "" - echo Installing $pkg + verbose 0 "" + verbose 0 "Installing $pkg" # look for package and save desc file @@ -1428,11 +1462,11 @@ function apt-cyg-install () setup.ini local desc="$(< "release/$pkg/desc")" if [ "$desc" = "Package not found" ]; then - echo Package $pkg not found or ambiguous name, exiting + verbose 0 "Package $pkg not found or ambiguous name, exiting" rm -r "release/$pkg" exit 1 fi - echo Found package $pkg + verbose 0 "Found package $pkg" # download and unpack the bz2 file @@ -1440,7 +1474,7 @@ function apt-cyg-install () local install="$(awk '/^install: / { print $2; exit }' "release/$pkg/desc")" if [ -z "$install" ]; then - echo "Could not find \"install\" in package description: obsolete package?" + verbose 0 "Could not find \"install\" in package description: obsolete package?" exit 1 fi @@ -1451,11 +1485,11 @@ function apt-cyg-install () # check the SHA512 hash local digest="$(awk '/^install: / { print $4; exit }' "desc")" if ! hash_check <<<"${digest} *${file}" ; then - echo "error: hash did not match: $file" + verbose 0 "error: hash did not match: $file" exit 1 fi - echo "Unpacking..." + verbose 0 "Unpacking..." tar > "/etc/setup/$pkg.lst" xvf "$file" -C / gzip -f "/etc/setup/$pkg.lst" cd ../.. @@ -1472,11 +1506,11 @@ function apt-cyg-install () local warn=0 if [ -n "$requires" ]; then - echo Package $pkg requires the following packages, installing: - echo $requires + verbose 0 "Package $pkg requires the following packages, installing:" + verbose 0 "$requires" for package in $requires; do if package_db-is_registered "$package"; then - echo Package $package is already installed, skipping + verbose 0 "Package $package is already installed, skipping" continue fi apt-cyg "${OPTS4INHERIT[@]}" --proxy inherit --noscripts install $package @@ -1491,14 +1525,14 @@ function apt-cyg-install () local pis="$(ls /etc/postinstall/*.sh 2>/dev/null | wc -l)" if [ $pis -gt 0 -a $noscripts -ne 1 ]; then - echo Running postinstall scripts + verbose 0 "Running postinstall scripts" for script in /etc/postinstall/*.sh; do $script mv $script $script.done done fi - echo Package $pkg installed + verbose 0 "Package $pkg installed" done } @@ -1512,23 +1546,23 @@ function apt-cyg-remove() checkpackages "$@" for pkg do if ! package_db-is_registered "$pkg"; then - echo Package $pkg is not installed, skipping + verbose 0 "Package $pkg is not installed, skipping" continue fi local dontremove="cygwin coreutils gawk bzip2 tar xz wget bash" for req in $dontremove; do if [ "$pkg" = "$req" ]; then - echo apt-cyg cannot remove package $pkg, exiting + verbose 0 "apt-cyg cannot remove package $pkg, exiting" exit 1 fi done if [ ! -e "/etc/setup/$pkg.lst.gz" -a -z "$force_remove" ]; then - echo Package manifest missing, cannot remove $pkg. Exiting + verbose 0 "Package manifest missing, cannot remove $pkg. Exiting" exit 1 fi - echo Removing $pkg + verbose 0 "Removing $pkg" # run preremove scripts @@ -1539,7 +1573,7 @@ function apt-cyg-remove() gzip -cd "/etc/setup/$pkg.lst.gz" | awk '/[^\/]$/ {print "rm -f \"/" $0 "\""}' | sh rm -f "/etc/postinstall/$pkg.sh.done" "/etc/preremove/$pkg.sh" "/etc/setup/$pkg.lst.gz" package_db-unregister "$pkg" - echo Package $pkg removed + verbose 0 "Package $pkg removed" done } From 999924cf41e74f409856b62ec9dfa25c86c8958a Mon Sep 17 00:00:00 2001 From: kou1okada Date: Sun, 2 Aug 2015 20:45:37 +0900 Subject: [PATCH 123/309] Add help about `--quiet` and `--verbose` options. --- apt-cyg | 2 ++ 1 file changed, 2 insertions(+) diff --git a/apt-cyg b/apt-cyg index 9d10570..cfede64 100755 --- a/apt-cyg +++ b/apt-cyg @@ -110,6 +110,8 @@ function usage() echo " --file, -f : read package names from file" echo " --noupdate, -u : don't update setup.ini from mirror" echo " --ipv4, -4 : wget prefer ipv4" + echo " --quiet, -q : quiet (no output)" + echo " --verbose, -v : verbose" echo " --help" echo " --version" } From 92d183e05b2f2f1bd4ac9e47d8722e85072b27bf Mon Sep 17 00:00:00 2001 From: kou1okada Date: Tue, 4 Aug 2015 20:26:43 +0900 Subject: [PATCH 124/309] Add `--no-header` option. --- apt-cyg | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/apt-cyg b/apt-cyg index cfede64..16f2e6d 100755 --- a/apt-cyg +++ b/apt-cyg @@ -98,6 +98,7 @@ function usage() echo " --no-verify, -X : Don't verify setup.ini signatures" echo " --no-check-certificate : Don't validate the server's certificate" echo " --no-update-setup : Don't update setup.exe" + echo " --no-header : Don't print header" echo " --proxy, -p :" echo " set proxy (default: \${APT_CYG_PROXY:-auto})" echo " --completion-get-subcommand:" @@ -752,14 +753,14 @@ function dep_check () function apt-cyg-depends () { local pkg - printf "%-40s %s\t%s\t%s\n" "PKGNAME" "AVAIL" "SHALLOW" "DEEP" + [ -z "$OPT_NO_HEADER" ] && printf "%-40s %s\t%s\t%s\n" "PKGNAME" "AVAIL" "SHALLOW" "DEEP" dep_check depends "$@" } function apt-cyg-rdepends () { local pkg - printf "%-40s %s\t%s\t%s\n" "PKGNAME" "AVAIL" "SHALLOW" "DEEP" + [ -z "$OPT_NO_HEADER" ] && printf "%-40s %s\t%s\t%s\n" "PKGNAME" "AVAIL" "SHALLOW" "DEEP" dep_check rdepends "$@" } @@ -1215,6 +1216,11 @@ function parse_args () shift ;; + --no-header) + OPT_NO_HEADER="$1" + shift + ;; + --proxy|-p) OPT_PROXY="$2" shift 2 || break @@ -1374,7 +1380,7 @@ function apt-cyg-update () function apt-cyg-show () { - echo 1>&2 The following packages are installed: + [ -z "$OPT_NO_HEADER" ] && echo "The following packages are installed:" package_db-list } From 56f56015bcfd8b03131f5e23884e9ac35b35298d Mon Sep 17 00:00:00 2001 From: kou1okada Date: Wed, 5 Aug 2015 02:26:29 +0900 Subject: [PATCH 125/309] Refactoring about the default value of $OPT_VERBOSE_LEVEL. --- apt-cyg | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/apt-cyg b/apt-cyg index 16f2e6d..f2da14b 100755 --- a/apt-cyg +++ b/apt-cyg @@ -130,7 +130,7 @@ function version() # Usage: verbose [level [msg ...]] function verbose () { - (( "${OPT_VERBOSE_LEVEL:-1}" < "${1:-1}" )) && return + (( "${OPT_VERBOSE_LEVEL}" < "${1:-1}" )) && return shift (( 0 < $# )) && echo "$@" || cat } >&2 @@ -138,7 +138,7 @@ function verbose () # Usage: verbosefor [level] function verbosefor () { - (( "${OPT_VERBOSE_LEVEL:-1}" < "${1:-1}" )) && { echo "/dev/null"; return; } + (( "${OPT_VERBOSE_LEVEL}" < "${1:-1}" )) && { echo "/dev/null"; return; } echo "/dev/stderr" } @@ -1345,6 +1345,8 @@ function parse_args () parse_args "$@" +: ${OPT_VERBOSE_LEVEL:=1} + [ -n "$OPT_CHARCH" ] && charch "$OPT_CHARCH" "${INITIAL_ARGS[@]}" [ "${#OPT_MIRROR[@]}" -gt 0 ] && echo "${OPT_MIRROR%/}/" > /etc/setup/last-mirror @@ -1365,9 +1367,9 @@ done wget --help | grep -- --show-progress &>/dev/null && HAVE_SHOW_PROGRESS="--show-progress" wget --help | grep -- --no-verbose &>/dev/null && HAVE_NO_VERBOSE="--no-verbose" -(( "${OPT_VERBOSE_LEVEL:-1}" < 0 )) && WGET+=( --quiet ) || \ -(( "${OPT_VERBOSE_LEVEL:-1}" < 1 )) && WGET+=( --quiet $HAVE_SHOW_PROGRESS ) || \ -(( "${OPT_VERBOSE_LEVEL:-1}" < 2 )) && WGET+=( $HAVE_NO_VERBOSE $HAVE_SHOW_PROGRESS ) +(( "${OPT_VERBOSE_LEVEL}" < 0 )) && WGET+=( --quiet ) || \ +(( "${OPT_VERBOSE_LEVEL}" < 1 )) && WGET+=( --quiet $HAVE_SHOW_PROGRESS ) || \ +(( "${OPT_VERBOSE_LEVEL}" < 2 )) && WGET+=( $HAVE_NO_VERBOSE $HAVE_SHOW_PROGRESS ) From f4d1d62a8b5a99b9858fbf27b9197ac4771c42d4 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Sat, 15 Aug 2015 18:25:37 +0900 Subject: [PATCH 126/309] Refactoring: A redundant argument of `package_db-register` function was removed. --- apt-cyg | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/apt-cyg b/apt-cyg index f2da14b..ebb28c3 100755 --- a/apt-cyg +++ b/apt-cyg @@ -592,6 +592,13 @@ function proxy_setup () esac } +# Usage: get_pkgname PKGFILE +function get_pkgname () +{ + local tarball="${1##*/}" + echo "$tarball" | sed -re's/-[0-9].*//g' +} + # PACKAGE_DB is defined at package_db.cc in the cygwin-app setup.exe # See blow: # https://www.sourceware.org/cygwin-apps/setup.html @@ -636,9 +643,11 @@ function package_db-list () ' "${PACKAGE_DB}" } -# Usage: package_db-register PKGNAME PKGFILE +# Usage: package_db-register PKGFILE function package_db-register () { + local pkgfile="${1##*/}" + local pkgname="$(get_pkgname "$pkgfile")" local work="/tmp/apt-cyg.$$.${PACKAGE_DB##*/}" package_db-version_check @@ -648,7 +657,7 @@ function package_db-register () !registered && PKGNAME < $1 && NF != 2 {register()} {print $0} END {if (!registered) register()} - ' PKGNAME="$1" PKGFILE="$2" "${PACKAGE_DB}" > "${work}" + ' PKGNAME="$pkgname" PKGFILE="${pkgfile}" "${PACKAGE_DB}" > "${work}" mv "${PACKAGE_DB}" "${PACKAGE_DB}-save" mv "${work}" "${PACKAGE_DB}" @@ -1507,7 +1516,7 @@ function apt-cyg-install () # update the package database - package_db-register "$pkg" "$file" + package_db-register "$file" # recursively install required packages From 84168f04baa85b238c8a8baa2d659f87548c9570 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Sun, 30 Aug 2015 02:27:45 +0900 Subject: [PATCH 127/309] `dist-upgrade` subcommand became no longer create desktop and start menu shortcuts. --- apt-cyg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apt-cyg b/apt-cyg index ebb28c3..f73e5b6 100755 --- a/apt-cyg +++ b/apt-cyg @@ -1063,7 +1063,7 @@ function apt-cyg-dist-upgrade-no-ask () pushd "$(apt-cyg-pathof cache)" > /dev/null apt-cyg-update-setup - cygstart cmd /c 'ECHO Press any key to start dist-upgrade for cygwin '"$(current_cygarch)"' && PAUSE && START /WAIT .\'"${SETUP_EXE}"' -B -q -g && ash -c "/bin/rebaseall -v" && ECHO dist-upgrade is finished && ECHO Press any key to exit && PAUSE' # ' + cygstart cmd /c 'ECHO Press any key to start dist-upgrade for cygwin '"$(current_cygarch)"' && PAUSE && START /WAIT .\'"${SETUP_EXE}"' -B -q -n -g && ash -c "/bin/rebaseall -v" && ECHO dist-upgrade is finished && ECHO Press any key to exit && PAUSE' # ' kill_all_cygwin_process popd > /dev/null From 96e7a89634f7cc7ad453f6776cdf5a51315e7d7f Mon Sep 17 00:00:00 2001 From: kou1okada Date: Fri, 6 Nov 2015 20:26:45 +0900 Subject: [PATCH 128/309] FIXED: Resume download became to be used at install subcommand. --- apt-cyg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apt-cyg b/apt-cyg index f73e5b6..d288d6a 100755 --- a/apt-cyg +++ b/apt-cyg @@ -1499,7 +1499,7 @@ function apt-cyg-install () local file="$(basename "$install")" cd "release/$pkg" - "${WGET[@]}" -nc $mirror/$install + "${WGET[@]}" -Nc $mirror/$install # check the SHA512 hash local digest="$(awk '/^install: / { print $4; exit }' "desc")" From 893c1a89550d81cbc6ad49b982685f5fc7e1baaf Mon Sep 17 00:00:00 2001 From: kou1okada Date: Sun, 27 Dec 2015 12:55:11 +0900 Subject: [PATCH 129/309] Update README.md * Add link to nobuyo/medy --- README.md | 4 ++++ apt-cyg | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ddb12ba..d29a8d6 100644 --- a/README.md +++ b/README.md @@ -180,6 +180,10 @@ Ex.) Merging to the GPL from the MIT is possible. But merging to the MIT from th * [wuyangnju / apt-cyg](https://github.com/wuyangnju/apt-cyg/network) * [takuya / apt-cyg](https://github.com/takuya/apt-cyg/network) +### Derivations of non-fork on the github + +* [nobuyo / medy](https://github.com/nobuyo/medy) + Todo ------------ diff --git a/apt-cyg b/apt-cyg index f73e5b6..d288d6a 100755 --- a/apt-cyg +++ b/apt-cyg @@ -1499,7 +1499,7 @@ function apt-cyg-install () local file="$(basename "$install")" cd "release/$pkg" - "${WGET[@]}" -nc $mirror/$install + "${WGET[@]}" -Nc $mirror/$install # check the SHA512 hash local digest="$(awk '/^install: / { print $4; exit }' "desc")" From 94d214f1e33db1cae92f6478bb056892f93bb9d9 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Tue, 5 Jan 2016 17:01:36 +0900 Subject: [PATCH 130/309] FIXED: mktemp makes a temporary file in tmpdir at apt-cyg-benchmark-parallel-mirrors. --- apt-cyg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apt-cyg b/apt-cyg index d288d6a..f4d7e40 100755 --- a/apt-cyg +++ b/apt-cyg @@ -909,7 +909,7 @@ function apt-cyg-benchmark-mirrors () function apt-cyg-benchmark-parallel-mirrors () { - local result="$(mktemp "${SCRIPTNAME}.$$.XXXXX")" + local result="$(mktemp --tmpdir "${SCRIPTNAME}.$$.XXXXX")" local mirror for mirror; do echo $mirror; done | lesser-parallel apt-cyg-benchmark-mirrors {} | tee "$result" echo Finished benchmark. From 4de0f739ed54f2d8f45b9dd21929b41129d1037e Mon Sep 17 00:00:00 2001 From: kou1okada Date: Sat, 30 Jan 2016 17:15:41 +0900 Subject: [PATCH 131/309] Add a derivation to README.md * Add svnpenn/sage --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index d29a8d6..509e67c 100644 --- a/README.md +++ b/README.md @@ -183,6 +183,7 @@ Ex.) Merging to the GPL from the MIT is possible. But merging to the MIT from th ### Derivations of non-fork on the github * [nobuyo / medy](https://github.com/nobuyo/medy) +* [svnpenn / sage](https://github.com/svnpenn/sage) Todo ------------ From fc9cc95d1d7647cbae59e8de67502f781c176e95 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Mon, 1 Feb 2016 22:21:05 +0900 Subject: [PATCH 132/309] Add and modify links for some forks in README.md * Add tmshn/cyg-fast * Modify digitallamb/apt-cyg * Add balanx/apt-cyg * Add langlichuan123/apt-cyg * Add Milly/apt-cyg * Add 10sr/pac-cyg * Modify nobuyo/medy * Modify svnpenn/sage --- README.md | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 509e67c..106c459 100644 --- a/README.md +++ b/README.md @@ -162,14 +162,18 @@ Ex.) Merging to the GPL from the MIT is possible. But merging to the MIT from th #### Official (MIT license) * [transcodes-open / apt-cyg](https://github.com/transcode-open/apt-cyg/network) + * [tmshn / cyg-fast](https://github.com/tmshn/cyg-fast/network) #### Unofficial (MIT license) -* [digitallamb / apt-cyg](https://github.com/digitallamb/apt-cyg) +* [digitallamb / apt-cyg](https://github.com/digitallamb/apt-cyg/network) +* [balanx / apt-cyg](https://github.com/balanx/apt-cyg/network) +* [langlichuan123 / apt-cyg](https://github.com/langlichuan123/apt-cyg/network) #### Unofficial (GPLv2) * [cfg / apt-cyg](https://github.com/cfg/apt-cyg/network) + * [Milly / apt-cyg](https://github.com/Milly/apt-cyg/network) * [ashumkin / apt-cyg](https://github.com/ashumkin/apt-cyg/network) * [svn2github / apt-cyg](https://github.com/svn2github/apt-cyg/network) * [nosuchuser / apt-cyg](https://github.com/nosuchuser/apt-cyg/network) @@ -182,8 +186,9 @@ Ex.) Merging to the GPL from the MIT is possible. But merging to the MIT from th ### Derivations of non-fork on the github -* [nobuyo / medy](https://github.com/nobuyo/medy) -* [svnpenn / sage](https://github.com/svnpenn/sage) +* [10sr / pac-cyg](https://github.com/10sr/pac-cyg/network) +* [nobuyo / medy](https://github.com/nobuyo/medy/network) +* [svnpenn / sage](https://github.com/svnpenn/sage/network) Todo ------------ From a249138cd23d448e1c491898f83a95a89e0838fa Mon Sep 17 00:00:00 2001 From: kou1okada Date: Fri, 5 Feb 2016 19:27:30 +0900 Subject: [PATCH 133/309] Update README.md * Add description about `update-setup` and `setup` subcommand. --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 106c459..48e2767 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,8 @@ apt-cyg is a command-line installer for [Cygwin](http://cygwin.com/) which coope * "apt-cyg scriptinfo" to show script infomations." * "apt-cyg show-packages-busyness <package names> ..." to show packages are busy or noe." * "apt-cyg dist-upgrade" to upgrade all packages that is installed. This subcommand uses setup-*.exe +* "apt-cyg update-setup" to update setup.exe +* "apt-cyg setup" to call setup.exe Requirements ------------ From b9febfb6d5e8c95db2b085d4f2f5514d183231e1 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Fri, 5 Feb 2016 19:39:45 +0900 Subject: [PATCH 134/309] Update README.md * Fix: mismatching of double quotations. --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 48e2767..195b1cb 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ apt-cyg is a command-line installer for [Cygwin](http://cygwin.com/) which coope * "apt-cyg find <pattern(s)>" to find packages matching patterns * "apt-cyg describe <pattern(s)>" to describe packages matching patterns * "apt-cyg packageof <commands or files>" to locate parent packages -* "apt-cyg pathof <cache|mirror|mirrordir|cache/mirrordir|setup.ini>" to show path" +* "apt-cyg pathof <cache|mirror|mirrordir|cache/mirrordir|setup.ini>" to show path * "apt-cyg key-add <files> ..." to add keys contained in <files> * "apt-cyg key-del <keyids> ..." to remove keys <keyids> * "apt-cyg key-list" to list keys @@ -24,8 +24,8 @@ apt-cyg is a command-line installer for [Cygwin](http://cygwin.com/) which coope * "apt-cyg benchmark-mirrors <url> ..." to benchmark mirrors. * "apt-cyg benchmark-parallel-mirrors <url> ..." to benchmark mirrors in parallel. * "apt-cyg benchmark-parallel-mirrors-list" to benchmark mirrors-list in parallel. -* "apt-cyg scriptinfo" to show script infomations." -* "apt-cyg show-packages-busyness <package names> ..." to show packages are busy or noe." +* "apt-cyg scriptinfo" to show script infomations. +* "apt-cyg show-packages-busyness <package names> ..." to show packages are busy or noe. * "apt-cyg dist-upgrade" to upgrade all packages that is installed. This subcommand uses setup-*.exe * "apt-cyg update-setup" to update setup.exe * "apt-cyg setup" to call setup.exe From 2b475f0bfae62459be3be2a984a5d05599665cad Mon Sep 17 00:00:00 2001 From: kou1okada Date: Fri, 5 Feb 2016 20:01:54 +0900 Subject: [PATCH 135/309] Add `packages-total-count` subcommand. --- README.md | 1 + apt-cyg | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/README.md b/README.md index 195b1cb..97bce10 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,7 @@ apt-cyg is a command-line installer for [Cygwin](http://cygwin.com/) which coope * "apt-cyg dist-upgrade" to upgrade all packages that is installed. This subcommand uses setup-*.exe * "apt-cyg update-setup" to update setup.exe * "apt-cyg setup" to call setup.exe +* "apt-cyg packages-total-count" count number of total packages from setup.ini Requirements ------------ diff --git a/apt-cyg b/apt-cyg index f4d7e40..94b9b81 100755 --- a/apt-cyg +++ b/apt-cyg @@ -89,6 +89,7 @@ function usage() echo " \"apt-cyg dist-upgrade\" to upgrade all packages that is installed. This subcommand uses setup.exe" echo " \"apt-cyg update-setup\" to update setup.exe" echo " \"apt-cyg setup\" to call setup.exe" + echo " \"apt-cyg packages-total-count\" count number of total packages from setup.ini" echo "Options:" echo " --charch : change archetecture" echo " --use-setuprc : set cache and mirror with /etc/setup/setup.rc" @@ -1081,6 +1082,11 @@ function apt-cyg-dist-upgrade () } } +function apt-cyg-packages-total-count () +{ + grep ^@ <"$(apt-cyg pathof setup.ini)" | wc -l +} + # Lesser Parallel for Embedding # Copyright (c) 2014 Koichi OKADA. All rights reserved. # The official repository is: From b07c68ae02ae9afb55ec7fd5a012077095bdaae6 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Fri, 5 Feb 2016 20:05:35 +0900 Subject: [PATCH 136/309] Add `packages-total-size` subcommand. --- README.md | 1 + apt-cyg | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/README.md b/README.md index 97bce10..b50b926 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,7 @@ apt-cyg is a command-line installer for [Cygwin](http://cygwin.com/) which coope * "apt-cyg update-setup" to update setup.exe * "apt-cyg setup" to call setup.exe * "apt-cyg packages-total-count" count number of total packages from setup.ini +* "apt-cyg packages-total-size" count size of total packages from setup.ini Requirements ------------ diff --git a/apt-cyg b/apt-cyg index 94b9b81..f617a2d 100755 --- a/apt-cyg +++ b/apt-cyg @@ -90,6 +90,7 @@ function usage() echo " \"apt-cyg update-setup\" to update setup.exe" echo " \"apt-cyg setup\" to call setup.exe" echo " \"apt-cyg packages-total-count\" count number of total packages from setup.ini" + echo " \"apt-cyg packages-total-size [pattern_of_section]\" count size of total packages from setup.ini" echo "Options:" echo " --charch : change archetecture" echo " --use-setuprc : set cache and mirror with /etc/setup/setup.rc" @@ -1087,6 +1088,20 @@ function apt-cyg-packages-total-count () grep ^@ <"$(apt-cyg pathof setup.ini)" | wc -l } +# Usage: apt-cyg-packages-total-size [pattern_of_section] +function apt-cyg-packages-total-size () +{ + local section="^$" + (( 0 < $# )) && section="$1" + + awk -v SECTION="$section" ' + /^@ [ -~]+ *$/ {section = ""} + match($0,/^\[([ -~]*)\] *$/,m) {section = m[1]} + match(section, SECTION) && $1 == "install:" {sum += $3} + END {print sum} + ' "$(apt-cyg pathof setup.ini)" +} + # Lesser Parallel for Embedding # Copyright (c) 2014 Koichi OKADA. All rights reserved. # The official repository is: From fb24e97c489acaf915ad12361ea05b972012311a Mon Sep 17 00:00:00 2001 From: kou1okada Date: Fri, 5 Feb 2016 20:14:40 +0900 Subject: [PATCH 137/309] Add `packages-cached-count` subcommand. --- README.md | 1 + apt-cyg | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/README.md b/README.md index b50b926..a70992e 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,7 @@ apt-cyg is a command-line installer for [Cygwin](http://cygwin.com/) which coope * "apt-cyg setup" to call setup.exe * "apt-cyg packages-total-count" count number of total packages from setup.ini * "apt-cyg packages-total-size" count size of total packages from setup.ini +* "apt-cyg packages-cached-count" count number of cached packages in cache/mirrordir. Requirements ------------ diff --git a/apt-cyg b/apt-cyg index f617a2d..169842f 100755 --- a/apt-cyg +++ b/apt-cyg @@ -91,6 +91,7 @@ function usage() echo " \"apt-cyg setup\" to call setup.exe" echo " \"apt-cyg packages-total-count\" count number of total packages from setup.ini" echo " \"apt-cyg packages-total-size [pattern_of_section]\" count size of total packages from setup.ini" + echo " \"apt-cyg packages-cached-count\" count number of cached packages in cache/mirrordir." echo "Options:" echo " --charch : change archetecture" echo " --use-setuprc : set cache and mirror with /etc/setup/setup.rc" @@ -1102,6 +1103,13 @@ function apt-cyg-packages-total-size () ' "$(apt-cyg pathof setup.ini)" } +function apt-cyg-packages-cached-count () +{ + pushd "$(apt-cyg pathof cache/mirrordir)" > /dev/null + find . -type f | grep tar | wc -l + popd > /dev/null +} + # Lesser Parallel for Embedding # Copyright (c) 2014 Koichi OKADA. All rights reserved. # The official repository is: From 985ac6720e14b69b8ca5a1ebad8027d3234be361 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Fri, 5 Feb 2016 20:18:11 +0900 Subject: [PATCH 138/309] Add `packages-cached-size` subcommand. --- README.md | 1 + apt-cyg | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/README.md b/README.md index a70992e..3b4642a 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,7 @@ apt-cyg is a command-line installer for [Cygwin](http://cygwin.com/) which coope * "apt-cyg packages-total-count" count number of total packages from setup.ini * "apt-cyg packages-total-size" count size of total packages from setup.ini * "apt-cyg packages-cached-count" count number of cached packages in cache/mirrordir. +* "apt-cyg packages-cached-size" count size of cached packages in cache/mirrordir. Requirements ------------ diff --git a/apt-cyg b/apt-cyg index 169842f..5491f26 100755 --- a/apt-cyg +++ b/apt-cyg @@ -92,6 +92,7 @@ function usage() echo " \"apt-cyg packages-total-count\" count number of total packages from setup.ini" echo " \"apt-cyg packages-total-size [pattern_of_section]\" count size of total packages from setup.ini" echo " \"apt-cyg packages-cached-count\" count number of cached packages in cache/mirrordir." + echo " \"apt-cyg packages-cached-size\" count size of cached packages in cache/mirrordir." echo "Options:" echo " --charch : change archetecture" echo " --use-setuprc : set cache and mirror with /etc/setup/setup.rc" @@ -1110,6 +1111,14 @@ function apt-cyg-packages-cached-count () popd > /dev/null } +function apt-cyg-packages-cached-size () +{ + pushd "$(apt-cyg pathof cache/mirrordir)" > /dev/null + find . -type f -iname '*tar*' -exec ls -l {} + \ + | awk '{sum+=$5}END{print sum}' + popd > /dev/null +} + # Lesser Parallel for Embedding # Copyright (c) 2014 Koichi OKADA. All rights reserved. # The official repository is: From 9b8178de3d980b000e664928725b5bf241f0ba94 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Sat, 6 Feb 2016 12:41:00 +0900 Subject: [PATCH 139/309] Add a link to a fork in README.md * Add pi0/cyg --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 3b4642a..96857a2 100644 --- a/README.md +++ b/README.md @@ -169,6 +169,7 @@ Ex.) Merging to the GPL from the MIT is possible. But merging to the MIT from th * [transcodes-open / apt-cyg](https://github.com/transcode-open/apt-cyg/network) * [tmshn / cyg-fast](https://github.com/tmshn/cyg-fast/network) + * [pi0 / cyg](https://github.com/pi0/cyg) (GPLv3) #### Unofficial (MIT license) From a0110bf5515f7cb406e5abeb49278ac134caa65c Mon Sep 17 00:00:00 2001 From: kou1okada Date: Thu, 11 Feb 2016 14:55:56 +0900 Subject: [PATCH 140/309] Update README.md * add current problem at 2016-02-11 with the ALC (maybe). --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index 96857a2..7739168 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,13 @@ apt-cyg ======= +2016-02-11: current problem +--------------------------- +It seems happenning some new problems, because the cygwin has changed the ALC mechanism, probably. +For example, when `apt-cyg install cygport` is executed, a permission of `/etc/X11` is not correct. + +apt-cyg +------- apt-cyg is a command-line installer for [Cygwin](http://cygwin.com/) which cooperates with Cygwin Setup and uses the same repository. The syntax is similar to apt-get. Usage examples: * "apt-cyg install <package names>" to install packages From 6ff8933b176ec770c766c9b3312ff12aeccea6ee Mon Sep 17 00:00:00 2001 From: kou1okada Date: Fri, 12 Feb 2016 20:25:58 +0900 Subject: [PATCH 141/309] Add `repair-acl` subcommand. --- README.md | 17 ++++++++++++----- apt-cyg | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 7739168..4902c0b 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,6 @@ apt-cyg ======= -2016-02-11: current problem ---------------------------- -It seems happenning some new problems, because the cygwin has changed the ALC mechanism, probably. -For example, when `apt-cyg install cygport` is executed, a permission of `/etc/X11` is not correct. - apt-cyg ------- apt-cyg is a command-line installer for [Cygwin](http://cygwin.com/) which cooperates with Cygwin Setup and uses the same repository. The syntax is similar to apt-get. Usage examples: @@ -40,6 +35,7 @@ apt-cyg is a command-line installer for [Cygwin](http://cygwin.com/) which coope * "apt-cyg packages-total-size" count size of total packages from setup.ini * "apt-cyg packages-cached-count" count number of cached packages in cache/mirrordir. * "apt-cyg packages-cached-size" count size of cached packages in cache/mirrordir. +* "apt-cyg repair-acl" repair acl. Requirements ------------ @@ -214,6 +210,17 @@ Todo Known Problem ------------ +### 2016-02-12: Problems about the ACL + +In recent version, the cygwin changed the ACL mechanism . +So, in the cygwin current version, if it will be installed by setup.exe with -B or --no-admin option, +the cygwin root (/) does not have correct ACL. + +A new subcommand `repair-acl` tries to repair it. +But some package, that are failed to install by the ACL problem, need to be reinstalled. + + + ### 2015-04-09: gpgv seems not work correctly on 32 bit environment To solve this problem, the backend of `verify_signatures` function was changed from `gpgv` to `gpg`. diff --git a/apt-cyg b/apt-cyg index 5491f26..0e9cfca 100755 --- a/apt-cyg +++ b/apt-cyg @@ -93,6 +93,7 @@ function usage() echo " \"apt-cyg packages-total-size [pattern_of_section]\" count size of total packages from setup.ini" echo " \"apt-cyg packages-cached-count\" count number of cached packages in cache/mirrordir." echo " \"apt-cyg packages-cached-size\" count size of cached packages in cache/mirrordir." + echo " \"apt-cyg repair-acl\" repair acl." echo "Options:" echo " --charch : change archetecture" echo " --use-setuprc : set cache and mirror with /etc/setup/setup.rc" @@ -1119,6 +1120,46 @@ function apt-cyg-packages-cached-size () popd > /dev/null } +function apt-cyg-repair-acl () +{ + local target="${1:-/}" + local aclbackup="/tmp/$(date +%Y%m%d_%H%M%S)_acl" + ask_user "$(cat <<-EOD + This subcommand tries to repair the ACL for "${target}". + Maybe it repairs a cygwin that was installed by setup.exe with -B and --no-admin options. + But some package, that are failed to install by the ACL problem, need to be reinstalled. + + And unfortunately, perchance, this might cause some corruptions about the ACL. + You can find a backup of the ACL before being rewritten by this subcommand at below: + "${aclbackup}.bin" + "${aclbackup}.txt" + + Are you sure ? + EOD + )" || exit 1 + echo + + cmd /c icacls "$(cygpath -w "${target}")" /save "$(cygpath -w "${aclbackup}.bin")" > /dev/null + cmd /c icacls "$(cygpath -w "${target}")" | cp2utf8 > "$(cygpath -w "${aclbackup}.txt")" + + cmd /c icacls "$(cygpath -w "${target}")" \ + /grant \ + "%USERDOMAIN%\\%USERNAME%:F" \ + "%USERDOMAIN%\\None:RX" \ + "Everyone:RX" \ + "CREATOR OWNER:(OI)(CI)(IO)F" \ + "CREATOR GROUP:(OI)(CI)(IO)RX" \ + "Everyone:(OI)(CI)(IO)RX" \ + /remove \ + "NT AUTHORITY\\Authenticated Users" \ + "NT AUTHORITY\\SYSTEM" \ + "BUILTIN\\Administrators" \ + "BUILTIN\\Users" \ + "NULL SID" \ + /inheritance:r \ + | cp2utf8 +} + # Lesser Parallel for Embedding # Copyright (c) 2014 Koichi OKADA. All rights reserved. # The official repository is: From 3b70550d3d35fa959b5fcf07e2bbec108f9b0d59 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Sat, 13 Feb 2016 04:05:15 +0900 Subject: [PATCH 142/309] Fix the ACL problem for Windows 10 Japanese edition. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * "guest::" is not "%USERDOMAIN\None" but "%USERDOMAIN%\なし" in Win10JP. * "*S-1-3-1" is "CREATOR GROUP", but "%USERDOMAIN%None" will be also changed. --- apt-cyg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apt-cyg b/apt-cyg index 0e9cfca..354b60c 100755 --- a/apt-cyg +++ b/apt-cyg @@ -1145,7 +1145,7 @@ function apt-cyg-repair-acl () cmd /c icacls "$(cygpath -w "${target}")" \ /grant \ "%USERDOMAIN%\\%USERNAME%:F" \ - "%USERDOMAIN%\\None:RX" \ + "*S-1-3-1:RX" \ "Everyone:RX" \ "CREATOR OWNER:(OI)(CI)(IO)F" \ "CREATOR GROUP:(OI)(CI)(IO)RX" \ From ab5134ae472cef8ea9e04f367b3cddaf5d50c87c Mon Sep 17 00:00:00 2001 From: laris Date: Mon, 26 Sep 2016 22:52:55 +0800 Subject: [PATCH 143/309] workaround to avoid warning for INSTALLED.DB 3 Warning: /etc/setup/installed.db is not version 2. The first line is below: INSTALLED.DB 3 --- apt-cyg | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apt-cyg b/apt-cyg index 354b60c..569d01e 100755 --- a/apt-cyg +++ b/apt-cyg @@ -613,7 +613,7 @@ PACKAGE_DB="/etc/setup/installed.db" function package_db-version_check () { local ver2hdr="INSTALLED.DB 2" - + if [ $(head -n1 installed.db | cut -d ' ' -f 2) -lt 2 ]; then if head -n1 "${PACKAGE_DB}" | grep -Fqvx "${ver2hdr}"; then echo -e "\e[33;1mWarning:\e[30;0m ${PACKAGE_DB} is not version 2. The first line is below:" echo -e "$(head -n1 "${PACKAGE_DB}")\n" >&2 @@ -623,6 +623,7 @@ function package_db-version_check () echo -e "The above line looks like version header, but it is not the first line.\n" >&2 fi fi + fi } # Usage: package_db-is_registered PKGNAME From f6a08813a1b20cfc5961f69f08438a4ff7ffd123 Mon Sep 17 00:00:00 2001 From: laris Date: Tue, 27 Sep 2016 13:12:15 +0800 Subject: [PATCH 144/309] Update apt-cyg --- apt-cyg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apt-cyg b/apt-cyg index 569d01e..8375203 100755 --- a/apt-cyg +++ b/apt-cyg @@ -613,7 +613,7 @@ PACKAGE_DB="/etc/setup/installed.db" function package_db-version_check () { local ver2hdr="INSTALLED.DB 2" - if [ $(head -n1 installed.db | cut -d ' ' -f 2) -lt 2 ]; then + if [ $(head -n1 ${PACKAGE_DB} | cut -d ' ' -f 2) -lt 2 ]; then if head -n1 "${PACKAGE_DB}" | grep -Fqvx "${ver2hdr}"; then echo -e "\e[33;1mWarning:\e[30;0m ${PACKAGE_DB} is not version 2. The first line is below:" echo -e "$(head -n1 "${PACKAGE_DB}")\n" >&2 From 6d8ed5b1bbb47627aab6a3cbb5289957a37b991a Mon Sep 17 00:00:00 2001 From: kou1okada Date: Tue, 27 Sep 2016 17:43:36 +0900 Subject: [PATCH 145/309] Support PACKAGE_DB version 3. See also [pull request #16](https://github.com/kou1okada/apt-cyg/pull/16). Thanks to laris for your pull request. This change related to below patch of cygwin-setup: * 2016-08-02: [Track if a package was installed by user, or as a dependency](https://sourceware.org/git/gitweb.cgi?p=cygwin-setup.git;a=commit;f=package_db.cc;h=f6d6c600edffdb83a57ed13384e38a504fdc366b) --- apt-cyg | 64 ++++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 54 insertions(+), 10 deletions(-) diff --git a/apt-cyg b/apt-cyg index 354b60c..b2433d5 100755 --- a/apt-cyg +++ b/apt-cyg @@ -612,17 +612,49 @@ PACKAGE_DB="/etc/setup/installed.db" function package_db-version_check () { - local ver2hdr="INSTALLED.DB 2" + [ -n "$PACKAGE_DB_VERSION_CHECK_DONE" ] && return - if head -n1 "${PACKAGE_DB}" | grep -Fqvx "${ver2hdr}"; then - echo -e "\e[33;1mWarning:\e[30;0m ${PACKAGE_DB} is not version 2. The first line is below:" + local vernhdr='INSTALLED\.DB [0-9]+' + local line1="$(head -n1 "${PACKAGE_DB}")" + local verhdr=( $line1 ) + local pkgname="${verhdr[0]}" + local dbver + [ "${verhdr[0]}" = "INSTALLED.DB" ] && dbver="${verhdr[1]}" || dbver="1" + + if echo "$line1" | grep -Eqvx "${vernhdr}"; then + echo -e "\e[33;1mWarning:\e[30;0m ${PACKAGE_DB} does not have version header. The first line is below:" >&2 echo -e "$(head -n1 "${PACKAGE_DB}")\n" >&2 - # The previous version of apt-cyg was not treat version header correctly. - if grep -FHnx "${ver2hdr}" "${PACKAGE_DB}" >&2; then + # The earlyer version of apt-cyg was not treat version header correctly. + if grep -EHnx "${vernhdr}" "${PACKAGE_DB}" >&2; then echo -e "The above line looks like version header, but it is not the first line.\n" >&2 fi fi + + if (( dbver < 3 )); then + echo -e "\e[33;1mWarning:\e[30;0m ${PACKAGE_DB} version is less than 3." >&2 + echo -e "Before continuing, recommend to execute below command:" >&2 + echo -e " apt-cyg dist-upgrade" >&2 + ask_user "Do you continue?" >&2 && { + echo "continue" >&2 + } || { + echo "abort" >&2 + exit 1 + } + fi + + if (( 3 < dbver )); then + echo -e "\e[31;1mError:\e[30;0m ${PACKAGE_DB} has unknown version header." >&2 + echo -e "Currently apt-cyg supports the DB of ver 3 or ealyer, but your DB is ver $dbver." >&2 + ask_user "Do you want to continue at your own risk?" >&2 && { + echo "continue" >&2 + } || { + echo "abort" >&2 + exit 1 + } + fi + + PACKAGE_DB_VERSION_CHECK_DONE=1 } # Usage: package_db-is_registered PKGNAME @@ -648,21 +680,22 @@ function package_db-list () ' "${PACKAGE_DB}" } -# Usage: package_db-register PKGFILE +# Usage: package_db-register PKGFILE USER_PICKED=0 function package_db-register () { local pkgfile="${1##*/}" local pkgname="$(get_pkgname "$pkgfile")" + local user_picked="${2:-0}" local work="/tmp/apt-cyg.$$.${PACKAGE_DB##*/}" package_db-version_check awk ' - function register() {print PKGNAME " " PKGFILE " 0"; registered = 1;} + function register() {print PKGNAME " " PKGFILE " " USER_PICKED; registered = 1;} !registered && PKGNAME < $1 && NF != 2 {register()} {print $0} END {if (!registered) register()} - ' PKGNAME="$pkgname" PKGFILE="${pkgfile}" "${PACKAGE_DB}" > "${work}" + ' PKGNAME="$pkgname" PKGFILE="${pkgfile}" USER_PICKED="${user_picked}" "${PACKAGE_DB}" > "${work}" mv "${PACKAGE_DB}" "${PACKAGE_DB}-save" mv "${work}" "${PACKAGE_DB}" @@ -1239,6 +1272,7 @@ function apt-cyg-help () # process options noscripts=0 +OPT_USER_PICKED=1 noupdate=0 OPT_FILES=() SUBCOMMAND="" @@ -1354,6 +1388,13 @@ function parse_args () shift ;; + # It will not register the user_picked flag in PACKAGE_DB. + # This option is for internal use only. + --no-user-picked) + OPT_USER_PICKED=0 + shift + ;; + --noupdate|-u) noupdate=1 shift @@ -1470,6 +1511,7 @@ function apt-cyg-update () function apt-cyg-show () { + package_db-version_check [ -z "$OPT_NO_HEADER" ] && echo "The following packages are installed:" package_db-list } @@ -1539,6 +1581,7 @@ function apt-cyg-install () local pkg local script + package_db-version_check checkpackages "$@" findworkspace getsetup @@ -1595,7 +1638,7 @@ function apt-cyg-install () # update the package database - package_db-register "$file" + package_db-register "$file" "$OPT_USER_PICKED" # recursively install required packages @@ -1611,7 +1654,7 @@ function apt-cyg-install () verbose 0 "Package $package is already installed, skipping" continue fi - apt-cyg "${OPTS4INHERIT[@]}" --proxy inherit --noscripts install $package + apt-cyg "${OPTS4INHERIT[@]}" --proxy inherit --noscripts --no-user-picked install $package if [ $? -ne 0 ]; then warn=1; fi done fi @@ -1641,6 +1684,7 @@ function apt-cyg-remove() local pkg local req + package_db-version_check checkpackages "$@" for pkg do if ! package_db-is_registered "$pkg"; then From a3b85c401a6ded95be90d1b30734d709c2c292e3 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Wed, 5 Oct 2016 18:18:12 +0900 Subject: [PATCH 146/309] Add `source`, `download` and `mirror` subcommands. --- README.md | 3 ++ apt-cyg | 111 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 113 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 4902c0b..dec8d93 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,9 @@ apt-cyg is a command-line installer for [Cygwin](http://cygwin.com/) which coope * "apt-cyg packages-cached-count" count number of cached packages in cache/mirrordir. * "apt-cyg packages-cached-size" count size of cached packages in cache/mirrordir. * "apt-cyg repair-acl" repair acl. +* "apt-cyg source" download source archive. +* "apt-cyg download" download the binary package into the current directory. +* "apt-cyg mirror" download the binary package into the current cache/mirrordir as mirror. Requirements ------------ diff --git a/apt-cyg b/apt-cyg index b2433d5..8606f4c 100755 --- a/apt-cyg +++ b/apt-cyg @@ -94,6 +94,9 @@ function usage() echo " \"apt-cyg packages-cached-count\" count number of cached packages in cache/mirrordir." echo " \"apt-cyg packages-cached-size\" count size of cached packages in cache/mirrordir." echo " \"apt-cyg repair-acl\" repair acl." + echo " \"apt-cyg source\" download source archive." + echo " \"apt-cyg download\" download the binary package into the current directory." + echo " \"apt-cyg mirror\" download the binary package into the current cache/mirrordir as mirror." echo "Options:" echo " --charch : change archetecture" echo " --use-setuprc : set cache and mirror with /etc/setup/setup.rc" @@ -1193,6 +1196,113 @@ function apt-cyg-repair-acl () | cp2utf8 } +function get_archives_list () #= section type [package_names ...] +#? get archives list by format below: +#? path size digest +#? ... +#? @param section takes section name like curr, prev, test and etc,,, +#? @param type takes type name like install or source. +{ + local section="$1" + local type="$2" + shift 2 + awk -v RS="\n\n@ " -v FS="\n" -v PKGS="$(join $'\x1c' "$@")" -v MIRROR="${mirror%/}/" \ + -v SECTION="$section" -v TYPE="$type" ' + BEGIN { + split(PKGS, tmp, "\x1c"); + for (k in tmp) pkgs[tmp[k]] = k; # swap key value + } + { + if(pkgs[$1] == "") { + delete pkgs[$1]; + } else { + section = "curr"; + for (i = 2; i <= NF; i++) { + if (match($i, /^\[.*\]$/, m)) { + section = m[1]; + } else if (match($i, TYPE ": *(.*)", m) && section == SECTION) { + result[0+n++]=m[1]; + delete pkgs[$1] + } + } + } + } + END { + for (i =0; i < n; i++) { + print result[i]; + } + if (0 < length(pkgs)) { + printf("\x1b[33;1mWarning:\x1b[0m following packages are not found:")>"/dev/stderr"; + for (pkg in pkgs) printf(" %s", pkg)>"/dev/stderr"; + printf("\n")>"/dev/stderr"; + } + } + ' "$(apt-cyg-pathof "setup.ini")" +} + +function download_packages () #= pos section type [package_names ...] +#? download packages +#? @param pos takes here or mirror. +#? @param section takes section name like curr, prev, test and etc,,, +#? @param type takes type name like install or source. +{ + local pos="$1" + local section="$2" + local type="$3" + shift 3 + + case "$pos" in + here) + ;; + mirror) + cd "$(apt-cyg pathof cache/mirrordir)" + ;; + *) + echo -e "\e[31;1mError:\e[0m unknown param: $pos" + exit 1 + ;; + esac + + local mirror="$(apt-cyg pathof mirror)" + local line + local pkgs="$(get_archives_list "$section" "$type" "$@")" + local total="$(echo "$pkgs" | awk '{sum+=$2}END{print sum;}')" + local n="$(echo "$pkgs" | wc -l)" + echo "$n packages, total $total bytes will be downloaded." + echo "$pkgs" | while read line; do + local tmp=( $line ) + local path="${tmp[0]%/*}/" + local file="${tmp[0]##*/}" + local url="${mirror%/}/${tmp[0]}" + local size="${tmp[1]}" + local digest="${tmp[2]}" + if [ "$pos" = "mirror" ]; then + mkdir -vp "$path" + pushd "$path" + fi + "${WGET[@]}" -N "$url" + if ! hash_check <<<"${digest} *${file}" ; then + verbose 1 -e "\e[31;1mError:\e[0m ${BASH_SOURCE[0]}: ${FUNCNAME[0]}: ${BASH_LINENO[0]}: hash did not match: $file" + fi + [ "$pos" = "mirror" ] && popd + done +} + +function apt-cyg-source () +{ + download_packages here curr source "$@" +} + +function apt-cyg-download () +{ + download_packages here curr install "$@" +} + +function apt-cyg-mirror () +{ + download_packages mirror curr install "$@" +} + # Lesser Parallel for Embedding # Copyright (c) 2014 Koichi OKADA. All rights reserved. # The official repository is: @@ -1575,7 +1685,6 @@ function apt-cyg-packageof () done } - function apt-cyg-install () { local pkg From ec7513b5fc42e303a45e162bbea08807082e05a9 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Wed, 5 Oct 2016 21:22:10 +0900 Subject: [PATCH 147/309] Add verbosefor cache. --- apt-cyg | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/apt-cyg b/apt-cyg index 8606f4c..d093933 100755 --- a/apt-cyg +++ b/apt-cyg @@ -146,8 +146,7 @@ function verbose () # Usage: verbosefor [level] function verbosefor () { - (( "${OPT_VERBOSE_LEVEL}" < "${1:-1}" )) && { echo "/dev/null"; return; } - echo "/dev/stderr" + (( ${OPT_VERBOSE_LEVEL} < ${1:-1} )) && echo "/dev/null" || echo "/dev/stderr" } function current_cygarch () @@ -1609,6 +1608,12 @@ wget --help | grep -- --no-verbose &>/dev/null && HAVE_NO_VERBOSE="--no-verbo (( "${OPT_VERBOSE_LEVEL}" < 0 )) && WGET+=( --quiet ) || \ (( "${OPT_VERBOSE_LEVEL}" < 1 )) && WGET+=( --quiet $HAVE_SHOW_PROGRESS ) || \ (( "${OPT_VERBOSE_LEVEL}" < 2 )) && WGET+=( $HAVE_NO_VERBOSE $HAVE_SHOW_PROGRESS ) +verbosefor0=$(verbosefor 0) +verbosefor1=$(verbosefor 1) +verbosefor2=$(verbosefor 2) +verbosefor3=$(verbosefor 3) +verbosefor4=$(verbosefor 4) +verbosefor5=$(verbosefor 5) @@ -1663,7 +1668,6 @@ function apt-cyg-describe () done } - function apt-cyg-packageof () { local pkg From db4a76454965cbd5d4184ba6219a985447de5c1e Mon Sep 17 00:00:00 2001 From: kou1okada Date: Wed, 5 Oct 2016 21:30:47 +0900 Subject: [PATCH 148/309] Improoved performance for `packageof` subcommand. Make packageof cache to "/tmp/.apt-cyg-packageof.cache.gz" and use it. --- apt-cyg | 82 +++++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 65 insertions(+), 17 deletions(-) diff --git a/apt-cyg b/apt-cyg index d093933..c8ca58c 100755 --- a/apt-cyg +++ b/apt-cyg @@ -103,6 +103,8 @@ function usage() echo " --ignore-case, -i : ignore case distinctions for " echo " --force-remove : force remove" echo " --force-fetch-trustedkeys: force fetch trustedkeys" + echo " --force-update-packageof-cache:" + echo " force update packageof cache" echo " --no-verify, -X : Don't verify setup.ini signatures" echo " --no-check-certificate : Don't validate the server's certificate" echo " --no-update-setup : Don't update setup.exe" @@ -119,6 +121,7 @@ function usage() echo " --file, -f : read package names from file" echo " --noupdate, -u : don't update setup.ini from mirror" echo " --ipv4, -4 : wget prefer ipv4" + echo " --no-progress : hide the progress bar in any verbosity mode" echo " --quiet, -q : quiet (no output)" echo " --verbose, -v : verbose" echo " --help" @@ -1302,6 +1305,56 @@ function apt-cyg-mirror () download_packages mirror curr install "$@" } +PACKAGEOF_CACHE="/tmp/.apt-cyg-packageof.cache.gz" +function update_packageof_cache () +{ + local i=0 p q path fn + local chr=( "=" "-" "/" "|" "\\" ) + local lstgz_stamp="$(find /etc/setup/ -maxdepth 1 -type f -name '*.lst.gz' -exec stat -c %Y {} + | sort | tail -n1)" + local cache_stamp="$(stat "$PACKAGEOF_CACHE" -c %Y 2>/dev/null || echo 0)" + local n="$(ls -1 /etc/setup/*.lst.gz|wc -l)" + + if (( cache_stamp < lstgz_stamp )) || [ -n "$OPT_FORCE_UPDATE_PACKAGEOF_CACHE" ]; then + verbose 1 "Updating packageof cache:" >&2 + progress_init + for path in /etc/setup/*.lst.gz; do + progress_update $(( i++ )) $n + local fn="${path##*/}" + zcat "$path" | awk -v PKGNAME="${fn%.lst.gz}" '{print PKGNAME ": " $0;}' +# printf "p=%d q=%d i=%d n=%d path=[%s]\n" $p $q $i $n "$path" + done | gzip >"$PACKAGEOF_CACHE" + progress_finish + fi +} + +PROGRESS_CHAR=( "=" "-" "/" "|" "\\" ) +function progress_init () +{ + [ -n "$OPT_NO_PROGRESS" ] && return + # 0 1 2 3 4 5 + # 12345678901234567890123456789012345678901234567890 + echo -ne "|..................................................|\r" >"$verbosefor0" +} + +function progress_update () #= current total=100 +{ + [ -n "$OPT_NO_PROGRESS" ] && return + local n=${2:-100} + local p=$((2 + 50 * ($1 ) / $n)) + local q=$((2 + 50 * ($1 + 1) / $n)) + if (( q - p <= 1 )); then + printf "\e[%dG%s" $p "${PROGRESS_CHAR[($1 % 4 + 1) * (1 + $p - $q)]}" >"$verbosefor0" + else + printf "\e[%dG%s" $p "$(seq $((q - p))|awk '{printf "="}')" >"$verbosefor0" + fi +} + +function progress_finish () +{ + [ -n "$OPT_NO_PROGRESS" ] && return + echo >"$verbosefor0" +} + # Lesser Parallel for Embedding # Copyright (c) 2014 Koichi OKADA. All rights reserved. # The official repository is: @@ -1430,6 +1483,11 @@ function parse_args () shift ;; + --force-update-packageof-cache) + OPT_FORCE_UPDATE_PACKAGEOF_CACHE="$1" + shift + ;; + --no-verify|-X) OPTS4INHERIT+=( "$1" ) no_verify=1 @@ -1514,6 +1572,11 @@ function parse_args () shift ;; + --no-progress) + OPT_NO_PROGRESS="$1" + shift + ;; + --quiet|-q) OPT_VERBOSE_LEVEL=-1 shift @@ -1670,23 +1733,8 @@ function apt-cyg-describe () function apt-cyg-packageof () { - local pkg - local manifest - - checkpackages "$@" - for pkg do - local key="$(which "$pkg" 2>/dev/null | sed "s:^/::")" - if [ -z "$key" ]; then - key="$pkg" - fi - for manifest in /etc/setup/*.lst.gz; do - local found="$(gzip -cd "$manifest" | grep -c "$key")" - if [ $found -gt 0 ]; then - local package="$(echo $manifest | sed -e "s:/etc/setup/::" -e "s/.lst.gz//")" - echo Found $key in the package $package - fi - done - done + update_packageof_cache + zcat "$PACKAGEOF_CACHE" | grep "$@" } function apt-cyg-install () From 3c466e3c76c7a78ccde450a2baf1337a022cb4b5 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Wed, 5 Oct 2016 22:19:15 +0900 Subject: [PATCH 149/309] Add `--ag` option. Use the silver searcher at `packageof` subcommand. --- apt-cyg | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/apt-cyg b/apt-cyg index c8ca58c..1eb48c7 100755 --- a/apt-cyg +++ b/apt-cyg @@ -98,6 +98,7 @@ function usage() echo " \"apt-cyg download\" download the binary package into the current directory." echo " \"apt-cyg mirror\" download the binary package into the current cache/mirrordir as mirror." echo "Options:" + echo " --ag : use the silver searcher (currently work only at packageof subcommand)" echo " --charch : change archetecture" echo " --use-setuprc : set cache and mirror with /etc/setup/setup.rc" echo " --ignore-case, -i : ignore case distinctions for " @@ -1457,6 +1458,11 @@ function parse_args () while [ $# -gt 0 ]; do case "$1" in + --ag) + OPT_AG="$1" + shift + ;; + --charch) OPT_CHARCH="$2" shift 2 || break @@ -1678,6 +1684,14 @@ verbosefor3=$(verbosefor 3) verbosefor4=$(verbosefor 4) verbosefor5=$(verbosefor 5) +if [ -n "$OPT_AG" ]; then + AG="$( which ag 2>/dev/null )" + if [ -z "$AG" ]; then + echo -e "\e[33;1mWarning:\e[0m ag is not found." + unset OPT_AG + fi +fi + function apt-cyg-update () @@ -1733,8 +1747,12 @@ function apt-cyg-describe () function apt-cyg-packageof () { - update_packageof_cache - zcat "$PACKAGEOF_CACHE" | grep "$@" + if [ -z "$OPT_AG" ]; then + update_packageof_cache + zcat "$PACKAGEOF_CACHE" | grep "$@" + else + "$AG" -z "$@" /etc/setup/*.lst.gz + fi } function apt-cyg-install () From f201f937fe80618ce947ef86c56a37a6452b2e37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filip=20Bj=C3=B6rck?= Date: Sun, 30 Oct 2016 13:34:43 +0100 Subject: [PATCH 150/309] Mirror and cache dir is now passed to setup. Now setup.exe will use sane folders and caches as apt-cyg on dist-upgrade --- apt-cyg | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/apt-cyg b/apt-cyg index 1eb48c7..4399035 100755 --- a/apt-cyg +++ b/apt-cyg @@ -1104,10 +1104,25 @@ function apt-cyg-setup () function apt-cyg-dist-upgrade-no-ask () { + + local cache_string=""; + local mirror_string=""; + pushd "$(apt-cyg-pathof cache)" > /dev/null + if [ "$?" == "0" ]; then + local windir_cache="$(cygpath -wa .)" + cache_string="-l ${windir_cache} " + fi + + local mirror=$(apt-cyg-pathof mirror) + if [ "$?" == "0" ]; then + mirror_string="-s ${mirror} " + fi + ### https://cygwin.com/faq/faq.html#faq.setup.cli + apt-cyg-update-setup - cygstart cmd /c 'ECHO Press any key to start dist-upgrade for cygwin '"$(current_cygarch)"' && PAUSE && START /WAIT .\'"${SETUP_EXE}"' -B -q -n -g && ash -c "/bin/rebaseall -v" && ECHO dist-upgrade is finished && ECHO Press any key to exit && PAUSE' # ' + cygstart cmd /c 'ECHO Press any key to start dist-upgrade for cygwin '"$(current_cygarch)"' && PAUSE && START /WAIT .\'"${SETUP_EXE}"' -B -q -n -g '"${w_cache}${mirror_string}"' && ash -c "/bin/rebaseall -v" && ECHO dist-upgrade is finished && ECHO Press any key to exit && PAUSE' # ' kill_all_cygwin_process popd > /dev/null From fc20ce0a34e859999bc36631b3c5971bafc27012 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Tue, 1 Nov 2016 23:07:30 +0900 Subject: [PATCH 151/309] Fixed: `w_cache` seems to be misspell about `cache_string`. --- apt-cyg | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/apt-cyg b/apt-cyg index 4399035..a1824fd 100755 --- a/apt-cyg +++ b/apt-cyg @@ -1104,25 +1104,24 @@ function apt-cyg-setup () function apt-cyg-dist-upgrade-no-ask () { - local cache_string=""; local mirror_string=""; - + pushd "$(apt-cyg-pathof cache)" > /dev/null if [ "$?" == "0" ]; then local windir_cache="$(cygpath -wa .)" cache_string="-l ${windir_cache} " fi - + local mirror=$(apt-cyg-pathof mirror) if [ "$?" == "0" ]; then mirror_string="-s ${mirror} " fi ### https://cygwin.com/faq/faq.html#faq.setup.cli - + apt-cyg-update-setup - cygstart cmd /c 'ECHO Press any key to start dist-upgrade for cygwin '"$(current_cygarch)"' && PAUSE && START /WAIT .\'"${SETUP_EXE}"' -B -q -n -g '"${w_cache}${mirror_string}"' && ash -c "/bin/rebaseall -v" && ECHO dist-upgrade is finished && ECHO Press any key to exit && PAUSE' # ' + cygstart cmd /c 'ECHO Press any key to start dist-upgrade for cygwin '"$(current_cygarch)"' && PAUSE && START /WAIT .\'"${SETUP_EXE}"' -B -q -n -g '"${cache_string}${mirror_string}"'&& ash -c "/bin/rebaseall -v" && ECHO dist-upgrade is finished && ECHO Press any key to exit && PAUSE' # ' kill_all_cygwin_process popd > /dev/null From 31196a4b517216b2015ab4c77863863039a65d1b Mon Sep 17 00:00:00 2001 From: kou1okada Date: Tue, 1 Nov 2016 23:47:49 +0900 Subject: [PATCH 152/309] Add `--use-own-conf` option. --- apt-cyg | 40 +++++++++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/apt-cyg b/apt-cyg index a1824fd..cbf4973 100755 --- a/apt-cyg +++ b/apt-cyg @@ -101,6 +101,7 @@ function usage() echo " --ag : use the silver searcher (currently work only at packageof subcommand)" echo " --charch : change archetecture" echo " --use-setuprc : set cache and mirror with /etc/setup/setup.rc" + echo " --use-own-conf : use own cache and mirror settings when apt-cyg calls setup.exe" echo " --ignore-case, -i : ignore case distinctions for " echo " --force-remove : force remove" echo " --force-fetch-trustedkeys: force fetch trustedkeys" @@ -1092,36 +1093,40 @@ function apt-cyg-update-setup () popd > /dev/null } +function use_own_conf () +{ + local opts=() + if [ -n "$OPT_USE_OWN_CONF" ]; then + local cache="$(apt-cyg-pathof cache)" + local mirror="$(apt-cyg-pathof mirror)" + [ -n "$cache" ] && opts+=( -l "$(cygpath -wa "$cache")" ) + [ -n "$mirror" ] && opts+=( -s "$mirror" ) + fi + join $'\n' "${opts[@]}" +} + function apt-cyg-setup () { pushd "$(apt-cyg pathof cache)" > /dev/null + local opts; readarray -t opts < <(use_own_conf) + local setup=( "./${SETUP_EXE}" "${opts[@]}" "$@" ) + apt-cyg-update-setup - ./"${SETUP_EXE}" "$@" + "${setup[@]}" popd > /dev/null } function apt-cyg-dist-upgrade-no-ask () { - local cache_string=""; - local mirror_string=""; + local opts; readarray -t opts < <(use_own_conf) + local setup=( ".\\${SETUP_EXE}" -B -q -n -g "${opts[@]}") pushd "$(apt-cyg-pathof cache)" > /dev/null - if [ "$?" == "0" ]; then - local windir_cache="$(cygpath -wa .)" - cache_string="-l ${windir_cache} " - fi - - local mirror=$(apt-cyg-pathof mirror) - if [ "$?" == "0" ]; then - mirror_string="-s ${mirror} " - fi - - ### https://cygwin.com/faq/faq.html#faq.setup.cli apt-cyg-update-setup - cygstart cmd /c 'ECHO Press any key to start dist-upgrade for cygwin '"$(current_cygarch)"' && PAUSE && START /WAIT .\'"${SETUP_EXE}"' -B -q -n -g '"${cache_string}${mirror_string}"'&& ash -c "/bin/rebaseall -v" && ECHO dist-upgrade is finished && ECHO Press any key to exit && PAUSE' # ' + cygstart cmd /c 'ECHO Press any key to start dist-upgrade for cygwin '"$(current_cygarch)"' && PAUSE && START /WAIT '"${setup[@]}"' && ash -c "/bin/rebaseall -v" && ECHO dist-upgrade is finished && ECHO Press any key to exit && PAUSE' # ' kill_all_cygwin_process popd > /dev/null @@ -1488,6 +1493,11 @@ function parse_args () shift ;; + --use-own-conf) + OPT_USE_OWN_CONF="$1" + shift + ;; + --ignore-case|-i) ignore_case="$1" shift From 15cc722dbd009e8d651a58ee53bb74eaddeae01f Mon Sep 17 00:00:00 2001 From: kou1okada Date: Wed, 2 Nov 2016 00:33:13 +0900 Subject: [PATCH 153/309] Fixed: join(): drop linebreak from tail. --- apt-cyg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apt-cyg b/apt-cyg index 1eb48c7..b23a387 100755 --- a/apt-cyg +++ b/apt-cyg @@ -729,7 +729,7 @@ function join () result="$result$sep$field" sep="$FS" done - echo "$result" + echo -n "$result" } # Usage: dep_check DIR ROOTPKGS ... From 0c3fc291d67061c6e196d4ca769ab097454a2561 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Sat, 31 Dec 2016 11:59:58 +0900 Subject: [PATCH 154/309] Bugfix: The process of `remove` subcommand was not precise. In some packages, postinstall scripts and preremove scripts were not detected. Because, these scripts do not always have to be `$pkg.sh`. Empty directories were not removed. --- apt-cyg | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/apt-cyg b/apt-cyg index 7f19d8b..f4a95e8 100755 --- a/apt-cyg +++ b/apt-cyg @@ -1911,12 +1911,17 @@ function apt-cyg-remove() # run preremove scripts - if [ -e "/etc/preremove/$pkg.sh" ]; then - "/etc/preremove/$pkg.sh" - fi + local i postinstalls preremoves + readarray -t postinstalls < <(zgrep -E "^etc/postinstall/.*[.]sh$" "/etc/setup/${pkg}.lst.gz" | awk '{print "/"$0}') + readarray -t preremoves < <(zgrep -E "^etc/preremove/.*[.](da)?sh$" "/etc/setup/${pkg}.lst.gz" | awk '{print "/"$0}') + for i in "${preremoves[@]}"; do + verbose 0 "Running: ${i}" + "${i}" + done - gzip -cd "/etc/setup/$pkg.lst.gz" | awk '/[^\/]$/ {print "rm -f \"/" $0 "\""}' | sh - rm -f "/etc/postinstall/$pkg.sh.done" "/etc/preremove/$pkg.sh" "/etc/setup/$pkg.lst.gz" + gzip -cd "/etc/setup/$pkg.lst.gz" | awk '/[^\/]$/{printf("/%s\0", $0)}' | xargs -0 rm -f + gzip -cd "/etc/setup/$pkg.lst.gz" | awk '/[^./].*[/]$/{printf("/%s\0", $0)}' | sort -zr | xargs -0 rmdir --ignore-fail-on-non-empty + rm -f "${postinstalls[@]/%/.done}" "/etc/setup/$pkg.lst.gz" package_db-unregister "$pkg" verbose 0 "Package $pkg removed" From 16ee42253bf95705fae76076399f11257f667293 Mon Sep 17 00:00:00 2001 From: Ross Smith II Date: Sun, 8 Jan 2017 17:34:09 -0800 Subject: [PATCH 155/309] s/apt-get/apt-cyg --- apt-cyg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apt-cyg b/apt-cyg index f4a95e8..be280bb 100755 --- a/apt-cyg +++ b/apt-cyg @@ -545,7 +545,7 @@ function apt-cyg-upgrade-self () { local basedir="$(dirname "$(readlink -f "$(which "$0")")")" if [ ! -d "$basedir/.git" ]; then - echo -e "\e[31;1mError:\e[30;0m apt-get is not under the git version control." + echo -e "\e[31;1mError:\e[30;0m apt-cyg is not under the git version control." exit 1 fi pushd "$basedir" > /dev/null From b6a89861e3bcf7befa8a660186a6bb58d1c511b5 Mon Sep 17 00:00:00 2001 From: Lucas Ventura Carro Date: Tue, 28 Feb 2017 18:58:50 +0100 Subject: [PATCH 156/309] Force LF download of script using .gitattributes --- .gitattributes | 1 + 1 file changed, 1 insertion(+) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..db12c9b --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +apt-cyg text eol=lf From 2fb8ccedc7a3c297b24ca4e30cc30f3fd32263ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filip=20Bj=C3=B6rck?= Date: Thu, 10 Aug 2017 17:52:45 +0200 Subject: [PATCH 157/309] Changed invokation of setup.exe to include current cygwin instance root. --- apt-cyg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apt-cyg b/apt-cyg index be280bb..167e48e 100755 --- a/apt-cyg +++ b/apt-cyg @@ -1121,7 +1121,7 @@ function apt-cyg-setup () function apt-cyg-dist-upgrade-no-ask () { local opts; readarray -t opts < <(use_own_conf) - local setup=( ".\\${SETUP_EXE}" -B -q -n -g "${opts[@]}") + local setup=( ".\\${SETUP_EXE}" -R "$(cygpath -wa / | sed 's/\\/\\\\/g')" -B -q -n -g "${opts[@]}") pushd "$(apt-cyg-pathof cache)" > /dev/null From 8960c3d03198538a4103dfa21a451c9dee2da9c3 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Thu, 17 Aug 2017 02:00:27 +0900 Subject: [PATCH 158/309] FIXED: In this part, it seems that sed does not provide helpful effects. --- apt-cyg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apt-cyg b/apt-cyg index 167e48e..1dccbeb 100755 --- a/apt-cyg +++ b/apt-cyg @@ -1121,7 +1121,7 @@ function apt-cyg-setup () function apt-cyg-dist-upgrade-no-ask () { local opts; readarray -t opts < <(use_own_conf) - local setup=( ".\\${SETUP_EXE}" -R "$(cygpath -wa / | sed 's/\\/\\\\/g')" -B -q -n -g "${opts[@]}") + local setup=( ".\\${SETUP_EXE}" -R "$(cygpath -wa /)" -B -q -n -g "${opts[@]}") pushd "$(apt-cyg-pathof cache)" > /dev/null From af9745614780e7722cdb05c7fefe9cf3e55655d3 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Fri, 6 Oct 2017 22:46:35 +0900 Subject: [PATCH 159/309] Add `listfiles` subcommand. --- apt-cyg | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/apt-cyg b/apt-cyg index 1dccbeb..e3f46d2 100755 --- a/apt-cyg +++ b/apt-cyg @@ -97,6 +97,7 @@ function usage() echo " \"apt-cyg source\" download source archive." echo " \"apt-cyg download\" download the binary package into the current directory." echo " \"apt-cyg mirror\" download the binary package into the current cache/mirrordir as mirror." + echo " \"apt-cyg listfiles\" List files 'owned' by package(s)." echo "Options:" echo " --ag : use the silver searcher (currently work only at packageof subcommand)" echo " --charch : change archetecture" @@ -1325,6 +1326,21 @@ function apt-cyg-mirror () download_packages mirror curr install "$@" } +function apt-cyg-listfiles () +{ + local lst i sep + for i; do + lst="/etc/setup/${i}.lst.gz" + if [ ! -e "$lst" ]; then + echo "apt-cyg-listfiles: package '${i}' is not installed" + continue + fi + zcat "${lst}" + [ -n "$sep" ] && echo + sep=1 + done +} + PACKAGEOF_CACHE="/tmp/.apt-cyg-packageof.cache.gz" function update_packageof_cache () { From e5eec733c1e83d895720aeb9a25733b96dda7ce4 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Fri, 6 Oct 2017 23:55:55 +0900 Subject: [PATCH 160/309] Fixed: `listfiles` subcommand becomes to print the absolute path. --- apt-cyg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apt-cyg b/apt-cyg index e3f46d2..caac204 100755 --- a/apt-cyg +++ b/apt-cyg @@ -1335,7 +1335,7 @@ function apt-cyg-listfiles () echo "apt-cyg-listfiles: package '${i}' is not installed" continue fi - zcat "${lst}" + zcat "${lst}" | sed -e 's:^:/:g' [ -n "$sep" ] && echo sep=1 done From 709db4f584839e4e943fd3dc4cdc43a927a458cf Mon Sep 17 00:00:00 2001 From: kou1okada Date: Fri, 6 Apr 2018 17:06:54 +0900 Subject: [PATCH 161/309] Added `get-proxy` subcommand. --- apt-cyg | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/apt-cyg b/apt-cyg index caac204..4583bf0 100755 --- a/apt-cyg +++ b/apt-cyg @@ -98,6 +98,7 @@ function usage() echo " \"apt-cyg download\" download the binary package into the current directory." echo " \"apt-cyg mirror\" download the binary package into the current cache/mirrordir as mirror." echo " \"apt-cyg listfiles\" List files 'owned' by package(s)." + echo " \"apt-cyg get-proxy\" Get proxies for eval." echo "Options:" echo " --ag : use the silver searcher (currently work only at packageof subcommand)" echo " --charch : change archetecture" @@ -605,6 +606,11 @@ function proxy_setup () esac } +function apt-cyg-get-proxy () +{ + declare -p ftp_proxy http_proxy https_proxy +} + # Usage: get_pkgname PKGFILE function get_pkgname () { From 409c1504db8de11f250868641004dcbba1082f70 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Fri, 6 Apr 2018 17:08:49 +0900 Subject: [PATCH 162/309] Updated `README.md`. * Forgot to write about `listfiles` and `get-proxy` subcommands. --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index dec8d93..4965c51 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,8 @@ apt-cyg is a command-line installer for [Cygwin](http://cygwin.com/) which coope * "apt-cyg source" download source archive. * "apt-cyg download" download the binary package into the current directory. * "apt-cyg mirror" download the binary package into the current cache/mirrordir as mirror. +* "apt-cyg listfiles" List files 'owned' by package(s). +* "apt-cyg get-proxy" Get proxies for eval. Requirements ------------ From 57dcd467c0c08307722118989ef2ad5dfa10dcab Mon Sep 17 00:00:00 2001 From: mettacrawler Date: Mon, 23 Apr 2018 16:53:21 -0400 Subject: [PATCH 163/309] Make apt-cyg update work Summary: I get "bad signature" errors when I try to run "apt-cyg updates". Expected: apt-cyg update ...skip... signature verified: setup.bz2.sig ...skip... Actual: Cache directory is /setup Mirror is http://cygwin.mirror.constant.com Updating setup.ini setup.bz2 100%[=========================================================>] 3.53M 2.53MB/s in 1.4s 2018-04-23 16:26:24 URL:http://cygwin.mirror.constant.com/x86/setup.bz2 [3700347/3700347] -> "setup.bz2" [1] setup.bz2.sig 100%[=========================================================>] 72 --.-KB/s in 0s 2018-04-23 16:26:24 URL:http://cygwin.mirror.constant.com/x86/setup.bz2.sig [72/72] -> "setup.bz2.sig" [1] Error: BAD signature: setup.bz2.sig 1. Use --verify to avoid "gpg: WARNING: no command supplied. Trying to guess what you mean ..." 2. Use --keyring pubring.kbx because pubring.gpg does not exist (at least not for my tests) 3. Use --no-default-keyring (I wish I knew exactly why, I just know that gpg returns 2 not 0 if you don't use that) Even with all of that you still need to interactively set up gpg: export GNUPGHOME="$cache/.apt-cyg" gpg --gen-key gpg --edit-key Cygwin # (set trust to 4) gpg --edit-key Yaakov --- apt-cyg | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apt-cyg b/apt-cyg index 4583bf0..b6e6097 100755 --- a/apt-cyg +++ b/apt-cyg @@ -312,7 +312,7 @@ function init_gnupg () exit 1 fi fi - GPG_KEYRING=( --keyring pubring.gpg ) + GPG_KEYRING=( --keyring pubring.kbx ) } # Usage: ask_user [MESSAGE [OPTIONS]] @@ -475,7 +475,7 @@ function fetch_trustedkeys () function verify_signatures () { while [ $# -gt 0 ]; do - if ! "${GPG[@]}" "${GPG_KEYRING[@]}" "$1" &> $(verbosefor 2); then + if ! "${GPG[@]}" --no-default-keyring "${GPG_KEYRING[@]}" --verify "$1" &> $(verbosefor 2); then echo -e "\e[31;1mError:\e[30;0m BAD signature: $1" >&2 return 1 else From 2aaa87c2c390f07b07e7aecb2c09c4d97c8bf507 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Wed, 3 Oct 2018 12:55:40 +0900 Subject: [PATCH 164/309] Fix `update-setup` subcommand has been forgetting to verify the signature. --- apt-cyg | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/apt-cyg b/apt-cyg index 4583bf0..0054670 100755 --- a/apt-cyg +++ b/apt-cyg @@ -169,7 +169,7 @@ function mirror_to_mirrordir () function findworkspace() { # default working directory, mirror and architecture - + mirror=http://ftp.jaist.ac.jp/pub/cygwin arch="$(current_cygarch)" cache=/setup @@ -1086,17 +1086,23 @@ function kill_all_cygwin_process () function apt-cyg-update-setup () { [ -n "$OPT_NO_UPDATE_SETUP" ] && return + local TARGETS=( "${SETUP_EXE}" "${SETUP_EXE}.sig" ) + pushd . > /dev/null + findworkspace + popd > /dev/null pushd "$(apt-cyg-pathof cache)" > /dev/null - - if "${WGET[@]}" -N "https://cygwin.com/${SETUP_EXE}"; then + files_backup "${TARGETS[@]}" + if download_and_verify "https://cygwin.com/${SETUP_EXE}"; then + files_backup_clean "${TARGETS[@]}" chmod +x "${SETUP_EXE}" ls -l "${SETUP_EXE}" > $(verbosefor 2) else - echo -e "\e[31;1mError:\e[30;0m ${SETUP_EXE} could not be downloaded." + files_restore "${TARGETS[@]}" + echo -e "\e[31;1mError:\e[30;0m ${SETUP_EXE} could not be downloaded: Rollbacked it and aborted." >&2 exit 1 fi - + popd > /dev/null } From 346a752cbea02057346d3a55fdc47a5a5800ab79 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Wed, 7 Nov 2018 19:02:30 +0900 Subject: [PATCH 165/309] Update version string. This update is for issue #28. --- apt-cyg | 49 +++++++++++++++++++++++++++++++++---------------- 1 file changed, 33 insertions(+), 16 deletions(-) diff --git a/apt-cyg b/apt-cyg index 0054670..ec1d0d2 100755 --- a/apt-cyg +++ b/apt-cyg @@ -25,6 +25,17 @@ # THE SOFTWARE. # +(( 5 <= "${DEBUG:-0}" )) && set -x + +SCRIPT_PATH="$(which "$0")" +SCRIPT_FILE="${SCRIPT_PATH##*/}" +SCRIPT_NAME="${SCRIPT_FILE%.*}" +SCRIPT_DIR="${SCRIPT_PATH%/*}" +SCRIPT_REALPATH="$(realpath "$(which "$0")")" +SCRIPT_REALFILE="${SCRIPT_REALPATH##*/}" +SCRIPT_REALNAME="${SCRIPT_REALFILE%.*}" +SCRIPT_REALDIR="${SCRIPT_REALPATH%/*}" + TRUSTEDKEYS=( CYGWIN CYGWINPORTS ); # ./pubring.asc # ------------ @@ -43,8 +54,6 @@ TRUSTEDKEY_CYGWINPORTS_SUM="ccf174d1e6ec20e50ff954e3d4a0c3de478032a100d26789c019 TRUSTEDKEY_CYGWINPORTS_FPR="45600BB98CA878AA97A70119FF20AF9A66EE1F94" TRUSTEDKEY_CYGWINPORTS_URL_LATEST="http://cygwinports.org/ports.gpg" -(( 5 <= "${DEBUG:-0}" )) && set -x - # this script requires some packages WGET="$( which wget 2>/dev/null )" @@ -134,12 +143,29 @@ function usage() -function version() +function git_status () +{ + local origin stauts + [ ! -d "${SCRIPT_REALDIR%/}/.git" ] && return 1 + pushd "${SCRIPT_REALDIR}" >/dev/null + echo + origin="$(git config --get remote.origin.url)" && echo "origin: $origin" + echo "commit: $(git log -1 --pretty=format:"%ai %h%d")" + status="$(git status --short "${SCRIPT_REALNAME}")" + [ -n "$status" ] && echo "status: $status" + popd >/dev/null +} + +function version () { - echo "apt-cyg version 0.57" - echo "Written by Stephen Jungels" - echo "" - echo "Copyright (c) 2005-9 Stephen Jungels. Released under the GPL." + cat<<-EOD + kou1okada/apt-cyg + forked from transcode-open/apt-cyg$(git_status) + + This script is based on apt-cyg version 0.57 + Copyright (c) 2005-9 Stephen Jungels. Released under the GPL. + Copyright (c) 2013-7 Stephen Jungels. Republished under the MIT license. + EOD } # Usage: verbose [level [msg ...]] @@ -1969,14 +1995,5 @@ function invoke_subcommand () fi } -SCRIPT_PATH="$(which "$0")" -SCRIPT_FILE="${SCRIPT_PATH##*/}" -SCRIPT_NAME="${SCRIPT_FILE%.*}" -SCRIPT_DIR="${SCRIPT_PATH%/*}" -SCRIPT_REALPATH="$(realpath "$(which "$0")")" -SCRIPT_REALFILE="${SCRIPT_REALPATH##*/}" -SCRIPT_REALNAME="${SCRIPT_REALFILE%.*}" -SCRIPT_REALDIR="${SCRIPT_REALPATH%/*}" - proxy_setup invoke_subcommand "$SUBCOMMAND" "${ARGS[@]}" From 9818e5edd50e944511e4cbbedf217387096309d2 Mon Sep 17 00:00:00 2001 From: "E:V:A" Date: Fri, 16 Nov 2018 09:02:45 +0000 Subject: [PATCH 166/309] Update README.md Improved command tables with proper markups and fixed grammatics in the README.md --- README.md | 81 ++++++++++++++++++++++++++++--------------------------- 1 file changed, 42 insertions(+), 39 deletions(-) diff --git a/README.md b/README.md index 4965c51..e2c2b4a 100644 --- a/README.md +++ b/README.md @@ -5,51 +5,54 @@ apt-cyg ------- apt-cyg is a command-line installer for [Cygwin](http://cygwin.com/) which cooperates with Cygwin Setup and uses the same repository. The syntax is similar to apt-get. Usage examples: -* "apt-cyg install <package names>" to install packages -* "apt-cyg remove <package names>" to remove packages -* "apt-cyg update" to update setup.ini -* "apt-cyg show" to show installed packages -* "apt-cyg find <pattern(s)>" to find packages matching patterns -* "apt-cyg describe <pattern(s)>" to describe packages matching patterns -* "apt-cyg packageof <commands or files>" to locate parent packages -* "apt-cyg pathof <cache|mirror|mirrordir|cache/mirrordir|setup.ini>" to show path -* "apt-cyg key-add <files> ..." to add keys contained in <files> -* "apt-cyg key-del <keyids> ..." to remove keys <keyids> -* "apt-cyg key-list" to list keys -* "apt-cyg key-finger" to list fingerprints -* "apt-cyg upgrade-self" to upgrade apt-cyg -* "apt-cyg depends <package names>" to show forward dependency information for packages with depth. -* "apt-cyg rdepends <package names>" to show reverse dependency information for packages with depth. -* "apt-cyg completion-install" to install completion. -* "apt-cyg completion-uninstall" to uninstall completion. -* "apt-cyg mirrors-list" to show list of mirrors. -* "apt-cyg benchmark-mirrors <url> ..." to benchmark mirrors. -* "apt-cyg benchmark-parallel-mirrors <url> ..." to benchmark mirrors in parallel. -* "apt-cyg benchmark-parallel-mirrors-list" to benchmark mirrors-list in parallel. -* "apt-cyg scriptinfo" to show script infomations. -* "apt-cyg show-packages-busyness <package names> ..." to show packages are busy or noe. -* "apt-cyg dist-upgrade" to upgrade all packages that is installed. This subcommand uses setup-*.exe -* "apt-cyg update-setup" to update setup.exe -* "apt-cyg setup" to call setup.exe -* "apt-cyg packages-total-count" count number of total packages from setup.ini -* "apt-cyg packages-total-size" count size of total packages from setup.ini -* "apt-cyg packages-cached-count" count number of cached packages in cache/mirrordir. -* "apt-cyg packages-cached-size" count size of cached packages in cache/mirrordir. -* "apt-cyg repair-acl" repair acl. -* "apt-cyg source" download source archive. -* "apt-cyg download" download the binary package into the current directory. -* "apt-cyg mirror" download the binary package into the current cache/mirrordir as mirror. -* "apt-cyg listfiles" List files 'owned' by package(s). -* "apt-cyg get-proxy" Get proxies for eval. +| Command | Description | +|:------- |:----------- | +| `apt-cyg install ` | to install packages | +| `apt-cyg remove ` | to remove packages | +| `apt-cyg update` | to update *setup.ini* | +| `apt-cyg show` | to show installed packages | +| `apt-cyg find ` | to find packages matching patterns | +| `apt-cyg describe ` | to describe packages matching patterns | +| `apt-cyg packageof ` | to locate parent packages | +| `apt-cyg pathof ` | to show path | +| `apt-cyg key-add ...` | to add keys contained in | +| `apt-cyg key-del ...` | to remove keys | +| `apt-cyg key-list` | to list keys | +| `apt-cyg key-finger` | to list fingerprints | +| `apt-cyg upgrade-self` | to upgrade apt-cyg | +| `apt-cyg depends ` | to show forward dependency information for packages with depth. | +| `apt-cyg rdepends ` | to show reverse dependency information for packages with depth. | +| `apt-cyg completion-install` | to install completion. | +| `apt-cyg completion-uninstall` | to uninstall completion. | +| `apt-cyg mirrors-list` | to show list of mirrors. | +| `apt-cyg benchmark-mirrors ...` | to benchmark mirrors. | +| `apt-cyg benchmark-parallel-mirrors ...` | to benchmark mirrors in parallel. | +| `apt-cyg benchmark-parallel-mirrors-list` | to benchmark mirrors-list in parallel. | +| `apt-cyg scriptinfo` | to show script infomations. | +| `apt-cyg show-packages-busyness ...` | to show if packages are busy or not. | +| `apt-cyg dist-upgrade` | to upgrade all packages that is installed. This subcommand uses **`setup-*.exe`** | +| `apt-cyg update-setup` | to update setup.exe | +| `apt-cyg setup` | to call setup.exe | +| `apt-cyg packages-total-count` | count number of total packages from setup.ini | +| `apt-cyg packages-total-size` | count size of total packages from setup.ini | +| `apt-cyg packages-cached-count` | count number of cached packages in cache/mirrordir. | +| `apt-cyg packages-cached-size` | count size of cached packages in cache/mirrordir. | +| `apt-cyg repair-acl` | repair the windows ACL (Access Control List). | +| `apt-cyg source` | download source archive. | +| `apt-cyg download` | download the binary package into the current directory. | +| `apt-cyg mirror` | download the binary package into the current cache/mirrordir as mirror. | +| `apt-cyg listfiles` | List files 'owned' by package(s). | +| `apt-cyg get-proxy` | Get proxies for eval. | + Requirements ------------ -apt-cyg requires the cygwin default environment and optional packages below. +`apt-cyg` requires the Cygwin default environment and the additional *Cygwin* packages: -* wget,ca-certificates,gnupg +`wget, ca-certificates, gnupg` -In 32bit version of cygwin, wget requires an additional setting for ca-certificates package. +In **32bit** version of cygwin, `wget` requires an additional setting for the `ca-certificates` package. Choose one of below settings. # 1. Create symbolic link for the default ca-directory of wget. From 6939693a1677ac21b5e3697a0d599f2b5e8bce42 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Fri, 16 Nov 2018 20:23:29 +0900 Subject: [PATCH 167/309] Update README.md * Fix mistakes for markuping to "<...>". * Improve markup for inline code. --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index e2c2b4a..6f63ef3 100644 --- a/README.md +++ b/README.md @@ -15,8 +15,8 @@ apt-cyg is a command-line installer for [Cygwin](http://cygwin.com/) which coope | `apt-cyg describe ` | to describe packages matching patterns | | `apt-cyg packageof ` | to locate parent packages | | `apt-cyg pathof ` | to show path | -| `apt-cyg key-add ...` | to add keys contained in | -| `apt-cyg key-del ...` | to remove keys | +| `apt-cyg key-add ...` | to add keys contained in `` | +| `apt-cyg key-del ...` | to remove keys `` | | `apt-cyg key-list` | to list keys | | `apt-cyg key-finger` | to list fingerprints | | `apt-cyg upgrade-self` | to upgrade apt-cyg | @@ -50,7 +50,7 @@ Requirements `apt-cyg` requires the Cygwin default environment and the additional *Cygwin* packages: -`wget, ca-certificates, gnupg` +`wget`, `ca-certificates`, `gnupg` In **32bit** version of cygwin, `wget` requires an additional setting for the `ca-certificates` package. Choose one of below settings. From ef08fe85c906ff562c694f2e328a46b57a65cb4a Mon Sep 17 00:00:00 2001 From: kou1okada Date: Fri, 16 Nov 2018 20:35:27 +0900 Subject: [PATCH 168/309] Fix a misspelling. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6f63ef3..d4dcc04 100644 --- a/README.md +++ b/README.md @@ -93,7 +93,7 @@ New features ### dist-upgrade support -This fork has achieved dist-upgrade command by using `setup-x86.exe` and `setup-x96_64.exe` as a backend. +This fork has achieved dist-upgrade command by using `setup-x86.exe` and `setup-x86_64.exe` as a backend. Note that all of running tasks on the cygwin will be killed before starting dist-upgrade. ### Multiple hash algorithms support From 212a4e3359ea1d01241b7d158e61c7462d0e0add Mon Sep 17 00:00:00 2001 From: kou1okada Date: Fri, 16 Nov 2018 20:39:02 +0900 Subject: [PATCH 169/309] Update README.md * Improve markup for inline code. --- README.md | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index d4dcc04..047387f 100644 --- a/README.md +++ b/README.md @@ -68,7 +68,7 @@ Choose one of below settings. Remarks: Above additional settings for wget is not required for 64bit version of cygwin. -But, as of 2014-01-17, perhaps ca-certificates package makes fail of certification in 64bit version of cygwin with Windows 8. See below: +But, as of 2014-01-17, perhaps `ca-certificates` package makes fail of certification in 64bit version of cygwin with Windows 8. See below: * Known Problem / [2014-01-17: ca-certificates package is not setup correct at x86_64 with Windows 8.](#2014-01-17-ca-certificates-package-is-not-setup-correct-at-x86_64-with-windows-8) @@ -93,7 +93,7 @@ New features ### dist-upgrade support -This fork has achieved dist-upgrade command by using `setup-x86.exe` and `setup-x86_64.exe` as a backend. +This fork has achieved `dist-upgrade` command by using `setup-x86.exe` and `setup-x86_64.exe` as a backend. Note that all of running tasks on the cygwin will be killed before starting dist-upgrade. ### Multiple hash algorithms support @@ -117,13 +117,13 @@ Of course, you must install both environments of x86_64 and x86, beforehand. ### Signature check and key management by GnuPG The default action of apt-cyg has been changed to check signature for 'setup.ini'. -Of course you can also avoid signature check by using --no-verify or -X options. +Of course you can also avoid signature check by using `--no-verify` or `-X` options. Public keys of cygwin and cygwinports are already registered to trusted keys of embeded. -If you want to use some other public keys, please use key-* subcommands. +If you want to use some other public keys, please use `key-*` subcommands. ### Upgrade apt-cyg -If apt-cyg is under the git version control, this fork can upgrade itself by "upgrade-self" subcommand. +If apt-cyg is under the git version control, this fork can upgrade itself by `upgrade-self` subcommand. Therefore, the most recommended way to deploy this fork is below: git clone HTTPS_clone_URL @@ -134,7 +134,7 @@ It can be found from the right side menu in each fork pages on github. ### Proxy support -Use --proxy, -p option. +Use `--proxy`, `-p` option. This option must take a parameter from one of "auto", "inherit", "none" and URL. * "auto" will determine a proxy using a part of the [Web Proxy Auto-Discovery Protocol (WPAD)](http://en.wikipedia.org/wiki/Web_Proxy_Autodiscovery_Protocol). @@ -221,7 +221,7 @@ Known Problem ### 2016-02-12: Problems about the ACL In recent version, the cygwin changed the ACL mechanism . -So, in the cygwin current version, if it will be installed by setup.exe with -B or --no-admin option, +So, in the cygwin current version, if it will be installed by `setup.exe` with `-B` or `--no-admin` option, the cygwin root (/) does not have correct ACL. A new subcommand `repair-acl` tries to repair it. @@ -236,7 +236,7 @@ thienhv reported this problem [#14](https://github.com/kou1okada/apt-cyg/issues/ ### 2014-01-17: ca-certificates package is not setup correct at x86_64 with Windows 8. -After clean installing with setup-x86_64, there are something wrong about ca-certificate package as below: +After clean installing with `setup-x86_64.exe`, there are something wrong about ca-certificate package as below: $ ls -lnG \ /cygdrive/c/cygwin/etc/pki/ca-trust/extracted/openssl/ca-bundle.trust.crt \ @@ -251,7 +251,7 @@ After clean installing with setup-x86_64, there are something wrong about ca-cer The x86 environment seems no problem except that need an additional setting for wget and ca-certificate. Hmm,,, -It seems that /usr/bin/update-ca-trust is failed at x86_64. +It seems that `/usr/bin/update-ca-trust` is failed at x86_64. It's ad hoc, but effective way to fix it, is to copy files from cygwin32 to cygwin64, as below: @@ -269,6 +269,7 @@ For more details, see a thread of below: * Cygwin mailing list / cygwin / [Re: Is there someone who have a same problem ?](http://cygwin.com/ml/cygwin/2014-01/msg00368.html) ### 2014-01-15: Signature check failed at cygwinports x86_64. + Oops, setup.bz2 is newer than setup.bz2.sig. And it seems to be corrupted. @@ -295,9 +296,10 @@ And it seems to be corrupted. As of 2014-01-24, above problem is recovered at least. -### FIXED: Check setup (cygcheck -c) can not detect .tar.xz packages +### FIXED: Check setup (`cygcheck -c`) can not detect .tar.xz packages + At cygwin 1.7.25, cygcheck is hardcoded for .tar.gz and .tar.bz2. -So check setup (cygcheck -c) can not detect .tar.xz packages. +So check setup (`cygcheck -c`) can not detect .tar.xz packages. This bug was already fixed with [src/winsup/utils/dump_setup.cc#rev1.28](http://cygwin.com/cgi-bin/cvsweb.cgi/src/winsup/utils/dump_setup.cc?cvsroot=src#rev1.28). Please wait a release of cygwin 1.7.26. From 56a9e8c7cb75b2483799860bba6bf4b355e4574a Mon Sep 17 00:00:00 2001 From: kou1okada Date: Fri, 16 Nov 2018 20:51:17 +0900 Subject: [PATCH 170/309] Improve help message. * Add descriptions of options for --help and --version. --- apt-cyg | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apt-cyg b/apt-cyg index ec1d0d2..08dc685 100755 --- a/apt-cyg +++ b/apt-cyg @@ -137,8 +137,8 @@ function usage() echo " --no-progress : hide the progress bar in any verbosity mode" echo " --quiet, -q : quiet (no output)" echo " --verbose, -v : verbose" - echo " --help" - echo " --version" + echo " --help : Display help and exit" + echo " --version : Display version and exit" } From 17165932b6cd6c7fd569c30aa699bcd01df4eb65 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Fri, 16 Nov 2018 20:52:52 +0900 Subject: [PATCH 171/309] Update README.md * Add descriptions of options. --- README.md | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/README.md b/README.md index 047387f..4f1b33d 100644 --- a/README.md +++ b/README.md @@ -44,6 +44,36 @@ apt-cyg is a command-line installer for [Cygwin](http://cygwin.com/) which coope | `apt-cyg listfiles` | List files 'owned' by package(s). | | `apt-cyg get-proxy` | Get proxies for eval. | +### Options + +| Option | Description | +|:------ |:----------- | +| `--ag` | use the silver searcher (currently work only at packageof subcommand) | +| `--charch ` | change archetecture | +| `--use-setuprc` | set cache and mirror with /etc/setup/setup.rc | +| `--use-own-conf` | use own cache and mirror settings when apt-cyg calls setup.exe | +| `--ignore-case`, `-i` | ignore case distinctions for `` | +| `--force-remove` | force remove +| `--force-fetch-trustedkeys` | force fetch trustedkeys | +| `--force-update-packageof-cache` | force update packageof cache | +| `--no-verify`, `-X` | Don't verify setup.ini signatures | +| `--no-check-certificate` | Don't validate the server's certificate | +| `--no-update-setup` | Don't update setup.exe +| `--no-header` | Don't print header | +| `--proxy`, `-p ` | set proxy (default: ${APT_CYG_PROXY:-auto}) | +| `--completion-get-subcommand` | get subcommand (for completion internal use) | +| `--completion-disable-autoupdate` | disable completion autoupdate | +| `--max-jobs`, `-j ` | Run n jobs in parallel | +| `--mirror`, `-m ` | set mirror +| `--cache`, `-c ` | set cache | +| `--file`, `-f ` | read package names from file | +| `--noupdate`, `-u` | don't update setup.ini from mirror | +| `--ipv4`, `-4` | wget prefer ipv4 | +| `--no-progress` | hide the progress bar in any verbosity mode | +| `--quiet`, `-q` | quiet (no output) | +| `--verbose`, `-v` | verbose | +| `--help` | Display help and exit | +| `--version` | Display version and exit | Requirements ------------ From 4829ecd97be9fd60d1a9d302e4ccb23ddd16397d Mon Sep 17 00:00:00 2001 From: kou1okada Date: Fri, 16 Nov 2018 21:14:19 +0900 Subject: [PATCH 172/309] Update README.md * Add a usage of command line. * Simplify the descriptions for sub commands by reduce redundant main command (`apt-cyg`) repetitions. --- README.md | 87 ++++++++++++++++++++++++++++++------------------------- 1 file changed, 47 insertions(+), 40 deletions(-) diff --git a/README.md b/README.md index 4f1b33d..d436946 100644 --- a/README.md +++ b/README.md @@ -1,48 +1,55 @@ apt-cyg ======= -apt-cyg -------- -apt-cyg is a command-line installer for [Cygwin](http://cygwin.com/) which cooperates with Cygwin Setup and uses the same repository. The syntax is similar to apt-get. Usage examples: +apt-cyg is a command-line installer for [Cygwin](http://cygwin.com/) which cooperates with Cygwin Setup and uses the same repository. The syntax is similar to apt-get. + +Usage +----- + +### Command line + + apt-cyg [OPTIONS ...] [SUBCOMMAND [PARAMETERS ...]] + +### Sub commands -| Command | Description | +| Sub command | Description | |:------- |:----------- | -| `apt-cyg install ` | to install packages | -| `apt-cyg remove ` | to remove packages | -| `apt-cyg update` | to update *setup.ini* | -| `apt-cyg show` | to show installed packages | -| `apt-cyg find ` | to find packages matching patterns | -| `apt-cyg describe ` | to describe packages matching patterns | -| `apt-cyg packageof ` | to locate parent packages | -| `apt-cyg pathof ` | to show path | -| `apt-cyg key-add ...` | to add keys contained in `` | -| `apt-cyg key-del ...` | to remove keys `` | -| `apt-cyg key-list` | to list keys | -| `apt-cyg key-finger` | to list fingerprints | -| `apt-cyg upgrade-self` | to upgrade apt-cyg | -| `apt-cyg depends ` | to show forward dependency information for packages with depth. | -| `apt-cyg rdepends ` | to show reverse dependency information for packages with depth. | -| `apt-cyg completion-install` | to install completion. | -| `apt-cyg completion-uninstall` | to uninstall completion. | -| `apt-cyg mirrors-list` | to show list of mirrors. | -| `apt-cyg benchmark-mirrors ...` | to benchmark mirrors. | -| `apt-cyg benchmark-parallel-mirrors ...` | to benchmark mirrors in parallel. | -| `apt-cyg benchmark-parallel-mirrors-list` | to benchmark mirrors-list in parallel. | -| `apt-cyg scriptinfo` | to show script infomations. | -| `apt-cyg show-packages-busyness ...` | to show if packages are busy or not. | -| `apt-cyg dist-upgrade` | to upgrade all packages that is installed. This subcommand uses **`setup-*.exe`** | -| `apt-cyg update-setup` | to update setup.exe | -| `apt-cyg setup` | to call setup.exe | -| `apt-cyg packages-total-count` | count number of total packages from setup.ini | -| `apt-cyg packages-total-size` | count size of total packages from setup.ini | -| `apt-cyg packages-cached-count` | count number of cached packages in cache/mirrordir. | -| `apt-cyg packages-cached-size` | count size of cached packages in cache/mirrordir. | -| `apt-cyg repair-acl` | repair the windows ACL (Access Control List). | -| `apt-cyg source` | download source archive. | -| `apt-cyg download` | download the binary package into the current directory. | -| `apt-cyg mirror` | download the binary package into the current cache/mirrordir as mirror. | -| `apt-cyg listfiles` | List files 'owned' by package(s). | -| `apt-cyg get-proxy` | Get proxies for eval. | +| `install ` | to install packages | +| `remove ` | to remove packages | +| `update` | to update *setup.ini* | +| `show` | to show installed packages | +| `find ` | to find packages matching patterns | +| `describe ` | to describe packages matching patterns | +| `packageof ` | to locate parent packages | +| `pathof ` | to show path | +| `key-add ...` | to add keys contained in `` | +| `key-del ...` | to remove keys `` | +| `key-list` | to list keys | +| `key-finger` | to list fingerprints | +| `upgrade-self` | to upgrade apt-cyg | +| `depends ` | to show forward dependency information for packages with depth. | +| `rdepends ` | to show reverse dependency information for packages with depth. | +| `completion-install` | to install completion. | +| `completion-uninstall` | to uninstall completion. | +| `mirrors-list` | to show list of mirrors. | +| `benchmark-mirrors ...` | to benchmark mirrors. | +| `benchmark-parallel-mirrors ...` | to benchmark mirrors in parallel. | +| `benchmark-parallel-mirrors-list` | to benchmark mirrors-list in parallel. | +| `scriptinfo` | to show script infomations. | +| `show-packages-busyness ...` | to show if packages are busy or not. | +| `dist-upgrade` | to upgrade all packages that is installed. This subcommand uses **`setup-*.exe`** | +| `update-setup` | to update setup.exe | +| `setup` | to call setup.exe | +| `packages-total-count` | count number of total packages from setup.ini | +| `packages-total-size` | count size of total packages from setup.ini | +| `packages-cached-count` | count number of cached packages in cache/mirrordir. | +| `packages-cached-size` | count size of cached packages in cache/mirrordir. | +| `repair-acl` | repair the windows ACL (Access Control List). | +| `source` | download source archive. | +| `download` | download the binary package into the current directory. | +| `mirror` | download the binary package into the current cache/mirrordir as mirror. | +| `listfiles` | List files 'owned' by package(s). | +| `get-proxy` | Get proxies for eval. | ### Options From 88c5616c12359381ae6da8715cd8fe72ab16f9cd Mon Sep 17 00:00:00 2001 From: kou1okada Date: Fri, 16 Nov 2018 22:12:43 +0900 Subject: [PATCH 173/309] Improve the description of usage in help and README.md. --- README.md | 50 ++++++++-------- apt-cyg | 166 +++++++++++++++++++++++++++++++----------------------- 2 files changed, 120 insertions(+), 96 deletions(-) diff --git a/README.md b/README.md index d436946..ff7d53c 100644 --- a/README.md +++ b/README.md @@ -14,41 +14,41 @@ Usage | Sub command | Description | |:------- |:----------- | -| `install ` | to install packages | -| `remove ` | to remove packages | +| `install PACKAGE_NAMES` | to install packages | +| `remove PACKAGE_NAMES` | to remove packages | | `update` | to update *setup.ini* | | `show` | to show installed packages | -| `find ` | to find packages matching patterns | -| `describe ` | to describe packages matching patterns | -| `packageof ` | to locate parent packages | -| `pathof ` | to show path | -| `key-add ...` | to add keys contained in `` | -| `key-del ...` | to remove keys `` | +| `find PATTERNS` | to find packages matching patterns | +| `describe PATTERNS` | to describe packages matching patterns | +| `packageof COMMAND_OR_FILE_NAMES ...` | to locate parent packages | +| `pathof "cache"\|"mirror"\|"mirrordir"\|"cache/mirrordir"\|"setup.ini"` | to show path | +| `key-add FILES ...` | to add keys contained in FILES | +| `key-del KEYIDS ...` | to remove keys `KEYIDS` | | `key-list` | to list keys | | `key-finger` | to list fingerprints | | `upgrade-self` | to upgrade apt-cyg | -| `depends ` | to show forward dependency information for packages with depth. | -| `rdepends ` | to show reverse dependency information for packages with depth. | +| `depends PACKAGE_NAMES ...` | to show forward dependency information for packages with depth. | +| `rdepends PACKAGE_NAMES ...` | to show reverse dependency information for packages with depth. | | `completion-install` | to install completion. | | `completion-uninstall` | to uninstall completion. | | `mirrors-list` | to show list of mirrors. | -| `benchmark-mirrors ...` | to benchmark mirrors. | -| `benchmark-parallel-mirrors ...` | to benchmark mirrors in parallel. | +| `benchmark-mirrors URLs ...` | to benchmark mirrors. | +| `benchmark-parallel-mirrors URLs ...` | to benchmark mirrors in parallel. | | `benchmark-parallel-mirrors-list` | to benchmark mirrors-list in parallel. | | `scriptinfo` | to show script infomations. | -| `show-packages-busyness ...` | to show if packages are busy or not. | +| `show-packages-busyness PACKAGE_NAMES ...` | to show if packages are busy or not. | | `dist-upgrade` | to upgrade all packages that is installed. This subcommand uses **`setup-*.exe`** | | `update-setup` | to update setup.exe | -| `setup` | to call setup.exe | +| `setup [PARAMS ...]` | to call setup.exe | | `packages-total-count` | count number of total packages from setup.ini | -| `packages-total-size` | count size of total packages from setup.ini | +| `packages-total-size [PATTERN_OF_SECTION]` | count size of total packages from setup.ini | | `packages-cached-count` | count number of cached packages in cache/mirrordir. | | `packages-cached-size` | count size of cached packages in cache/mirrordir. | | `repair-acl` | repair the windows ACL (Access Control List). | -| `source` | download source archive. | -| `download` | download the binary package into the current directory. | -| `mirror` | download the binary package into the current cache/mirrordir as mirror. | -| `listfiles` | List files 'owned' by package(s). | +| `source PACKAGE_NAMES ...` | download source archive. | +| `download PACKAGE_NAMES ...` | download the binary package into the current directory. | +| `mirror PACKAGE_NAMES ...` | download the binary package into the current cache/mirrordir as mirror. | +| `listfiles PACKAGE_NAMES ...` | List files 'owned' by package(s). | | `get-proxy` | Get proxies for eval. | ### Options @@ -56,7 +56,7 @@ Usage | Option | Description | |:------ |:----------- | | `--ag` | use the silver searcher (currently work only at packageof subcommand) | -| `--charch ` | change archetecture | +| `--charch ARCH` | change archetecture | | `--use-setuprc` | set cache and mirror with /etc/setup/setup.rc | | `--use-own-conf` | use own cache and mirror settings when apt-cyg calls setup.exe | | `--ignore-case`, `-i` | ignore case distinctions for `` | @@ -67,13 +67,13 @@ Usage | `--no-check-certificate` | Don't validate the server's certificate | | `--no-update-setup` | Don't update setup.exe | `--no-header` | Don't print header | -| `--proxy`, `-p ` | set proxy (default: ${APT_CYG_PROXY:-auto}) | +| `--proxy`, `-p "auto"\|"inherit"\|"none"\|URL` | set proxy (default: ${APT_CYG_PROXY:-auto}) | | `--completion-get-subcommand` | get subcommand (for completion internal use) | | `--completion-disable-autoupdate` | disable completion autoupdate | -| `--max-jobs`, `-j ` | Run n jobs in parallel | -| `--mirror`, `-m ` | set mirror -| `--cache`, `-c ` | set cache | -| `--file`, `-f ` | read package names from file | +| `--max-jobs`, `-j N` | Run N jobs in parallel | +| `--mirror`, `-m URL` | set mirror +| `--cache`, `-c DIR` | set cache | +| `--file`, `-f FILE` | read package names from file | | `--noupdate`, `-u` | don't update setup.ini from mirror | | `--ipv4`, `-4` | wget prefer ipv4 | | `--no-progress` | hide the progress bar in any verbosity mode | diff --git a/apt-cyg b/apt-cyg index 08dc685..e34221e 100755 --- a/apt-cyg +++ b/apt-cyg @@ -68,77 +68,101 @@ fi function usage() { - echo apt-cyg: Installs and removes Cygwin packages. - echo " \"apt-cyg install \" to install packages" - echo " \"apt-cyg remove \" to remove packages" - echo " \"apt-cyg update\" to update setup.ini" - echo " \"apt-cyg show\" to show installed packages" - echo " \"apt-cyg find \" to find packages matching patterns" - echo " \"apt-cyg describe \" to describe packages matching patterns" - echo " \"apt-cyg packageof \" to locate parent packages" - echo " \"apt-cyg pathof \"" - echo " to show path" - echo " \"apt-cyg key-add ...\" to add keys contained in " - echo " \"apt-cyg key-del ...\" to remove keys " - echo " \"apt-cyg key-list\" to list keys" - echo " \"apt-cyg key-finger\" to list fingerprints" - echo " \"apt-cyg upgrade-self\" to upgrade apt-cyg" - echo " \"apt-cyg depends \"" - echo " to show forward dependency information for packages with depth." - echo " \"apt-cyg rdepends \"" - echo " to show reverse dependency information for packages with depth." - echo " \"apt-cyg completion-install\" to install completion." - echo " \"apt-cyg completion-uninstall\" to uninstall completion." - echo " \"apt-cyg mirrors-list\" to show list of mirros." - echo " \"apt-cyg benchmark-mirrors ...\" to benchmark mirrors." - echo " \"apt-cyg benchmark-parallel-mirrors ...\" to benchmark mirrors in parallel." - echo " \"apt-cyg benchmark-parallel-mirrors-list\" to benchmark mirrors-list in parallel." - echo " \"apt-cyg scriptinfo\" to show script infomations." - echo " \"apt-cyg show-packages-busyness ...\" to show packages are busy or noe." - echo " \"apt-cyg dist-upgrade\" to upgrade all packages that is installed. This subcommand uses setup.exe" - echo " \"apt-cyg update-setup\" to update setup.exe" - echo " \"apt-cyg setup\" to call setup.exe" - echo " \"apt-cyg packages-total-count\" count number of total packages from setup.ini" - echo " \"apt-cyg packages-total-size [pattern_of_section]\" count size of total packages from setup.ini" - echo " \"apt-cyg packages-cached-count\" count number of cached packages in cache/mirrordir." - echo " \"apt-cyg packages-cached-size\" count size of cached packages in cache/mirrordir." - echo " \"apt-cyg repair-acl\" repair acl." - echo " \"apt-cyg source\" download source archive." - echo " \"apt-cyg download\" download the binary package into the current directory." - echo " \"apt-cyg mirror\" download the binary package into the current cache/mirrordir as mirror." - echo " \"apt-cyg listfiles\" List files 'owned' by package(s)." - echo " \"apt-cyg get-proxy\" Get proxies for eval." - echo "Options:" - echo " --ag : use the silver searcher (currently work only at packageof subcommand)" - echo " --charch : change archetecture" - echo " --use-setuprc : set cache and mirror with /etc/setup/setup.rc" - echo " --use-own-conf : use own cache and mirror settings when apt-cyg calls setup.exe" - echo " --ignore-case, -i : ignore case distinctions for " - echo " --force-remove : force remove" - echo " --force-fetch-trustedkeys: force fetch trustedkeys" - echo " --force-update-packageof-cache:" - echo " force update packageof cache" - echo " --no-verify, -X : Don't verify setup.ini signatures" - echo " --no-check-certificate : Don't validate the server's certificate" - echo " --no-update-setup : Don't update setup.exe" - echo " --no-header : Don't print header" - echo " --proxy, -p :" - echo " set proxy (default: \${APT_CYG_PROXY:-auto})" - echo " --completion-get-subcommand:" - echo " get subcommand (for completion internal use)" - echo " --completion-disable-autoupdate:" - echo " disable completion autoupdate" - echo " --max-jobs, -j : Run n jobs in parallel" - echo " --mirror, -m : set mirror" - echo " --cache, -c : set cache" - echo " --file, -f : read package names from file" - echo " --noupdate, -u : don't update setup.ini from mirror" - echo " --ipv4, -4 : wget prefer ipv4" - echo " --no-progress : hide the progress bar in any verbosity mode" - echo " --quiet, -q : quiet (no output)" - echo " --verbose, -v : verbose" - echo " --help : Display help and exit" - echo " --version : Display version and exit" + cat<<-EOD + Usage: apt-cyg [OPTIONS ...] [SUBCOMMAND [PARAMETERS ...]] + Installs and removes Cygwin packages. + Sub Commands: + install PACKAGE_NAMES : to install packages + remove PACKAGE_NAMES : to remove packages + update : to update setup.ini + show : to show installed packages + find PATTERNS ... : to find packages matching PATTERNS + describe PATTERNS ... : to describe packages matching PATTERNS + packageof COMMAND_OR_FILE_NAMES ... : + to locate parent packages + pathof "cache"|"mirror"|"mirrordir"|"cache/mirrordir"|"setup.ini" : + to show path + key-add FILES ... : to add keys contained in FILES + key-del KEYIDS ... : to remove keys KEYIDS + key-list : to list keys + key-finger : to list fingerprints + upgrade-self : to upgrade apt-cyg + depends PACKAGE_NAMES ... : + to show forward dependency information + for packages with depth. + rdepends PACKAGE_NAMES ... : + to show reverse dependency information + for packages with depth. + completion-install : to install completion. + completion-uninstall : to uninstall completion. + mirrors-list : to show list of mirros. + benchmark-mirrors URLs ... : + to benchmark mirrors. + benchmark-parallel-mirrors URLs ... : + to benchmark mirrors in parallel. + benchmark-parallel-mirrors-list : + to benchmark mirrors-list in parallel. + scriptinfo : to show script infomations. + show-packages-busyness PACKAGE_NAMES ... : + to show packages are busy or noe. + dist-upgrade : to upgrade all packages that is installed. + This subcommand uses setup.exe + update-setup : to update setup.exe + setup [PARAMS ...] : to call setup.exe + packages-total-count : count number of total packages from setup.ini + packages-total-size [PATTERN_OF_SECTION] : + count size of total packages from setup.ini + packages-cached-count : count number of cached packages + in cache/mirrordir. + packages-cached-size : count size of cached packages + in cache/mirrordir. + repair-acl : repair acl. + source PACKAGE_NAMES ... : + download source archive. + download PACKAGE_NAMES ... : + download the binary package + into the current directory. + mirror PACKAGE_NAMES ... : + download the binary package + into the current cache/mirrordir as mirror. + listfiles PACKAGE_NAMES ... : + List files 'owned' by package(s). + get-proxy : Get proxies for eval. + Options: + --ag : use the silver searcher + (currently work only at packageof subcommand) + --charch ARCH : change archetecture + --use-setuprc : set cache and mirror with /etc/setup/setup.rc + --use-own-conf : use own cache and mirror settings + when apt-cyg calls setup.exe + --ignore-case, -i : ignore case distinctions for + --force-remove : force remove + --force-fetch-trustedkeys : + force fetch trustedkeys + --force-update-packageof-cache : + force update packageof cache + --no-verify, -X : Don't verify setup.ini signatures + --no-check-certificate : Don't validate the server's certificate + --no-update-setup : Don't update setup.exe + --no-header : Don't print header + --proxy, -p "auto"|"inherit"|"none"|URL : + set proxy (default: \${APT_CYG_PROXY:-auto}) + --completion-get-subcommand : + get subcommand (for completion internal use) + --completion-disable-autoupdate : + disable completion autoupdate + --max-jobs, -j N : Run N jobs in parallel + --mirror, -m URL : set mirror + --cache, -c DIR : set cache + --file, -f FILE : read package names from file + --noupdate, -u : don't update setup.ini from mirror + --ipv4, -4 : wget prefer ipv4 + --no-progress : hide the progress bar in any verbosity mode + --quiet, -q : quiet (no output) + --verbose, -v : verbose + --help : Display help and exit + --version : Display version and exit + EOD } From d9ae7d8e091f6b4034151f9630c67d587173b81a Mon Sep 17 00:00:00 2001 From: kou1okada Date: Tue, 20 Nov 2018 09:53:43 +0900 Subject: [PATCH 174/309] Add `ls-categories` sub command. --- README.md | 1 + apt-cyg | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/README.md b/README.md index ff7d53c..77d3556 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,7 @@ Usage | `mirror PACKAGE_NAMES ...` | download the binary package into the current cache/mirrordir as mirror. | | `listfiles PACKAGE_NAMES ...` | List files 'owned' by package(s). | | `get-proxy` | Get proxies for eval. | +| `ls-categories` | List categories. | ### Options diff --git a/apt-cyg b/apt-cyg index e34221e..99c8ea5 100755 --- a/apt-cyg +++ b/apt-cyg @@ -128,6 +128,7 @@ function usage() listfiles PACKAGE_NAMES ... : List files 'owned' by package(s). get-proxy : Get proxies for eval. + ls-categories : List categories. Options: --ag : use the silver searcher (currently work only at packageof subcommand) @@ -1403,6 +1404,15 @@ function apt-cyg-listfiles () done } +function apt-cyg-ls-categories () +{ + cat "$(apt-cyg-pathof setup.ini)" \ + | grep category: \ + | sed -r 's/.*: *//g;s/ +/\n/g' \ + | sort \ + | uniq +} + PACKAGEOF_CACHE="/tmp/.apt-cyg-packageof.cache.gz" function update_packageof_cache () { From d34efdfc3cfade63b33e6a6c30e8898fe2374ab6 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Tue, 20 Nov 2018 11:32:35 +0900 Subject: [PATCH 175/309] Fix misspelling. --- apt-cyg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apt-cyg b/apt-cyg index 99c8ea5..e3c14c6 100755 --- a/apt-cyg +++ b/apt-cyg @@ -104,7 +104,7 @@ function usage() to benchmark mirrors-list in parallel. scriptinfo : to show script infomations. show-packages-busyness PACKAGE_NAMES ... : - to show packages are busy or noe. + to show packages are busy or not. dist-upgrade : to upgrade all packages that is installed. This subcommand uses setup.exe update-setup : to update setup.exe From a423ed90c65dd86f03d34326a6fe94dc3652f4a7 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Tue, 20 Nov 2018 11:41:53 +0900 Subject: [PATCH 176/309] Fix a missed alignment of indent. --- apt-cyg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apt-cyg b/apt-cyg index e3c14c6..7f76bac 100755 --- a/apt-cyg +++ b/apt-cyg @@ -128,7 +128,7 @@ function usage() listfiles PACKAGE_NAMES ... : List files 'owned' by package(s). get-proxy : Get proxies for eval. - ls-categories : List categories. + ls-categories : List categories. Options: --ag : use the silver searcher (currently work only at packageof subcommand) From e3c13d22fea6c8c78b87fcbf5f4d4c18c82c039b Mon Sep 17 00:00:00 2001 From: kou1okada Date: Tue, 20 Nov 2018 02:13:51 +0900 Subject: [PATCH 177/309] Modify placeholder rules for help. --- README.md | 52 ++++++++++++++++++++++++++-------------------------- apt-cyg | 54 +++++++++++++++++++++++++++--------------------------- 2 files changed, 53 insertions(+), 53 deletions(-) mode change 100644 => 100755 README.md diff --git a/README.md b/README.md old mode 100644 new mode 100755 index 77d3556..40e053b --- a/README.md +++ b/README.md @@ -8,47 +8,47 @@ Usage ### Command line - apt-cyg [OPTIONS ...] [SUBCOMMAND [PARAMETERS ...]] + apt-cyg [] [ [ ...]] ### Sub commands | Sub command | Description | |:------- |:----------- | -| `install PACKAGE_NAMES` | to install packages | -| `remove PACKAGE_NAMES` | to remove packages | +| `install ` | to install packages | +| `remove ` | to remove packages | | `update` | to update *setup.ini* | | `show` | to show installed packages | -| `find PATTERNS` | to find packages matching patterns | -| `describe PATTERNS` | to describe packages matching patterns | -| `packageof COMMAND_OR_FILE_NAMES ...` | to locate parent packages | -| `pathof "cache"\|"mirror"\|"mirrordir"\|"cache/mirrordir"\|"setup.ini"` | to show path | -| `key-add FILES ...` | to add keys contained in FILES | -| `key-del KEYIDS ...` | to remove keys `KEYIDS` | +| `find ` | to find packages matching patterns | +| `describe ` | to describe packages matching patterns | +| `packageof ...` | to locate parent packages | +| `pathof {cache\|mirror\|mirrordir\|cache/mirrordir\|setup.ini}` | to show path | +| `key-add ...` | to add keys contained in \ | +| `key-del ...` | to remove keys \ | | `key-list` | to list keys | | `key-finger` | to list fingerprints | | `upgrade-self` | to upgrade apt-cyg | -| `depends PACKAGE_NAMES ...` | to show forward dependency information for packages with depth. | -| `rdepends PACKAGE_NAMES ...` | to show reverse dependency information for packages with depth. | +| `depends ...` | to show forward dependency information for packages with depth. | +| `rdepends ...` | to show reverse dependency information for packages with depth. | | `completion-install` | to install completion. | | `completion-uninstall` | to uninstall completion. | | `mirrors-list` | to show list of mirrors. | -| `benchmark-mirrors URLs ...` | to benchmark mirrors. | -| `benchmark-parallel-mirrors URLs ...` | to benchmark mirrors in parallel. | +| `benchmark-mirrors ...` | to benchmark mirrors. | +| `benchmark-parallel-mirrors ...` | to benchmark mirrors in parallel. | | `benchmark-parallel-mirrors-list` | to benchmark mirrors-list in parallel. | | `scriptinfo` | to show script infomations. | -| `show-packages-busyness PACKAGE_NAMES ...` | to show if packages are busy or not. | +| `show-packages-busyness ...` | to show if packages are busy or not. | | `dist-upgrade` | to upgrade all packages that is installed. This subcommand uses **`setup-*.exe`** | | `update-setup` | to update setup.exe | -| `setup [PARAMS ...]` | to call setup.exe | +| `setup [ ...]` | to call setup.exe | | `packages-total-count` | count number of total packages from setup.ini | -| `packages-total-size [PATTERN_OF_SECTION]` | count size of total packages from setup.ini | +| `packages-total-size []` | count size of total packages from setup.ini | | `packages-cached-count` | count number of cached packages in cache/mirrordir. | | `packages-cached-size` | count size of cached packages in cache/mirrordir. | | `repair-acl` | repair the windows ACL (Access Control List). | -| `source PACKAGE_NAMES ...` | download source archive. | -| `download PACKAGE_NAMES ...` | download the binary package into the current directory. | -| `mirror PACKAGE_NAMES ...` | download the binary package into the current cache/mirrordir as mirror. | -| `listfiles PACKAGE_NAMES ...` | List files 'owned' by package(s). | +| `source ...` | download source archive. | +| `download ...` | download the binary package into the current directory. | +| `mirror ...` | download the binary package into the current cache/mirrordir as mirror. | +| `listfiles ...` | List files 'owned' by package(s). | | `get-proxy` | Get proxies for eval. | | `ls-categories` | List categories. | @@ -57,7 +57,7 @@ Usage | Option | Description | |:------ |:----------- | | `--ag` | use the silver searcher (currently work only at packageof subcommand) | -| `--charch ARCH` | change archetecture | +| `--charch ` | change archetecture | | `--use-setuprc` | set cache and mirror with /etc/setup/setup.rc | | `--use-own-conf` | use own cache and mirror settings when apt-cyg calls setup.exe | | `--ignore-case`, `-i` | ignore case distinctions for `` | @@ -68,13 +68,13 @@ Usage | `--no-check-certificate` | Don't validate the server's certificate | | `--no-update-setup` | Don't update setup.exe | `--no-header` | Don't print header | -| `--proxy`, `-p "auto"\|"inherit"\|"none"\|URL` | set proxy (default: ${APT_CYG_PROXY:-auto}) | +| `--proxy`, `-p {auto\|inherit\|none\|}` | set proxy (default: ${APT_CYG_PROXY:-auto}) | | `--completion-get-subcommand` | get subcommand (for completion internal use) | | `--completion-disable-autoupdate` | disable completion autoupdate | -| `--max-jobs`, `-j N` | Run N jobs in parallel | -| `--mirror`, `-m URL` | set mirror -| `--cache`, `-c DIR` | set cache | -| `--file`, `-f FILE` | read package names from file | +| `--max-jobs`, `-j ` | Run \ jobs in parallel | +| `--mirror`, `-m ` | set mirror +| `--cache`, `-c ` | set cache | +| `--file`, `-f ` | read package names from \ | | `--noupdate`, `-u` | don't update setup.ini from mirror | | `--ipv4`, `-4` | wget prefer ipv4 | | `--no-progress` | hide the progress bar in any verbosity mode | diff --git a/apt-cyg b/apt-cyg index 7f76bac..1a2a208 100755 --- a/apt-cyg +++ b/apt-cyg @@ -69,70 +69,70 @@ fi function usage() { cat<<-EOD - Usage: apt-cyg [OPTIONS ...] [SUBCOMMAND [PARAMETERS ...]] + Usage: apt-cyg [] [ [ ...]] Installs and removes Cygwin packages. Sub Commands: - install PACKAGE_NAMES : to install packages - remove PACKAGE_NAMES : to remove packages + install : to install packages + remove : to remove packages update : to update setup.ini show : to show installed packages - find PATTERNS ... : to find packages matching PATTERNS - describe PATTERNS ... : to describe packages matching PATTERNS - packageof COMMAND_OR_FILE_NAMES ... : + find ... : to find packages matching patterns + describe ... : to describe packages matching patterns + packageof ... : to locate parent packages - pathof "cache"|"mirror"|"mirrordir"|"cache/mirrordir"|"setup.ini" : + pathof {cache|mirror|mirrordir|cache/mirrordir|setup.ini} : to show path - key-add FILES ... : to add keys contained in FILES - key-del KEYIDS ... : to remove keys KEYIDS + key-add ... : to add keys contained in + key-del ... : to remove keys key-list : to list keys key-finger : to list fingerprints upgrade-self : to upgrade apt-cyg - depends PACKAGE_NAMES ... : + depends ... : to show forward dependency information for packages with depth. - rdepends PACKAGE_NAMES ... : + rdepends ... : to show reverse dependency information for packages with depth. completion-install : to install completion. completion-uninstall : to uninstall completion. mirrors-list : to show list of mirros. - benchmark-mirrors URLs ... : + benchmark-mirrors ... : to benchmark mirrors. - benchmark-parallel-mirrors URLs ... : + benchmark-parallel-mirrors ... : to benchmark mirrors in parallel. benchmark-parallel-mirrors-list : to benchmark mirrors-list in parallel. scriptinfo : to show script infomations. - show-packages-busyness PACKAGE_NAMES ... : + show-packages-busyness ... : to show packages are busy or not. dist-upgrade : to upgrade all packages that is installed. This subcommand uses setup.exe update-setup : to update setup.exe - setup [PARAMS ...] : to call setup.exe + setup [ ...] : to call setup.exe packages-total-count : count number of total packages from setup.ini - packages-total-size [PATTERN_OF_SECTION] : + packages-total-size [] : count size of total packages from setup.ini packages-cached-count : count number of cached packages in cache/mirrordir. packages-cached-size : count size of cached packages in cache/mirrordir. repair-acl : repair acl. - source PACKAGE_NAMES ... : - download source archive. - download PACKAGE_NAMES ... : + source ... : + download source archive. + download ... : download the binary package into the current directory. - mirror PACKAGE_NAMES ... : + mirror ... : download the binary package into the current cache/mirrordir as mirror. - listfiles PACKAGE_NAMES ... : + listfiles ... : List files 'owned' by package(s). get-proxy : Get proxies for eval. ls-categories : List categories. Options: --ag : use the silver searcher (currently work only at packageof subcommand) - --charch ARCH : change archetecture + --charch : change archetecture --use-setuprc : set cache and mirror with /etc/setup/setup.rc --use-own-conf : use own cache and mirror settings when apt-cyg calls setup.exe @@ -146,16 +146,16 @@ function usage() --no-check-certificate : Don't validate the server's certificate --no-update-setup : Don't update setup.exe --no-header : Don't print header - --proxy, -p "auto"|"inherit"|"none"|URL : + --proxy, -p {auto|inherit|none|} : set proxy (default: \${APT_CYG_PROXY:-auto}) --completion-get-subcommand : get subcommand (for completion internal use) --completion-disable-autoupdate : disable completion autoupdate - --max-jobs, -j N : Run N jobs in parallel - --mirror, -m URL : set mirror - --cache, -c DIR : set cache - --file, -f FILE : read package names from file + --max-jobs, -j : Run jobs in parallel + --mirror, -m : set mirror + --cache, -c : set cache + --file, -f : read package names from --noupdate, -u : don't update setup.ini from mirror --ipv4, -4 : wget prefer ipv4 --no-progress : hide the progress bar in any verbosity mode From d5f71c0fe3b81d21bcf3d95a61ec43ed27ae87eb Mon Sep 17 00:00:00 2001 From: "E:V:A" Date: Thu, 22 Nov 2018 07:20:59 +0000 Subject: [PATCH 178/309] Create known_problems.md Moved known problems from readme to its own file --- known_problems.md | 91 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 known_problems.md diff --git a/known_problems.md b/known_problems.md new file mode 100644 index 0000000..4c3a02e --- /dev/null +++ b/known_problems.md @@ -0,0 +1,91 @@ + +### Known Problems + +--- + +### 2016-02-12: Problems about the ACL + +In recent version, the cygwin changed the ACL mechanism . +So, in the cygwin current version, if it will be installed by `setup.exe` with `-B` or `--no-admin` option, +the cygwin root (/) does not have correct ACL. + +A new subcommand `repair-acl` tries to repair it. +But some package, that are failed to install by the ACL problem, need to be reinstalled. + + + +### 2015-04-09: gpgv seems not work correctly on 32 bit environment + +To solve this problem, the backend of `verify_signatures` function was changed from `gpgv` to `gpg`. +thienhv reported this problem [#14](https://github.com/kou1okada/apt-cyg/issues/14). Thanks. + +### 2014-01-17: ca-certificates package is not setup correct at x86_64 with Windows 8. + +After clean installing with `setup-x86_64.exe`, there are something wrong about ca-certificate package as below: + + $ ls -lnG \ + /cygdrive/c/cygwin/etc/pki/ca-trust/extracted/openssl/ca-bundle.trust.crt \ + /cygdrive/c/cygwin64/etc/pki/ca-trust/extracted/openssl/ca-bundle.trust.crt + -r--r--r-- 1 1001 314336 Jan 17 18:17 /cygdrive/c/cygwin/etc/pki/ca-trust/extracted/openssl/ca-bundle.trust.crt + -rw-r--r-- 1 1001 0 Oct 16 12:35 /cygdrive/c/cygwin64/etc/pki/ca-trust/extracted/openssl/ca-bundle.trust.crt + $ ls -lnG \ + /cygdrive/c/cygwin/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem \ + /cygdrive/c/cygwin64/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem + -r--r--r-- 1 1001 232342 Jan 17 18:17 /cygdrive/c/cygwin/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem + -rw-r--r-- 1 1001 0 Oct 16 12:35 /cygdrive/c/cygwin64/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem + +The x86 environment seems no problem except that need an additional setting for wget and ca-certificate. Hmm,,, + +It seems that `/usr/bin/update-ca-trust` is failed at x86_64. + +It's ad hoc, but effective way to fix it, is to copy files from cygwin32 to cygwin64, as below: + + cp -a /cygdrive/c/cygwin/etc/pki/ca-trust/extracted/openssl/ca-bundle.trust.crt \ + /cygdrive/c/cygwin64/etc/pki/ca-trust/extracted/openssl/ca-bundle.trust.crt + cp -a /cygdrive/c/cygwin/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem \ + /cygdrive/c/cygwin64/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem + +This problem is fixed at 2014-01-24. +version 0.18.7-1 of p11-kit, p11-kit-trust and libp11-kit0 did not work at the cygwin64 under the Windows 8. +If you face the above problem, please upgrade these three packages from version 0.18.7-1 to version 0.18.7-2. + +For more details, see a thread of below: + +* Cygwin mailing list / cygwin / [Re: Is there someone who have a same problem ?](http://cygwin.com/ml/cygwin/2014-01/msg00368.html) + +### 2014-01-15: Signature check failed at cygwinports x86_64. + +Oops, setup.bz2 is newer than setup.bz2.sig. +And it seems to be corrupted. + + $ date + Wed Jan 15 01:30:19 JST 2014 + $ w3m -dump ftp://ftp.cygwinports.org/pub/cygwinports/x86_64/ + Index of ftp://ftp.cygwinports.org/pub/cygwinports/x86_64/ + + [Upper Directory] + md5.sum. . . . . . . Jan 10 14:24 184 + release/ . . . . . . Jan 10 18:00 + setup.bz2. . . . . . Jan 10 13:59 579K + setup.bz2.sig. . . . Dec 6 11:28 72 + setup.ini. . . . . . Dec 6 11:28 3.20M + setup.ini.sig. . . . Dec 6 11:28 72 + + $ wget -q -O - ftp://ftp.cygwinports.org/pub/cygwinports/x86_64/setup.bz2 | bzip2 -tvv + (stdin): + [1: huff+mtf rt+rld] + [2: huff+mtf data integrity (CRC) error in data + + You can use the `bzip2recover' program to attempt to recover + data from undamaged sections of corrupted files. + +As of 2014-01-24, above problem is recovered at least. + +### FIXED: Check setup (`cygcheck -c`) can not detect .tar.xz packages + +At cygwin 1.7.25, cygcheck is hardcoded for .tar.gz and .tar.bz2. +So check setup (`cygcheck -c`) can not detect .tar.xz packages. +This bug was already fixed with [src/winsup/utils/dump_setup.cc#rev1.28](http://cygwin.com/cgi-bin/cvsweb.cgi/src/winsup/utils/dump_setup.cc?cvsroot=src#rev1.28). +Please wait a release of cygwin 1.7.26. + +This Problem was fixed [cygwin 1.7.26](http://cygwin.com/ml/cygwin-announce/2013-11/msg00027.html) which released at 2013-11-29. From 23467bc5ee0bd1188d2c5337e5ad45545a0782c8 Mon Sep 17 00:00:00 2001 From: "E:V:A" Date: Thu, 22 Nov 2018 07:26:52 +0000 Subject: [PATCH 179/309] Update README.md Moved known problems and "fork list" to own file --- README.md | 135 +++--------------------------------------------------- 1 file changed, 6 insertions(+), 129 deletions(-) diff --git a/README.md b/README.md index 77d3556..992264e 100644 --- a/README.md +++ b/README.md @@ -209,136 +209,13 @@ The [Google Code project](https://code.google.com/p/apt-cyg/) has a list of open ### Forks on the github -Caution: -Please do not merge forks that have incompatible licenses. -Ex.) Merging to the GPL from the MIT is possible. But merging to the MIT from the GPL is impossible. +#### Todo -#### Official (MIT license) +- [ ] Support multi mirrors: Cygwin setup can use multi mirrors. They are recorded at last-mirror section in '/etc/setup/setup.rc'. It's useful for using [Cygwinports](http://cygwinports.org/). +- [ ] Support upgrade: But maybe, busy resources can not be upgraded, and rebase problem will happen. Cygwin setup resolves by replacing them at next reboot. +- [ ] Support dependency check for remove subcommand. -* [transcodes-open / apt-cyg](https://github.com/transcode-open/apt-cyg/network) - * [tmshn / cyg-fast](https://github.com/tmshn/cyg-fast/network) - * [pi0 / cyg](https://github.com/pi0/cyg) (GPLv3) +#### Known Problems -#### Unofficial (MIT license) - -* [digitallamb / apt-cyg](https://github.com/digitallamb/apt-cyg/network) -* [balanx / apt-cyg](https://github.com/balanx/apt-cyg/network) -* [langlichuan123 / apt-cyg](https://github.com/langlichuan123/apt-cyg/network) - -#### Unofficial (GPLv2) - -* [cfg / apt-cyg](https://github.com/cfg/apt-cyg/network) - * [Milly / apt-cyg](https://github.com/Milly/apt-cyg/network) -* [ashumkin / apt-cyg](https://github.com/ashumkin/apt-cyg/network) -* [svn2github / apt-cyg](https://github.com/svn2github/apt-cyg/network) -* [nosuchuser / apt-cyg](https://github.com/nosuchuser/apt-cyg/network) -* [kazuhisya / apt-cyg64](https://github.com/kazuhisya/apt-cyg64/network) -* [bnormsoftware / apt-cyg](https://github.com/bnormsoftware/apt-cyg/network) -* [rcmdnk / apt-cyg](https://github.com/rcmdnk/apt-cyg/network) -* [buzain / apt-cyg](https://github.com/buzain/apt-cyg/network) -* [wuyangnju / apt-cyg](https://github.com/wuyangnju/apt-cyg/network) -* [takuya / apt-cyg](https://github.com/takuya/apt-cyg/network) - -### Derivations of non-fork on the github - -* [10sr / pac-cyg](https://github.com/10sr/pac-cyg/network) -* [nobuyo / medy](https://github.com/nobuyo/medy/network) -* [svnpenn / sage](https://github.com/svnpenn/sage/network) - -Todo ------------- - -* Support multi mirrors: Cygwin setup can use multi mirrors. They are recorded at last-mirror section in '/etc/setup/setup.rc'. It's useful for using [Cygwinports](http://cygwinports.org/). -* Support upgrade: But maybe, busy resources can not be upgraded, and rebase problem will happen. Cygwin setup resolves by replacing them at next reboot. -* Support dependency check for remove subcommand. - -Known Problem ------------- - -### 2016-02-12: Problems about the ACL - -In recent version, the cygwin changed the ACL mechanism . -So, in the cygwin current version, if it will be installed by `setup.exe` with `-B` or `--no-admin` option, -the cygwin root (/) does not have correct ACL. - -A new subcommand `repair-acl` tries to repair it. -But some package, that are failed to install by the ACL problem, need to be reinstalled. - - - -### 2015-04-09: gpgv seems not work correctly on 32 bit environment - -To solve this problem, the backend of `verify_signatures` function was changed from `gpgv` to `gpg`. -thienhv reported this problem [#14](https://github.com/kou1okada/apt-cyg/issues/14). Thanks. - -### 2014-01-17: ca-certificates package is not setup correct at x86_64 with Windows 8. - -After clean installing with `setup-x86_64.exe`, there are something wrong about ca-certificate package as below: - - $ ls -lnG \ - /cygdrive/c/cygwin/etc/pki/ca-trust/extracted/openssl/ca-bundle.trust.crt \ - /cygdrive/c/cygwin64/etc/pki/ca-trust/extracted/openssl/ca-bundle.trust.crt - -r--r--r-- 1 1001 314336 Jan 17 18:17 /cygdrive/c/cygwin/etc/pki/ca-trust/extracted/openssl/ca-bundle.trust.crt - -rw-r--r-- 1 1001 0 Oct 16 12:35 /cygdrive/c/cygwin64/etc/pki/ca-trust/extracted/openssl/ca-bundle.trust.crt - $ ls -lnG \ - /cygdrive/c/cygwin/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem \ - /cygdrive/c/cygwin64/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem - -r--r--r-- 1 1001 232342 Jan 17 18:17 /cygdrive/c/cygwin/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem - -rw-r--r-- 1 1001 0 Oct 16 12:35 /cygdrive/c/cygwin64/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem - -The x86 environment seems no problem except that need an additional setting for wget and ca-certificate. Hmm,,, - -It seems that `/usr/bin/update-ca-trust` is failed at x86_64. - -It's ad hoc, but effective way to fix it, is to copy files from cygwin32 to cygwin64, as below: - - cp -a /cygdrive/c/cygwin/etc/pki/ca-trust/extracted/openssl/ca-bundle.trust.crt \ - /cygdrive/c/cygwin64/etc/pki/ca-trust/extracted/openssl/ca-bundle.trust.crt - cp -a /cygdrive/c/cygwin/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem \ - /cygdrive/c/cygwin64/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem - -This problem is fixed at 2014-01-24. -version 0.18.7-1 of p11-kit, p11-kit-trust and libp11-kit0 did not work at the cygwin64 under the Windows 8. -If you face the above problem, please upgrade these three packages from version 0.18.7-1 to version 0.18.7-2. - -For more details, see a thread of below: - -* Cygwin mailing list / cygwin / [Re: Is there someone who have a same problem ?](http://cygwin.com/ml/cygwin/2014-01/msg00368.html) - -### 2014-01-15: Signature check failed at cygwinports x86_64. - -Oops, setup.bz2 is newer than setup.bz2.sig. -And it seems to be corrupted. - - $ date - Wed Jan 15 01:30:19 JST 2014 - $ w3m -dump ftp://ftp.cygwinports.org/pub/cygwinports/x86_64/ - Index of ftp://ftp.cygwinports.org/pub/cygwinports/x86_64/ - - [Upper Directory] - md5.sum. . . . . . . Jan 10 14:24 184 - release/ . . . . . . Jan 10 18:00 - setup.bz2. . . . . . Jan 10 13:59 579K - setup.bz2.sig. . . . Dec 6 11:28 72 - setup.ini. . . . . . Dec 6 11:28 3.20M - setup.ini.sig. . . . Dec 6 11:28 72 - - $ wget -q -O - ftp://ftp.cygwinports.org/pub/cygwinports/x86_64/setup.bz2 | bzip2 -tvv - (stdin): - [1: huff+mtf rt+rld] - [2: huff+mtf data integrity (CRC) error in data - - You can use the `bzip2recover' program to attempt to recover - data from undamaged sections of corrupted files. - -As of 2014-01-24, above problem is recovered at least. - -### FIXED: Check setup (`cygcheck -c`) can not detect .tar.xz packages - -At cygwin 1.7.25, cygcheck is hardcoded for .tar.gz and .tar.bz2. -So check setup (`cygcheck -c`) can not detect .tar.xz packages. -This bug was already fixed with [src/winsup/utils/dump_setup.cc#rev1.28](http://cygwin.com/cgi-bin/cvsweb.cgi/src/winsup/utils/dump_setup.cc?cvsroot=src#rev1.28). -Please wait a release of cygwin 1.7.26. - -This Problem was fixed [cygwin 1.7.26](http://cygwin.com/ml/cygwin-announce/2013-11/msg00027.html) which released at 2013-11-29. +For older known problems see: [**`known problems`**](known_problems.md) From 874857fd39f7cd86a137732bdba6cc41a3513a90 Mon Sep 17 00:00:00 2001 From: "E:V:A" Date: Thu, 22 Nov 2018 07:28:40 +0000 Subject: [PATCH 180/309] Create other_forks.md --- other_forks.md | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 other_forks.md diff --git a/other_forks.md b/other_forks.md new file mode 100644 index 0000000..e690b09 --- /dev/null +++ b/other_forks.md @@ -0,0 +1,39 @@ + +### Other Known *apt-cyg* Forks + +Caution: +Please do not merge forks that have incompatible licenses. + +Ex.) Merging to the GPL from the MIT is possible. But merging to the MIT from the GPL is impossible. + +#### Official (MIT license) + +* [transcodes-open / apt-cyg](https://github.com/transcode-open/apt-cyg/network) + * [tmshn / cyg-fast](https://github.com/tmshn/cyg-fast/network) + * [pi0 / cyg](https://github.com/pi0/cyg) (GPLv3) + +#### Unofficial (MIT license) + +* [digitallamb / apt-cyg](https://github.com/digitallamb/apt-cyg/network) +* [balanx / apt-cyg](https://github.com/balanx/apt-cyg/network) +* [langlichuan123 / apt-cyg](https://github.com/langlichuan123/apt-cyg/network) + +#### Unofficial (GPLv2) + +* [cfg / apt-cyg](https://github.com/cfg/apt-cyg/network) + * [Milly / apt-cyg](https://github.com/Milly/apt-cyg/network) +* [ashumkin / apt-cyg](https://github.com/ashumkin/apt-cyg/network) +* [svn2github / apt-cyg](https://github.com/svn2github/apt-cyg/network) +* [nosuchuser / apt-cyg](https://github.com/nosuchuser/apt-cyg/network) +* [kazuhisya / apt-cyg64](https://github.com/kazuhisya/apt-cyg64/network) +* [bnormsoftware / apt-cyg](https://github.com/bnormsoftware/apt-cyg/network) +* [rcmdnk / apt-cyg](https://github.com/rcmdnk/apt-cyg/network) +* [buzain / apt-cyg](https://github.com/buzain/apt-cyg/network) +* [wuyangnju / apt-cyg](https://github.com/wuyangnju/apt-cyg/network) +* [takuya / apt-cyg](https://github.com/takuya/apt-cyg/network) + +### Derivations of non-fork on the github + +* [10sr / pac-cyg](https://github.com/10sr/pac-cyg/network) +* [nobuyo / medy](https://github.com/nobuyo/medy/network) +* [svnpenn / sage](https://github.com/svnpenn/sage/network) From 108a9929d607725d0a40ad3e8472ea0a39c21e20 Mon Sep 17 00:00:00 2001 From: "E:V:A" Date: Thu, 22 Nov 2018 07:30:49 +0000 Subject: [PATCH 181/309] Update README.md --- README.md | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 992264e..b115d5d 100644 --- a/README.md +++ b/README.md @@ -200,15 +200,19 @@ If you don't want to update it automatically, execute `completion-install` subco Some other forks, [Milly / apt-cyg](https://github.com/Milly/apt-cyg) under the cfg / apt-cyg fork, [ashumkin / apt-cyg](https://github.com/ashumkin/apt-cyg) and etc, are also supported it. -Contributing ------------- -This project has been re-published on GitHub to make contributing easier. Feel free to fork and modify this script. +--- + +### Contributing + +This project has been re-published on GitHub to make contributing easier. +Feel free to fork and modify this script. The [Google Code project](https://code.google.com/p/apt-cyg/) has a list of open issues. -### Forks on the github +#### Forks on the github +See [known_forks.md](known_forks.md) #### Todo From 5bf97359e915d9a45f10cd76a8454f6f52f74190 Mon Sep 17 00:00:00 2001 From: "E:V:A" Date: Thu, 22 Nov 2018 07:56:27 +0000 Subject: [PATCH 182/309] Update README.md * Added maintenance badges and maintenance table * Added Credits * Added License badge --- README.md | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/README.md b/README.md index b115d5d..eccf786 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,20 @@ +[![GitHub last commit](https://img.shields.io/github/last-commit/kou1okada/apt-cyg.svg)](https://github.com/kou1okada/apt-cyg) +[![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green.svg)](https://GitHub.com/kou1okada/apt-cyg/graphs/commit-activity) +[![Average time to resolve an issue](http://isitmaintained.com/badge/resolution/kou1okada/apt-cyg.svg)](http://isitmaintained.com//project/kou1okada/apt-cyg "Average time to resolve an issue") + + +`**apt-cyg**` is your friendly [Cygwin](http://cygwin.com/) package manager. The syntax is similar to *apt-get* and is a feature improved wrapper to the native Cygwin `setup.exe`. + + +| STATUS: | Version | Date | Maintained? | +|:------- |:------- |:---- |:----------- | +| Working | `1.0.58` | 2018-11-22 | YES | + +--- + + + + apt-cyg ======= @@ -223,3 +240,18 @@ See [known_forks.md](known_forks.md) #### Known Problems For older known problems see: [**`known problems`**](known_problems.md) + +--- + +#### Credits + +Most grateful thanks to: +* [---](https://github.com/---/) - for clarifying and fixing XXXX + +--- + +#### License + +[![GitHub license](https://img.shields.io/github/license/kou1okada/apt-cyg.svg)](https://github.com/kou1okada/apt-cyg/blob/master/LICENSE) +A license to :sparkling_heart:! + From 206b33e8dfb2f3db4e9a3de33e88d667903e313d Mon Sep 17 00:00:00 2001 From: "E:V:A" Date: Thu, 22 Nov 2018 07:57:26 +0000 Subject: [PATCH 183/309] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index eccf786..9b91404 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ [![Average time to resolve an issue](http://isitmaintained.com/badge/resolution/kou1okada/apt-cyg.svg)](http://isitmaintained.com//project/kou1okada/apt-cyg "Average time to resolve an issue") -`**apt-cyg**` is your friendly [Cygwin](http://cygwin.com/) package manager. The syntax is similar to *apt-get* and is a feature improved wrapper to the native Cygwin `setup.exe`. +**`apt-cyg`** is your friendly [Cygwin](http://cygwin.com/) package manager. The syntax is similar to *apt-get* and is a feature improved wrapper to the native Cygwin `setup.exe`. | STATUS: | Version | Date | Maintained? | From 9ca3de878f9e037d792e668e80c3062b4edec54a Mon Sep 17 00:00:00 2001 From: "E:V:A" Date: Thu, 22 Nov 2018 07:58:15 +0000 Subject: [PATCH 184/309] Update README.md --- README.md | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 9b91404..b247098 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,6 @@ +apt-cyg +======= + [![GitHub last commit](https://img.shields.io/github/last-commit/kou1okada/apt-cyg.svg)](https://github.com/kou1okada/apt-cyg) [![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green.svg)](https://GitHub.com/kou1okada/apt-cyg/graphs/commit-activity) [![Average time to resolve an issue](http://isitmaintained.com/badge/resolution/kou1okada/apt-cyg.svg)](http://isitmaintained.com//project/kou1okada/apt-cyg "Average time to resolve an issue") @@ -13,13 +16,6 @@ --- - - -apt-cyg -======= - -apt-cyg is a command-line installer for [Cygwin](http://cygwin.com/) which cooperates with Cygwin Setup and uses the same repository. The syntax is similar to apt-get. - Usage ----- From 85cf5c8c4d984bf1e7f6c5b46afc82dba1d8d656 Mon Sep 17 00:00:00 2001 From: "E:V:A" Date: Thu, 22 Nov 2018 08:00:21 +0000 Subject: [PATCH 185/309] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b247098..e672ee4 100644 --- a/README.md +++ b/README.md @@ -225,7 +225,7 @@ The [Google Code project](https://code.google.com/p/apt-cyg/) has a list of open #### Forks on the github -See [known_forks.md](known_forks.md) +See [other_forks.md](other_forks.md) #### Todo From 62572739d64c74a1f0b86b34fa9fa8b052cce855 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Sun, 25 Nov 2018 18:56:16 +0900 Subject: [PATCH 186/309] Update `README.md`. * Create `known_problems.md`. * Moved known problems from readme to its own file. This commit based on d5f71c0fe3b81d21bcf3d95a61ec43ed27ae87eb and part of 23467bc5ee0bd1188d2c5337e5ad45545a0782c8. --- README.md | 89 +------------------------------------------- known_problems.md | 95 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 97 insertions(+), 87 deletions(-) create mode 100644 known_problems.md diff --git a/README.md b/README.md index 77d3556..dc2adca 100644 --- a/README.md +++ b/README.md @@ -253,92 +253,7 @@ Todo * Support upgrade: But maybe, busy resources can not be upgraded, and rebase problem will happen. Cygwin setup resolves by replacing them at next reboot. * Support dependency check for remove subcommand. -Known Problem +Known Problems ------------ -### 2016-02-12: Problems about the ACL - -In recent version, the cygwin changed the ACL mechanism . -So, in the cygwin current version, if it will be installed by `setup.exe` with `-B` or `--no-admin` option, -the cygwin root (/) does not have correct ACL. - -A new subcommand `repair-acl` tries to repair it. -But some package, that are failed to install by the ACL problem, need to be reinstalled. - - - -### 2015-04-09: gpgv seems not work correctly on 32 bit environment - -To solve this problem, the backend of `verify_signatures` function was changed from `gpgv` to `gpg`. -thienhv reported this problem [#14](https://github.com/kou1okada/apt-cyg/issues/14). Thanks. - -### 2014-01-17: ca-certificates package is not setup correct at x86_64 with Windows 8. - -After clean installing with `setup-x86_64.exe`, there are something wrong about ca-certificate package as below: - - $ ls -lnG \ - /cygdrive/c/cygwin/etc/pki/ca-trust/extracted/openssl/ca-bundle.trust.crt \ - /cygdrive/c/cygwin64/etc/pki/ca-trust/extracted/openssl/ca-bundle.trust.crt - -r--r--r-- 1 1001 314336 Jan 17 18:17 /cygdrive/c/cygwin/etc/pki/ca-trust/extracted/openssl/ca-bundle.trust.crt - -rw-r--r-- 1 1001 0 Oct 16 12:35 /cygdrive/c/cygwin64/etc/pki/ca-trust/extracted/openssl/ca-bundle.trust.crt - $ ls -lnG \ - /cygdrive/c/cygwin/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem \ - /cygdrive/c/cygwin64/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem - -r--r--r-- 1 1001 232342 Jan 17 18:17 /cygdrive/c/cygwin/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem - -rw-r--r-- 1 1001 0 Oct 16 12:35 /cygdrive/c/cygwin64/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem - -The x86 environment seems no problem except that need an additional setting for wget and ca-certificate. Hmm,,, - -It seems that `/usr/bin/update-ca-trust` is failed at x86_64. - -It's ad hoc, but effective way to fix it, is to copy files from cygwin32 to cygwin64, as below: - - cp -a /cygdrive/c/cygwin/etc/pki/ca-trust/extracted/openssl/ca-bundle.trust.crt \ - /cygdrive/c/cygwin64/etc/pki/ca-trust/extracted/openssl/ca-bundle.trust.crt - cp -a /cygdrive/c/cygwin/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem \ - /cygdrive/c/cygwin64/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem - -This problem is fixed at 2014-01-24. -version 0.18.7-1 of p11-kit, p11-kit-trust and libp11-kit0 did not work at the cygwin64 under the Windows 8. -If you face the above problem, please upgrade these three packages from version 0.18.7-1 to version 0.18.7-2. - -For more details, see a thread of below: - -* Cygwin mailing list / cygwin / [Re: Is there someone who have a same problem ?](http://cygwin.com/ml/cygwin/2014-01/msg00368.html) - -### 2014-01-15: Signature check failed at cygwinports x86_64. - -Oops, setup.bz2 is newer than setup.bz2.sig. -And it seems to be corrupted. - - $ date - Wed Jan 15 01:30:19 JST 2014 - $ w3m -dump ftp://ftp.cygwinports.org/pub/cygwinports/x86_64/ - Index of ftp://ftp.cygwinports.org/pub/cygwinports/x86_64/ - - [Upper Directory] - md5.sum. . . . . . . Jan 10 14:24 184 - release/ . . . . . . Jan 10 18:00 - setup.bz2. . . . . . Jan 10 13:59 579K - setup.bz2.sig. . . . Dec 6 11:28 72 - setup.ini. . . . . . Dec 6 11:28 3.20M - setup.ini.sig. . . . Dec 6 11:28 72 - - $ wget -q -O - ftp://ftp.cygwinports.org/pub/cygwinports/x86_64/setup.bz2 | bzip2 -tvv - (stdin): - [1: huff+mtf rt+rld] - [2: huff+mtf data integrity (CRC) error in data - - You can use the `bzip2recover' program to attempt to recover - data from undamaged sections of corrupted files. - -As of 2014-01-24, above problem is recovered at least. - -### FIXED: Check setup (`cygcheck -c`) can not detect .tar.xz packages - -At cygwin 1.7.25, cygcheck is hardcoded for .tar.gz and .tar.bz2. -So check setup (`cygcheck -c`) can not detect .tar.xz packages. -This bug was already fixed with [src/winsup/utils/dump_setup.cc#rev1.28](http://cygwin.com/cgi-bin/cvsweb.cgi/src/winsup/utils/dump_setup.cc?cvsroot=src#rev1.28). -Please wait a release of cygwin 1.7.26. - -This Problem was fixed [cygwin 1.7.26](http://cygwin.com/ml/cygwin-announce/2013-11/msg00027.html) which released at 2013-11-29. +For older known problems see [known_problems.md](known_problems.md). diff --git a/known_problems.md b/known_problems.md new file mode 100644 index 0000000..068d79a --- /dev/null +++ b/known_problems.md @@ -0,0 +1,95 @@ +Known Problems +-------------- + +### 2016-02-12: Problems about the ACL + +In recent version, the cygwin changed the ACL mechanism . +So, in the cygwin current version, if it will be installed by `setup.exe` with `-B` or `--no-admin` option, +the cygwin root (/) does not have correct ACL. + +A new subcommand `repair-acl` tries to repair it. +But some package, that are failed to install by the ACL problem, need to be reinstalled. + + + +### 2015-04-09: gpgv seems not work correctly on 32 bit environment + +To solve this problem, the backend of `verify_signatures` function was changed from `gpgv` to `gpg`. +thienhv reported this problem [#14](https://github.com/kou1okada/apt-cyg/issues/14). Thanks. + + + +### 2014-01-17: ca-certificates package is not setup correct at x86_64 with Windows 8. + +After clean installing with `setup-x86_64.exe`, there are something wrong about ca-certificate package as below: + + $ ls -lnG \ + /cygdrive/c/cygwin/etc/pki/ca-trust/extracted/openssl/ca-bundle.trust.crt \ + /cygdrive/c/cygwin64/etc/pki/ca-trust/extracted/openssl/ca-bundle.trust.crt + -r--r--r-- 1 1001 314336 Jan 17 18:17 /cygdrive/c/cygwin/etc/pki/ca-trust/extracted/openssl/ca-bundle.trust.crt + -rw-r--r-- 1 1001 0 Oct 16 12:35 /cygdrive/c/cygwin64/etc/pki/ca-trust/extracted/openssl/ca-bundle.trust.crt + $ ls -lnG \ + /cygdrive/c/cygwin/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem \ + /cygdrive/c/cygwin64/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem + -r--r--r-- 1 1001 232342 Jan 17 18:17 /cygdrive/c/cygwin/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem + -rw-r--r-- 1 1001 0 Oct 16 12:35 /cygdrive/c/cygwin64/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem + +The x86 environment seems no problem except that need an additional setting for wget and ca-certificate. Hmm,,, + +It seems that `/usr/bin/update-ca-trust` is failed at x86_64. + +It's ad hoc, but effective way to fix it, is to copy files from cygwin32 to cygwin64, as below: + + cp -a /cygdrive/c/cygwin/etc/pki/ca-trust/extracted/openssl/ca-bundle.trust.crt \ + /cygdrive/c/cygwin64/etc/pki/ca-trust/extracted/openssl/ca-bundle.trust.crt + cp -a /cygdrive/c/cygwin/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem \ + /cygdrive/c/cygwin64/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem + +This problem is fixed at 2014-01-24. +version 0.18.7-1 of p11-kit, p11-kit-trust and libp11-kit0 did not work at the cygwin64 under the Windows 8. +If you face the above problem, please upgrade these three packages from version 0.18.7-1 to version 0.18.7-2. + +For more details, see a thread of below: + +* Cygwin mailing list / cygwin / [Re: Is there someone who have a same problem ?](http://cygwin.com/ml/cygwin/2014-01/msg00368.html) + + + +### 2014-01-15: Signature check failed at cygwinports x86_64. + +Oops, setup.bz2 is newer than setup.bz2.sig. +And it seems to be corrupted. + + $ date + Wed Jan 15 01:30:19 JST 2014 + $ w3m -dump ftp://ftp.cygwinports.org/pub/cygwinports/x86_64/ + Index of ftp://ftp.cygwinports.org/pub/cygwinports/x86_64/ + + [Upper Directory] + md5.sum. . . . . . . Jan 10 14:24 184 + release/ . . . . . . Jan 10 18:00 + setup.bz2. . . . . . Jan 10 13:59 579K + setup.bz2.sig. . . . Dec 6 11:28 72 + setup.ini. . . . . . Dec 6 11:28 3.20M + setup.ini.sig. . . . Dec 6 11:28 72 + + $ wget -q -O - ftp://ftp.cygwinports.org/pub/cygwinports/x86_64/setup.bz2 | bzip2 -tvv + (stdin): + [1: huff+mtf rt+rld] + [2: huff+mtf data integrity (CRC) error in data + + You can use the `bzip2recover' program to attempt to recover + data from undamaged sections of corrupted files. + +As of 2014-01-24, above problem is recovered at least. + + + +### FIXED: Check setup (`cygcheck -c`) can not detect .tar.xz packages + +At cygwin 1.7.25, cygcheck is hardcoded for .tar.gz and .tar.bz2. +So check setup (`cygcheck -c`) can not detect .tar.xz packages. +This bug was already fixed with [src/winsup/utils/dump_setup.cc#rev1.28](http://cygwin.com/cgi-bin/cvsweb.cgi/src/winsup/utils/dump_setup.cc?cvsroot=src#rev1.28). +Please wait a release of cygwin 1.7.26. + +This Problem was fixed [cygwin 1.7.26](http://cygwin.com/ml/cygwin-announce/2013-11/msg00027.html) which released at 2013-11-29. From 6141156ba383431d289a0edd7a3d017477056b93 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Mon, 26 Nov 2018 01:51:34 +0900 Subject: [PATCH 187/309] Update `README.md`. * Create `other_forks.md`. * Moved "fork list" to own file. This commit is based on part of 23467bc5ee0bd1188d2c5337e5ad45545a0782c8 and 874857fd39f7cd86a137732bdba6cc41a3513a90 and 108a9929d607725d0a40ad3e8472ea0a39c21e20 and 85cf5c8c4d984bf1e7f6c5b46afc82dba1d8d656. --- README.md | 32 +------------------------------- other_forks.md | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 31 deletions(-) create mode 100644 other_forks.md diff --git a/README.md b/README.md index dc2adca..22ebb44 100644 --- a/README.md +++ b/README.md @@ -214,37 +214,7 @@ Please do not merge forks that have incompatible licenses. Ex.) Merging to the GPL from the MIT is possible. But merging to the MIT from the GPL is impossible. -#### Official (MIT license) - -* [transcodes-open / apt-cyg](https://github.com/transcode-open/apt-cyg/network) - * [tmshn / cyg-fast](https://github.com/tmshn/cyg-fast/network) - * [pi0 / cyg](https://github.com/pi0/cyg) (GPLv3) - -#### Unofficial (MIT license) - -* [digitallamb / apt-cyg](https://github.com/digitallamb/apt-cyg/network) -* [balanx / apt-cyg](https://github.com/balanx/apt-cyg/network) -* [langlichuan123 / apt-cyg](https://github.com/langlichuan123/apt-cyg/network) - -#### Unofficial (GPLv2) - -* [cfg / apt-cyg](https://github.com/cfg/apt-cyg/network) - * [Milly / apt-cyg](https://github.com/Milly/apt-cyg/network) -* [ashumkin / apt-cyg](https://github.com/ashumkin/apt-cyg/network) -* [svn2github / apt-cyg](https://github.com/svn2github/apt-cyg/network) -* [nosuchuser / apt-cyg](https://github.com/nosuchuser/apt-cyg/network) -* [kazuhisya / apt-cyg64](https://github.com/kazuhisya/apt-cyg64/network) -* [bnormsoftware / apt-cyg](https://github.com/bnormsoftware/apt-cyg/network) -* [rcmdnk / apt-cyg](https://github.com/rcmdnk/apt-cyg/network) -* [buzain / apt-cyg](https://github.com/buzain/apt-cyg/network) -* [wuyangnju / apt-cyg](https://github.com/wuyangnju/apt-cyg/network) -* [takuya / apt-cyg](https://github.com/takuya/apt-cyg/network) - -### Derivations of non-fork on the github - -* [10sr / pac-cyg](https://github.com/10sr/pac-cyg/network) -* [nobuyo / medy](https://github.com/nobuyo/medy/network) -* [svnpenn / sage](https://github.com/svnpenn/sage/network) +See [other_forks.md](other_forks.md) Todo ------------ diff --git a/other_forks.md b/other_forks.md new file mode 100644 index 0000000..2a7f59b --- /dev/null +++ b/other_forks.md @@ -0,0 +1,39 @@ +Other Known *`apt-cyg`* Forks on the GitHub +------------------------------------------- + +Caution: +Please do not merge forks that have incompatible licenses. + +Ex.) Merging to the GPL from the MIT is possible. But merging to the MIT from the GPL is impossible. + +### Official (MIT license) + +* [transcodes-open / apt-cyg](https://github.com/transcode-open/apt-cyg/network) + * [tmshn / cyg-fast](https://github.com/tmshn/cyg-fast/network) + * [pi0 / cyg](https://github.com/pi0/cyg) (GPLv3) + +### Unofficial (MIT license) + +* [digitallamb / apt-cyg](https://github.com/digitallamb/apt-cyg/network) +* [balanx / apt-cyg](https://github.com/balanx/apt-cyg/network) +* [langlichuan123 / apt-cyg](https://github.com/langlichuan123/apt-cyg/network) + +### Unofficial (GPLv2) + +* [cfg / apt-cyg](https://github.com/cfg/apt-cyg/network) + * [Milly / apt-cyg](https://github.com/Milly/apt-cyg/network) +* [ashumkin / apt-cyg](https://github.com/ashumkin/apt-cyg/network) +* [svn2github / apt-cyg](https://github.com/svn2github/apt-cyg/network) +* [nosuchuser / apt-cyg](https://github.com/nosuchuser/apt-cyg/network) +* [kazuhisya / apt-cyg64](https://github.com/kazuhisya/apt-cyg64/network) +* [bnormsoftware / apt-cyg](https://github.com/bnormsoftware/apt-cyg/network) +* [rcmdnk / apt-cyg](https://github.com/rcmdnk/apt-cyg/network) +* [buzain / apt-cyg](https://github.com/buzain/apt-cyg/network) +* [wuyangnju / apt-cyg](https://github.com/wuyangnju/apt-cyg/network) +* [takuya / apt-cyg](https://github.com/takuya/apt-cyg/network) + +### Derivations of non-fork on the github + +* [10sr / pac-cyg](https://github.com/10sr/pac-cyg/network) +* [nobuyo / medy](https://github.com/nobuyo/medy/network) +* [svnpenn / sage](https://github.com/svnpenn/sage/network) From 1e4e99b743df906577413d12215e8e5b02f9fc7d Mon Sep 17 00:00:00 2001 From: kou1okada Date: Sun, 25 Nov 2018 19:24:13 +0900 Subject: [PATCH 188/309] Update `README.md`. * Rewrite the section of Todo with the syntax of `Task Lists`. This commit is based on part of 23467bc5ee0bd1188d2c5337e5ad45545a0782c8. --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 22ebb44..b1dc24d 100644 --- a/README.md +++ b/README.md @@ -219,9 +219,9 @@ See [other_forks.md](other_forks.md) Todo ------------ -* Support multi mirrors: Cygwin setup can use multi mirrors. They are recorded at last-mirror section in '/etc/setup/setup.rc'. It's useful for using [Cygwinports](http://cygwinports.org/). -* Support upgrade: But maybe, busy resources can not be upgraded, and rebase problem will happen. Cygwin setup resolves by replacing them at next reboot. -* Support dependency check for remove subcommand. +- [ ] Support multi mirrors: Cygwin setup can use multi mirrors. They are recorded at last-mirror section in '/etc/setup/setup.rc'. It's useful for using [Cygwinports](http://cygwinports.org/). +- [ ] Support upgrade: But maybe, busy resources can not be upgraded, and rebase problem will happen. Cygwin setup resolves by replacing them at next reboot. +- [ ] Support dependency check for remove subcommand. Known Problems ------------ From 1028169494b7fb2c4714197b788eafe9f9979b97 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Mon, 26 Nov 2018 02:40:18 +0900 Subject: [PATCH 189/309] Update `README.md`. * Added License badge. This commit is based on part of 5bf97359e915d9a45f10cd76a8454f6f52f74190. --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index b1dc24d..d0b8677 100644 --- a/README.md +++ b/README.md @@ -227,3 +227,8 @@ Known Problems ------------ For older known problems see [known_problems.md](known_problems.md). + +License +------- + +[![The MIT license](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE) From be081f2d5f6f25ab9e136bd766b4e20d6f6b6a6e Mon Sep 17 00:00:00 2001 From: kou1okada Date: Sat, 19 Jan 2019 02:23:33 +0900 Subject: [PATCH 190/309] Update document for considering issue #37. --- README.md | 6 +++--- apt-cyg | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 69f4b1a..c62fbed 100755 --- a/README.md +++ b/README.md @@ -10,9 +10,9 @@ Usage apt-cyg [] [ [ ...]] -### Sub commands +### Subcommands -| Sub command | Description | +| Subcommand | Description | |:------- |:----------- | | `install ` | to install packages | | `remove ` | to remove packages | @@ -35,7 +35,7 @@ Usage | `benchmark-mirrors ...` | to benchmark mirrors. | | `benchmark-parallel-mirrors ...` | to benchmark mirrors in parallel. | | `benchmark-parallel-mirrors-list` | to benchmark mirrors-list in parallel. | -| `scriptinfo` | to show script infomations. | +| `scriptinfo` | to show script information. | | `show-packages-busyness ...` | to show if packages are busy or not. | | `dist-upgrade` | to upgrade all packages that is installed. This subcommand uses **`setup-*.exe`** | | `update-setup` | to update setup.exe | diff --git a/apt-cyg b/apt-cyg index 1a2a208..63dbadc 100755 --- a/apt-cyg +++ b/apt-cyg @@ -71,7 +71,7 @@ function usage() cat<<-EOD Usage: apt-cyg [] [ [ ...]] Installs and removes Cygwin packages. - Sub Commands: + Subcommands: install : to install packages remove : to remove packages update : to update setup.ini @@ -102,7 +102,7 @@ function usage() to benchmark mirrors in parallel. benchmark-parallel-mirrors-list : to benchmark mirrors-list in parallel. - scriptinfo : to show script infomations. + scriptinfo : to show script information. show-packages-busyness ... : to show packages are busy or not. dist-upgrade : to upgrade all packages that is installed. From 4498ecacde09839c7df3b9546393a751c7057e12 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Fri, 15 Feb 2019 10:44:33 +0900 Subject: [PATCH 191/309] Improve performance under the Active Directory environment (see issue #39). --- apt-cyg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apt-cyg b/apt-cyg index 63dbadc..2bc21a1 100755 --- a/apt-cyg +++ b/apt-cyg @@ -1922,7 +1922,7 @@ function apt-cyg-install () fi verbose 0 "Unpacking..." - tar > "/etc/setup/$pkg.lst" xvf "$file" -C / + tar > "/etc/setup/$pkg.lst" xvf "$file" -C / --numeric-owner gzip -f "/etc/setup/$pkg.lst" cd ../.. From 97317e0273fec28aa4ebea29821f54f6148c7b7b Mon Sep 17 00:00:00 2001 From: kou1okada Date: Mon, 18 Feb 2019 20:24:11 +0900 Subject: [PATCH 192/309] Use original Cygwin setup preferences and repo folder (issue #24). * remove `--use-setuprc` and `--use-own-conf` options. * TODO: update `--mirror` and `--cache` options. --- README.md | 2 -- apt-cyg | 65 +++++++++++++++++-------------------------------------- 2 files changed, 20 insertions(+), 47 deletions(-) diff --git a/README.md b/README.md index c62fbed..f38c306 100755 --- a/README.md +++ b/README.md @@ -58,8 +58,6 @@ Usage |:------ |:----------- | | `--ag` | use the silver searcher (currently work only at packageof subcommand) | | `--charch ` | change archetecture | -| `--use-setuprc` | set cache and mirror with /etc/setup/setup.rc | -| `--use-own-conf` | use own cache and mirror settings when apt-cyg calls setup.exe | | `--ignore-case`, `-i` | ignore case distinctions for `` | | `--force-remove` | force remove | `--force-fetch-trustedkeys` | force fetch trustedkeys | diff --git a/apt-cyg b/apt-cyg index 63dbadc..b05026f 100755 --- a/apt-cyg +++ b/apt-cyg @@ -133,9 +133,6 @@ function usage() --ag : use the silver searcher (currently work only at packageof subcommand) --charch : change archetecture - --use-setuprc : set cache and mirror with /etc/setup/setup.rc - --use-own-conf : use own cache and mirror settings - when apt-cyg calls setup.exe --ignore-case, -i : ignore case distinctions for --force-remove : force remove --force-fetch-trustedkeys : @@ -153,8 +150,8 @@ function usage() --completion-disable-autoupdate : disable completion autoupdate --max-jobs, -j : Run jobs in parallel - --mirror, -m : set mirror - --cache, -c : set cache + --mirror, -m : set mirror (currently, not work) + --cache, -c : set cache (currently, not work) --file, -f : read package names from --noupdate, -u : don't update setup.ini from mirror --ipv4, -4 : wget prefer ipv4 @@ -217,25 +214,26 @@ function mirror_to_mirrordir () echo "$1" | sed -e "s/:/%3a/g" -e "s:/:%2f:g" } +function setuprc_query () # SECTION +{ + cat /etc/setup/setup.rc \ + | cp2utf8 \ + | awk -vRS='\n\\<' -vFS='\n\t' -vsection="$1" ' + $1 == section {for(i = 2; i <= NF; i++) print $i;} + ' +} + function findworkspace() { - # default working directory, mirror and architecture - - mirror=http://ftp.jaist.ac.jp/pub/cygwin + readarray -t last_mirror < <(setuprc_query last-mirror) + readarray -t last_cache < <(setuprc_query last-cache) + mirror="$last_mirror" + cache="$(cygpath -au "$last_cache")" arch="$(current_cygarch)" - cache=/setup - # work wherever setup worked last, if possible - - if [ -e /etc/setup/last-cache ]; then - cache="$(cygpath -au "$(head -1 /etc/setup/last-cache)")" - fi cache="${cache%/}" - - if [ -e /etc/setup/last-mirror ]; then - mirror="$(head -1 /etc/setup/last-mirror)" - fi mirror="${mirror%/}" + mirrordir="$(mirror_to_mirrordir "$mirror/")" verbose 1 "Cache directory is $cache" @@ -1157,24 +1155,11 @@ function apt-cyg-update-setup () popd > /dev/null } -function use_own_conf () -{ - local opts=() - if [ -n "$OPT_USE_OWN_CONF" ]; then - local cache="$(apt-cyg-pathof cache)" - local mirror="$(apt-cyg-pathof mirror)" - [ -n "$cache" ] && opts+=( -l "$(cygpath -wa "$cache")" ) - [ -n "$mirror" ] && opts+=( -s "$mirror" ) - fi - join $'\n' "${opts[@]}" -} - function apt-cyg-setup () { pushd "$(apt-cyg pathof cache)" > /dev/null - local opts; readarray -t opts < <(use_own_conf) - local setup=( "./${SETUP_EXE}" "${opts[@]}" "$@" ) + local setup=( "./${SETUP_EXE}" "$@" ) apt-cyg-update-setup "${setup[@]}" @@ -1184,8 +1169,7 @@ function apt-cyg-setup () function apt-cyg-dist-upgrade-no-ask () { - local opts; readarray -t opts < <(use_own_conf) - local setup=( ".\\${SETUP_EXE}" -R "$(cygpath -wa /)" -B -q -n -g "${opts[@]}") + local setup=( ".\\${SETUP_EXE}" -R "$(cygpath -wa /)" -B -q -n -g) pushd "$(apt-cyg-pathof cache)" > /dev/null @@ -1575,17 +1559,6 @@ function parse_args () shift 2 || break ;; - --use-setuprc) - "$0" -c "$(grep -aA1 '^last-cache$' /etc/setup/setup.rc | tail -n1 | cp2utf8 | sed -r 's/^\s*|\s*$//g')" > /dev/null - "$0" -m "$(grep -aA1 '^last-mirror$' /etc/setup/setup.rc | tail -n1 | sed -r 's/^\s*|\s*$//g')" > /dev/null - shift - ;; - - --use-own-conf) - OPT_USE_OWN_CONF="$1" - shift - ;; - --ignore-case|-i) ignore_case="$1" shift @@ -1659,11 +1632,13 @@ function parse_args () ;; --mirror|-m) + # TODO: update imprementation for -m option OPT_MIRROR="$2" shift 2 || break ;; --cache|-c) + # TODO: update imprementation for -c option OPT_CACHE="$2" shift 2 || break ;; From ec6d94b41dc28a1507c0d290142b1fa8c7307350 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Wed, 20 Feb 2019 14:40:46 +0900 Subject: [PATCH 193/309] Add warning if mirror is unofficial. This commit is for issue #40. --- apt-cyg | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/apt-cyg b/apt-cyg index 63dbadc..3065431 100755 --- a/apt-cyg +++ b/apt-cyg @@ -207,6 +207,31 @@ function verbosefor () (( ${OPT_VERBOSE_LEVEL} < ${1:-1} )) && echo "/dev/null" || echo "/dev/stderr" } +function is_official_mirrors_of_cygwin () # ... +# Check whether are listed in official mirrors list of cygwin. +# Official mirros list provides on https://cygwin.com/mirrors.html. +# Args: +# : URLs of the cygwin mirror. +# Return: +# Return zero if all mirrors are known, non-zero otherwise. +{ + local mirror + local result=0 + local local_list="$(apt-cyg-mirrors-list)" + local online_list="$(wget -qO- https://cygwin.com/mirrors.lst)" + for mirror; do + if ! grep -q "$mirror" <<< "$local_list"; then + echo -e "\e[33;1mWarning:\e[0m /etc/setup/setup.rc doesn't know your mirror: \e[1m$mirror\e[0m" >&2 + result=1 + fi + if ! grep -q "$mirror" <<< "$online_list"; then + echo -e "\e[33;1mWarning:\e[0m Official mirrors.lst doesn't know your mirror: \e[1m$mirror\e[0m" >&2 + result=1 + fi + done + return $result +} + function current_cygarch () { arch | sed -e 's/^i686$/x86/g' @@ -312,6 +337,7 @@ function setupini_download () function getsetup () { + is_official_mirrors_of_cygwin "$mirror" setupini_download || return 1 } From 84a7901e57e5178729c5550f029ad73044dd81fb Mon Sep 17 00:00:00 2001 From: kou1okada Date: Fri, 8 Mar 2019 17:39:47 +0900 Subject: [PATCH 194/309] Update to re-enable `--mirror` and `--cache` option. * Add `setuprc-get`, `set-cache` and `set-mirror` subcommand. --- README.md | 3 +++ apt-cyg | 66 +++++++++++++++++++++++++++++++++++++++++++++---------- 2 files changed, 58 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index f38c306..ac29842 100755 --- a/README.md +++ b/README.md @@ -51,6 +51,9 @@ Usage | `listfiles ...` | List files 'owned' by package(s). | | `get-proxy` | Get proxies for eval. | | `ls-categories` | List categories. | +| `setuprc-get
` | Get section from **`setup.rc`**. | +| `set-cache []` | Set cache. | +| `set-mirror [ ...]` | Set mirrors. Note: `setup-x86{,_64}.exe` uses all of them but currently `apt-cyg` uses the first one only. | ### Options diff --git a/apt-cyg b/apt-cyg index b05026f..45c749c 100755 --- a/apt-cyg +++ b/apt-cyg @@ -129,6 +129,12 @@ function usage() List files 'owned' by package(s). get-proxy : Get proxies for eval. ls-categories : List categories. + setuprc-get
: Get section from 'setup.rc'. + set-cache [] : Set cache. + set-mirror [ ...] : + Set mirror. + Note: setup-x86{,_64}.exe uses all of them + but currently `apt-cyg` uses the first one only. Options: --ag : use the silver searcher (currently work only at packageof subcommand) @@ -150,8 +156,8 @@ function usage() --completion-disable-autoupdate : disable completion autoupdate --max-jobs, -j : Run jobs in parallel - --mirror, -m : set mirror (currently, not work) - --cache, -c : set cache (currently, not work) + --mirror, -m : set mirror + --cache, -c : set cache --file, -f : read package names from --noupdate, -u : don't update setup.ini from mirror --ipv4, -4 : wget prefer ipv4 @@ -214,19 +220,38 @@ function mirror_to_mirrordir () echo "$1" | sed -e "s/:/%3a/g" -e "s:/:%2f:g" } -function setuprc_query () # SECTION +function setuprc_get_section () #
{ cat /etc/setup/setup.rc \ | cp2utf8 \ - | awk -vRS='\n\\<' -vFS='\n\t' -vsection="$1" ' + | awk -vRS='\n\\<|\n\\'\' -vFS='\n\t' -vsection="${1//\\/\\\\}" ' $1 == section {for(i = 2; i <= NF; i++) print $i;} ' } +function setuprc_set_section () #
[ ...] +{ + local s="$(join $'\n\t' "${@}")" + local setuprc="/etc/setup/setup.rc" + local setuprc_bak="${setuprc},$(date -r "$setuprc" "+%Y%m%d_%H%M%S")" + + cp -a "$setuprc" "$setuprc_bak" + + cat "$setuprc_bak" \ + | cp2utf8 \ + | awk -vRS='\n\\<|\n\\'\' -vFS='\n\t' -vsection="${1//\\/\\\\}" -vs="${s//\\/\\\\}" ' + $1 != section + $1 == section {print s; done=1;} + END {if(!done) print s;} + ' \ + | utf82cp \ + > "$setuprc" +} + function findworkspace() { - readarray -t last_mirror < <(setuprc_query last-mirror) - readarray -t last_cache < <(setuprc_query last-cache) + readarray -t last_mirror < <(setuprc_get_section last-mirror) + readarray -t last_cache < <(setuprc_get_section last-cache) mirror="$last_mirror" cache="$(cygpath -au "$last_cache")" arch="$(current_cygarch)" @@ -1071,6 +1096,11 @@ function cp2utf8 () iconv -f $(get_codepage) -t UTF-8 } +function utf82cp () +{ + iconv -f UTF-8 -t $(get_codepage) +} + # dummy command for unknown sum. # Usage: unknownsum function unknownsum () @@ -1397,6 +1427,22 @@ function apt-cyg-ls-categories () | uniq } +function apt-cyg-setuprc-get () #
+{ + setuprc_get_section "$1" +} + +function apt-cyg-set-cache () # [] +{ + (( 0 <$# )) && setuprc_set_section last-cache "$(cygpath -aw "$1")" +} + +function apt-cyg-set-mirror () # [ ...] +{ + set -- "${@%/}" + (( 0 < $# )) && setuprc_set_section last-mirror "${@/%/\/}" +} + PACKAGEOF_CACHE="/tmp/.apt-cyg-packageof.cache.gz" function update_packageof_cache () { @@ -1632,13 +1678,11 @@ function parse_args () ;; --mirror|-m) - # TODO: update imprementation for -m option - OPT_MIRROR="$2" + OPT_MIRROR+=( "$2" ) shift 2 || break ;; --cache|-c) - # TODO: update imprementation for -c option OPT_CACHE="$2" shift 2 || break ;; @@ -1743,8 +1787,8 @@ parse_args "$@" [ -n "$OPT_CHARCH" ] && charch "$OPT_CHARCH" "${INITIAL_ARGS[@]}" -[ "${#OPT_MIRROR[@]}" -gt 0 ] && echo "${OPT_MIRROR%/}/" > /etc/setup/last-mirror -[ "${#OPT_CACHE[@]}" -gt 0 ] && echo "$(cygpath -aw "$OPT_CACHE")" > /etc/setup/last-cache +[ "${#OPT_MIRROR[@]}" -gt 0 ] && apt-cyg-set-mirror "${OPT_MIRROR[@]}" +[ "${#OPT_CACHE[@]}" -gt 0 ] && apt-cyg-set-cache "${OPT_CACHE}" if [ -z "$GPGV" -a -z "$no_verify" ]; then echo -e "\e[31;1mError:\e[30;0m GnuPG is not installed. Prease install gnupg package or use -X option." From 9e5867d45bca9280945f4e480da2fcca386893d4 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Fri, 8 Mar 2019 19:45:27 +0900 Subject: [PATCH 195/309] Bugfix: `usage` includes recursive command substitution. --- apt-cyg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apt-cyg b/apt-cyg index 54cc2d4..e7024c2 100755 --- a/apt-cyg +++ b/apt-cyg @@ -134,7 +134,7 @@ function usage() set-mirror [ ...] : Set mirror. Note: setup-x86{,_64}.exe uses all of them - but currently `apt-cyg` uses the first one only. + but currently apt-cyg uses the first one only. Options: --ag : use the silver searcher (currently work only at packageof subcommand) From 73c4186fc9ebb68089f69fe0773e4cae99c88ad6 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Sat, 9 Mar 2019 01:14:28 +0900 Subject: [PATCH 196/309] Refine `cp2utf8` and `utf82cp`. --- apt-cyg | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/apt-cyg b/apt-cyg index e7024c2..e65079f 100755 --- a/apt-cyg +++ b/apt-cyg @@ -247,8 +247,7 @@ function mirror_to_mirrordir () function setuprc_get_section () #
{ - cat /etc/setup/setup.rc \ - | cp2utf8 \ + cp2utf8 /etc/setup/setup.rc \ | awk -vRS='\n\\<|\n\\'\' -vFS='\n\t' -vsection="${1//\\/\\\\}" ' $1 == section {for(i = 2; i <= NF; i++) print $i;} ' @@ -262,15 +261,13 @@ function setuprc_set_section () #
[ ...] cp -a "$setuprc" "$setuprc_bak" - cat "$setuprc_bak" \ - | cp2utf8 \ + cp2utf8 "$setuprc_bak" \ | awk -vRS='\n\\<|\n\\'\' -vFS='\n\t' -vsection="${1//\\/\\\\}" -vs="${s//\\/\\\\}" ' $1 != section $1 == section {print s; done=1;} END {if(!done) print s;} ' \ - | utf82cp \ - > "$setuprc" + | utf82cp > "$setuprc" } function findworkspace() @@ -1112,19 +1109,21 @@ function apt-cyg-show-packages-busyness () done } +unset CODEPAGE + function get_codepage () { - cmd.exe /c chcp | awk '{printf $NF;}' | sed -re 's/^[^0-9]*([0-9]+).*$/CP\1/g' + echo -n "${CODEPAGE:=$(cmd.exe /c chcp | awk '{printf $NF;}' | sed -re 's/^[^0-9]*([0-9]+).*$/CP\1/g')}" } -function cp2utf8 () +function cp2utf8 () # [ ...] { - iconv -f $(get_codepage) -t UTF-8 + iconv -f $(get_codepage) -t UTF-8 "$@" } -function utf82cp () +function utf82cp () # [ ...] { - iconv -f UTF-8 -t $(get_codepage) + iconv -f UTF-8 -t $(get_codepage) "$@" } # dummy command for unknown sum. From 562cde246fc038367ba04620a59d04dd093cb114 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Sat, 9 Mar 2019 01:44:11 +0900 Subject: [PATCH 197/309] Refactoring: Simplify 'mirrors-list' subcommand. --- apt-cyg | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/apt-cyg b/apt-cyg index e65079f..5fd9743 100755 --- a/apt-cyg +++ b/apt-cyg @@ -1036,10 +1036,7 @@ function apt-cyg-completion-uninstall () function apt-cyg-mirrors-list () { - awk ' - /^[^ \t]+/ {section = $1} - section=="mirrors-lst" && match($0, /^[ \t]+([^;]+);/, m) {print m[1]} - ' "/etc/setup/setup.rc" + setuprc_get_section mirrors-lst | sed -re 's/;.*//g' } function apt-cyg-benchmark-mirrors () From 8d92f6c2c719e1f116dd63f06c12bb1e50244399 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Sat, 9 Mar 2019 02:37:28 +0900 Subject: [PATCH 198/309] Refactoring: Clean up indents and blank lines. --- apt-cyg | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/apt-cyg b/apt-cyg index 5fd9743..190c637 100755 --- a/apt-cyg +++ b/apt-cyg @@ -1063,7 +1063,6 @@ function apt-cyg-benchmark-parallel-mirrors () echo Sorted result. sort -rV "$result" rm "$result" - } function apt-cyg-benchmark-parallel-mirrors-list () @@ -1075,16 +1074,16 @@ function apt-cyg-benchmark-parallel-mirrors-list () function apt-cyg-scriptinfo () { -cat< Date: Sat, 9 Mar 2019 04:39:46 +0900 Subject: [PATCH 199/309] Modularize the routines for bash completion. --- apt-cyg | 115 ++++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 79 insertions(+), 36 deletions(-) diff --git a/apt-cyg b/apt-cyg index 190c637..05c0d6c 100755 --- a/apt-cyg +++ b/apt-cyg @@ -922,6 +922,35 @@ function apt-cyg-rdepends () dep_check rdepends "$@" } +function get_module_line () # [] +# Return line numbers of module about begin and end. +{ + grep -nE "^#\s*(BEGIN|END)_MODULE\s*:\s*${1}" "${@:2:1}" | grep -Eo '^[0-9]+' +} + +function headtail () # [] +# Split lines from to . +{ + head -n+$2 "${@:3:1}" | tail -n+$1 +} + +function replace_range # [] +{ + awk -vl1=$1 -vl2=$2 -vs="${3//\\/\\\\}" ' + NR < l1 || l2 < NR + !done && l1 <= NR {print s;done=1;} + ' "${@:4:1}" +} + +function replace_module # +{ + local tmpfile="$(mktemp -u)" + local srclines=( $(get_module_line "bash completion for apt-cyg" "$2") ) + local dstlines=( $(get_module_line "bash completion for apt-cyg" "$3") ) + replace_range "${dstlines[@]}" "$(headtail "${srclines[@]}" "$2")" "$3" > "$tmpfile" + mv "$tmpfile" "$3" +} + function apt-cyg-completion-install () { if [ ! -d "/etc/bash_completion.d" ]; then @@ -933,13 +962,14 @@ function apt-cyg-completion-install () exit 1 fi - local SUBCMDS - local OPTIONS - local SCRIPTFILE="$(realpath "$(which apt-cyg)")" - local SCRIPTDIR="${SCRIPTNAME%/*}" + local __APT_CYG_SUBCMDS + local __APT_CYG_OPTIONS + local __APT_CYG_SCRIPTPATH="$(realpath "$(which apt-cyg)")" + local __APT_CYG_SCRIPTDIR="${__APT_CYG_SCRIPTPATH%/*}" + local __APT_CYG_COMPLETION_DISABLE_AUTOUPDATE="$OPT_COMPLETION_DISABLE_AUTOUPDATE" - readarray -t -O ${#SUBCMDS[@]} SUBCMDS < <(grep "^function " "$SCRIPTFILE" | awk 'match($2, /apt-cyg-([-_0-9A-Za-z]+)/,m){print m[1]}') - readarray -t -O ${#OPTIONS[@]} OPTIONS < <( + readarray -t __APT_CYG_SUBCMDS < <(grep "^function " "$__APT_CYG_SCRIPTPATH" | awk 'match($2, /apt-cyg-([-_0-9A-Za-z]+)/,m){print m[1]}') + readarray -t __APT_CYG_OPTIONS < <( awk ' /^function *parse_args *\(\)/ {proc=1} /^} *# *\/parse_args( |$)/ {proc=0} @@ -947,17 +977,32 @@ function apt-cyg-completion-install () split(m[1], x, "|"); for (i in x) print x[i]; } - ' "$SCRIPTFILE" + ' "$__APT_CYG_SCRIPTPATH" ) + cat <<-EOD > /etc/bash_completion.d/apt-cyg -# bash completion for apt-cyg + $(declare -p __APT_CYG_{SUBCMDS,OPTIONS,SCRIPTPATH,SCRIPTDIR,COMPLETION_DISABLE_AUTOUPDATE} ) + + # BEGIN_MODULE: bash completion for apt-cyg + # END_MODULE: bash completion for apt-cyg + + complete -F __apt-cyg apt-cyg + EOD + + replace_module "bash completion for apt-cyg" "${BASH_SOURCE}" /etc/bash_completion.d/apt-cyg + touch -r "$__APT_CYG_SCRIPTPATH" "/etc/bash_completion.d/apt-cyg" + + echo "A bash completion /etc/bash_completion.d/apt-cyg is installed" +} + +# BEGIN_MODULE: bash completion for apt-cyg function __apt-cyg () { local cur prev getsubcmd subcmd # Auto update for completion script. - if [ -z "$OPT_COMPLETION_DISABLE_AUTOUPDATE" -a "$SCRIPTFILE" -nt "/etc/bash_completion.d/apt-cyg" ]; then + if [ -z "$__APT_CYG_COMPLETION_DISABLE_AUTOUPDATE" -a "$__APT_CYG_SCRIPTPATH" -nt "/etc/bash_completion.d/apt-cyg" ]; then apt-cyg completion-install >/dev/null 2>&1 . /etc/bash_completion.d/apt-cyg __apt-cyg "$@" @@ -966,64 +1011,62 @@ function __apt-cyg () _get_comp_words_by_ref -n : cur prev - getsubcmd=( apt-cyg --completion-get-subcommand \$(echo "\${COMP_LINE}" | sed -r -e 's/^[^ \t]+//g' -e 's/[^ \t]+\$//g') ) - subcmd="\$( "\${getsubcmd[@]}" )" + getsubcmd=( apt-cyg --completion-get-subcommand $(echo "${COMP_LINE}" | sed -r -e 's/^[^ \t]+//g' -e 's/[^ \t]+$//g') ) + subcmd="$( "${getsubcmd[@]}" )" - case "\$subcmd" in + case "$subcmd" in install|depends|rdepends|describe|find) - COMPREPLY=( \$(awk '/^@ /{print \$2}' "$(apt-cyg pathof setup.ini)") ) + COMPREPLY=( $(awk '/^@ /{print $2}' "$(apt-cyg pathof setup.ini)") ) ;; remove) - COMPREPLY=( \$(apt-cyg show 2>/dev/null) ) + COMPREPLY=( $(apt-cyg --no-header show 2>/dev/null | awk '$0=$1') ) ;; pathof) COMPREPLY=( cache mirror mirrordir cache/mirrordir setup.ini ) ;; "") - COMPREPLY=( "${SUBCMDS[*]}" ) + COMPREPLY=( "${__APT_CYG_SUBCMDS[*]}" ) ;; esac - case "\$prev" in + case "$prev" in --charch) COMPREPLY=( x86 x86_64 ) ;; --cache|-c) - COMPREPLY=( \$(compgen -d -- "\$cur") ) + COMPREPLY=( $(compgen -d -- "$cur") ) ;; --mirror|-m) - COMPREPLY=( \$(awk '/^[^ \t]+/{section=\$1}section=="mirrors-lst"&&match(\$0,/^[ \t]+([^;]+);/,m){print "\""m[1]"\""}' "/etc/setup/setup.rc") ) + COMPREPLY=( $(awk '/^[^ \t]+/{section=\$1}section=="mirrors-lst"&&match(\$0,/^[ \t]+([^;]+);/,m){print "\""m[1]"\""}' "/etc/setup/setup.rc") ) ;; --file|-f) - COMPREPLY=( \$(compgen -f -- "\$cur") ) + COMPREPLY=( $(compgen -f -- "$cur") ) ;; --proxy|-p) COMPREPLY=( auto inherit none http:// ) ;; *) - COMPREPLY+=( "${OPTIONS[*]}" ) + COMPREPLY+=( "${__APT_CYG_OPTIONS[*]}" ) ;; esac - if [ -n "\$DEBUG_COMPLETION" ]; then + if [ -n "$DEBUG_COMPLETION" ]; then echo - echo "COMP_WORDBREAKS: \$COMP_WORDBREAKS" - echo "getsubcmd: '\${getsubcmd[@]}'" - echo "subcmd: '\${subcmd[@]}'" - echo "COMP_LINE: '\${COMP_LINE}'" - echo "cur: \$cur" - echo "prev: \$prev" - echo "COMP_WORDS: \${COMP_WORDS[@]}" + echo "COMP_WORDBREAKS: $COMP_WORDBREAKS" + echo "getsubcmd: '${getsubcmd[@]}'" + echo "subcmd: '${subcmd[@]}'" + echo "COMP_LINE: '${COMP_LINE}'" + echo "cur: $cur" + echo "prev: $prev" + echo "COMP_WORDS: ${COMP_WORDS[@]}" echo - echo -n "\${COMP_LINE}" + echo -n "${COMP_LINE}" + fi - COMPREPLY=( \$(compgen -W "\${COMPREPLY[*]}" -- "\$cur") ) - __ltrim_colon_completions "\$cur" -} -complete -F __apt-cyg apt-cyg -EOD - touch -r "$SCRIPTFILE" "/etc/bash_completion.d/apt-cyg" - echo "A bash completion /etc/bash_completion.d/apt-cyg is installed" + COMPREPLY=( $(compgen -W "${COMPREPLY[*]}" -- "$cur") ) + __ltrim_colon_completions "$cur" } +# END_MODULE: bash completion for apt-cyg + function apt-cyg-completion-uninstall () { if [ ! -f /etc/bash_completion.d/apt-cyg ]; then From 7f1fd6ffe56fa37af2d1637b2462586c48f41bdd Mon Sep 17 00:00:00 2001 From: kou1okada Date: Sat, 9 Mar 2019 04:44:25 +0900 Subject: [PATCH 200/309] Improve the debug information for bash completion. --- apt-cyg | 1 + 1 file changed, 1 insertion(+) diff --git a/apt-cyg b/apt-cyg index 05c0d6c..440568c 100755 --- a/apt-cyg +++ b/apt-cyg @@ -1057,6 +1057,7 @@ function __apt-cyg () echo "cur: $cur" echo "prev: $prev" echo "COMP_WORDS: ${COMP_WORDS[@]}" + echo "#COMPREPLY[@]: ${#COMPREPLY[@]}" echo echo -n "${COMP_LINE}" From 3b907e7812e5bd8a8d78e404af07d636632fda58 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Sat, 9 Mar 2019 04:47:09 +0900 Subject: [PATCH 201/309] Bug fixing: subcommand could not be completed. --- apt-cyg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apt-cyg b/apt-cyg index 440568c..a7874cf 100755 --- a/apt-cyg +++ b/apt-cyg @@ -1024,7 +1024,7 @@ function __apt-cyg () pathof) COMPREPLY=( cache mirror mirrordir cache/mirrordir setup.ini ) ;; - "") + *) COMPREPLY=( "${__APT_CYG_SUBCMDS[*]}" ) ;; esac From 3708975e9634fda3593e985f64413dcfba41e07a Mon Sep 17 00:00:00 2001 From: kou1okada Date: Mon, 11 Mar 2019 03:07:21 +0900 Subject: [PATCH 202/309] Use $COMSPEC and $SYSTEMROOT to call Windows system commands. This patch is for issue #42. --- apt-cyg | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/apt-cyg b/apt-cyg index a7874cf..ab2f6bf 100755 --- a/apt-cyg +++ b/apt-cyg @@ -1153,7 +1153,7 @@ unset CODEPAGE function get_codepage () { - echo -n "${CODEPAGE:=$(cmd.exe /c chcp | awk '{printf $NF;}' | sed -re 's/^[^0-9]*([0-9]+).*$/CP\1/g')}" + echo -n "${CODEPAGE:=$("${COMSPEC//\\//}" /c "$SYSTEMROOT"'\System32\chcp.com' | awk '{printf $NF;}' | sed -re 's/^[^0-9]*([0-9]+).*$/CP\1/g')}" } function cp2utf8 () # [ ...] @@ -1269,7 +1269,7 @@ function apt-cyg-dist-upgrade-no-ask () pushd "$(apt-cyg-pathof cache)" > /dev/null apt-cyg-update-setup - cygstart cmd /c 'ECHO Press any key to start dist-upgrade for cygwin '"$(current_cygarch)"' && PAUSE && START /WAIT '"${setup[@]}"' && ash -c "/bin/rebaseall -v" && ECHO dist-upgrade is finished && ECHO Press any key to exit && PAUSE' # ' + cygstart "$COMSPEC" /c 'ECHO Press any key to start dist-upgrade for cygwin '"$(current_cygarch)"' && PAUSE && START /WAIT '"${setup[@]}"' && ash -c "/bin/rebaseall -v" && ECHO dist-upgrade is finished && ECHO Press any key to exit && PAUSE' # ' kill_all_cygwin_process popd > /dev/null @@ -1340,10 +1340,10 @@ function apt-cyg-repair-acl () )" || exit 1 echo - cmd /c icacls "$(cygpath -w "${target}")" /save "$(cygpath -w "${aclbackup}.bin")" > /dev/null - cmd /c icacls "$(cygpath -w "${target}")" | cp2utf8 > "$(cygpath -w "${aclbackup}.txt")" + "${COMSPEC//\\//}" /c "$SYSTEMROOT"'\System32\icacls.exe' "$(cygpath -w "${target}")" /save "$(cygpath -w "${aclbackup}.bin")" > /dev/null + "${COMSPEC//\\//}" /c "$SYSTEMROOT"'\System32\icacls.exe' "$(cygpath -w "${target}")" | cp2utf8 > "$(cygpath -w "${aclbackup}.txt")" - cmd /c icacls "$(cygpath -w "${target}")" \ + "${COMSPEC//\\//}" /c "$SYSTEMROOT"'\System32\icacls.exe' "$(cygpath -w "${target}")" \ /grant \ "%USERDOMAIN%\\%USERNAME%:F" \ "*S-1-3-1:RX" \ From caea32ca809affbca4c422d4bb610fd746cf28dd Mon Sep 17 00:00:00 2001 From: kou1okada Date: Mon, 11 Mar 2019 18:43:43 +0900 Subject: [PATCH 203/309] Improve `show` subcommand. * Align columns automatically with field width. --- apt-cyg | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/apt-cyg b/apt-cyg index a7874cf..3ad788b 100755 --- a/apt-cyg +++ b/apt-cyg @@ -210,6 +210,32 @@ function verbosefor () (( ${OPT_VERBOSE_LEVEL} < ${1:-1} )) && echo "/dev/null" || echo "/dev/stderr" } +function detect_field_width () +# Read stdin and detect field width. +# Return NF+2 values as follorwing: +# w(0) w(1) w(2) ... w(NF) sum(w(1),w(2), ..., w(NF))+NF-1 +# Now NF is a number of fields, +# w(x) is a function of maxium width of field x th +# (note that 0 does not mean the field but the whole line) +# and sum(v1,v2, ..., vn) is a function to sum all arguments. +{ + awk ' + function max(a,b){return a ... # Check whether are listed in official mirrors list of cygwin. # Official mirros list provides on https://cygwin.com/mirrors.html. @@ -786,7 +812,7 @@ function package_db-list () awk ' NF == 3 { version = gensub(/^(.*)\.(tgz|tbz|tbz2|tb2|taz|tz|tlz|txz|tar\.(gz|bz2|Z|lz|lzma|xz))$/, "\\1", 1, substr($2, length($1) + 2)); - printf("%-45s %s\n", $1, version); + printf("%s %s %s\n", $1, version, $3); } ' "${PACKAGE_DB}" } @@ -1901,7 +1927,7 @@ function apt-cyg-show () { package_db-version_check [ -z "$OPT_NO_HEADER" ] && echo "The following packages are installed:" - package_db-list + package_db-list | awk '($3="")||1' | align_columns } From ef4b0bdd075da31df8fe67b70244992614d2a13a Mon Sep 17 00:00:00 2001 From: kou1okada Date: Mon, 11 Mar 2019 18:54:01 +0900 Subject: [PATCH 204/309] Add apt-mark features. * Add `mark-auto`, `mark-manual`, `mark-showauto` and `mark-showmanual` subcommands. --- README.md | 4 ++++ apt-cyg | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+) diff --git a/README.md b/README.md index ac29842..a989bfc 100755 --- a/README.md +++ b/README.md @@ -54,6 +54,10 @@ Usage | `setuprc-get
` | Get section from **`setup.rc`**. | | `set-cache []` | Set cache. | | `set-mirror [ ...]` | Set mirrors. Note: `setup-x86{,_64}.exe` uses all of them but currently `apt-cyg` uses the first one only. | +| `mark-auto [ ...]` | Mark the given packages as automatically installed. | +| `mark-manual [ ...]` | Mark the given packages as manually installed. | +| `mark-showauto` |Print the list of automatically installed packages. | +| `mark-showmanual` | Print the list of manually installed packages. | ### Options diff --git a/apt-cyg b/apt-cyg index 3ad788b..e1501fa 100755 --- a/apt-cyg +++ b/apt-cyg @@ -135,6 +135,14 @@ function usage() Set mirror. Note: setup-x86{,_64}.exe uses all of them but currently apt-cyg uses the first one only. + mark-auto [ ...] : + Mark the given packages + as automatically installed. + mark-manual [ ...] : + Mark the given packages as manually installed. + mark-showauto : Print the list of + automatically installed packages. + mark-showmanual : Print the list of manually installed packages. Options: --ag : use the silver searcher (currently work only at packageof subcommand) @@ -838,6 +846,38 @@ function package_db-register () mv "${work}" "${PACKAGE_DB}" } +function package_db_change_mark () # [ ...] +# Change marks of package in PACKAGE_DB. +# means that 0 was automatically installed +# and 1 was manually installed. +{ + local user_picked="$1" + local PACKAGE_NAMES="$(join $'\x1c' "${@:2}")" + local work="/tmp/apt-cyg.$$.${PACKAGE_DB##*/}" + + package_db-version_check + + awk -vPACKAGE_NAMES="$PACKAGE_NAMES" -vUSER_PICKED="$user_picked" ' + BEGIN { + split(PACKAGE_NAMES, package_names, "\x1c"); + for(i in package_names) target[package_names[i]]=1; + label = USER_PICKED ? "manually" : "automatically"; + } + NF==2 + NF!=2&&!target[$1] + NF!=2&& target[$1] { + msg = $1 " was " ($3==USER_PICKED?"already ":"") "set to " label " installed."; + $3 = USER_PICKED; + print $0; + print msg > "/dev/stderr" + } + ' "${PACKAGE_DB}" 2>&1 >"${work}" + + mv "${PACKAGE_DB}" "${PACKAGE_DB}-save" + mv "${work}" "${PACKAGE_DB}" +} + + # Usage: package_db-unregister PKGNAME function package_db-unregister () { @@ -1534,6 +1574,26 @@ function apt-cyg-set-mirror () # [ ...] (( 0 < $# )) && setuprc_set_section last-mirror "${@/%/\/}" } +function apt-cyg-mark-auto () # [ ...] +{ + package_db_change_mark 0 "$@" +} + +function apt-cyg-mark-manual () # [ ...] +{ + package_db_change_mark 1 "$@" +} + +function apt-cyg-mark-showauto () +{ + package_db-list | awk '!$3{print $1}' +} + +function apt-cyg-mark-showmanual () +{ + package_db-list | awk '$3{print $1}' +} + PACKAGEOF_CACHE="/tmp/.apt-cyg-packageof.cache.gz" function update_packageof_cache () { From a5f796cd39990692eb2275b4ebc30dd58fecba17 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Mon, 11 Mar 2019 23:05:35 +0900 Subject: [PATCH 205/309] Bugfix: `/etc/bash_completion.d/apt-cyg` must declare global variables. --- apt-cyg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apt-cyg b/apt-cyg index e1501fa..31cf563 100755 --- a/apt-cyg +++ b/apt-cyg @@ -1047,7 +1047,7 @@ function apt-cyg-completion-install () ) cat <<-EOD > /etc/bash_completion.d/apt-cyg - $(declare -p __APT_CYG_{SUBCMDS,OPTIONS,SCRIPTPATH,SCRIPTDIR,COMPLETION_DISABLE_AUTOUPDATE} ) + $(declare -p __APT_CYG_{SUBCMDS,OPTIONS,SCRIPTPATH,SCRIPTDIR,COMPLETION_DISABLE_AUTOUPDATE} | sed -re 's/^declare/\0 -g/g') # BEGIN_MODULE: bash completion for apt-cyg # END_MODULE: bash completion for apt-cyg From b7acbae35c27071d9fbbe363823c4ef58c4035d0 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Mon, 18 Mar 2019 18:26:39 +0900 Subject: [PATCH 206/309] Improvements to call Windows system commands. --- apt-cyg | 43 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 39 insertions(+), 4 deletions(-) diff --git a/apt-cyg b/apt-cyg index ab2f6bf..7a93043 100755 --- a/apt-cyg +++ b/apt-cyg @@ -210,6 +210,41 @@ function verbosefor () (( ${OPT_VERBOSE_LEVEL} < ${1:-1} )) && echo "/dev/null" || echo "/dev/stderr" } +function join_to_head () # [ ...] +# Append values to head of joined strings. +{ + local str="$1" + local sep="$2" + local values="$(IFS="$sep"; printf "%s" "${*:3}")" + local value + for value in "${@:3}"; do + str="${str:+$sep$str$sep}" + str="${str//$sep$value$sep/$sep}" + str="${str#$sep}" + str="${str%$sep}" + done + [ -z "$values" -o -z "$str" ] && sep="" + printf "%s\n" "$values$sep$str" +} + +function init_comspec () +{ + : ${SYSTEMPATH:=$(join_to_head "$PATH" : "$(cygpath -u "${SYSTEMROOT:-$WINDIR}")"{/system32,})} +} + +function comspec () # [ ...] +# Call $COMSPEC. +{ + init_comspec + PATH="$SYSTEMPATH" "${COMSPEC//\\//}" "$@" +} + +function cygstart () # [ ...] +{ + init_comspec + PATH="$SYSTEMPATH" cygstart.exe "$@" +} + function is_official_mirrors_of_cygwin () # ... # Check whether are listed in official mirrors list of cygwin. # Official mirros list provides on https://cygwin.com/mirrors.html. @@ -1153,7 +1188,7 @@ unset CODEPAGE function get_codepage () { - echo -n "${CODEPAGE:=$("${COMSPEC//\\//}" /c "$SYSTEMROOT"'\System32\chcp.com' | awk '{printf $NF;}' | sed -re 's/^[^0-9]*([0-9]+).*$/CP\1/g')}" + echo -n "${CODEPAGE:=$(comspec /c chcp.com | awk '{printf $NF;}' | sed -re 's/^[^0-9]*([0-9]+).*$/CP\1/g')}" } function cp2utf8 () # [ ...] @@ -1340,10 +1375,10 @@ function apt-cyg-repair-acl () )" || exit 1 echo - "${COMSPEC//\\//}" /c "$SYSTEMROOT"'\System32\icacls.exe' "$(cygpath -w "${target}")" /save "$(cygpath -w "${aclbackup}.bin")" > /dev/null - "${COMSPEC//\\//}" /c "$SYSTEMROOT"'\System32\icacls.exe' "$(cygpath -w "${target}")" | cp2utf8 > "$(cygpath -w "${aclbackup}.txt")" + comspec /c icacls.exe "$(cygpath -w "${target}")" /save "$(cygpath -w "${aclbackup}.bin")" > /dev/null + comspec /c icacls.exe "$(cygpath -w "${target}")" | cp2utf8 > "$(cygpath -w "${aclbackup}.txt")" - "${COMSPEC//\\//}" /c "$SYSTEMROOT"'\System32\icacls.exe' "$(cygpath -w "${target}")" \ + comspec /c icacls.exe "$(cygpath -w "${target}")" \ /grant \ "%USERDOMAIN%\\%USERNAME%:F" \ "*S-1-3-1:RX" \ From 8bb5c7c14a2420e1ab85da419fd13fd7bc8a61f2 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Mon, 18 Mar 2019 19:56:10 +0900 Subject: [PATCH 207/309] Add `call` subcommand. --- README.md | 1 + apt-cyg | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/README.md b/README.md index a989bfc..e86e34f 100755 --- a/README.md +++ b/README.md @@ -58,6 +58,7 @@ Usage | `mark-manual [ ...]` | Mark the given packages as manually installed. | | `mark-showauto` |Print the list of automatically installed packages. | | `mark-showmanual` | Print the list of manually installed packages. | +| `call [ [ ...]]` | Call internal function in apt-cyg. | ### Options diff --git a/apt-cyg b/apt-cyg index 9af4d22..0b3b58a 100755 --- a/apt-cyg +++ b/apt-cyg @@ -143,6 +143,8 @@ function usage() mark-showauto : Print the list of automatically installed packages. mark-showmanual : Print the list of manually installed packages. + call [ [ ...]] : + Call internal function in apt-cyg. Options: --ag : use the silver searcher (currently work only at packageof subcommand) @@ -1629,6 +1631,12 @@ function apt-cyg-mark-showmanual () package_db-list | awk '$3{print $1}' } +function apt-cyg-call () # [ [ ...]] +# Call internal function in apt-cyg. +{ + "$@" +} + PACKAGEOF_CACHE="/tmp/.apt-cyg-packageof.cache.gz" function update_packageof_cache () { From 0934dd621d85a8c9bc2b61fdced68157f56cda04 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Wed, 20 Mar 2019 18:56:55 +0900 Subject: [PATCH 208/309] Update `other_forks.md`. --- other_forks.md | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/other_forks.md b/other_forks.md index 2a7f59b..183eacc 100644 --- a/other_forks.md +++ b/other_forks.md @@ -8,32 +8,33 @@ Ex.) Merging to the GPL from the MIT is possible. But merging to the MIT from th ### Official (MIT license) -* [transcodes-open / apt-cyg](https://github.com/transcode-open/apt-cyg/network) - * [tmshn / cyg-fast](https://github.com/tmshn/cyg-fast/network) - * [pi0 / cyg](https://github.com/pi0/cyg) (GPLv3) +* [transcodes-open / apt-cyg](https://github.com/transcode-open/apt-cyg/network) ([Stargazers forks](http://forked.yannick.io/transcode-open/apt-cyg)) + * [tmshn / cyg-fast](https://github.com/tmshn/cyg-fast/network) ([Stargazers forks](http://forked.yannick.io/tmshn/cyg-fast)) + * [pi0 / cyg](https://github.com/pi0/cyg/network) ([Stargazers forks](http://forked.yannick.io/pi0/cyg)) (GPLv3) ### Unofficial (MIT license) -* [digitallamb / apt-cyg](https://github.com/digitallamb/apt-cyg/network) -* [balanx / apt-cyg](https://github.com/balanx/apt-cyg/network) -* [langlichuan123 / apt-cyg](https://github.com/langlichuan123/apt-cyg/network) +* [digitallamb / apt-cyg](https://github.com/digitallamb/apt-cyg/network) ([Stargazers forks](http://forked.yannick.io/digitallamb/apt-cyg)) +* [balanx / apt-cyg](https://github.com/balanx/apt-cyg/network) ([Stargazers forks](http://forked.yannick.io/balanx/apt-cyg)) +* [langlichuan123 / apt-cyg](https://github.com/langlichuan123/apt-cyg/network) ([Stargazers forks](http://forked.yannick.io/langlichuan123/apt-cyg)) ### Unofficial (GPLv2) -* [cfg / apt-cyg](https://github.com/cfg/apt-cyg/network) - * [Milly / apt-cyg](https://github.com/Milly/apt-cyg/network) -* [ashumkin / apt-cyg](https://github.com/ashumkin/apt-cyg/network) -* [svn2github / apt-cyg](https://github.com/svn2github/apt-cyg/network) -* [nosuchuser / apt-cyg](https://github.com/nosuchuser/apt-cyg/network) -* [kazuhisya / apt-cyg64](https://github.com/kazuhisya/apt-cyg64/network) -* [bnormsoftware / apt-cyg](https://github.com/bnormsoftware/apt-cyg/network) -* [rcmdnk / apt-cyg](https://github.com/rcmdnk/apt-cyg/network) -* [buzain / apt-cyg](https://github.com/buzain/apt-cyg/network) -* [wuyangnju / apt-cyg](https://github.com/wuyangnju/apt-cyg/network) -* [takuya / apt-cyg](https://github.com/takuya/apt-cyg/network) +* [cfg / apt-cyg](https://github.com/cfg/apt-cyg/network) ([Stargazers forks](http://forked.yannick.io/cfg/apt-cyg)) + * [Milly / apt-cyg](https://github.com/Milly/apt-cyg/network) ([Stargazers forks](http://forked.yannick.io/Milly/apt-cyg)) +* [ashumkin / apt-cyg](https://github.com/ashumkin/apt-cyg/network) ([Stargazers forks](http://forked.yannick.io/ashumkin/apt-cyg)) +* [svn2github / apt-cyg](https://github.com/svn2github/apt-cyg/network) ([Stargazers forks](http://forked.yannick.io/svn2github/apt-cyg)) +* [nosuchuser / apt-cyg](https://github.com/nosuchuser/apt-cyg/network) ([Stargazers forks](http://forked.yannick.io/nosuchuser/apt-cyg)) +* [kazuhisya / apt-cyg64](https://github.com/kazuhisya/apt-cyg64/network) ([Stargazers forks](http://forked.yannick.io/kazuhisya/apt-cyg64)) +* [bnormsoftware / apt-cyg](https://github.com/bnormsoftware/apt-cyg/network) ([Stargazers forks](http://forked.yannick.io/bnormsoftware/apt-cyg)) +* [rcmdnk / apt-cyg](https://github.com/rcmdnk/apt-cyg/network) ([Stargazers forks](http://forked.yannick.io/rcmdnk/apt-cyg)) +* [buzain / apt-cyg](https://github.com/buzain/apt-cyg/network) ([Stargazers forks](http://forked.yannick.io/buzain/apt-cyg)) +* [wuyangnju / apt-cyg](https://github.com/wuyangnju/apt-cyg/network) ([Stargazers forks](http://forked.yannick.io/wuyangnju/apt-cyg)) +* [takuya / apt-cyg](https://github.com/takuya/apt-cyg/network) ([Stargazers forks](http://forked.yannick.io/takuya/apt-cyg)) ### Derivations of non-fork on the github -* [10sr / pac-cyg](https://github.com/10sr/pac-cyg/network) -* [nobuyo / medy](https://github.com/nobuyo/medy/network) -* [svnpenn / sage](https://github.com/svnpenn/sage/network) +* [10sr / pac-cyg](https://github.com/10sr/pac-cyg/network) ([Stargazers forks](http://forked.yannick.io/10sr/pac-cyg)) +* [nobuyo / medy](https://github.com/nobuyo/medy/network) ([Stargazers forks](http://forked.yannick.io/nobuyo/medy)) +* [svnpenn / sage](https://github.com/svnpenn/sage/network) ([Stargazers forks](http://forked.yannick.io/svnpenn/sage)) -> [cup / pear](https://github.com/cup/pear/network) ([Stargazers forks](http://forked.yannick.io/cup/pear)) + From 30d5afeabc39b1cfbe91bfad61ff36087ef5fc48 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Wed, 20 Mar 2019 19:13:36 +0900 Subject: [PATCH 209/309] Bugfix: wrong separator location for `listfiles` subcommand. --- apt-cyg | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/apt-cyg b/apt-cyg index 0b3b58a..9b82814 100755 --- a/apt-cyg +++ b/apt-cyg @@ -125,7 +125,7 @@ function usage() mirror ... : download the binary package into the current cache/mirrordir as mirror. - listfiles ... : + listfiles [ ...] : List files 'owned' by package(s). get-proxy : Get proxies for eval. ls-categories : List categories. @@ -1571,18 +1571,18 @@ function apt-cyg-mirror () download_packages mirror curr install "$@" } -function apt-cyg-listfiles () +function apt-cyg-listfiles () # [ ...] +# List files 'owned' by package(s). { local lst i sep for i; do + echo -en "$sep"; sep="\n" lst="/etc/setup/${i}.lst.gz" if [ ! -e "$lst" ]; then echo "apt-cyg-listfiles: package '${i}' is not installed" continue fi zcat "${lst}" | sed -e 's:^:/:g' - [ -n "$sep" ] && echo - sep=1 done } From a578389553df3839e852d8a12470f4dff8436f42 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Fri, 22 Mar 2019 17:15:43 +0900 Subject: [PATCH 210/309] Improve compatibility for GnuPG v1 and v2. --- apt-cyg | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/apt-cyg b/apt-cyg index 62d890c..27f80a4 100755 --- a/apt-cyg +++ b/apt-cyg @@ -480,7 +480,6 @@ function init_gnupg () exit 1 fi fi - GPG_KEYRING=( --keyring pubring.kbx ) } # Usage: ask_user [MESSAGE [OPTIONS]] @@ -643,7 +642,7 @@ function fetch_trustedkeys () function verify_signatures () { while [ $# -gt 0 ]; do - if ! "${GPG[@]}" --no-default-keyring "${GPG_KEYRING[@]}" --verify "$1" &> $(verbosefor 2); then + if ! "${GPG[@]}" --verify "$1" &> $(verbosefor 2); then echo -e "\e[31;1mError:\e[30;0m BAD signature: $1" >&2 return 1 else From 6bfb2fd5d192115821844c37d44726ebd9a66251 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Fri, 22 Mar 2019 17:55:05 +0900 Subject: [PATCH 211/309] Rewrite error and warning with hhs_embed. --- apt-cyg | 193 +++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 148 insertions(+), 45 deletions(-) diff --git a/apt-cyg b/apt-cyg index 27f80a4..de16c1e 100755 --- a/apt-cyg +++ b/apt-cyg @@ -25,17 +25,119 @@ # THE SOFTWARE. # -(( 5 <= "${DEBUG:-0}" )) && set -x +# EMBED_BEGIN: hhs_embed -SCRIPT_PATH="$(which "$0")" +(( 5 <= DEBUG )) && set -x + +SCRIPT_PATH="$0" SCRIPT_FILE="${SCRIPT_PATH##*/}" SCRIPT_NAME="${SCRIPT_FILE%.*}" SCRIPT_DIR="${SCRIPT_PATH%/*}" -SCRIPT_REALPATH="$(realpath "$(which "$0")")" +SCRIPT_REALPATH="$(readlink -f "$SCRIPT_PATH")" SCRIPT_REALFILE="${SCRIPT_REALPATH##*/}" SCRIPT_REALNAME="${SCRIPT_REALFILE%.*}" SCRIPT_REALDIR="${SCRIPT_REALPATH%/*}" +# EMBED_BEGIN: hhs_sgr.bash + +function init_SGR () +{ + if [ -n "$COLORIZE" ]; then + SGR_reset="\e[0m" + SGR_bold="\e[1m" + SGR_fg_red="\e[31m" + SGR_fg_green="\e[32m" + SGR_fg_yellow="\e[33m" + SGR_fg_blue="\e[34m" + SGR_fg_magenta="\e[35m" + else + unset SGR_reset SGR_bold SGR_red SGR_green SGR_yellow SGR_blue SGR_magenta + fi + FATAL_COLOR="${SGR_fg_magenta}${SGR_bold}" + ERROR_COLOR="${SGR_fg_red}${SGR_bold}" + WARNING_COLOR="${SGR_fg_yellow}${SGR_bold}" + INFO_COLOR="${SGR_fg_green}${SGR_bold}" + DEBUG_COLOR="${SGR_fg_blue}${SGR_bold}" +} + +# EMBED_END: hhs_sgr.bash +# EMBED_BEGIN: hhs_debug.bash + +THRESHOLD_OF_FATAL=0 +THRESHOLD_OF_ERROR=1 +THRESHOLD_OF_WARNING=3 +THRESHOLD_OF_INFO=4 +THRESHOLD_OF_DEBUG=4 + +function abort () #= [EXITCODE=1 [CALLSTACKSKIP=0]] +{ + dump_callstack $(( 2 + ${2:-0} )) + exit "${1:-1}" +} + +function dump_callstack () #= [N=1] +#? N is a depth to skip the callstack. +#? $CALLSTACK_SKIP is depth to skip the callstack too. +#? N and CALLSTACK_SKIP is summed before skipping. +#? The default value is N = 1 and CALLSTACK_SKIP = 0. +{ + local i + echo "Callstack:" + for i in `seq "$(( ${#FUNCNAME[@]} - 1 ))" -1 $(( ${1:-1} + ${CALLSTACK_SKIP:-0} ))`; do + echo -e "\t${BASH_SOURCE[i]}: ${FUNCNAME[i]}: ${BASH_LINENO[i-1]}" + done +} #/dump_callstack + +function source_at () #= [N=1] +{ + local i=${1:-1} + echo -e "${DEBUG_COLOR}at :${SGR_reset} ${BASH_SOURCE[i-1]}: ${FUNCNAME[i]}: ${BASH_LINENO[i-1]}" +} + +function fatal () #= [MESSAGES ...] +{ + (( THRESHOLD_OF_FATAL <= ${VERBOSE:-0} )) || return 1 + echo -e "${FATAL_COLOR}Fatal:${SGR_reset} $@" + (( THRESHOLD_OF_FATAL <= SOURCE_AT )) && source_at 2 +} >&2 #/fatal + +function error () #= [MESSAGES ...] +{ + (( THRESHOLD_OF_ERROR <= ${VERBOSE:-0} )) || return 1 + echo -e "${ERROR_COLOR}Error:${SGR_reset} $@" + (( THRESHOLD_OF_ERROR <= SOURCE_AT )) && source_at 2 +} >&2 #/error + +function warning () #= [MESSAGES ...] +{ + (( THRESHOLD_OF_WARNING <= ${VERBOSE:-0} )) || return 1 + echo -e "${WARNING_COLOR}Warning:${SGR_reset} $@" + (( THRESHOLD_OF_WARNIGN <= SOURCE_AT )) && source_at 2 +} >&2 #/warning + +function info () #= [MESSAGES ...] +{ + (( THRESHOLD_OF_INFO <= ${VERBOSE:-0} )) || return 1 + echo -e "${INFO_COLOR}Info:${SGR_reset} $@" + (( THRESHOLD_OF_INFO <= SOURCE_AT )) && source_at 2 +} >&2 #/info + +function debug () #= [MESSAGES ...] +{ + (( THRESHOLD_OF_DEBUG <= ${VERBOSE:-0} )) || return 1 + echo -e "${DEBUG_COLOR}Debug:${SGR_reset} $@" + (( THRESHOLD_OF_DEBUG <= SOURCE_AT )) && source_at 2 +} >&2 #/debug + +# EMBED_END: hhs_debug.bash + +: ${VERBOSE:=1} +: ${SOURCE_AT:=1} +: ${COLORIZE:=1} +init_SGR + +# EMBED_END: hhs_embed + TRUSTEDKEYS=( CYGWIN CYGWINPORTS ); # ./pubring.asc # ------------ @@ -295,11 +397,11 @@ function is_official_mirrors_of_cygwin () # ... local online_list="$(wget -qO- https://cygwin.com/mirrors.lst)" for mirror; do if ! grep -q "$mirror" <<< "$local_list"; then - echo -e "\e[33;1mWarning:\e[0m /etc/setup/setup.rc doesn't know your mirror: \e[1m$mirror\e[0m" >&2 + warning "/etc/setup/setup.rc doesn't know your mirror: ${SGR_bold}$mirror${SGR_reset}" >&2 result=1 fi if ! grep -q "$mirror" <<< "$online_list"; then - echo -e "\e[33;1mWarning:\e[0m Official mirrors.lst doesn't know your mirror: \e[1m$mirror\e[0m" >&2 + warning "Official mirrors.lst doesn't know your mirror: ${SGR_bold}$mirror${SGR_reset}" >&2 result=1 fi done @@ -403,7 +505,7 @@ function files_backup_clean () function setupini_download () { local BASEDIR="$cache/$mirrordir/$arch" - mkdir -p "$BASEDIR" || { echo -e "\e[31;1mError:\e[30;0m mkdir \"$BASEDIR\" failed."; exit 1; } + mkdir -p "$BASEDIR" || { error "mkdir failed: $BASEDIR"; exit 1; } [ $noscripts -ne 0 -o $noupdate -ne 0 ] && return @@ -422,7 +524,7 @@ function setupini_download () done files_restore setup.ini setup.ini.sig setup.bz2 setup.bz2.sig popd > /dev/null - echo -e "\e[31;1mError:\e[30;0m updating setup.ini, reverting." >&2 + error "updating setup.ini failed, reverting." return 1 } @@ -449,7 +551,7 @@ function getrootdir () x86_64) cygpath -u "$(< /proc/registry64/HKEY_LOCAL_MACHINE/SOFTWARE/Cygwin/setup/rootdir)" ;; *) - echo -e "\e[31;1mError:\e[30;0m unknown arch $1" >&2 ;; + error "unknown arch: $1" ;; esac } @@ -458,7 +560,7 @@ function charch () { local rootdir if [ "$(current_cygarch)" != "$1" ]; then - echo -e "\e[32;1mcharch to:\e[30;0m $1" + echo -e "${SGR_fg_green}${SGR_bold}charch to:${SGR_reset} $1" rootdir="$(getrootdir "$1")" shift chroot "$rootdir" "$rootdir/bin/bash" -lc \ @@ -476,7 +578,7 @@ function init_gnupg () export GNUPGHOME="$cache/.apt-cyg" if [ ! -d "$GNUPGHOME" ]; then if ! { mkdir -p "$GNUPGHOME" && chmod 700 "$GNUPGHOME"; } then - echo -e "\e[31;1mError:\e[30;0m cannot initialize directory $GNUPGHOME" + error "Cannot initialize directory: $GNUPGHOME" exit 1 fi fi @@ -607,30 +709,30 @@ function fetch_trustedkeys () "${GPG[@]}" --import "$FILE" ;; 02) - echo "Warning: ${LABEL} has been updated." + warning "${LABEL} has been updated." "${GPG[@]}" --import "$FILE" ;; -0) "${GPG[@]}" --import "$FILE_LATEST" ;; 10|20) - echo -e "\e[31;1mError:\e[30;0m ${LABEL} has miss configuration." + error "${LABEL} has miss configuration." exit 1 ;; 11|1-|-1) - echo -e "\e[31;1mError:\e[30;0m Could not download ${LABEL}." + error "Could not download ${LABEL}." exit 1 ;; 12|-2) - echo -e "\e[31;1mError:\e[30;0m ${LABEL} has been updated, maybe. But sometimes it may has been cracked. Be careful !!!" + error "${LABEL} has been updated, maybe. But sometimes it may has been cracked. Be careful !!!" exit 1 ;; 21|22|2-) - echo -e "\e[31;1mError:\e[30;0m ${LABEL} has been cracked, maybe" + error "${LABEL} has been cracked, maybe" exit 1 ;; --) - echo -e "\e[31;1mError:\e[30;0m ${LABEL} has no URL." + error "${LABEL} has no URL." exit 1 ;; esac @@ -643,10 +745,10 @@ function verify_signatures () { while [ $# -gt 0 ]; do if ! "${GPG[@]}" --verify "$1" &> $(verbosefor 2); then - echo -e "\e[31;1mError:\e[30;0m BAD signature: $1" >&2 + error "BAD signature: $1" return 1 else - verbose 0 -e "\e[32;1msignature verified\e[30;0m: $1" + verbose 0 -e "${SGR_fg_green}${SGR_bold}signature verified:${SGR_reset} $1" fi shift done @@ -655,7 +757,7 @@ function verify_signatures () # Usage: apt-cyg-key-add pkey ... function apt-cyg-key-add () { - [ -z "$GPG" ] && { echo -e "\e[31;1mError:\e[30;0m GnuPG is not installed. Prease install gnupg package"; exit 1; } + [ -z "$GPG" ] && { error "GnuPG is not installed. Prease install gnupg package"; exit 1; } local pkeys for pkey; do pkeys+=( "$(cygpath -a "$pkey" )" ) @@ -669,7 +771,7 @@ function apt-cyg-key-add () # Usage: apt-cyg-key-add keyid ... function apt-cyg-key-del () { - [ -z "$GPG" ] && { echo -e "\e[31;1mError:\e[30;0m GnuPG is not installed. Prease install gnupg package"; exit 1; } + [ -z "$GPG" ] && { error "GnuPG is not installed. Prease install gnupg package"; exit 1; } local keyid findworkspace for keyid; do @@ -679,14 +781,14 @@ function apt-cyg-key-del () function apt-cyg-key-list () { - [ -z "$GPG" ] && { echo -e "\e[31;1mError:\e[30;0m GnuPG is not installed. Prease install gnupg package"; exit 1; } + [ -z "$GPG" ] && { error "GnuPG is not installed. Prease install gnupg package"; exit 1; } findworkspace "${GPG[@]}" --list-keys } function apt-cyg-key-finger () { - [ -z "$GPG" ] && { echo -e "\e[31;1mError:\e[30;0m GnuPG is not installed. Prease install gnupg package"; exit 1; } + [ -z "$GPG" ] && { error "GnuPG is not installed. Prease install gnupg package"; exit 1; } findworkspace "${GPG[@]}" --fingerprint } @@ -702,7 +804,7 @@ function apt-cyg-pathof () cache/mirrordir) echo "$cache/$mirrordir" ;; setup.ini) echo "$cache/$mirrordir/$arch/setup.ini" ;; *) - echo -e "\e[31;1mError:\e[30;0m in function $FUNCNAME: unknown parameter: $1" + error "unknown parameter: $1" exit 1 ;; esac @@ -714,7 +816,7 @@ function apt-cyg-upgrade-self () { local basedir="$(dirname "$(readlink -f "$(which "$0")")")" if [ ! -d "$basedir/.git" ]; then - echo -e "\e[31;1mError:\e[30;0m apt-cyg is not under the git version control." + error "apt-cyg is not under the git version control." exit 1 fi pushd "$basedir" > /dev/null @@ -803,8 +905,8 @@ function package_db-version_check () [ "${verhdr[0]}" = "INSTALLED.DB" ] && dbver="${verhdr[1]}" || dbver="1" if echo "$line1" | grep -Eqvx "${vernhdr}"; then - echo -e "\e[33;1mWarning:\e[30;0m ${PACKAGE_DB} does not have version header. The first line is below:" >&2 - echo -e "$(head -n1 "${PACKAGE_DB}")\n" >&2 + warning "${PACKAGE_DB} does not have version header. The first line is below:\n" \ + "$(head -n1 "${PACKAGE_DB}")\n" # The earlyer version of apt-cyg was not treat version header correctly. if grep -EHnx "${vernhdr}" "${PACKAGE_DB}" >&2; then @@ -813,9 +915,9 @@ function package_db-version_check () fi if (( dbver < 3 )); then - echo -e "\e[33;1mWarning:\e[30;0m ${PACKAGE_DB} version is less than 3." >&2 - echo -e "Before continuing, recommend to execute below command:" >&2 - echo -e " apt-cyg dist-upgrade" >&2 + warning "${PACKAGE_DB} version is less than 3.\n" \ + "Before continuing, recommend to execute below command:\n" \ + " apt-cyg dist-upgrade" ask_user "Do you continue?" >&2 && { echo "continue" >&2 } || { @@ -825,8 +927,8 @@ function package_db-version_check () fi if (( 3 < dbver )); then - echo -e "\e[31;1mError:\e[30;0m ${PACKAGE_DB} has unknown version header." >&2 - echo -e "Currently apt-cyg supports the DB of ver 3 or ealyer, but your DB is ver $dbver." >&2 + error "${PACKAGE_DB} has unknown version header.\n" \ + "Currently apt-cyg supports the DB of ver 3 or ealyer, but your DB is ver $dbver.\n" ask_user "Do you want to continue at your own risk?" >&2 && { echo "continue" >&2 } || { @@ -1056,11 +1158,11 @@ function replace_module # function apt-cyg-completion-install () { if [ ! -d "/etc/bash_completion.d" ]; then - echo -e "\e[31;1mError:\e[30;0m /etc/bash_completion.d is not exist." + error "/etc/bash_completion.d is not exist." exit 1 fi if ! package_db-is_registered "bash-completion"; then - echo -e "\e[31;1mError:\e[30;0m bash-completion is not installed." + error "bash-completion is not installed." exit 1 fi @@ -1173,7 +1275,7 @@ function __apt-cyg () function apt-cyg-completion-uninstall () { if [ ! -f /etc/bash_completion.d/apt-cyg ]; then - echo -e "\e[31;1mError:\e[30;0m /etc/bash_completion.d/apt-cyg is not exist." + error "/etc/bash_completion.d/apt-cyg is not exist." exit 1 fi rm /etc/bash_completion.d/apt-cyg @@ -1192,7 +1294,7 @@ function apt-cyg-benchmark-mirrors () result="$( { time wget -qO/dev/null -T3 -t 1 "${mirror%/}/$(current_cygarch)/setup.bz2"; } 2>&1 )" exitcode=$? if [ $exitcode -ne 0 ];then - echo -e "\e[33;1mWarning:\e[30;0m benchmark failed with wget exitcode $exitcode: $(wget-exitstatus $exitcode): $1" >&2 + warning "benchmark failed with wget exitcode $exitcode: $(wget-exitstatus $exitcode): $1" continue fi echo -e "$(echo "$result" | grep real | cut -f 2 | tr -d "\n")\t${mirror}" @@ -1345,7 +1447,7 @@ function apt-cyg-update-setup () ls -l "${SETUP_EXE}" > $(verbosefor 2) else files_restore "${TARGETS[@]}" - echo -e "\e[31;1mError:\e[30;0m ${SETUP_EXE} could not be downloaded: Rollbacked it and aborted." >&2 + error "${SETUP_EXE} could not be downloaded: Rollbacked it and aborted." exit 1 fi @@ -1525,7 +1627,7 @@ function download_packages () #= pos section type [package_names ...] cd "$(apt-cyg pathof cache/mirrordir)" ;; *) - echo -e "\e[31;1mError:\e[0m unknown param: $pos" + error "unknown param: $pos" exit 1 ;; esac @@ -1549,7 +1651,7 @@ function download_packages () #= pos section type [package_names ...] fi "${WGET[@]}" -N "$url" if ! hash_check <<<"${digest} *${file}" ; then - verbose 1 -e "\e[31;1mError:\e[0m ${BASH_SOURCE[0]}: ${FUNCNAME[0]}: ${BASH_LINENO[0]}: hash did not match: $file" + error "hash did not match: $file" fi [ "$pos" = "mirror" ] && popd done @@ -1963,12 +2065,12 @@ function parse_args () fi if [ -n "$unknown_option" ]; then - echo -e "\e[31;1mError:\e[30;0m Unknown option: $unknown_option" + error "Unknown option: $unknown_option" exit 1 fi if [ $# -gt 0 ]; then - echo -e "\e[31;1mError:\e[30;0m Number of parameters is not enough: $@" + error "Number of parameters is not enough: $@" exit 1 fi @@ -1976,7 +2078,8 @@ function parse_args () parse_args "$@" -: ${OPT_VERBOSE_LEVEL:=1} +: ${OPT_VERBOSE_LEVEL:=$VERBOSE} +VERBOSE=$OPT_VERBOSE_LEVEL [ -n "$OPT_CHARCH" ] && charch "$OPT_CHARCH" "${INITIAL_ARGS[@]}" @@ -1984,7 +2087,7 @@ parse_args "$@" [ "${#OPT_CACHE[@]}" -gt 0 ] && apt-cyg-set-cache "${OPT_CACHE}" if [ -z "$GPGV" -a -z "$no_verify" ]; then - echo -e "\e[31;1mError:\e[30;0m GnuPG is not installed. Prease install gnupg package or use -X option." + error "GnuPG is not installed. Prease install gnupg package or use -X option." exit 1 fi @@ -2011,7 +2114,7 @@ verbosefor5=$(verbosefor 5) if [ -n "$OPT_AG" ]; then AG="$( which ag 2>/dev/null )" if [ -z "$AG" ]; then - echo -e "\e[33;1mWarning:\e[0m ag is not found." + warning "ag is not found. ignore option: $OPT_AG" unset OPT_AG fi fi @@ -2162,7 +2265,7 @@ function apt-cyg-install () done fi if [ $warn -ne 0 ]; then - echo "Warning: some required packages did not install, continuing" + warning "some required packages did not install, continuing" fi # run all postinstall scripts @@ -2236,7 +2339,7 @@ function invoke_subcommand () if type "$ACTION" >& /dev/null; then "$ACTION" "${ARGS[@]}" else - echo -e "\e[31;1mError:\e[30;0m unknown subcommand: $SUBCOMMAND" + error "unknown subcommand: $SUBCOMMAND" exit 1 fi } From 6353b02806e413fce6a825c0762a93a0ea1aeb40 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Fri, 22 Mar 2019 20:01:40 +0900 Subject: [PATCH 212/309] Add `time` subcommand. --- README.md | 1 + apt-cyg | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/README.md b/README.md index e86e34f..8a92aef 100755 --- a/README.md +++ b/README.md @@ -59,6 +59,7 @@ Usage | `mark-showauto` |Print the list of automatically installed packages. | | `mark-showmanual` | Print the list of manually installed packages. | | `call [ [ ...]]` | Call internal function in apt-cyg. | +| `time [ [ ...]]` | Report time consumed to call internal function in apt-cyg. | ### Options diff --git a/apt-cyg b/apt-cyg index de16c1e..5c4f525 100755 --- a/apt-cyg +++ b/apt-cyg @@ -247,6 +247,9 @@ function usage() mark-showmanual : Print the list of manually installed packages. call [ [ ...]] : Call internal function in apt-cyg. + time [ [ ...]] : + Report time consumed + to call internal function in apt-cyg. Options: --ag : use the silver searcher (currently work only at packageof subcommand) @@ -1738,6 +1741,12 @@ function apt-cyg-call () # [ [ ...]] "$@" } +function apt-cyg-time () # [ [ ...]] +# Report time consumed to call internal function in apt-cyg. +{ + time "$@" +} + PACKAGEOF_CACHE="/tmp/.apt-cyg-packageof.cache.gz" function update_packageof_cache () { From 51c72dcb8919206c5e7593441fa679e4cf0d73ef Mon Sep 17 00:00:00 2001 From: kou1okada Date: Fri, 29 Mar 2019 21:06:24 +0900 Subject: [PATCH 213/309] Refactoring: replace `join` to `join_str` function. --- apt-cyg | 40 ++++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/apt-cyg b/apt-cyg index 5c4f525..186b093 100755 --- a/apt-cyg +++ b/apt-cyg @@ -346,17 +346,33 @@ function align_columns () { local lines w fmt readarray -t lines - w=( $(IFS=$'\n'; printf "%s" "${lines[*]}" | detect_field_width) ) + w=( $(join_str $'\n' "${lines[@]}" | detect_field_width) ) fmt="$(printf " %%-%ds" "${w[@]:1:${#w[@]}-2}")" printf "${fmt:1}\n" ${lines[@]} } +function join_str () # [ ...] +# Join strings with separator. +# Note that separator must be single character. +# If you want separator with multiple character, use join_str_ex. +{ + (IFS="$1"; printf "%s" "${*:2}") +} + +function join_str_ex () # [ ...] +# Join strings with separator. +# Different for join_str the separator can take multiple character. +{ + local str="$(join_str $'\x1c' "${@:2}")" + printf "%s" "${str//$'\x1c'/$1}" +} + function join_to_head () # [ ...] # Append values to head of joined strings. { local str="$1" local sep="$2" - local values="$(IFS="$sep"; printf "%s" "${*:3}")" + local values="$(join_str "$sep" "${@:3}")" local value for value in "${@:3}"; do str="${str:+$sep$str$sep}" @@ -431,7 +447,7 @@ function setuprc_get_section () #
function setuprc_set_section () #
[ ...] { - local s="$(join $'\n\t' "${@}")" + local s="$(join_str_ex $'\n\t' "${@}")" local setuprc="/etc/setup/setup.rc" local setuprc_bak="${setuprc},$(date -r "$setuprc" "+%Y%m%d_%H%M%S")" @@ -993,7 +1009,7 @@ function package_db_change_mark () # [ ...] # and 1 was manually installed. { local user_picked="$1" - local PACKAGE_NAMES="$(join $'\x1c' "${@:2}")" + local PACKAGE_NAMES="$(join_str $'\x1c' "${@:2}")" local work="/tmp/apt-cyg.$$.${PACKAGE_DB##*/}" package_db-version_check @@ -1032,18 +1048,6 @@ function package_db-unregister () mv "${work}" "${PACKAGE_DB}" } -# Usage: join FS fields ... -function join () -{ - local FS="$1" field="" result="" sep="" - shift - for field; do - result="$result$sep$field" - sep="$FS" - done - echo -n "$result" -} - # Usage: dep_check DIR ROOTPKGS ... # Parameters: # DIR is "depends" or "rdepends". @@ -1093,7 +1097,7 @@ function dep_check () } } ' \ - DIR="$1" ROOTPKGS="$(join $'\x1c' "${@:2}")" "$(apt-cyg-pathof "setup.ini")" \ + DIR="$1" ROOTPKGS="$(join_str $'\x1c' "${@:2}")" "$(apt-cyg-pathof "setup.ini")" \ | awk ' function min(x,y) {return x < y ? x : y} function max(x,y) {return x < y ? y : x} @@ -1578,7 +1582,7 @@ function get_archives_list () #= section type [package_names ...] local section="$1" local type="$2" shift 2 - awk -v RS="\n\n@ " -v FS="\n" -v PKGS="$(join $'\x1c' "$@")" -v MIRROR="${mirror%/}/" \ + awk -v RS="\n\n@ " -v FS="\n" -v PKGS="$(join_str $'\x1c' "$@")" -v MIRROR="${mirror%/}/" \ -v SECTION="$section" -v TYPE="$type" ' BEGIN { split(PKGS, tmp, "\x1c"); From 739b5e42d5bfe03d183178651bc7a9bbb2855b4b Mon Sep 17 00:00:00 2001 From: kou1okada Date: Fri, 29 Mar 2019 21:15:59 +0900 Subject: [PATCH 214/309] Refactoring: replace `join_to_head` to `join_str_uniq` function. --- apt-cyg | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/apt-cyg b/apt-cyg index 186b093..cb16aec 100755 --- a/apt-cyg +++ b/apt-cyg @@ -367,26 +367,24 @@ function join_str_ex () # [ ...] printf "%s" "${str//$'\x1c'/$1}" } -function join_to_head () # [ ...] +function split_str () # [ ...] +# Split strings with separator. +{ + local str=( "${@:2}" ) + (IFS=$'\n'; printf "%s" "${str[*]//$1/$'\n'}") +} + +function join_str_uniq () # [ ...] # Append values to head of joined strings. { - local str="$1" - local sep="$2" - local values="$(join_str "$sep" "${@:3}")" - local value - for value in "${@:3}"; do - str="${str:+$sep$str$sep}" - str="${str//$sep$value$sep/$sep}" - str="${str#$sep}" - str="${str%$sep}" - done - [ -z "$values" -o -z "$str" ] && sep="" - printf "%s\n" "$values$sep$str" + local str + readarray -t str < <(split_str "$@" | uniqex) + join_str "$1" "${str[@]}" } function init_comspec () { - : ${SYSTEMPATH:=$(join_to_head "$PATH" : "$(cygpath -u "${SYSTEMROOT:-$WINDIR}")"{/system32,})} + : ${SYSTEMPATH:=$(join_str_uniq : "$(cygpath -u "${SYSTEMROOT:-$WINDIR}")"{/system32,} "$PATH")} } function comspec () # [ ...] @@ -1139,12 +1137,22 @@ function get_module_line () # [] grep -nE "^#\s*(BEGIN|END)_MODULE\s*:\s*${1}" "${@:2:1}" | grep -Eo '^[0-9]+' } +# EMBED_BEGIN: hhs_utils.bash + function headtail () # [] # Split lines from to . { head -n+$2 "${@:3:1}" | tail -n+$1 } +function uniqex () +# An alternative uniq command which is not required sort +{ + awk '!c[$0]++' +} + +# EMBED_END: hhs_utils.bash + function replace_range # [] { awk -vl1=$1 -vl2=$2 -vs="${3//\\/\\\\}" ' From 5d4075995cd0e89290b6c0525528ddba678249e8 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Fri, 29 Mar 2019 21:20:10 +0900 Subject: [PATCH 215/309] Bugfix: `get_archives_list` can not find prev and test packages. --- apt-cyg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apt-cyg b/apt-cyg index cb16aec..ede3a9d 100755 --- a/apt-cyg +++ b/apt-cyg @@ -1602,7 +1602,7 @@ function get_archives_list () #= section type [package_names ...] } else { section = "curr"; for (i = 2; i <= NF; i++) { - if (match($i, /^\[.*\]$/, m)) { + if (match($i, /^\[(.*)\]$/, m)) { section = m[1]; } else if (match($i, TYPE ": *(.*)", m) && section == SECTION) { result[0+n++]=m[1]; From 467870df6a08bc3b8f803b025aa6f67d2767a3cd Mon Sep 17 00:00:00 2001 From: Kaos-Industries Date: Sat, 30 Mar 2019 00:05:29 +0000 Subject: [PATCH 216/309] Update README.md I'm not sure what the logic behind giving a generic link is, but adding the actual link for this fork (which is what people want if they land here in the first place) seems a lot more useful and likely to make more people download the program the proper way --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8a92aef..836dde1 100755 --- a/README.md +++ b/README.md @@ -171,7 +171,7 @@ If you want to use some other public keys, please use `key-*` subcommands. If apt-cyg is under the git version control, this fork can upgrade itself by `upgrade-self` subcommand. Therefore, the most recommended way to deploy this fork is below: - git clone HTTPS_clone_URL + git clone https://github.com/kou1okada/apt-cyg.git ln -s "$(realpath apt-cyg/apt-cyg)" /usr/local/bin/ `HTTPS_clone_URL` is like a `https://github.com/USERNAME/apt-cyg.git`. From 7c739f4f996ee62c009c87923dc5637757628d8b Mon Sep 17 00:00:00 2001 From: Kaos-Industries Date: Sat, 30 Mar 2019 00:07:51 +0000 Subject: [PATCH 217/309] Update README.md --- README.md | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/README.md b/README.md index 8a92aef..c81abb9 100755 --- a/README.md +++ b/README.md @@ -168,14 +168,11 @@ If you want to use some other public keys, please use `key-*` subcommands. ### Upgrade apt-cyg -If apt-cyg is under the git version control, this fork can upgrade itself by `upgrade-self` subcommand. +If apt-cyg is under Git version control, this fork can upgrade itself by `upgrade-self` subcommand. Therefore, the most recommended way to deploy this fork is below: git clone HTTPS_clone_URL ln -s "$(realpath apt-cyg/apt-cyg)" /usr/local/bin/ - -`HTTPS_clone_URL` is like a `https://github.com/USERNAME/apt-cyg.git`. -It can be found from the right side menu in each fork pages on github. ### Proxy support From 46c1b04d42d9be84a9712d05c3747227ef9d7fab Mon Sep 17 00:00:00 2001 From: kou1okada Date: Sun, 31 Mar 2019 12:37:13 +0900 Subject: [PATCH 218/309] Update `README.md` about the most recommended way to deploy. --- README.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 0eaedf4..9a3a92f 100755 --- a/README.md +++ b/README.md @@ -169,11 +169,14 @@ If you want to use some other public keys, please use `key-*` subcommands. ### Upgrade apt-cyg If apt-cyg is under Git version control, this fork can upgrade itself by `upgrade-self` subcommand. -Therefore, the most recommended way to deploy this fork is below: +Therefore, the most recommended way to deploy this fork is `copy and paste` below commands to cygwin console: + # cd $DIR # Change working directory where you want to install apt-cyg git clone https://github.com/kou1okada/apt-cyg.git ln -s "$(realpath apt-cyg/apt-cyg)" /usr/local/bin/ - + +If you want to use another fork, which forked from https://github.com/kou1okada/apt-cyg, rewrite the URL for apropriate one. + ### Proxy support Use `--proxy`, `-p` option. From 853cf23afc56f4cbd52320fa66b13b54035beef5 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Sun, 7 Apr 2019 18:58:57 +0900 Subject: [PATCH 219/309] Tuning for thresholds about debug messages. --- apt-cyg | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/apt-cyg b/apt-cyg index ede3a9d..c8e7678 100755 --- a/apt-cyg +++ b/apt-cyg @@ -65,8 +65,8 @@ function init_SGR () THRESHOLD_OF_FATAL=0 THRESHOLD_OF_ERROR=1 -THRESHOLD_OF_WARNING=3 -THRESHOLD_OF_INFO=4 +THRESHOLD_OF_WARNING=2 +THRESHOLD_OF_INFO=3 THRESHOLD_OF_DEBUG=4 function abort () #= [EXITCODE=1 [CALLSTACKSKIP=0]] @@ -131,8 +131,8 @@ function debug () #= [MESSAGES ...] # EMBED_END: hhs_debug.bash -: ${VERBOSE:=1} -: ${SOURCE_AT:=1} +: ${VERBOSE:=$THRESHOLD_OF_WARNING} +: ${SOURCE_AT:=$THRESHOLD_OF_WARNING} : ${COLORIZE:=1} init_SGR From 038e8fb5d8462505b770791ff63cebc09074a957 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Sun, 7 Apr 2019 19:04:03 +0900 Subject: [PATCH 220/309] Add warning for missing current directory. --- apt-cyg | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/apt-cyg b/apt-cyg index c8e7678..e6a3aa4 100755 --- a/apt-cyg +++ b/apt-cyg @@ -2365,5 +2365,10 @@ function invoke_subcommand () fi } +[ -d "$PWD" ] || { + warning "Missing current directory: $PWD" \ + "\nNote that some functions, which require access to current directory, will be failed." +} + proxy_setup invoke_subcommand "$SUBCOMMAND" "${ARGS[@]}" From 155e35bfbb6d1b6180a34bffbe0a562ce87160ca Mon Sep 17 00:00:00 2001 From: Hosh Date: Wed, 17 Apr 2019 12:02:59 +0100 Subject: [PATCH 221/309] Add support for gpg2 --- apt-cyg | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/apt-cyg b/apt-cyg index e6a3aa4..4c5f13d 100755 --- a/apt-cyg +++ b/apt-cyg @@ -161,8 +161,7 @@ TRUSTEDKEY_CYGWINPORTS_URL_LATEST="http://cygwinports.org/ports.gpg" WGET="$( which wget 2>/dev/null )" TAR="$( which tar 2>/dev/null )" GAWK="$( which awk 2>/dev/null )" -GPGV="$( which gpgv 2>/dev/null )" -GPG="$( which gpg 2>/dev/null )" +GPG="$( which gpg 2>/dev/null || which gpg2 2>/dev/null )" if [ -z "$WGET" -o -z "$TAR" -o -z "$GAWK" ]; then echo You must install wget, tar and gawk to use apt-cyg. exit 1 @@ -2107,7 +2106,7 @@ VERBOSE=$OPT_VERBOSE_LEVEL [ "${#OPT_MIRROR[@]}" -gt 0 ] && apt-cyg-set-mirror "${OPT_MIRROR[@]}" [ "${#OPT_CACHE[@]}" -gt 0 ] && apt-cyg-set-cache "${OPT_CACHE}" -if [ -z "$GPGV" -a -z "$no_verify" ]; then +if [ -z "$GPG" -a -z "$no_verify" ]; then error "GnuPG is not installed. Prease install gnupg package or use -X option." exit 1 fi From c3b4d0044159618709b9aff98b26ccfd6d017e33 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Sun, 5 May 2019 17:40:40 +0900 Subject: [PATCH 222/309] Support for multiple installation of cygwin. This commit relates to issue #47. --- apt-cyg | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/apt-cyg b/apt-cyg index 4c5f13d..fd6b2f9 100755 --- a/apt-cyg +++ b/apt-cyg @@ -1468,13 +1468,26 @@ function apt-cyg-update-setup () popd > /dev/null } +function prepare_setup_rc () +{ + local cache="$(apt-cyg-pathof cache)" + if ! ln -f /etc/setup/setup.rc "${cache%/}/" >&/dev/null; then + warning "\n\tFailed: ln -f /etc/setup/setup.rc \"${cache%/}/\"" \ + "\n\tFall back: cp -a /etc/setup/setup.rc \"${cache%/}/\"" + unlink "${cache%/}/setup.rc" + cp -a /etc/setup/setup.rc "${cache%/}/" \ + || { error "Failed: cp -a /etc/setup/setup.rc \"${cache%/}/\""; exit 1; } + fi +} + function apt-cyg-setup () { pushd "$(apt-cyg pathof cache)" > /dev/null - local setup=( "./${SETUP_EXE}" "$@" ) + local setup=( "./${SETUP_EXE}" -R "$(cygpath -wa /)" "$@" ) apt-cyg-update-setup + prepare_setup_rc "${setup[@]}" popd > /dev/null @@ -1487,6 +1500,7 @@ function apt-cyg-dist-upgrade-no-ask () pushd "$(apt-cyg-pathof cache)" > /dev/null apt-cyg-update-setup + prepare_setup_rc cygstart "$COMSPEC" /c 'ECHO Press any key to start dist-upgrade for cygwin '"$(current_cygarch)"' && PAUSE && START /WAIT '"${setup[@]}"' && ash -c "/bin/rebaseall -v" && ECHO dist-upgrade is finished && ECHO Press any key to exit && PAUSE' # ' kill_all_cygwin_process From cbeeec3bcec7a85ba0e4fe521c576719d73192c6 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Fri, 7 Jun 2019 17:46:14 +0900 Subject: [PATCH 223/309] For issue #49: Change behavior of `describe` subcommand. If the results contain exact match, only exact matches are returned. This change is also related to issue #33. --- apt-cyg | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/apt-cyg b/apt-cyg index 4c5f13d..46100b1 100755 --- a/apt-cyg +++ b/apt-cyg @@ -2179,15 +2179,15 @@ function apt-cyg-find () function apt-cyg-describe () { - local pkg + local pkg exact checkpackages "$@" findworkspace getsetup for pkg do - echo "" - awk -v query="$pkg" -v IGNORECASE="$ignore_case" \ - 'BEGIN{RS="\n\n@ "; FS="\n"; ORS="\n"} {if ($1 ~ query) {print $0 "\n"}}' \ + exact="$(grep -q "@ $pkg$" setup.ini&&echo 1||echo "")" + awk -v query="${exact:+^}$pkg${exact:+$}" -v IGNORECASE="$ignore_case" \ + 'BEGIN{RS="\n\n@ "; FS="\n"} ($1 ~ query){print "@ "$0"\n"}' \ setup.ini done } From 449915b8b9ae2acf1cc9f45176be4fd5731ee720 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Sun, 9 Jun 2019 13:34:07 +0900 Subject: [PATCH 224/309] Refactoring: Simplifying command. --- apt-cyg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apt-cyg b/apt-cyg index 46100b1..901bd1a 100755 --- a/apt-cyg +++ b/apt-cyg @@ -2185,7 +2185,7 @@ function apt-cyg-describe () findworkspace getsetup for pkg do - exact="$(grep -q "@ $pkg$" setup.ini&&echo 1||echo "")" + exact="$(grep "@ $pkg$" setup.ini)" awk -v query="${exact:+^}$pkg${exact:+$}" -v IGNORECASE="$ignore_case" \ 'BEGIN{RS="\n\n@ "; FS="\n"} ($1 ~ query){print "@ "$0"\n"}' \ setup.ini From fd7a1b6870ce46e064d410a237bd878ff131b9b8 Mon Sep 17 00:00:00 2001 From: sukucorp <31029928+sukucorp@users.noreply.github.com> Date: Mon, 10 Jun 2019 20:04:01 +0530 Subject: [PATCH 225/309] Add new command "category" from original apt-cyg --- apt-cyg | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/apt-cyg b/apt-cyg index 901bd1a..7740cc1 100755 --- a/apt-cyg +++ b/apt-cyg @@ -230,6 +230,7 @@ function usage() List files 'owned' by package(s). get-proxy : Get proxies for eval. ls-categories : List categories. + category : List all packages in given category. setuprc-get
: Get section from 'setup.rc'. set-cache [] : Set cache. set-mirror [ ...] : @@ -1233,7 +1234,7 @@ function __apt-cyg () subcmd="$( "${getsubcmd[@]}" )" case "$subcmd" in - install|depends|rdepends|describe|find) + install|depends|rdepends|describe|find|category) COMPREPLY=( $(awk '/^@ /{print $2}' "$(apt-cyg pathof setup.ini)") ) ;; remove) @@ -2177,6 +2178,27 @@ function apt-cyg-find () } +function apt-cyg-category () +{ + local pkg + + checkpackages "$@" + findworkspace + getsetup + + for pkg do + awk ' + $1 == "@" { + pcat = $2 + } + $1 == "category:" && $0 ~ query { + print pcat + } + ' query="$pkg" setup.ini + done +} + + function apt-cyg-describe () { local pkg exact From b73b293e660a9fa3792295e005da9faa8f7a7a2d Mon Sep 17 00:00:00 2001 From: kou1okada Date: Tue, 11 Jun 2019 20:06:02 +0900 Subject: [PATCH 226/309] add `ls-pkg-with-category` subcommand. --- README.md | 1 + apt-cyg | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/README.md b/README.md index 9a3a92f..92d8967 100755 --- a/README.md +++ b/README.md @@ -51,6 +51,7 @@ Usage | `listfiles ...` | List files 'owned' by package(s). | | `get-proxy` | Get proxies for eval. | | `ls-categories` | List categories. | +| `ls-pkg-with-category` | List packages with category. | | `setuprc-get
` | Get section from **`setup.rc`**. | | `set-cache []` | Set cache. | | `set-mirror [ ...]` | Set mirrors. Note: `setup-x86{,_64}.exe` uses all of them but currently `apt-cyg` uses the first one only. | diff --git a/apt-cyg b/apt-cyg index 7740cc1..3bba258 100755 --- a/apt-cyg +++ b/apt-cyg @@ -230,6 +230,7 @@ function usage() List files 'owned' by package(s). get-proxy : Get proxies for eval. ls-categories : List categories. + ls-pkg-with-category : List packages with category. category : List all packages in given category. setuprc-get
: Get section from 'setup.rc'. set-cache [] : Set cache. @@ -1711,6 +1712,13 @@ function apt-cyg-ls-categories () | uniq } +function apt-cyg-ls-pkg-with-category () +{ + cat "$(apt-cyg-pathof setup.ini)" \ + | awk '$1=="@"{pkg=$2;}$1=="category:"{for(i=2;i<=NF;i++)print $i,pkg}' \ + | align_columns +} + function apt-cyg-setuprc-get () #
{ setuprc_get_section "$1" From 549df20195e8ec2f26deeff5694c0db6bba863c0 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Tue, 11 Jun 2019 20:13:28 +0900 Subject: [PATCH 227/309] Reimprelemt `category` subcommand using `ls-pkg-with-category`. --- apt-cyg | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/apt-cyg b/apt-cyg index 3bba258..40d84d2 100755 --- a/apt-cyg +++ b/apt-cyg @@ -231,7 +231,7 @@ function usage() get-proxy : Get proxies for eval. ls-categories : List categories. ls-pkg-with-category : List packages with category. - category : List all packages in given category. + category : List all packages in given . setuprc-get
: Get section from 'setup.rc'. set-cache [] : Set cache. set-mirror [ ...] : @@ -2188,22 +2188,9 @@ function apt-cyg-find () function apt-cyg-category () { - local pkg - - checkpackages "$@" - findworkspace - getsetup - - for pkg do - awk ' - $1 == "@" { - pcat = $2 - } - $1 == "category:" && $0 ~ query { - print pcat - } - ' query="$pkg" setup.ini - done + apt-cyg-ls-pkg-with-category \ + | grep "$@" \ + | awk '$0=$2' } From 305947b32ba38160a4463d304dce4965d6622771 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Tue, 11 Jun 2019 22:28:31 +0900 Subject: [PATCH 228/309] Use `/etc/setup/setup.rc` directly for `setup.exe`. --- apt-cyg | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/apt-cyg b/apt-cyg index fd6b2f9..5a9e063 100755 --- a/apt-cyg +++ b/apt-cyg @@ -1468,26 +1468,14 @@ function apt-cyg-update-setup () popd > /dev/null } -function prepare_setup_rc () -{ - local cache="$(apt-cyg-pathof cache)" - if ! ln -f /etc/setup/setup.rc "${cache%/}/" >&/dev/null; then - warning "\n\tFailed: ln -f /etc/setup/setup.rc \"${cache%/}/\"" \ - "\n\tFall back: cp -a /etc/setup/setup.rc \"${cache%/}/\"" - unlink "${cache%/}/setup.rc" - cp -a /etc/setup/setup.rc "${cache%/}/" \ - || { error "Failed: cp -a /etc/setup/setup.rc \"${cache%/}/\""; exit 1; } - fi -} - function apt-cyg-setup () { pushd "$(apt-cyg pathof cache)" > /dev/null - local setup=( "./${SETUP_EXE}" -R "$(cygpath -wa /)" "$@" ) + local setup=( "$PWD/${SETUP_EXE}" -R "$(cygpath -wa /)" "$@" ) apt-cyg-update-setup - prepare_setup_rc + cd /etc/setup "${setup[@]}" popd > /dev/null @@ -1495,12 +1483,12 @@ function apt-cyg-setup () function apt-cyg-dist-upgrade-no-ask () { - local setup=( ".\\${SETUP_EXE}" -R "$(cygpath -wa /)" -B -q -n -g) + local setup=( "$(cygpath -wa "$PWD")\\${SETUP_EXE}" -R "$(cygpath -wa /)" -B -q -n -g) pushd "$(apt-cyg-pathof cache)" > /dev/null apt-cyg-update-setup - prepare_setup_rc + cd /etc/setup cygstart "$COMSPEC" /c 'ECHO Press any key to start dist-upgrade for cygwin '"$(current_cygarch)"' && PAUSE && START /WAIT '"${setup[@]}"' && ash -c "/bin/rebaseall -v" && ECHO dist-upgrade is finished && ECHO Press any key to exit && PAUSE' # ' kill_all_cygwin_process From a3ec2b15ea78e8335ac0f144513a18bbbee955ef Mon Sep 17 00:00:00 2001 From: kou1okada Date: Thu, 20 Jun 2019 13:57:35 +0900 Subject: [PATCH 229/309] Fix behavior for exact matching. * This is a patch for issue #49 and #53. --- apt-cyg | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apt-cyg b/apt-cyg index 40d84d2..2593ccc 100755 --- a/apt-cyg +++ b/apt-cyg @@ -2202,9 +2202,9 @@ function apt-cyg-describe () findworkspace getsetup for pkg do - exact="$(grep "@ $pkg$" setup.ini)" - awk -v query="${exact:+^}$pkg${exact:+$}" -v IGNORECASE="$ignore_case" \ - 'BEGIN{RS="\n\n@ "; FS="\n"} ($1 ~ query){print "@ "$0"\n"}' \ + exact="$(grep -Fx "@ $pkg" setup.ini)" + awk -v query="$pkg" -v exact="${exact:+1}" -v IGNORECASE="$ignore_case" \ + 'BEGIN{RS="\n\n@ "; FS="\n"} (exact?$1==query:$1~query){print "@ "$0"\n"}' \ setup.ini done } From 4d438deb2c1be2575dd43bcddb661802cb932cd6 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Tue, 1 Oct 2019 18:01:25 +0900 Subject: [PATCH 230/309] Add `filesearch` subcommand. --- README.md | 1 + apt-cyg | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/README.md b/README.md index 92d8967..e973aaf 100755 --- a/README.md +++ b/README.md @@ -61,6 +61,7 @@ Usage | `mark-showmanual` | Print the list of manually installed packages. | | `call [ [ ...]]` | Call internal function in apt-cyg. | | `time [ [ ...]]` | Report time consumed to call internal function in apt-cyg. | +| `filesearch []` | File search like apt-file search. | ### Options diff --git a/apt-cyg b/apt-cyg index 2593ccc..90bcb69 100755 --- a/apt-cyg +++ b/apt-cyg @@ -251,6 +251,7 @@ function usage() time [ [ ...]] : Report time consumed to call internal function in apt-cyg. + filesearch [] : File search like apt-file search. Options: --ag : use the silver searcher (currently work only at packageof subcommand) @@ -1767,6 +1768,30 @@ function apt-cyg-time () # [ [ ...]] time "$@" } +function apt-cyg-filesearch () # [] +# File search like apt-file search +{ + local arch cachedir cachefile cachequery colmns line package packages url + arch="$(current_cygarch)" + cachedir="/tmp/.apt-cyg.cache/filesearch" + cachequery="$cachedir/$(sha256sum <<<"$1"|awk '$0=$1')" + mkdir -p "$cachedir" + + [ ! -e "$cachequery" ] && cygcheck -p "$1" >"$cachequery" + readarray -t packages < "$cachequery" + packages=( "${packages[@]:1}" ) + for line in "${packages[@]}"; do + columns=( $line ) + url="https://cygwin.com/packages/$arch/${columns[0]%%-[0-9]*}/${columns[0]}" + cachefile="$cachedir/$(mirror_to_mirrordir "$url")" + [ ! -e "$cachefile" ] && wget -qO"$cachefile" "$url" + echo -n "${columns[0]}" + awk '/<\/pre>/{f=0}/
/{f=1}f' "$cachefile" \
+    | grep -E "$1" \
+    | awk '($1=$2=$3="")||1'
+  done
+}
+
 PACKAGEOF_CACHE="/tmp/.apt-cyg-packageof.cache.gz"
 function update_packageof_cache ()
 {

From 214e3a537e30f09f6b310892d6557ec8fae3976b Mon Sep 17 00:00:00 2001
From: Christopher Slycord 
Date: Fri, 25 Oct 2019 19:16:53 +0900
Subject: [PATCH 231/309] fixed typos in upstream script

A few variables were misspelled and therefore unused or used incorrectly
---
 apt-cyg | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/apt-cyg b/apt-cyg
index 90bcb69..eac60b7 100755
--- a/apt-cyg
+++ b/apt-cyg
@@ -112,7 +112,7 @@ function warning () #= [MESSAGES ...]
 {
   (( THRESHOLD_OF_WARNING <= ${VERBOSE:-0} )) || return 1
   echo -e "${WARNING_COLOR}Warning:${SGR_reset} $@"
-  (( THRESHOLD_OF_WARNIGN <= SOURCE_AT )) && source_at 2
+  (( THRESHOLD_OF_WARNING <= SOURCE_AT )) && source_at 2
 } >&2 #/warning
 
 function info () #= [MESSAGES ...]
@@ -290,7 +290,7 @@ function usage()
 
 function git_status ()
 {
-  local origin stauts
+  local origin status
   [ ! -d "${SCRIPT_REALDIR%/}/.git" ] && return 1
   pushd "${SCRIPT_REALDIR}" >/dev/null
   echo
@@ -1320,7 +1320,7 @@ function apt-cyg-benchmark-mirrors ()
 
 function apt-cyg-benchmark-parallel-mirrors ()
 {
-  local result="$(mktemp --tmpdir "${SCRIPTNAME}.$$.XXXXX")"
+  local result="$(mktemp --tmpdir "${SCRIPT_NAME}.$$.XXXXX")"
   local mirror
   for mirror; do echo $mirror; done | lesser-parallel apt-cyg-benchmark-mirrors {} | tee "$result"
   echo Finished benchmark.
@@ -1771,7 +1771,7 @@ function apt-cyg-time () # [ [ ...]]
 function apt-cyg-filesearch () # []
 #   File search like apt-file search
 {
-  local arch cachedir cachefile cachequery colmns line package packages url
+  local arch cachedir cachefile cachequery columns line package packages url
   arch="$(current_cygarch)"
   cachedir="/tmp/.apt-cyg.cache/filesearch"
   cachequery="$cachedir/$(sha256sum <<<"$1"|awk '$0=$1')"

From db0c0d91d706fe6b380b8add72768e9065ae8f3b Mon Sep 17 00:00:00 2001
From: Christopher Slycord 
Date: Fri, 25 Oct 2019 19:16:53 +0900
Subject: [PATCH 232/309] modification to use wget for updating

Modifications to the upstream apt-cyg to use wget
These changes now are separated from the others.
---
 apt-cyg | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/apt-cyg b/apt-cyg
index 90bcb69..8210650 100755
--- a/apt-cyg
+++ b/apt-cyg
@@ -834,13 +834,20 @@ function apt-cyg-pathof ()
 function apt-cyg-upgrade-self ()
 {
   local basedir="$(dirname "$(readlink -f "$(which "$0")")")"
-  if [ ! -d "$basedir/.git" ]; then
-    error "apt-cyg is not under the git version control."
-    exit 1
+  if [ -d "$basedir/.git" ]; then
+    pushd "$basedir" > /dev/null
+    git pull -v
+    popd > /dev/null
+  else
+    local updated_url='https://raw.githubusercontent.com/kou1okada/apt-cyg/master/apt-cyg'
+    local temp_file=$(mktemp)
+    local this_script="${basedir}/$(basename ${updated_url})"
+    "${WGET[@]}" "${updated_url}" -q -O "$temp_file"
+    chmod +x "$temp_file"
+    { diff "$temp_file" "$this_script" >/dev/null && exit 0; } || cp "$temp_file" "$this_script"
+    rm "$temp_file"
+    exit 0
   fi
-  pushd "$basedir" > /dev/null
-  git pull -v
-  popd > /dev/null
 }
 
 function proxy_auto ()

From bf2f52a866d24a5031991d608b2b7eb95ff3d7c9 Mon Sep 17 00:00:00 2001
From: kou1okada 
Date: Thu, 31 Oct 2019 13:03:32 +0900
Subject: [PATCH 233/309] Split upgrade-self to with-git and with-wget(for
 fallback).

---
 apt-cyg | 22 +++++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)

diff --git a/apt-cyg b/apt-cyg
index 8210650..a8173ff 100755
--- a/apt-cyg
+++ b/apt-cyg
@@ -831,14 +831,21 @@ function apt-cyg-pathof ()
   done
 }
 
-function apt-cyg-upgrade-self ()
+function upgrade-self-with-git ()
 {
   local basedir="$(dirname "$(readlink -f "$(which "$0")")")"
-  if [ -d "$basedir/.git" ]; then
+  if [ ! -d "$basedir/.git" ]; then
+    warning "apt-cyg is not under the git version control."
+    return 1
+  fi
     pushd "$basedir" > /dev/null
     git pull -v
     popd > /dev/null
-  else
+}
+
+function upgrade-self-with-wget ()
+{
+    local basedir="$(dirname "$(readlink -f "$(which "$0")")")"
     local updated_url='https://raw.githubusercontent.com/kou1okada/apt-cyg/master/apt-cyg'
     local temp_file=$(mktemp)
     local this_script="${basedir}/$(basename ${updated_url})"
@@ -846,8 +853,13 @@ function apt-cyg-upgrade-self ()
     chmod +x "$temp_file"
     { diff "$temp_file" "$this_script" >/dev/null && exit 0; } || cp "$temp_file" "$this_script"
     rm "$temp_file"
-    exit 0
-  fi
+}
+
+function apt-cyg-upgrade-self ()
+{
+  upgrade-self-with-git && return
+  echo "Fall back to wget for upgrade-self."
+  upgrade-self-with-wget
 }
 
 function proxy_auto ()

From 4f536a56bac135a3ad6847101a2122a07db49bd0 Mon Sep 17 00:00:00 2001
From: kou1okada 
Date: Thu, 31 Oct 2019 13:09:48 +0900
Subject: [PATCH 234/309] Rearranging indents.

---
 apt-cyg | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/apt-cyg b/apt-cyg
index a8173ff..666f179 100755
--- a/apt-cyg
+++ b/apt-cyg
@@ -838,9 +838,9 @@ function upgrade-self-with-git ()
     warning "apt-cyg is not under the git version control."
     return 1
   fi
-    pushd "$basedir" > /dev/null
-    git pull -v
-    popd > /dev/null
+  pushd "$basedir" > /dev/null
+  git pull -v
+  popd > /dev/null
 }
 
 function upgrade-self-with-wget ()

From 82a5e2e3b8a94b3231512be47d6003d9aed74849 Mon Sep 17 00:00:00 2001
From: kou1okada 
Date: Mon, 2 Dec 2019 15:23:15 +0900
Subject: [PATCH 235/309] Refactoring: Use $SCRIPT_PATH and $SCRIPT_DIR.

---
 apt-cyg | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/apt-cyg b/apt-cyg
index 666f179..211c0d7 100755
--- a/apt-cyg
+++ b/apt-cyg
@@ -833,25 +833,22 @@ function apt-cyg-pathof ()
 
 function upgrade-self-with-git ()
 {
-  local basedir="$(dirname "$(readlink -f "$(which "$0")")")"
-  if [ ! -d "$basedir/.git" ]; then
+  if [ ! -d "$SCRIPT_REALDIR/.git" ]; then
     warning "apt-cyg is not under the git version control."
     return 1
   fi
-  pushd "$basedir" > /dev/null
+  pushd "$SCRIPT_REALDIR" > /dev/null
   git pull -v
   popd > /dev/null
 }
 
 function upgrade-self-with-wget ()
 {
-    local basedir="$(dirname "$(readlink -f "$(which "$0")")")"
     local updated_url='https://raw.githubusercontent.com/kou1okada/apt-cyg/master/apt-cyg'
     local temp_file=$(mktemp)
-    local this_script="${basedir}/$(basename ${updated_url})"
     "${WGET[@]}" "${updated_url}" -q -O "$temp_file"
     chmod +x "$temp_file"
-    { diff "$temp_file" "$this_script" >/dev/null && exit 0; } || cp "$temp_file" "$this_script"
+    { diff "$temp_file" "$SCRIPT_REALPATH" >/dev/null && exit 0; } || cp "$temp_file" "$SCRIPT_REALPATH"
     rm "$temp_file"
 }
 

From bec4bc1f212fde8474a8cfe5fcac26455c84d99d Mon Sep 17 00:00:00 2001
From: kou1okada 
Date: Mon, 2 Dec 2019 15:28:11 +0900
Subject: [PATCH 236/309] Add a TODO.

---
 apt-cyg | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/apt-cyg b/apt-cyg
index 211c0d7..05dd608 100755
--- a/apt-cyg
+++ b/apt-cyg
@@ -844,7 +844,7 @@ function upgrade-self-with-git ()
 
 function upgrade-self-with-wget ()
 {
-    local updated_url='https://raw.githubusercontent.com/kou1okada/apt-cyg/master/apt-cyg'
+    local updated_url='https://raw.githubusercontent.com/kou1okada/apt-cyg/master/apt-cyg' # TODO: Do not use MAGIC NUMBER
     local temp_file=$(mktemp)
     "${WGET[@]}" "${updated_url}" -q -O "$temp_file"
     chmod +x "$temp_file"

From e44069af020270430fcf0348a190badfa4e9268a Mon Sep 17 00:00:00 2001
From: kou1okada 
Date: Mon, 2 Dec 2019 15:31:12 +0900
Subject: [PATCH 237/309] Rearranging indents.

---
 apt-cyg | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/apt-cyg b/apt-cyg
index 61a1fe5..c34f235 100755
--- a/apt-cyg
+++ b/apt-cyg
@@ -844,12 +844,12 @@ function upgrade-self-with-git ()
 
 function upgrade-self-with-wget ()
 {
-    local updated_url='https://raw.githubusercontent.com/kou1okada/apt-cyg/master/apt-cyg' # TODO: Do not use MAGIC NUMBER
-    local temp_file=$(mktemp)
-    "${WGET[@]}" "${updated_url}" -q -O "$temp_file"
-    chmod +x "$temp_file"
-    { diff "$temp_file" "$SCRIPT_REALPATH" >/dev/null && exit 0; } || cp "$temp_file" "$SCRIPT_REALPATH"
-    rm "$temp_file"
+  local updated_url='https://raw.githubusercontent.com/kou1okada/apt-cyg/master/apt-cyg' # TODO: Do not use MAGIC NUMBER
+  local temp_file=$(mktemp)
+  "${WGET[@]}" "${updated_url}" -q -O "$temp_file"
+  chmod +x "$temp_file"
+  { diff "$temp_file" "$SCRIPT_REALPATH" >/dev/null && exit 0; } || cp "$temp_file" "$SCRIPT_REALPATH"
+  rm "$temp_file"
 }
 
 function apt-cyg-upgrade-self ()

From 9e7d45f400aed1021101cb342b8d47a0abb1209a Mon Sep 17 00:00:00 2001
From: kou1okada 
Date: Mon, 2 Dec 2019 15:40:03 +0900
Subject: [PATCH 238/309] Revived --use-setuprc option for backward
 compatibility.

---
 apt-cyg | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/apt-cyg b/apt-cyg
index c34f235..797a638 100755
--- a/apt-cyg
+++ b/apt-cyg
@@ -1970,6 +1970,11 @@ function parse_args ()
         shift 2 || break
         ;;
       
+      --use-setuprc)
+        warning "Ignore --use-setuprc. This option was removed with issue-24."
+        shift
+        ;;
+      
       --ignore-case|-i)
         ignore_case="$1"
         shift

From e9f9cadf4e4bd32fbe39d6d8353abe8de319f481 Mon Sep 17 00:00:00 2001
From: kou1okada 
Date: Wed, 25 Dec 2019 18:46:21 +0900
Subject: [PATCH 239/309] Bugfix: PATH of `$setup` is incorrect at `apt-cyg
 dist-upgrade`.

---
 apt-cyg | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/apt-cyg b/apt-cyg
index 831d01a..5a57809 100755
--- a/apt-cyg
+++ b/apt-cyg
@@ -1502,10 +1502,10 @@ function apt-cyg-setup ()
 
 function apt-cyg-dist-upgrade-no-ask ()
 {
-  local setup=( "$(cygpath -wa "$PWD")\\${SETUP_EXE}" -R "$(cygpath -wa /)" -B -q -n -g)
-  
   pushd "$(apt-cyg-pathof cache)" > /dev/null
   
+  local setup=( "$(cygpath -wa "$PWD")\\${SETUP_EXE}" -R "$(cygpath -wa /)" -B -q -n -g)
+  
   apt-cyg-update-setup
   cd /etc/setup
   cygstart "$COMSPEC" /c 'ECHO Press any key to start dist-upgrade for cygwin '"$(current_cygarch)"' && PAUSE && START /WAIT '"${setup[@]}"' && ash -c "/bin/rebaseall -v" && ECHO dist-upgrade is finished && ECHO Press any key to exit && PAUSE' # '

From d83a2d509230bb8e1f19e014d06e93f9eea95ea9 Mon Sep 17 00:00:00 2001
From: kou1okada 
Date: Sun, 29 Dec 2019 22:33:56 +0900
Subject: [PATCH 240/309] Bugfix: iconv can not recognize CP20127(=US-ASCII).

This patch is related to issue #63.
---
 apt-cyg | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/apt-cyg b/apt-cyg
index 5a57809..34e665a 100755
--- a/apt-cyg
+++ b/apt-cyg
@@ -1390,7 +1390,7 @@ unset CODEPAGE
 
 function get_codepage ()
 {
-  echo -n "${CODEPAGE:=$(comspec /c chcp.com | awk '{printf $NF;}' | sed -re 's/^[^0-9]*([0-9]+).*$/CP\1/g')}"
+  echo -n "${CODEPAGE:=$(comspec /c chcp.com | awk '{printf $NF;}' | sed -E 's/^[^0-9]*([0-9]+).*$/CP\1/g;s/CP20127/US-ASCII/g')}"
 }
 
 function cp2utf8 () # [ ...]
@@ -1503,7 +1503,7 @@ function apt-cyg-setup ()
 function apt-cyg-dist-upgrade-no-ask ()
 {
   pushd "$(apt-cyg-pathof cache)" > /dev/null
-  
+
   local setup=( "$(cygpath -wa "$PWD")\\${SETUP_EXE}" -R "$(cygpath -wa /)" -B -q -n -g)
   
   apt-cyg-update-setup

From 302d4696690f9900fb8a0090e212912bc31838e6 Mon Sep 17 00:00:00 2001
From: kou1okada 
Date: Sun, 22 Mar 2020 12:35:10 +0900
Subject: [PATCH 241/309] Improve performance for get_codepage.

---
 apt-cyg | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/apt-cyg b/apt-cyg
index 34e665a..2c30087 100755
--- a/apt-cyg
+++ b/apt-cyg
@@ -1388,9 +1388,15 @@ function apt-cyg-show-packages-busyness ()
 
 unset CODEPAGE
 
+function get_codepage_wt_chcp ()
+{
+  comspec /c chcp.com \
+  | awk 'match($NF, /([0-9]+)/, m) { print m[1] == "20127" ? "US-ASCII" : ("CP" m[1]) }'
+}
+
 function get_codepage ()
 {
-  echo -n "${CODEPAGE:=$(comspec /c chcp.com | awk '{printf $NF;}' | sed -E 's/^[^0-9]*([0-9]+).*$/CP\1/g;s/CP20127/US-ASCII/g')}"
+  echo -n "${CODEPAGE:=$(get_codepage_wt_chcp)}"
 }
 
 function cp2utf8 () # [ ...]

From 3a041d8736b876c23959c1183c79f6326814ef15 Mon Sep 17 00:00:00 2001
From: kou1okada 
Date: Sun, 22 Mar 2020 12:47:02 +0900
Subject: [PATCH 242/309] Improve performance for mirror_to_mirrordir.

---
 apt-cyg | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/apt-cyg b/apt-cyg
index 2c30087..968cad5 100755
--- a/apt-cyg
+++ b/apt-cyg
@@ -432,9 +432,10 @@ function current_cygarch ()
   arch | sed -e 's/^i686$/x86/g'
 }
 
-function mirror_to_mirrordir ()
+function mirror_to_mirrordir () # 
 {
-  echo "$1" | sed -e "s/:/%3a/g" -e "s:/:%2f:g"
+  local tmp="${1//:/%3a}"
+  echo "${tmp//\//%2f}"
 }
 
 function setuprc_get_section () # 
From ed4f5584dedb6c5e6d457952390059e6611e9f81 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Sun, 22 Mar 2020 13:01:19 +0900 Subject: [PATCH 243/309] Improve performance for findworkspace. --- apt-cyg | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/apt-cyg b/apt-cyg index 968cad5..9062e42 100755 --- a/apt-cyg +++ b/apt-cyg @@ -438,6 +438,20 @@ function mirror_to_mirrordir () # echo "${tmp//\//%2f}" } +function setuprc_import_sections () #
... +{ + local IFS="|" + cp2utf8 /etc/setup/setup.rc \ + | awk -vRS='\n\\<|\n\\'\' -vFS='\n\t' -vsections="^${*//\\/\\\\}$" ' + match($1, sections) { + s = gensub(/-/, "_", "g", $1) "=(" + for(i = 2; i <= NF; i++) s = s " \x27" $i "\x27"; + s = s " )"; + print s; + } + ' +} + function setuprc_get_section () #
{ cp2utf8 /etc/setup/setup.rc \ @@ -465,8 +479,8 @@ function setuprc_set_section () #
[ ...] function findworkspace() { - readarray -t last_mirror < <(setuprc_get_section last-mirror) - readarray -t last_cache < <(setuprc_get_section last-cache) + eval "$(setuprc_import_sections last-cache last-mirror)" + mirror="$last_mirror" cache="$(cygpath -au "$last_cache")" arch="$(current_cygarch)" From 54d0715bc535e44999e2f9d03da3edb2f96748b3 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Sun, 22 Mar 2020 16:18:18 +0900 Subject: [PATCH 244/309] Improve performance for determining command path. * Replace `which` to `type -p`. --- apt-cyg | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/apt-cyg b/apt-cyg index 9062e42..4c00f07 100755 --- a/apt-cyg +++ b/apt-cyg @@ -158,10 +158,10 @@ TRUSTEDKEY_CYGWINPORTS_URL_LATEST="http://cygwinports.org/ports.gpg" # this script requires some packages -WGET="$( which wget 2>/dev/null )" -TAR="$( which tar 2>/dev/null )" -GAWK="$( which awk 2>/dev/null )" -GPG="$( which gpg 2>/dev/null || which gpg2 2>/dev/null )" +WGET="$( type -p wget 2>/dev/null )" +TAR="$( type -p tar 2>/dev/null )" +GAWK="$( type -p awk 2>/dev/null )" +GPG="$( type -p gpg 2>/dev/null || type -p gpg2 2>/dev/null )" if [ -z "$WGET" -o -z "$TAR" -o -z "$GAWK" ]; then echo You must install wget, tar and gawk to use apt-cyg. exit 1 @@ -599,8 +599,8 @@ function charch () shift chroot "$rootdir" "$rootdir/bin/bash" -lc \ 'cd "$1"; shift ; "$0" "$@"' \ - "$(which "$0" | xargs cygpath -aml | xargs cygpath -u)" \ - "$(pwd | xargs cygpath -aml | xargs cygpath -u)" \ + "$(type -p "$0" | xargs cygpath -aml | xargs cygpath -u)" \ + "$(pwd | xargs cygpath -aml | xargs cygpath -u)" \ "$@" exit $? fi @@ -1216,7 +1216,7 @@ function apt-cyg-completion-install () local __APT_CYG_SUBCMDS local __APT_CYG_OPTIONS - local __APT_CYG_SCRIPTPATH="$(realpath "$(which apt-cyg)")" + local __APT_CYG_SCRIPTPATH="$(realpath "$(type -p apt-cyg)")" local __APT_CYG_SCRIPTDIR="${__APT_CYG_SCRIPTPATH%/*}" local __APT_CYG_COMPLETION_DISABLE_AUTOUPDATE="$OPT_COMPLETION_DISABLE_AUTOUPDATE" @@ -2210,7 +2210,7 @@ verbosefor4=$(verbosefor 4) verbosefor5=$(verbosefor 5) if [ -n "$OPT_AG" ]; then - AG="$( which ag 2>/dev/null )" + AG="$( type -p ag 2>/dev/null )" if [ -z "$AG" ]; then warning "ag is not found. ignore option: $OPT_AG" unset OPT_AG From f5eede5f40744c0868b74d914f4b6863cd170d4c Mon Sep 17 00:00:00 2001 From: kou1okada Date: Sun, 22 Mar 2020 17:41:23 +0900 Subject: [PATCH 245/309] Improve performance for proxy_auto. --- apt-cyg | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apt-cyg b/apt-cyg index 4c00f07..874ecfd 100755 --- a/apt-cyg +++ b/apt-cyg @@ -876,10 +876,10 @@ function apt-cyg-upgrade-self () function proxy_auto () { - local hash="$(ipconfig 2>&1 | md5sum -b | awk '{print $1}')" + local hash=( $(ipconfig |& md5sum -b) ) local cache="/tmp/apt-cyg.proxy.$hash" local last="$(stat -c %Y "$cache" 2>/dev/null)" - local now="$(date +%s)" + local now="$(printf "%(%s)T")" local proxy [ -n "$OPT_PROXY_FORCE_REFRESH" ] && last=0 From 020c4a9ab76e56c09d97853d93c717bf3eaa3278 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Sun, 22 Mar 2020 18:32:28 +0900 Subject: [PATCH 246/309] Improve performance for detecting wget options. --- apt-cyg | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/apt-cyg b/apt-cyg index 874ecfd..4092403 100755 --- a/apt-cyg +++ b/apt-cyg @@ -2197,8 +2197,10 @@ for file in "${OPT_FILES[@]}"; do fi done -wget --help | grep -- --show-progress &>/dev/null && HAVE_SHOW_PROGRESS="--show-progress" -wget --help | grep -- --no-verbose &>/dev/null && HAVE_NO_VERBOSE="--no-verbose" +eval "$(wget --help |& awk ' + /--show-progres/{print "HAVE_SHOW_PROGRESS=--show-progress"} + /--no-verbose/ {print "HAVE_NO_VERBOSE=--no-verbose"} +')" (( "${OPT_VERBOSE_LEVEL}" < 0 )) && WGET+=( --quiet ) || \ (( "${OPT_VERBOSE_LEVEL}" < 1 )) && WGET+=( --quiet $HAVE_SHOW_PROGRESS ) || \ (( "${OPT_VERBOSE_LEVEL}" < 2 )) && WGET+=( $HAVE_NO_VERBOSE $HAVE_SHOW_PROGRESS ) From ca90987b2ea7e1bb71f154ad14ca96a02bc1bd7b Mon Sep 17 00:00:00 2001 From: kou1okada Date: Sun, 22 Mar 2020 18:35:05 +0900 Subject: [PATCH 247/309] Improve performance for verbosefor. * Drop unused variables. --- apt-cyg | 5 ----- 1 file changed, 5 deletions(-) diff --git a/apt-cyg b/apt-cyg index 4092403..e62a45e 100755 --- a/apt-cyg +++ b/apt-cyg @@ -2205,11 +2205,6 @@ eval "$(wget --help |& awk ' (( "${OPT_VERBOSE_LEVEL}" < 1 )) && WGET+=( --quiet $HAVE_SHOW_PROGRESS ) || \ (( "${OPT_VERBOSE_LEVEL}" < 2 )) && WGET+=( $HAVE_NO_VERBOSE $HAVE_SHOW_PROGRESS ) verbosefor0=$(verbosefor 0) -verbosefor1=$(verbosefor 1) -verbosefor2=$(verbosefor 2) -verbosefor3=$(verbosefor 3) -verbosefor4=$(verbosefor 4) -verbosefor5=$(verbosefor 5) if [ -n "$OPT_AG" ]; then AG="$( type -p ag 2>/dev/null )" From 9c4dcf751e33397509a54c9d0151fac78bb0ad14 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Mon, 23 Mar 2020 00:29:57 +0900 Subject: [PATCH 248/309] Improve performance by using named reference. --- apt-cyg | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/apt-cyg b/apt-cyg index e62a45e..202ad12 100755 --- a/apt-cyg +++ b/apt-cyg @@ -718,10 +718,10 @@ function fetch_trustedkeys () local FILE_LATEST="$(mktemp)" for i in "${TRUSTEDKEYS[@]}"; do local LABEL="TRUSTEDKEY_${i}" - local SUM="$(eval echo "\$${LABEL}_SUM")" - local FPR="$(eval echo "\$${LABEL}_FPR")" - local URL="$(eval echo "\$${LABEL}_URL")" - local URL_LATEST="$(eval echo "\$${LABEL}_URL_LATEST")" + local -n SUM="${LABEL}_SUM" + local -n FPR="${LABEL}_FPR" + local -n URL="${LABEL}_URL" + local -n URL_LATEST="${LABEL}_URL_LATEST" local CASE="" if [ -z "$force_fetch_trustedkeys" ] && { "${GPG[@]}" --fingerprint --with-colons | grep -q "$FPR"; } &> $(verbosefor 2); then continue From 62382516e76f7f9a4027755be6a3cec5b5d2c86c Mon Sep 17 00:00:00 2001 From: kou1okada Date: Mon, 23 Mar 2020 00:41:08 +0900 Subject: [PATCH 249/309] Improve performance by using alternative mktemp. --- apt-cyg | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/apt-cyg b/apt-cyg index 202ad12..fcc778c 100755 --- a/apt-cyg +++ b/apt-cyg @@ -384,6 +384,12 @@ function join_str_uniq () # [ ...] join_str "$1" "${str[@]}" } +function mktmpfn () # -v +# Temporary filename +{ + printf ${@:1:2} "/tmp/${SCRIPT_NAME}.$$.%04x%04x" $RANDOM $RANDOM +} + function init_comspec () { : ${SYSTEMPATH:=$(join_str_uniq : "$(cygpath -u "${SYSTEMROOT:-$WINDIR}")"{/system32,} "$PATH")} @@ -714,8 +720,8 @@ function fetch_trustedkeys () { [ -z "$GPG" ] && return local i - local FILE="$(mktemp)" - local FILE_LATEST="$(mktemp)" + local FILE ; mktmpfn -v FILE + local FILE_LATEST; mktmpfn -v FILE_LATEST for i in "${TRUSTEDKEYS[@]}"; do local LABEL="TRUSTEDKEY_${i}" local -n SUM="${LABEL}_SUM" @@ -770,8 +776,8 @@ function fetch_trustedkeys () exit 1 ;; esac + rm "$FILE" "$FILE_LATEST" &>/dev/null done - rm "$FILE" "$FILE_LATEST" } # Usage: verify_signatures files ... @@ -860,7 +866,7 @@ function upgrade-self-with-git () function upgrade-self-with-wget () { local updated_url='https://raw.githubusercontent.com/kou1okada/apt-cyg/master/apt-cyg' # TODO: Do not use MAGIC NUMBER - local temp_file=$(mktemp) + local temp_file; mktmpfn -v temp_file "${WGET[@]}" "${updated_url}" -q -O "$temp_file" chmod +x "$temp_file" { diff "$temp_file" "$SCRIPT_REALPATH" >/dev/null && exit 0; } || cp "$temp_file" "$SCRIPT_REALPATH" @@ -1196,7 +1202,7 @@ function replace_range # [] function replace_module # { - local tmpfile="$(mktemp -u)" + local tmpfile; mktmpfn -v tmpfile local srclines=( $(get_module_line "bash completion for apt-cyg" "$2") ) local dstlines=( $(get_module_line "bash completion for apt-cyg" "$3") ) replace_range "${dstlines[@]}" "$(headtail "${srclines[@]}" "$2")" "$3" > "$tmpfile" @@ -1351,7 +1357,7 @@ function apt-cyg-benchmark-mirrors () function apt-cyg-benchmark-parallel-mirrors () { - local result="$(mktemp --tmpdir "${SCRIPT_NAME}.$$.XXXXX")" + local result; mktmpfn -v result local mirror for mirror; do echo $mirror; done | lesser-parallel apt-cyg-benchmark-mirrors {} | tee "$result" echo Finished benchmark. From 98f57e0e2d50f99ec2b2a93b279c5a21dad9e333 Mon Sep 17 00:00:00 2001 From: a-ueda-lab <62556115+a-ueda-lab@users.noreply.github.com> Date: Tue, 24 Mar 2020 00:55:44 +0900 Subject: [PATCH 250/309] Update pubring.asc SUM&FPR --- apt-cyg | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/apt-cyg b/apt-cyg index 34e665a..d11c409 100755 --- a/apt-cyg +++ b/apt-cyg @@ -141,11 +141,10 @@ init_SGR TRUSTEDKEYS=( CYGWIN CYGWINPORTS ); # ./pubring.asc # ------------ -# pub 1024D/676041BA 2008-06-13 +# pub 4096R/E2E56300 2020-02-27:2022-02-26 # uid Cygwin -# sub 1024g/A1DB7B5C 2008-06-13 -TRUSTEDKEY_CYGWIN_SUM="e6630b94e6bf1afcc1b1054afa9994a423764d795b2a3a5e831fc658962905dcadf63c3a29155136f3138d6375176c9384de68d12a6dd4dde35b55c9b225cd7f" -TRUSTEDKEY_CYGWIN_FPR="1169DF9F22734F743AA59232A9A262FF676041BA" +TRUSTEDKEY_CYGWIN_SUM="6291bf8f958e1ea05501b91d776ea10b2cd781c5caeb3d72da63333e5c45698fa4766d524a2d9a128b09b8446ee7e25cbb7942ee49d7409583e712d5c68ee81e" +TRUSTEDKEY_CYGWIN_FPR="56405CF6FCC81574682A5D561A698DE9E2E56300" TRUSTEDKEY_CYGWIN_URL_LATEST="https://cygwin.com/key/pubring.asc" # ./ports.gpg # ----------- From b591e72d941238d515ebfa1ddf58b99edc13af73 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Tue, 24 Mar 2020 12:20:37 +0900 Subject: [PATCH 251/309] Improve performance for current_cygarch. --- apt-cyg | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apt-cyg b/apt-cyg index fcc778c..aac2707 100755 --- a/apt-cyg +++ b/apt-cyg @@ -435,7 +435,8 @@ function is_official_mirrors_of_cygwin () # ... function current_cygarch () { - arch | sed -e 's/^i686$/x86/g' + local arch="${HOSTTYPE:-$(arch)}" + echo "${arch/i686/x86}" } function mirror_to_mirrordir () # From a58fca1689f8bf6e304198a0665d04dc3884daf1 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Tue, 24 Mar 2020 14:08:02 +0900 Subject: [PATCH 252/309] Improve performance for `mkdir -p`. --- apt-cyg | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/apt-cyg b/apt-cyg index aac2707..cc10e6e 100755 --- a/apt-cyg +++ b/apt-cyg @@ -384,6 +384,11 @@ function join_str_uniq () # [ ...] join_str "$1" "${str[@]}" } +function mkdirp () # +{ + [ -d "$1" ] || mkdir -p "$1" || { error "mkdir failed: $1"; exit 1; } +} + function mktmpfn () # -v # Temporary filename { @@ -499,7 +504,8 @@ function findworkspace() verbose 1 "Cache directory is $cache" verbose 1 "Mirror is $mirror" - mkdir -p "$cache/$mirrordir/$arch" + + mkdirp "$cache/$mirrordir/$arch" cd "$cache/$mirrordir/$arch" init_gnupg @@ -546,7 +552,7 @@ function files_backup_clean () function setupini_download () { local BASEDIR="$cache/$mirrordir/$arch" - mkdir -p "$BASEDIR" || { error "mkdir failed: $BASEDIR"; exit 1; } + mkdirp "$BASEDIR" [ $noscripts -ne 0 -o $noupdate -ne 0 ] && return @@ -1709,7 +1715,7 @@ function download_packages () #= pos section type [package_names ...] local size="${tmp[1]}" local digest="${tmp[2]}" if [ "$pos" = "mirror" ]; then - mkdir -vp "$path" + mkdirp "$path" pushd "$path" fi "${WGET[@]}" -N "$url" @@ -1821,7 +1827,7 @@ function apt-cyg-filesearch () # [] arch="$(current_cygarch)" cachedir="/tmp/.apt-cyg.cache/filesearch" cachequery="$cachedir/$(sha256sum <<<"$1"|awk '$0=$1')" - mkdir -p "$cachedir" + mkdirp "$cachedir" [ ! -e "$cachequery" ] && cygcheck -p "$1" >"$cachequery" readarray -t packages < "$cachequery" @@ -2312,7 +2318,7 @@ function apt-cyg-install () # look for package and save desc file - mkdir -p "release/$pkg" + mkdirp "release/$pkg" awk > "release/$pkg/desc" -v package="$pkg" \ 'BEGIN{RS="\n\n@ "; FS="\n"} {if ($1 == package) {desc = $0; px++}} \ END {if (px == 1 && desc != "") print desc; else print "Package not found"}' \ From fd420843887315122e959354c08ae2169321edcd Mon Sep 17 00:00:00 2001 From: kou1okada Date: Tue, 24 Mar 2020 16:45:01 +0900 Subject: [PATCH 253/309] Rewrite comment of pubring.asc with result of `apt-cyg key-list`. --- apt-cyg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apt-cyg b/apt-cyg index d11c409..3959b9d 100755 --- a/apt-cyg +++ b/apt-cyg @@ -141,7 +141,7 @@ init_SGR TRUSTEDKEYS=( CYGWIN CYGWINPORTS ); # ./pubring.asc # ------------ -# pub 4096R/E2E56300 2020-02-27:2022-02-26 +# pub 4096R/E2E56300 2020-02-27 [expires: 2022-02-26] # uid Cygwin TRUSTEDKEY_CYGWIN_SUM="6291bf8f958e1ea05501b91d776ea10b2cd781c5caeb3d72da63333e5c45698fa4766d524a2d9a128b09b8446ee7e25cbb7942ee49d7409583e712d5c68ee81e" TRUSTEDKEY_CYGWIN_FPR="56405CF6FCC81574682A5D561A698DE9E2E56300" From b6bbe51f52b51250d9fa5e22546f4e2b83fd697d Mon Sep 17 00:00:00 2001 From: kou1okada Date: Tue, 24 Mar 2020 22:11:36 +0900 Subject: [PATCH 254/309] Improve performance for fetch_trustedkeys. --- apt-cyg | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/apt-cyg b/apt-cyg index cc10e6e..6c60b92 100755 --- a/apt-cyg +++ b/apt-cyg @@ -723,12 +723,23 @@ function wget_and_hash_check () echo "$LABEL: OK" } +function get_gpg_fingerprint_to_assoc () # +{ + local -n result="$1" + local line lines + readarray -t lines < <("${GPG[@]}" --with-colons --fingerprint) + for line in "${lines[@]}"; do + [[ "$line" =~ ^fpr:+([0-9A-Za-z]+):* ]] && result[${BASH_REMATCH[1]}]=1 + done +} + function fetch_trustedkeys () { [ -z "$GPG" ] && return local i local FILE ; mktmpfn -v FILE local FILE_LATEST; mktmpfn -v FILE_LATEST + local -A FPRS_assoc; get_gpg_fingerprint_to_assoc FPRS_assoc for i in "${TRUSTEDKEYS[@]}"; do local LABEL="TRUSTEDKEY_${i}" local -n SUM="${LABEL}_SUM" @@ -736,7 +747,7 @@ function fetch_trustedkeys () local -n URL="${LABEL}_URL" local -n URL_LATEST="${LABEL}_URL_LATEST" local CASE="" - if [ -z "$force_fetch_trustedkeys" ] && { "${GPG[@]}" --fingerprint --with-colons | grep -q "$FPR"; } &> $(verbosefor 2); then + if [ -z "$force_fetch_trustedkeys" -a -n "${FPRS_assoc[$FPR]}" ]; then continue fi if [ -n "$URL" ]; then From cc150db65724a6e401d8856ebc71da3c5a8470a2 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Tue, 24 Mar 2020 23:33:27 +0900 Subject: [PATCH 255/309] Improve performance with caching `cp2utf8 /etc/setup/setur.rc`. --- apt-cyg | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/apt-cyg b/apt-cyg index 6c60b92..0aceacf 100755 --- a/apt-cyg +++ b/apt-cyg @@ -450,10 +450,21 @@ function mirror_to_mirrordir () # echo "${tmp//\//%2f}" } +function get_utf8_setuprc () +{ + local utf8_setuprc="$apt_cyg_cachedir/setup.rc.utf8" + mkdirp "$apt_cyg_cachedir" + [ "$utf8_setuprc" -nt /etc/setup/setup.rc ] && { + cat "$utf8_setuprc" + } || { + cp2utf8 /etc/setup/setup.rc | tee "$utf8_setuprc" + } +} + function setuprc_import_sections () #
... { local IFS="|" - cp2utf8 /etc/setup/setup.rc \ + get_utf8_setuprc \ | awk -vRS='\n\\<|\n\\'\' -vFS='\n\t' -vsections="^${*//\\/\\\\}$" ' match($1, sections) { s = gensub(/-/, "_", "g", $1) "=(" @@ -466,7 +477,7 @@ function setuprc_import_sections () #
... function setuprc_get_section () #
{ - cp2utf8 /etc/setup/setup.rc \ + get_utf8_setuprc \ | awk -vRS='\n\\<|\n\\'\' -vFS='\n\t' -vsection="${1//\\/\\\\}" ' $1 == section {for(i = 2; i <= NF; i++) print $i;} ' @@ -1983,6 +1994,7 @@ function apt-cyg-help () # process options +apt_cyg_cachedir="${tmp:-/tmp}/.apt-cyg.cache" noscripts=0 OPT_USER_PICKED=1 noupdate=0 From 905911a78f2f04089026f430e2c88e6812f2b31e Mon Sep 17 00:00:00 2001 From: kou1okada Date: Tue, 24 Mar 2020 23:39:52 +0900 Subject: [PATCH 256/309] Improve performance for findworkspace. * Improve performance by storing variables in the cache. --- apt-cyg | 53 +++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 43 insertions(+), 10 deletions(-) diff --git a/apt-cyg b/apt-cyg index 0aceacf..65d5607 100755 --- a/apt-cyg +++ b/apt-cyg @@ -500,19 +500,52 @@ function setuprc_set_section () #
[ ...] | utf82cp > "$setuprc" } +function set_cachefile () +{ + cachefile="$apt_cyg_cachedir/$FUNCNAME[0]" +} + +function is_cachevars_fresh () # [ ...] +{ + local i + set_cachefile + set -- "$SCRIPT_PATH" "$@" + for i; do + [ "$cachefile" -nt "$i" ] || return 1 + done +} + +function restore_cachevars () # [ ...] +{ + local cachefile + is_cachevars_fresh "$@" || return $? + source "$cachefile" +} + +function save_cachevars () # [ ...] +{ + local cachefile; set_cachefile + declare -p "$@" | sed -E 's/^declare .. //g' >"$cachefile" +} + function findworkspace() { - eval "$(setuprc_import_sections last-cache last-mirror)" + local cachevars=( last_cache last_mirror mirror cache arch mirrordir ) + restore_cachevars /etc/setup/setup.rc || { + eval "$(setuprc_import_sections last-cache last-mirror)" + + mirror="$last_mirror" + cache="$(cygpath -au "$last_cache")" + arch="$(current_cygarch)" + + cache="${cache%/}" + mirror="${mirror%/}" + + mirrordir="$(mirror_to_mirrordir "$mirror/")" + + save_cachevars "${cachevars[@]}" + } - mirror="$last_mirror" - cache="$(cygpath -au "$last_cache")" - arch="$(current_cygarch)" - - cache="${cache%/}" - mirror="${mirror%/}" - - mirrordir="$(mirror_to_mirrordir "$mirror/")" - verbose 1 "Cache directory is $cache" verbose 1 "Mirror is $mirror" From de3e6172b4bc69cf120f86318bb88fbb137f11c2 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Wed, 25 Mar 2020 13:09:47 +0900 Subject: [PATCH 257/309] Brushup for verbose system. --- apt-cyg | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/apt-cyg b/apt-cyg index 65d5607..4a2b94b 100755 --- a/apt-cyg +++ b/apt-cyg @@ -316,15 +316,22 @@ function version () # Usage: verbose [level [msg ...]] function verbose () { - (( "${OPT_VERBOSE_LEVEL}" < "${1:-1}" )) && return - shift - (( 0 < $# )) && echo "$@" || cat + (( OPT_VERBOSE_LEVEL < "${1:-1}" )) && return + (( 1 < $# )) && echo "${@:2}" || cat } >&2 # Usage: verbosefor [level] function verbosefor () { - (( ${OPT_VERBOSE_LEVEL} < ${1:-1} )) && echo "/dev/null" || echo "/dev/stderr" + (( OPT_VERBOSE_LEVEL < ${1:-1} )) && echo /dev/null || echo /dev/stderr +} + +function update_verbosefor () +{ + local i + for i in {0..5}; do + (( OPT_VERBOSE_LEVEL < i )) && verbosefor[i]=/dev/null || verbosefor[i]=/dev/stderr + done } function detect_field_width () @@ -846,7 +853,7 @@ function fetch_trustedkeys () function verify_signatures () { while [ $# -gt 0 ]; do - if ! "${GPG[@]}" --verify "$1" &> $(verbosefor 2); then + if ! "${GPG[@]}" --verify "$1" &>"${verbosefor[2]}"; then error "BAD signature: $1" return 1 else @@ -1566,7 +1573,7 @@ function apt-cyg-update-setup () if download_and_verify "https://cygwin.com/${SETUP_EXE}"; then files_backup_clean "${TARGETS[@]}" chmod +x "${SETUP_EXE}" - ls -l "${SETUP_EXE}" > $(verbosefor 2) + ls -l "${SETUP_EXE}" >"${verbosefor[2]}" else files_restore "${TARGETS[@]}" error "${SETUP_EXE} could not be downloaded: Rollbacked it and aborted." @@ -1909,7 +1916,7 @@ function update_packageof_cache () local n="$(ls -1 /etc/setup/*.lst.gz|wc -l)" if (( cache_stamp < lstgz_stamp )) || [ -n "$OPT_FORCE_UPDATE_PACKAGEOF_CACHE" ]; then - verbose 1 "Updating packageof cache:" >&2 + verbose 1 "Updating packageof cache:" progress_init for path in /etc/setup/*.lst.gz; do progress_update $(( i++ )) $n @@ -1927,7 +1934,7 @@ function progress_init () [ -n "$OPT_NO_PROGRESS" ] && return # 0 1 2 3 4 5 # 12345678901234567890123456789012345678901234567890 - echo -ne "|..................................................|\r" >"$verbosefor0" + echo -ne "|..................................................|\r" >"${verbosefor[0]}" } function progress_update () #= current total=100 @@ -1937,16 +1944,16 @@ function progress_update () #= current total=100 local p=$((2 + 50 * ($1 ) / $n)) local q=$((2 + 50 * ($1 + 1) / $n)) if (( q - p <= 1 )); then - printf "\e[%dG%s" $p "${PROGRESS_CHAR[($1 % 4 + 1) * (1 + $p - $q)]}" >"$verbosefor0" + printf "\e[%dG%s" $p "${PROGRESS_CHAR[($1 % 4 + 1) * (1 + $p - $q)]}" >"${verbosefor[0]}" else - printf "\e[%dG%s" $p "$(seq $((q - p))|awk '{printf "="}')" >"$verbosefor0" + printf "\e[%dG%s" $p "$(seq $((q - p))|awk '{printf "="}')" >"${verbosefor[0]}" fi } function progress_finish () { [ -n "$OPT_NO_PROGRESS" ] && return - echo >"$verbosefor0" + echo >"${verbosefor[0]}" } # Lesser Parallel for Embedding @@ -2273,7 +2280,8 @@ eval "$(wget --help |& awk ' (( "${OPT_VERBOSE_LEVEL}" < 0 )) && WGET+=( --quiet ) || \ (( "${OPT_VERBOSE_LEVEL}" < 1 )) && WGET+=( --quiet $HAVE_SHOW_PROGRESS ) || \ (( "${OPT_VERBOSE_LEVEL}" < 2 )) && WGET+=( $HAVE_NO_VERBOSE $HAVE_SHOW_PROGRESS ) -verbosefor0=$(verbosefor 0) + +update_verbosefor if [ -n "$OPT_AG" ]; then AG="$( type -p ag 2>/dev/null )" From 367fb5b38c5da31cd2a3c9eabfbf2037b65e0bee Mon Sep 17 00:00:00 2001 From: kou1okada Date: Wed, 25 Mar 2020 16:29:14 +0900 Subject: [PATCH 258/309] Improve performance for initialization about wget. --- apt-cyg | 53 +++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 37 insertions(+), 16 deletions(-) diff --git a/apt-cyg b/apt-cyg index 4a2b94b..c43c510 100755 --- a/apt-cyg +++ b/apt-cyg @@ -565,10 +565,10 @@ function findworkspace() function download_and_verify () { - "${WGET[@]}" -N "$1" || return 1 + wget -N "$1" || return 1 [ -e "${1##*/}" ] || return 1 if [ -z "$no_verify" ]; then - "${WGET[@]}" -N "${1}.sig" || return 1 + wget -N "${1}.sig" || return 1 [ -e "${1##*/}.sig" ] && verify_signatures "${1##*/}.sig" || { rm -f "${1##*/}" "${1##*/}.sig"; return 1; } fi return @@ -704,6 +704,32 @@ function ask_user () done } +unset INIT_WGET +function init_wget () +{ + [ -n "$INIT_WGET" ] && return + + eval "$( + "$WGET" --help \ + |& awk ' + /--show-progres/{print "HAVE_SHOW_PROGRESS=--show-progress"} + /--no-verbose/ {print "HAVE_NO_VERBOSE=--no-verbose"} + ')" + (( OPT_VERBOSE_LEVEL < 0 )) && WGET+=( --quiet ) || \ + (( OPT_VERBOSE_LEVEL < 1 )) && WGET+=( --quiet $HAVE_SHOW_PROGRESS ) || \ + (( OPT_VERBOSE_LEVEL < 2 )) && WGET+=( $HAVE_NO_VERBOSE $HAVE_SHOW_PROGRESS ) + + proxy_setup + + INIT_WGET=DONE +} + +function wget () +{ + init_wget + "${WGET[@]}" "$@" +} + # Reference: # https://www.gnu.org/software/wget/manual/wget.html#Exit-Status # Usage: wget-exitstatus EXITSTATUS @@ -763,7 +789,7 @@ function wget_and_hash_check () local SUM="$2" local URL="$3" local FILE="$4" - if ! { "${WGET[@]}" "$URL" -O "$FILE" || get_advice wget; }; then + if ! { wget "$URL" -O "$FILE" || get_advice wget; }; then echo "$LABEL: FAILED: Could not download $URL." return 1 fi @@ -936,7 +962,7 @@ function upgrade-self-with-wget () { local updated_url='https://raw.githubusercontent.com/kou1okada/apt-cyg/master/apt-cyg' # TODO: Do not use MAGIC NUMBER local temp_file; mktmpfn -v temp_file - "${WGET[@]}" "${updated_url}" -q -O "$temp_file" + wget "${updated_url}" -q -O "$temp_file" chmod +x "$temp_file" { diff "$temp_file" "$SCRIPT_REALPATH" >/dev/null && exit 0; } || cp "$temp_file" "$SCRIPT_REALPATH" rm "$temp_file" @@ -983,8 +1009,10 @@ function proxy_unset () export -n ftp_proxy } +unset PROXY_SETUP function proxy_setup () { + [ -n "$PROXY_SETUP" ] && return case "$OPT_PROXY" in auto) proxy_auto @@ -998,10 +1026,12 @@ function proxy_setup () proxy_set "$OPT_PROXY" ;; esac + PROXY_SETUP=DONE } function apt-cyg-get-proxy () { + proxy_setup declare -p ftp_proxy http_proxy https_proxy } @@ -1780,7 +1810,7 @@ function download_packages () #= pos section type [package_names ...] mkdirp "$path" pushd "$path" fi - "${WGET[@]}" -N "$url" + wget -N "$url" if ! hash_check <<<"${digest} *${file}" ; then error "hash did not match: $file" fi @@ -2174,7 +2204,7 @@ function parse_args () ;; --ipv4|-4) - WGET=( "${WGET[@]}" "--prefer-family=IPv4" ) + WGET+=( "--prefer-family=IPv4" ) shift ;; @@ -2273,14 +2303,6 @@ for file in "${OPT_FILES[@]}"; do fi done -eval "$(wget --help |& awk ' - /--show-progres/{print "HAVE_SHOW_PROGRESS=--show-progress"} - /--no-verbose/ {print "HAVE_NO_VERBOSE=--no-verbose"} -')" -(( "${OPT_VERBOSE_LEVEL}" < 0 )) && WGET+=( --quiet ) || \ -(( "${OPT_VERBOSE_LEVEL}" < 1 )) && WGET+=( --quiet $HAVE_SHOW_PROGRESS ) || \ -(( "${OPT_VERBOSE_LEVEL}" < 2 )) && WGET+=( $HAVE_NO_VERBOSE $HAVE_SHOW_PROGRESS ) - update_verbosefor if [ -n "$OPT_AG" ]; then @@ -2407,7 +2429,7 @@ function apt-cyg-install () local file="$(basename "$install")" cd "release/$pkg" - "${WGET[@]}" -Nc $mirror/$install + wget -Nc $mirror/$install # check the SHA512 hash local digest="$(awk '/^install: / { print $4; exit }' "desc")" @@ -2529,5 +2551,4 @@ function invoke_subcommand () "\nNote that some functions, which require access to current directory, will be failed." } -proxy_setup invoke_subcommand "$SUBCOMMAND" "${ARGS[@]}" From bbbc903dd298e7db6c0a2e4d0e42aaee7723a1e7 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Wed, 25 Mar 2020 20:49:50 +0900 Subject: [PATCH 259/309] Bugfix: bash_completion. * Could not complete file name including space. * Could not complete mirror. * Could not get subcommand under time command. --- apt-cyg | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/apt-cyg b/apt-cyg index c43c510..8210cbd 100755 --- a/apt-cyg +++ b/apt-cyg @@ -1338,12 +1338,12 @@ function apt-cyg-completion-install () ) cat <<-EOD > /etc/bash_completion.d/apt-cyg - $(declare -p __APT_CYG_{SUBCMDS,OPTIONS,SCRIPTPATH,SCRIPTDIR,COMPLETION_DISABLE_AUTOUPDATE} | sed -re 's/^declare/\0 -g/g') + $(declare -p __APT_CYG_{SUBCMDS,OPTIONS,SCRIPTPATH,SCRIPTDIR,COMPLETION_DISABLE_AUTOUPDATE} | sed -E 's/^declare/\0 -g/g') # BEGIN_MODULE: bash completion for apt-cyg # END_MODULE: bash completion for apt-cyg - complete -F __apt-cyg apt-cyg + complete -o filenames -F __apt-cyg apt-cyg EOD replace_module "bash completion for apt-cyg" "${BASH_SOURCE}" /etc/bash_completion.d/apt-cyg @@ -1368,7 +1368,7 @@ function __apt-cyg () _get_comp_words_by_ref -n : cur prev - getsubcmd=( apt-cyg --completion-get-subcommand $(echo "${COMP_LINE}" | sed -r -e 's/^[^ \t]+//g' -e 's/[^ \t]+$//g') ) + getsubcmd=( apt-cyg --completion-get-subcommand $(echo "${COMP_LINE}" | sed -E 's/^[ \t]*[^ \t]+//g;s/[^ \t]+$//g') ) subcmd="$( "${getsubcmd[@]}" )" case "$subcmd" in @@ -1382,7 +1382,7 @@ function __apt-cyg () COMPREPLY=( cache mirror mirrordir cache/mirrordir setup.ini ) ;; *) - COMPREPLY=( "${__APT_CYG_SUBCMDS[*]}" ) + COMPREPLY=( "${__APT_CYG_SUBCMDS[@]}" ) ;; esac case "$prev" in @@ -1390,36 +1390,38 @@ function __apt-cyg () COMPREPLY=( x86 x86_64 ) ;; --cache|-c) - COMPREPLY=( $(compgen -d -- "$cur") ) + readarray -t COMPREPLY < <(compgen -d -- "$cur") ;; --mirror|-m) - COMPREPLY=( $(awk '/^[^ \t]+/{section=\$1}section=="mirrors-lst"&&match(\$0,/^[ \t]+([^;]+);/,m){print "\""m[1]"\""}' "/etc/setup/setup.rc") ) + COMPREPLY=( $(apt-cyg mirrors-list) ) ;; --file|-f) - COMPREPLY=( $(compgen -f -- "$cur") ) + readarray -t COMPREPLY < <(compgen -f -- "$cur") ;; --proxy|-p) COMPREPLY=( auto inherit none http:// ) ;; *) - COMPREPLY+=( "${__APT_CYG_OPTIONS[*]}" ) + COMPREPLY+=( "${__APT_CYG_OPTIONS[@]}" ) ;; esac if [ -n "$DEBUG_COMPLETION" ]; then echo - echo "COMP_WORDBREAKS: $COMP_WORDBREAKS" - echo "getsubcmd: '${getsubcmd[@]}'" - echo "subcmd: '${subcmd[@]}'" - echo "COMP_LINE: '${COMP_LINE}'" - echo "cur: $cur" - echo "prev: $prev" - echo "COMP_WORDS: ${COMP_WORDS[@]}" + echo "COMP_WORDBREAKS: ${COMP_WORDBREAKS@Q}" + echo "getsubcmd: ${getsubcmd[@]@Q}" + echo "subcmd: ${subcmd[@]@Q}" + echo "COMP_LINE: ${COMP_LINE@Q}" + echo "cur: ${cur@Q}" + echo "prev: ${prev@Q}" + echo "COMP_WORDS: ${COMP_WORDS[@]@Q}" echo "#COMPREPLY[@]: ${#COMPREPLY[@]}" + echo "COMPREPLY[@]: ${COMPREPLY[@]@Q}" + echo "BASH_SOURCE[@]: ${BASH_SOURCE[@]@Q}" echo echo -n "${COMP_LINE}" fi - COMPREPLY=( $(compgen -W "${COMPREPLY[*]}" -- "$cur") ) + readarray -t COMPREPLY < <(compgen -W "${COMPREPLY[*]@Q}" -- "$cur") __ltrim_colon_completions "$cur" } From ff161999f2ea574e1ba20d722d3dbce818608764 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Fri, 27 Mar 2020 18:33:56 +0900 Subject: [PATCH 260/309] Improve DEBUG_COMPLETION. --- apt-cyg | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/apt-cyg b/apt-cyg index 8210cbd..78e5900 100755 --- a/apt-cyg +++ b/apt-cyg @@ -1407,19 +1407,11 @@ function __apt-cyg () esac if [ -n "$DEBUG_COMPLETION" ]; then echo - echo "COMP_WORDBREAKS: ${COMP_WORDBREAKS@Q}" - echo "getsubcmd: ${getsubcmd[@]@Q}" - echo "subcmd: ${subcmd[@]@Q}" - echo "COMP_LINE: ${COMP_LINE@Q}" - echo "cur: ${cur@Q}" - echo "prev: ${prev@Q}" - echo "COMP_WORDS: ${COMP_WORDS[@]@Q}" - echo "#COMPREPLY[@]: ${#COMPREPLY[@]}" - echo "COMPREPLY[@]: ${COMPREPLY[@]@Q}" - echo "BASH_SOURCE[@]: ${BASH_SOURCE[@]@Q}" - echo + declare -p BASH_SOURCE "${!COMP@}" getsubcmd subcmd cur prev + echo -n "${PS1@P}" + [[ "$COMP_LINE" =~ ^\ ]] && echo -n "time" # maybe... echo -n "${COMP_LINE}" - + (( ${#COMP_LINE} - COMP_POINT )) && echo -ne "\e[$(( ${#COMP_LINE} - COMP_POINT ))D" fi readarray -t COMPREPLY < <(compgen -W "${COMPREPLY[*]@Q}" -- "$cur") __ltrim_colon_completions "$cur" From d5611cb353fc882b7c9c4af8551dc147a8474443 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Fri, 27 Mar 2020 22:59:56 +0900 Subject: [PATCH 261/309] Reconstruct download_and_verify. --- apt-cyg | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/apt-cyg b/apt-cyg index 78e5900..68985e5 100755 --- a/apt-cyg +++ b/apt-cyg @@ -563,15 +563,14 @@ function findworkspace() fetch_trustedkeys } -function download_and_verify () +function download_and_verify () # { - wget -N "$1" || return 1 - [ -e "${1##*/}" ] || return 1 + local urls=( "$1"{,.sig} ) + wget -N "${urls[@]}" || return 1 if [ -z "$no_verify" ]; then - wget -N "${1}.sig" || return 1 - [ -e "${1##*/}.sig" ] && verify_signatures "${1##*/}.sig" || { rm -f "${1##*/}" "${1##*/}.sig"; return 1; } + [ -e "${1##*/}.sig" ] && verify_signatures "${1##*/}.sig" || return 1 fi - return + [ -e "${1##*/}" ] } function files_backup () From 9b08900b4715d751472f2911ff313c54fae25ed4 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Sat, 25 Apr 2020 18:03:06 +0900 Subject: [PATCH 262/309] Bugfix: naming rule of cachefile is incorrect in `set_cachefile`. --- apt-cyg | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/apt-cyg b/apt-cyg index 68985e5..f15d286 100755 --- a/apt-cyg +++ b/apt-cyg @@ -509,13 +509,12 @@ function setuprc_set_section () #
[ ...] function set_cachefile () { - cachefile="$apt_cyg_cachedir/$FUNCNAME[0]" + cachefile="$apt_cyg_cachedir/cachefile_for_vars_of_${FUNCNAME[2]}" } function is_cachevars_fresh () # [ ...] { local i - set_cachefile set -- "$SCRIPT_PATH" "$@" for i; do [ "$cachefile" -nt "$i" ] || return 1 @@ -524,7 +523,7 @@ function is_cachevars_fresh () # [ ...] function restore_cachevars () # [ ...] { - local cachefile + local cachefile; set_cachefile is_cachevars_fresh "$@" || return $? source "$cachefile" } From bb85851880857e6784826d653550761fa16fa5f4 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Sat, 25 Apr 2020 18:35:58 +0900 Subject: [PATCH 263/309] Refactoring about cachevars. --- apt-cyg | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/apt-cyg b/apt-cyg index f15d286..d795ac4 100755 --- a/apt-cyg +++ b/apt-cyg @@ -507,28 +507,28 @@ function setuprc_set_section () #
[ ...] | utf82cp > "$setuprc" } -function set_cachefile () +function set_cachefile () # +# Set filename of cachevars to $cachefile. +# Returns: +# $cachefile : Overwrite with filename of cachevars. +# Note: +# This is internal function for load_vars_from_cache and save_vars_to_cache. { - cachefile="$apt_cyg_cachedir/cachefile_for_vars_of_${FUNCNAME[2]}" + cachefile="$apt_cyg_cachedir/cache_for_vars_of_${FUNCNAME[2]}" } -function is_cachevars_fresh () # [ ...] +function load_vars_from_cache () # [ ...] || { init_vars ...; save_vars_to_cache [ ...]; } +# restore vars from cache. { + local cachefile; set_cachefile local i set -- "$SCRIPT_PATH" "$@" - for i; do - [ "$cachefile" -nt "$i" ] || return 1 - done -} - -function restore_cachevars () # [ ...] -{ - local cachefile; set_cachefile - is_cachevars_fresh "$@" || return $? + for i; do [ "$cachefile" -nt "$i" ] || return 1; done source "$cachefile" } -function save_cachevars () # [ ...] +function save_vars_to_cache () # [ ...] +# save vars to cache. { local cachefile; set_cachefile declare -p "$@" | sed -E 's/^declare .. //g' >"$cachefile" @@ -537,7 +537,7 @@ function save_cachevars () # [ ...] function findworkspace() { local cachevars=( last_cache last_mirror mirror cache arch mirrordir ) - restore_cachevars /etc/setup/setup.rc || { + load_vars_from_cache /etc/setup/setup.rc || { eval "$(setuprc_import_sections last-cache last-mirror)" mirror="$last_mirror" @@ -549,7 +549,7 @@ function findworkspace() mirrordir="$(mirror_to_mirrordir "$mirror/")" - save_cachevars "${cachevars[@]}" + save_vars_to_cache "${cachevars[@]}" } verbose 1 "Cache directory is $cache" From 1ad6e89fb8d4eadc5e90e1ccf76058b68a2d8b01 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Sat, 25 Apr 2020 18:45:45 +0900 Subject: [PATCH 264/309] Improve performance for updating "setup.ini". * Move `is_official_mirrors_of_cygwin` from `getsetup` to `apt-cyg-set-mirror`. --- apt-cyg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apt-cyg b/apt-cyg index d795ac4..65f6e14 100755 --- a/apt-cyg +++ b/apt-cyg @@ -626,7 +626,6 @@ function setupini_download () function getsetup () { - is_official_mirrors_of_cygwin "$mirror" setupini_download || return 1 } @@ -1870,6 +1869,7 @@ function apt-cyg-set-mirror () # [ ...] { set -- "${@%/}" (( 0 < $# )) && setuprc_set_section last-mirror "${@/%/\/}" + is_official_mirrors_of_cygwin "${@/%/\/}" } function apt-cyg-mark-auto () # [ ...] From 9c407e2c201da2c7ba8f633bebb8d63d6594dc3f Mon Sep 17 00:00:00 2001 From: kou1okada Date: Sat, 25 Apr 2020 21:21:27 +0900 Subject: [PATCH 265/309] Add `mirrors-list-online` subcommand. --- README.md | 1 + apt-cyg | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e973aaf..63aae0c 100755 --- a/README.md +++ b/README.md @@ -32,6 +32,7 @@ Usage | `completion-install` | to install completion. | | `completion-uninstall` | to uninstall completion. | | `mirrors-list` | to show list of mirrors. | +| `mirrors-list-online` | to show list of mirrors from online. | | `benchmark-mirrors ...` | to benchmark mirrors. | | `benchmark-parallel-mirrors ...` | to benchmark mirrors in parallel. | | `benchmark-parallel-mirrors-list` | to benchmark mirrors-list in parallel. | diff --git a/apt-cyg b/apt-cyg index 65f6e14..5be1076 100755 --- a/apt-cyg +++ b/apt-cyg @@ -197,6 +197,7 @@ function usage() completion-install : to install completion. completion-uninstall : to uninstall completion. mirrors-list : to show list of mirros. + mirrors-list-online : to show list of mirros from online. benchmark-mirrors ... : to benchmark mirrors. benchmark-parallel-mirrors ... : @@ -420,6 +421,13 @@ function cygstart () # [ ...] PATH="$SYSTEMPATH" cygstart.exe "$@" } +function update_cache_for_mirrors_list_online () +{ + pushd "$apt_cyg_cachedir" >/dev/null + wget -qN https://cygwin.com/mirrors.lst + popd >/dev/null +} + function is_official_mirrors_of_cygwin () # ... # Check whether are listed in official mirrors list of cygwin. # Official mirros list provides on https://cygwin.com/mirrors.html. @@ -431,7 +439,7 @@ function is_official_mirrors_of_cygwin () # ... local mirror local result=0 local local_list="$(apt-cyg-mirrors-list)" - local online_list="$(wget -qO- https://cygwin.com/mirrors.lst)" + local online_list="$(apt-cyg-mirrors-list-online)" for mirror; do if ! grep -q "$mirror" <<< "$local_list"; then warning "/etc/setup/setup.rc doesn't know your mirror: ${SGR_bold}$mirror${SGR_reset}" >&2 @@ -1431,6 +1439,12 @@ function apt-cyg-mirrors-list () setuprc_get_section mirrors-lst | sed -re 's/;.*//g' } +function apt-cyg-mirrors-list-online () +{ + update_cache_for_mirrors_list_online + cat "${apt_cyg_cachedir}/mirrors.lst" +} + function apt-cyg-benchmark-mirrors () { local mirror result exitcode From 9642502133bcd6049d594812ec609940b84106a5 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Mon, 27 Apr 2020 15:14:38 +0900 Subject: [PATCH 266/309] Remove a gpg key of Cygwin Ports from TRUSTEDKEYS. * Because http://cygwinports.org/ became unavailable. * This commit is related to issue #67. --- apt-cyg | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/apt-cyg b/apt-cyg index 3959b9d..b05db08 100755 --- a/apt-cyg +++ b/apt-cyg @@ -138,7 +138,7 @@ init_SGR # EMBED_END: hhs_embed -TRUSTEDKEYS=( CYGWIN CYGWINPORTS ); +TRUSTEDKEYS=( CYGWIN ); # ./pubring.asc # ------------ # pub 4096R/E2E56300 2020-02-27 [expires: 2022-02-26] @@ -146,14 +146,6 @@ TRUSTEDKEYS=( CYGWIN CYGWINPORTS ); TRUSTEDKEY_CYGWIN_SUM="6291bf8f958e1ea05501b91d776ea10b2cd781c5caeb3d72da63333e5c45698fa4766d524a2d9a128b09b8446ee7e25cbb7942ee49d7409583e712d5c68ee81e" TRUSTEDKEY_CYGWIN_FPR="56405CF6FCC81574682A5D561A698DE9E2E56300" TRUSTEDKEY_CYGWIN_URL_LATEST="https://cygwin.com/key/pubring.asc" -# ./ports.gpg -# ----------- -# pub 1024D/66EE1F94 2008-10-27 -# uid Yaakov Selkowitz (Cygwin Ports) -# sub 4096g/7D66B0D2 2008-10-27 -TRUSTEDKEY_CYGWINPORTS_SUM="ccf174d1e6ec20e50ff954e3d4a0c3de478032a100d26789c0190587ae80128e842ff5404ed3b48f8693c8803c88a3acbf8dca339edfdaab0f3c247fb6091e42" -TRUSTEDKEY_CYGWINPORTS_FPR="45600BB98CA878AA97A70119FF20AF9A66EE1F94" -TRUSTEDKEY_CYGWINPORTS_URL_LATEST="http://cygwinports.org/ports.gpg" # this script requires some packages From 0c0b871207e8321e6bed5c5e517d170886196ba3 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Sun, 24 May 2020 22:18:53 +0900 Subject: [PATCH 267/309] Add `mirrors-list-long` subcommand. * Print the full details of the mirror. * This commit is related to issue #69. --- apt-cyg | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/apt-cyg b/apt-cyg index b05db08..9f356c4 100755 --- a/apt-cyg +++ b/apt-cyg @@ -1311,6 +1311,11 @@ function apt-cyg-mirrors-list () setuprc_get_section mirrors-lst | sed -re 's/;.*//g' } +function apt-cyg-mirrors-list-long () +{ + setuprc_get_section mirrors-lst | column -t -s ";" +} + function apt-cyg-benchmark-mirrors () { local mirror result exitcode From 1308fa13165673f8c93cd6593c2da5a65a459fc1 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Sun, 24 May 2020 22:29:49 +0900 Subject: [PATCH 268/309] Update help and `README.md`. --- README.md | 1 + apt-cyg | 1 + 2 files changed, 2 insertions(+) diff --git a/README.md b/README.md index e973aaf..acbfb93 100755 --- a/README.md +++ b/README.md @@ -32,6 +32,7 @@ Usage | `completion-install` | to install completion. | | `completion-uninstall` | to uninstall completion. | | `mirrors-list` | to show list of mirrors. | +| `mirrors-list-long` | to show list of mirros with full details. | | `benchmark-mirrors ...` | to benchmark mirrors. | | `benchmark-parallel-mirrors ...` | to benchmark mirrors in parallel. | | `benchmark-parallel-mirrors-list` | to benchmark mirrors-list in parallel. | diff --git a/apt-cyg b/apt-cyg index 9f356c4..5783f0b 100755 --- a/apt-cyg +++ b/apt-cyg @@ -188,6 +188,7 @@ function usage() completion-install : to install completion. completion-uninstall : to uninstall completion. mirrors-list : to show list of mirros. + mirrors-list-long : to show list of mirros with full details. benchmark-mirrors ... : to benchmark mirrors. benchmark-parallel-mirrors ... : From 502aa3d63afa1dc70b82d5c1a73559cacc4e88e3 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Tue, 14 Jul 2020 17:14:18 +0900 Subject: [PATCH 269/309] Bugfix for issue #70. * `grep $category` must be applied to "$category" not "$category $pkg". --- apt-cyg | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apt-cyg b/apt-cyg index b05db08..804bf3f 100755 --- a/apt-cyg +++ b/apt-cyg @@ -2225,11 +2225,11 @@ function apt-cyg-find () } -function apt-cyg-category () +function apt-cyg-category () # +# List all packages in given . { apt-cyg-ls-pkg-with-category \ - | grep "$@" \ - | awk '$0=$2' + | awk -vcategory="$1" '$1==category {print $2}' } From 622bcf6798261dfb45e29b48d9dfa493842960cb Mon Sep 17 00:00:00 2001 From: kou1okada Date: Tue, 14 Jul 2020 18:07:05 +0900 Subject: [PATCH 270/309] Update `README.md`. * Forgetting to add a help for `category` subcommand. --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index acbfb93..8464380 100755 --- a/README.md +++ b/README.md @@ -53,6 +53,7 @@ Usage | `get-proxy` | Get proxies for eval. | | `ls-categories` | List categories. | | `ls-pkg-with-category` | List packages with category. | +| `category ` | List all packages in given \.| | `setuprc-get
` | Get section from **`setup.rc`**. | | `set-cache []` | Set cache. | | `set-mirror [ ...]` | Set mirrors. Note: `setup-x86{,_64}.exe` uses all of them but currently `apt-cyg` uses the first one only. | From 60ff08735e62729a6c99b5c94996a5119292a5db Mon Sep 17 00:00:00 2001 From: Leo Date: Sat, 25 Jul 2020 22:07:01 +0300 Subject: [PATCH 271/309] README.md: archetecture -> architecture --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index cf06a84..2caa273 100755 --- a/README.md +++ b/README.md @@ -46,7 +46,7 @@ Usage | `packages-total-size []` | count size of total packages from setup.ini | | `packages-cached-count` | count number of cached packages in cache/mirrordir. | | `packages-cached-size` | count size of cached packages in cache/mirrordir. | -| `repair-acl` | repair the windows ACL (Access Control List). | +| `repair-acl` | to repair the windows ACL (Access Control List). | | `source ...` | download source archive. | | `download ...` | download the binary package into the current directory. | | `mirror ...` | download the binary package into the current cache/mirrordir as mirror. | @@ -71,7 +71,7 @@ Usage | Option | Description | |:------ |:----------- | | `--ag` | use the silver searcher (currently work only at packageof subcommand) | -| `--charch ` | change archetecture | +| `--charch ` | change architecture | | `--ignore-case`, `-i` | ignore case distinctions for `` | | `--force-remove` | force remove | `--force-fetch-trustedkeys` | force fetch trustedkeys | From f1241f98e0f25f870af21ca169451522e1554c06 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Tue, 22 Sep 2020 15:20:50 +0900 Subject: [PATCH 272/309] Typo: archetecture -> architecture --- apt-cyg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apt-cyg b/apt-cyg index 574729f..ecc1438 100755 --- a/apt-cyg +++ b/apt-cyg @@ -248,7 +248,7 @@ function usage() Options: --ag : use the silver searcher (currently work only at packageof subcommand) - --charch : change archetecture + --charch : change architecture --ignore-case, -i : ignore case distinctions for --force-remove : force remove --force-fetch-trustedkeys : From b7ff2ef6d5004d9ca3bd3609a1129a228015d532 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Tue, 22 Sep 2020 15:58:02 +0900 Subject: [PATCH 273/309] Skip to get trusted key when use `--no-verify` option. --- apt-cyg | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/apt-cyg b/apt-cyg index ecc1438..fb29f0c 100755 --- a/apt-cyg +++ b/apt-cyg @@ -669,7 +669,7 @@ function charch () function init_gnupg () { - [ -z "$GPG" ] && return + [ -z "$GPG" -o -n "$no_verify" ] && return export GNUPGHOME="$cache/.apt-cyg" if [ ! -d "$GNUPGHOME" ]; then if ! { mkdir -p "$GNUPGHOME" && chmod 700 "$GNUPGHOME"; } then @@ -809,7 +809,7 @@ function get_gpg_fingerprint_to_assoc () # function fetch_trustedkeys () { - [ -z "$GPG" ] && return + [ -z "$GPG" -o -n "$no_verify" ] && return local i local FILE ; mktmpfn -v FILE local FILE_LATEST; mktmpfn -v FILE_LATEST @@ -1617,7 +1617,7 @@ function apt-cyg-update-setup () function apt-cyg-setup () { - pushd "$(apt-cyg pathof cache)" > /dev/null + pushd "$(apt-cyg-pathof cache)" > /dev/null local setup=( "$PWD/${SETUP_EXE}" -R "$(cygpath -wa /)" "$@" ) @@ -1656,7 +1656,7 @@ function apt-cyg-dist-upgrade () function apt-cyg-packages-total-count () { - grep ^@ <"$(apt-cyg pathof setup.ini)" | wc -l + grep ^@ <"$(apt-cyg-pathof setup.ini)" | wc -l } # Usage: apt-cyg-packages-total-size [pattern_of_section] @@ -1670,19 +1670,19 @@ function apt-cyg-packages-total-size () match($0,/^\[([ -~]*)\] *$/,m) {section = m[1]} match(section, SECTION) && $1 == "install:" {sum += $3} END {print sum} - ' "$(apt-cyg pathof setup.ini)" + ' "$(apt-cyg-pathof setup.ini)" } function apt-cyg-packages-cached-count () { - pushd "$(apt-cyg pathof cache/mirrordir)" > /dev/null + pushd "$(apt-cyg-pathof cache/mirrordir)" > /dev/null find . -type f | grep tar | wc -l popd > /dev/null } function apt-cyg-packages-cached-size () { - pushd "$(apt-cyg pathof cache/mirrordir)" > /dev/null + pushd "$(apt-cyg-pathof cache/mirrordir)" > /dev/null find . -type f -iname '*tar*' -exec ls -l {} + \ | awk '{sum+=$5}END{print sum}' popd > /dev/null @@ -1787,7 +1787,7 @@ function download_packages () #= pos section type [package_names ...] here) ;; mirror) - cd "$(apt-cyg pathof cache/mirrordir)" + cd "$(apt-cyg-pathof cache/mirrordir)" ;; *) error "unknown param: $pos" @@ -1795,7 +1795,7 @@ function download_packages () #= pos section type [package_names ...] ;; esac - local mirror="$(apt-cyg pathof mirror)" + local mirror="$(apt-cyg-pathof mirror)" local line local pkgs="$(get_archives_list "$section" "$type" "$@")" local total="$(echo "$pkgs" | awk '{sum+=$2}END{print sum;}')" From a7523e4dc1a531bb8c95f7e9613958f0f76011b8 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Thu, 26 Nov 2020 13:35:50 +0900 Subject: [PATCH 274/309] Add `filelist` subcommand. --- README.md | 1 + apt-cyg | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/README.md b/README.md index 2caa273..b72ad86 100755 --- a/README.md +++ b/README.md @@ -64,6 +64,7 @@ Usage | `mark-showmanual` | Print the list of manually installed packages. | | `call [ [ ...]]` | Call internal function in apt-cyg. | | `time [ [ ...]]` | Report time consumed to call internal function in apt-cyg. | +| `filelist []` | File list line apt-file list. | | `filesearch []` | File search like apt-file search. | ### Options diff --git a/apt-cyg b/apt-cyg index fb29f0c..1f714fb 100755 --- a/apt-cyg +++ b/apt-cyg @@ -244,6 +244,7 @@ function usage() time [ [ ...]] : Report time consumed to call internal function in apt-cyg. + filelist [] : File list line apt-file list. filesearch [] : File search like apt-file search. Options: --ag : use the silver searcher @@ -1915,6 +1916,24 @@ function apt-cyg-time () # [ [ ...]] time "$@" } +function apt-cyg-filelist () # [] +# File list like apt-file list +{ + local arch list_rel_urls + arch="$(current_cygarch)" + readarray -t list_rel_urls < <( + wget -qO- "https://cygwin.com/packages/summary/${1}.html" \ + | grep -E ']*>list of files' \ + | sed -E 's:.*$/,/^<\/pre>$/' | tail -n+2 | head -n-1 \ + | awk -vpkg="$1" '$0=pkg": /"$4' + fi +} + function apt-cyg-filesearch () # [] # File search like apt-file search { From cf882601e718e9390ffa0c421345b9f197d6bf18 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Mon, 1 Mar 2021 20:52:01 +0900 Subject: [PATCH 275/309] Fix typo --- README.md | 2 +- apt-cyg | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b72ad86..d7ec23c 100755 --- a/README.md +++ b/README.md @@ -64,7 +64,7 @@ Usage | `mark-showmanual` | Print the list of manually installed packages. | | `call [ [ ...]]` | Call internal function in apt-cyg. | | `time [ [ ...]]` | Report time consumed to call internal function in apt-cyg. | -| `filelist []` | File list line apt-file list. | +| `filelist []` | File list like apt-file list. | | `filesearch []` | File search like apt-file search. | ### Options diff --git a/apt-cyg b/apt-cyg index 1f714fb..92de144 100755 --- a/apt-cyg +++ b/apt-cyg @@ -244,7 +244,7 @@ function usage() time [ [ ...]] : Report time consumed to call internal function in apt-cyg. - filelist [] : File list line apt-file list. + filelist [] : File list like apt-file list. filesearch [] : File search like apt-file search. Options: --ag : use the silver searcher From 5e986762c6d026d928400d60437469d7a78dcc5c Mon Sep 17 00:00:00 2001 From: kou1okada Date: Mon, 1 Mar 2021 21:47:58 +0900 Subject: [PATCH 276/309] Add `mirror-source` and `web` subcommands. --- README.md | 2 ++ apt-cyg | 53 +++++++++++++++++++++++++++++++++++++++++++++++------ 2 files changed, 49 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index d7ec23c..89f881b 100755 --- a/README.md +++ b/README.md @@ -48,8 +48,10 @@ Usage | `packages-cached-size` | count size of cached packages in cache/mirrordir. | | `repair-acl` | to repair the windows ACL (Access Control List). | | `source ...` | download source archive. | +| `mirror-source ...` | download the source package into the current cache/mirrordir as mirror. | | `download ...` | download the binary package into the current directory. | | `mirror ...` | download the binary package into the current cache/mirrordir as mirror. | +| `web ...` | Open web pages of packages. | | `listfiles ...` | List files 'owned' by package(s). | | `get-proxy` | Get proxies for eval. | | `ls-categories` | List categories. | diff --git a/apt-cyg b/apt-cyg index 92de144..3b2422a 100755 --- a/apt-cyg +++ b/apt-cyg @@ -212,13 +212,18 @@ function usage() in cache/mirrordir. repair-acl : repair acl. source ... : - download source archive. + download source archive. + mirror-source ... : + download the source package + into the current cache/mirrordir as mirror. download ... : download the binary package into the current directory. mirror ... : download the binary package into the current cache/mirrordir as mirror. + web ... : + Open web pages of packages. listfiles [ ...] : List files 'owned' by package(s). get-proxy : Get proxies for eval. @@ -1797,12 +1802,12 @@ function download_packages () #= pos section type [package_names ...] esac local mirror="$(apt-cyg-pathof mirror)" - local line - local pkgs="$(get_archives_list "$section" "$type" "$@")" - local total="$(echo "$pkgs" | awk '{sum+=$2}END{print sum;}')" - local n="$(echo "$pkgs" | wc -l)" + local pkgs; readarray -t pkgs < <(get_archives_list "$section" "$type" "$@") + local total="$(printf "%s\n" "${pkgs[@]}" | awk '{sum+=$2}END{print sum;}')" + local n=${#pkgs[@]} echo "$n packages, total $total bytes will be downloaded." - echo "$pkgs" | while read line; do + local line reply=() + for line in "${pkgs[@]}"; do local tmp=( $line ) local path="${tmp[0]%/*}/" local file="${tmp[0]##*/}" @@ -1816,9 +1821,12 @@ function download_packages () #= pos section type [package_names ...] wget -N "$url" if ! hash_check <<<"${digest} *${file}" ; then error "hash did not match: $file" + else + reply+=( "$(cygpath -a "$file" )" ) fi [ "$pos" = "mirror" ] && popd done + REPLY=( "${reply[@]}" ) } function apt-cyg-source () @@ -1826,6 +1834,11 @@ function apt-cyg-source () download_packages here curr source "$@" } +function apt-cyg-mirror-source () +{ + download_packages mirror curr source "$@" +} + function apt-cyg-download () { download_packages here curr install "$@" @@ -1836,6 +1849,34 @@ function apt-cyg-mirror () download_packages mirror curr install "$@" } +function apt-cyg-web () +{ + apt-cyg-mirror-source "$@" + declare -p REPLY + + local source sources=( "${REPLY[@]}" ) + + for source in "${sources[@]}"; do + local PN="${source##*/}";PN="${PN%%-[0-9]*}" + local cygport cygports=() + readarray -t cygports < <(tar tf "$source" | grep '\.cygport$') + for cygport in "${cygports[@]}"; do + local url + read url < <( + tar xf "$source" "$cygport" -O \ + | grep -E '^HOMEPAGE=' \ + | sed -E "s/HOMEPAGE=(.*?)\s*/\1/g;s/[\"']+//g;s/\\$\\{PN\\}/$PN/g" \ + ) + if [[ "$url" =~ ^https?:// ]]; then + echo "Open: $url" + cygstart "$url" + else + error "Invalid URL: $url" + fi + done + done +} + function apt-cyg-listfiles () # [ ...] # List files 'owned' by package(s). { From 9d8110a1005ba8b91017cf6a90d9a4cf05feac6c Mon Sep 17 00:00:00 2001 From: kou1okada Date: Wed, 17 Mar 2021 17:24:08 +0900 Subject: [PATCH 277/309] Support the case of that cygport is included in patch. --- apt-cyg | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/apt-cyg b/apt-cyg index 3b2422a..0ba3067 100755 --- a/apt-cyg +++ b/apt-cyg @@ -1852,7 +1852,6 @@ function apt-cyg-mirror () function apt-cyg-web () { apt-cyg-mirror-source "$@" - declare -p REPLY local source sources=( "${REPLY[@]}" ) @@ -1860,12 +1859,15 @@ function apt-cyg-web () local PN="${source##*/}";PN="${PN%%-[0-9]*}" local cygport cygports=() readarray -t cygports < <(tar tf "$source" | grep '\.cygport$') + if (( ${#cygport} <= 0 )); then + readarray -t cygports < <(tar tf "$source" | grep '\.patch$') + fi for cygport in "${cygports[@]}"; do local url read url < <( tar xf "$source" "$cygport" -O \ - | grep -E '^HOMEPAGE=' \ - | sed -E "s/HOMEPAGE=(.*?)\s*/\1/g;s/[\"']+//g;s/\\$\\{PN\\}/$PN/g" \ + | grep -E '^\+?HOMEPAGE=' \ + | sed -E "s/\+?HOMEPAGE=(.*?)\s*/\1/g;s/[\"']+//g;s/\\$\\{PN\\}/$PN/g" \ ) if [[ "$url" =~ ^https?:// ]]; then echo "Open: $url" From fa100dd5fe6b0b47ef05dcaf16474338c336f5e2 Mon Sep 17 00:00:00 2001 From: Sebastian Thomschke Date: Thu, 1 Apr 2021 22:34:11 +0200 Subject: [PATCH 278/309] Check that iconv command exists libiconv and thus the iconv command may not be present in a cygwin installation. This PR adds a check for the availability of iconv on PATH. Without this check apt-cyg reports very misleading error messages as iconv is called indirectly in a subshell via an eval command. This results in apt-cyg not aborting when the command is not present. Without this PR: ``` $ apt-cyg find upx cygpath: can't convert empty path /usr/local/bin/apt-cyg: line 535: declare: last_cache: not found /usr/local/bin/apt-cyg: line 535: declare: last_mirror: not found Cache directory is Mirror is Updating setup.ini /x86_64/setup.bz2: Scheme missing. /x86_64/setup.bz2.sig: Scheme missing. /x86_64/setup.ini: Scheme missing. /x86_64/setup.ini.sig: Scheme missing. Error: updating setup.ini failed, reverting. at : /usr/local/bin/apt-cyg: setupini_download: 624 Searching for installed packages matching upx: Searching for installable packages matching upx: awk: cmd. line:1: fatal: cannot open file `setup.ini' for reading: No such file or directory ``` With this PR: ``` $ apt-cyg find upx Error: Required command [iconv] not found. at : /usr/local/bin/apt-cyg: assert_command_exists: 82 ``` --- apt-cyg | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/apt-cyg b/apt-cyg index 92de144..9c1e786 100755 --- a/apt-cyg +++ b/apt-cyg @@ -75,6 +75,14 @@ function abort () #= [EXITCODE=1 [CALLSTACKSKIP=0]] exit "${1:-1}" } +function assert_command_exists () #= [COMMAND ...] +{ + local command + for command in $@; do + hash $command 2>/dev/null || { error "Required command [$command] not found."; exit 1; } + done +} + function dump_callstack () #= [N=1] #? N is a depth to skip the callstack. #? $CALLSTACK_SKIP is depth to skip the callstack too. @@ -2561,6 +2569,7 @@ function invoke_subcommand () local ARGS=( "${@:2}" ) local ACTION="apt-cyg-${SUBCOMMAND:-help}" if type "$ACTION" >& /dev/null; then + assert_command_exists iconv "$ACTION" "${ARGS[@]}" else error "unknown subcommand: $SUBCOMMAND" From 81a4c1ff7f6d7d3971c4e0099d9cb008a0153e59 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Fri, 2 Apr 2021 11:34:38 +0900 Subject: [PATCH 279/309] Bugfix: fix typo --- apt-cyg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apt-cyg b/apt-cyg index 0ba3067..b4c79a3 100755 --- a/apt-cyg +++ b/apt-cyg @@ -1859,7 +1859,7 @@ function apt-cyg-web () local PN="${source##*/}";PN="${PN%%-[0-9]*}" local cygport cygports=() readarray -t cygports < <(tar tf "$source" | grep '\.cygport$') - if (( ${#cygport} <= 0 )); then + if (( ${#cygports} <= 0 )); then readarray -t cygports < <(tar tf "$source" | grep '\.patch$') fi for cygport in "${cygports[@]}"; do From 82453279705d236c759b960df350d4d2a08e732c Mon Sep 17 00:00:00 2001 From: kou1okada Date: Fri, 2 Apr 2021 12:45:58 +0900 Subject: [PATCH 280/309] Rename subcommand `web` to `homepage`. And `web` makes synonym for `homepage`. --- README.md | 3 ++- apt-cyg | 15 ++++++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 89f881b..9567505 100755 --- a/README.md +++ b/README.md @@ -51,7 +51,8 @@ Usage | `mirror-source ...` | download the source package into the current cache/mirrordir as mirror. | | `download ...` | download the binary package into the current directory. | | `mirror ...` | download the binary package into the current cache/mirrordir as mirror. | -| `web ...` | Open web pages of packages. | +| `homepage [ ...]` | Open homepages of packages. | +| `web [ ...]` | Synonym for `homepage`. | | `listfiles ...` | List files 'owned' by package(s). | | `get-proxy` | Get proxies for eval. | | `ls-categories` | List categories. | diff --git a/apt-cyg b/apt-cyg index b4c79a3..2f62565 100755 --- a/apt-cyg +++ b/apt-cyg @@ -222,8 +222,10 @@ function usage() mirror ... : download the binary package into the current cache/mirrordir as mirror. - web ... : - Open web pages of packages. + homepage [ ...] : + Open homepages of packages. + web [ ...] : + Synonym for `homepage`. listfiles [ ...] : List files 'owned' by package(s). get-proxy : Get proxies for eval. @@ -1849,7 +1851,8 @@ function apt-cyg-mirror () download_packages mirror curr install "$@" } -function apt-cyg-web () +function apt-cyg-homepage () # [ ...] +# Open homepages of packages. { apt-cyg-mirror-source "$@" @@ -1879,6 +1882,12 @@ function apt-cyg-web () done } +function apt-cyg-web () # [ ...] +# Synonym for `homepage`. +{ + apt-cyg-homepage "$@" +} + function apt-cyg-listfiles () # [ ...] # List files 'owned' by package(s). { From f212f39e88eec5c9a267a4513d911ff4893341de Mon Sep 17 00:00:00 2001 From: kou1okada Date: Thu, 8 Apr 2021 18:26:51 +0900 Subject: [PATCH 281/309] Bugfix: can't use backquotes in the here document. * This patch will fix issues #77. --- apt-cyg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apt-cyg b/apt-cyg index 05df372..a06c5b0 100755 --- a/apt-cyg +++ b/apt-cyg @@ -233,7 +233,7 @@ function usage() homepage [ ...] : Open homepages of packages. web [ ...] : - Synonym for `homepage`. + Synonym for homepage. listfiles [ ...] : List files 'owned' by package(s). get-proxy : Get proxies for eval. From b4216ad85a5811ff070ccfd599ae1cb7cfb1dc23 Mon Sep 17 00:00:00 2001 From: kou1okada Date: Thu, 22 Apr 2021 12:27:06 +0900 Subject: [PATCH 282/309] Bugfix: The filelist subcommand does not display anything in some packages. For example, https://cygwin.com/packages/x86_64/gccmakedep/gccmakedep-1.0.3-1 contains the HTML element around the HTML
 element.
That was not matched filter rule of awk.
---
 apt-cyg | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/apt-cyg b/apt-cyg
index a06c5b0..0548faf 100755
--- a/apt-cyg
+++ b/apt-cyg
@@ -1989,7 +1989,7 @@ function apt-cyg-filelist () # []
   )
   if (( ${#list_rel_urls[@]} )); then
     wget -qO- "https://cygwin.com/packages/${list_rel_urls[-1]}" \
-    | awk '/^
$/,/^<\/pre>$/' | tail -n+2 | head -n-1 \
+    | awk '/
$/,/^<\/pre>/' | tail -n+2 | head -n-1 \
     | awk -vpkg="$1" '$0=pkg": /"$4'
   fi
 }

From ec7d1f49b1d5a0115cb544cc689b9cd049bc1508 Mon Sep 17 00:00:00 2001
From: Yoshida Shunsuke 
Date: Wed, 5 May 2021 19:59:53 +0900
Subject: [PATCH 283/309] Update README.md about apt-cyg needed iconv

 Changed in MR #75
---
 README.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/README.md b/README.md
index 9567505..52a712b 100755
--- a/README.md
+++ b/README.md
@@ -104,7 +104,7 @@ Requirements
 
 `apt-cyg` requires the Cygwin default environment and the additional *Cygwin* packages:
 
-`wget`, `ca-certificates`, `gnupg`
+`wget`, `ca-certificates`, `gnupg`, `iconv`
 
 In **32bit** version of cygwin, `wget` requires an additional setting for the `ca-certificates` package.
 Choose one of below settings.

From e337e06666f81b332e4663aadd335a633332127a Mon Sep 17 00:00:00 2001
From: kou1okada 
Date: Thu, 6 May 2021 13:13:10 +0900
Subject: [PATCH 284/309] Update README.md

* The iconv package does not exist.
  The iconv command is included in the libiconv package
  instead of the iconv package.
---
 README.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/README.md b/README.md
index 52a712b..bf4cf83 100755
--- a/README.md
+++ b/README.md
@@ -104,7 +104,7 @@ Requirements
 
 `apt-cyg` requires the Cygwin default environment and the additional *Cygwin* packages:
 
-`wget`, `ca-certificates`, `gnupg`, `iconv`
+`wget`, `ca-certificates`, `gnupg`, `libiconv`
 
 In **32bit** version of cygwin, `wget` requires an additional setting for the `ca-certificates` package.
 Choose one of below settings.

From f358e608d3ae0afac974874d3aca48a245f28ead Mon Sep 17 00:00:00 2001
From: kou1okada 
Date: Thu, 10 Feb 2022 19:14:47 +0900
Subject: [PATCH 285/309] Scrap and building for subcommands.

* Add subcommand: `browse-homepage`
* Add subcommand: `browse-summary`
* Rename subcommand: `homepage` to `browse-homepage-with-mirror-source`
* Remove subcommand: `web`
---
 README.md |  5 +++--
 apt-cyg   | 49 ++++++++++++++++++++++++++++++++++++++++---------
 2 files changed, 43 insertions(+), 11 deletions(-)

diff --git a/README.md b/README.md
index bf4cf83..ace6f29 100755
--- a/README.md
+++ b/README.md
@@ -51,8 +51,9 @@ Usage
 | `mirror-source  ...` | download the source package into the current cache/mirrordir as mirror. |
 | `download  ...` |  download the binary package into the current directory. |
 | `mirror  ...` |  download the binary package into the current cache/mirrordir as mirror. |
-| `homepage [ ...]` | Open homepages of packages. |
-| `web [ ...]` | Synonym for `homepage`. |
+| `browse-homepage-with-mirror-source [ ...]` | Browse homepages of packages with mirror-source. |
+| `browse-homepage [ ...]` | Browse homepages of packages. |
+| `browse-summary [ ...]` | Browse summaries of packages. |
 | `listfiles  ...` |  List files 'owned' by package(s). |
 | `get-proxy` |  Get proxies for eval. |
 | `ls-categories` |  List categories. |
diff --git a/apt-cyg b/apt-cyg
index 0548faf..963a13b 100755
--- a/apt-cyg
+++ b/apt-cyg
@@ -230,10 +230,12 @@ function usage()
 	  mirror  ... :
 	                             download the binary package
 	                             into the current cache/mirrordir as mirror.
-	  homepage [ ...] :
-	                             Open homepages of packages.
-	  web [ ...] :
-	                             Synonym for homepage.
+	  browse-homepage-with-mirror-source [ ...] :
+	                             Browse homepages of packages with mirror-source.
+	  browse-homepage [ ...] :
+	                             Browse homepages of packages.
+	  browse-summary [ ...] :
+	                             Browse summaries of packages.
 	  listfiles [ ...] :
 	                             List files 'owned' by package(s).
 	  get-proxy                : Get proxies for eval.
@@ -1859,8 +1861,8 @@ function apt-cyg-mirror ()
   download_packages mirror curr install "$@"
 }
 
-function apt-cyg-homepage () # [ ...]
-#   Open homepages of packages. 
+function apt-cyg-browse-homepage-with-mirror-source () # [ ...]
+#   Browse homepages of packages with mirror-source. 
 {
   apt-cyg-mirror-source "$@"
 
@@ -1890,10 +1892,39 @@ function apt-cyg-homepage () # [ ...]
   done
 }
 
-function apt-cyg-web () # [ ...]
-#   Synonym for `homepage`.
+function apt-cyg-browse-homepage () # [ ...]
+#   Browse homepages of packages.
 {
-  apt-cyg-homepage "$@"
+  local basepath="cygwin.com/packages/summary/"
+  local pkg summary_path srcsummary_path homepage_url
+
+  pushd "$(apt-cyg-pathof cache)" > /dev/null
+  for pkg; do
+    summary_path="${basepath}${pkg}.html"
+    [ -e "$summary_path" ] || wget -q -N -x "https://$summary_path"
+    read srcsummary_path < <(
+      cat "$summary_path" \
+      | grep "source package" \
+      | sed -E 's@.*\shref="([^"]+)".*@'"${basepath}"'\1@g'
+      )
+    [ -e "$srcsummary_path" ] || wget -q -N -x "https://$srcsummary_path"
+    read homepage_url < <(
+      cat "$srcsummary_path" \
+      | grep "homepage" \
+      | sed -E 's/.*\shref="([^"]+)".*/\1/g'
+      )
+    cygstart "$homepage_url"
+  done
+  popd
+}
+
+function apt-cyg-browse-summary () # [ ...]
+#   Browse summaries of packages.
+{
+  local pkg
+  for pkg; do
+    cygstart "https://cygwin.com/packages/summary/${pkg}.html"
+  done
 }
 
 function apt-cyg-listfiles () # [ ...]

From 579f84bbdb116666419698b613a2bc69bff1f1fe Mon Sep 17 00:00:00 2001
From: Nico Mexis 
Date: Fri, 4 Mar 2022 14:56:24 +0100
Subject: [PATCH 286/309] Update GPG Key hash

---
 apt-cyg | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/apt-cyg b/apt-cyg
index 963a13b..e4d6ec1 100755
--- a/apt-cyg
+++ b/apt-cyg
@@ -149,9 +149,9 @@ init_SGR
 TRUSTEDKEYS=( CYGWIN );
 # ./pubring.asc
 # ------------
-# pub   4096R/E2E56300 2020-02-27 [expires: 2022-02-26]
+# pub   4096R/E2E56300 2020-02-27 [expires: 2024-02-27]
 # uid                  Cygwin 
-TRUSTEDKEY_CYGWIN_SUM="6291bf8f958e1ea05501b91d776ea10b2cd781c5caeb3d72da63333e5c45698fa4766d524a2d9a128b09b8446ee7e25cbb7942ee49d7409583e712d5c68ee81e"
+TRUSTEDKEY_CYGWIN_SUM="c7fe28492055e8f0c10d450cfbce74550cca233e8d8b5c2298113bf2c5ac98ef61031ebcb68f5b97bd4e66e878d076dc24b1140130cc5cc154fe39bd8dc98d3f"
 TRUSTEDKEY_CYGWIN_FPR="56405CF6FCC81574682A5D561A698DE9E2E56300"
 TRUSTEDKEY_CYGWIN_URL_LATEST="https://cygwin.com/key/pubring.asc"
 

From e47cee70d80b546ebb3e9bafe78fbd78faddd250 Mon Sep 17 00:00:00 2001
From: Nico Mexis 
Date: Sun, 6 Mar 2022 20:45:09 +0100
Subject: [PATCH 287/309] Update hash (again)

---
 apt-cyg | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/apt-cyg b/apt-cyg
index e4d6ec1..566dfc4 100755
--- a/apt-cyg
+++ b/apt-cyg
@@ -151,7 +151,7 @@ TRUSTEDKEYS=( CYGWIN );
 # ------------
 # pub   4096R/E2E56300 2020-02-27 [expires: 2024-02-27]
 # uid                  Cygwin 
-TRUSTEDKEY_CYGWIN_SUM="c7fe28492055e8f0c10d450cfbce74550cca233e8d8b5c2298113bf2c5ac98ef61031ebcb68f5b97bd4e66e878d076dc24b1140130cc5cc154fe39bd8dc98d3f"
+TRUSTEDKEY_CYGWIN_SUM="019b3d2efe208f1441c660a34d08151b5c9675523b85e0a4ca748137ed45d086a4eb06e0efd4d86a1479246e62641a0c284ffb8c4b0b637063681a9282beca3d"
 TRUSTEDKEY_CYGWIN_FPR="56405CF6FCC81574682A5D561A698DE9E2E56300"
 TRUSTEDKEY_CYGWIN_URL_LATEST="https://cygwin.com/key/pubring.asc"
 

From 6fb2bd8a2e49f7d903e0a38fa61575f2427abe26 Mon Sep 17 00:00:00 2001
From: Mehdi Zakaria Benadel 
Date: Fri, 1 Apr 2022 21:59:05 +0200
Subject: [PATCH 288/309] Removing Stargazers forks links

Stargazers forks website links to spam pages
---
 other_forks.md | 44 +++++++++++++++++++++++---------------------
 1 file changed, 23 insertions(+), 21 deletions(-)

diff --git a/other_forks.md b/other_forks.md
index 183eacc..e008a22 100644
--- a/other_forks.md
+++ b/other_forks.md
@@ -4,37 +4,39 @@ Other Known *`apt-cyg`* Forks on the GitHub
 Caution:
 Please do not merge forks that have incompatible licenses.
 
-Ex.) Merging to the GPL from the MIT is possible. But merging to the MIT from the GPL  is impossible.
+Ex.) Merging to the GPL from the MIT is possible. But merging to the MIT from the GPL is impossible.
+
+**NB:** For comparison between forks, you can use a fork analyzer tool. Unfortunately, *Stagazers forks* website is down, but you can use [Lovely Forks browser extension](https://github.com/musically-ut/lovely-forks)
 
 ### Official (MIT license)
 
-* [transcodes-open / apt-cyg](https://github.com/transcode-open/apt-cyg/network) ([Stargazers forks](http://forked.yannick.io/transcode-open/apt-cyg))
-  * [tmshn / cyg-fast](https://github.com/tmshn/cyg-fast/network) ([Stargazers forks](http://forked.yannick.io/tmshn/cyg-fast)) 
-  * [pi0 / cyg](https://github.com/pi0/cyg/network) ([Stargazers forks](http://forked.yannick.io/pi0/cyg)) (GPLv3)
+* [transcodes-open / apt-cyg](https://github.com/transcode-open/apt-cyg/network)
+  * [tmshn / cyg-fast](https://github.com/tmshn/cyg-fast/network)
+  * [pi0 / cyg](https://github.com/pi0/cyg/network) (GPLv3)
 
 ### Unofficial (MIT license)
 
-* [digitallamb / apt-cyg](https://github.com/digitallamb/apt-cyg/network) ([Stargazers forks](http://forked.yannick.io/digitallamb/apt-cyg))
-* [balanx / apt-cyg](https://github.com/balanx/apt-cyg/network) ([Stargazers forks](http://forked.yannick.io/balanx/apt-cyg))
-* [langlichuan123 / apt-cyg](https://github.com/langlichuan123/apt-cyg/network) ([Stargazers forks](http://forked.yannick.io/langlichuan123/apt-cyg))
+* [digitallamb / apt-cyg](https://github.com/digitallamb/apt-cyg/network)
+* [balanx / apt-cyg](https://github.com/balanx/apt-cyg/network)
+* [langlichuan123 / apt-cyg](https://github.com/langlichuan123/apt-cyg/network)
 
 ### Unofficial (GPLv2)
 
-* [cfg / apt-cyg](https://github.com/cfg/apt-cyg/network) ([Stargazers forks](http://forked.yannick.io/cfg/apt-cyg))
-  * [Milly / apt-cyg](https://github.com/Milly/apt-cyg/network) ([Stargazers forks](http://forked.yannick.io/Milly/apt-cyg))
-* [ashumkin / apt-cyg](https://github.com/ashumkin/apt-cyg/network) ([Stargazers forks](http://forked.yannick.io/ashumkin/apt-cyg))
-* [svn2github / apt-cyg](https://github.com/svn2github/apt-cyg/network) ([Stargazers forks](http://forked.yannick.io/svn2github/apt-cyg))
-* [nosuchuser / apt-cyg](https://github.com/nosuchuser/apt-cyg/network) ([Stargazers forks](http://forked.yannick.io/nosuchuser/apt-cyg))
-* [kazuhisya / apt-cyg64](https://github.com/kazuhisya/apt-cyg64/network) ([Stargazers forks](http://forked.yannick.io/kazuhisya/apt-cyg64))
-* [bnormsoftware / apt-cyg](https://github.com/bnormsoftware/apt-cyg/network) ([Stargazers forks](http://forked.yannick.io/bnormsoftware/apt-cyg))
-* [rcmdnk / apt-cyg](https://github.com/rcmdnk/apt-cyg/network) ([Stargazers forks](http://forked.yannick.io/rcmdnk/apt-cyg))
-* [buzain / apt-cyg](https://github.com/buzain/apt-cyg/network) ([Stargazers forks](http://forked.yannick.io/buzain/apt-cyg))
-* [wuyangnju / apt-cyg](https://github.com/wuyangnju/apt-cyg/network) ([Stargazers forks](http://forked.yannick.io/wuyangnju/apt-cyg))
-* [takuya / apt-cyg](https://github.com/takuya/apt-cyg/network) ([Stargazers forks](http://forked.yannick.io/takuya/apt-cyg))
+* [cfg / apt-cyg](https://github.com/cfg/apt-cyg/network)
+  * [Milly / apt-cyg](https://github.com/Milly/apt-cyg/network)
+* [ashumkin / apt-cyg](https://github.com/ashumkin/apt-cyg/network)
+* [svn2github / apt-cyg](https://github.com/svn2github/apt-cyg/network)
+* [nosuchuser / apt-cyg](https://github.com/nosuchuser/apt-cyg/network)
+* [kazuhisya / apt-cyg64](https://github.com/kazuhisya/apt-cyg64/network)
+* [bnormsoftware / apt-cyg](https://github.com/bnormsoftware/apt-cyg/network)
+* [rcmdnk / apt-cyg](https://github.com/rcmdnk/apt-cyg/network)
+* [buzain / apt-cyg](https://github.com/buzain/apt-cyg/network)
+* [wuyangnju / apt-cyg](https://github.com/wuyangnju/apt-cyg/network)
+* [takuya / apt-cyg](https://github.com/takuya/apt-cyg/network)
 
 ### Derivations of non-fork on the github
 
-* [10sr / pac-cyg](https://github.com/10sr/pac-cyg/network) ([Stargazers forks](http://forked.yannick.io/10sr/pac-cyg))
-* [nobuyo / medy](https://github.com/nobuyo/medy/network) ([Stargazers forks](http://forked.yannick.io/nobuyo/medy))
-* [svnpenn / sage](https://github.com/svnpenn/sage/network) ([Stargazers forks](http://forked.yannick.io/svnpenn/sage)) -> [cup / pear](https://github.com/cup/pear/network) ([Stargazers forks](http://forked.yannick.io/cup/pear))
+* [10sr / pac-cyg](https://github.com/10sr/pac-cyg/network)
+* [nobuyo / medy](https://github.com/nobuyo/medy/network)
+* [svnpenn / sage](https://github.com/svnpenn/sage/network) -> [cup / pear](https://github.com/cup/pear/network)
 

From a14cd4bac7d27d6c2524c469a0a268fa39902791 Mon Sep 17 00:00:00 2001
From: kou1okada 
Date: Tue, 5 Apr 2022 16:28:48 +0900
Subject: [PATCH 289/309] Refactoring: package_db-version_check

Improve performance as

```
$ # before
$ time for i in {1..10}; do apt-cyg show; done >/dev/null

real    0m6.963s
user    0m2.689s
sys     0m3.724s

$ # after
$ time for i in {1..10}; do apt-cyg show; done >/dev/null

real    0m6.128s
user    0m2.148s
sys     0m3.229s
```
---
 apt-cyg | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)

diff --git a/apt-cyg b/apt-cyg
index 566dfc4..1d027f6 100755
--- a/apt-cyg
+++ b/apt-cyg
@@ -1068,19 +1068,18 @@ function package_db-version_check ()
   [ -n "$PACKAGE_DB_VERSION_CHECK_DONE" ] && return
   
   local vernhdr='INSTALLED\.DB [0-9]+'
-  local line1="$(head -n1 "${PACKAGE_DB}")"
-  local verhdr=( $line1 )
-  local pkgname="${verhdr[0]}"
-  local dbver
-  [ "${verhdr[0]}" = "INSTALLED.DB" ] && dbver="${verhdr[1]}" || dbver="1"
+  local line1; read line1 < "${PACKAGE_DB}"
+  local dbver=1
   
-  if echo "$line1" | grep -Eqvx "${vernhdr}"; then
+  if [[ "$line1" =~ ^INSTALLED\.DB[[:space:]]+([0-9]+)$ ]]; then
+    dbver="${BASH_REMATCH[1]}"
+  else
     warning "${PACKAGE_DB} does not have version header. The first line is below:\n" \
             "$(head -n1 "${PACKAGE_DB}")\n"
     
     # The earlyer version of apt-cyg was not treat version header correctly.
     if grep -EHnx "${vernhdr}" "${PACKAGE_DB}" >&2; then
-      echo -e "The above line looks like version header, but it is not the first line.\n" >&2
+      echo "The above line looks like version header, but it is not the first line." >&2
     fi
   fi
   
@@ -1094,9 +1093,7 @@ function package_db-version_check ()
       echo "abort" >&2
       exit 1
     }
-  fi
-  
-  if (( 3 < dbver )); then
+  elif (( 3 < dbver )); then
     error "${PACKAGE_DB} has unknown version header.\n" \
           "Currently apt-cyg supports the DB of ver 3 or ealyer, but your DB is ver $dbver.\n"
     ask_user "Do you want to continue at your own risk?" >&2 && {

From e8f1be2ae72bd0e7060831b7581da92fd3b6ed06 Mon Sep 17 00:00:00 2001
From: kou1okada 
Date: Tue, 5 Apr 2022 17:12:20 +0900
Subject: [PATCH 290/309] Remove --charch.

---
 README.md | 13 -------------
 apt-cyg   | 41 -----------------------------------------
 2 files changed, 54 deletions(-)

diff --git a/README.md b/README.md
index ace6f29..617a199 100755
--- a/README.md
+++ b/README.md
@@ -76,7 +76,6 @@ Usage
 | Option | Description |
 |:------ |:----------- |
 | `--ag` | use the silver searcher (currently work only at packageof subcommand) |
-| `--charch ` | change architecture |
 | `--ignore-case`, `-i` | ignore case distinctions for `` |
 | `--force-remove` | force remove
 | `--force-fetch-trustedkeys` | force fetch trustedkeys |
@@ -157,18 +156,6 @@ After the middle of 2015-03, the cygwin project changed the hash algorithm for c
 But, as of 2015-04-09, the cygwinports project seems still using md5.
 This fork is available for both of cygwin and cygwinports by supporting algorithm of md5, sha1, sha224, sha256 and sha512.
 
-### True multi-architecture support
-
-Let think a case that you want to install the x86 package when you are working under the x86_64 environment.
-For example:
-
-    apt-cyg --charch x86 install chere
-
-As of 2013-10-26, chere package is provided for only the repository for x86.
-
-Remarks:
-Of course, you must install both environments of x86_64 and x86, beforehand.
-
 ### Signature check and key management by GnuPG
 
 The default action of apt-cyg has been changed to check signature for 'setup.ini'.
diff --git a/apt-cyg b/apt-cyg
index 1d027f6..815114a 100755
--- a/apt-cyg
+++ b/apt-cyg
@@ -266,7 +266,6 @@ function usage()
 	Options:
 	  --ag                     : use the silver searcher
 	                             (currently work only at packageof subcommand)
-	  --charch           : change architecture
 	  --ignore-case, -i        : ignore case distinctions for 
 	  --force-remove           : force remove
 	  --force-fetch-trustedkeys :
@@ -655,36 +654,6 @@ function checkpackages()
   fi
 }
 
-# Usage: getrootdir arch
-function getrootdir ()
-{
-  case "$1" in
-    x86)
-      cygpath -u "$(< /proc/registry32/HKEY_LOCAL_MACHINE/SOFTWARE/Cygwin/setup/rootdir)" ;;
-    x86_64)
-      cygpath -u "$(< /proc/registry64/HKEY_LOCAL_MACHINE/SOFTWARE/Cygwin/setup/rootdir)" ;;
-    *)
-      error "unknown arch: $1" ;;
-  esac
-}
-
-# Usage: charch arch apt-cyg_parms ...
-function charch ()
-{
-  local rootdir
-  if [ "$(current_cygarch)" != "$1" ]; then
-    echo -e "${SGR_fg_green}${SGR_bold}charch to:${SGR_reset} $1"
-    rootdir="$(getrootdir "$1")"
-    shift
-    chroot "$rootdir" "$rootdir/bin/bash" -lc \
-      'cd "$1"; shift ; "$0" "$@"' \
-      "$(type -p "$0" | xargs cygpath -aml | xargs cygpath -u)" \
-      "$(pwd          | xargs cygpath -aml | xargs cygpath -u)" \
-      "$@"
-    exit $?
-  fi
-}
-
 function init_gnupg ()
 {
   [ -z "$GPG" -o -n "$no_verify" ] && return
@@ -1398,9 +1367,6 @@ function __apt-cyg ()
       ;;
   esac
   case "$prev" in
-    --charch)
-      COMPREPLY=( x86 x86_64 )
-      ;;
     --cache|-c)
       readarray -t COMPREPLY < <(compgen -d -- "$cur")
       ;;
@@ -2204,11 +2170,6 @@ function parse_args ()
         shift
         ;;
       
-      --charch)
-        OPT_CHARCH="$2"
-        shift 2 || break
-        ;;
-      
       --use-setuprc)
         warning "Ignore --use-setuprc. This option was removed with issue-24."
         shift
@@ -2395,8 +2356,6 @@ parse_args "$@"
 : ${OPT_VERBOSE_LEVEL:=$VERBOSE}
 VERBOSE=$OPT_VERBOSE_LEVEL
 
-[ -n "$OPT_CHARCH" ] && charch "$OPT_CHARCH" "${INITIAL_ARGS[@]}"
-
 [ "${#OPT_MIRROR[@]}" -gt 0 ] && apt-cyg-set-mirror "${OPT_MIRROR[@]}"
 [ "${#OPT_CACHE[@]}"  -gt 0 ] && apt-cyg-set-cache  "${OPT_CACHE}"
 

From 04976430430f333d69334a8e647db412ef37ac4a Mon Sep 17 00:00:00 2001
From: kou1okada 
Date: Tue, 5 Apr 2022 17:31:02 +0900
Subject: [PATCH 291/309] Remove current_cygarch().

---
 apt-cyg | 20 ++++++--------------
 1 file changed, 6 insertions(+), 14 deletions(-)

diff --git a/apt-cyg b/apt-cyg
index 815114a..7521f1d 100755
--- a/apt-cyg
+++ b/apt-cyg
@@ -462,12 +462,6 @@ function is_official_mirrors_of_cygwin () #  ...
   return $result
 }
 
-function current_cygarch ()
-{
-  local arch="${HOSTTYPE:-$(arch)}"
-  echo "${arch/i686/x86}"
-}
-
 function mirror_to_mirrordir () # 
 {
   local tmp="${1//:/%3a}"
@@ -559,7 +553,6 @@ function findworkspace()
 
     mirror="$last_mirror"
     cache="$(cygpath -au "$last_cache")"
-    arch="$(current_cygarch)"
     
     cache="${cache%/}"
     mirror="${mirror%/}"
@@ -1427,7 +1420,7 @@ function apt-cyg-benchmark-mirrors ()
 {
   local mirror result exitcode
   for mirror; do
-    result="$( { time wget -qO/dev/null -T3 -t 1 "${mirror%/}/$(current_cygarch)/setup.bz2"; } 2>&1 )"
+    result="$( { time wget -qO/dev/null -T3 -t 1 "${mirror%/}/$arch/setup.bz2"; } 2>&1 )"
     exitcode=$?
     if [ $exitcode -ne 0 ];then
       warning "benchmark failed with wget exitcode $exitcode: $(wget-exitstatus $exitcode): $1"
@@ -1617,7 +1610,7 @@ function apt-cyg-dist-upgrade-no-ask ()
   
   apt-cyg-update-setup
   cd /etc/setup
-  cygstart "$COMSPEC" /c 'ECHO Press any key to start dist-upgrade for cygwin '"$(current_cygarch)"' && PAUSE && START /WAIT '"${setup[@]}"' && ash -c "/bin/rebaseall -v" && ECHO dist-upgrade is finished && ECHO Press any key to exit && PAUSE' # '
+  cygstart "$COMSPEC" /c 'ECHO Press any key to start dist-upgrade for cygwin '"$arch"' && PAUSE && START /WAIT '"${setup[@]}"' && ash -c "/bin/rebaseall -v" && ECHO dist-upgrade is finished && ECHO Press any key to exit && PAUSE' # '
   kill_all_cygwin_process
   
   popd > /dev/null
@@ -1973,8 +1966,7 @@ function apt-cyg-time () # [ [ ...]]
 function apt-cyg-filelist () # []
 #   File list like apt-file list
 {
-  local arch list_rel_urls
-  arch="$(current_cygarch)"
+  local list_rel_urls
   readarray -t list_rel_urls < <(
     wget -qO- "https://cygwin.com/packages/summary/${1}.html" \
     | grep -E ']*>list of files' \
@@ -1991,8 +1983,7 @@ function apt-cyg-filelist () # []
 function apt-cyg-filesearch () # []
 #   File search like apt-file search
 {
-  local arch cachedir cachefile cachequery columns line package packages url
-  arch="$(current_cygarch)"
+  local cachedir cachefile cachequery columns line package packages url
   cachedir="/tmp/.apt-cyg.cache/filesearch"
   cachequery="$cachedir/$(sha256sum <<<"$1"|awk '$0=$1')"
   mkdirp "$cachedir"
@@ -2140,6 +2131,7 @@ function apt-cyg-help ()
 
 # process options
 
+arch="${HOSTTYPE:-$(arch)}";arch="${arch/i686/x86}"
 apt_cyg_cachedir="${tmp:-/tmp}/.apt-cyg.cache"
 noscripts=0
 OPT_USER_PICKED=1
@@ -2153,7 +2145,7 @@ no_verify=""
 OPT_PROXY=${APT_CYG_PROXY:-auto}
 OPT_PROXY_REFRESH_INTERVAL=${APT_CYG_PROXY_REFRESH_INTERVAL:-86400} # 86400s = 1day
 OPTS4INHERIT=()
-SETUP_EXE="setup-$(current_cygarch).exe"
+SETUP_EXE="setup-$arch.exe"
 YES_TO_ALL=false
 INITIAL_ARGS=( "$@" )
 ARGS=()

From ef8950d9bf329d60025186ce5b2c63fada26357e Mon Sep 17 00:00:00 2001
From: kou1okada 
Date: Tue, 5 Apr 2022 17:47:13 +0900
Subject: [PATCH 292/309] Refactoring: Use redirect instead of command
 substitution for checking command exists.

Improve performance as

```
$ # before
$ time for i in {1..10}; do apt-cyg show; done >/dev/null

real    0m6.103s
user    0m2.175s
sys     0m3.407s

$ # after
$ time for i in {1..10}; do apt-cyg show; done >/dev/null

real    0m5.817s
user    0m2.385s
sys     0m3.208s
```
---
 apt-cyg | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/apt-cyg b/apt-cyg
index 7521f1d..45a26ce 100755
--- a/apt-cyg
+++ b/apt-cyg
@@ -157,10 +157,10 @@ TRUSTEDKEY_CYGWIN_URL_LATEST="https://cygwin.com/key/pubring.asc"
 
 # this script requires some packages
 
-WGET="$( type -p wget 2>/dev/null )"
-TAR="$(  type -p tar  2>/dev/null )"
-GAWK="$( type -p awk  2>/dev/null )"
-GPG="$(  type -p gpg  2>/dev/null || type -p gpg2  2>/dev/null )"
+read WGET < <( type -p wget 2>/dev/null )
+read TAR  < <( type -p tar  2>/dev/null )
+read GAWK < <( type -p awk  2>/dev/null )
+read GPG  < <( type -p gpg  2>/dev/null || type -p gpg2  2>/dev/null )
 if [ -z "$WGET" -o -z "$TAR" -o -z "$GAWK" ]; then
   echo You must install wget, tar and gawk to use apt-cyg.
   exit 1
@@ -2367,7 +2367,7 @@ done
 update_verbosefor
 
 if [ -n "$OPT_AG" ]; then
-  AG="$( type -p ag 2>/dev/null )"
+  read AG < <( type -p ag 2>/dev/null )
   if [ -z "$AG" ]; then
     warning "ag is not found. ignore option: $OPT_AG"
     unset OPT_AG

From a2758ac47596d6c44b04b035d71a196e3daa56a0 Mon Sep 17 00:00:00 2001
From: kou1okada 
Date: Tue, 5 Apr 2022 18:59:53 +0900
Subject: [PATCH 293/309] Support setup.{zst,xz}.

---
 apt-cyg | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/apt-cyg b/apt-cyg
index 45a26ce..25b2dc5 100755
--- a/apt-cyg
+++ b/apt-cyg
@@ -616,14 +616,17 @@ function setupini_download ()
   [ $noscripts -ne 0 -o $noupdate -ne 0 ] && return
   
   pushd "$BASEDIR" > /dev/null
-  files_backup setup.ini setup.ini.sig setup.bz2 setup.bz2.sig
+  files_backup setup.{zst,xz,bz2,ini}{,.sig}
   
   while true; do
     verbose 1 "Updating setup.ini"
-    download_and_verify "$mirror/$arch/setup.bz2" && { bunzip2 -k setup.bz2 && mv setup setup.ini || rm -f setup.bz2; }
+    false \
+    || { download_and_verify "$mirror/$arch/setup.zst" && { zstd  -dfkq setup.zst && mv setup setup.ini || rm -f setup.zst; }; } \
+    || { download_and_verify "$mirror/$arch/setup.xz"  && { xz    -dfk  setup.xz  && mv setup setup.ini || rm -f setup.xz;  }; } \
+    || { download_and_verify "$mirror/$arch/setup.bz2" && { bzip2 -dfk  setup.bz2 && mv setup setup.ini || rm -f setup.bz2; }; }
     download_and_verify "$mirror/$arch/setup.ini" || break
     
-    files_backup_clean setup.ini setup.ini.sig setup.bz2 setup.bz2.sig
+    files_backup_clean setup.{zst,xz,bz2,ini}{,.sig}
     popd > /dev/null
     verbose 1 "Updated setup.ini"
     return

From 9cfc2cfdbb80d7a1b3713917b56b9a45126d9c4f Mon Sep 17 00:00:00 2001
From: kou1okada 
Date: Tue, 5 Apr 2022 19:09:53 +0900
Subject: [PATCH 294/309] Support .zst for `/etc/setup/install.db`.

---
 apt-cyg | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/apt-cyg b/apt-cyg
index 25b2dc5..2fb3d21 100755
--- a/apt-cyg
+++ b/apt-cyg
@@ -1089,7 +1089,7 @@ function package_db-list ()
   
   awk '
     NF == 3 {
-      version = gensub(/^(.*)\.(tgz|tbz|tbz2|tb2|taz|tz|tlz|txz|tar\.(gz|bz2|Z|lz|lzma|xz))$/, "\\1", 1, substr($2, length($1) + 2));
+      version = gensub(/^(.*)\.(tgz|tbz|tbz2|tb2|taz|tz|tlz|txz|tar\.(gz|bz2|Z|lz|lzma|xz|zst))$/, "\\1", 1, substr($2, length($1) + 2));
       printf("%s %s %s\n", $1, version, $3);
     }
   ' "${PACKAGE_DB}"

From 091f386b7d6520852c74fae8b10a07f6e7f7be2c Mon Sep 17 00:00:00 2001
From: kou1okada 
Date: Thu, 26 May 2022 20:06:46 +0900
Subject: [PATCH 295/309] Bugfix: upgrade-self-with-git does not use
 proxy_setup.

---
 apt-cyg | 1 +
 1 file changed, 1 insertion(+)

diff --git a/apt-cyg b/apt-cyg
index 2fb3d21..59f7c33 100755
--- a/apt-cyg
+++ b/apt-cyg
@@ -933,6 +933,7 @@ function upgrade-self-with-git ()
     warning "apt-cyg is not under the git version control."
     return 1
   fi
+  proxy_setup
   pushd "$SCRIPT_REALDIR" > /dev/null
   git pull -v
   popd > /dev/null

From 47fd11e9a2a4ee4d060956baf133a368edc90871 Mon Sep 17 00:00:00 2001
From: kou1okada 
Date: Tue, 18 Oct 2022 18:38:57 +0900
Subject: [PATCH 296/309] Bugfix: Cygwin 3.3.6 can't execute
 "${COMSPEC//\\//}".

* This patch will fix issue #88.

I would like to thank @zoidby, @kirusyaga, @darklie and @jarnosz
who reported it.
---
 apt-cyg | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/apt-cyg b/apt-cyg
index 59f7c33..2403f65 100755
--- a/apt-cyg
+++ b/apt-cyg
@@ -421,7 +421,7 @@ function comspec () # [ ...]
 # Call $COMSPEC.
 {
   init_comspec
-  PATH="$SYSTEMPATH" "${COMSPEC//\\//}" "$@"
+  PATH="$SYSTEMPATH" "$(cygpath "$COMSPEC")" "$@"
 }
 
 function cygstart () # [ ...]

From 0f49c039500bc164574c43b5796903699792b3ab Mon Sep 17 00:00:00 2001
From: kou1okada 
Date: Mon, 7 Nov 2022 13:14:53 +0900
Subject: [PATCH 297/309] Consider the `depends2:` field in `setup.ini`.

This change regards to issue #90.

The `requires:` field is gone from the `setup.ini`.
It seems that is replaced by `depends2:` field.
The `setup.ini` specifications may have changed.
---
 apt-cyg | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/apt-cyg b/apt-cyg
index 2403f65..21d2b9c 100755
--- a/apt-cyg
+++ b/apt-cyg
@@ -1191,10 +1191,11 @@ function dep_check ()
       pkg = $2;
       available[pkg] = 1;
     }
-    $1 == "requires:" {
+    $1 == "requires:" || $1 == "depends2:" {
       for (req = 2; req <= NF; req++) {
-        dep["rdepends", $req, dep["rdepends", $req, "n"]++] = pkg;
-        dep["depends" , pkg , dep["depends" , pkg , "n"]++] = $req;
+        reqpkg = gensub(/,$/, "", "g", $req);
+        dep["rdepends", reqpkg, dep["rdepends", reqpkg, "n"]++] = pkg;
+        dep["depends" , pkg   , dep["depends" , pkg   , "n"]++] = reqpkg;
       }
     }
     END {
@@ -2516,7 +2517,7 @@ function apt-cyg-install ()
     
     # recursively install required packages
     
-    local requires="$(grep "^requires: " "release/$pkg/desc" | sed -re 's/^requires: *(.*[^ ]) */\1/g' -e 's/ +/ /g')"
+    local requires="$(grep -E "^(requires|depends2): " "release/$pkg/desc" | sed -re 's/^(requires|depends2): *(.*[^ ]) */\2/g' -e 's/,? +/ /g')"
     
     local warn=0
     if [ -n "$requires" ]; then

From 172b24295a1958691a5c6d8fb9c80bcbc037fe93 Mon Sep 17 00:00:00 2001
From: kou1okada 
Date: Fri, 2 Dec 2022 14:12:44 +0900
Subject: [PATCH 298/309] Bugfix: Type p of postinstall scripts must not be
 marked .done.

This patch is related to issue #92.

* Type p of postinstall scripts will not marked .done.
* Add a repair routine for incorrect .done marked postinstall scripts.
---
 README.md |  1 +
 apt-cyg   | 25 +++++++++++++++++++++++--
 2 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/README.md b/README.md
index 617a199..05253e3 100755
--- a/README.md
+++ b/README.md
@@ -47,6 +47,7 @@ Usage
 | `packages-cached-count` |  count number of cached packages in cache/mirrordir. |
 | `packages-cached-size` |  count size of cached packages in cache/mirrordir. |
 | `repair-acl` |  to repair the windows ACL (Access Control List). |
+| `repair-postinstall` | Repair postinstall scripts. |
 | `source  ...` |  download source archive. |
 | `mirror-source  ...` | download the source package into the current cache/mirrordir as mirror. |
 | `download  ...` |  download the binary package into the current directory. |
diff --git a/apt-cyg b/apt-cyg
index 2403f65..63e04f6 100755
--- a/apt-cyg
+++ b/apt-cyg
@@ -219,6 +219,7 @@ function usage()
 	  packages-cached-size     : count size of cached packages
 	                             in cache/mirrordir.
 	  repair-acl               : repair acl.
+	  repair-postinstall       : Repair postinstall scripts.
 	  source  ... :
 	                             download source archive.
 	  mirror-source  ... :
@@ -1706,6 +1707,24 @@ function apt-cyg-repair-acl ()
   | cp2utf8
 }
 
+function apt-cyg-repair-postinstall ()
+# Repair postinstall scripts
+{
+  # Repair type p scripts that were marked "done" incorrectly. 
+  local i done_marked_p=( /etc/postinstall/[0_z]p_*.done )
+  [[ ! -e "$done_marked_p" ]] && return
+
+  verbose 0 -e "${SGR_fg_green}${SGR_bold}Repairing:${SGR_reset} type p postinstall scripts that were marked .done incorrectly."
+  for i in "${done_marked_p[@]}"; do
+    if [[ "$i" -ot "${i%.done}" ]]; then
+      rm -v "$i"
+    else
+      mv -v "$i" "${i%.done}"
+    fi
+  done
+  echo
+}
+
 function get_archives_list () #= section type [package_names ...]
 #? get archives list by format below:
 #?    path size digest
@@ -2538,11 +2557,13 @@ function apt-cyg-install ()
     # run all postinstall scripts
     
     local pis="$(ls /etc/postinstall/*.sh 2>/dev/null | wc -l)"
+    apt-cyg-repair-postinstall
     if [ $pis -gt 0 -a $noscripts -ne 1 ]; then
       verbose 0 "Running postinstall scripts"
       for script in /etc/postinstall/*.sh; do
-        $script
-        mv $script $script.done
+        $script \
+        && [[ $script != /*/?p_* ]] \
+        && mv $script $script.done
       done
     fi
     

From 9187117e45e352abe37bc98648101551cb326b29 Mon Sep 17 00:00:00 2001
From: kou1okada 
Date: Fri, 2 Dec 2022 15:11:26 +0900
Subject: [PATCH 299/309] Bugfix: /etc/postinstall/*.dash are not executed.

This patch is related to issue #93.
---
 apt-cyg | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/apt-cyg b/apt-cyg
index 661959f..0dcf04f 100755
--- a/apt-cyg
+++ b/apt-cyg
@@ -25,6 +25,8 @@
 # THE SOFTWARE.
 # 
 
+shopt -s extglob
+
 # EMBED_BEGIN: hhs_embed
 
 (( 5 <= DEBUG )) && set -x
@@ -2557,11 +2559,12 @@ function apt-cyg-install ()
     
     # run all postinstall scripts
     
-    local pis="$(ls /etc/postinstall/*.sh 2>/dev/null | wc -l)"
     apt-cyg-repair-postinstall
-    if [ $pis -gt 0 -a $noscripts -ne 1 ]; then
+    
+    local postinstalls=( /etc/postinstall/*.?(da)sh )
+    if [ -e "$postinstalls" -a $noscripts -ne 1 ]; then
       verbose 0 "Running postinstall scripts"
-      for script in /etc/postinstall/*.sh; do
+      for script in "${postinstalls[@]}"; do
         $script \
         && [[ $script != /*/?p_* ]] \
         && mv $script $script.done
@@ -2604,8 +2607,8 @@ function apt-cyg-remove()
     # run preremove scripts
     
     local i postinstalls preremoves
-    readarray -t postinstalls < <(zgrep -E "^etc/postinstall/.*[.]sh$"    "/etc/setup/${pkg}.lst.gz" | awk '{print "/"$0}')
-    readarray -t preremoves   < <(zgrep -E "^etc/preremove/.*[.](da)?sh$" "/etc/setup/${pkg}.lst.gz" | awk '{print "/"$0}')
+    readarray -t postinstalls < <(zgrep -E "^etc/postinstall/.*[.](da)?sh$" "/etc/setup/${pkg}.lst.gz" | awk '{print "/"$0}')
+    readarray -t preremoves   < <(zgrep -E "^etc/preremove/.*[.](da)?sh$"   "/etc/setup/${pkg}.lst.gz" | awk '{print "/"$0}')
     for i in "${preremoves[@]}"; do
       verbose 0 "Running: ${i}"
       "${i}"

From fe3d07fc286e444ca71f3b0078996b8dc75c6592 Mon Sep 17 00:00:00 2001
From: kou1okada 
Date: Fri, 28 Apr 2023 23:04:49 +0900
Subject: [PATCH 300/309] Add `--benchmark-timeout` option.

---
 README.md |  1 +
 apt-cyg   | 20 +++++++++++++++++---
 2 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/README.md b/README.md
index 05253e3..c025d32 100755
--- a/README.md
+++ b/README.md
@@ -77,6 +77,7 @@ Usage
 | Option | Description |
 |:------ |:----------- |
 | `--ag` | use the silver searcher (currently work only at packageof subcommand) |
+| `--benchmark-timeout ` | Truncate items that take longer than \ when benchmarking |
 | `--ignore-case`, `-i` | ignore case distinctions for `` |
 | `--force-remove` | force remove
 | `--force-fetch-trustedkeys` | force fetch trustedkeys |
diff --git a/apt-cyg b/apt-cyg
index 0dcf04f..d622953 100755
--- a/apt-cyg
+++ b/apt-cyg
@@ -269,6 +269,9 @@ function usage()
 	Options:
 	  --ag                     : use the silver searcher
 	                             (currently work only at packageof subcommand)
+	  --benchmark-timeout  :
+	                             Truncate items that take longer than 
+	                             when benchmarking.
 	  --ignore-case, -i        : ignore case distinctions for 
 	  --force-remove           : force remove
 	  --force-fetch-trustedkeys :
@@ -1427,14 +1430,20 @@ function apt-cyg-mirrors-list-online ()
 function apt-cyg-benchmark-mirrors ()
 {
   local mirror result exitcode
+  local WGET=( wget )
+  [ -n "$OPT_BENCHMARK_TIMEOUT" ] && WGET=( timeout "$OPT_BENCHMARK_TIMEOUT" "${WGET[@]}" )
   for mirror; do
-    result="$( { time wget -qO/dev/null -T3 -t 1 "${mirror%/}/$arch/setup.bz2"; } 2>&1 )"
+    result="$( { time "${WGET[@]}" -qO/dev/null -T3 -t 1 "${mirror%/}/$arch/setup.bz2"; } 2>&1 )"
     exitcode=$?
     if [ $exitcode -ne 0 ];then
-      warning "benchmark failed with wget exitcode $exitcode: $(wget-exitstatus $exitcode): $1"
+      if [ $exitcode -eq 124 ]; then
+        echo -e "Timeout:\t${mirror}" >&2
+      else
+        warning "benchmark failed with wget exitcode $exitcode: $(wget-exitstatus $exitcode): $1"
+      fi
       continue
     fi
-    echo -e "$(echo "$result" | grep real | cut -f 2 | tr -d "\n")\t${mirror}"
+    [[ "$result" =~ real[^0-9]*([0-9]*m[0-9.]*s) ]] && echo -e "${BASH_REMATCH[1]}\t${mirror}"
   done
 }
 
@@ -2188,6 +2197,11 @@ function parse_args ()
         shift
         ;;
       
+      --benchmark-timeout)
+        OPT_BENCHMARK_TIMEOUT="$2"
+        shift 2 || break
+        ;;
+
       --use-setuprc)
         warning "Ignore --use-setuprc. This option was removed with issue-24."
         shift

From da909ec5cc437269da1a95130f333342970c3559 Mon Sep 17 00:00:00 2001
From: Yak! 
Date: Sun, 23 Jul 2023 13:36:07 +0900
Subject: [PATCH 301/309] Prefer gpg2 over gpg.

---
 apt-cyg | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/apt-cyg b/apt-cyg
index d622953..f6a6ca1 100755
--- a/apt-cyg
+++ b/apt-cyg
@@ -162,7 +162,7 @@ TRUSTEDKEY_CYGWIN_URL_LATEST="https://cygwin.com/key/pubring.asc"
 read WGET < <( type -p wget 2>/dev/null )
 read TAR  < <( type -p tar  2>/dev/null )
 read GAWK < <( type -p awk  2>/dev/null )
-read GPG  < <( type -p gpg  2>/dev/null || type -p gpg2  2>/dev/null )
+read GPG  < <( type -p gpg2 2>/dev/null || type -p gpg   2>/dev/null )
 if [ -z "$WGET" -o -z "$TAR" -o -z "$GAWK" ]; then
   echo You must install wget, tar and gawk to use apt-cyg.
   exit 1

From 84b6eae92a17daac3048801d57d580e2de6795c5 Mon Sep 17 00:00:00 2001
From: Yak! 
Date: Sun, 23 Jul 2023 13:49:10 +0900
Subject: [PATCH 302/309] Fix unintentional behavior in setupini_download().

- A plain setup.ini is always downloaded even though
  it is successful to download one of compressed versions.
- Arguments for files_restore() is not aligned with
  files_backup() and files_backup_clean().
---
 apt-cyg | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/apt-cyg b/apt-cyg
index d622953..4441837 100755
--- a/apt-cyg
+++ b/apt-cyg
@@ -629,15 +629,15 @@ function setupini_download ()
     false \
     || { download_and_verify "$mirror/$arch/setup.zst" && { zstd  -dfkq setup.zst && mv setup setup.ini || rm -f setup.zst; }; } \
     || { download_and_verify "$mirror/$arch/setup.xz"  && { xz    -dfk  setup.xz  && mv setup setup.ini || rm -f setup.xz;  }; } \
-    || { download_and_verify "$mirror/$arch/setup.bz2" && { bzip2 -dfk  setup.bz2 && mv setup setup.ini || rm -f setup.bz2; }; }
-    download_and_verify "$mirror/$arch/setup.ini" || break
+    || { download_and_verify "$mirror/$arch/setup.bz2" && { bzip2 -dfk  setup.bz2 && mv setup setup.ini || rm -f setup.bz2; }; } \
+    || download_and_verify "$mirror/$arch/setup.ini" || break
     
     files_backup_clean setup.{zst,xz,bz2,ini}{,.sig}
     popd > /dev/null
     verbose 1 "Updated setup.ini"
     return
   done
-  files_restore setup.ini setup.ini.sig setup.bz2 setup.bz2.sig
+  files_restore setup.{zst,xz,bz2,ini}{,.sig}
   popd > /dev/null
   error "updating setup.ini failed, reverting."
   return 1

From 5d824b029ccbd46bce87a65868c34a79baac793e Mon Sep 17 00:00:00 2001
From: Yak! 
Date: Sun, 23 Jul 2023 14:14:15 +0900
Subject: [PATCH 303/309] Add --mirror-index|-M option to choose a mirror.

- Add --mirror-index|-M option.
- Add fd tweaks to findworkspace() and its caller
  for error handling for the above option.
- Add completion for the above option with new pathof argument.
---
 apt-cyg | 32 ++++++++++++++++++++++++++++----
 1 file changed, 28 insertions(+), 4 deletions(-)

diff --git a/apt-cyg b/apt-cyg
index d622953..5041d03 100755
--- a/apt-cyg
+++ b/apt-cyg
@@ -182,7 +182,7 @@ function usage()
 	  describe  ...  : to describe packages matching patterns
 	  packageof  ... :
 	                             to locate parent packages
-	  pathof {cache|mirror|mirrordir|cache/mirrordir|setup.ini} :
+	  pathof {cache|mirror|mirrordir|cache/mirrordir|setup.ini|lastmirror} :
 	                             to show path
 	  key-add  ...      : to add keys contained in 
 	  key-del  ...     : to remove keys 
@@ -290,6 +290,8 @@ function usage()
 	                             disable completion autoupdate
 	  --max-jobs, -j        : Run  jobs in parallel
 	  --mirror, -m        : set mirror
+	  --mirror-index, -M    : choose mirror from last-mirror list.
+	                              is 0-based index in last-mirror.
 	  --cache, -c         : set cache
 	  --file, -f         : read package names from 
 	  --noupdate, -u           : don't update setup.ini from mirror
@@ -567,6 +569,18 @@ function findworkspace()
 
     save_vars_to_cache "${cachevars[@]}"
   }
+  # apt-cyg-pathof suppresses output from fd 1 and fd 2,
+  # and fd 3 is duplicated from actual fd 2 for bypass.
+  # Other callers don't have fd 3, so check it and duplicate fd 2 to fd 3.
+  { exec 2>&3; } 2>/dev/null || exec 3>&2
+  [ -z "$OPT_MIRROR_INDEX" ] || {
+    [[ $OPT_MIRROR_INDEX =~ ^[0-9]+$ ]] && \
+      (( 0 <= $OPT_MIRROR_INDEX && $OPT_MIRROR_INDEX < ${#last_mirror[@]} )) || \
+        { error "mirror index must be from 0 to $((${#last_mirror[@]}-1)), inclusive"; exit 1; }
+    mirror="${last_mirror[OPT_MIRROR_INDEX]}"
+    mirror="${mirror%/}"
+    mirrordir="$(mirror_to_mirrordir "$mirror/")"
+  } 2>&3
 
   verbose 1 "Cache directory is $cache"
   verbose 1 "Mirror is $mirror"
@@ -916,7 +930,7 @@ function apt-cyg-key-finger ()
 
 function apt-cyg-pathof ()
 {
-  findworkspace >& /dev/null
+  findworkspace 3>&2 >& /dev/null
   while [ "$#" -gt 0 ]; do
     case "$1" in
       cache)            echo "$cache" ;;
@@ -924,6 +938,7 @@ function apt-cyg-pathof ()
       mirrordir)        echo "$mirrordir" ;;
       cache/mirrordir)  echo "$cache/$mirrordir" ;;
       setup.ini)        echo "$cache/$mirrordir/$arch/setup.ini" ;;
+      lastmirror)       echo "${last_mirror[@]}" ;;
       *)
         error "unknown parameter: $1"
         exit 1
@@ -1355,16 +1370,17 @@ function __apt-cyg ()
   
   getsubcmd=( apt-cyg --completion-get-subcommand $(echo "${COMP_LINE}" | sed -E 's/^[ \t]*[^ \t]+//g;s/[^ \t]+$//g') )
   subcmd="$( "${getsubcmd[@]}" )"
+  mirroridxopt=$(echo ${COMP_LINE} | awk 'BEGIN { RS=" " } /^-M|--mirror-index$/ { if(getline) printf "-M %s", $1 }')
   
   case "$subcmd" in
     install|depends|rdepends|describe|find|category)
-      COMPREPLY=( $(awk '/^@ /{print $2}' "$(apt-cyg pathof setup.ini)") )
+      COMPREPLY=( $(awk '/^@ /{print $2}' "$(apt-cyg pathof ${mirroridxopt} setup.ini)") )
       ;;
     remove)
       COMPREPLY=( $(apt-cyg --no-header show 2>/dev/null | awk '$0=$1') )
       ;;
     pathof)
-      COMPREPLY=( cache mirror mirrordir cache/mirrordir setup.ini )
+      COMPREPLY=( cache mirror mirrordir cache/mirrordir setup.ini lastmirror )
       ;;
     *)
       COMPREPLY=( "${__APT_CYG_SUBCMDS[@]}" )
@@ -1383,6 +1399,9 @@ function __apt-cyg ()
     --proxy|-p)
       COMPREPLY=( auto inherit none http:// )
       ;;
+    --mirror-index|-M)
+      COMPREPLY=( $(seq 0 $(($(apt-cyg pathof lastmirror | wc -w)-1))) )
+      ;;
     *)
       COMPREPLY+=( "${__APT_CYG_OPTIONS[@]}" )
       ;;
@@ -2284,6 +2303,11 @@ function parse_args ()
         shift 2 || break
         ;;
       
+      --mirror-index|-M)
+        OPT_MIRROR_INDEX="$2"
+        shift 2 || break
+        ;;
+      
       --cache|-c)
         OPT_CACHE="$2"
         shift 2 || break

From 2e23ac8326ef0eb5b2ba96938ae2cad8e09bcd8a Mon Sep 17 00:00:00 2001
From: kou1okada 
Date: Mon, 24 Jul 2023 13:47:59 +0900
Subject: [PATCH 304/309] Remove old signature of `setup.ini`.

---
 apt-cyg | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/apt-cyg b/apt-cyg
index 4441837..ae3efd4 100755
--- a/apt-cyg
+++ b/apt-cyg
@@ -627,10 +627,10 @@ function setupini_download ()
   while true; do
     verbose 1 "Updating setup.ini"
     false \
-    || { download_and_verify "$mirror/$arch/setup.zst" && { zstd  -dfkq setup.zst && mv setup setup.ini || rm -f setup.zst; }; } \
-    || { download_and_verify "$mirror/$arch/setup.xz"  && { xz    -dfk  setup.xz  && mv setup setup.ini || rm -f setup.xz;  }; } \
-    || { download_and_verify "$mirror/$arch/setup.bz2" && { bzip2 -dfk  setup.bz2 && mv setup setup.ini || rm -f setup.bz2; }; } \
-    || download_and_verify "$mirror/$arch/setup.ini" || break
+    || { download_and_verify "$mirror/$arch/setup.zst" && { zstd  -dfkq setup.zst && mv setup{,.ini} && rm -f setup.ini.sig || rm -fv setup.zst; }; } \
+    || { download_and_verify "$mirror/$arch/setup.xz"  && { xz    -dfk  setup.xz  && mv setup{,.ini} && rm -f setup.ini.sig || rm -fv setup.xz;  }; } \
+    || { download_and_verify "$mirror/$arch/setup.bz2" && { bzip2 -dfk  setup.bz2 && mv setup{,.ini} && rm -f setup.ini.sig || rm -fv setup.bz2; }; } \
+    ||   download_and_verify "$mirror/$arch/setup.ini" || break
     
     files_backup_clean setup.{zst,xz,bz2,ini}{,.sig}
     popd > /dev/null

From a9e67001250302841b4d5437b7d18dbd6b2ecdbf Mon Sep 17 00:00:00 2001
From: kou1okada 
Date: Mon, 24 Jul 2023 13:48:55 +0900
Subject: [PATCH 305/309] Bugfix: Fallbacks for fail of extract `setup.ini` is
 not worked.

---
 apt-cyg | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/apt-cyg b/apt-cyg
index ae3efd4..8b59177 100755
--- a/apt-cyg
+++ b/apt-cyg
@@ -627,9 +627,9 @@ function setupini_download ()
   while true; do
     verbose 1 "Updating setup.ini"
     false \
-    || { download_and_verify "$mirror/$arch/setup.zst" && { zstd  -dfkq setup.zst && mv setup{,.ini} && rm -f setup.ini.sig || rm -fv setup.zst; }; } \
-    || { download_and_verify "$mirror/$arch/setup.xz"  && { xz    -dfk  setup.xz  && mv setup{,.ini} && rm -f setup.ini.sig || rm -fv setup.xz;  }; } \
-    || { download_and_verify "$mirror/$arch/setup.bz2" && { bzip2 -dfk  setup.bz2 && mv setup{,.ini} && rm -f setup.ini.sig || rm -fv setup.bz2; }; } \
+    || { download_and_verify "$mirror/$arch/setup.zst" && { zstd  -dfkq setup.zst && mv setup{,.ini} && rm -f setup.ini.sig || ! rm -fv setup.zst; }; } \
+    || { download_and_verify "$mirror/$arch/setup.xz"  && { xz    -dfk  setup.xz  && mv setup{,.ini} && rm -f setup.ini.sig || ! rm -fv setup.xz;  }; } \
+    || { download_and_verify "$mirror/$arch/setup.bz2" && { bzip2 -dfk  setup.bz2 && mv setup{,.ini} && rm -f setup.ini.sig || ! rm -fv setup.bz2; }; } \
     ||   download_and_verify "$mirror/$arch/setup.ini" || break
     
     files_backup_clean setup.{zst,xz,bz2,ini}{,.sig}

From bbca8304141e637e26d36a4d2db52129ae681d06 Mon Sep 17 00:00:00 2001
From: kou1okada 
Date: Mon, 24 Jul 2023 16:23:06 +0900
Subject: [PATCH 306/309] Update `README.md`.

---
 README.md | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/README.md b/README.md
index c025d32..437df33 100755
--- a/README.md
+++ b/README.md
@@ -21,7 +21,7 @@ Usage
 | `find ` |  to find packages matching patterns |
 | `describe ` |  to describe packages matching patterns |
 | `packageof  ...` |  to locate parent packages |
-| `pathof {cache\|mirror\|mirrordir\|cache/mirrordir\|setup.ini}` |  to show path |
+| `pathof {cache\|mirror\|mirrordir\|cache/mirrordir\|setup.ini|lastmirror}` |  to show path |
 | `key-add  ...` |  to add keys contained in \ |
 | `key-del  ...` |  to remove keys \ |
 | `key-list` |  to list keys |
@@ -91,6 +91,7 @@ Usage
 | `--completion-disable-autoupdate` | disable completion autoupdate |
 | `--max-jobs`, `-j ` | Run \ jobs in parallel |
 | `--mirror`, `-m ` | set mirror
+| `--mirror-index`, `-M ` | choose mirror from last-mirror list. \ is 0-based index in last-mirror. |
 | `--cache`, `-c ` | set cache |
 | `--file`, `-f ` | read package names from \ |
 | `--noupdate`, `-u` | don't update setup.ini from mirror |

From 3a3d447473529da5b72ee8036ecbca09cccfc202 Mon Sep 17 00:00:00 2001
From: kou1okada 
Date: Mon, 24 Jul 2023 17:41:16 +0900
Subject: [PATCH 307/309] Brush up about the -mirror-index option.

- User OPT_VERBOSE_LEVEL instead of fd 3.
- Support multiple mirrors internally.
- Replace `pathof lastmirror` to `pathof mirros`.
---
 README.md |  2 +-
 apt-cyg   | 37 +++++++++++++++----------------------
 2 files changed, 16 insertions(+), 23 deletions(-)

diff --git a/README.md b/README.md
index 437df33..b66318e 100755
--- a/README.md
+++ b/README.md
@@ -21,7 +21,7 @@ Usage
 | `find ` |  to find packages matching patterns |
 | `describe ` |  to describe packages matching patterns |
 | `packageof  ...` |  to locate parent packages |
-| `pathof {cache\|mirror\|mirrordir\|cache/mirrordir\|setup.ini|lastmirror}` |  to show path |
+| `pathof {cache\|mirror\|mirrors\|mirrordir\|cache/mirrordir\|setup.ini}` |  to show path |
 | `key-add  ...` |  to add keys contained in \ |
 | `key-del  ...` |  to remove keys \ |
 | `key-list` |  to list keys |
diff --git a/apt-cyg b/apt-cyg
index 5041d03..8bcca9f 100755
--- a/apt-cyg
+++ b/apt-cyg
@@ -182,7 +182,7 @@ function usage()
 	  describe  ...  : to describe packages matching patterns
 	  packageof  ... :
 	                             to locate parent packages
-	  pathof {cache|mirror|mirrordir|cache/mirrordir|setup.ini|lastmirror} :
+	  pathof {cache|mirror|mirros|mirrordir|cache/mirrordir|setup.ini} :
 	                             to show path
 	  key-add  ...      : to add keys contained in 
 	  key-del  ...     : to remove keys 
@@ -559,28 +559,21 @@ function findworkspace()
   load_vars_from_cache /etc/setup/setup.rc || {
     eval "$(setuprc_import_sections last-cache last-mirror)"
 
-    mirror="$last_mirror"
+    mirror=( "${last_mirror[@]}" )
     cache="$(cygpath -au "$last_cache")"
     
-    cache="${cache%/}"
-    mirror="${mirror%/}"
+    cache=( "${cache[@]/%*(\/)/}" )
+    mirror=( "${mirror[@]/%*(\/)/}" )
     
-    mirrordir="$(mirror_to_mirrordir "$mirror/")"
+    readarray -t mirrordir < <(mirror_to_mirrordir "${mirror[@]/%/\/}" )
 
     save_vars_to_cache "${cachevars[@]}"
   }
-  # apt-cyg-pathof suppresses output from fd 1 and fd 2,
-  # and fd 3 is duplicated from actual fd 2 for bypass.
-  # Other callers don't have fd 3, so check it and duplicate fd 2 to fd 3.
-  { exec 2>&3; } 2>/dev/null || exec 3>&2
   [ -z "$OPT_MIRROR_INDEX" ] || {
-    [[ $OPT_MIRROR_INDEX =~ ^[0-9]+$ ]] && \
-      (( 0 <= $OPT_MIRROR_INDEX && $OPT_MIRROR_INDEX < ${#last_mirror[@]} )) || \
-        { error "mirror index must be from 0 to $((${#last_mirror[@]}-1)), inclusive"; exit 1; }
-    mirror="${last_mirror[OPT_MIRROR_INDEX]}"
-    mirror="${mirror%/}"
-    mirrordir="$(mirror_to_mirrordir "$mirror/")"
-  } 2>&3
+    [[ $OPT_MIRROR_INDEX =~ ^[0-9]+$ ]] || { error "--mirror-index, -M  must be 0 <= n: n = $OPT_MIRROR_INDEX"; exit 1; }
+    mirror=( "${mirror[@]:OPT_MIRROR_INDEX:1}" "${mirror[@]:0:OPT_MIRROR_INDEX}" "${mirror[@]:OPT_MIRROR_INDEX+1}" )
+    readarray -t mirrordir < <(mirror_to_mirrordir "${mirror[@]/%/\/}" )
+  }
 
   verbose 1 "Cache directory is $cache"
   verbose 1 "Mirror is $mirror"
@@ -930,15 +923,15 @@ function apt-cyg-key-finger ()
 
 function apt-cyg-pathof ()
 {
-  findworkspace 3>&2 >& /dev/null
+  OPT_VERBOSE_LEVEL=0 findworkspace
   while [ "$#" -gt 0 ]; do
     case "$1" in
       cache)            echo "$cache" ;;
       mirror)           echo "$mirror" ;;
+      mirrors)          printf "%s/\n" "${mirror[@]}" ;;
       mirrordir)        echo "$mirrordir" ;;
       cache/mirrordir)  echo "$cache/$mirrordir" ;;
       setup.ini)        echo "$cache/$mirrordir/$arch/setup.ini" ;;
-      lastmirror)       echo "${last_mirror[@]}" ;;
       *)
         error "unknown parameter: $1"
         exit 1
@@ -1370,17 +1363,17 @@ function __apt-cyg ()
   
   getsubcmd=( apt-cyg --completion-get-subcommand $(echo "${COMP_LINE}" | sed -E 's/^[ \t]*[^ \t]+//g;s/[^ \t]+$//g') )
   subcmd="$( "${getsubcmd[@]}" )"
-  mirroridxopt=$(echo ${COMP_LINE} | awk 'BEGIN { RS=" " } /^-M|--mirror-index$/ { if(getline) printf "-M %s", $1 }')
+  mirroridxopt=( $(echo ${COMP_LINE} | awk 'BEGIN { RS=" " } /^-M|--mirror-index$/ { if(getline) printf "-M %s", $1 }') )
   
   case "$subcmd" in
     install|depends|rdepends|describe|find|category)
-      COMPREPLY=( $(awk '/^@ /{print $2}' "$(apt-cyg pathof ${mirroridxopt} setup.ini)") )
+      COMPREPLY=( $(awk '/^@ /{print $2}' "$(apt-cyg pathof "${mirroridxopt[@]}" setup.ini)") )
       ;;
     remove)
       COMPREPLY=( $(apt-cyg --no-header show 2>/dev/null | awk '$0=$1') )
       ;;
     pathof)
-      COMPREPLY=( cache mirror mirrordir cache/mirrordir setup.ini lastmirror )
+      COMPREPLY=( cache mirror mirrors mirrordir cache/mirrordir setup.ini )
       ;;
     *)
       COMPREPLY=( "${__APT_CYG_SUBCMDS[@]}" )
@@ -1400,7 +1393,7 @@ function __apt-cyg ()
       COMPREPLY=( auto inherit none http:// )
       ;;
     --mirror-index|-M)
-      COMPREPLY=( $(seq 0 $(($(apt-cyg pathof lastmirror | wc -w)-1))) )
+      COMPREPLY=( $(seq 0 $(($(apt-cyg pathof mirrors | wc -w)-1))) )
       ;;
     *)
       COMPREPLY+=( "${__APT_CYG_OPTIONS[@]}" )

From 4e5373368e95d3d19a9f0097693477d12bf7dd4f Mon Sep 17 00:00:00 2001
From: kou1okada 
Date: Wed, 14 Feb 2024 19:44:04 +0900
Subject: [PATCH 308/309] Improve error messages:

* Add a check for iconv to the check for required commands
  at the start of execution.
* Remove the check for iconv before subcommand execution
  as it became unnecessary.

This related to issue #104.
---
 apt-cyg | 22 +++++++---------------
 1 file changed, 7 insertions(+), 15 deletions(-)

diff --git a/apt-cyg b/apt-cyg
index f1a0166..76473b9 100755
--- a/apt-cyg
+++ b/apt-cyg
@@ -77,14 +77,6 @@ function abort () #= [EXITCODE=1 [CALLSTACKSKIP=0]]
   exit "${1:-1}"
 }
 
-function assert_command_exists () #= [COMMAND ...]
-{
-  local command
-  for command in $@; do
-    hash $command 2>/dev/null || { error "Required command [$command] not found."; exit 1; }
-  done
-}
-
 function dump_callstack () #= [N=1]
 #? N is a depth to skip the callstack.
 #? $CALLSTACK_SKIP is depth to skip the callstack too.
@@ -159,12 +151,13 @@ TRUSTEDKEY_CYGWIN_URL_LATEST="https://cygwin.com/key/pubring.asc"
 
 # this script requires some packages
 
-read WGET < <( type -p wget 2>/dev/null )
-read TAR  < <( type -p tar  2>/dev/null )
-read GAWK < <( type -p awk  2>/dev/null )
-read GPG  < <( type -p gpg2 2>/dev/null || type -p gpg   2>/dev/null )
-if [ -z "$WGET" -o -z "$TAR" -o -z "$GAWK" ]; then
-  echo You must install wget, tar and gawk to use apt-cyg.
+read WGET  < <( type -p wget  2>/dev/null )
+read TAR   < <( type -p tar   2>/dev/null )
+read GAWK  < <( type -p awk   2>/dev/null )
+read ICONV < <( type -p iconv 2>/dev/null )
+read GPG   < <( type -p gpg2  2>/dev/null || type -p gpg   2>/dev/null )
+if [ -z "$WGET" -o -z "$TAR" -o -z "$GAWK" -o -z "$ICONV" ]; then
+  echo You must install wget, tar, gawk and libiconv to use apt-cyg.
   exit 1
 fi
 
@@ -2660,7 +2653,6 @@ function invoke_subcommand ()
   local ARGS=( "${@:2}" )
   local ACTION="apt-cyg-${SUBCOMMAND:-help}"
   if type "$ACTION" >& /dev/null; then
-    assert_command_exists iconv
     "$ACTION" "${ARGS[@]}"
   else
     error "unknown subcommand: $SUBCOMMAND"

From cd5f0f80aa98faff2c2d2abcefd8188bf3c87e26 Mon Sep 17 00:00:00 2001
From: kou1okada 
Date: Mon, 18 Mar 2024 16:15:26 +0900
Subject: [PATCH 309/309] Update sha512sum of `pubring.asc`.

This change is related to following issue:

* Cygwin public key hardcoded in apt-cyg expired #105.
---
 apt-cyg | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/apt-cyg b/apt-cyg
index f1a0166..c789b51 100755
--- a/apt-cyg
+++ b/apt-cyg
@@ -151,9 +151,9 @@ init_SGR
 TRUSTEDKEYS=( CYGWIN );
 # ./pubring.asc
 # ------------
-# pub   4096R/E2E56300 2020-02-27 [expires: 2024-02-27]
+# pub   4096R/E2E56300 2020-02-27 [expires: 2026-02-27]
 # uid                  Cygwin 
-TRUSTEDKEY_CYGWIN_SUM="019b3d2efe208f1441c660a34d08151b5c9675523b85e0a4ca748137ed45d086a4eb06e0efd4d86a1479246e62641a0c284ffb8c4b0b637063681a9282beca3d"
+TRUSTEDKEY_CYGWIN_SUM="05db5174c02a4359a4caf7765d0fd894f2ec8f025b97aec5e4408aa1d17a2e27f65b6d70e9faba87ed1eca661643b0608ddc33047c066a3f50c222ccc28e306e"
 TRUSTEDKEY_CYGWIN_FPR="56405CF6FCC81574682A5D561A698DE9E2E56300"
 TRUSTEDKEY_CYGWIN_URL_LATEST="https://cygwin.com/key/pubring.asc"