Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Homebrew integration #221

Merged
merged 31 commits into from Oct 26, 2019

Conversation

@Bl4Cc4t
Copy link
Contributor

Bl4Cc4t commented Oct 23, 2019

With Homebrew you can install stuff very easy on macOS.
Since LANraragi is kinda portable, we have to move user generated files out of /usr. By that, I mean in particular the content and public/temp folders.

To implement this, I created ifs to look out for the flag BREWMODE (you are free to change that name btw) and use the directory suited for saving these files: ~/Library/Application Support/<name>.
To fire it up, I created tools/homebrew-start/lanraragi.

You can install it via my tap by issuing the following commands:

brew tap bl4cc4t/other
brew install lanraragi --HEAD
tools/homebrew-start/lanraragi Outdated Show resolved Hide resolved
trap "kill 0" SIGINT
export BREWMODE=1
workdir=$(dirname $0)/$(dirname $(readlink $0))/..
redis-server & npm start --prefix "${workdir}"

This comment has been minimized.

Copy link
@Difegue

Difegue Oct 24, 2019

Owner

I quickly tried out Homebrew for Linux and got the following error upon running the app:

Can't locate Mojo/Base.pm in @INC (you may need to install the Mojo::Base module) (@INC contains: /home/linuxbrew/.linuxbrew/Cellar/perl/5.30.0/lib/perl5/site_perl/5.30.0/x86_64-linux-thread-multi /home/linuxbrew/.linuxbrew/Cellar/perl/5.30.0/lib/perl5/site_perl/5.30.0 /home/linuxbrew/.linuxbrew/Cellar/perl/5.30.0/lib/perl5/5.30.0/x86_64-linux-thread-multi /home/linuxbrew/.linuxbrew/Cellar/perl/5.30.0/lib/perl5/5.30.0 /home/linuxbrew/.linuxbrew/lib/perl5/site_perl/5.30.0/x86_64-linux-thread-multi /home/linuxbrew/.linuxbrew/lib/perl5/site_perl/5.30.0) at ./script/launcher.pl line 7.
BEGIN failed--compilation aborted at ./script/launcher.pl line 7.

It looks like your script does install Mojolicious properly, but since you're not using the cpanfile(well it's being used when you run my installer script later down the line) some dependencies might be missing?

I'll try this on a real Mac tomorrow as it's the true target and I'm pretty sure it'll work there, just letting you know.

This comment has been minimized.

Copy link
@Difegue

Difegue Oct 24, 2019

Owner

Also, launching Redis this way doesn't shut it down after Ctrl-C-ing out of the main app. Not sure how you could fix that(or if it's that much of a problem.)

This comment has been minimized.

Copy link
@Bl4Cc4t

Bl4Cc4t Oct 24, 2019

Author Contributor

Indeed, Linux is not the target. Although Homebrew claims to work on Linux as well, I think solving this issue could be done by opening an issue over at my tap discussing it in the issue I just opened: Bl4Cc4t/homebrew-other#1

As for redis, it gets killed just fine for me. That’s what the first line should handle.

lib/LANraragi/Model/Config.pm Outdated Show resolved Hide resolved
@Difegue

This comment has been minimized.

Copy link
Owner

Difegue commented Oct 24, 2019

This is great! Homebrew support never crossed my mind but it'll certainly motivate me to get the ChangeNotify changes merged ASAP. 🍺

Wrote a few suggestions and I'll make sure to whip out a Mac later for proper testing.

Bl4Cc4t added 2 commits Oct 24, 2019
@Bl4Cc4t

This comment has been minimized.

Copy link
Contributor Author

Bl4Cc4t commented Oct 24, 2019

I changed quite a bit, I think it is way more dynamic now and not restricted to use for Homebrew alone.

lib/LANraragi/Model/Config.pm Outdated Show resolved Hide resolved
tools/homebrew-start/lanraragi Outdated Show resolved Hide resolved
@Difegue

This comment has been minimized.

Copy link
Owner

Difegue commented Oct 25, 2019

Yep, that's good! Only needs a few minor fixes.

If you could also write a documentation page for macOS installation, that'd be perfect.

@Difegue

This comment has been minimized.

Copy link
Owner

Difegue commented Oct 25, 2019

Also, I tried installing this on a macOS machine with no previous traces of cpanm and got the following:

Working Directory: /private/tmp/lanraragi-20191025-23949-2pje0g

IPC::Cmd package installed, proceeding...

Will now check if all LRR software dependencies are met. 

Checking for Redis...
OK!
Ensure you have libarchive/libjpeg/libpng installed or this will fail!

Installing Perl modules... This might take a while.

Setting Environmental Flags for macOS
--> Working on ./tools/.
Configuring /private/tmp/lanraragi-20191025-23949-2pje0g/tools ... OK
==> Found dependencies: Image::Scale, Compress::Zlib, Logfile::Rotate, Proc::Simple
--> Working on Image::Scale
Fetching http://www.cpan.org/authors/id/A/AG/AGRUNDMA/Image-Scale-0.14.tar.gz ... OK
Configuring Image-Scale-0.14 ... OK
==> Found dependencies: Test::NoWarnings
--> Working on Test::NoWarnings
Fetching http://www.cpan.org/authors/id/A/AD/ADAMK/Test-NoWarnings-1.04.tar.gz ... OK
Configuring Test-NoWarnings-1.04 ... OK
Building Test-NoWarnings-1.04 ... ! Installing Test::NoWarnings failed. See /private/tmp/lanraragi-20191025-23949-2pje0g/.brew_home/.cpanm/work/1572004175.33900/build.log for details. Retry with --force to force install it.
! Installing the dependencies failed: Module 'Test::NoWarnings' is not installed
! Bailing out the installation for Image-Scale-0.14.
FAIL
--> Working on Compress::Zlib
Fetching http://www.cpan.org/authors/id/P/PM/PMQS/IO-Compress-2.087.tar.gz ... OK
Configuring IO-Compress-2.087 ... OK
==> Found dependencies: Compress::Raw::Zlib, Compress::Raw::Bzip2
--> Working on Compress::Raw::Zlib
Fetching http://www.cpan.org/authors/id/P/PM/PMQS/Compress-Raw-Zlib-2.087.tar.gz ... OK
Configuring Compress-Raw-Zlib-2.087 ... OK
Building Compress-Raw-Zlib-2.087 ... ! Installing Compress::Raw::Zlib failed. See /private/tmp/lanraragi-20191025-23949-2pje0g/.brew_home/.cpanm/work/1572004175.33900/build.log for details. Retry with --force to force install it.
FAIL
--> Working on Compress::Raw::Bzip2
Fetching http://www.cpan.org/authors/id/P/PM/PMQS/Compress-Raw-Bzip2-2.087.tar.gz ... OK
Configuring Compress-Raw-Bzip2-2.087 ... OK
Building Compress-Raw-Bzip2-2.087 ... ! Installing Compress::Raw::Bzip2 failed. See /private/tmp/lanraragi-20191025-23949-2pje0g/.brew_home/.cpanm/work/1572004175.33900/build.log for details. Retry with --force to force install it.
! Installing the dependencies failed: Installed version (2.084) of Compress::Raw::Bzip2 is not in range '2.087', Installed version (2.084) of Compress::Raw::Zlib is not in range '2.087'
! Bailing out the installation for IO-Compress-2.087.
FAIL
--> Working on Logfile::Rotate
Fetching http://www.cpan.org/authors/id/P/PA/PAULG/Logfile-Rotate-1.04.tar.gz ... OK
Configuring Logfile-Rotate-1.04 ... OK
Building Logfile-Rotate-1.05 ... ! Installing Logfile::Rotate failed. See /private/tmp/lanraragi-20191025-23949-2pje0g/.brew_home/.cpanm/work/1572004175.33900/build.log for details. Retry with --force to force install it.
FAIL
--> Working on Proc::Simple
Fetching http://www.cpan.org/authors/id/M/MS/MSCHILLI/Proc-Simple-1.32.tar.gz ... OK
Configuring Proc-Simple-1.32 ... OK
Building Proc-Simple-1.32 ... ! Installing Proc::Simple failed. See /private/tmp/lanraragi-20191025-23949-2pje0g/.brew_home/.cpanm/work/1572004175.33900/build.log for details. Retry with --force to force install it.
! Installing the dependencies failed: Module 'Proc::Simple' is not installed, Module 'Logfile::Rotate' is not installed, Installed version (2.084) of Compress::Zlib is not in range '2.087', Module 'Image::Scale' is not installed
! Bailing out the installation for ./tools/..
FAIL
Something went wrong while installing Perl modules - Bailing out. at ./tools/install.pl line 136.
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! lanraragi@0.6.5 lanraragi-installer: `perl ./tools/install.pl "install-full"`
npm ERR! Exit status 2
npm ERR! 
npm ERR! Failed at the lanraragi@0.6.5 lanraragi-installer script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /private/tmp/lanraragi-20191025-23949-2pje0g/.brew_home/.npm/_logs/2019-10-25T11_49_51_670Z-debug.log

HOMEBREW_VERSION: 2.1.15
ORIGIN: https://github.com/Homebrew/brew
HEAD: 2bf8015bc44878d432fb9da4f11e1d8abcef8f32
Last commit: 9 days ago
Core tap ORIGIN: https://github.com/Homebrew/homebrew-core
Core tap HEAD: ea623d4914d2e854229e007c78b39426c6698acd
Core tap last commit: 6 hours ago
HOMEBREW_PREFIX: /usr/local
HOMEBREW_CACHE: /Users/hackerman/Library/Caches/Homebrew
HOMEBREW_LOGS: /Users/hackerman/Library/Logs/Homebrew
CPU: quad-core 64-bit penryn
Homebrew Ruby: 2.6.3 => /usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/2.6.3/bin/ruby
Clang: 10.0 build 1001
Git: 2.20.1 => /Applications/Xcode102.app/Contents/Developer/usr/bin/git
Curl: 7.54.0 => /usr/bin/curl
macOS: 10.14.3-x86_64
CLT: 10.2.1.0.1.1554506761
Xcode: 10.2 => /Applications/Xcode102.app/Contents/Developer
CLT headers: 10.2.1.0.1.1554506761

HOMEBREW_CC: clang
HOMEBREW_CXX: clang++
MAKEFLAGS: -j4
CMAKE_PREFIX_PATH: /usr/local/opt/libarchive:/usr/local/opt/icu4c:/usr/local/opt/openssl:/usr/local
CMAKE_INCLUDE_PATH: /Applications/Xcode102.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/libxml2:/Applications/Xcode102.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/OpenGL.framework/Versions/Current/Headers
CMAKE_LIBRARY_PATH: /Applications/Xcode102.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/OpenGL.framework/Versions/Current/Libraries
PKG_CONFIG_PATH: /usr/local/opt/xz/lib/pkgconfig:/usr/local/opt/libarchive/lib/pkgconfig:/usr/local/opt/jpeg/lib/pkgconfig:/usr/local/opt/libpng/lib/pkgconfig:/usr/local/opt/icu4c/lib/pkgconfig:/usr/local/opt/openssl/lib/pkgconfig
PKG_CONFIG_LIBDIR: /usr/lib/pkgconfig:/usr/local/Homebrew/Library/Homebrew/os/mac/pkgconfig/10.14
HOMEBREW_GIT: git
HOMEBREW_SDKROOT: /Applications/Xcode102.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk
ACLOCAL_PATH: /usr/local/share/aclocal
PATH: /usr/local/opt/node/libexec/bin:/usr/local/Homebrew/Library/Homebrew/shims/mac/super:/usr/local/opt/pkg-config/bin:/usr/local/opt/cpanminus/bin:/usr/local/opt/xz/bin:/usr/local/opt/libarchive/bin:/usr/local/opt/jpeg/bin:/usr/local/opt/libpng/bin:/usr/local/opt/icu4c/bin:/usr/local/opt/node/bin:/usr/local/opt/openssl/bin:/usr/local/opt/perl/bin:/usr/local/opt/redis/bin:/usr/bin:/bin:/usr/sbin:/sbin
@Bl4Cc4t

This comment has been minimized.

Copy link
Contributor Author

Bl4Cc4t commented Oct 25, 2019

I am not really sure what I’m looking at tbh. Is that the output you got when running brew install lanraragi --HEAD? My output looks very different.

@Bl4Cc4t

This comment has been minimized.

Copy link
Contributor Author

Bl4Cc4t commented Oct 25, 2019

On another note, I noticed the directory ~/Library/Logs exists. Should we output the logs into that folder?
Logically, we would need yet another env var for that though. Not really sure if that’s important enough

@Difegue

This comment has been minimized.

Copy link
Owner

Difegue commented Oct 25, 2019

This is the output from the installer.pl script itself.
The brew install output is the following but it's less detailed:
https://gist.github.com/Difegue/248016ea276c651aad2b71bed2224ff3

@Difegue

This comment has been minimized.

Copy link
Owner

Difegue commented Oct 25, 2019

For the logs, the benefit of putting them in ~/Library/Logs is that they're accessible from the macOS Console.app(cf. https://developer.apple.com/documentation/os/logging?language=objc), but since there's already a dedicated log viewer in the app itself, I think it's not too important for the time being.

There's no dedicated get_log_folder subroutine so the code would need a bit of refactoring first as well.

@Bl4Cc4t

This comment has been minimized.

Copy link
Contributor Author

Bl4Cc4t commented Oct 25, 2019

Ah, so that’s interesting. It seems like I missed several packages in my formula… Oh well. It worked for me, because I already have them in my brewed perl. I’m gonna change the formula.

#221

Co-Authored-By: Difegue <sugoi@cock.li>
@Bl4Cc4t

This comment has been minimized.

Copy link
Contributor Author

Bl4Cc4t commented Oct 26, 2019

I can setup a dev VM for you if you wish to experiment on your own.

I can’t reproduce this issue, so I gladly accept your offer on that :)

@Difegue

This comment has been minimized.

Copy link
Owner

Difegue commented Oct 26, 2019

And so it is done, available through tmate by either web or ssh:

SSH: ssh MZP2EyxqKev6fX73SUBBG9cqd@nyc1.tmate.io
Web: https://tmate.io/t/MZP2EyxqKev6fX73SUBBG9cqd

The VM is provided by github so it will be up for about 6 hours. Homebrew and most devtools are preinstalled.

Bl4Cc4t added 8 commits Oct 26, 2019
…into homebrew-test
@Bl4Cc4t

This comment has been minimized.

Copy link
Contributor Author

Bl4Cc4t commented Oct 26, 2019

I found out what caused all the problems.

I think I tried installing LRR previously by using the normal method which installed all necessary modules in my brewed perl: /usr/local/Cellar/perl/5.30.0/lib/perl5/5.30.0/
After I reinstalled perl, they all disappeared and I got the same error like you did.

As it turns out, all I had to do is export PERL5LIB=<prefix>/libexec/lib/perl5 and then pass cpanm the option -l <prefix>/libexec. That essentially fixed the whole situation.
No need to include all modules in the formula like I did before, the modules get installed by tools/install.pl like they should.

I’m pretty happy that this is now fixed, it bugged me quite a bit!


# create path if it does not exist yet
mkdir -p ${_LRR_DATA_DIRECTORY}/log

export LRR_DATA_DIRECTORY="${_LRR_DATA_DIRECTORY}"
export PERL5LIB="${workdir}/libexec/lib/perl5"

This comment has been minimized.

Copy link
@Bl4Cc4t

Bl4Cc4t Oct 26, 2019

Author Contributor

this tells perl to look for modules in the directory we install stuff to.

$suff = " -l " . $ENV{HOMEBREW_FORMULA_PREFIX} . "/libexec";
}
if ( system($pre . "cpanm --installdeps ./tools/. --notest") != 0 ) {
if ( system($pre . "cpanm --installdeps ./tools/. --notest" . $suff) != 0 ) {
Comment on lines 135 to 137

This comment has been minimized.

Copy link
@Bl4Cc4t

Bl4Cc4t Oct 26, 2019

Author Contributor

This tells cpanm to install everything to the correct location.
The formula performed this before and did put them in the correct spot.

@@ -160,7 +160,7 @@ loglevel notice
# Specify the log file name. Also the empty string can be used to force
# Redis to log on the standard output. Note that if you use standard
# output for logging but daemonize, logs will be sent to /dev/null
logfile <LRR_DATA_DIRECTORY>/log/redis.log
logfile "<LRR_DATA_DIRECTORY>/log/redis.log"

This comment has been minimized.

Copy link
@Bl4Cc4t

Bl4Cc4t Oct 26, 2019

Author Contributor

As for the log situation, redis had problems with the path since it contained whitespace (Application Support). It works when quoted, so we don’t have to escape anything :)

tools/install.pl Show resolved Hide resolved
@Difegue

This comment has been minimized.

Copy link
Owner

Difegue commented Oct 26, 2019

Great stuff! I thought it was a bit odd you had to manually install packages instead of using the installer -- It'd mean much more work on your end to support eventual dependency changes/updates down the line.
Glad you won't have to do that. 😁

One last question from me and I think this is good for merging.

tools/homebrew-start/lanraragi Outdated Show resolved Hide resolved
@Bl4Cc4t

This comment has been minimized.

Copy link
Contributor Author

Bl4Cc4t commented Oct 26, 2019

Yeah… At some point while fixing these issues, I ran into the requirement chain of these modules. At first I thought I just missed like 2 more or something, but then I realized it wanted me to add all modules required by the modules required for LRR.

And that got me thinking :D

Bl4Cc4t and others added 2 commits Oct 26, 2019
Co-Authored-By: Difegue <sugoi@cock.li>
tools/homebrew-start/lanraragi Outdated Show resolved Hide resolved
Co-Authored-By: Difegue <sugoi@cock.li>
@Difegue

This comment has been minimized.

Copy link
Owner

Difegue commented Oct 26, 2019

Well that was quite the ordeal, but I think it's all good to go now. Thank you very much! 👍🎊

(don't forget https://tvc-16.science/hacktoberfest-lrr.html too if you're interested.)

@Difegue Difegue merged commit a7fd4f0 into Difegue:changenotify-test Oct 26, 2019
2 checks passed
2 checks passed
Run Test Suite and Perl Critic
Details
Run Test Suite and Perl Critic
Details
@CirnoT

This comment has been minimized.

Copy link
Contributor

CirnoT commented Oct 29, 2019

LRR should host its own fork of https://github.com/Bl4Cc4t/homebrew-other if it wishes to integrate into Homebrew, as the repository is outside of LRR reach and may disappear at any moment or be modified in any way that may not represent proper LRR usage or break user's installations on purpose. Additionally, right now it is using 'dev' branch which should be strictly and openly communicated in documentation.

What's proposed way to update such installation whilst keeping user data in Redis? The documentation is mute on that issue and considering rapid development LRR now sees it's important to keep it up to date with changes.

@Bl4Cc4t

This comment has been minimized.

Copy link
Contributor Author

Bl4Cc4t commented Oct 29, 2019

LRR should host its own fork of https://github.com/Bl4Cc4t/homebrew-other if it wishes to integrate into Homebrew, as the repository is outside of LRR reach and may disappear at any moment or be modified in any way that may not represent proper LRR usage or break user's installations on purpose. Additionally, right now it is using 'dev' branch which should be strictly and openly communicated in documentation.

I don’t really see these huge problems you seem to notice. I can assure you that it is in fact impossible to harm your computer when using Homebrew to install something. Homebrew restricts the install scripts (“formulae”) to not go outside of the installation sandbox.

The purpose of the current host on my private tap is to get it to work right. The final step is of course to create a PR to include it in the main tap, over at Homebrew/homebrew-core.
Btw, for them to accept that PR, we have to provide a stable working release of LRR first.
HEAD only formulae get rejected.

We are using the dev branch, because LRR required us to change quite a bit to accustom certain behaviors on actual installed programs; LRR in its current state is “portable”. That means we have to move user generated files out of the installation path.
However, if these changes get merged into master, the branch in the formula will also change — I don’t really get your point here.

What's proposed way to update such installation whilst keeping user data in Redis? The documentation is mute on that issue and considering rapid development LRR now sees it's important to keep it up to date with changes.

This is a good idea, I did in fact not think of this. I can add that to the macOS documentation!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.