Some situations call for manually installing a local package using dpkg -i <packagename>. Sometimes it may be further useful to leverage the functionality of apt with that package so the question is:

How do you quickly create a local repository for random packages using a Debian based linux distribution - like Xubuntu 13.04/Ubuntu?

  • Just FYI. The usual thing is to follow dpkg -i <packagename> with apt-get -f install to pull in required packages. Also, the usual thing to create an apt repos for Debian is reprepro. – Faheem Mitha Aug 17 '13 at 17:38
  • I've found reprepro helpful – Gilles 'SO- stop being evil' Aug 17 '13 at 21:11
  • Thank you for your comments. @Faheem Mitha: can you please briefly expand on why running apt with --fix-broken would be required after installing a local package with dpkg -i? Wouldn't dpkg take care of that? I read it may be required the first time apt is run? @FM&Gilles: About reprepro. Seems useful if I could get it to work (not sure about dir struct, contents of 3 files or params at runtime). Will try again and update or post full question. – user44370 Aug 18 '13 at 3:49
  • 1
    @illuminÉ : dpkg does not resolve dependencies, but apt does. dpkg will warn of broken dependencies, but is low level, so will not attempt to fix them. The dpkg -i *.deb followed by apt-get -f install is standard procedure. There is a wishlist bug to have apt itself handle the case of local package installation, and there is even a patch, I think, but it has not yet been implemented. See apt-get install could install local package files, too, originally filed in 1999. – Faheem Mitha Aug 18 '13 at 8:39
  • @illuminÉ Expressing interest in this feature will not hurt. I think the more people who (politely) express interest, the more likely it is that it will be implemented. Note also that gdebi is an alternative, as noted in the bug report. That is part of the reason it has not been implemented, I think. Though having such core functionality part of apt would be better than having this functionality as part of another package. – Faheem Mitha Aug 18 '13 at 8:42

This should be distinguished from the situation where you're trying to replicate a full package tree from an official repository and fine tuning sources priority. Random packages mean virtual packages, packages which are compiled locally or copied in a piecemeal fashion for testing purposes. Here's a simple setup based on now obsolete documentation.

First, make a directory to host the packages:

mkdir <packagedir>

Then move your .deb package files there. Execute this command from the directory above the one we just created (make sure permissions allow this!):

dpkg-scanpackages packagedir | gzip > packagedir/Packages.gz

Now create a file with extension .list in /etc/apt/sources.list.d/ with the contents:

deb [trusted=yes] file:///path_to_dir_above_packagedir packagedir/

and update the apt database:

apt-get update

At this point the packages in our local repository can be installed like any other package using apt-get install <packagename>. When new packages are added to the local repository, the prescribed dpkg-scanpackages command must be issued again to update the Packages.gz file and apt must be updated before the new packages are made available. Hopefully this can be useful for testing purposes.

  • 6
    With the new apt 1.1, one needs [trusted=yes] between deb and the file:/// URI (see the sources.list(5) man page), otherwise apt-get update fails because of the lack of signature. – vinc17 Nov 27 '15 at 2:31

If you want to create a repo with the full structure that you need for tools like debootstrap, the simplest way I've found is:

  1. Create a repository directory.

    # mkdir -p /opt/debian
  2. Create a conf subdirectory.

    # mkdir /opt/debian/conf
  3. Create an /opt/debian/conf/distributions file with contents like this (adjust as appropriate for the distribution you're using):

    Label: Local APT repository
    Codename: jessie
    Architectures: amd64
    Components: main
    Description: Local APT repository for debootstrap
  4. Import your package with reprepro.

    # reprepro -b /opt/debian includedeb jessie /path/to/package.db
  5. Import a bunch of packages with a shell for-loop, e.g. everything from your APT cache:

    # cd /var/cache/apt/archives
    # for DEB in *.deb; do reprepro -b /opt/debian includedeb jessie $DEB; done

This will create an unsigned archive. It can be used with debootstrap with the --no-check-gpg option.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy