You are not logged in.

#1 2023-02-25 13:31:14

Lone_Gunman
Member
Registered: 2010-02-17
Posts: 18

Help with modifying PKGBUILD

Hello all,

I need to modify an existing PKGBUILD from AUR but I'm a total noob and I'm stuck.

I have 2 reasons :
- I need to apply a patch to the AUR build version
- I need to insert 2 extra files as build includes

I managed to insert the patch command into the PKGBUILD prepare section and it works fine :

# Maintainer: Jacqueline Fisher <weretiger95@gmail.com>
# Maintainer: Justin Jagieniak <justin@jagieniak.net>
# Contributor: Nicky D

pkgname=firestorm
pkgver=6.6.8
pkgrel=1
pkgdesc="An open source viewer for accessing virtual worlds"
arch=('i686' 'x86_64')
url=https://www.firestormviewer.org
license=('LGPL')
depends=(apr-util dbus-glib gconf glu gtk2 lib32-libidn lib32-libsndfile lib32-util-linux lib32-zlib libgl libidn libjpeg-turbo libpng libxss libxml2 mesa nss openal sdl vlc zlib 'libcrypt.so=1')
optdepends=(
  'alsa-lib: for ALSA support'
  'pepper-flash: for inworld Flash support'
  'freealut: for OpenAL support'
  'lib32-libidn11: for voice support'
  'libpulse: for PulseAudio support'
  'mesa-libgl: For Intel, Radeon, Nouveau support'
  'nvidia-libgl: for NVIDIA support'
  'nvidia-utils: for NVIDIA support')
makedepends=('cmake' 'gcc' 'make' 'python-virtualenv' 'python-pip' 'git' 'boost' 'xz')
conflicts=('firestorm-bin' 'firestorm-nightly' 'firestorm-beta-bin')
provides=('firestorm')
#options=(debug !strip)

source=("$pkgname"::"git+https://vcs.firestormviewer.org/phoenix-firestorm#branch=Firestorm_$pkgver" "fs-build-variables"::'git+https://vcs.firestormviewer.org/fs-build-variables' 'firestorm.desktop' 'firestorm.launcher' 'glx.diff')
md5sums=('SKIP' 'SKIP' '5e3dade65948533ff8412da776029179' '3daa9e24492337e62bcac318df4ab370')

pkgver() {
	cat $(find "$srcdir/$pkgname/indra/newview/" -type f -iname viewer_version.txt)
}

prepare() {
	export AUTOBUILD_VARIABLES_FILE="$srcdir/fs-build-variables/variables"
	cd "$pkgname"
	patch --forward --strip=1 --input="${srcdir}/glx.diff"
	virtualenv ".venv" -p python3
	source .venv/bin/activate
	pip3 install git+https://vcs.firestormviewer.org/autobuild-3.0
	pip3 install llbase
	export CXXFLAGS="$CXXFLAGS -Wno-error"
	export CFLAGS="$CFLAGS -Wno-error"
	autobuild configure -A 64 -c ReleaseFS_open -- -DLL_TESTS:BOOL=FALSE -DREVISION_FROM_VCS=ON -DPACKAGE:BOOL=Off --chan="ArchLinux"
}

build() {
	cd "$srcdir/$pkgname"
	source .venv/bin/activate
	cd "$srcdir/$pkgname/build-linux-x86_64"
	export CXXFLAGS="$CXXFLAGS -Wno-error"
	export CFLAGS="$CFLAGS -Wno-error"
	make
}

package() {
	mkdir -p "$pkgdir/opt/firestorm"
	mkdir -p "$pkgdir/usr/share/applications"
	
	cp -rT "$pkgname/build-linux-x86_64/newview/packaged" "$pkgdir/opt/firestorm"

	install -Dm644 "firestorm.desktop" "$pkgdir/usr/share/applications/firestorm.desktop"
	install -Dm755 "firestorm.launcher" "$pkgdir/usr/bin/firestorm"
}
md5sums=('SKIP'
         'SKIP'
         '5e3dade65948533ff8412da776029179'
         '3daa9e24492337e62bcac318df4ab370'
         '2b1ee4dcd2dee1938dd659c9d890a740')

Good, but now compiling fails because I need 2 GL headers files as includes, and I don't know how to do that from within the PKGBUILD.
Files are glext.h and glxext.h from https://registry.khronos.org/OpenGL/index_gl.php

I tried to use :

prepare() {
	...
        autobuild install --local GL-linux-20230224.tar.bz2
	autobuild configure -A 64 -c ReleaseFS_open -- -DLL_TESTS:BOOL=FALSE -DREVISION_FROM_VCS=ON -DPACKAGE:BOOL=Off --chan="ArchLinux"
}

with a tarball I made of the 2 files, but it crashes saying
ERROR: Incompatible archive name 'GL-linux-20230224.tar.bz2' lacks some components

I'm really new to packaging, can someone help me ?

Offline

#2 2023-02-25 14:21:43

loqs
Member
Registered: 2014-03-06
Posts: 17,372

Re: Help with modifying PKGBUILD

What does the patch do?  Please include a copy of it or a link to it.

Offline

#3 2023-02-25 15:04:14

Lone_Gunman
Member
Registered: 2010-02-17
Posts: 18

Re: Help with modifying PKGBUILD

---
 indra/llrender/llgl.cpp | 45 ++++++++++++++++++++++++++++++++++-------
 indra/llrender/llgl.h   |  1 +
 2 files changed, 39 insertions(+), 7 deletions(-)
 
diff --git a/indra/llrender/llgl.cpp b/indra/llrender/llgl.cpp
index 36f1f86853..15b7928064 100644
--- a/indra/llrender/llgl.cpp
+++ b/indra/llrender/llgl.cpp
@@ -411,6 +411,7 @@ LLGLManager::LLGLManager() :
    mHasATIMemInfo(FALSE),
    mHasAMDAssociations(FALSE),
    mHasNVXMemInfo(FALSE),
+   mHasMesaQuery(FALSE),
    mNumTextureUnits(1),
    mHasMipMapGeneration(FALSE),
    mHasCompressedTextures(FALSE),
@@ -670,15 +671,21 @@ bool LLGLManager::initGL()
    }
 #endif
 
-   if (mHasATIMemInfo && mVRAM == 0)
-   { //ask the gl how much vram is free at startup and attempt to use no more than half of that
-       S32 meminfo[4];
-       glGetIntegerv(GL_TEXTURE_FREE_MEMORY_ATI, meminfo);
-
-       mVRAM = meminfo[0] / 1024;
-       LL_WARNS("RenderInit") << "VRAM Detected (ATIMemInfo):" << mVRAM << LL_ENDL;
+#if LL_LINUX
+   if (mHasMesaQuery && mVRAM == 0)
+   { 
+       //Mesa graphics library is one of the dominant OpenGL implementations for Linux.
+       //It provides accelerated graphics driver for several graphics hardware vendors,
+       //including Intel and AMD, which makes it a popular choice
+       unsigned int mesa_video_memory;
+       glXQueryCurrentRendererIntegerMESA(GLX_RENDERER_VIDEO_MEMORY_MESA, &mesa_video_memory);
+       //According to spec, Mesa extension returns number of megabytes
+       mVRAM = mesa_video_memory;
+       LL_WARNS("RenderInit") << "VRAM Detected (MESA_query_renderer):" << mVRAM << LL_ENDL;
    }
+#endif
 
+   //Try GL_NVX_gpu_memory_info fist, as more drivers support it
    if (mHasNVXMemInfo && mVRAM == 0)
    {
        S32 dedicated_memory;
@@ -686,6 +693,15 @@ bool LLGLManager::initGL()
        mVRAM = dedicated_memory/1024;
        LL_WARNS("RenderInit") << "VRAM Detected (NVXMemInfo):" << mVRAM << LL_ENDL;
    }
+   
+   if (mHasATIMemInfo && mVRAM == 0)
+   { //ask the gl how much vram is free at startup and attempt to use no more than half of that
+       S32 meminfo[4];
+       glGetIntegerv(GL_TEXTURE_FREE_MEMORY_ATI, meminfo);
+
+       mVRAM = meminfo[0] / 1024;
+       LL_WARNS("RenderInit") << "VRAM Detected (ATIMemInfo):" << mVRAM << LL_ENDL;
+   }
 
 #if LL_WINDOWS
    if (mVRAM < 256)
@@ -1124,6 +1140,21 @@ void LLGLManager::initExtensions()
        if (strchr(blacklist,'u')) mHasDepthClamp = FALSE;
        
    }
+
+   
+   //UGLY: There should be a better way to add this.
+   //Things you need: 1. Check that we're actually running on X11
+   //                 2. A handler for X11 Display
+   //                 3. An number of X11 screen
+   if (getenv("DISPLAY"))
+   {
+       Display* disp = XOpenDisplay(0);
+       const char* glx_extensions = glXQueryExtensionsString(disp, 0); //No real screen detection :(
+       mHasMesaQuery = ExtensionExists("GLX_MESA_query_renderer", glx_extensions);
+       //Be nice and close connection
+       XCloseDisplay(disp);
+   }
+
 #endif // LL_LINUX
    
    if (!mHasMultitexture)
diff --git a/indra/llrender/llgl.h b/indra/llrender/llgl.h
index d2e27d2e00..e98edfde56 100644
--- a/indra/llrender/llgl.h
+++ b/indra/llrender/llgl.h
@@ -91,6 +91,7 @@ public:
    BOOL mHasATIMemInfo;
    BOOL mHasAMDAssociations;
    BOOL mHasNVXMemInfo;
+   BOOL mHasMesaQuery;
    S32  mNumTextureUnits;
    BOOL mHasMipMapGeneration;
    BOOL mHasCompressedTextures;
-- 
2.39.1

Patch applies very well, but needs more recent GL extensions

Offline

#4 2023-02-25 17:30:03

loqs
Member
Registered: 2014-03-06
Posts: 17,372

Re: Help with modifying PKGBUILD

[ 28%] Building CXX object llrender/CMakeFiles/llrender.dir/llglcommonfunc.cpp.o
/build/firestorm/src/firestorm/indra/llrender/llgl.cpp: In member function ‘bool LLGLManager::initGL()’:
/build/firestorm/src/firestorm/indra/llrender/llgl.cpp:681:43: error: ‘GLX_RENDERER_VIDEO_MEMORY_MESA’ was not declared in this scope
  681 |        glXQueryCurrentRendererIntegerMESA(GLX_RENDERER_VIDEO_MEMORY_MESA, &mesa_video_memory);
      |                                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/build/firestorm/src/firestorm/indra/llrender/llgl.cpp:681:8: error: ‘glXQueryCurrentRendererIntegerMESA’ was not declared in this scope
  681 |        glXQueryCurrentRendererIntegerMESA(GLX_RENDERER_VIDEO_MEMORY_MESA, &mesa_video_memory);
      |        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
make[2]: *** [llrender/CMakeFiles/llrender.dir/build.make:160: llrender/CMakeFiles/llrender.dir/llgl.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
/build/firestorm/src/firestorm/indra/llrender/llimagegl.cpp: In member function ‘BOOL LLImageGL::setImage(const U8*, BOOL, S32)’:
/build/firestorm/src/firestorm/indra/llrender/llimagegl.cpp:872:74: warning: pointer ‘cur_mip_data’ used after ‘void operator delete [](void*)’ [-Wuse-after-free]
  872 |                                                                 delete[] cur_mip_data;
      |                                                                          ^~~~~~~~~~~~
/build/firestorm/src/firestorm/indra/llrender/llimagegl.cpp:870:74: note: call to ‘void operator delete [](void*)’ here
  870 |                                                                 delete[] prev_mip_data;
      |                                                                          ^~~~~~~~~~~~~
make[1]: *** [CMakeFiles/Makefile2:1077: llrender/CMakeFiles/llrender.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....

Why not disable the use of vendored packages and  package the dependencies that are not currently packaged?  So you would be using the system libglvnd which has the required definitions.

Last edited by loqs (2023-02-25 17:30:26)

Offline

#5 2023-02-25 18:24:48

Lone_Gunman
Member
Registered: 2010-02-17
Posts: 18

Re: Help with modifying PKGBUILD

As I said, I'm a total newbie at this. I don't know how to disable "vendored package" or to package dependencies...

Apparently, the  "glXQueryCurrentRendererIntegerMESA" Error means I need to provide these two header files glext.h and glxext.h as includes

I wish I knew how to package these 2 files correctly and tell PKGBUILD the way to use them, but if there's a better way I'm all ears smile

Offline

#6 2023-02-25 23:45:14

loqs
Member
Registered: 2014-03-06
Posts: 17,372

Re: Help with modifying PKGBUILD

The error message you encountered seems to be due to the archive lacking autobuild-package.xml.  I tired using http://3p.firestormviewer.org/glext-68- … 54.tar.bz2 that then produced:

[notice] To update, run: pip install --upgrade pip
Using --local with no package names listed installs only those local packages
Using --local install flags any resulting package as 'dirty'
Traceback (most recent call last):
  File "/build/firestorm/src/firestorm/.venv/bin/autobuild", line 8, in <module>
    sys.exit(main())
  File "/build/firestorm/src/firestorm/.venv/lib/python3.10/site-packages/autobuild/autobuild_main.py", line 255, in main
    sys.exit(Autobuild().main(sys.argv[1:]))
  File "/build/firestorm/src/firestorm/.venv/lib/python3.10/site-packages/autobuild/autobuild_main.py", line 237, in main
    tool_to_run.run(args)
  File "/build/firestorm/src/firestorm/.venv/lib/python3.10/site-packages/autobuild/autobuild_tool_install.py", line 957, in run
    install_packages(args, bconfig, install_dir, platform, args.package)
  File "/build/firestorm/src/firestorm/.venv/lib/python3.10/site-packages/autobuild/autobuild_tool_install.py", line 799, in install_packages
    packages = do_install(packages, config_file, installed, platform, install_dir,
  File "/build/firestorm/src/firestorm/.venv/lib/python3.10/site-packages/autobuild/autobuild_tool_install.py", line 382, in do_install
    if _install_local(pname, platform, package, local_archives[pname], install_dir, installed, dry_run):
  File "/build/firestorm/src/firestorm/.venv/lib/python3.10/site-packages/autobuild/autobuild_tool_install.py", line 407, in _install_local
    _update_installed_package_files(metadata, installed_package,
  File "/build/firestorm/src/firestorm/.venv/lib/python3.10/site-packages/autobuild/autobuild_tool_install.py", line 689, in _update_installed_package_files
    installed_package.archive = installed_platform.archive
AttributeError: 'NoneType' object has no attribute 'archive'

So far I have only found this awful hack

...
	autobuild configure -A 64 -c ReleaseFS_open -- -DLL_TESTS:BOOL=FALSE -DREVISION_FROM_VCS=ON -DPACKAGE:BOOL=Off --chan="ArchLinux"
	rm build-linux-x86_64/packages/include/GL/{wgl,glx,gl}ext.h

Build tested only.

Offline

Board footer

Powered by FluxBB