# Description: awesome window manager # URL: https://awesomewm.org/ # Maintainer: Cory Burgett, cmburget at gmail dot com # Depends on: cmake lua51 lua-lgi imlib2 cairo pango imagemagick libev xorg-libx11 xorg-xorgproto libxkbcommon xorg-libxcb xorg-xcb-proto xorg-xcb-util xorg-xcb-util-cursor xorg-xcb-util-keysyms xorg-xcb-util-wm xorg-xcb-util-renderutil xorg-xcb-util-image xorg-xcb-util-xrm libxdg-basedir dbus xmessage startup-notification docbook-xsl docbook-xml xmlto asciidoctor # Optional: luajit name=awesome version=4.3 release=2 source=(https://github.com/awesomeWM/awesome-releases/raw/master/$name-$version.tar.xz) # verify that the detected values for the lua configuration are # indeed valid--files exist and release version is formatted as # expected. # luafound_p() { stat -L "$LUABIN" >/dev/null && which "$LUACMD" || return 1 stat -L "$LUALIB" >/dev/null || return 1 stat -L "$LUAINC" >/dev/null || return 1 grep -Eq -e '^[0-9]+.[0-9]+.[0-9]+$' <<<"$LUAREL" || { echo "Pkgfile: unexpected format for Lua release version in lua.h: '$LUAREL'" >&2 return 1 } return 0 } # cmake has some module, "FindLua", that does all this, but shittily. # awesome did not used to use it, but it does now. as far as I can # tell, the module gives us very little control over the detection # process, and no chance to override the detected shit. so. I've # duplicated the functionality below (in about a fifth as many lines # of shell script as it takes to produce the functionality in cmake's # sorry excuse for a language). it takes advantage of pkginfo to # locate installed files, but that's more for the sake of playing nice # with CRUX's package system than anything else. it'd still be one # (or *maybe* two--for readability) lines to find the files without # pkginfo's help. # # anyway, the function will find the values and leave them in some # variables, the same way cmake's FindLua module would. I find that # pretty ugly, but I reckon the 1-to-1 correspondence better illustrates # just how shit cmake is in comparison. # cmake_sux() { local prt="${1:-lua}" LUAFND=FALSE LUABIN="/$(pkginfo -l $prt |grep -m1 -e 'bin/lua')" LUACMD="${LUABIN##*/}" LUALIB="/$(pkginfo -l $prt |grep -m1 -e '/liblua.*\.so')" LUALIB="$(eval printf '%s\\n' "${LUALIB%.so*}.so*" |sed '1p;d')" LUAINC="/$(pkginfo -l $prt |grep -e '/lua\.h$')" LUAINC="${LUAINC%/*}" LUAREL="$( printf '#include "lua.h"\nLUA_RELEASE\n' \ | cpp -I "$LUAINC" - \ | sed -nre '$s/[^0-9.]//gp' \ )" LUAPAT=${LUAREL##*.} LUAVER=${LUAREL%.*} LUAMAJ=${LUAVER%.*} LUAMIN=${LUAVER#*.} luafound_p && { LUAFND=TRUE return 0 } return 1 } build() { local i XMLPATH cd $name-$version # make sure xmlto/xsltproc can find the proper schemata and stylesheets # for processing the docbook output (from asciidoc) into manpages. # without being directed explicitly to the searchpath, the tool (I'm not # even sure which one, be it xmlto or xsltproc) will try and fail to # fetch docbook schemata and/or stylesheets from the network. it does # not matter whether or not those resources are actually reachable over # the network. it will fail regardless. and then the build will also # fail. so. cmake -> make -> asciidoc -> xmlto -> xsltproc -> ERROR. # what a fucking nightmare. # manpages aren't that hard to write, y'all. not much harder than # asciidoc! really! (see, e.g., groff_mdoc(7) or the mandoc homepage). # does anyone seriously think this is not absolutely insane? # XMLPATH="/$(pkginfo -l docbook-xsl |grep -e '/manpages/$')" XMLPATH="${XMLPATH%/}:/$(pkginfo -l docbook-xml |grep -e '/xml-dtd-4.5/$')" XMLPATH="${XMLPATH%/}" sed -e \ "$(printf '%s' 's@' \ '^\(\s*COMMAND ${XMLTO_EXECUTABLE}\) \(man ${xmlfile}\)' \ '@' \ '\1 --searchpath "'"$XMLPATH"'" \2' \ '@')" \ -i CMakeLists.txt # don't bother building i15d manpages; used to `rm` them later, # but it's better this way... maybe... # sed -re 's/^(\s*set\(AWE_MAN_LANGS\s+)[^)]+\)$/\1default)/' \ -i CMakeLists.txt # we depend on lua51 because it's official lua, but awesome also supports # building with lua52 (last I checked), and luajit functions as a drop-in # replacement for lua51 by design, with considerably better performance. # so, if luajit is installed, we'll prefer it instead, despite what our # deps list says. we'll also fall back to lua52 if it's installed but # lua51 is not, and give it a try. currently, the unqualified lua port is # lua53, which is definitely *not* supported by awesome at this time--it # won't even finish building successfully for all the linker errors. # # cf. cmake_sux() definition above, and the comments there. # for i in luajit lua51 lua52; do cmake_sux $i && break done # we've already done the work of FindLua and we're removing it, but to play # nice we'll replace it with a cmake log message that looks like the one # FindLua would've spat out if it was successful. # sed -e '/include(FindLua)/c \ include(FindPackageMessage)\ if (LUA_FOUND)\ find_package_message(Lua\ "Found Lua: ${LUA_LIBRARIES} (found version ${LUA_VERSION_STRING}) "\ "[${LUA_LIBRARIES}][${LUA_INCLUDE_DIR}][${LUA_VERSION_STRING}][${LUA_VERSION_MAJOR}][${LUA_VERSION_MINOR}][${LUA_VERSION_PATCH}]")\ endif() ' -i awesomeConfig.cmake # now we edit a bunch of scripts and shit that just assume the lua # interpreter executable is named simply `lua`, and this is of course # hard-coded with no override. well. `sed` is an override of sorts... # for i in CMakeLists.txt *.cmake; do sed -re 's@^(\s*COMMAND\s*) lua @\1 '"$LUACMD"' @' -i $i sed -re 's@^(\s*)lua @\1'"$LUACMD"' @' -i $i done # okay, now we can finally try to build this fucker. fingers crossed. # mkdir build && cd build # GCC 10 changed the default to -fno-common -- this breaks the build: CFLAGS="$CFLAGS -fcommon" \ cmake .. \ -DCMAKE_BUILD_TYPE=RELEASE \ -DCMAKE_INSTALL_PREFIX=/usr \ -DSYSCONFDIR=/etc \ -DLUA_FOUND=$LUAFND \ -DLUA_LIBRARIES="$LUALIB" \ -DLUA_INCLUDE_DIR="$LUAINC" \ -DLUA_VERSION_STRING="$LUAREL" \ -DLUA_VERSION_MAJOR=$LUAMAJ \ -DLUA_VERSION_MINOR=$LUAMIN \ -DLUA_VERSION_PATCH=$LUAPAT make make DESTDIR=$PKG install # clean up, per CRUX packaging guidelines # rm -rf $PKG/usr/share/doc rm $PKG/usr/share/awesome/themes/default/README }