How to build a package from source on manjaro?

pacman -S whatever pertains to the sync database, or all packages. The db is located at /var/lib/pacman/sync. If you use pacman -Fx to search for a file in the packages, the *.files are stored in this location too (pacman -Fy to update).

pacman -Q whatever refers to the local database. The db is located at /var/lib/pacman/local. This is everything that is installed on the system via pacman.

When you sync and update, the archived/compressed packages are stored at /var/cache/pacman/pkg. You can control how many versions of a package you want to keep. This is necessary in case you need to refer to an earlier version.

Check systemd timers (systemctl list-timers) for two timers, one related to cleaning cache and the other for updating the mirrors.

Related config files: /etc/pacman.conf, /etc/pamac.conf, /etc/pacman.d/mirrorlist.

You need to run pacman-mirrors at least once with -c or --geoip to create your custom mirrorlist. Related files are located at /var/lib/pacman-mirrors/.

You need to run DIFFPROG=meld pacdiff after an update to check for new config files. I use meld for comparisons.

I normally use pacman, but I currently use pamac GUI to build a package from AUR. Check pamac Preferences for AUR support options.