121

I'm a blind computer user that uses Cygwin.

The installation program isn't very accessible: upgrading, installing, and removing specific packages is quite hard to do since you have to use simulated mouse keystrokes to click and scroll.

Is there a way to either manually install/upgrade packages or install/upgrade them through the command-line?

Zombo
  • 1
  • 24
  • 120
  • 163
Jared
  • 2,255
  • 3
  • 22
  • 27

10 Answers10

123

Install apt-cyg:

lynx -source https://raw.githubusercontent.com/transcode-open/apt-cyg/master/apt-cyg > apt-cyg
install apt-cyg /bin

After that you'll be able to install say the package "lynx" including dependencies by running:

apt-cyg install lynx
gliptak
  • 229
  • 3
  • 7
knorv
  • 3,492
  • 7
  • 27
  • 23
  • 5
    The repository hasn't **moved** : a DMCA complaint has been [issued](//github.com/github/dmca/blob/master/2016-01-27-apt-cyg-counternotice.md) againt transcode-open/apt-cyg. Incidentally, Github user svnpenn created a fork named "sage" at the same time, claiming to be its successor – Lucas Cimon Feb 11 '16 at 14:34
  • 3
    [Updated link for the DMCA counternotice](https://github.com/github/dmca/blob/ffd9865c2b143512aa7e6e2467ffcbe95accba69/2016-01-27-apt-cyg-counternotice.md) ... [svnpenn/sage fork](https://github.com/svnpenn/sage) – Abdull Apr 05 '17 at 05:45
  • I had to chmod +x apt-cyg for it to be executable (just in case it helps someone) – Pedro A Mar 25 '18 at 19:34
25

Old question, but for others that google and got here: Official setup has command line arguments which allowed me to prepare simple *.bat script - just put following line in e.g. "install-pkg.bat" and put that file into your root directory (e.g. C:\cygwin):

setup-x86.exe --no-desktop --no-shortcuts --no-startmenu --quiet-mode --root "%cd%" --packages %*

You need to download and put http://www.cygwin.com/setup-x86.exe (32bit) or http://www.cygwin.com/setup-x86_64.exe (64bit) into the same directory. Now all you have to do to install package is:

install-pkg packagename

Positive: official setup, should always work, for any package. Negative: current (june/2015) official setup requires administrator rights even though it actually does not need one (e.g. root directory outside system folders).

peenut
  • 389
  • 3
  • 4
  • 1
    nice answer, as it's a tool that you already have in any Cygwin installation; however, it seems that you can't keep it from updating all the already installed packages? it's quite annoying if you just want to install one new package; in other words, there is no command-line equivalent to the "Keep" option of the graphical setup.exe – golimar Mar 28 '12 at 22:26
  • 1
    note setup.exe is now called setup-x86.exe - or a variant depending on cpu bits. – ErichBSchulz Jan 18 '14 at 06:47
  • Link is broken, now is : https://cygwin.com/faq/faq.html#faq.setup.cli Can you edit that in your answer ? Thanks – Benj Jun 10 '15 at 08:59
  • You don't need administrator rights if you use the `--no-admin` switch (same as `-B`). – cdlvcdlv Jul 23 '19 at 08:13
25

Since some people correctly stated that apt-cyg itself needs wget and in order to get apt-cyg you need wget, there is a bash only solution to bootstrap wget in pure bash.

Create a function like this in your mintty bash shell:

function __wget() {
    : ${DEBUG:=0}
    local URL=$1
    local tag="Connection: close"
    local mark=0

    if [ -z "${URL}" ]; then
        printf "Usage: %s \"URL\" [e.g.: %s http://www.google.com/]" \
               "${FUNCNAME[0]}" "${FUNCNAME[0]}"
        return 1;
    fi
    read proto server path <<<$(echo ${URL//// })
    DOC=/${path// //}
    HOST=${server//:*}
    PORT=${server//*:}
    [[ x"${HOST}" == x"${PORT}" ]] && PORT=80
    [[ $DEBUG -eq 1 ]] && echo "HOST=$HOST"
    [[ $DEBUG -eq 1 ]] && echo "PORT=$PORT"
    [[ $DEBUG -eq 1 ]] && echo "DOC =$DOC"

    exec 3<>/dev/tcp/${HOST}/$PORT
    echo -en "GET ${DOC} HTTP/1.1\r\nHost: ${HOST}\r\n${tag}\r\n\r\n" >&3
    while read line; do
        [[ $mark -eq 1 ]] && echo $line
        if [[ "${line}" =~ "${tag}" ]]; then
            mark=1
        fi
    done <&3
    exec 3>&-
}

Now you can use it almost like wget:

__wget http://apt-cyg.googlecode.com/svn/trunk/apt-cyg > /usr/bin/apt-cyg && chmod 0755 /usr/bin/apt-cyg
random
  • 14,638
  • 9
  • 54
  • 58
ikaerom
  • 794
  • 9
  • 19
  • Excuse me, @moreaki, but there is one thing I can not understand from apt-cyg: in the classical CygWin Windows installer I may/must specify the repositories/packages location, whether be it one of the (many) ftp/http download sites, or local drive (in my computer). I don't see such option in the official googlecode site. Where does `apt-cyg` download the packages from? – Sopalajo de Arrierez Apr 19 '14 at 19:24
  • Pardon my late reply. I have just skimmed through the code of apt-cyg on the official googlecode site and to me it looks like the selected download site seems to be `http://mirrors.kernel.org/sourceware/cygwin`, as specified in `findworkspace()`, when you haven't specified the mirror using the command line option `-m`. If you specify the command line, the mirror server information will be written to `/etc/setup/last-mirror`. – ikaerom Jun 19 '14 at 17:29
  • apt-cyg installation no longer relies on wget, so none of this probably matters any more? They use lynx (which seems to be built-in in cygwin?) on their website. – akauppi Jul 17 '15 at 12:00
  • @steven What's the reason for the wholesale edit that changes more than a substantial portion? It's pretty much a separate answer itself – random Oct 25 '15 at 19:16
  • @steven Then that would be cause for a new answer to showcase that, and not to summarily change an existing answer against the intent and voice of the original author – random Oct 25 '15 at 21:39
  • 2
    Then downvote and provide a competing answer. If you are the maintainer of apt-cyg there is no indication on your profile or in your edit summary or anywhere visible that suggests that kind of authority or background to steamroll in with swathes of these kind of edits – random Oct 25 '15 at 21:45
  • @random you should be @ mentioning me so I do not have to keep checking. Also I think this should do nicely http://github.com/transcode-open/apt-cyg/graphs/contributors – Zombo Oct 25 '15 at 21:57
21

The official apt-cyg installation method is:

lynx -source rawgit.com/transcode-open/apt-cyg/master/apt-cyg > apt-cyg
install apt-cyg /bin

Two steps is better than three. Then:

apt-cyg install nano

By the way, to make it work you will need to install wget, tar, gawk and bzip2 in order to use apt-cyg. Apart from wget, the others come with default Cygwin installation.

Journeyman Geek
  • 127,463
  • 52
  • 260
  • 430
Marc Climent
  • 335
  • 3
  • 11
  • 2
    For 64-bit Cygwin, `svn` and `apt-cyg` may be broken. So you may have to use the `three step` wget approach to install `apt-cyg` and then replace `$mirror/setup...` with `$mirror/x86_64/setup...` in lines 98 and 105 of apt-cyg file. – sagunms Oct 08 '13 at 09:00
13

Cygwin's setup.exe, at least in the 1.7 "beta" release, has an "unattended" mode built-in. Drag and drop your setup.exe shortcut into a command window (or otherwise prepare to run it with switches), and add -q for unattended mode followed by -P and comma-separated package names. So, for me, this installed lynx:

$ "C:\Documents and Settings\martind\Desktop\setup-1.7.exe" -q -P lynx
zessx
  • 813
  • 1
  • 9
  • 21
Martin Dorey
  • 241
  • 1
  • 8
9
setup-x86 -nq -s http://box-soft.com -P curl,git,make

or

setup-x86 -nq -s http://box-soft.com -P curl -P git -P make

This will install cURL, git, and make, with no shortcuts in quiet mode.

Zombo
  • 1
  • 24
  • 120
  • 163
2

I found two 'apt like' package managers for cygwin. One is a python script called cyg-apt which you can download from http://www.lilypond.org/~janneke/software/cyg-apt and the other is apt-cyg which you can find at http://code.google.com/p/apt-cyg/

Mokubai
  • 89,133
  • 25
  • 207
  • 233
LunchMoney
  • 156
  • 2
1

There is a chicken <=> egg problem with the accepted answer. If you didn't get wget or lynx during the initial install, you cannot use apt-cyg. Here is how I installed wget so that I could use apt-cyg. (It uses the CLI features of the cygwin setup exe.)

# check to see if you are running 64 bit cygwin
$ uname -a
CYGWIN_NT-10.0 WINDOWS-ABMESEI 2.6.0(0.304/5/3) 2016-08-31 14:32 x86_64 Cygwin

# if you are not using 64 bit, get http://www.cygwin.com/setup-x86.exe instead of...
$ curl -o cygwin-setup.exe http://www.cygwin.com/setup-x86_64.exe
$ chmod +x cygwin-setup.exe

# now you are ready to use it according to: https://cygwin.com/faq/faq.html#faq.setup.cli
$ cygwin-setup.exe --no-desktop --no-shortcuts --no-startmenu --quiet-mode --packages wget
Bruno Bronosky
  • 1,885
  • 1
  • 20
  • 26
0

Other answers are missing the dependencies you need before you can run the lynx installer within Cygwin. Run this from a privileged powershell or equivalent (your setup executable should be somewhere like Downloads\ or C:\tools\cygwin):

./setup-x86_64.exe -q -P git,vim,curl,wget,zsh,chere,iconv,lynx

After that, you can launch cygwin and install the package manager:

lynx -source rawgit.com/transcode-open/apt-cyg/master/apt-cyg > apt-cyg
install apt-cyg /bin
3pitt
  • 145
  • 2
  • 8
-1

For at least packages that do not require post-install configuration, I have simply untarred them from the cygwin root '/'. I required an older version of subversion (1.7.14) which had passed beyond the two versions handled by setup.

An additional advantage is the package becomes outside the cygwin package management world and thus in a kind of adhoc blacklist is not automatically updated with the newest package if defaults are kept.

Chris
  • 1