How do I custom build a homebrew package? - phantomjs

This Homebrew Cookbook manual is helpful in giving some clues on how the homebrewsystem works. I have installed PhantomJS using brew install phantomjs, but I need to apply some patches. I can see that the formula already has a patch applied:
# Qt Yosemite build fix. Upstream commit/PR:
# https://qt.gitorious.org/qt/qtbase/commit/70e442
# https://github.com/ariya/phantomjs/pull/12934
patch do
url "https://raw.githubusercontent.com/Homebrew/patches/480b7142c4e2ae07de6028f672695eb927a34875/phantomjs/yosemite.patch"
sha256 "f54bd1592185f031552d3ad5c8809ff27e8f3be4f1c05c81b59bf7dbc4a59de1"
end
What is the 'correct' way to modify the source and rebuild? I suppose I could modify the source, repackage it using tar/gz, place it in the cache folder, and then change the checksum in the formula, but is that the right way to do it?

Add your patches like the one that’s already there:
patch do
url "https://where.your.patch/is"
sha256 "... its checksum ..."
end
patch do
url "https://another.patch.url"
sha256 "... its checksum ..."
end
Make sure it’s in the stable do block like the existing patch.
Then run brew install --build-from-source phantomjs. Once it’s installed, edit the formula to its original state or your next brew update will fail.
If you know what you’re doing you can avoid adding sha256s to each patch; Homebrew will warn you it can’t verify them but won’t abort the install.

Related

nextcloud: uninstall and reinstall with occ

Nextcloud has a command-line tool, "occ".
The command occ maintenance:install will install nextcloud.
After initial install, the maintenance:install command is no longer available.
This is also reflected in the output from occ status which reports installed: true.
What I want to do now is to destroy the existing installation, and start over.
So far I always delete the docker volumes that contain nextcloud and the database, but this seems overkill.
There has to be an option to uninstall or mark the installation as uninstalled, and then reinstall.
What I found so far
I found a file config/CAN_INSTALL file which gets removed on install. But restoring this seemed to have no effect.
Setting occ config:system:set --value=false --type=boolean installed does make the system believe it is not installed, but then the occ maintenance:install will fail because there is existing data and configuration. It is not clear to me how I would wipe this.

How to get missing modules in Ocaml?

[Solved (at bottom). installed quartz and re-installed with x11 via brew then restarted machine.]
I'm learning Ocaml and am going through these documentations pages and need to install some modules (graphics).
I'm missing a Graphics module in Ocaml. After trying to load it on toplevel (the REPL right?) with:
$ ocaml
OCaml version blahblah
# #load "graphics.cma";;
# open Graphics;;
I get the error message:
Cannot find file graphics.cma.
So I wander over to this question and after not finding the file with the command:
ls `ocamlc -where`/graphics*`
I read that this means that:
Graphics is not installed and you have to reinstall OCaml compiler
enabling Graphics.
Does this mean I have to recompile Ocaml every time I need a new module? I'm not sure what he meant by that.
Then, I tried to install Graphics with: opam install graphics.
I got this error:
This package relies on external (system) dependencies that may be missing. `opam depext lablgl.1.05' may help you find the correct installation for your system.
So I did opam depext lablgl.1.05
After this, I tried opam install graphics again, but it failed with this error:
#=== ERROR while installing graphics.1.0 ======================================#
# opam-version 1.2.2
# os darwin
# command ocamlc -custom graphics.cma -o test
# path /Users/alexanderkleinhans/.opam/system/build/graphics.1.0
# compiler system (4.02.2)
# exit-code 2
# env-file /Users/alexanderkleinhans/.opam/system/build/graphics.1.0/graphics-24451-7afd23.env
# stdout-file /Users/alexanderkleinhans/.opam/system/build/graphics.1.0/graphics-24451-7afd23.out
# stderr-file /Users/alexanderkleinhans/.opam/system/build/graphics.1.0/graphics-24451-7afd23.err
### stderr ###
# File "_none_", line 1:
# Error: Cannot find file graphics.cma
=-=- Error report -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
The following actions failed
∗ install graphics 1.0
No changes have been performed
=-=- graphics.1.0 troubleshooting -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
=> This package checks whether the Graphics library was compiled.
This error says Cannot find file graphics.cma which brings me back to this question and what the steps are to get graphics.cma (and other modules as I might need them).
I though opam was a package manager for ocaml (this install modules right?)
EDIT:
I did brew info ocaml and I did install with x11 so I though this meant I should have it...
ocaml: stable 4.04.1 (bottled), devel 4.05.0+beta3, HEAD
General purpose programming language in the ML family
https://ocaml.org/
/usr/local/Cellar/ocaml/4.04.1 (1,730 files, 194.4MB) *
Poured from bottle on 2017-06-13 at 15:23:43
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/ocaml.rb
==> Requirements
Optional: x11 ✘
==> Options
--with-flambda
Install with flambda support
--with-x11
Install with the Graphics module
--devel
Install development version 4.05.0+beta3
--HEAD
Install HEAD version
EDIT 2:
Running
brew install Caskroom/cask/xquartz
brew reinstall ocaml --with-x11
Allowed me to compile, but running gave me this fatal exception. Seems to be an X11 thing?
Fatal error: exception Graphics.Graphic_failure("Cannot open display ")
Solved
So I think the two steps that were necessary were to make sure ocaml was installed with X11. Note that `brew info ocaml` seemed to give wrong information (said it was installed with X11 but reinstall was necessary). On OSX, I also needed to install quarts.
brew install Caskroom/cask/xquartz
brew reinstall ocaml --with-x11
After this I COULD compile, but got an error on execution. This was simply solved by restarting which I read was necessary after installation of xquartz.
After that I could run fine.
The graphics module is an optional part of the base OCaml install, not an external module. This explains why you can't install it using OPAM. The OPAM module that you show is only testing whether it is installed in the current OCaml system. It can't (and hence doesn't try to) install graphics as a separate module.
For this reason, installing graphics (when it's not already installed) is unusually tricky. There's no need to recompile OCaml for installing most (if not all) other modules.
For what it's worth, I am running macOS 10.12.4, and I used "opam switch" to switch my OCaml system to the 4.03.0 release. In the resulting environment, the Graphics module is installed, and I have no trouble running the examples at the website you mention. (For the first, I see concentric red and yellow circles, for example.)
You might try doing "opam switch" to switch to a recent version of the compiler, and see if this gets things going for you. In the past I have had trouble getting Graphics to work, but it is working great for me now.

error while running apt-get update probably incorrect release file causing apt-get update to fail

I've been using elementary OS 0.3 Freya (64-bit) built on Ubuntu 14.04
When I tried to open Software Updater its showing Failed to download repository information
and when I tried to run
sudo apt-get update
this is what it prints:
W: Failed to fetch http://in.archive.ubuntu.com/ubuntu/dists/trusty/Release Unable to find expected entry 'restricted/source/Sources' in Release file (Wrong sources.list entry or malformed file)
E: Some index files failed to download. They have been ignored, or old ones used instead.
I donno whats the problem and I cann't find a solution for this while I googled it.
From what I've read on the issue, one of the repositories has failed. Maybe try removing them one at a time and see if you can find the offending one.
Edit the ppa's and change freya to trusty. Not sure if this is the ideal solution, but it fixes it.
I removed Chrome download/update from the download list and changed the Ubuntu Software Settings in column 1 to Download from main server. It did the download and update this way.

rvm install fails with or without rvmrc

I'm using rvmrc with the following text:
rvm_path=/local/rvm
(on Ubuntu 11.10) but trying to install gives an obscure error:
$ bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)
Successfully checked out branch ''
Current branch master is up to date.
Successfully pulled (rebased) from origin
: No such file or directory
Any ideas?
You have no need at all to set $rvm_path. You're using a multi-user install. Please follow the explicit instructions for the Multi-User install at https://rvm.io and remove any existing installations, remove /etc/rvmrc, /etc/profile.d/rvm.sh, and $HOME/.rvmrc. Comment out any RVM sourcing lines in your .bash_profile, and .bashrc and log out of the machine then back in. Then reinstall correctly. Setting the rvm_path has never been a requirement of the installer UNLESS you already have a Multi-User working installation in place, and you want to attempt to use a per-user install with it. THEN you would preset the $rvm_path to $HOME/.rvm in your own $HOME/.rvmrc, log out then back in and then attempt the install again. BUT, that is not a supported installation type. Which is why 99.999% of users will not need to set rvm_path at all.
The real problem was that the git configuration for auto-converting line endings was not set correctly which prevented any installation from working. It had nothing to do with using rvmrc settings.
The fix for this is simple (and comes straight from the github help page):
$ git config --global core.autocrlf input
Line endings are important in linux and by forgetting that setting, everything the rvm-install script was pulling from github had \r\n endings. I made that change so long ago on my work machine, I didn't even remember it -- but it was not set on my home system.
I'll leave it up in case someone else has the same problem.

Apache is "Unable to initialize module" because of module's and PHP's API don't match after changing the PHP configuration

php -v gives this
PHP Warning: PHP Startup: memcache: Unable to initialize module
Module compiled with module API=20060613
PHP compiled with module API=20090626
These options need to match in Unknown on line 0
PHP Warning: PHP Startup: memcache: Unable to initialize module
Module compiled with module API=20060613
PHP compiled with module API=20090626
These options need to match in Unknown on line 0
bogus test name tests/
ps. i've upgraded from php 5.2 to 5.3. before this everything worked okay.
When you update the version of PHP (especially when going from version X.Y to version X.Z), you must update the PHP extensions as well.
This is because PHP extensions are developped in C, and are "close" to the internals of PHP -- which means that, if the APIs of those internals change, the extension must be re-compiled, to use the new versions.
And, between PHP 5.2 and PHP 5.3, for what I remember, there have been some modifications in the internal data-structures used by the PHP engine -- which means extensions must be re-compiled, in order to match that new version of those data-structures.
How to update your PHP extensions will depend on which system you are using.
If you are on windows, you can find the .dll for some extensions here : http://downloads.php.net/pierre/
For more informations about the different versions, you can take a look at what's said on the left-sidebar of windows.php.net.
If you are on Linux, you must either :
Check what your distribution provides
Or use the pecl command, to re-download the sources of the extensions in question, and re-compile them.
just
pecl uninstall module_name
then
pecl install module_name
Your problem is within the php5-dev package. I guess you went from php5.2 on an older linux version to php5.3. I did the same thing, and when I managed to install php 5.3 there was a conflict with php5-dev. For some reason it doesn't get upgraded to the new version. Dunno why is that and I don't care, however this makes your extension compiled with the older API version, while php ofc is with the newer api version. What I did to solve this problem was:
I removed php5-dev with
sudo apt-get remove php5-dev, then I ran sudo apt-get autoremove to get rid of the leftovers that were giving me the trouble, and after that I just installed php5-dev again.
sudo apt-get install php5-dev.
Once that was done, I removed my memcache with sudo pecl uninstall memcache and installed it again sudo pecl install memcache. Now both the module and the php had the same api version so I knew right away that I had the issue solved :)
Hope it helps.
It's possible that the modules are installed, but your PHP.ini still points to an old directory.
Check the contents of /usr/lib/php/extensions. In mine, there were two directories: no-debug-non-zts-20060613 and no-debug-non-zts-20060613. Around line 428 of your php.ini, change:
extension_dir = "/usr/local/lib/php/extensions/no-debug-non-zts-20060613"
to
extension_dir = "/usr/local/lib/php/extensions/no-debug-non-zts-20090626"
Then restart apache. This should resolve the issue.
I struggled with this issue for a long time and found out that when you run configure, just pass it the path to the correct php-config tool.
In my case, it was
./configure --with-php-config=/usr/local/zend/bin/php-config
... If you're unsure, run a locate php-config on your machine and find the right one amongst the different versions installed.
Hope this helps somebody in the future.
PS. My default php-config was set to 20090926 which is PHP 5.3. The one I manually entered as a param for ./configure was for PHP 5.4 (2010...)
I had this part enabled in my php.ini
extension=php_memcache.dll
[Memcache]
memcache.allow_failover = 1
memcache.max_failover_attempts=20
memcache.chunk_size =8192
memcache.default_port = 11211
After commenting these lines composer was installed in my windows 10
I had a similar issue after upgrading from PHP 5.5 to PHP 5.6. The phpize and php-config libraries being used to compile the phalcon extension were still the ones from PHP 5.5. I had to run the command below:
sudo apt-get install php5.6-dev
There will be a long stacktrace, the key information I saw was this:
update-alternatives: using /usr/bin/php-config5.6 to provide /usr/bin/php-config (php-config) in auto mode
update-alternatives: using /usr/bin/phpize5.6 to provide /usr/bin/phpize (phpize) in auto mode
I hope this helps someone.
Before you phpize, make sure to update your path ($PS1) to point to the new PHP! phpize uses your environment, and if you still have vestiges of your old PHP in your path or other parts of the environment, things will get hairy!
I'd the same error even after recompiling the modules.
But I solved it you just have to specify the absolute path of your phpize.
Here is the one that works with php 5.5. Download xampp 1.8.3 from here and download memcache dll from here
In my case in php.ini
[CLDbg]
extension=php_cl_dbg_5_3_VC9.dll
clport=6000
I removed Codelobster which support different PHP version, so need to update to:
[CLDbg]
;extension=php_cl_dbg_5_3_VC9.dll
;clport=6000
This problem has just happened to me and has been solved simply by increasing
memory_limit from 32 M to 64 M
You can adjust the value on the file where php.ini exists
locate php.ini
then choose the right file and search for memory_limit and after modifying it
you must reboot the apache
/etc/init.d/httpd restart
All the best.
In my case, I used lnmp to install php with version 5.4.45. But maybe because I installed php5-dev after lnmp (which I guess is not necessary if you installed lnmp), my phpize and php-config both point to older version tools than php.
I solved this by change the soft link of /etc/alternatives/phpize and /etc/alternatives/php-config to /usr/local/php/bin/phpize and /usr/local/php/bin/php-config.
Hopes this is helpful.
What worked for me was simply to do the following:
open the php.ini file.
Under the DYNAMIC EXTENSIONS heading, comment out the following line as
;extension=php_java.dll
Restarted Apache and all was fine