Monday 24 December 2012

How To: Build local apt repositories

How To: Build local apt repositories for debian and ubuntu

1. Create a folder where you would like to keep your deb packages:
 [ Plan so that, you can get those file over network or http ]
 a. example: mkdir -p /var/www/my_repo

2. Keep all your deb package to /var/www/my_repo. [ You can keep this directory at any place ]
 FYI: you can find few pkgs that you have installed earlier from internet, just incase, if you want those also should be there in your local repo. "/var/cache/apt/archives"

3. Generate a Packages.gz file like this:
 a. sudo dpkg-scanpackages /var/www/my_repo /dev/null | gzip -9c > /var/www/my_repo/Packages.gz
 b. or:  cd /var/www/my_repo ; sudo dpkg-scanpackages . /dev/null | gzip -9c > Packages.gz
 Note: there is a space before and after .
 Note: Make sure build-essential is installed (sudo aptitude install build-essential) before you run the above command.

4. Add the following line to your sources.list file (/etc/apt/sources.list)
    deb file:/var/www/my_repo / [ a space between my_repo and last / ]

5. Reload your package index: sudo apt-get update

NOTE: when you update the package to the custom repository: you have to run the following command: [ each and every time ]
 get into the repository directory: and the following commands:
sudo dpkg-scanpackages . /dev/null | gzip -9c > Packages.gz ; sudo apt-get update


Few more information:
  1. Install the package "dpkg-dev". It is available on the installation disk.
  2. Download necessary packages along with the dependencies to a directory on your local fileystsem. You may organize the packages into sub directories.
  3. Let us call the directory into which the files have been copied as .
  4. From konsole or any other terminal of your choice, issue following commands.
    1. cd
    2. dpkg-scanpackages . /dev/null >Packages
  5. Open /etc/apt/source.list in your favorite editor and add the line "deb file:// ./"
  6. Your new repository is ready.


No comments:

Post a Comment