Wednesday, May 24, 2017

use apt-cache to search package from multiple release

1- prepare apt-cache enviroment
$ mkdir ~/apt-cache/{"precise","trusty","xenial","yakkety","zesty","artful"} -p

2- create two file in each directory with the following content
show only precise

- apt.conf (~/apt-cache/precise/apt.conf)
Dir::Cache::pkgcache "/home/user1/apt-cache/precise/m.bin";
Dir::Cache::srcpkgcache "/home/user1/apt-cache/precise/s.bin";

Dir::Etc::SourceList "/home/user1/apt-cache/precise/sources.list";
dir::cachedir "/home/user1/apt-cache/precise";
Dir::State::Lists "/home/user1/apt-cache/precise/lists";
bincachedb "m.bin";


-  sources.list (~/apt-cache/precise/sources.list)
deb http://deb.repo/ubuntu/ precise main restricted universe multiverse
deb http://deb.repo/ubuntu/ precise-backports main restricted universe multiverse
deb http://deb.repo/ubuntu/ precise-updates main restricted universe multiverse
deb http://deb.repo/ubuntu/ precise-security main restricted universe multiverse



3- if you use other release rather than precise, copy sources.list above to /etc/apt/
$ suod cp sources.list  /etc/apt/

4- update the package lists and generate cache
$ sudo apt-get update
$ sudo cp -r  /var/lib/apt/* .
- gen chaces
$ sudo apt-cache -c apt.conf gencaches

after it will generate two file m.bin and s.bin in precise folder

*** repeat the step 2 to 3, until those interested release are completed

some commands
- search for name gmrun
$ sudo apt-cache -c apt.conf search gmrun

-list all available packages
$ sudo apt-cache -c apt.conf pkgnames

4- script to search it all at once

#!/usr/bin/python

import os
import sys


basedir = "/home/tun/test/apt-cache"
confname = "apt.conf"

release = ["precise","trusty","xenial","yakkety","zesty","artful"]

searchTerm = sys.argv[1]

for i in release:
    fullConfName = basedir +"/" + i +"/" + confname
    print "*********"+i+"*********"
    os.system("apt-cache -c " + fullConfName + " search " + searchTerm)



5- example to search kubernetes
$ python search-all-release.py kubernetes
*********precise*********
*********trusty*********
*********xenial*********
python-magnumclient - client library for Magnum API - Python 2.x
python-magnumclient-doc - client library for Magnum API - doc
magnum-api - OpenStack containers as a service
magnum-common - OpenStack containers as a service - API server
magnum-conductor - OpenStack containers as a service - conductor
python-magnum - OpenStack containers as a service - Python library
python3-magnumclient - client library for Magnum API - Python 3.x
*********yakkety*********
python-magnumclient - client library for Magnum API - Python 2.x
python-magnumclient-doc - client library for Magnum API - doc
magnum-api - OpenStack containers as a service
magnum-common - OpenStack containers as a service - API server
magnum-conductor - OpenStack containers as a service - conductor
python-k8sclient - Kubernetes API Python client code - Python 2.7
python-k8sclient-doc - Kubernetes API Python client code - doc
python-magnum - OpenStack containers as a service - Python library
python3-k8sclient - Kubernetes API Python client code - Python 3.x
python3-magnumclient - client library for Magnum API - Python 3.x
salt-formula-kubernetes - Salt formula for Kubernetes
*********zesty*********
python-magnumclient - client library for Magnum API - Python 2.x
python-magnumclient-doc - client library for Magnum API - doc
flannel - Etcd backed network fabric for containers
magnum-api - OpenStack containers as a service
magnum-common - OpenStack containers as a service - API server
magnum-conductor - OpenStack containers as a service - conductor
python-k8sclient - Kubernetes API Python client code - Python 2.7
python-k8sclient-doc - Kubernetes API Python client code - doc
python-magnum - OpenStack containers as a service - Python library
python3-k8sclient - Kubernetes API Python client code - Python 3.x
python3-magnumclient - client library for Magnum API - Python 3.x
salt-formula-kubernetes - Salt formula for Kubernetes
*********artful*********
python-magnumclient - client library for Magnum API - Python 2.x
python-magnumclient-doc - client library for Magnum API - doc
flannel - Etcd backed network fabric for containers
golang-github-kubernetes-gengo-dev - Library for generating code based on Go files
magnum-api - OpenStack containers as a service
magnum-common - OpenStack containers as a service - API server
magnum-conductor - OpenStack containers as a service - conductor
python-k8sclient - Kubernetes API Python client code - Python 2.7
python-k8sclient-doc - Kubernetes API Python client code - doc
python-magnum - OpenStack containers as a service - Python library
python3-k8sclient - Kubernetes API Python client code - Python 3.x
python3-magnumclient - client library for Magnum API - Python 3.x
salt-formula-kubernetes - Salt formula for Kubernetes





No comments:

Post a Comment