paru icon indicating copy to clipboard operation
paru copied to clipboard

[Feature Request] Build, Install and Update Official Arch packages from source (by only using github server)

Open J1Man opened this issue 3 years ago • 5 comments

Hi Morgan,

Thanks for Paru. It is an awesome tool. I have a feature request. Can you add the option to build, install and update official Arch packages from source? For example, something like "paru -S nano --buildfromsource" that can compile and install nano directly from source instead of using the official binary from arch repos. It should also track updates and re-build from source when there is an update. One time source install without update tracking can be a separate option. Something like "--buildfromsource-onlyonce".

I know that automating SVN access to Arch servers is forbidden. There is a workaround that can use github servers only. I wrote it below in detail because it can be automated. For example, if I currently want to build nano from source by using Paru, I do the following from my home directory:

cd ~ git clone https://github.com/archlinux/svntogit-packages.git --branch packages/nano --single-branch nano cd /nano/repos/core-x86_64 paru -Ui

note: paru complained about a missing key, so I imported it with a single command "gpg --recv-keys BFD009061E535052AD0DF2150D28D4D2A0ACE884" and ran "paru -Ui" again. But this might not happen for other packages.

With only 4 lines, I am able to build and install a package from source using Paru!! But sadly, Paru does not track the updates for it. Pacman tries to update the package when there is a new version available. I can manually update using the commands below:

cd ~ cd /nano/repos/core-x86_64 git pull paru -Ui

The git clone command only pulls the files and commits associated with the package nano when branch options are specified. When you type "git log --oneline", only nano related commits are displayed. In order to automate you can keep a json file with the names of the source installed official packages. Pacman will try to update those packages when there are updates, so you can use pacman metadata to know when you have to issue "git pull" command. You also can keep the latest commit numbers for each package in the json file if you want to track by commit. Keys have to be imported automatically if they are missing, but since these are official sources importing their keys should be safe.

Also one complimentary feature can be the option to build everything in RAM (to save hard disk life) and move the resulting files to paru cache after the build is complete. Arch linux wiki page that I linked below talks about tmpfs method. If paru can automatically copy the build folder from its cache to RAM/tmpfs before the build process, and move it back to its cache after the build, that can be a valuable HDD life extending option. Please let me know if you want me to create a separate feature request for this. I wrote it here for now. https://wiki.archlinux.org/title/makepkg#Building_from_files_in_memory

Please let me know if my feature request is acceptable. Thanks for everything.

J1Man avatar Feb 18 '22 23:02 J1Man

I'd be interested in this feature too and I'd like to help implementing it.

pvdrz avatar Mar 03 '22 19:03 pvdrz

This would be a super nice feature, if you want to build some packages with other compilers or compiler flags!

I wrote a script a long time ago which rebuilds all packages on the system (but it requires yaourt). It basically keeps track of the versions it saw the last time and rebuilds them if the installed version changed.

But this obviously means you have to fetch the binary first and then build the package from the sources... so I abandoned the idea.

Selecting just a few packages would be much better, and having paru to build them and push them into a local repository would be great!

RubenKelevra avatar Apr 17 '22 16:04 RubenKelevra

I know that automating SVN access to Arch servers is forbidden. There is a workaround that can use github servers only. I wrote it below in detail because it can be automated. For example, if I currently want to build nano from source by using Paru, I do the following from my home directory:

cd ~ git clone https://github.com/archlinux/svntogit-packages.git --branch packages/nano --single-branch nano cd /nano/repos/core-x86_64 paru -Ui

Well, paru could just fetch the regular database updates and if there's an update available for a package on his "source-build" list, it could run the "paru -G" command inside a chroot and then build it with paru -U - and put the package into a local repository afterwards.

If this repository get priority over the "official" ones by selecting the package with $repository/$packagename while running pacman -Syu it should be automatically selected over the other repos.

note: paru complained about a missing key, so I imported it with a single command "gpg --recv-keys BFD009061E535052AD0DF2150D28D4D2A0ACE884" and ran "paru -Ui" again. But this might not happen for other packages.

Paru can automatically fetch new keys btw. Look at the paru.conf :)

RubenKelevra avatar Apr 17 '22 16:04 RubenKelevra

Also one complimentary feature can be the option to build everything in RAM (to save hard disk life) and move the resulting files to paru cache after the build is complete. Arch linux wiki page that I linked below talks about tmpfs method. If paru can automatically copy the build folder from its cache to RAM/tmpfs before the build process, and move it back to its cache after the build, that can be a valuable HDD life extending option. Please let me know if you want me to create a separate feature request for this. I wrote it here for now. https://wiki.archlinux.org/title/makepkg#Building_from_files_in_memory

This might be an option for the chroot environment, we could (in theory) mount an overlay tmpfs for the writing to it, as we discard these writes afterwards anyway.

We don't have to copy the whole chroot environment to the tmpfs, as it's cached anyway in memory, and we hardly need most of the stuff.

Make a new issue for this, @J1Man. :)

RubenKelevra avatar Apr 30 '22 08:04 RubenKelevra

See #585

This can be partially implemented by adding some sort of git repo of the archlinux pkgbuilds to your paru.conf. Though paru does not track where a package is installed from and repos always take priority. This means you can paru -S myarrchpkgbuilds/git to build git, but the depends will be from the main repos and updates will be to.

You can probably write a tool on top paru to get the behaviour you want. Like the one mentioned that requires yaourt. But I don't think issue will be fully integrated as it requires things out of scope like coupling with arch's build system and tracking where packages were installed.

Morganamilo avatar Sep 03 '22 20:09 Morganamilo

Bump! Would love to see this feature implemented.

nyabinary avatar Oct 08 '22 04:10 nyabinary