# multi-architecture package repos



## Ali.Z (Thursday at 10:22 AM)

OS: FreeBSD 12.4, ABI amd64.

what I am trying to do is to enable multi-architecture pkg repos, i.e. to have both amd64 and i386.

what I did is I made a conf file under /usr/local/etc/pkg/repos/*.conf
and set the url to FreeBSD:12:i386.

tried to run pkg update, it fetched all required i386 files, but failed to update repository, because the OS is amd64 and I already have an amd64 repo exist under pkg/repos.

is there any way to have both amd64 and i386 repos *enabled at the same time*?


----------



## SirDice (Thursday at 10:37 AM)

You can define more than one repository.


----------



## Ali.Z (Thursday at 11:03 AM)

I am sure you did not read my first post properly, here is an attachment,


----------



## SirDice (Thursday at 11:43 AM)

Please don't post pictures of text. They're impossible to quote from. Just copy/paste the actual text in a [code]...[/code] block. 

That said, you have two seperate repositories defined and they're both enabled. But pkg(8) will refuse to install packages from a different architecture than the host. 



Ali.Z said:


> tried to run pkg update, it fetched all required i386 files,


It only fetches and caches a _local_ copy of the catalog. 



Ali.Z said:


> because the OS is amd64 and I already have an amd64 repo exist under pkg/repos.


This local catalog will be saved in a different SQLite database. If you look in /var/db/pkg you will see repo-<name>.sqlite. Each repository will have its own local database containing the catalog. The reason you're getting this error is because your system is AMD64 and you're trying to save a catalog intended for i386. That's the issue, not the fact you have an existing AMD64 catalog. Your AMD64 catalog will be saved in repo-FreeBSD.sqlite and the i386 would be saved in repo-FreeBSDx86.sqlite. So there's no conflict with regards to saving the catalog.


----------



## SirDice (Thursday at 11:50 AM)

On this system I have two repositories enabled, the default FreeBSD one and a custom repository:

```
root@fbsd-test:~ # ll /var/db/pkg/
total 88591
-rw-r--r--  1 root  wheel       158 Jan 11 03:43 FreeBSD.meta
-rw-r--r--  1 root  wheel       158 Jan 12 13:47 dicelan.meta
-rw-r--r--  1 root  wheel  15089664 Jan 12 03:02 local.sqlite
-rw-r--r--  1 root  wheel  54644736 Jan 11 03:43 repo-FreeBSD.sqlite
-rw-r--r--  1 root  wheel   2682880 Jan 11 13:20 repo-dicelan.sqlite
-rw-r--r--  1 root  wheel         0 Jan 12 13:47 repo-dicelan.sqlite-journal
-r--r--r--  1 root  wheel   7359814 Jan 11 03:11 vuln.xml
```


```
Repositories:
  FreeBSD: {
    url             : "pkg+http://pkg.FreeBSD.org/FreeBSD:13:amd64/quarterly",
    enabled         : yes,
    priority        : 0,
    mirror_type     : "SRV",
    signature_type  : "FINGERPRINTS",
    fingerprints    : "/usr/share/keys/pkg"
  }
  dicelan: {
    url             : "http://_internal_server/packages/FreeBSD:13:amd64",
    enabled         : yes,
    priority        : 0
  }
```
Notice how the name of the repository is reflected in the _name_ of the repo-*.sqlite database files?


----------



## SirDice (Thursday at 11:57 AM)

As for the naming convention of the packages, they're going to clash. The architecture isn't included in the package name, so if you try to install apache24 for example it can't tell the difference between apache24-2.4.54.pkg (for amd64) and apache24-2.4.54.pkg (for i386), the intended architecture is stored in metadata _inside_ the package.


----------



## Ali.Z (Thursday at 12:21 PM)

sorry I dont have gui to copy/paste.

still, this does not solve my problem.
also repo-FreeBSDx86.sqlite is 0, as it couldnt update it.

perhaps there is a way to overcome this limitation, at least to be able to search in i386 repo?

yes I am aware of naming convention, the only way around is to install the i386 package in my home directory.

thank you for the details.


----------



## T-Daemon (Thursday at 1:14 PM)

Ali.Z said:


> is there any way to have both amd64 and i386 repos *enabled at the same time*?


Yes it's possible, only you need to set the ABI environment of the i386 repository.

For example, if there is a i386 repository configuration named "12-i386", to create and update that repository database:

```
# env ABI=FreeBSD:12:i386 pkg update -r 12-i386
```

Afterwards, i386 packages, if desired, can be pkg-fetch(8)ed locally in a separate repository (not the default in /var/cache/pkg), e.g.:

```
# pkg fetch -r 12-i386 -o /var/cache/pkg-i386 <package_name>
```


----------



## T-Daemon (Thursday at 1:55 PM)

Ali.Z said:


> sorry I dont have gui to copy/paste.


There is no need for a gui, you can paste the console output on a text storage site: `pkg update -r 12-i386 | nc termbin.com 9999`

Link the provided URL or copy and paste into forums post.


----------



## Ali.Z (Thursday at 2:14 PM)

I was able to update my (repo-FreeBSDx86.sqlite) using:
pkg -o ABI=FreeBSD:12:i386 update -r FreeBSDx86
now I can search and install successfully.
thank you.


----------

