Search
Monday, March 16, 2020

In this post I will illustrate how to build a public ubuntu/debian APT repository, where you can make your packages publicly available in such a way that they can be installed with apt in the standard way. For this purpose, I will use a tool called reprepro. I assume that you already know how to build deb packages. If not, you can find a very nice basic tutorial here:

https://ubuntuforums.org/showthread.php?t=910717

In one of my github repositories you can find an example of script for automatic building of a deb package in a autotools environment:

https://github.com/golosio/NeuronGPU/blob/master/deb/build_package.sh

First of all, install all the necessary tools:

sudo apt install reprepro gpg

In order to be able to sign the deb packages, if you have not already done so you should create a GPG key.

gpg --gen-key

After following the instructions, in the output there should be a line like:

gpg: key CAF404E7379E2A0E marked as ultimately trusted

Take note of the key ID (CAF404E7379E2A0E in this example). In any case, you can retrieve it with the command:

gpg --keyid-format long --list-secret-keys

which yields something like:

sec rsa3072/CAF404E7379E2A0E 2020-03-16 [SC] [expires: 2022-03-16]
63EAA1AA6B332DB9496D1A17CAF404E7379E2A0E

Then upload the public key:

gpg --send-keys CAF404E7379E2A0E
gpg: sending key CAF404E7379E2A0E to hkp server keys.gnupg.net

In your home or in any other directory build the main folder:

mkdir -p ~/www/repo/{debian,ubuntu}/{conf,dists,incoming,indices,logs,pool,project,tmp}

Put a copy of the public part of the GPG key in the repo folder:

cd ~/www/repo
gpg --armor --export mikey@gmail.com > pubkey.gpg

where you should use the same email address that you used to generate the key.

With emacs or with your favorite editor open the main configuration file:

emacs ~/www/repo/distributions

and write something like:

Origin: Scientific Software
Label: deb.scisoft.net
Codename: bionic
Architectures: amd64
Components: main
Description: Debian/Ubuntu Packages for scientific software maintained by Bruno Golosio
SignWith: CAF404E7379E2A0E

Origin: Scientific Software
Label: deb.scisoft.net
Codename: eoan
Architectures: amd64
Components: main
Description: Debian/Ubuntu Packages for scientific software maintained by Bruno Golosio
SignWith: CAF404E7379E2A0E

with one block for each release, changing the Origin, Label and Description according to your needs, and replacing the SignWith field with the GPG key ID that you created before. For a description of all fields see for instance:

https://blog.packagecloud.io/eng/2017/03/23/create-debian-repository-reprepro/

Now you can use reprepro to create the initial structure, symbolic links and initial Packages files:

cd ~/www/repo/ubuntu
reprepro -Vb . createsymlinks
reprepro -Vb . export

Follow the same procedure for the www/deb/debian folder if you need it.

now you can start signing and adding your deb packages to the repository. When you import the first package, reprepro wil automatically generate the repository. To sign a package, type:

dpkg-sig --sign builder package-name.deb

Then use reprepro to add the package to the repository:

reprepro -b ~/www/repo/ubuntu includedeb bionic package-name.deb
Exporting indices...

In order to make your repository publicly available, you should upload the directory www/deb with all its content in a web hosting server. There are many providers of such service, and you can choose the one that you prefere. Remember that you must synchronize your local folder with your hosted domain, so that every time you update a package or add a new package to the repo this package is available in the public repository. The way how to syncronize the folder depends on the web hosting provider and is not covered in this post.

In order to install your packages with apt, the users shoud type the following commands:

curl -sS http://deb.scisoft.net/pubkey.gpg | sudo apt-key add -
echo "deb [arch=amd64] https://deb.scisoft.net/ubuntu bionic main" | sudo tee /etc/apt/sources.list.d/scisoft.list
sudo apt-get update

where deb.scisoft.net must be replaced by the domain of your repository and bionic by the user's ubuntu release.

 


Friday, March 13, 2020

Resilio Sync is a folder syncing tool that can allow you to share your folders and files among different PCs and devices over the internet. It uses edge-to-edge technology for a fast and secure file synchronization. Unlike hosting services such as Dropbox, file sharing does not require an intermediary host, therefore synchronization is faster and storage limits depend only on the storage capacity of your devices.

How to install and configure Resilio Sync on Ubuntu

In your PC in Ubuntu open a terminal and type:

wget http://linux-packages.resilio.com/resilio-sync/key.asc
sudo apt-key add key.asc
sudo apt install software-properties-common
sudo add-apt-repository "deb http://linux-packages.resilio.com/resilio-sync/deb resilio-sync non-free"
sudo apt install resilio-sync
sudo systemctl enable resilio-sync
sudo systemctl start resilio-sync

Check if it is active with the command:

systemctl status resilio-sync

and press q.

By default, rslsync operates through an ad-hoc user called rslsync. In order to avoid problems with read/write permissions on synchronized files, it is more convenient to run the service through your own user, the  one that you can see by typing the command

whoami

In order to start automatically the service through your user, type:

/etc/resilio-sync/init_user_config.sh
sudo systemctl edit resilio-sync.service

You should have the following section in the file that you have just opened (if you do not have it, copy/past it):

[Service]
User=golosio
Group=golosio
PIDFile=/home/golosio/.config/resilio-sync/sync.pid
ExecStartPre=
ExecStart=
ExecStart=/usr/bin/rslsync --config /home/golosio/.config/resilio-sync/config.json

Here you must replace golosio with your username (you should make four substitutions). Save it (leave the proposed filename unchanged). Then run:

sudo systemctl daemon-reload
sudo systemctl restart resilio-sync.service

and check if it worked by typing:

ps aux | grep rslsync

You should see something like:

golosio   1121  1.5  0.7 1526160 115868 ?      Ssl  ago19  32:12 /usr/bin/rslsync --config /home/golosio/.config/resilio-sync/config.json

with your username in place of golosio.

Open an internet browser, and in the address bar write:

http://127.0.0.1:8888/

Depending on the browser you might have to press "Advanced..." and accept the security risk.  Enter your username and password. Now you have the possibility to create new synced folders. Choose "Standard folder". A secret key is associated to each folder. To use a synced folder from a different device, press the "+" at the top left, select "Enter a key or link" and enter the secret key associated to the folder.