GithubHelp home page GithubHelp logo

maphew / apt Goto Github PK

View Code? Open in Web Editor NEW
4.0 4.0 2.0 1.05 MB

command line package manager for Osgeo4W

Home Page: http://trac.osgeo.org/osgeo4w/wiki/pkg-apt

License: GNU General Public License v2.0

Python 94.46% Batchfile 5.54%
gis osgeo4w python

apt's Introduction

Matt’s code thicket

A sometimes-tended garden of things a hewer of maps has made and copied that can occasionally be turned to useful work.

apt's People

Contributors

amr66 avatar maphew avatar mhw-at-yg avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

amr66 cynerboy

apt's Issues

Move apt install location from `bin` to `apps`

I believe this will enable:

  • easier to upgrade self and python, because we can enforce using a separate python27.dll that isn't in active use at run time
  • distribute a smaller apt.exe: because the redistributed system .dll's won't have to included again with every version bump, which in turn will make it easier and faster to release new exe versions

install arbitrary package versions?

I released a new apt.exe testing package today. When I started setting up an environment to test what it will do in an upgrade situation I realised I need to put Osgeo4W into an older state, which means installing no-longer-current packages first. This isn't so easy.

I think the easiest approach is likely to be to adapting osgeo4w-regen.sh and genini to generate a setup.ini based on a date stamp. Then issuing an instruction like regen.sh 2014-06-01 would crawl the release package tree, ignore any files newer than said date, and generate setup_2014-06-01.ini.

Actually this is something useful for setup.exe too. I'm going to create a ticket for it upstream.

upgrade doesn't download all before proceeding to install

B:\code\apt>apt upgrade all
warning: missing packages: qgis tcltk
to install:    qgis tcltk qgis-common

qgis-grass-plugin = d:/temp/o4w-cache/setup/http%3a%2f%2fdownload.osgeo.org%2
gin/qgis-grass-plugin-2.6.0-1.tar.bz2

remote:  22a54f29e679bb8fe2b837276152ddb7  qgis-grass-plugin-2.6.0-1.tar.bz2
local:   22a54f29e679bb8fe2b837276152ddb7  qgis-grass-plugin-2.6.0-1.tar.bz2

qgis-grass-plugin = d:/temp/o4w-cache/setup/http%3a%2f%2fdownload.osgeo.org%2
gin/qgis-grass-plugin-2.6.0-1.tar.bz2

remote:  22a54f29e679bb8fe2b837276152ddb7  qgis-grass-plugin-2.6.0-1.tar.bz2
local:   22a54f29e679bb8fe2b837276152ddb7  qgis-grass-plugin-2.6.0-1.tar.bz2

qgis-grass-plugin = d:/temp/o4w-cache/setup/http%3a%2f%2fdownload.osgeo.org%2
gin/qgis-grass-plugin-2.6.0-1.tar.bz2

remote:  22a54f29e679bb8fe2b837276152ddb7  qgis-grass-plugin-2.6.0-1.tar.bz2
local:   22a54f29e679bb8fe2b837276152ddb7  qgis-grass-plugin-2.6.0-1.tar.bz2
installing qgis 2.6.0-1
Traceback (most recent call last):
  File "apt.py", line 1384, in <module>
    __main__.__dict__[command] (packages)
  File "apt.py", line 522, in upgrade
    install(packages)
  File "apt.py", line 229, in install
    install_next(missing.keys(), set([]), set([]))
  File "apt.py", line 258, in install_next
    do_install(packagename)
  File "apt.py", line 627, in do_install
    pipe = tarfile.open(ball,'r')
  File "B:\o4w\apps\Python27\lib\tarfile.py", line 1660, in open
    return func(name, "r", fileobj, **kwargs)
  File "B:\o4w\apps\Python27\lib\tarfile.py", line 1722, in gzopen
    fileobj = bltn_open(name, mode + "b")
IOError: [Errno 2] No such file or directory: 'd:/temp/o4w-cache/setup/http%3
release/qgis/qgis/qgis-2.6.0-1.tar.bz2'

Issue on getopt, comma missing

lately i came back to an old behavior of apt, that getopt (sometimes?) would not accept long name options like --ini and so on.
It's just a missing comma in the long name list, after 'root='

    (options, params) = getopt.getopt (sys.argv[1:],
                      'cdhi:m:r:t:s:xv',
                      ('cache=', 'download', 'help', 'mirror=', 'root='
                       'ini=', 't=', 'start-menu=', 'no-deps', 'debug', 'verbose'))

May be you want to change this ...

Use alternate ini option is broken

B:\code\apt>apt --ini b:\o4w-packages\setup_2014-12-01.ini available

GetoptError: option --ini not recognized

B:\code\apt>apt -i b:\o4w-packages\setup_2014-12-01.ini available

IOError: [Errno url error] unknown url type: 'b'

B:\code\apt>apt -i file://b:\o4w-packages\setup_2014-12-01.ini available

IOError: [Errno socket error] [Errno 11004] getaddrinfo failed

Remove readonly file doesn't report that to console

From fix f3540a1

Today I noticed a knock on effect: even though the readonly file is removed from the file system and the installed-files-list successfully, that removal is not reported to console:

B:\code\apt>attrib  b:\o4w\bin\iconv.dll
A            B:\o4w\bin\iconv.dll

B:\code\apt>attrib +R b:\o4w\bin\iconv.dll

B:\code\apt>attrib  b:\o4w\bin\iconv.dll
A    R       B:\o4w\bin\iconv.dll

B:\code\apt>apt remove iconv
iconv
removing iconv 1.9.1-1
removed: B:\o4w\include\iconv.h
removed: B:\o4w\lib\iconv.lib

B:\code\apt>attrib  b:\o4w\bin\iconv.dll
File not found - B:\o4w\bin\iconv.dll

Apt with --root to save OSGEO4W_ROOT in shell environment

Would be nice if apt --root={...} --bits=64 setup saved the OSGEO4W_ROOT var in the shell so that we can just carry on with the next steps in the same session. Otherwise we have to keep re-using --root in every invocation which is a pain, leading to using set osgeo... at the beginning of a session, which leads to the --root parameter being not used, which is another way of saying "essentially useless". ;-)

update requires `--mirror`, doesn't know about x86/64bit switch.

B:\code\apt>apt update
Fetching http://download.osgeo.org/osgeo4w//setup.ini.bz2
...100%
Traceback (most recent call last):
  File "apt.py", line 1341, in <module>
    update ()
  File "apt.py", line 479, in update
    raise IOError('\n*** Error decompressing: %s' % archive)
IOError:
*** Error decompressing: d:/temp/o4w-cache/setup/http%3a%2f%2fdownload.osgeo.org%2fosgeo4w%2fsetup.ini.bz2

command line option -r --root

is not considered. Could be done in check_env(), would be a good thing if doing a apt setup and no environment variable has been set yet. Anyway, it exists, so it should do something.

Error: "list" not understood, please run "apt help"

X:> apt list
"list" not understood, please run "apt help"

Something broke recently. All other commands are ok.


Never mind. Forgot there is no list command, though now I can't remember the reason. Because of collision with python list() ? Might be sufficient to add an alias, similar to uninstall = remove.

Rework all info-like functions to use `get_info()`

With 32fbd7b we have a working info command, and a get_info() function which builds a dictionary of useful attributes. Now we have the necessary plumbing to rework all the functions which go out one by one to fetch and build the attributes one at a time into simple lookups from the dict.

So instead of calling on 3 chained functions

def ball(packages):
    '''Print full local path name of package archive '''
    print "\n%s = %s" % (p, get_ball(p))

def get_ball (packagename):
    url, md5 = get_url (packagename)
    return '%s/%s' % (downloads, url)

def get_url (packagename):
    if not dists[distname].has_key (packagename) \
   ...~20 lines snipped...
    return filename, md5

we can just do

pkg_info = get_info(pkg)
print pkg_info['ball']

A delightful collapse in complexity which should make understanding and working on this program a whole lot easier and more enjoyable!

Before going to deep into touching all the info-like functions we should spend some time thinking about building a nested list/dictionary one level higher. Get_info() gives us a dict for each package, one at a time. Should we also build a list-of-pkg-dicts for everything all in one go?

KeyError: 'install'

    B:\code\apt>apt remove iconv
    iconv
    warning: iconv not installed

    B:\code\apt>apt install iconv
    Already installed!

    KeyError: 'install'

    B:\code\apt>apt --debug install iconv
    ### DEBUG: parse_setuprc ###
    last-cache:     B:/o4w//var/cache/setup
    last-mirror:    http://download.osgeo.org/osgeo4w/

    ### DEBUG: <module> ###
    last-mirror: http://download.osgeo.org/osgeo4w/
    last-cache: B:/o4w//var/cache/setup
    Already installed!
    iconv               1.9.1-1

    ### DEBUG: write_setuprc ###
    Wrote B:/o4w//etc/setup/setup.rc

3 bugs here:

  1. iconv not installed when it is (verify this; pkg might be in incomplete state)
  2. the command appears to be being treated as a package name
  3. using --debug changes the behaviour, 2nd bug doesn't manifest. Using debug should not change behaviour.

Test script output missing stdout

In b3de40f (and everywhere?) stdout isn't being captured.

What I see at command prompt

Running test-architecture.bat:

Couldn't open C:/Users/Matt/AppData/Local/Temp/apt-9460/etc/setup//setup.rc, setting empty
Fetching http://download.osgeo.org/osgeo4w//x86_64/setup.ini
Skipping download - url modified time isn't newer than local file
D:\Public\Downloads/http%3a%2f%2fdownload.osgeo.org%2fosgeo4w%2f\x86_64/setup.ini

    Osgeo4w folders and setup config exist; skeleton environment is complete.

    You might try `apt available` and `apt install` next.

What is captured

apt---bits=64 setup.stdout - nothing, doesn't exist!

apt---bits=64 setup.stderr

Root dir not found, creating C:/Users/Matt/AppData/Local/Temp/apt-17074
creating C:/Users/Matt/AppData/Local/Temp/apt-17074/etc/setup/
creating C:/Users/Matt/AppData/Local/Temp/apt-17074/etc/setup//installed.db
getting C:/Users/Matt/AppData/Local/Temp/apt-17074/etc/setup//setup.ini

Interactive results

B:\code\apt\tests>apt --bits=64 setup
Couldn't open d:/temp/apt-mar31xx/etc/setup//setup.rc, setting empty
Root dir not found, creating d:/temp/apt-mar31xx
creating d:/temp/apt-mar31xx/etc/setup/
creating d:/temp/apt-mar31xx/etc/setup//installed.db
getting d:/temp/apt-mar31xx/etc/setup//setup.ini
Fetching http://download.osgeo.org/osgeo4w//x86_64/setup.ini
Skipping download - url modified time isn't newer than local file
D:\Public\Downloads/http%3a%2f%2fdownload.osgeo.org%2fosgeo4w%2f\x86_64/setup.ini

    Osgeo4w folders and setup config exist; skeleton environment is complete.

    You might try `apt available` and `apt install` next.

clean and/or remove cached download files

Occasionally a file in the downloads cache is corrupted or doesn't match it's mirror equivalent. Currently one has to remove that local file manually, and locating it in order to do so is a pain. We should either automatically overwrite the local file when downloading, or provide a means to clean the cache of that and/or all files.

...might be able to join or match this with removing versions older than X.

Apt doesn't work from `site-packages` (a.k.a. setup.py incomplete)

D:\>pip install --editable b:\code\apt
Obtaining file:///b:/code/apt
  Running setup.py (path:b:/code/apt\setup.py) egg_info for package from file://
/b:/code/apt

Installing collected packages: apt
  Running setup.py develop for apt
    B:\o4w\apps\Python27\lib\site-packages\setuptools-1.3.2-py2.7.egg\setuptools
\command\easy_install.py:320: UserWarning: Unbuilt egg for apt-Osgeo4w-package-m
anager [unknown version] (b:\code\apt)

    Creating b:\o4w\apps\python27\lib\site-packages\apt.egg-link (link to .)
    Adding apt 0.3 to easy-install.pth file
    Installing apt-script.py script to B:\o4w\apps\Python27\Scripts
    Installing apt.exe script to B:\o4w\apps\Python27\Scripts
    Installing apt.exe.manifest script to B:\o4w\apps\Python27\Scripts

    Installed b:\code\apt
Successfully installed apt
Cleaning up...

D:\>apt
Traceback (most recent call last):
  File "B:\o4w\apps\Python27\Scripts\apt-script.py", line 9, in <module>
    load_entry_point('apt==0.3', 'console_scripts', 'apt')()
  File "b:\code\apt\apt.py", line 1271, in main
    last_mirror = get_config('last-mirror')
  File "b:\code\apt\apt.py", line 727, in get_config
    f = os.path.join(config, fname)
NameError: global name 'config' is not defined

Fixed with new error

My last commit on amr66/apt now allows to download tinyows and dependencies, but it fails with apache. I got a message from shlex called by get_menu_links(). I didn't try much further, but it seems to be a link in apache.bat.done that causes an exception on link = shlex.split(line)[1]. Error is "Value Error: No closing quatation". Line from bat is:
xxmklink "%OSGEO4W_STARTMENU%\Apache\OSGEO4W-Apache-Monitor.lnk" %OSGEO4W_ROOT%\Apache\bin\ApacheMonitor.exe"
Is this a " which is missing in front of %OSGEO4W_ROOT%?
PS:
I just tried to install with setup exe: It works, even the start menu entries are there,
so by the way: why do we do this: parsing a batch file that has already finished it's work? What intention is behind get_menu_entries?

New formal Release

It's been a very long time since I've let anyone know about what's going in apt world, and all of the main commands now do useful work. It's time to update the main Trac instance, and put in a pointer in SVN that points here.

This is worth doing, even if there isn't anything truly new in what apt does (no new commands or features), mostly better screen reporting, but there are some worthwhile bug fixes too (IMO).

Add 64bit handling

Recap from 881fe03:

  • mix and match of architecture in same install root folder would likely be very bad
  • option A: use --arch= [x86 | x86_64] 8c36813) (or --bits= [32 | 64] 881fe03)
  • option B: keep them distinct by naming calling script differently apt, apt-x64 (though it would be identical script inside)
  • there is architecture statement in setup.ini that we've ignored (until 49f374e)
  • should we allow same cache folder? (is separated by x32 and x64 subfolders anyway)
  • allow apt running from inside one install root install to a different root? (might allow things like updating both 32 and 64bit installs on a single machine from the same shell session)

download and mirror messed up, duplicated "x86" in path

2 problems here:

  • download should check and handle file not found
  • why is mirror path messed up?
B:\code\apt>apt download gdal-filegdb

Fetching http://download.osgeo.org/osgeo4w/x86/x86/release/gdal/gdal-filegdb/gdal-filegdb-1.11.1-4.tar.bz2
...100%
gdal-filegdb = d:/temp/o4w-cache/setup/http%3a%2f%2fdownload.osgeo.org%2fosgeo4w%2fx86/x86/release/gdal/gdal-filegdb/gda
l-filegdb-1.11.1-4.tar.bz2

remote:  b434e716cc2ff6a0eb252fd725219d20  gdal-filegdb-1.11.1-4.tar.bz2
local:   81802d554670b1cb3d40c770ecdcdff5  gdal-filegdb-1.11.1-4.tar.bz2
...snip...

contents of the local file:

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL /osgeo4w/x86/x86/release/gdal/gdal-filegdb/gdal-filegdb-1.11.1-4.tar.bz2 was not found on this server.</p>
<hr>
<address>Apache/2.2.16 (Debian) Server at download.osgeo.org Port 80</address>
</body></html>

`apt new` is broken

Package             Installed   Available
-----------------   ---------   ----------

TypeError: no_package() takes at least 2 arguments (0 given)

AttributeError: module 'ctypes' has no attribute 'util'

I Tried running python program to controlling thorlabs motor controller. I found error codes such below:
Traceback (most recent call last):
File "C:\Users\N 417 TA\Desktop\meanshift.py", line 6, in
import thorlabs_apt as apt
File "C:\ProgramData\Anaconda3\lib\site-packages\thorlabs_apt-0.1-py3.6.egg\thorlabs_apt_init_.py", line 1, in
from .core import *
File "C:\ProgramData\Anaconda3\lib\site-packages\thorlabs_apt-0.1-py3.6.egg\thorlabs_apt\core.py", line 1373, in
_lib = _load_library()
File "C:\ProgramData\Anaconda3\lib\site-packages\thorlabs_apt-0.1-py3.6.egg\thorlabs_apt\core.py", line 1354, in _load_library
filename = ctypes.util.find_library("APT")
AttributeError: module 'ctypes' has no attribute 'util'
As information, I using python 3.6.0 64 bit.

Shrink apt.exe as much as possible

Using pyinstaller with out of the box settings works, but the resulting file is really big: 9mb when bundled as onefile, and 20mb when as onedir (!)

Inspecting the expanded folder I see Tk and Tcl are included. We certainly don't need those modules, and I suspect there are probably others that we can exclude too.

Wrong downloads folder chosen

B:\code\apt>apt -i setup_test.ini  install qgis

PKGS: Checking install status: qgis

Requirement         Installed   (Available)
-------------------------------------------
msvcrt              1.0.1-12    (1.0.1-12)
setup               1.0.7-10    (1.0.7-10)
...
python-dateutil     2.2-1       (2.2-1)
pytz                2014.2-1    (2014.2-1)
qgis
REQS: --- To install: qgis-common qgis

Preparing to download: qgis-common

WindowsError: [Error 5] Access is denied: 'C:\\Users\\Public'

should exit gracefully with md5 mismatch


B:\code\apt>apt upgrade gdal-filegdb
to install:    gdal-filegdb

Fetching http://download.osgeo.org/osgeo4w/x86/x86/release/gdal/gdal-filegdb/gdal-filegdb-1.11.1-4.tar.bz2
...100%
gdal-filegdb = d:/temp/o4w-cache/setup/http%3a%2f%2fdownload.osgeo.org%2fosgeo4w%2fx86/x86/release/gdal/gdal-filegdb/gda
l-filegdb-1.11.1-4.tar.bz2

remote:  b434e716cc2ff6a0eb252fd725219d20  gdal-filegdb-1.11.1-4.tar.bz2
local:   81802d554670b1cb3d40c770ecdcdff5  gdal-filegdb-1.11.1-4.tar.bz2
Traceback (most recent call last):
  File "apt.py", line 1385, in <module>
    __main__.__dict__[command] (packages)
  File "apt.py", line 522, in upgrade
    install(packages)
  File "apt.py", line 224, in install
    download(p)
  File "apt.py", line 169, in download
    md5(p)
  File "apt.py", line 318, in md5
    raise TypeError('file md5 does not match for ' + ball)
TypeError: file md5 does not match for gdal-filegdb-1.11.1-4.tar.bz2

Menu and Desktop links variable not used

Apt doesn't know about the %OSGEO4W_MENU_LINKS% and %OSGEO4W_DESKTOP_LINKS% variables introduced in setup.exe v1.0.6-5.

With the qgis-dev package this manifests with a mkdir was unexpected at this time. error message at the console during postinstall phase, consequently the Start Menu and Desktop shortcuts are not created, nor are the relevant registry entries created/updated.

http://trac.osgeo.org/osgeo4w/ticket/300

apt with alternate ini doesn't test md5 against alternate ini

B:\code\apt>apt -i setup_test.ini install apt-exe

PKGS: Checking install status: apt-exe

Requirement         Installed   (Available)
-------------------------------------------
apt-lib             0.3-3       (0.3-3)
apt-exe             -           (0.3-3)

REQS: --- To install: apt-exe

Preparing to download: apt-exe
--- Verifying local file's md5 hash matches mirror
        True
        remote: 334808074060560b8e8d78a86a4fa1e1
        local:  334808074060560b8e8d78a86a4fa1e1
Skipping download of apt-exe-0.3-3.tar.bz2, exists in cache

apt-exe = C:\Users\Public\Downloads\OSGeo4W-setup-cache\http
-exe\apt-exe-0.3-3.tar.bz2
--- Verifying local file's md5 hash matches mirror
        True
        remote: 334808074060560b8e8d78a86a4fa1e1
        local:  334808074060560b8e8d78a86a4fa1e1

Reports md5 in package archive (334808074060560b8e8d78a86a4fa1e1) matches md5 from setup.ini , but that's not the case (a662af2ce6b94ffa011a5252c3a3cd0c):

@ apt-exe
sdesc: "Command line OSGeo4W Installer/Updater/Remover"
ldesc: "Command line OSGeo4W Installer/Updater/Remover - exe version (doesn't require python)"
category: Commandline_Utilities
requires: apt-lib
version: 0.3-3
install: x86/release/apt/apt-exe/apt-exe-0.3-3.tar.bz2 1963823 a662af2ce6b94ffa011a5252c3a3cd0c
[prev]
version: 0.3-2
install: x86/release/apt/apt-exe/apt-exe-0.3-2.tar.bz2 1963590 734a96cd949b1ecf661047c9ec6adc0c

It appears apt is ignoring the custom ini and reverting to the default for md5 check. Apt does however use the custom ini when installing (apt -i setup_test.ini install foobaz).
:-/

`apt upgrade pyqt4` failed, but at least two others are ok(?)

Curious, apt upgrade pyqt4 failed, in the sense that it decided there was nothing to do, while apt upgrade gpsbabel and another package which I don't remember, worked just fine. Workaround to just remove the pyqt4 package and then install/upgrade it again was quick and easy, but still should have worked in the first place.

B:\code\apt>apt new

*** Warning: 'grass71-dev' is missing 'install' entry in setup.ini. This might cause problems.

Package             Installed   Available
-----------------   ---------   ----------
gdal                1.11.1-5    (1.11.2-1)
gdal-filegdb        1.11.1-5    (1.11.2-1)
gdal-python         1.11.1-5    (1.11.2-1)
gpsbabel            1.4.2-1     (1.4.4-1)
grass               6.4.4-1     (7.0.0-1)
osg-libs            3.0.0-1     (3.1.7-1)
osgearth-libs       2.0.0-1     (2.4-1)
pyqt4               4.8.3-2     (4.11.3-1)
python-numpy        2.7.1.5.1-1 (2.7.1.7.0-1)
python-qscintilla   2.6.2-2     (2.8.4-1)
qgis                2.6.0-1     (2.8.1-1)
qgis-common         2.4.0-1     (2.8.1-1)
qgis-dev            2.7.0-21    (2.9.0-34)
qgis-grass-plugin   2.4.0-1     (2.8.1-1)
qscintilla          2.6.2-2     (2.8.4-1)
qt4-libs            4.7.1-6     (4.8.6-1)

B:\code\apt>apt upgrade pyqt4

*** Warning: 'grass71-dev' is missing 'install' entry in setup.ini. This might cause problems.

+++ get_requires() is depcrecated. Please use get_all_dependencies().
PKGS: Checking install status: pyqt4
         pyqt4 - True
REQS: Checking dependencies installed: python-tools qt4-libs shell python-testsuite python setup zlib openssl python-cor
e python-help python-tcltk sqlite3 msvcrt
         python-tools - True
         qt4-libs - True
         shell - True
         python-testsuite - True
         python - True
         setup - True
         zlib - True
         openssl - True
         python-core - True
         python-help - True
         python-tcltk - True
         sqlite3 - True
         msvcrt - True

Packages and required dependencies are installed.

pyqt4               4.11.3-1

python-tools        2.7.4-1
qt4-libs            4.8.6-1
shell               1.0.0-13
python-testsuite    2.7.4-1
python              2.7.4-2
setup               1.0.7-10
zlib                1.2.3-1
openssl             1.0.1g-1
python-core         2.7.4-3
python-help         2.7.4-1
python-tcltk        2.7.4-1
sqlite3             3.7.17-1
msvcrt              1.0.1-12

Need a real test suite

Currently all my testing is done by running in a command shell and then comparing against my memory of what to expect. This is inadequate.

I've avoided unittest to this point because in my (limited) experience with it I spend more time debugging the tests themselves that the functions they're supposed to be verifying. ...

Still, something needs to be done. :)

See 0f2a644 for an example

etc/setup/timestamp not created or used

Setup.exe creates this, we don't need it so I don't see much value in maintaining feature parity in this particular instance. Presumably it is to avoid downloading a new package list on every invocation, only when older than X. Apt doesn't need this since it has it's own apt update command that's fired at user discretion.

It could be helpful though, no point in having Setup download a new package ini if apt did it just a few minutes ago, but I'm not going to implement it myself while there's bigger things to tackle. Pull requests welcome.

Search descriptions, not just name

apt search only looks in package names. It would be much more useful it looked in description fields as well (or perhaps any part of the .ini record).

Spent some time researching how to search nested dictionaries, but didn't come up with anything that I both (a) understood, and (b) didn't involve a lot of extra work.

Clean separation of Apt and batch file messages

As explored in #40, the intermingling of Apt progress reporting and the messages coming from batch files extracted from packages can make it difficult to determine where a problem is coming from. It would be good to portray these messages and errors in way that makes it easier to differentiate.

One idea is to redirect batch stdout stderr to another console or log file(s). The more I think about this though the less attracted I am. Who wants to wade through possibly dozens or hundreds of logfiles in the event of an issue? Maybe could just draw them in different colours?

Anyway, no solution or plan for one at this point, just a ticket to attach one to later.

Short form bits `-b=64 ` is broken

B:\code\apt>apt --root=%temp%\%random% -b=64 setup
Couldn't open C:\Users\Matt\AppData\Local\Temp\5024/etc/setup//setup.rc, setting empty
error: `--bits` is required parameter for Setup

*** CPU Architecture not defined. Please use `--bits [32 | 64]`

Read the Docs apt module page is empty

When I build the sphinx docs locally with make html there is a module page populated with content, but at http://apt.readthedocs.org/en/latest/apt.html the page is empty.

http://imgur.com/fo9TIYm

Under Builds, https://readthedocs.org/builds/apt/2900858/, there is an error with ctypes.

/var/build/user_builds/apt/checkouts/latest/docs/source/apt.rst:4: WARNING: autodoc: failed to import module u'apt'; the following exception was raised:
Traceback (most recent call last):
  File "/home/docs/checkouts/readthedocs.org/user_builds/apt/envs/latest/local/lib/python2.7/site-packages/sphinx/ext/autodoc.py", line 385, in import_object
    __import__(self.modname)
  File "/var/build/user_builds/apt/checkouts/latest/apt.py", line 38, in <module>
    import knownpaths # for fetching Windows special folders
  File "/var/build/user_builds/apt/checkouts/latest/knownpaths.py", line 5, in <module>
    from ctypes import windll, wintypes
  File "/usr/lib/python2.7/ctypes/wintypes.py", line 23, in <module>
    class VARIANT_BOOL(_SimpleCData):
ValueError: _type_ 'v' not supported

Follow dependency chain, install bottom first

also: http://trac.osgeo.org/osgeo4w/ticket/283

D:\osgeo>apt install shell
to install:    setup shell msvcrt

...downloads happen...

Traceback (most recent call last):
  File "<string>", line 1524, in <module>
  File "<string>", line 299, in install
  File "<string>", line 316, in install_next
  File "<string>", line 315, in install_next
Exception: Required package setup from shell is a circular reference with a prev
ious dependent

D:\osgeo>apt requires shell msvcrt setup
----- "shell" requires the following to work -----
msvcrt
setup
----- "msvcrt" requires the following to work -----

----- "setup" requires the following to work -----
msvcrt
shell

D:\osgeo>apt --no-deps install shell
to install:    shell
...
installing shell 1.0.0-13

D:\osgeo\Osgeo4w-apt>mkdir "C:\ProgramData\Microsoft\Windows\Start Menu\Programs
\OSGeo4W"
Access is denied.

D:\osgeo\Osgeo4w-apt>xxmklink "C:\ProgramData\Microsoft\Windows\Start Menu\Progr
ams\OSGeo4W\OSGeo4W.lnk" "D:\osgeo\Osgeo4w-apt\OSGeo4W.bat" " " \ "OSGeo for Win
dows command shell" 1 "D:\osgeo\Osgeo4w-apt\OSGeo4W.ico"
'xxmklink' is not recognized as an internal or external command,
operable program or batch file.
...
Post_install complete, return code 1

Move last-cache, -mirror, etc. into setup.rc

Setup.exe has moved it's settings for last-mirror, last-cache, etc. into a single file: ./etc/setup/setup.rc. We need to do the same to maintain compatibility.

mirrors-lst
    http://download.osgeo.org/osgeo4w/;OSGeo;USA;California
window-placement
    44,0,0,0,0,0,0,0,1,0,0,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,151,1,0,0,185,0,0,0,185,3,0,0,72,2,0,0
last-mode
    Advanced
last-mirror
    http://download.osgeo.org/osgeo4w/
net-method
    Direct
last-cache
    C:\Users\Matt\Downloads
last-menu-name
    OSGeo4W_default

apt.py crashes on reading setup.ini with no 'install' key

With the last update() of setup.ini i recognized that grass71-devel has no entry for install.
So in parse_setup_ini() this will cause an KeyError Exception:

d['zip_path'],d['zip_size'],d['md5'] = d['install'].split()

you could change it to
try:
d['zip_path'],d['zip_size'],d['md5'] = d['install'].split()
except KeyError:
print "warning: ", d['name'], "has no entry install"
d['zip_path'],d['zip_size'],d['md5'] = ('','','')

But this causes errors later, if one tries to access that information, e.g. on download/install

Change inappropriate TypeError raises

I've not been using Raise or Exceptions properly. Some of that is inheritance from the original cyg-apt script, which just used a bare raise 'string message' syntax, and some of it is me, in ignorance, using TypeError all over the place, even when the error is not a type error. I've since learned enough to recognize the issue, but don't think I know enough about exception handling to solve it properly. We'll see I guess ;-)

Permission denied on certain files when upgrading

python-core = C:\Users\Public\Downloads\http%3a%2f%2fdownload.osgeo.org%2fosgeo4w%2f\x86_64\release\python\python\python-core\python-core-2.7.5-3.tar.bz2
--- Verifying local file's md5 hash matches mirror
        True
        remote: c38a03b6ffa6b43fcf514fe5e1b7614c
        local:  c38a03b6ffa6b43fcf514fe5e1b7614c

IOError: [Errno 13] Permission denied: '.\\etc\\ini\\python-core.bat'
Failed to execute script apt

The work-around:

attrib -r C:\OSGeo4W64\etc\ini\python-core.bat

a little issue on install - purely academic?

Because I don't understand the code in get_requires() i wrote a function for my own, but failed with the order of packages. There are indeed packages that need other packages to be already installed! 8-o
e.g. qgis depends on qgis-common which tries to execute a command %OSGEO4W_ROOT%\apps\qgis\crssync, an exe to do something with proj's spatial references. Anyway, if so, during install there must be a certain order. So i came back to apt's get_requires() and yes, the order is different to mine.
In setup.ini all packages have there "requires" and those can have their own "requires" too. I tried to recursively collect the required packages but ended in an infinite loop :-(
The reason is that some elements are "mutual depending", eg. "shell" needs "setup" and vice versa.
I still don't know, why and how get_requires() work, but it definitely does not follow the recursive way, even not in its output.
For example "install python"
A strict order would be (reading setup.ini carefully): 'setup', 'msvcrt', 'shell', 'sqlite3', 'python-core', 'python-help', 'python-tcltk', 'python-testsuite', 'python-tools', 'python'
but get_requires() gives 'shell', 'python-testsuite', 'python', 'setup', 'sqlite3', 'python-core', 'python-help', 'python-tcltk', 'python-tools', 'msvcrt'
All this works well, but what if a package-to-be must execute an python script which then depends on msvcrt?

It ended all up with my own get_dependencies(), where i tried to recursively, not falling into the infinite-loop-trap, sort packages according to dependence:

def get_dependencies(packages, nestedl, parent=None):
    """a recursive lookup for required packages in order of dependence"""
    if isinstance(packages, basestring): packages = [packages]

    for p in packages:
        mm = get_requires(p)
        if parent:
            inspos = nestedl.index(parent)
            nestedl.insert(inspos, p)
        else:
            nestedl.append(p)
        delete_in_existing(mm, nestedl)
        if mm:
            nestedl = get_dependencies(mm, nestedl,p)

    return nestedl

And here is the driver:

dlist = []
dlist = get_dependencies(packages, dlist)
print dlist

May be, this could be a replacement for get_requires, even there's actually no need for it...
Any comment is welcome!

Couldn't we shorten install()

with get_all_dependencies we get all packages to be installed in an list, odered by dependencies, starting with basic packages and ending with those dependending on the foregoing. So we need not to distinguish between packages[] and requiered[] anymore. Also we clean the list froms doubles, so we needn't unique() twice?
just

  • check packages list
  • without loop: call get_all_dependencies with complete packages list
  • delete packages from list, which are already installed (and have the newest version)
  • loop over list to install...

Clarify core data model, we're in a data muddle

When working on better information messages from apt info command I realized I've made a muddle:

4b9190f The main data tables need clear separation, "package names and version available on server" and "what is actually locally installed". The old functions actually maintained this better before I started messing with them. (In my defense, they were horribly opaque tho'.)

For instance I grew the idea that apt ball reconstructed the version name from the currently available archive filename on the server. Yes, get_ball() constructs from the filename, but not from the filename in setup.ini, it's actually from the name in installed.db -- a crucial difference!

TODO: rescue good parts of old functions, clearly separate local/server info, dump overlapping dict records.

So something like

SETUP = parse_setup_ini()
INSTALLED = parse_installed_db()

I want to think carefully about the names though. We'll be using them frequently. They should make intuitive sense when read, while being short enough to cause no typing strain and keep our code phrases short and fast to read.

  • ALLCAPS is out; no shouting.
  • setup_ini is being used (but could be moved, with some effort)
  • setup_d, installed_d ?
  • sini_d, inst_d ?
  • ini_d, inst_d ?
  • S, I ? (is this still shouting?)
  • ...?

A couple of spelled out phrases:

p = packagename

server_ver = sini_d[p]['version']
local_ver  = inst_d[p]['version']
server_ver = S[p]['version']
local_ver  = I[p]['version']

if sini_d[p]['version'] > inst_d[p]['version']:
    do_upgrade(p)

if S[p]['version'] > I[p]['version']:
    do_upgrade(p)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.