Quick start

  • apt-cyg is a simple script. To install:
lynx -source rawgit.com/transcode-open/apt-cyg/master/apt-cyg > apt-cyg
chmod +x apt-cyg
cp apt-cyg /bin/

指定国内的镜像地址

apt-cyg  mirror http://mirrors.163.com/cygwin/

Example use of apt-cyg:

apt-cyg install nano

附录,脚本文件如下

#!/bin/bash
# apt-cyg: install tool for Cygwin similar to debian apt-get
#
# The MIT License (MIT)
#
# Copyright (c) 2013 Trans-code Design
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.if [ ${BASH_VERSINFO}${BASH_VERSINFO[1]} -lt 42 ]
thenecho 'Bash version 4.2+ required'exit
fiusage="\
NAMEapt-cyg - package manager utilitySYNOPSISapt-cyg [operation] [options] [targets]DESCRIPTIONapt-cyg is a package management utility that tracks installed packages on aCygwin system. Invoking apt-cyg involves specifying an operation with anypotential options and targets to operate on. A target is usually a packagename, file name, URL, or a search string. Targets can be provided as commandline arguments.OPERATIONSinstallInstall package(s).removeRemove package(s) from the system.updateDownload a fresh copy of the master package list (setup.ini) from theserver defined in setup.rc.downloadRetrieve package(s) from the server, but do not install/upgrade anything.showDisplay information on given package(s).dependsProduce a dependency tree for a package.rdependsProduce a tree of packages that depend on the named package.listSearch each locally-installed package for names that match regexp. If nopackage names are provided in the command line, all installed packages willbe queried.listallThis will search each package in the master package list (setup.ini) fornames that match regexp.categoryDisplay all packages that are members of a named category.listfilesList all files owned by a given package. Multiple packages can be specifiedon the command line.searchSearch for downloaded packages that own the specified file(s). The path canbe relative or absolute, and one or more files can be specified.searchallSearch cygwin.com to retrieve file information about packages. The providedtarget is considered to be a filename and searchall will return thepackage(s) which contain this file.mirrorSet the mirror; a full URL to a location where the database, packages, andsignatures for this repository can be found. If no URL is provided, displaycurrent mirror.cacheSet the package cache directory. If a file is not found in cache directory,it will be downloaded. Unix and Windows forms are accepted, as well asabsolute or regular paths. If no directory is provided, display currentcache.OPTIONS--nodepsSpecify this option to skip all dependency checks.--versionDisplay version and exit.
"version="\
apt-cyg version 1The MIT License (MIT)Copyright (c) 2005-9 Stephen Jungels
"function wget {if command wget -h &>/dev/nullthencommand wget "$@"elsewarn wget is not installed, using lynx as fallbackset "${*: -1}"lynx -source "$1" > "${1##*/}"fi
}function find-workspace {# default working directory and mirror# work wherever setup worked last, if possiblecache=$(awk 'BEGIN {RS = "\n\\<"FS = "\n\t"}$1 == "last-cache" {print $2}' /etc/setup/setup.rc)mirror=$(awk '/last-mirror/ {getlineprint $1}' /etc/setup/setup.rc)mirrordir=$(sed 's / %2f gs : %3a g' <<< "$mirror")mkdir -p "$cache/$mirrordir/$arch"cd "$cache/$mirrordir/$arch"if [ -e setup.ini ]thenreturn 0elseget-setupreturn 1fi
}function get-setup {touch setup.inimv setup.ini setup.ini-savewget -N $mirror/$arch/setup.bz2if [ -e setup.bz2 ]thenbunzip2 setup.bz2mv setup setup.iniecho Updated setup.inielseecho Error updating setup.ini, revertingmv setup.ini-save setup.inifi
}function check-packages {if [[ $pks ]]thenreturn 0elseecho No packages found.return 1fi
}function warn {printf '\e[1;31m%s\e[m\n' "$*" >&2
}function apt-update {if find-workspacethenget-setupfi
}function apt-category {check-packagesfind-workspacefor pkg in "${pks[@]}"doawk '$1 == "@" {pck = $2}$1 == "category:" && $0 ~ query {print pck}' query="$pks" setup.inidone
}function apt-list {local sbqfor pkg in "${pks[@]}"dolet sbq++ && echoawk 'NR>1 && $1~pkg && $0=$1' pkg="$pkg" /etc/setup/installed.dbdonelet sbq && returnawk 'NR>1 && $0=$1' /etc/setup/installed.db
}function apt-listall {check-packagesfind-workspacelocal sbqfor pkg in "${pks[@]}"dolet sbq++ && echoawk '$1~pkg && $0=$1' RS='\n\n@ ' FS='\n' pkg="$pkg" setup.inidone
}function apt-listfiles {check-packagesfind-workspacelocal pkg sbqfor pkg in "${pks[@]}"do(( sbq++ )) && echoif [ ! -e /etc/setup/"$pkg".lst.gz ]thendownload "$pkg"figzip -cd /etc/setup/"$pkg".lst.gzdone
}function apt-show {find-workspacecheck-packagesfor pkg in "${pks[@]}"do(( notfirst++ )) && echoawk '$1 == query {printfd++}END {if (! fd)print "Unable to locate package " query}' RS='\n\n@ ' FS='\n' query="$pkg" setup.inidone
}function apt-depends {find-workspacecheck-packagesfor pkg in "${pks[@]}"doawk '@include "join"$1 == "@" {apg = $2}$1 == "requires:" {for (z=2; z<=NF; z++)reqs[apg][z-1] = $z}END {prpg(ENVIRON["pkg"])}function smartmatch(small, large,    values) {for (each in large)values[large[each]]return small in values}function prpg(fpg) {if (smartmatch(fpg, spath)) returnspath[length(spath)+1] = fpgprint join(spath, 1, length(spath), " > ")if (isarray(reqs[fpg]))for (each in reqs[fpg])prpg(reqs[fpg][each])delete spath[length(spath)]}' setup.inidone
}function apt-rdepends {find-workspacefor pkg in "${pks[@]}"doawk '@include "join"$1 == "@" {apg = $2}$1 == "requires:" {for (z=2; z<=NF; z++)reqs[$z][length(reqs[$z])+1] = apg}END {prpg(ENVIRON["pkg"])}function smartmatch(small, large,    values) {for (each in large)values[large[each]]return small in values}function prpg(fpg) {if (smartmatch(fpg, spath)) returnspath[length(spath)+1] = fpgprint join(spath, 1, length(spath), " < ")if (isarray(reqs[fpg]))for (each in reqs[fpg])prpg(reqs[fpg][each])delete spath[length(spath)]}' setup.inidone
}function apt-download {check-packagesfind-workspacelocal pkg sbqfor pkg in "${pks[@]}"do(( sbq++ )) && echodownload "$pkg"done
}function download {local pkg digest digactualpkg=$1# look for package and save desc fileawk '$1 == pc' RS='\n\n@ ' FS='\n' pc=$pkg setup.ini > descif [ ! -s desc ]thenecho Unable to locate package $pkgexit 1fi# download and unpack the bz2 or xz file# pick the latest version, which comes firstset -- $(awk '$1 == "install:"' desc)if (( ! $# ))thenecho 'Could not find "install" in package description: obsolete package?'exit 1fidn=$(dirname $2)bn=$(basename $2)# check the md5digest=$4case ${#digest} in32) hash=md5sum    ;;128) hash=sha512sum ;;esacmkdir -p "$cache/$mirrordir/$dn"cd "$cache/$mirrordir/$dn"if ! test -e $bn || ! $hash -c <<< "$digest $bn"thenwget -O $bn $mirror/$dn/$bn$hash -c <<< "$digest $bn" || exitfitar tf $bn | gzip > /etc/setup/"$pkg".lst.gzcd ~-mv desc "$cache/$mirrordir/$dn"echo $dn $bn > /tmp/dwn
}function apt-search {check-packagesecho Searching downloaded packages...for pkg in "${pks[@]}"dokey=$(type -P "$pkg" | sed s./..)[[ $key ]] || key=$pkgfor manifest in /etc/setup/*.lst.gzdoif gzip -cd $manifest | grep -q "$key"thenpackage=$(sed 's,/etc/setup/,,s,.lst.gz,,' <<< $manifest)echo $packagefidonedone
}function apt-searchall {cd /tmpfor pkg in "${pks[@]}"doprintf -v qs 'text=1&arch=%s&grep=%s' $arch "$pkg"wget -O matches cygwin.com/cgi-bin2/package-grep.cgi?"$qs"awk 'NR == 1 {next}mc[$1]++ {next}/-debuginfo-/ {next}/^cygwin32-/ {next}{print $1}' FS=-[[:digit:]] matchesdone
}function apt-install {check-packagesfind-workspacelocal pkg dn bn requires wr package sbq scriptfor pkg in "${pks[@]}"doif grep -q "^$pkg " /etc/setup/installed.dbthenecho Package $pkg is already installed, skippingcontinuefi(( sbq++ )) && echoecho Installing $pkgdownload $pkgread dn bn </tmp/dwnecho Unpacking...cd "$cache/$mirrordir/$dn"tar -x -C / -f $bn# update the package databaseawk 'ins != 1 && pkg < $1 {print pkg, bz, 0ins = 1}1END {if (ins != 1) print pkg, bz, 0}' pkg="$pkg" bz=$bn /etc/setup/installed.db > /tmp/awk.$$mv /etc/setup/installed.db /etc/setup/installed.db-savemv /tmp/awk.$$ /etc/setup/installed.db[ -v nodeps ] && continue# recursively install required packagesrequires=$(awk '$1=="requires", $0=$2' FS=': ' desc)cd ~-wr=0if [[ $requires ]]thenecho Package $pkg requires the following packages, installing:echo $requiresfor package in $requiresdoif grep -q "^$package " /etc/setup/installed.dbthenecho Package $package is already installed, skippingcontinuefiapt-cyg install --noscripts $package || (( wr++ ))donefiif (( wr ))thenecho some required packages did not install, continuingfi# run all postinstall scripts[ -v noscripts ] && continuefind /etc/postinstall -name '*.sh' | while read scriptdoecho Running $script$scriptmv $script $script.donedoneecho Package $pkg installeddone
}function apt-remove {check-packagescd /etccygcheck awk bash bunzip2 grep gzip mv sed tar xz > setup/essential.lstfor pkg in "${pks[@]}"doif ! grep -q "^$pkg " setup/installed.dbthenecho Package $pkg is not installed, skippingcontinuefiif [ ! -e setup/"$pkg".lst.gz ]thenwarn Package manifest missing, cannot remove $pkg. Exitingexit 1figzip -dk setup/"$pkg".lst.gzawk 'NR == FNR {if ($NF) ess[$NF]next}$NF in ess {exit 1}' FS='[/\\\\]' setup/{essential,$pkg}.lstesn=$?if [ $esn = 0 ]thenecho Removing $pkgif [ -e preremove/"$pkg".sh ]thenpreremove/"$pkg".shrm preremove/"$pkg".shfimapfile dt < setup/"$pkg".lstfor each in ${dt[*]}do[ -f /$each ] && rm /$eachdonefor each in ${dt[*]}do[ -d /$each ] && rmdir --i /$eachdonerm -f setup/"$pkg".lst.gz postinstall/"$pkg".sh.doneawk -i inplace '$1 != ENVIRON["pkg"]' setup/installed.dbecho Package $pkg removedfirm setup/"$pkg".lstif [ $esn = 1 ]thenwarn apt-cyg cannot remove package $pkg, exitingexit 1fidone
}function apt-mirror {if [ "$pks" ]thenawk -i inplace '1/last-mirror/ {getlineprint "\t" pks}' pks="$pks" /etc/setup/setup.rcecho Mirror set to "$pks".elseawk '/last-mirror/ {getlineprint $1}' /etc/setup/setup.rcfi
}function apt-cache {if [ "$pks" ]thenvas=$(cygpath -aw "$pks")awk -i inplace '1/last-cache/ {getlineprint "\t" vas}' vas="${vas//\\/\\\\}" /etc/setup/setup.rcecho Cache set to "$vas".elseawk '/last-cache/ {getlineprint $1}' /etc/setup/setup.rcfi
}if [ -p /dev/stdin ]
thenmapfile -t pks
fi# process options
until [ $# = 0 ]
docase "$1" in--nodeps)nodeps=1shift;;--noscripts)noscripts=1shift;;--version)printf "$version"exit;;update)command=$1shift;;list | cache  | remove | depends | listall  | download | listfiles |\show | mirror | search | install | category | rdepends | searchall )if [[ $command ]]thenpks+=("$1")elsecommand=$1fishift;;*)pks+=("$1")shift;;esac
doneset -aif type -t apt-$command | grep -q function
thenreadonly arch=${HOSTTYPE/i6/x}apt-$command
elseprintf "$usage"
fi

让cygwin方便安装软件 apt-cyg相关推荐

  1. cygwin下安装软件

    2019独角兽企业重金招聘Python工程师标准>>> http://blog.csdn.net/forlong401/article/details/8517711 很多时候,我们 ...

  2. linux安装软件apt或者编译安装说明

    文章目录 静态库打包成程序时已经编译到程序内运行时不要链接,但是动态库需要 为什么静态和动态库,静态链接时完全拷贝,动态库执行时链接拷贝入内存,多程序公用 讲解静态动态区别 cmake中添加第三方库和 ...

  3. cygwin中安装软件

    一种是使用apt-cyg: lynx -source rawgit.com/transcode-open/apt-cyg/master/apt-cyg > apt-cyg chmod +x ap ...

  4. apt ubuntu 指定ipv4_如何使用 apt 命令安装软件

    apt 命令是做什么的 apt是一个命令行实用程序,用于在Ubuntu.Debian和相关Linux发行版上安装.更新.删除和管理deb软件包,它结合了apt-get和apt-cache工具中最常用的 ...

  5. cygwin用命令安装软件_Cygwin本地安装版

    cygwin本地安装版离线即可安装,使用十分方便,适合linux.安卓平台软件开发与测试时使用,倍受行业人员和学者们的青睐. http://www.itmop.com/downinfo/13002.h ...

  6. Cygwin中如何像在Ubuntu中一样安装软件

    cygwin作为windows下模拟Linux环境的的工具,使得我们能在windows下非常方便的使用Linux的命令和工具,下面讲讲怎样在cygwin添加不支持的命令. 1.首先安装cygwin: ...

  7. debian 11 apt 安装软件报错:Media change: please insert the disc labeled

    新安装了Debian环境,在安装软件的时候报错Media change: please insert the disc labeled,这是由于Debian的软件源中存在如下配置,即通过DVD光盘来安 ...

  8. Linux基础-制作本地apt仓库(离线安装软件)

    目录 一.准备工作 1.首先找一台可以访问互联网的机器,系统版本需要和离线环境一致,推荐安装一台虚拟机 2.配置网络APT源 二.下载 1.查看当前软件包 1)命令 2)实例 2.下载软件与相关依赖包 ...

  9. Linux查看已经安装软件的版本,安装软件的路径,以及dpkg、aptitude、apt-get、apt工具的使用

    Linux查看已经安装软件的版本,安装软件的路径,以及dpkg.aptitude.apt-get.apt工具的使用: 1 dpkg的使用 2 Linux查看已经安装的软件以及版本 2.1 Linux查 ...

最新文章

  1. 用HttpWebRequest抓取网页,尝试自动重定向的次数太多”的错误,
  2. ICG游戏:证明,先手不是必胜就是必败。
  3. 海南师范大学计算机设计大赛证书,我校品牌VI设计作品在中国大学生计算机设计大赛海南省赛中获得一等奖...
  4. 一篇文章指明做JavaWeb项目需要的前置知识+完整项目初解读(萌新必看,十分友好)
  5. C案例:打印斐波拉契数列
  6. win7下U盘安装Ubuntu16.04双系统
  7. Python数据结构与算法(1.3)——Python基础之输入、输出与高阶赋值
  8. 【倒计时10day】看雪论坛精华优秀文章分享与点评
  9. axure6.5汉化
  10. laravel8+ 微信小程序生成二维码
  11. 手游无限多开器安卓版_万能多开助手app下载-万能多开助手 安卓版v3.8.2-PC6安卓网...
  12. 书小宅之C#——实现的第三方程序嵌入自己的WinForm
  13. PEP8 Python 编码规范 -----Indent 缩进
  14. Java入门-机票购买、座舱等级、淡旺季计算价格
  15. Python爬虫之App爬虫视频下载
  16. 20220425二次型复习
  17. dz diy html用户信息,Discuz教程:个人资料设置只显示用户名的解决方法
  18. 混合动力客车整车控制策略及总成参数匹配研究
  19. 为王菲写的第十首《雄心永在》
  20. Transformer29

热门文章

  1. VHDL和Verilog HDL的区别
  2. 玩转微信小程序 之 获取用户信息以及玩转基本列表渲染(2019/04/14)
  3. 网络设备配置与管理————11、配置主机名、时钟、IP地址
  4. 防手机锁屏解锁自定义View
  5. PHP 简单案例[4]
  6. 【数据存储】从hashMap、mysql、redis、到分布式
  7. 华中科技大计算机全国排名,2017华中科技大学全国排名第几
  8. 我决定谈一谈世界上最著名的虫子:BUG !
  9. C++入门:鸡兔同笼问题
  10. 游戏低延迟高续航真无线蓝牙耳机,小巧便捷出差旅行必备