aptly-based-repository-setup.md 3.76 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149
# Aptly Setup Walkthorugh

### Terminology
#### mirror
Copy of a remote repository.
Mutable: Yes

#### repo
Repository that contains packages.
- Local (Testing)
  The local copy of the repository you’re trying to build. Should be accessible to the user testing
  and serving it.
  Server: Aptly HTTP Server
  Mutable: Yes
- Published (Production)
  The public and published version with GPG keys. Should be in a publicly accessible folder.
  Server: nginx
  Mutable: Shoud not be


#### snapshot
A locked version of a repo or mirror.
Mutable: No

### Things to take care of
 - You should only publish a snapshot. This will make sense if we have to rollback to a previous
   state.
 - Packages should only be replaced in the local repo.
 - Configuration of maximum open files should be highest else aptly would crash complaining
   that you have reached the maximum number of open files.
 - Always create a new snapshot after making any changes.
 - Avoid creating contents index unless necessary because it
   - takes long time
   - leads to several lock issues as new packages arrive to the server and cannot be added to the
     repository because of Aptly DB being locked 
     
     
### Procedure
1. Create Debian testing mirror
2. Update the created mirror
3. Create a snapshot of the mirror
4. Create a repo from the snapshot
5. Add hamara packages with forcpe replace option to the repo created in above step
6. Create the snapshot again
7. Publish the snapshot
8. Add the appropriate sources to apt sources
9. Add your GPG key to APT with apt-key


On the side,
Add a hook in GitLab to repeat steps 4-7 above on every successful build of Hamara packages

### Useful commands
 ```shell
 $ aptly mirror create test_mirror http://deb.debian.org/debian testing
 
 $ aptly mirror update test_mirror
 
 ### ET: 32 hours 29 minutes with an average download speed of 27 Mbps
 
 $ aptly mirror list
 
 $ aptly mirror show test_mirror
 
 $ aptly snapshot create aptly_snapshot from mirror test_mirror
 
 # Note: Make sure to have successfully updated the mirror before running this command.
 
 $ aptly repo create hamara from snapshot aptly_snapshot
 
 $ aptly repo add hamara <hamara_package_deb> -force-replace
 
 $ aptly snapshot create svastik from repo hamara
 
 $ aptly publish snapshot svastik
```


### Setup of a repository with multi components ( main, contrib, non-free)


[Multi component setup of repository](https://www.aptly.info/doc/feature/multi-component/)


   Mirror of Debian testing with separate components
   
   Snapshot these mirrors
   
   Create three repos from the respective snapshots based on the component.
   
   Remove packages that we are providing from the repository from all the repositories.
   or
   ~~use force-replace to replace debian provided packages with our packages.~~
   
   snapshot these modified debian repositories.
   
   serve these snapshots
   
   
```shell
deb  devel.hamaralinux.org main
   
deb  devel.hamaralinux.org contrib
   
deb  devel.hamaralinux.org non-free
```
   
   
   Create a separate repository for Hamara Packages.
    - Add all our packages, upstream modified as well as native packages into this repository.
   
   - Create a snapshot of our own(hamara) repository.
   
   serve this hamara repository snapshot
   
   
```   
deb  devel.hamaralinux.org native
```
   
Final repositories
   
`/etc/apt/sources.list`
```
deb  devel.hamaralinux.org main
   
deb  devel.hamaralinux.org contrib
   
deb  devel.hamaralinux.org non-free
   
deb  devel.hamaralinux.org native
```



#### Setup Implementation


### 1. Create Mirrors from upstream repositories

Creating the mirror of Debian testing main suite with specific architectures.

```shell

# aptly mirror -architectures="amd64,arm64,armel,armhf,i386" create testing-main http://deb.debian.org/debian testing main


```