Advertisement
Guest User

PKGBUILD to compile Wine-Staging on Arch with custom patches

a guest
Jan 4th, 2018
403
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 8.24 KB | None | 0 0
  1. # Maintainer: BieHDC <[email protected]>
  2.  
  3. pkgname=wine-staging #>FIXME: replace it for now
  4. pkgrel=1
  5.  
  6. pkgdesc="A compatibility layer for running Windows programs - Custom Staging branch"
  7. url="http://www.wine-staging.com"
  8. arch=(x86_64) #No 32-bit version here
  9. options=(staticlibs !strip) #dont strip for debug reasons
  10. license=(LGPL)
  11. conflicts=('wine' 'wine-wow64') ##FIXME: fix this if we not replace wine-staging
  12.  
  13. _depends=(
  14.   attr             lib32-attr
  15.   fontconfig       lib32-fontconfig
  16.   lcms2            lib32-lcms2
  17.   libxml2          lib32-libxml2
  18.   libxcursor       lib32-libxcursor
  19.   libxrandr        lib32-libxrandr
  20.   libxdamage       lib32-libxdamage
  21.   libxi            lib32-libxi
  22.   gettext          lib32-gettext
  23.   freetype2        lib32-freetype2
  24.   glu              lib32-glu
  25.   libsm            lib32-libsm
  26.   gcc-libs         lib32-gcc-libs
  27.   libpcap          lib32-libpcap
  28.   desktop-file-utils
  29. )
  30.  
  31. makedepends=(autoconf ncurses bison perl fontforge flex
  32.   'gcc>=4.5.0-2' #  'gcc-multilib>=4.5.0-2' merged into gcc?
  33.   giflib                lib32-giflib
  34.   libpng                lib32-libpng
  35.   gnutls                lib32-gnutls
  36.   libxinerama           lib32-libxinerama
  37.   libxcomposite         lib32-libxcomposite
  38.   libxmu                lib32-libxmu
  39.   libxxf86vm            lib32-libxxf86vm
  40.   libldap               lib32-libldap
  41.   mpg123                lib32-mpg123
  42.   openal                lib32-openal
  43.   v4l-utils             lib32-v4l-utils
  44.   alsa-lib              lib32-alsa-lib
  45.   libxcomposite         lib32-libxcomposite
  46.   mesa                  lib32-mesa
  47.   mesa-libgl            lib32-mesa-libgl
  48.   opencl-icd-loader     lib32-opencl-icd-loader
  49.   libxslt               lib32-libxslt
  50.   libpulse              lib32-libpulse
  51.   libva                 lib32-libva
  52.   gtk3                  lib32-gtk3
  53.   gst-plugins-base-libs lib32-gst-plugins-base-libs
  54.   samba
  55.   opencl-headers
  56. )
  57.  
  58. optdepends=(
  59.   giflib                lib32-giflib
  60.   libpng                lib32-libpng
  61.   libldap               lib32-libldap
  62.   gnutls                lib32-gnutls
  63.   mpg123                lib32-mpg123
  64.   openal                lib32-openal
  65.   v4l-utils             lib32-v4l-utils
  66.   libpulse              lib32-libpulse
  67.   alsa-plugins          lib32-alsa-plugins
  68.   alsa-lib              lib32-alsa-lib
  69.   libjpeg-turbo         lib32-libjpeg-turbo
  70.   libxcomposite         lib32-libxcomposite
  71.   libxinerama           lib32-libxinerama
  72.   ncurses               lib32-ncurses
  73.   opencl-icd-loader     lib32-opencl-icd-loader
  74.   libxslt               lib32-libxslt
  75.   libva                 lib32-libva
  76.   gtk3                  lib32-gtk3
  77.   gst-plugins-base-libs lib32-gst-plugins-base-libs
  78.   vulkan-icd-loader     lib32-vulkan-icd-loader
  79.   cups
  80.   samba           dosbox
  81. )
  82.  
  83. makedepends=(${makedepends[@]} ${_depends[@]})
  84.  
  85. #########################
  86. #####FUN BEGINS HERE#####
  87. #########################
  88. #If you know how to improve it or you find bugs etc. please let me know
  89. #In case of adding features, well, we can talk about it ;)
  90. #NEEDS_TESTING: rebase should also check out newer versions
  91.  
  92. #USE_MODE="preserve" #preserve custom changes
  93. USE_MODE="rebase" #make a clean build/delete changes made to the source code - Default
  94. #USE_MODE="refresh" #delete old build files, redownload wine - use this when you want the newest wine-staging version
  95.  
  96. #true/false switch, very useful between a new wine release and staging hasn't cought up yet --UNSTABLE
  97. OVERRIDE_VERSION="true"
  98. #set this to your desired version/when not in use, set this to the current version or your package reports the wrong wine version
  99. pkgver=2.21
  100.  
  101. provides=("wine=$pkgver" "wine-wow64=$pkgver") #ignore this
  102.  
  103. prepare() {
  104.     #Delete everything on refresh
  105.     if [ $USE_MODE == "refresh" ]; then
  106.         if [ -d "build_wine64" ]; then rm -Rf "build_wine64"; fi
  107.         if [ -d "build_wine32" ]; then rm -Rf "build_wine32"; fi
  108.         if [ -d "wine" ]        ; then rm -Rf "wine"        ; fi
  109.         if [ -d "wine-staging" ]; then rm -Rf "wine-staging"; fi
  110.     fi
  111.  
  112.     #Get sources for wine
  113.     if [ ! -d "wine" ]; then #refresh
  114.         git clone git://source.winehq.org/git/wine.git
  115.         cd wine
  116.         if [ $OVERRIDE_VERSION == "true" ]; then
  117.             git checkout tags/wine-$pkgver
  118.         else
  119.             git checkout tags/$(git describe --abbrev=0 --tags)
  120.             pkgver=$(git describe --abbrev=0 --tags)
  121.             pkgver=${pkgver/wine-/}
  122.         fi
  123.         cd ..
  124.     elif [ $USE_MODE == "rebase" ]; then
  125.         cd wine
  126.         git clean -fd #clean the repo
  127.         git reset --hard HEAD #Reset
  128.         git checkout master
  129.         git fetch --all #this should fix parsing new tags
  130.         if [ $OVERRIDE_VERSION == "true" ]; then
  131.             git checkout tags/wine-$pkgver
  132.         else
  133.             git checkout tags/$(git describe --abbrev=0 --tags)
  134.             pkgver=$(git describe --abbrev=0 --tags)
  135.             pkgver=${pkgver/wine-/}
  136.         fi
  137.         if [ -f "wine_staging_patched" ]; then rm wine_staging_patched; fi #we need to re-apply the patches
  138.         cd ..
  139.     else
  140.         cd wine
  141.         pkgver=$(git describe --abbrev=0 --tags)
  142.         cd ..
  143.     fi
  144.  
  145.     #Get sources for wine-staging
  146.     if [ ! -d "wine-staging" ]; then #refresh
  147.         git clone https://github.com/wine-compholio/wine-staging
  148.         cd wine-staging
  149.         if [ $OVERRIDE_VERSION == "true" ]; then
  150.             git checkout tags/v$pkgver
  151.         else
  152.             git checkout tags/$(git describe --abbrev=0 --tags)
  153.         fi
  154.         cd ..
  155.     elif [ $USE_MODE == "rebase" ]; then
  156.         cd wine-staging
  157.         git clean -fd #clean the repo
  158.         git reset --hard HEAD #Reset
  159.         git checkout master
  160.         git fetch --all #this should fix parsing new tags
  161.         if [ $OVERRIDE_VERSION == "true" ]; then
  162.             git checkout tags/v$pkgver
  163.         else
  164.             git checkout tags/$(git describe --abbrev=0 --tags)
  165.         fi
  166.         cd ..
  167.     fi
  168.  
  169.     if [ ! -f "wine/wine_staging_patched" ]; then #if the patches have not been applied
  170.         #Apply staging patches
  171.         ./wine-staging/patches/patchinstall.sh DESTDIR="wine" --all
  172.         #Set the flag that we have patched
  173.         touch "wine/wine_staging_patched"
  174.     fi
  175.  
  176.     #https://bugs.winehq.org/show_bug.cgi?id=43530
  177.     export CFLAGS="${CFLAGS/-fno-plt/}"
  178.     export LDFLAGS="${LDFLAGS/,-z,now/}"
  179.  
  180.     sed 's|OpenCL/opencl.h|CL/opencl.h|g' -i wine/configure*
  181.  
  182.     #Create build dirs if they dont exist
  183.     if [ ! -d "build_wine64" ]; then mkdir build_wine64; fi
  184.     if [ ! -d "build_wine32" ]; then mkdir build_wine32; fi
  185. }
  186.  
  187. build() {
  188.     #Apply our custom patch files
  189.     #Place patch files in the patches dir
  190.     cd ..
  191.  
  192.     #if we have reset our repo, simple clean the file
  193.     if [ $USE_MODE != "preserve" ]; then
  194.         if [ -f "patches_applied" ]; then rm patches_applied; fi
  195.     fi
  196.  
  197.     #create the file if it does not exist
  198.     if [ ! -f "patches_applied" ]; then
  199.         touch patches_applied
  200.     fi
  201.  
  202.     #load already applied patches from the file into an array
  203.     appliedPatches=()
  204.     while IFS= read -r line
  205.     do
  206.         appliedPatches+=("$line")
  207.     done < "patches_applied"
  208.  
  209.     if [ "$(ls -A patches/)" ]; then #if there are patches to apply
  210.         #compare files inside patches dir against our already applied patches
  211.         for f in patches/*
  212.         do
  213.             if [[ ! " ${appliedPatches[@]} " =~ " ${f} " ]]; then #if patch has not been applied
  214.                 echo $f
  215.                 cd src/wine/
  216.                 patch --ignore-whitespace -p1 < "$srcdir/../$f"
  217.                 cd ../../
  218.                 echo "$f" >> patches_applied #add the patch into our applied list
  219.             else
  220.                 echo Skipping $f #skip the file if already applied
  221.             fi
  222.         done
  223.     fi
  224.  
  225.     #Nothing to do for you after this line ;)
  226.     #Except you can change -j4 to the amount of processor cores you want to work eg -j7
  227.     #Apply the generated .pkg.tar file with "sudo pacman -U FILENAME.pkg.tar"
  228.  
  229.     cd src/wine
  230.     msg2 "Building Wine-64..."
  231.  
  232.     cd "$srcdir/build_wine64"
  233.     ../wine/configure \
  234.         --prefix=/usr \
  235.         --libdir=/usr/lib \
  236.         --with-x \
  237.         --with-gstreamer \
  238.         --enable-win64 \
  239.         --with-xattr
  240.  
  241.     make -j4
  242.  
  243.     export PKG_CONFIG_PATH="/usr/lib32/pkgconfig"
  244.  
  245.     msg2 "Building Wine-32..."
  246.     cd "$srcdir/build_wine32"
  247.     ../wine/configure \
  248.         --prefix=/usr \
  249.         --libdir=/usr/lib32 \
  250.         --with-x \
  251.         --with-gstreamer \
  252.         --with-xattr \
  253.         --with-wine64="../build_wine64"
  254.  
  255.     make -j4
  256. }
  257.  
  258. package() {
  259.  
  260.     msg2 "Packaging Wine-32..."
  261.  
  262.     cd "$srcdir/build_wine32"
  263.  
  264.     make prefix="$pkgdir/usr" \
  265.         libdir="$pkgdir/usr/lib32" \
  266.         dlldir="$pkgdir/usr/lib32/wine" install
  267.  
  268.     msg2 "Packaging Wine-64..."
  269.  
  270.     cd "$srcdir/build_wine64"
  271.  
  272.     make prefix="$pkgdir/usr" \
  273.         libdir="$pkgdir/usr/lib" \
  274.         dlldir="$pkgdir/usr/lib/wine" install
  275. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement