mirror and cache are now operations rather than options. This is in line with
both apt-get and pacman. Note this does mean some situations may require extra
commands. For example if you want to temporarily change the mirror, you will
need to do
apt-cyg mirror http://alpha.com
apt-cyg install bravo
apt-cyg mirror http://charlie.com
This may end up being nothing, but would like to rewrite apt-cyg in Go. This
will be nice because you will end up with a single EXE file, similar to
setup-x86_64.exe. The difference is that it will be totally command line like
apt-cyg, but better because you can build all the requirements
(wget, bunzip2, awk) right into the EXE. My concern right now is that I will
probably have to write an INI parser, because Cygwin setup.ini is a weird
format. Since I am just starting with Go I may not have the skill, we shall see.
Here are the changes, by line number:
- remove "-c", keep long version
- remove "-f" and "--file". I have never used this, and apt-get does does have
it
- remove "-m", keep long version
- remove "--help", you can get help by just "apt-cyg"
- lowercase ARCH variable, typically uppercase is for exported variables
- use readonly variables where applicable
- remove setup.ini-save, I see no point in this, and setup.exe does not use it
- go back to using "[" over "[[", more portable
- declare all variables local in "begin" function, this will prevent creation of
global variables. Child functions still have access to local variables, but
the only fix to that is running every function in a subshell, which is also
not ideal
- use "let" over "(("
- stop using awk ENVIRON array. This became a problem because the array is only
populated with exported variables. We do not want variables being passed to
child "apt-cyg" processes just to play nice with awk
- use "return" in functions instead of "exit", this will allow proper running of
"charlie" function
- add "check-packages" to some functions
- stop creating "desc" files, you can parse this information out of setup.ini
easy enough, and setup.exe does not create them either
- generate md5 file from setup.ini, this way you can use it with md5sum instead
of stdin
- utilize "wget -rnH" to create directories
- stop running "type -P" when searching for a file with "apt-cyg search".
apt-get does not do this and it could be confusing
- break "--cache" and "--mirror" out of the case statement and into their own
functions. this will make the case statement less unwieldy
- write directly to "installed.db" using "awk -i inplace"
- function "charlie": this check for any leaked global variables and prints them
to stdout just before the script finishes. this should help with debugging
- use one awk command instead of two, to determine if package is not removable
- save comparison files to /etc/setup instead of /tmp
- save as "essential.lst" and "$pkg.lst" respectively
- use warnings where appropriate
- new file list logic
- extract file list
- if package is essential, remove file list and exit
- if package is not essential, remove package, remove file list and continue
- new delete logic
- remove all files
- remove empty directories
- utilize awk inplace where appropriate
apt-cyg has had a long standing circular dependency with wget. This is because
Base Cygwin does not include wget or curl. I have mentioned before workarounds
to this
41e1d91172
However none were ideal. I have since discovered lynx, which can be used in a
pinch to download files
http://unix.stackexchange.com/a/83987
lynx has these features
- pure command line, unlike setup-x86_64
- works with "https://" URLs, unlike /dev/tcp
- comes with Base Cygwin, unlike wget/curl
If wget is not installed, lynx will be used as a fallback with a warning
printed.
when dealing with package dependency woes, such as
http://cygwin.com/ml/cygwin/2014-10/msg00563.html
The current "depends" tree method fails, because it only shows the packages, not
the dependency paths. These paths are necessary to solve the "shortest path
problem"
http://wikipedia.org/wiki/Shortest_path_problem
Now, every possible dependency path will print from the chosen package. Combined
with category search you can run searches such as
apt-cyg category Base |
apt-cyg depends |
awk '/perl$/ {print length,$0}' |
sort -n
Solving the path problem in seconds.
Can now pipe package names to apt-cyg, example
echo bash | apt-cyg show
If --file is provided as well, it will override stdin
echo bash | apt-cyg show --file foo.txt
Note the Linux analog "apt-cache show" does not provide this functionality.
Some packages were being downloaded to wrong location. For example "gcc-core" is
supposed to be found at
release/gcc/gcc-core
However it was being downloaded at
release/gcc-core
Packages will now be downloaded as directed by "setup.ini"
1. create proxy file if not exist
2. create array from proxy file if not exist
3. if array is empty download proxy file
4. shift continue unless country is US
5. shift continue if proxy is slow
6. shift continue if proxy is blocked by Google
7. print successful proxy
8. save remaining proxies to file