Menu

Main Menu
Talk Get Daily Search

Member's Online

    User Name
    Password

    aptly - an apt-get/apt-cache/dpkg wrapper

    Reply
    Page 1 of 2 | 1   2   | Next
    aspidites | # 1 | 2009-12-24, 05:00 | Report

    update 6
    -fixed bug mentioned before about option order.
    -created topic in Applications to see if this is worth distributing
    -all changes from now on will be in aptly/CHANGES from now on

    update 5
    - regression. re-factoring the code as I have caused some options to be evaluated in th e wrong order. This will be fixed in the next version (in particular --install and --update
    - packaging seems to be a lot of work. I will announce this in Applications and if there is enough generated interest I'll officially package it.
    update 4
    - re-factored/cleaned code
    - syntax is more apt-get like in that instead of having to type:
    Code:
    aptly -i pkg1,pkg2,pkg3
    you can type:
    Code:
    aptly -i pkg1 pkg2 pkg3
    - apps are now installed simultaneously instead of sequencially*
    - help command is a bit more detailed:


    I'm thinking about packaging this shortly and maybe even pushinging to maemo-devel.

    update 3
    - experimental support for dependency handling for local *.deb files added.
    - added todo list and licensing.

    update 2
    I finally got the basics down (after sacrificing some initial features), and I rather like it. It's a command line app, so there isn't much to screenshot, but here it is anyways


    Here is a comparison of doing things with aptly versus pure apt tools:

    Update & Upgrade
    Code:
    # old way
    apt-get update && apt-get upgrade
    
    # aptly
    aptly -uU
    Install & remove simultaneously
    Code:
    # old way
    apt-get remove some_package some_other package && apt-get install new_package
    
    # aptly
    aptly -r some_package,some_other_pacakge -i new_package
    Install from multiple sources
    Code:
    # old way
    apt-get install some_package_name && dpkg -i some_deb_file
    
    # aplty
    aptly -i some_package_name,soem_deb_file
    Note that for the above to work, aptly has to be in your PATH. Otherwise, you should run as follows:
    Code:
    python ./aptly -i some_app
    # if you have made aptly executable
    ./aptly -i some_app

    update 1

    You can now string commands together. A common use-case is that something like:
    Code:
    apt-get update && apt-get install app
    can be done like this:
    Code:
    aptly --upgrade --install vim
    ore more succiently:
    Code:
    aptly -ui vim
    original post
    As the title suggests, I'm writing an apt-get, apt-cache, and dpkg wrapper in python called aptly. In addition to being a learning exercise, I wanted a way to consolidate the functions of all of these programs into one tool.

    Here is a screencast of it in it's primitive state.

    I am however running into the following problems:
    • On most systems, as long as you set the executable flag on a file and have the appropriate header, you can run it without actually prefixing it with the interpreter (ie "aptly" instead of "python aptly". I can't seem to do this on my N900. (thanks fatalsaint)
    • I can't seem to find a command that will allow me to distinguish from which repo/catalog an app came from. I would use this information to allow a user to specify from which rep/catalog a piece of software comes from. short of disabling and reenabling repos manually, this doesn't seem to be something that apt does natively
    • I have noticed that modifications to /etc/apt/sources.list.d/hildon-application-manager.list by hand don't seem to appear in App.manager. filed a bug report, but doubt it'll get looked into any time soon

    Edit | Forward | Quote | Quick Reply | Thanks

    Last edited by aspidites; 2009-12-26 at 04:15.
    The Following 2 Users Say Thank You to aspidites For This Useful Post:
    iKneaDough, qole

     
    fatalsaint | # 2 | 2009-12-24, 05:21 | Report

    For the first point it will only work if the application is in your $PATH.. /usr/bin, /bin, /opt/bin/, etc..

    You should be able to run the command like "./aptly" if its in the same directory you're in.

    I know theres a way to get a the repo info.. still looking. Things like "apt-cache show package_name" give a ton of information including version, and section (the control file), but doesn't list repo. Interesting.

    Edit | Forward | Quote | Quick Reply | Thanks
    The Following User Says Thank You to fatalsaint For This Useful Post:
    aspidites

     
    dvergin | # 3 | 2009-12-24, 05:22 | Report

    Originally Posted by aspidites View Post
    ...you can run it without actually prefixing it with the interpreter (ie "aptly" instead of "python aptly". I can't seem to do this on my N900.
    With questions like this, it moves the conversation toward a solution more quickly if you post what you have tried when you state the problem.

    This works fine for me as the first line in a python executable which runs without prefixing "python" on the command line:
    Code:
    #!/usr/bin/python
    What have you tried?
    -----------------------------------
    Edit: ...and what fatalsaint said.

    Edit | Forward | Quote | Quick Reply | Thanks

     
    aspidites | # 4 | 2009-12-24, 05:24 | Report

    Originally Posted by fatalsaint View Post
    For the first point it will only work if the application is in your $PATH.. /usr/bin, /bin, /opt/bin/, etc..
    Duh!. I must be tired, having not thought of that, lol.

    I already had the "#!/usr/bin/env python" at the top of my script.

    Edit | Forward | Quote | Quick Reply | Thanks

     
    fatalsaint | # 5 | 2009-12-24, 05:25 | Report

    apt-cache showpkg package_name

    Gives information such as:

    Originally Posted by
    2:1.0~rc3+svn20090426-1ubuntu10.1 (/var/lib/apt/lists/us.archive.ubuntu.com_ubuntu_dists_karmic-updates_multiverse_binary-amd64_Packages) (/var/lib/dpkg/status)
    Description Language:
    File: /var/lib/apt/lists/us.archive.ubuntu.com_ubuntu_dists_karmic-updates_multiverse_binary-amd64_Packages
    MD5: c765aa48044329115354123039018b09

    2:1.0~rc3+svn20090426-1ubuntu10 (/var/lib/apt/lists/us.archive.ubuntu.com_ubuntu_dists_karmic_multiver se_binary-amd64_Packages)
    Description Language:
    File: /var/lib/apt/lists/us.archive.ubuntu.com_ubuntu_dists_karmic_multiver se_binary-amd64_Packages
    MD5: c765aa48044329115354123039018b09
    The repository IS in there... just kind of.. ugly.

    Edit | Forward | Quote | Quick Reply | Thanks
    The Following User Says Thank You to fatalsaint For This Useful Post:
    aspidites

     
    aspidites | # 6 | 2009-12-24, 05:33 | Report

    Originally Posted by fatalsaint View Post
    apt-cache showpkg package_name

    Gives information such as:



    The repository IS in there... just kind of.. ugly.
    That is better than nothing. Thanks again :-)

    Edit | Forward | Quote | Quick Reply | Thanks

     
    aspidites | # 7 | 2009-12-25, 02:17 | Report

    I was trying to sanitize output, however it seems as though apt-get, etc automatically buffer output when it detects it is being run through a pipe, which means that I have to wait until the app is done executing before I can capture output (as opposed to doing it real time). The result is that trying to do so makes aplty feel sluggish. As such, I've decided to just keep each respective program's output untouched.

    Anyways, it's working now, and I'll update the first post with the code, screenshots, and a screencast showing its flexibility (or at least my laziness)

    Edit | Forward | Quote | Quick Reply | Thanks

     
    aspidites | # 8 | 2009-12-27, 04:08 | Report

    Well, I cant seem to get the --cache command to work.

    How it is supposed to work is that you evoke it like such:
    Code:
    aptly --cache --install some_package
    # or
    aplty --cache some_directory --install some_package
    Supposedly, that will download your deb package to some_directory or ~/.config/aptly/cache if some_directory is omitted.

    The equivalent in plain old apt-get is this:
    Code:
    apt-get -o dir::cache::archives="/home/user/.config/aptly/cache" install some_package
    which runs fine.

    I am trying to evoke it using python's subprocess:
    Code:
    command = ["apt-get", "-o", "dir::cache::archives="/home/user/.config/aptly/cache"", "install", "some_package"]
    
    subprocess.call(command)
    The problem is that I get the following error:
    Code:
    E: could not open lock file /var/cache/apt/" /home/user/.config/aptly/cache/" /lock - open (2 no such file or directory
    I'm confused because no where in the code have I done any variable substitution for the /valr/cache/apt/" or assigned it explicitly. Am I missing something glaringly obvious?

    Edit | Forward | Quote | Quick Reply | Thanks

     
    fatalsaint | # 9 | 2009-12-27, 04:11 | Report

    I'm assuming its your quotes. You have quotes within quotes in your app. I suggest one of the following:

    Code:
    command = ["apt-get", "-o", "dir::cache::archives=\"/home/user/.config/aptly/cache\"", "install", "some_package"]
    or

    Code:
    command = ["apt-get", "-o", 'dir::cache::archives="/home/user/.config/aptly/cache"', "install", "some_package"]

    Edit | Forward | Quote | Quick Reply | Thanks

     
    aspidites | # 10 | 2009-12-27, 04:46 | Report

    Originally Posted by fatalsaint View Post
    I'm assuming its your quotes. You have quotes within quotes in your app. I suggest one of the following:

    Code:
    command = ["apt-get", "-o", "dir::cache::archives=\"/home/user/.config/aptly/cache\"", "install", "some_package"]
    or

    Code:
    command = ["apt-get", "-o", 'dir::cache::archives="/home/user/.config/aptly/cache"', "install", "some_package"]
    Actually the previous post was essentially pseudo code from the top of my head, sorry.. In the actually code I had tried both """ "some_stuff" """ and " ' some stuff ' " and got the same results.

    Turns out that the -o produced some kind of anomaly. I finally got it to work ,but I had to use an alternate syntax for call:
    Code:
    # instead of this
    call([command, arg1, arg2])
    # I had to use this:
    call("command arg1 arg2", shell=True")
    I had read that I should avoid the latter form in most situations which is why I hadn't used it before.

    Anyways, it is now possible to install to a different cache directory (defaulting to home if not is specified with the -C/--cache option or the system default if the option is omitted) :-)

    I also added options to (auto)clean. I still need to test for regressions before I release this, but it's starting to shape up pretty nicely I think.

    Edit | Forward | Quote | Quick Reply | Thanks

     
    Page 1 of 2 | 1   2   | Next
vBulletin® Version 3.8.8
Normal Logout