sonatype-nexus-community / nexus-repository-apt

A Nexus Repository 3 plugin that allows usage of apt repositories
Eclipse Public License 1.0
105 stars 50 forks source link

Unable to point apt sources to Nexus 3.9 with APT plugin #45

Closed mckenziec closed 6 years ago

mckenziec commented 6 years ago

Hi. I feel like there's some inside information I'm missing regarding getting Nexus and your great APT plugin working. I've successfully followed the project instructions for building and installing it into my fresh Nexus OSS 3.9.0 install. When I create a new APT proxy repo I specify the name (Ubuntu-16.04), distribution (16.04), and remote location (http://releases.ubuntu.com/). Then in my test Ubuntu 16.04 VM I add "deb http://192.168.51.101:8081/Ubuntu-16.04 xenial main" to /etc/apt/sources.lst. When I "apt-get update" I end up with errors like:

The repository 'http://192.168.51.101:8081/Ubuntu-16.04/dists/xenial/main/binary-amd64/Packages 404 Not Found" Data from such as repository can't be authenticated and is therefore potentially dangerous to use. etc...

So I'm clearly messing up my APT plugin repo URL/path, and possibly my test client config. This git project is missing this last mile in setup and use. I realize that end user use is subjective, but can you include a basic/simple example? Or some tip? Thanks!!!

mpoindexter commented 6 years ago

Looks like your repo URL is slightly wrong (missing a "repository" path component). If you go to the repository list page in nexus admin, and use the "Copy" button in the "URL" column that will show you the right URL to use.

mckenziec commented 6 years ago

Ok!!! I've made progress. Thanks for the tip mpoindexter, but the situation is more complicated than just that. To some what I'm about to detail may seem obvious. Well its not if you haven't spent days trying to understand the Ubuntu repo url scheme and what apt does under the hood. I suggest you include at least a paragraph in the project's doc on the client setup.

After following the project README (https://github.com/sonatype-nexus-community/nexus-repository-apt) and successfully starting Nexus with the APT plug in, here's what I did to make a 100% proxy repo work:

1) Login to Nexus as admin and create a new APT repo. 2) Set the remote storage to a URL from your initial target client's /etc/apt/sources.list. e.g. http://us.archive.ubuntu.com/ubuntu/ 3) Set the distribution to your target ubuntu version. Hint you can check which versions accessible by just browsing to the remote storage URL under dists (e.g. http://us.archive.ubuntu.com/ubuntu/dists/). Note that I'm not sure if this is necessary or what it does, but I did it. e.g. xenial or trusty, etc... 4) Get your new Nexus APT repo URL from the "COPY" button in the Nexus admin repo list. e.g. http://192.168.56.101:8081/repository/apt-ubuntu16.04/ 5) On the target Ubuntu client, complete the following: sudo cp /etc/apt/sources.list /etc/apt/sources.list.bk sudo vi /etc/apt/sources.list

Add the following (swap your repo URL links in there):

deb http://192.168.56.101:8081/repository/apt-ubuntu16.04 xenial main deb http://192.168.56.101:8081/repository/apt-ubuntu16.04 xenial restricted deb http://192.168.56.101:8081/repository/apt-ubuntu16.04 xenial universe deb http://192.168.56.101:8081/repository/apt-ubuntu16.04 xenial multiverse deb http://192.168.56.101:8081/repository/apt-ubuntu16.04 xenial-updates main deb http://192.168.56.101:8081/repository/apt-ubuntu16.04 xenial-updates restricted deb http://192.168.56.101:8081/repository/apt-ubuntu16.04 xenial-updates universe deb http://192.168.56.101:8081/repository/apt-ubuntu16.04 xenial-updates multiverse

Note that you need the -updates variants otherwise you'll have broken dependencies when you try to install a newer package. Hint, everything is newer after the 1st Ubuntu distro release.

sudo apt-get update Hit:1 http://192.168.56.101:8081/repository/apt-ubuntu16.04 xenial InRelease Get:2 http://192.168.56.101:8081/repository/apt-ubuntu16.04 xenial-updates InRelease [102 kB] ... Fetched 2,392 kB in 2s (1,123 kB/s)
Reading package lists... Done

6) Test it:

sudo apt-get install vim Reading package lists... Done Building dependency tree
Reading state information... Done The following additional packages will be installed: vim-runtime Suggested packages: ctags vim-doc vim-scripts vim-gnome-py2 | vim-gtk-py2 | vim-gtk3-py2 | vim-athena-py2 | vim-nox-py2 The following NEW packages will be installed: vim vim-runtime 0 upgraded, 2 newly installed, 0 to remove and 23 not upgraded. Need to get 6,199 kB of archives. After this operation, 30.0 MB of additional disk space will be used. Do you want to continue? [Y/n] y Get:1 http://192.168.56.101:8081/repository/apt-ubuntu16.04 xenial-updates/main amd64 vim-runtime all 2:7.4.1689-3ubuntu1.2 [5,164 kB] Get:2 http://192.168.56.101:8081/repository/apt-ubuntu16.04 xenial-updates/main amd64 vim amd64 2:7.4.1689-3ubuntu1.2 [1,036 kB] Fetched 6,199 kB in 4s (1,523 kB/s) Selecting previously unselected package vim-runtime. (Reading database ... 160628 files and directories currently installed.) Preparing to unpack .../vim-runtime_2%3a7.4.1689-3ubuntu1.2_all.deb ... Adding 'diversion of /usr/share/vim/vim74/doc/help.txt to /usr/share/vim/vim74/doc/help.txt.vim-tiny by vim-runtime' Adding 'diversion of /usr/share/vim/vim74/doc/tags to /usr/share/vim/vim74/doc/tags.vim-tiny by vim-runtime' Unpacking vim-runtime (2:7.4.1689-3ubuntu1.2) ... Selecting previously unselected package vim. Preparing to unpack .../vim_2%3a7.4.1689-3ubuntu1.2_amd64.deb ... Unpacking vim (2:7.4.1689-3ubuntu1.2) ... Processing triggers for man-db (2.7.5-1) ... Setting up vim-runtime (2:7.4.1689-3ubuntu1.2) ... Setting up vim (2:7.4.1689-3ubuntu1.2) ... update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/vim (vim) in auto mode update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/vimdiff (vimdiff) in auto mode update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/rvim (rvim) in auto mode update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/rview (rview) in auto mode update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/vi (vi) in auto mode update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/view (view) in auto mode update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/ex (ex) in auto mode

I have an outstanding question. Do I have to have a separate APT repo in Nexus for each Ubuntu version? e.g. xenial, trusty, etc...? The remote storage URL is not distro specific, and apt knows its distro. I don't think its necessary and means we have to create separate reports for each version, unlike the YUM repo in Nexus which you can just create once. Maybe there's some technical detail that makes this impossible.

mpoindexter commented 6 years ago

@mckenziec - You do currently have to have a separate repo per Ubuntu version.

There's an open ticket to change it (https://github.com/sonatype-nexus-community/nexus-repository-apt/issues/22), but no one has done it yet. That ticket discusses some of the reasons why, but the short of it is that when I initially wrote this I limited it to one repo per version for no good reason other than it made a couple of things in the code simpler and I had no use cases to do otherwise :)

mpoindexter commented 6 years ago

Closing this out as it appears to be resolved.