After trial & error, I have pcsx2 libretro core up and running on Ubuntu 20.04
Hopefully somebody can turn this chaos into an unofficial script.
Keep in mind that I'm rusty with retropie configs.

Okay so.. Here we go.

sudo apt remove gcc-9 g++-9 sudo apt install cmake g++-10-multilib libaio-dev libasound2-dev libcairo2-dev libegl-dev \ libegl1-mesa-dev libgdk-pixbuf2.0-dev libgirepository-1.0-1 libgl-dev libgl1-mesa-dev \ libgl1-mesa-dri libgles-dev libgles-dev libgles2-mesa-dev libglib2.0-dev libglu1-mesa-dev \ libglu1-mesa libglvnd-dev libglx-dev libglx-mesa0 libglx0 libgtk-3-dev libgtk2.0-dev \ libharfbuzz-dev libllvm10 liblzma-dev libpango1.0-dev libpcap0.8-dev libpulse-dev \ libsdl2-dev libsamplerate0-dev libsoundtouch-dev libwxgtk3.0-gtk3-0v5 libwxgtk3.0-gtk3-dev \ libx11-xcb-dev libxext-dev libxft-dev libxml2-dev portaudio19-dev zlib1g-dev ccache sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 10 sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-10 10 sudo update-alternatives --install /usr/bin/cc cc /usr/bin/gcc 30 sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++ 30 git clone https://github.com/libretro/pcsx2.git && cd pcsx2 && mkdir build && cd build cmake .. -Wno-dev cmake .. -DLIBRETRO=ON -DCMAKE_BUILD_TYPE=Release make -j$(nproc) cd ../bin

If everything goes right, there should be a "pcsx2" folder in the "bin" folder of the root folder.

Make a "lr-pcsx2" folder in "opt/retropie/libretrocores" and move the "pcsx2_libretro.so" into it.

pcsx2-libretros bios seem to be hardcoded to one spot.. otherwise segmentation fault.

Make a "pcsx2" folder in "Home/Retropie/BIOS" and move the "pcsx2" folder from the "bin" folder into it.

Yeah its weird.. the folder tree should look like:

"Home/Retropie/BIOS/pcsx2/pcsx2/bios"

And of course have all your ps2 bios files in that last folder.

Now if you have pcsx2 stand alone installed..

Go into "opt/retropie/configs/ps2" folders, otherwise make one.

Edit your "emulators.cfg" and paste this:

lr-pcsx2 = "/opt/retropie/emulators/retroarch/bin/retroarch -L /opt/retropie/libretrocores/lr-pcsx2/pcsx2_libretro.so --config /opt/retropie/configs/ps2/retroarch.cfg %ROM%"

Make a "retroarch.cfg" and paste this:

system_directory = "~/RetroPie/BIOS/pcsx2"

Now load a ps2 game, be sure to set your runcommand to "lr-pcsx2" and cross fingers.

gcc-9 will be installed whenever you update your retropie emu's.
So you have to go through the compiling procedures above any time you want to update pcsx2-libretro.
Actually after a few times it seems gcc-9 and gcc-10 are installed.

Keep in mind these are alpha builds and purely x64 so no software mode.

Edit your es_systems.cfg to accept .chd in the ps2 section.

If someone can make an unofficial script out of this. It would be appreciated.