Created
June 11, 2014 12:30
-
-
Save didrocks/afc625607feab0432e4e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import apt | |
import os | |
import tempfile | |
import shutil | |
apt.apt_pkg.config.clear("APT::Update::Post-Invoke") | |
apt.apt_pkg.config.clear("APT::Update::Post-Invoke-Success") | |
apt.apt_pkg.config.clear("DPkg::Post-Invoke") | |
# set to something not existing | |
apt.apt_pkg.config.set("Dir::Bin::dpkg", "/usr/bin/dpkg2") | |
apt_package_dir = tempfile.mkdtemp() | |
with open(os.path.join(apt_package_dir, 'Packages'), 'w') as f: | |
f.write('''Package: abrowser | |
Priority: optional | |
Section: web | |
Installed-Size: 136 | |
Maintainer: Ubuntu Mozilla Team <ubuntu-mozillateam@lists.ubuntu.com> | |
Architecture: all | |
Source: firefox | |
Version: 3.6.9+build1+nobinonly-0ubuntu1 | |
Depends: firefox, abrowser-branding | |
Filename: pool/main/f/firefox/abrowser_3.6.9+build1+nobinonly-0ubuntu1_all.deb | |
Size: 82324 | |
MD5sum: 3a8c96814b0201c285274fded3e2d203 | |
SHA1: 05a3c9d5ced88fc51f3aa3166b0ca4030dcc4e49 | |
SHA256: 1c3d03dfe4364394f89f453d46b81c2024996a81d929a5ed6e1803ad5f9a21e9 | |
Description: metapackage for the unbranded abrowser | |
ABrowser is an unbranded version of the popular Firefox webbrowser; | |
it is written in the XUL language and designed to be lightweight and | |
cross-platform. | |
. | |
This is a metapackage that will point to the latest abrowser package in | |
your distribution. | |
Don't remove this if you want to receive automatic major version upgrades | |
for this package in future. | |
Xul-Appid: {ec8030f7-c20a-464f-9b0e-13a3a9e97384} | |
Bugs: https://bugs.launchpad.net/ubuntu/+filebug | |
Origin: Ubuntu | |
Supported: 18m''') | |
apt_chroot = tempfile.mkdtemp() | |
os.makedirs(os.path.join(apt_chroot, 'var', 'log', 'apt')) | |
apt_etc = os.path.join(apt_chroot, 'etc', 'apt') | |
os.makedirs(apt_etc) | |
with open(os.path.join(apt_etc, 'sources.list'), 'w') as f: | |
f.write('deb copy:{} /'.format(apt_package_dir)) | |
cache = apt.Cache(rootdir=apt_chroot) | |
cache.update() | |
cache = apt.Cache() | |
pkg = cache['abrowser'] | |
print(pkg) | |
pkg.mark_install() | |
return_value = cache.commit() | |
print(return_value) | |
shutil.rmtree(apt_package_dir) | |
shutil.rmtree(apt_chroot) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment