# Maintain packages that were removed from ports repository



## spag (Jan 28, 2022)

I need to provide php73 to my servers and it was removed from ports.

All other parts of the system should be up to date - so I do not want to lock the system with a specific hash of ports.

The idea I have is to get ports clone and omit hash that removed PHP73 ports - then builds it with poudriere as a separate repo with only php73 packages.
The final hosts would receive two repositories: legacy-php73 and current.

`git clone https://git.FreeBSD.org/ports.git /usr/ports
git rebase -i cc378fb60bd6ff39ac810093b5fc83cf330c1d92~`

Do you have any ideas of best practices how to manage such a situation?


----------



## jmos (Jan 28, 2022)

You can build packages on a machine that has them installed: `pkg create pkgname` does it. You can install such packages on another machine (`pkg install /path/to/package`).

You can lock packages, so updates won't remove old ones: `pkg lock packagename`

PHP is quite simple to compile by yourself: Use the source, read the docs and compile it as described; You can get PHP 7.3 without any package.

Using the old ports instead isn't an option, as you would also need the old  /usr/ports/Mk/Uses/php.mk…

But one thing remains: Why does a PHP application still needs an EOL version? You've had over two years to update your code… (and afaik it was quite simple to switch to 7.4 as there weren't huge changes; 8.1 costed me much more time: ~half day for 1 MB plain PHP code). Using PHP means to me: Subscribe their RSS feed, read the changelogs, and check your code with every new, major release. As PHP mostly is used on servers exposed to the internet you've got to look after them anyway.


----------



## monwarez (Jan 28, 2022)

The "best practice" would simply be to copy all of php73 ports that are needed in an overlay port tree
See





						⚙ D21468 Overlay support for the ports tree
					






					reviews.freebsd.org
				




And then you can use ports-mgmt/poudriere to build them by giving the overlay as a port overlay (see the poudriere documentation for that)

You may be able to overwrite Uses/php.mk


----------



## grahamperrin@ (Jan 29, 2022)

monwarez said:


> … overlay … then you can use ports-mgmt/poudriere …



No mention of _overlay_ in the FreeBSD Handbook <https://docs.freebsd.org/en/books/handbook/book/> and related documentation for poudriere is bugged.

Please, where best to begin learning?

Something concise and non-complex with a real-world example will be ideal. Thanks.

dvl@ I see your tweet from 2019. Any suggestions for learning for beginners in 2022? TIA


----------



## monwarez (Jan 29, 2022)

I don't really know where there is a concise documentation about poudriere and overlay, basically you need to add your overlay as a port tree and then tell poudriere to use it as an overlay. A quick search on github give this repository that provide an example on how to use it (NOTE: you don't need the devel version of poudriere)









						GitHub - decke/ports: Custom FreeBSD Ports Overlay
					

Custom FreeBSD Ports Overlay. Contribute to decke/ports development by creating an account on GitHub.




					github.com


----------



## zirias@ (Jan 29, 2022)

spag said:


> The idea I have is to get ports clone and omit hash that removed PHP73 ports - then builds it with poudriere as a separate repo with only php73 packages.


The IMHO best method is slightly different:

Create a local branch e.g. `git checkout -b local`
On that branch, revert the commit you don't want with `git revert <hash>`
Then in the future, you can fetch main and rebase your local branch onto main.

My personal ports tree is an example for one with a custom local branch: https://github.com/Zirias/zfbsd-ports/commits/local
I use the following commands to update it:

```
cd /usr/local/poudriere/ports/default
    git checkout local
    git fetch origin main:main && git rebase main
```

But: There's a reason old software is removed, often security concerns. Try to solve whatever keeps you from using a newer PHP ASAP.


----------



## grahamperrin@ (Jan 29, 2022)

Thanks. poudriere, I'm mostly OK with, so far.

Now, I probably have a better understanding of the scope of overlays:

`poudriere ports -c -U https://github.com/decke/ports.git -p decke-ports -m git -B master`

– <https://github.com/freebsd/poudriere/wiki/poudriere-ports.8#options> option `-p`, and it's an expansive overlay.



monwarez said:


> (NOTE: you don't need the devel version of poudriere)



As far as I can tell, it's needed for poudriere-bulk(8). Option `-O`:

present under <https://github.com/freebsd/poudriere/wiki/poudriere-bulk.8-devel#options>
not present under <https://github.com/freebsd/poudriere/wiki/poudriere-bulk.8#options>
present at <https://github.com/freebsd/poudrier...9c8b6067a2326054f92eced460d8df1e4f4d1d04e4R45>
Cross-reference: auto-generation issues involving wiki pages such as poudriere-testport.8 · Issue #965 · freebsd/poudriere


----------



## spag (Mar 6, 2022)

The process I have followed :

```
# Make sure poudriere-devel is installed as it has -O option
pkg install poudriere-devel -y

#make sure you have options set up for /usr/local/etc/poudriere.d/130amd64-options php73 packages - if you don't copy them from php74 they should work.

#get repository with the last commit before removal of PHP73 from official repo
mkdir php73-lastcommit
git clone https://git.FreeBSD.org/ports.git
git revert a60d5b0d747489751077ce93e8e52b44910f8eba

#create a new repository (github/etc)
mkdir php73
git init

#copy all php73 ports from the above repository to the new one and push.
cat /builders/build-packages.list | grep php73 | xargs cp php73-lastcommit/ports/..{} ph.p73/...
#Copy Mk php.mk definitions
cp  php73-lastcommit/ports/Mk/Uses/php.mk .
git add *
git commit -m 'last PHP73 ever'
git push

#create a new repository in poudriere
poudriere ports -c -p php73 -U git@github.com:*****/php73.git -m git+ssh -v

#build update ports
/usr/local/bin/poudriere ports -u

#remove 'php73' MOVED references (tmp) from main REPO ( temporally for a build only )
mv /usr/local/poudriere/ports/default/MOVED /usr/local/poudriere/ports/default/MOVED.old
cat /usr/local/poudriere/ports/default/MOVED.old | grep -v php73 >/usr/local/poudriere/ports/default/MOVED

#Build packages
/usr/local/bin/poudriere bulk -f /builders/build-packages.list -O php73 -j 130amd64

#Bring back original MOVED. Otherwise you will get git stage error when you will be updating ports.
mv /usr/local/poudriere/ports/default/MOVED.old /usr/local/poudriere/ports/default/MOVED
```


----------



## bsduck (Mar 6, 2022)

spag said:


> # Make sure *poudiere*-devel is installed as it has -O option
> pkg install *poudiere*-devel -y





spag said:


> #create a new repository in *poudiere*


You're missing a R in poudriere.


----------



## grahamperrin@ (Mar 6, 2022)

bsduck said:


> … missing a R in poudriere.



A suprisingly widespead eror, fo example <https://old.reddit.com/comments/ba0j98/-/>, <https://old.reddit.com/comments/pjkzmi/-/hbz9nfm/> and <https://old.reddit.com/comments/mzl8ki//gw1cm2s/>. I quiet like that last one. Voulez-vouz proudiere?


----------

