1. Open a terminal
2. Install the Debian Package Development Tools. To do that, enter the following command in the the Terminal:
sudo apt-get install dpkg-dev
Note: I'm using Ubuntu 14.04 LTS and the package is already installed in this version.
3. Crete a directory for the packages. When you download any packages from the local repository, they will be saved here. To do this, just enter the following command:
sudo mkdir -p /usr/local/mypackages
4. Create a script that will scan the packages in the destination folder and will create a file that can be read by apt-get. To do this, enter the following commands in the terminal:
- sudo gedit (this opens a text editor. If you don't have it already installed, enter: sudo apt-get install gedit)
- When Gedit opens, paste the following text into Gedit:
dpkg-scanpackages . /dev/null | gzip -9c > Packages.gz
- Go to File > Save As.
- Go to Home > User > bin, where 'User' is your user name (e.g., Home/Jorge/bin). If you don't have a bin folder, create it.
- Save the file as: update-mypackages
- Close Gedit
5. Make the script executable:
sudo chmod u+x ~/bin/update-mypackages
6. Open the sources.list file:
- In the terminal, enter sudo gedit
- From the Gedit window, click Open.
- Browse to /etc/apt and open sources.list
- Go to the end of the file and add the following line:
deb file:/usr/local/mypackages ./
- Click 'Save' and close Gedit.
And that's all. A simple repository is running in your Ubuntu Server. Now let's test it.
1. Download the .deb file for Notepad++ here.
2. Now, copy the file into the folder you created for packages: /usr/local/mypackages (you might need to use sudo mv)
3. Run the script you created in ~/bin ('~' means your home directory) with the following command:
4. Update apt-get: sudo apt-get update
5. Now, to test if the local repository is working, disconnect from Internet.
6. Run this command to install the package:
sudo apt-get install notepad++
There's a lot to say about creating a local repository in Linux, but I think this is a good starting point. I'll be writing more about this in future posts.