# Proper operation of Synth



## toprank (Feb 9, 2018)

I'm not sure that I've got the grasp of Synth.

I'm trialing it on a server for the first time, having decided to make the switch from Poudriere, and wish to create a local repository to install packages built with Synth by using `pkg`.

For example, I've built a number of packages with `synth just-build ports2build.txt` that now reside in /var/synth/live_packages/All/, have then issued `synth prepare-system`, and now want `pkg` to install these local Synth built packages--not binaries from the FreeBSD repository.

But when I issue `pkg install multitail`, for example, it goes to install from the FreeBSD repository--not the local Synth repo.


```
# pkg install multitail
Updating Synth repository catalogue...
Synth repository is up to date.
Updating FreeBSD repository catalogue...
FreeBSD repository is up to date.
All repositories are up to date.
The following 1 package(s) will be affected (of 0 checked):

New packages to be INSTALLED:
    multitail: 6.4.2 [FreeBSD]

Number of packages to be installed: 1

119 KiB to be downloaded.

Proceed with this action? [y/N]:
```

See Synth configuration:


```
Synth configuration profile: LiveSystem
===============================================================================
   [A] Ports directory            /usr/ports
   ['B] Packages directory         /var/synth/live_packages
   [C] Distfiles directory        /usr/ports/distfiles
   [D] Port options directory     /var/db/ports
   [E] Build logs directory       /var/log/synth
   [F] Build base directory       /usr/obj/synth-live
   [G] System root directory      /
   [H] Compiler cache directory   /var/cache/ccache
   ['I] Num. concurrent builders   3
   [J] Max. jobs per builder      3
   [K] Use tmpfs for work area    true
   [L] Use tmpfs for localbase    true
   [M] Display using ncurses      true
   [N] Fetch prebuilt packages    true

   [>]   Switch/create profiles
   [RET] Exit

Press key of selection:
```

Contents of /usr/local/etc/pkg/repos/ directory:


```
/usr/local/etc/pkg/repos # ls
00_synth.conf    FreeBSD.conf
```

Contents of these *.conf files:


```
cat /usr/local/etc/pkg/repos/00_synth.conf 
# Automatically generated.

Synth: {
  url      : file:///var/synth/live_packages,
  priority : 0,
  enabled  : yes,
}
```


```
cat /usr/local/etc/pkg/repos/FreeBSD.conf 

FreeBSD: {

    url: "pkg+http://pkg.FreeBSD.org/${ABI}/latest"

}
```

I have configured this FreeBSD.conf file to use the latest FreeBSD package repository because I use `portsnap` to update the ports tree and want to adhere to the instructions on the Synth GitHub page of _"ensur[ing] pkg(8) is configured for the Latest packages and the ports tree is as well"_ when setting Fetch prebuilt packages to true (cf. option [N] in `synth configure`):



> *Synth is configured to prefetch suitable officially-built packages, but very few are actually retrieved. What's wrong?*
> This only happens to FreeBSD users. On FreeBSD, there are basically two official repositories: _Quarterly_ and _Latest_. The 10.2 Release and later have pkg(8) configured to use the _Quarterly_ packages by default. Earlier releases are configured to use the _Latest_ packages.
> 
> Either repository is fine, but the provided ports tree has to match! If you decided to continue with the _Quarterly_ branch (a fine choice if you don't like constant rebuilding) then you need to provide Synth with a SVN version of the ports tree set to the same _Quarterly_ branch. As could be deduced from the name, a new SVN branch is created every three months, so Synth users that choose the _Quarterly_ ports and packages need to remember to switch branches in January, April, July, and October.
> ...



What have I misconfigured that pkg(8) resorts to installing packages from the remote FreeBSD repository and not the local Synth repo? Is it simply a matter of assigning a higher _priority_ variable in /usr/local/etc/pkg/repos/00_synth.conf than in the /usr/local/etc/pkg/repos/FreeBSD.conf file?


----------



## PacketMan (Feb 9, 2018)

Did Synth actually build the sysutils/multitail package?  Look in /var/synth/live_packages/All and see if the package is there? It may not be because you have 
	
	



```
[N] Fetch prebuilt packages    true
```
 configured.  Which is the way it is supposed to work.  When you have fetching prebuilt packages turned on, Synth will only build the packages it needs to. The rest it will download at time of repository bulding.  I use `synth upgrade-system` after `synth prepare-system` to do the package installation for me.  I haven't used Synth in a while now; just haven't been doing any updates lately; but my memory tells me Synth would fetch any prebuilt packages during `synth prepare-system`, but I don't think it will do that during `synth just-build` command.  I can try and test this weekend if I can get some time.

EDIT: Only reason I do prepare-system before I do an upgrade-system is to allow and verify that everything and built successfully before I try to do the upgrade part.  Slow and steady, block by block, wins the race right?


----------



## toprank (Feb 9, 2018)

Yes, Synth did build this port and the .txz package is in /var/synth/live_packages/All


```
/var/synth/live_packages/All # ls multi*
multitail-6.4.2.txz
```

Is this strange behaviour or do I have something misconfigured?


```
root@novo:/var/synth/live_packages/All # ls multi*
multitail-6.4.2.txz
root@novo:/var/synth/live_packages/All # pkg install multitail
Updating Synth repository catalogue...
Synth repository is up to date.
Updating FreeBSD repository catalogue...
FreeBSD repository is up to date.
All repositories are up to date.
The following 1 package(s) will be affected (of 0 checked):

New packages to be INSTALLED:
    multitail: 6.4.2 [FreeBSD]

Number of packages to be installed: 1

119 KiB to be downloaded.

Proceed with this action? [y/N]: n
root@novo:/var/synth/live_packages/All #
```


----------



## PacketMan (Feb 9, 2018)

Hmmm I never use pkg(8) to install from Synth, I use Synth exclusively.  But I think you are supposed to do something like this `pkg install -R Synth multitail`.


----------



## toprank (Feb 9, 2018)

Thank you, but it produces the same result:


```
# pkg install -R Synth multitail
Updating Synth repository catalogue...
Synth repository is up to date.
Updating FreeBSD repository catalogue...
FreeBSD repository is up to date.
All repositories are up to date.
The following 1 package(s) will be affected (of 0 checked):

New packages to be INSTALLED:
    multitail: 6.4.2 [FreeBSD]

Number of packages to be installed: 1

119 KiB to be downloaded.

Proceed with this action? [y/N]: n
```


----------



## toprank (Feb 9, 2018)

Ah lowercase r works!


```
# pkg install -r Synth multitail
Updating Synth repository catalogue...
Synth repository is up to date.
All repositories are up to date.
Checking integrity... done (0 conflicting)
The following 1 package(s) will be affected (of 0 checked):

New packages to be INSTALLED:
    multitail: 6.4.2 [Synth]

Number of packages to be installed: 1

Proceed with this action? [y/N]: y
[1/1] Installing multitail-6.4.2...
[1/1] Extracting multitail-6.4.2: 100%
```


----------



## toprank (Feb 9, 2018)

Can it be configured so that the local Synth repository is used by default without having to pass the `-r Synth` option?


----------



## rigoletto@ (Feb 9, 2018)

The "default" way to use ports-mgmt/synth is disabling the FreeBSD official repository and just have the Synth one ON. The last time I used it Synth automatically disabled the FreeBSD one.


----------



## toprank (Feb 9, 2018)

lebarondemerde said:


> The "default" way to use ports-mgmt/synth is disabling the FreeBSD official repository and just have the Synth one ON. The last time I used it Synth automatically disabled the FreeBSD one.



How does this work with:


```
[N] Fetch prebuilt packages    true
```

And:



> *Synth is configured to prefetch suitable officially-built packages, but very few are actually retrieved. What's wrong?*
> This only happens to FreeBSD users. On FreeBSD, there are basically two official repositories: _Quarterly_ and _Latest_. The 10.2 Release and later have pkg(8) configured to use the _Quarterly_ packages by default. Earlier releases are configured to use the _Latest_ packages.
> 
> Either repository is fine, but the provided ports tree has to match! If you decided to continue with the _Quarterly_ branch (a fine choice if you don't like constant rebuilding) then you need to provide Synth with a SVN version of the ports tree set to the same _Quarterly_ branch. As could be deduced from the name, a new SVN branch is created every three months, so Synth users that choose the _Quarterly_ ports and packages need to remember to switch branches in January, April, July, and October.
> ...


----------



## PacketMan (Feb 9, 2018)

Is there a reason you want to use pkg commands, versus using synth based commands? Just curious.


----------



## toprank (Feb 9, 2018)

Primarily habit, to be honest. I can't really argue that typing `pkg install app` is any quicker than `synth install category/port` except with `synth install` I'd have to remember the port category, which might involve a freshports.org search or similar. This is cumbersome in comparison. But also because it should work. And this is a test run before deploying the repository to a webserver for other machines to access remotely. I don't want to install Synth on all the workstations that will be using this repo, so it has to work.


----------



## rigoletto@ (Feb 9, 2018)

toprank 

/usr/local/etc/pkg/repos/FreeBSD.conf

```
FreeBSD: {
   url: "pkg+http://pkg.FreeBSD.org/${ABI}/latest",
   mirror_type: "srv",
   signature_type: "fingerprints",
   fingerprints: "/usr/share/keys/pkg",
   enabled: no
}
```

PacketMan 

The problem of using ports-mgmt/synth to install the packages it built, like `synth upgrade-system` is not related with Synth it-self but with `pkg`, what is issued by Synth to actutally install the packages.

If some silly dependency that many packages depends fail during the process, when Synth later issue `pkg` it will do using `--yes` (without confirmation) and you can easily end up without a large number of your packages uninstalled.


----------



## PacketMan (Feb 9, 2018)

lebarondemerde said:


> PacketMan
> If some silly dependency that many packages depends fail during the process, when Synth later issue `pkg` it will do using `--yes` (without confirmation) and you can easily end up without a large number of your packages uninstalled.



Why is why I said I use `synth prepare-system` first, to make sure all built well. If anything fails I go investigate and (try to) fix it.  Then after that is all resolved I then do the `synth upgrade-system`. I have not had a single issue to date doing it that way.


----------



## rigoletto@ (Feb 9, 2018)

The point is, Synth does not install the packages by it-self, it just issue `pkg` to do the job. Using `synth prepare-system` to build the ports and later `synth upgrade-system` to install them instead of `pkg upgrade` will just make the process slower because `synth` will do some checks it already did when `synth prepare-system` was used.


----------



## PacketMan (Feb 9, 2018)

lebarondemerde said:


> ....`synth` will do some checks it already did when `synth prepare-system` was used.



I will gladly take an extra round of checks, and lose a few minutes of time, to ensure the best possible upgrade.


----------



## toprank (Feb 10, 2018)

What is considered best practice when using Synth built repository on the local machine?

`synth install category/port`

or

`synth just-build listofports.txt`
`pkg install -r Synth port`

or only enable Synth (and disable FreeBSD) repository and

`synth just-build listofports.txt`
`pkg install port`


----------



## rigoletto@ (Feb 10, 2018)

toprank 

For new packages it doesn't matter if you use `synth install` or `synth build` or `synth just-build`, depends on your objectives.

IIRC, `synth just-build` does not rebuild the repository and then you will need to issue `synth rebuild-repository` to have the built packages available to be installed.


----------



## PacketMan (Feb 10, 2018)

Yep, know that.


----------

