Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Is it possible to add a location/folder on my hard disk (ex: /media/Data/Ubuntu) to the sources.list? If possible,how?

share|improve this question

1 Answer 1

up vote 5 down vote accepted

There are 4 steps to setting up a simple repository for yourself:

  1. Install dpkg-dev
  2. Put the packages in a directory
  3. Create a script that will scan the packages and create a file apt-get update can read
  4. Add a line to your sources.list pointing at your repository

Install dpkg-dev

Type in a terminal

sudo apt-get install dpkg-dev

The Directory

Create a directory where you will keep your packages.

sudo mkdir -p /media/Data/Ubuntu

Now move your packages into the directory you've just created.

The Script update-mydebs

It's a simple three liner:

#! /bin/bash
cd /media/Data/Ubuntu
dpkg-scanpackages . /dev/null | gzip -9c > Packages.gz

Cut and paste the above into gedit, and save it as update-mydebs in ~/bin. (the tilde '~' means your home directory. If ~/bin does not exist, create it: Ubuntu will put that directory in your PATH. It's a good place to put personal scripts). Next, make the script executable:

chmod u+x ~/bin/update-mydebs

Sources.list

add the line

deb file:/media/Data/Ubuntu ./

to your /etc/apt/sources.list, and you're done.

Using the Repository

Whenever you put a new deb in the mydebs directory, run

sudo update-mydebs
sudo apt-get update

Now your local packages can be manipulated with Synaptic, aptitude and the apt commands: apt-get, apt-cache, etc. When you attempt to apt-get install, any dependencies will be resolved for you, as long as they can be met.

Source: https://help.ubuntu.com/community/Repositories/Personal

share|improve this answer
    
Thank you so much for the prompt reply. I appreciate your time taken to help me (and the fellow linux users). –  Din May 2 at 4:36
    
Hi Sylvian, just one more question: I have two folders called "Main" and "Contrib" in the folder where the packages are stored. What should be the line added to the sources.list? What does this (./) command do? Thanks! –  Din May 4 at 7:08

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.