Is it possible to only install free software packages in Arch Linux? Or perhaps to query a package's license before installing? I suppose you could use
-Q to search for the text of a specific license, but it seems overkill.
You can do this with
expac, an alpm data tool that is in [extra]. For example, to search for Apache licensed software in the repos:
expac -Ss '%L - %n' '^Apache'
Note: expac does a full search on the target, so additional filtering may be necessary.
Ultimately, though, if you only want free software, you want Parabola Linux, which is Arch-based, but a separate distribution.