Skip to content

Creating Local Repo

Sourav Das edited this page May 3, 2021 · 1 revision

This Instruction Assumes you had generate all .*[d]deb packages with the help of other instruction available on this wiki.
And You may proceed Now.

                   There is 2 types of Repo
                            |
            |-----------------------------|
            |                             |
     hosting in github           hosting with apache 
                                   server locally

In case of hosting in github you have to sign generated files because you are redistributing.

In case of hosting locally with apache server you don't need to sign it because you are using for you personal perpose unless you are not expose your server outside to your home network for redistribute.

Hosting in Github as repo

This has been allready written here Its a 5mins of reading time. Read it before going to below further.

Setting up a local package repository (Apache)

This is subset of this.

We need to install apache webserver, to do this do following.

# apt-get install apache2

may be you need to start the service for apache server.

# systemctl start apache2

check whether its working or not.

$ curl -I http://localhost or $ curl -I http://10.1.1.4

If everything goes well you can see the following after entering the above command.

┌─[sourav@Arch-Linux]─[~]
└──╼ $ curl -I http://localhost
HTTP/1.1 200 OK
Date: Thu, 29 Apr 2021 14:05:34 GMT
Server: Apache/2.4.46 (Unix)
Content-Type: text/html;charset=ISO-8859-1

The apache webserver is running but no content has been added, yet. The DocumentRoot of the default Apache VirtualHost, is /var/www/html: this is where we will create our repository. Now copy all files under LEVEL0 of your building tree to a empty directory. Now cd into that directory. The next step consists in the generation of a package list. Just use the dpkg-scanpackages utility to accomplish the task. You may need to install the dpkg-dev package in case the dpkg-scanpackages command is missing (but it shouldn't unless how you could generate all packages?)

$ dpkg-scanpackages . | gzip -c9  > Packages.gz
dpkg-scanpackages: info: Wrote 1 entries to output Packages file.

Now cd into parent directory And move package's directory to the /var/www/html/

Our local repository is now ready.

Adding the repository to the software sources

At this point to be able to install our package from the local repository we created, we need to edit the /etc/apt/sources.list file, add the entry relative to it (change IP address to reflect that of your machine), and synchronize the repositories:

echo "deb [trusted=yes] http://10.1.1.4/debian ./" | tee -a /etc/apt/sources.list > /dev/null

Be sure to add the above [trusted=yes] to avoid the following error message:

Release' does not have a Release file. N: Updating from such a repository can't be done securely, and is therefore disabled by default.

Synchronize repositories:

$ sudo apt-get update
Ign:1 http://10.1.1.4/debian ./ InRelease
Ign:2 http://10.1.1.4/debian ./ Release
Ign:3 http://10.1.1.4/debian ./ Packages
Ign:3 http://10.1.1.4/debian ./ Packages
Ign:3 http://10.1.1.4/debian ./ Packages
Get:3 http://10.1.1.4/debian ./ Packages [303 B]

To install our package, we can now use the apt-get tool:

sudo apt-get install ${Package_Name}
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
  ${Package_Name}
0 upgraded, 1 newly installed, 0 to remove and 8 not upgraded.
Need to get 3174 B of archives.
After this operation, 1,049 kB of additional disk space will be used.
WARNING: The following packages cannot be authenticated!
  ${Package_Name}
Install these packages without verification [y/N]? y

Thats it.