Edit sources of a port before installing - macports

I have a problem with a certain port. It compiles and installs fine (port install webkit-gtk), and the actual problem occurs later (a certain symbol is not compiled into the library, but the details don't matter here).
In order to debug and fix this, I'd like to make some changes to the webkit-gtk sources before installing. With apt-get, I could do something like apt-get source packagename.
I found that I can call
sudo port fetch webkit-gtk
sudo port extract webkit-gtk
sudo port patch webkit-gtk
sudo port configure webkit-gtk
to do the individual steps of the installation. However, after I make changes to the sources I can't continue because I get error messages. I think there is a problem with permissions, as I can only edit the files as root (chowning to myself breaks the build process, and I can't su macports for some reason).
What I'd like to do is to make a few changes before the configure step, and then install the port with the changes as usual. How can I do that?

you're almost there...
sudo port uninstall webkit-gtk
sudo port clean webkit-gtk
sudo port fetch webkit-gtk
sudo port extract webkit-gtk
sudo port patch webkit-gtk
before the configure step, make your changes:
sudo su -
cd $(port work webkit-gtk)
cd $(ls -1) #usually a work directory in here
...change stuff...
exit
sudo port configure webkit-gtk
sudo port build webkit-gtk
sudo port destroot webkit-gtk
sudo port activate webkit-gtk
IDK what errors you are getting in the process, but they are probably related to the changes you made, not to the procedure. You were generally on the right track.

Related

How to fix '(38)Function not implemented: AH00141: Could not initialize random number generator' after upgrading Apache from 2.4.18 to 2.4.46?

I have a running system with Ubuntu 16.04, Apache 2.4.18, PHP 7.3 and 7.4, PHP-FPM, PHP FastCGI, MPM event.
I wanted to upgrade to the latest Apache version (2.4.46-2+ubuntu16.04.1+deb.sury.org+3 amd64 [upgradable from: 2.4.18-2ubuntu3.17]) as follows:
add-apt-repository -y ppa:ondrej/apache2
apt update
apt-get --only-upgrade install apache2
service apache2 restart
Job for apache2.service failed because the control process exited with error code. See "systemctl status apache2.service" and "journalctl -xe" for details.
journalctl -xe
apachectl[9010]: [:crit] [pid 9013] (38)Function not implemented: AH00141: Could not initialize random number generator
I checked and /dev/random and /dev/urandom are installed.
Kernel: 4.4.0-042stab141.2 and libc6: 2.23-0ubuntu11.2
Happened to me after upgrading apache to version 2.4.46 on Ubuntu as well. I found out it was the kernel version.
I knew I did apt-get upgrade and the kernel should be latest version, Also running
sudo update-grub
Showed me newer versions, but running uname -r showed very old kernel.
After a long investigation that took almost all day and trying everything I found online about upgrading Ubuntu kernel - I found out it was Digitalocean, not me. Old droplets use external managed kernel - so no matter what you do on your environment, it will always take the external kernel. The solution was here:
https://www.digitalocean.com/docs/droplets/how-to/kernel/grubloader/#switch
If you do see the drop down & change button in your droplet settings in Digital ocean control panel, then your kernel is externally managed. In that drop down type “grub” and choose GrubLoader v0.2, press “change” button & that’s it!
Now you’ll need to shut down & turn back on your server, but before you do so I suggest to run the following commands:
sudo apt-get update
sudo apt-get upgrade
The above upgrade will update the whole system. To update just kernel run the above update command followed by:
sudo apt-get upgrade linux-image-generic
Now shut down (sudo poweroff or power off from DigitalOcean interface, though doing it from CLI is preferred). Note that reboot is not sufficient in this particular case and a complete shut down is needed (Thanks #gauss256 for your comment). Then power it back on from digital ocean interface, And upon startup you should see a new kernel version.
Tip - you might want to delete old Kernel files after the reboot, this can be done by:
sudo apt-get purge $( dpkg --list | grep -P -o "linux-image-\d\S+" | grep -v $(uname -r | grep -P -o ".+\d") )

Wireguard VPN - How to fix Operation not supported if it worked before?

Trying to get up my VPN interface with sudo wg-quick down wg0;sudo wg-quick up wg0 raised:
RTNETLINK answers: Operation not supported
Unable to access interface: Protocol not supported
I am not sure what happened but the only thing I did was reboot. I did not update my packages. Still something apparently changed.
In my case there were no appropriate kernel headers installed.
First you need to know your current kernel version:
# uname --kernel-release
4.19.0-14-cloud-amd64
Important part here is "cloud-amd64" (there are several versions of "linux-headers-..." package, use apt list linux-headers-* to see what is available).
Then install appropriate kernel headers (I'm using Debian):
# apt install linux-headers-cloud-amd64
Then re-install wireguard-dkms package:
# apt install --reinstall wireguard-dkms
Reboot your OS:
# reboot
In my case (Debian 10, PiVPN) i had to:
Install linux headers:
apt-get update
apt-get install linux-image-amd64 linux-headers-amd64
reboot
apt reinstall wireguard-dkms
reboot
Running apt update / upgrade revealed that there are wireguard updates available. Install those (you might have to reboot as well) and all will work fine again.
Secure boot as the internet suggests was a false trail in my case.
solution can be simple:
set in
[Interface]
MTU = 1412
to avoid packet limitations.
Done.
You may elaborate a smaller fitting size.
In my case it was enough:
sudo apt update
sudo apt upgrade
sudo reboot

Apache disabling mpm_prefork error: The following modules depend on mpm_prefork and need to be disabled first: php7.3

I have a 8GB droplet on digitalocean. We launched our site today and we got intense traffic, we have about 3000 concurrent users.
I tried to raise the amount of concurrent connections (with the advice of apache2buddy) but the suggested MaxRequestWorkers to be 482. Here is the file:
<IfModule mpm_prefork_module>
ServerLimit 482
StartServers 5
MinSpareServers 5
MaxSpareServers 10
MaxRequestWorkers 482
MaxConnectionsPerChild 0
</IfModule>
Apache2 uses mdm_prefork and we have read that it's better if we use mdm_worker.
So i tried to disable mdm_prefork, so that I can enable mdm_worker:
a2dismod mpm_prefork
And I got the following error:
ERROR: The following modules depend on mpm_prefork and need to be disabled first: php7.3
What do I have to do to enable mpm_worker?
I found the possible solution to resolve this on my ubuntu server, dont know whether you are running ubuntu as well on your side, but I feel that the steps that I have taken will be the same for almost all distros with change in 1 step where you need to install a new package and the command for that may change based on the distro that you are using.
so the first step is
$ sudo a2dismod php7.3 mpm_prefork
This will disable the prefork module but before that it will disable the php7.3 module to stop the dependency error from occurring.
Next, we enable the worker module
$ sudo a2enmod mpm_worker
Now, the output would suggest that you restart the apache web-server. So, we do the same
$ sudo systemctl restart apache2
Now, if you go to check your website homepage, it may either throw an error or may load a blank page.
So, how do we resolve that; I scoured multiple community forums and found a solution related to the same but it was for freebsd platform so tried the same on ubuntu with some tweaks required to be made on ubuntu side for the steps to work.
The Solution based on ubuntu OS :
First of all, we enable the proxy, proxy_fcgi and setenvif module followed with a php-fpm package installation corresponding to your php version
$ sudo a2enmod proxy
$ sudo a2enmod proxy_fcgi
$ sudo a2enmod setenvif
$ sudo apt-get install php7.3-fpm -y
the php7.3-fpm installation command is the one where you may need to check the installation steps based on the Distro you are using.
Once, php-fpm service is installed you need to make sure that it gets enabled and then start it, so for that
$ sudo a2enconf php7.3-fpm
$ sudo systemctl enable php7.3-fpm.service
$ sudo systemctl start php7.3-fpm.service
Once, the php-fpm service starts successfully, just restart apache service to make sure all the made changes take effect properly
$ sudo systemctl restart apache2
After these steps are taken, please check/refresh your website homepage and the error page or the blank page will change to the proper website page.
The End-Result; your website has shifted from using prefork module to worker module to handle requests.
Also, if you want to switch to event module instead of worker module; just enable event module in place of worker module in the second step; the one that you will take after disabling php7.3 and prefork module
replace
$ sudo a2enmod mpm_worker
with
$ sudo a2enmod mpm_event
rest all steps after that remain the same irrespective of enabling worker or event module.
These steps helped me switch from prefork module to worker module on my server so hoping it may help you as well as help others who stumble on this issue.

Macports: what exactly does the -f flag mean?

Let's contrast
sudo port install [port_name]
and
sudo port -f install [port_name]
What exactly does the flag -f do in this case? Why don't we use the -f flag each time we install a new port?
On installation, the force flag is used to force activation in case a file that would be provided by the port you are installing already exists on your system. Without the force flag, MacPorts will abort the installation and warn you; with the flag, MacPorts will rename the existing file (appending .mp_$timestamp).
Forcing may become necessary if you have previously uninstalled a version of MacPorts but not cleaned up all the files it provided, or if a third-party installer built using MacPorts installed files into /opt/local (which is wrong, but still happens sometimes).
Because overwriting is not safe behavior, it isn't the default. This is also the reason why you should not always specify -f.
The flag -f is to force the install/install. If there are dependencies that is preventing macports from installing/uninstalling, you can use the -f flag to force the install/uninstall but that is not a desirable way of installing/uninstalling.
Take a look at explanation from https://guide.macports.org/
sudo port uninstall libcomerr
---> Unable to uninstall libcomerr #1.42.9_0, the following ports depend on it:
---> kerberos5 #1.11.3_0
---> subversion #1.8.9_0
---> subversion-perlbindings-5.16 #1.8.9_0
Error: port uninstall failed: Please uninstall the ports that depend on libcomerr first.
You can recursively uninstall all ports that depend on the given port before uninstalling the port itself to work around this. To do that, use the --follow-dependents flag.
$ sudo port uninstall --follow-dependents libcomerr
You can also override this safety check using the -f (force) flag.
Since this will obviously break the dependents you shouldn't do this
unless you know what you are doing.
$ sudo port -f uninstall libcomerr
Although this is an example of uninstall, you can see how -f flag works.

how to flush macports installation queue?

I wanted to install git with macports - it failed. ok. So I went with dmg - succeeded.
However, now I cannot remove git from some install queue and if I want install anything it still fetches git install command (which is failing btw).
so.. "sudo port install htop" still invokes "sudo port install git-core"
how to fix it?
htop uses a git repo. You have to install git-core first. Try this first:
sudo port clean git-core

Resources