PKG update/upgrade dosen't work...How do I update using ports?

Traditionally I have upgraded using the pkg update / pkg upgrade commands. Now the last update was -1.15.2.793_1…so I’m well behind. How would I upgrade using the ports command or is there a “force” to use the pkg command? Thanks in advance for your help!

You have to wait. Plex neglects the FreBSD users and they only make packages every here and there. By the way, this makes useless to pay for the Plex Pass.

Its a bit unfair to say we neglect FreeBSD, the update is live on our website, the fact that the port takes a bit more is because this is the way FreeBSD ports work and at times because the maintainer take a bit more, but to be fair even if we were the ones owning such port and updating it directly it would still take so time to be built and get it on pkg repos.

For now if you do want to update as soon as you want using ports the best way would be to bump the version in the ports Makefile, download the tarball to /usr/ports/distfiles; run make makesum and then make package… You know have a txz ready to install pkg under work/pkg/XXXX.txz.

As I said in other posts, there is actually internal interest in making this easier, maybe even have our own pkg repo, or at least provide ready to install txzs fro say FreeBSD 11 and 12, but we still need to make sure this wouldn’t break the way FreeNAS plugins work, which have been historically relying on the ports system as they do for everything else.

I can promise you we don’t neglect FreeBSD even though sometimes we need to do things differently there to keep it working or there’s, if we wanted to neglect it we could have just drop support for it entirely a long time ago, or not even offer it to start with.

No, it is not unfair. We once tried to develop our own way to update the packages (PMS_Updater.sh) but when we had problems you always blamed it our updating procedure and said we should not use this updating mechanism and we should just upgrade via pkg command. Well, that’s what we do now, we do exactly what you said. And we keep getting stuck with old versions.

Saying “The update is live in our site” is ridiculous when Plex told us not to update that way.

If you were not neglecting FreeBSD users you would find another solution.

And suddenly you care about not breaking the FreeNAS plugin. When in the past we were told not to use the plugin and just create an empty Jail and install Plex via pkg.

What I am reading here is such a mess that I am now sure Plex do not have a clear path about their FreeBSD users and that’s why we get contradictory support replies. No roadmap at all. To me this is been neglected, not sure that it is to you.

The newer FreeNAS versions actually improved the plugin mechanism, it now uses the ports system, and simply creates a jail (iocage and installs the plexmediaserver port) so that’s far better than it used to be.

But yes its still not perfect. However this is often the cases with NAS vendors… a lot of them also use their own update mechanism and make it even more complex than FreeBSD.

Also if we are talking about beta builds, except for the platforms where we support auto updates, all of them involve manually installing (granted that i.e. for debian its a simple dpkg -i *.deb command, but not so much for others)

I also provided in several posts steps to how to update using the ports by simply changing the version in the Makefile and a few commands, which I still think is better than the PMS_Updater.sh since this is a CUSTOM script that is not made by us or FreeBSD maintainers, it does not use the system standard method of updating. And even so I myself offered help on how to keep using such script by simply making sure update the rc.d file.

This means I took the time to understand how a CUSTOM 3rd party script works and offered a solution…

We also spend quite some time investigating how to enable Hardware Transcoding on FreeBSD, if we did not care why spend the time?

So yes I do think, IMHO, what you stated is unfair.

I’d also like to had here that you are free to use any scripts you like, what you cannot expect, and this is valid for any platform, is that we offer support for such scripts, in fact I believe when this happens whatever is wrong should be reported to wherever such script is maintained (i.e. github) as they would be in the best position to help. The devs of such scripts are also of course always free to ask for help, but we might not always be able to do so if they are not using the built-in mechanisms!

Lets take the example of that PMS_Updater.sh, why isn’t the script shipping its own start/rc.d script? Just this would avoid all the recent problems even if its still not using pkg/ports system, I’ve suggested so myself!

I would also kindly ask you to read this again:

As I said in other posts, there is actually internal interest in making this easier, maybe even have our own pkg repo, or at least provide ready to install txz s fro say FreeBSD 11 and 12, but we still need to make sure this wouldn’t break the way FreeNAS plugins work, which have been historically relying on the ports system as they do for everything else.

Is this not what you’re asking for actually? And is it not normal that we want to make sure we don’t break things for users?

Actually if this helps, here is a step by step using ports:

porstnap fetch update
cd /usr/ports/distfiles

[Download or copy the tarbal to this dir; i.e:]

fetch "https://downloads.plex.tv/plex-media-server-new/1.15.5.994-4610c6e8d/freebsd/PlexMediaServer-1.15.5.994-4610c6e8d-FreeBSD-amd64.tar.bz2"

Now the Makefile update could be done manually but I made a 1 min shell script to help (disclaimer its late here so this is just simple and lame :slight_smile: but it should work )

#!/bin/sh

newVer=$(echo $2 | cut -d "-" -f1)
newSufix=$(echo $2 | cut -d "-" -f2)

oldVer=$(awk '$1 ~ /PORTVERSION/ { print $2}' $1)
oldSufix=$(awk -F "=" '$1 ~ /DISTVERSIONSUFFIX/ { print $2}' $1)

sed -i '.bk' "s/$oldVer/$newVer/" $1
sed -i '.bk' "s/$oldSufix/$newSufix/" $1

Save that in ~/update_pms_makefile.sh and then:

cd /usr/ports/multimedia/plexmediaserver
~/update_pms_makefile.sh Makefile 1.15.5.994-4610c6e8d

[This should update the Makefile and point it to the newer version; also the way ports work, if that version is already on this it will not need to download it]

make makesum
make package

The txz will now be in the inner work/pkg dir.

Now you can use pkg install PATH_TO_FILE.txz

That Updater Script already handles auto download, so maybe it wouldn’t be that complicated to do something like this instead of replacing the binaries come to think of it…

There’s no arguing that the best way here would be for us to distribute a txz and / or provide a pkg repo, and although I can’t really promise anything I do hope this is something we can provide in the not so long future, for now I hope these steps help.

1 Like

If the first time you have to run:

portsnap fetch extract
mkdir /usr/ports/distfiles
cd /usr/ports/distfiles

And to fetch/download the tar file I’ve got an error using HTTPS (I hope it is not because Plex is too cheap to buy proper certificates), so I had to use HTTP instead.

Then now the REAL problem.

You told us to do:

cd /usr/ports/multimedia/plexmediaserver

But we Plex Pass users use a package called plexmediaserver-plexpass. I didn’t realize this and ended up with a package called plexmediaserver instead and I installed it and ended up with two versions of Plex installed and a total mess.

The correct path for Plex Pass users is:

cd /usr/ports/multimedia/plexmediaserver-plexpass

After redoing everything I installed the package and now Plex starts OK. But it shows as OFFLINE in some clients. It works in other clients. Not sure yet why.

The fetch command probably fails because root certs are missing… They are not shipped by default in freebsd.

You could skip cert verification or install the ca bundle (pkg install ca_root_nss)

As for the port name, yeah there’s a port flavour, but you don’t need it. The flavour version is simply using the original port and pointing to (usually) a more recent build… (Beta) but plexpass is not gated on the version it self so it’s actually misleading that those work this way… But thats an issue to solve another time.

If you what you can just adapt for what you have, or move to using the original port and thw commands I posted, you would just need to updated you’re rc.conf like (this time only) and move the older plexdata dir (one time only) to /usr/local/plexdata.

Possibly just adapting that I posted to be plexpass flavour port works best for you now.

Btw you should ALWAYS remove the old pkg before installing the new one, pkgng doesn’t do it for you except when using pkg upgrade to upgrade all pkg.
And ofc restart pms.

If I have some time this weekend I’ll try to convet this to a single script… Then maybe you could put it in a cron job or something and have something close to auto updates on mac/windows.

:joy: not at all, in fact we even offer our users free certs that enable secure remote connections to pms servers :slight_smile:

This is a freebsd issue, or rather just how they choose to do things, installing the pkg I mention should fix it.

Hum that’s not so good… It could just be cache though, what clients in particular!?

Web clients are all offline.

Samsung TV and Amazon Fire devices are working.

IMHO, I like the way FreeBSD updates, even the slight delay… It gives me time to check the forums and see if there are any major problems before I update both my FreeBSD and Windows 7 PMS installs…

I however, don’t use pkg… I use portmaster, that way I don’t have to wait for the FreeBSD package servers to build the package and make it available… It still gives me about a week after PLEX announces a release to check the forums, depending on how long it takes the port maintainer to update the port…

I have also seen the port not updated on certain releases if it didn’t affect the FreeBSD version… i.e., a windows only issue was fixed…

Just my two cents…

Is this still the case, this is odd if some apps can connected and others can’t… I don’t see how it could be a server issue, still… logs would help if you can grab them.

Is there any chance we could get all-in-one script in one weekend? :slight_smile:

Its in my list for sure, hopefully I can post something soon, even if its a lame shell script.

I’m also prefer portmaster update procedure, but port 1.16.0.1226 delaying on that time :frowning:

The list was too long :slight_smile:
So I’ve created simple script with step by step actions and checks. Can be used to change Plex versions from official site. Can be saved for example to ~/plex_update.sh and called with first parameter - link to plex new version on site and second parameter - plexpass, if you use one (e.g. ~/plex_update.sh https://downloads.plex.tv/plex-media-server-new/1.15.5.994-4610c6e8d/freebsd/PlexMediaServer-1.15.5.994-4610c6e8d-FreeBSD-amd64.tar.bz2 plexpass ). All the rest is done like in post with original function :), and delete packages after work. Hope, it will help.

#!/bin/sh

NV="$(echo $1 | awk -F '/' '{print $7}' | awk -F '-' '{print $2"-"$3}')"
if [ "$2" = "plexpass" ] ;then
	PLEXPASS="-plexpass"
fi

PORTDIR="/usr/ports/multimedia/plexmediaserver$PLEXPASS"

update_pms(){
	newVer=$(echo $2 | cut -d "-" -f1)
	newSufix=$(echo $2 | cut -d "-" -f2)

	oldVer=$(awk '$1 ~ /PORTVERSION/ { print $2}' $1)
	oldSufix=$(awk -F "=" '$1 ~ /DISTVERSIONSUFFIX/ { print $2}' $1)

	sed -i '.bk' "s/$oldVer/$newVer/" $1
	sed -i '.bk' "s/$oldSufix/$newSufix/" $1
	exit 0
}

echo "Do you want to upgrade to version $NV ? (Y/n)"
read REPLY
echo
if echo "$REPLY" | grep -iq "^n" ; then
        echo Installation is cancelled. Exiting...
	exit 1
fi

portsnap fetch update
if [ $? -ne 0 ]; then
	echo Please check your fetch operation. Exiting...
	exit 1
fi

cd /usr/ports/distfiles
fetch "$1"

if [ "$(ls -la | grep "$NV")" = "" ]; then
	echo The installation file was not downloaded from Plex. Exiting...
	exit 1
fi

cd $PORTDIR
update_pms Makefile $NV

make makesum
if [ $? -ne 0 ]; then
	echo make makesum error. Exiting...
	exit 1
fi

make package
if [ $? -ne 0 ]; then
	echo make package error. Exiting...
	exit 1
fi

PKGDIR="$PORTDIR"/work/pkg
PKGFILE="plexmediaserver$PLEXPASS"-"$(echo $NV | cut -d "-" -f1)".txz

if [ ! -f "$PKGDIR"/"$PKGFILE" ]; then
	echo Package not found. Exiting...
	exit 1
fi

pkg install "$PKGDIR"/"$PKGFILE"
if [ $? -ne 0 ]; then
	echo pkg error. Exiting...
	exit 1
else
	rm -rf "$PORTDIR"/work
	rm -f "$PORTDIR"/Makefile.bk
	echo "Do you want to restart Plex ? (Y/n)"
	read REPLY
	echo
	if echo "$REPLY" | grep -iq "^n" ; then
		echo "Plex was not restarted"
	else
		service plexmediaserver$PLEXPASS restart
	fi	
fi

Actually I’ve posted something like this (using pkg/ports) but uses the built-in PMS updater on another thread a while ago, sorry I forgot to post back here, let me see if I find it again

Couldn’t quickly find it so posting here, you’re as some interesting prompts, mine is a bit more simple and doesn’t have params, which I wanted to add but never need it so this just runs in a cron task:

#!/bin/sh
# Uses PMS API to check for updates
# Downloads Updates if available
# Installs to jail using ports system

PLEX_PORT_PATH="/usr/ports/multimedia/plexmediaserver"
PLEX_PKG_NAME="plexmediaserver"
SERVER_URL="https://YOUR-LOCAL-IP.some_hash.plex.direct:32400"
JAIL_NAME="ioc-plex"

release_info=""
download_url=""

split_version_sufix()
{
  version_prefix=$(echo $1 | cut -d "-" -f1)
  version_sufix=$(echo $1 | cut -d "-" -f2)
}


check_updates()
{
  ##fetch -qo - SERVER_URL/updater/status | egrep -o '([0-9]+(\.|-)){4}([a-z|0-9]+)'
  ## I wanted no deps but fetch doens't support post/put, and httpie'jq = awesomeness

  echo -e "Checking for updates...\n"
  http PUT $SERVER_URL/updater/check > /dev/null
  release_info=$(http --json -b $SERVER_URL/updater/status | jq '.MediaContainer.Release[]')

  if [ ! -z "$release_info" ]; then

    state=$(echo $release_info| jq -r '.state')
    new_version=$(echo $release_info| jq -r '.version')
    whats_new=$(echo $release_info| jq -r '{added,fixed} |to_entries[] | "  \(.key):   \(.value)"')
    download_url=$(echo $release_info| jq -r '.downloadURL')

    if [ "$state" == "notify" ]; then
      echo -e "New Update Available\nRelease info:\n"
      echo -e "Version: $new_version"
      echo -e "What's New: \n$whats_new\n\n"
    fi
  else
    echo "No updates available what the time"
    exit 1
  fi
}

check_jail_pkg_version()
{
  pkg -j $JAIL_NAME query %v plexmediaserver
}

download_new_version()
{
  cd /usr/ports/distfiles
  http -bd $download_url # TODO: add continue mode; need filename
  cd -
}

update_port_makefile()
{
  # expects version_prefix and sufix as arg1 and arg2
  portVersion=$(make -C $PLEX_PORT_PATH -V PORTVERSION)
  portVersionSufix=$(make -C $PLEX_PORT_PATH -V DISTVERSIONSUFFIX)

  echo "PORTVERSION: $portVersion || DISTVERSIONSUFFIX: $portVersionSufix"

  today=$(date +%F)
  sed -i "_$today.bk" "s/$portVersion/$1/" "$PLEX_PORT_PATH/Makefile"
  sed -i "_$today.bk" "s/$portVersionSufix/$2/" "$PLEX_PORT_PATH/Makefile"

  echo -e "\nMakefile Updated:"
  echo "PORTVERSION: $(make -C $PLEX_PORT_PATH -V PORTVERSION) || DISTVERSIONSUFFIX: $(make -C $PLEX_PORT_PATH -V DISTVERSIONSUFFIX)"
}

make_package()
{
  make -sC $PLEX_PORT_PATH clean
  make -sC $PLEX_PORT_PATH makesum
  make -sC $PLEX_PORT_PATH package
}

upgrade_pkg()
{
  # expects version prefix as arg
  PLEX_JAIL_PATH="$(jls -j $JAIL_NAME path)"

  jexec $JAIL_NAME service plexmediaserver stop
  pkg -j $JAIL_NAME remove -y $PLEX_PKG_NAME
  mv "$PLEX_PORT_PATH/work/pkg/$PLEX_PKG_NAME-$1.txz" "$PLEX_JAIL_PATH/tmp/$PLEX_PKG_NAME-$1.txz"
  pkg -j $JAIL_NAME install -y /tmp/$PLEX_PKG_NAME-$1.txz
  jexec $JAIL_NAME service plexmediaserver start
}


check_updates
pkg_version=check_jail_pkg_version


### Main ###
# TODO: add optional params
if [ ! -z "$pkg_version" ]; then
  split_version_sufix $new_version
  if [ "$version_prefix" == "$pkg_version" ]; then
    echo "This version ($verion_prefix) is already installed in the jail ($JAIL_NAME)!!!"
  else
    download_new_version
    echo -e "\n\nUpdate Port Makefile"
    update_port_makefile $version_prefix $version_sufix
    echo -e "\nTime to make the port/package ..."
    make_package
    echo -e "\nUpgrade the port inside the jail and restart PMS "
    upgrade_pkg $version_prefix
  fi
fi

Just need the server url and port path updated to match the user’s sytem.

The host needs httpie and jq installed (pkg install py37-httpie pkg install jq should do it)

This also respects the pref the user sets for “Channel” in the server, so it will get either public or beta updates regardless of how the port/path is named (that never made any difference anyway and its adds only confusion)

Maybe you can merge the 2 and use the PMS updater API part? In any case feel free to use as you please.

One of the reasons I took so long to post it here, is that honestly I was hoping we would have our own ready to install pkgs, which is still something we do want to have, but sadly the day is to small for all the things :slight_smile:

Wow, thanks. Will try to combine to use in PMS jail’s cron.

But from what I see here, it works only for PMS package without plexpass. Is there any chance to get the plexpass versions?