# Install older version with pgk install



## Aknot (Oct 26, 2022)

Hello,

I'm using `pkg install` to install packages for the first time (was using portmaster earlier).
Now I need to install OpenSearch, but I need an earlier compatible version than the found through the pkg install command.

This is a new install, so I don't have any older versionen locally in cache.

Is it possible to find the old version somewhere, and install it by typing `pkg install opensearch124.tgz` for instance?

Thanks,


----------



## SirDice (Oct 26, 2022)

You will have to build from ports because the repository doesn't store the old versions of the packages.


----------



## Aknot (Oct 26, 2022)

SirDice said:


> You will have to build from ports because the repository doesn't store the old versions of the packages.



Thanks for the input!

Okay I see, is it dangerous in any way to mix ports and packages?


----------



## SirDice (Oct 26, 2022)

Aknot said:


> Okay I see, is it dangerous in any way to mix ports and packages?


Not if you're careful. Make sure you use the correct branch of the ports tree. Use the quarterly branch if you use quarterly packages and the main branch if you're using latest. Also keep the options at default as those can change the dependencies (which might lead to conflicts between the 'official' package and what you've built from ports).

Use git(1) to get a ports tree, that will allow you to revert the commits that updated this specific port.


----------



## Aknot (Oct 26, 2022)

Thanks again for the input!

This is a new server, so I think the best thing to do, is going back to ports again, as I'm afraid fiddling with dependencies in the future.

Thanks,


----------



## SirDice (Oct 26, 2022)

The best solution is to set up your own repository. But this takes a bit of effort to set up (not to mention the time it takes to build everything). That will get you the best of both worlds, the flexibility of ports (options, default versions, etc) and the convenience of packages (quick and easy to install, update, etc).


----------



## chrbr (Oct 26, 2022)

Aknot said:


> Is it possible to find the old version somewhere, and install it by typing `pkg install opensearch124.tgz` for instance?


It might be possible to find such old packages in /var/cache/pkg. But it is very likely that dependencies do not match with current ports or packages. The temporary re-installation of previous packages can be helpful if the current version has a regression. Then one can `pkg lock something` until the regression is fixed.


----------



## Aknot (Oct 26, 2022)

Thank you for using your time to answer and help, i really appreciate it 
It's impossible not to love this forum and community 

Is it possible to download an old version from the ports tree?
For example download to "textproc/opensearch124", and then run "portmaster textproc/opensearch124"?

This is the one I need, version 1.2.4:





						opensearch « textproc - ports - FreeBSD ports tree
					






					cgit.freebsd.org
				




Thanks again


----------



## SirDice (Oct 26, 2022)

Aknot said:


> Is it possible to download an old version from the ports tree?


The ports tree is controlled with git, you can revert to any version you like. 



Aknot said:


> This is the one I need, version 1.2.4:



Edit: I'm making a mess of things. Got thrown off by the link.

Look at the commit logs for the Makefile (that determines what version the port has): https://cgit.freebsd.org/ports/log/...e?id=81ec2b0f060cb8a30754f3a8aec2ecea18484dec 
This specific commit updated the port to 1.2.4 (from 1.2.3): https://cgit.freebsd.org/ports/comm...e?id=81ec2b0f060cb8a30754f3a8aec2ecea18484dec
So, a `git revert 81ec2b0f060cb8a30754f3a8aec2ecea18484dec` would remove that specific commit, and thus revert that port back to its previous version.


----------



## SirDice (Oct 26, 2022)

Lets start that again. Look at the commit log of the Makefile for that port: https://cgit.freebsd.org/ports/log/textproc/opensearch/Makefile
You will have to revert each of those commits all the way back to the "textproc/opensearch*: Update to 1.3.0" commit (that commit updated the port from 1.2.4 to 1.3.0). Start at the top and work your way down.

To revert this commit: https://cgit.freebsd.org/ports/comm...e?id=e21e127ba49d389a1dfcd89010a066ac5a755568
use `git revert e21e127ba49d389a1dfcd89010a066ac5a755568`

Then this one: https://cgit.freebsd.org/ports/comm...e?id=97b0bb60dc4dc6a71a26e08cc3d92576067b017a
Then: https://cgit.freebsd.org/ports/comm...e?id=b7f05445c00f2625aa19b4154ebcbce5ed2daa52
etc.


----------



## Whattteva (Oct 26, 2022)

Wouldn't it be easier to just reset to a tagged version (not sure if the git tree has these tags) instead of reverting all those commits individually?

Something like this one (assuming it's tagged 1.2.4).

```
git reset --hard 1.2.4
```


----------



## SirDice (Oct 27, 2022)

Well, you normally go back one, maybe two version when you run into trouble. So if you have issues with version N you try to go back to version N-1. That's usually just one or two commits to revert. In this case the OP wants to go back several versions. From 2.2.1 back to 1.2.4. 

It's probably better to repo copy the original port and create a opensearch1 port that sticks to the 1.x versions. Looking at the website they seem to have two major version trees, one for 2.x and one for 1.x. The 1.x train is currently at 1.3.6.


----------



## Whattteva (Oct 27, 2022)

SirDice said:


> Well, you normally go back one, maybe two version when you run into trouble. So if you have issues with version N you try to go back to version N-1. That's usually just one or two commits to revert. In this case the OP wants to go back several versions. From 2.2.1 back to 1.2.4.
> 
> It's probably better to repo copy the original port and create a opensearch1 port that sticks to the 1.x versions. Looking at the website they seem to have two major version trees, one for 2.x and one for 1.x. The 1.x train is currently at 1.3.6.


I understand that, but you don't need to revert manually like that if they tagged their versions (I don't know if they do, I'd imagine they do). You can just simply reset the head back to that tagged commit hash. No need to do very laborious manual reverts. Actually, now that I think about it more, I just thought of something even better than resetting, which is simply:

```
git checkout 1.2.4
```

Again, all this assumes that they tag their versions. If they don't, then you'd simply just have to replace the version number with the actual commit hash... bit more hassle, but still fairly simple 1-line commands.


----------



## Whattteva (Oct 27, 2022)

I actually just pulled the entire ports tree..... only took 20 mins lol...

It doesn't look like they have a specific tag like I mentioned. So will have to do this instead and that will take you exactly where you want to.

```
git checkout 81ec2b0f060cb8a30754f3a8aec2ecea18484dec
```

Here's the output from my terminal:

```
user@machine:~/git/ports$ git checkout 81ec2b0f060cb8a30754f3a8aec2ecea18484dec
HEAD is now at 81ec2b0f060c textproc/opensearch: Update to 1.2.4
user@machine:~/git/ports$ git show
commit 81ec2b0f060cb8a30754f3a8aec2ecea18484dec (HEAD)
Author: Romain Tartière <romain@FreeBSD.org>
Date:   Sun Feb 6 17:19:19 2022 -1000

    textproc/opensearch: Update to 1.2.4
   
    Release note:
    https://github.com/opensearch-project/opensearch-build/blob/main/release-notes/opensearch-release-notes-1.2.4.md
   
    With hat:       opensearch

diff --git a/textproc/opensearch/Makefile b/textproc/opensearch/Makefile
index 60e10c215ae6..01d5443d578f 100644
--- a/textproc/opensearch/Makefile
+++ b/textproc/opensearch/Makefile
@@ -1,7 +1,7 @@
 # Created by: Sven R <freebsd@hackacad.net>
 
 PORTNAME=      opensearch
-DISTVERSION=   1.2.3
+DISTVERSION=   1.2.4
 DISTVERSIONSUFFIX=     -linux-x64
 CATEGORIES=    textproc java devel
 MASTER_SITES=  https://artifacts.opensearch.org/releases/bundle/${PORTNAME}/${PORTVERSION}/
diff --git a/textproc/opensearch/distinfo b/textproc/opensearch/distinfo
index f74f346c8ae9..0c44d85b2c53 100644
--- a/textproc/opensearch/distinfo
+++ b/textproc/opensearch/distinfo
@@ -1,3 +1,3 @@
-TIMESTAMP = 1640622753
-SHA256 (opensearch-1.2.3-linux-x64.tar.gz) = a594ac2808e6e476d647e47e45e837fba3e21671285ce39b2cee1c32d5e6887d
-SIZE (opensearch-1.2.3-linux-x64.tar.gz) = 414294749
+TIMESTAMP = 1644200170
+SHA256 (opensearch-1.2.4-linux-x64.tar.gz) = d40f2696623b6766aa235997e2847a6c661a226815d4ba173292a219754bd8a8
+SIZE (opensearch-1.2.4-linux-x64.tar.gz) = 414286691
```

Aknot From here, you just have to look at the instructions to build. I imagine it's as simple as:

```
cd ports/textproc/opensearch
make install clean
```

Good luck! Hope that helps!


----------



## Aknot (Oct 28, 2022)

Thank you very very much guys, this is really valuable help to me!!

I'm running Magento in a multistore setup with 8 separate stores, and the requirements are very specific, even if using the latest version of Magento (Current: 2.4.5-P1).

It's up and running now:


```
curl -XGET http://localhost:9200
{
  "name" : "srv06",
  "cluster_name" : "opensearch",
  "version" : {
    "distribution" : "opensearch",
    "number" : "1.2.4",
    "build_type" : "tar",
    "build_date" : "2022-01-14T03:38:06.881862Z",
    "build_snapshot" : false,
    "lucene_version" : "8.10.1",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  },
  "tagline" : "The OpenSearch Project: https://opensearch.org/"
}
```

Thanks again


----------

