Giter Site home page Giter Site logo

linuxify's Introduction

linuxify

Transparently transform the macOS CLI into a fresh GNU/Linux CLI experience by

  • installing missing GNU programs
  • updating outdated GNU programs
  • replacing pre-installed BSD programs with their preferred GNU implementation
  • installing other programs common among popular GNU/Linux distributions

You should review the script, but if you want to go back you can uninstall just as easily as the install.

Install

git clone https://github.com/fabiomaia/linuxify.git
cd linuxify/
./linuxify install

Uninstall

./linuxify uninstall

linuxify's People

Contributors

0xflotus avatar gregnuj avatar ivanpedersen avatar pbmartins avatar pianohacker avatar pkill37 avatar sainnhe avatar smaslennikov avatar techwizrd avatar zmilonas avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

linuxify's Issues

brew requirement

I just realized I don't check if brew is installed or do anything about it. Should I?

Script fails when installing openssh on High Sierra due to sbin folder missing

When I ran this on macOS High Sierra (MacBook Pro (Retina, 15-inch, Mid 2015)) I got the following error when it was installing openssh:

==> Downloading https://homebrew.bintray.com/bottles/openssh-7.8p1.high_sierra.bottle.tar.gz
######################################################################## 100.0%
==> Pouring openssh-7.8p1.high_sierra.bottle.tar.gz
Error: The `brew link` step did not complete successfully
The formula built, but is not symlinked into /usr/local
Could not symlink sbin/sshd
/usr/local/sbin is not writable.

You can try again using:
  brew link openssh

Per this comment it looks like Apple stopped creating the /usr/local/sbin by default.
Would it make sense to, as part of this script, create that directory first if it doesn't exist?

Deprecated options

--with-default-names and --with-gettext flags seem to have been deprecated in Homebrew and it no longer replaces the default binaries as it prefixes them with g instead, so for example /usr/bin/sed remains untouched while it installs /usr/local/bin/gsed..

I tried aliasing sed with gsed, but it is limited to the Shell, e.g it won't work with commands that skip Shells and execute binaries like xargs.

I don't know if there's a solution for this, I might just downgrade homebrew.

Thanks for the awesome library!

Option to use MacPorts (as well as other package managers)

It would be nice if this script could use MacPorts instead of Homebrew. Or other package managers, too; including Fink, Nix, pkgsrc, etc. I've found that MacPorts has a significant number of usages and areas in which it is superior to Homebrew. Other package managers are also tailored for special paradigms. It would be nice if people who use this script could use it with their preferred package manager, rather than being forced to use Homebrew.

Fails after checking if a brew installed

I'm having a weird issue, when running ./linuxify install, it immediately exits when it gets to a package that isn't installed:

 bash -x linuxify install                                                        
+ set -euo pipefail
++ sysctl -a
++ /usr/bin/awk '/machdep.cpu.brand_string/{print $2}'
+ export 'CPU_BRAND_STRING=Intel(R)'
+ CPU_BRAND_STRING='Intel(R)'
+ linuxify_formulas=("watch" "wget" "wdiff" "autoconf" "coreutils" "binutils" "diffutils" "ed" "findutils" "gawk" "gnu-indent" "gnu-sed" "gnu-tar" "gnu-which" "grep" "gzip" "screen" "bash" "emacs" "gpatch" "less" "m4" "make" "nano" "bison" "flex" "libressl" "file-formula" "git" "openssh" "perl" "python" "rsync" "unzip" "vim")
+ linuxify_main install
+ '[' 1 -eq 1 ']'
+ case $1 in
+ linuxify_install
+ linuxify_check_os
+ [[ darwin19 =~ darwin* ]]
+ linuxify_check_brew
+ command -v brew
+ linuxify_set_prefix
++ brew --prefix
+ export BREW_PREFIX=/usr/local
+ BREW_PREFIX=/usr/local
+ linuxify_check_dirs
+ result=0
+ for dir in '${BREW_PREFIX}/bin' '${BREW_PREFIX}/sbin'
+ [[ ! -d /usr/local/bin ]]
+ [[ ! -w /usr/local/bin ]]
+ for dir in '${BREW_PREFIX}/bin' '${BREW_PREFIX}/sbin'
+ [[ ! -d /usr/local/sbin ]]
+ [[ ! -w /usr/local/sbin ]]
+ return 0
+ (( i=0 ))
+ (( i<35 ))
++ brew ls --versions watch
+ INSTALLED='watch 3.3.17'
+ [[ -n watch 3.3.17 ]]
+ echo 'Found Existing watch - watch 3.3.17'
Found Existing watch - watch 3.3.17
+ (( i++  ))
+ (( i<35 ))
++ brew ls --versions wget
+ INSTALLED='wget 1.21.1'
+ [[ -n wget 1.21.1 ]]
+ echo 'Found Existing wget - wget 1.21.1'
Found Existing wget - wget 1.21.1
+ (( i++  ))
+ (( i<35 ))
++ brew ls --versions wdiff
+ INSTALLED='wdiff 1.2.2_2'
+ [[ -n wdiff 1.2.2_2 ]]
+ echo 'Found Existing wdiff - wdiff 1.2.2_2'
Found Existing wdiff - wdiff 1.2.2_2
+ (( i++  ))
+ (( i<35 ))
++ brew ls --versions autoconf
+ INSTALLED=
~/Development/linuxify master >

It just returns to the prompt, something about this test returning blank makes it bail out:


      INSTALLED=$(brew ls --versions ${linuxify_formulas[i]})
        if [[ -n $INSTALLED ]]; then
            echo "Found Existing ${linuxify_formulas[i]} - ${INSTALLED}"
        else
            echo "Installing ${linuxify_formulas[i]}"
            brew install ${linuxify_formulas[i]}
        fi


sudo

Should the script need to be run with sudo, or should the script (not run with sudo explicitly) individually ask for sudo when it really needs it?

Add help text

Add help text that is displayed if

  • No arguments are passed
  • The -h flag is passed
  • The --help flag is passed

linuxify uninstall fails because of python dependency

Tried to uninstall and got this error:

$ ./linuxify uninstall
Error: Refusing to uninstall /usr/local/Cellar/[email protected]/3.9.1_6
because it is required by cairo, gdk-pixbuf, glances, glib, gobject-introspection, graphviz, gts, harfbuzz, imagemagick, libheif, liblqr, librsvg, pango, plantuml, shared-mime-info, sphinx-doc and termtosvg, which are currently installed.
You can override this and force removal with:
  brew uninstall --ignore-dependencies python

not sure whether to follow the advice of brew or do something else?

Add option to install BusyBox utilities instead of GNU/Linux utilities

From the BusyBox About page:

BusyBox combines tiny versions of many common UNIX utilities into a single small executable. It provides replacements for most of the utilities you usually find in GNU fileutils, shellutils, etc. The utilities in BusyBox generally have fewer options than their full-featured GNU cousins; however, the options that are included provide the expected functionality and behave very much like their GNU counterparts. BusyBox provides a fairly complete environment for any small or embedded system.

BusyBox has been written with size-optimization and limited resources in mind.

It'd be nice to have an option to choose the BusyBox Homebrew formuale instead of the GNU/Linux formulae.

Consider a Brewfile ?

Love your script. Thought I'd share this too.

You can replace the linuxify_formulas and the for loop in linuxify_install with the following Brewfile:

watch
wget
wdiff --with-gettext
gdb
autoconf

# GNU programs whose BSD counterpart is installed in macOS
coreutils
binutils
diffutils
ed --with-default-names
findutils --with-default-names
gawk
gnu-indent --with-default-names
gnu-sed --with-default-names
gnu-tar --with-default-names
gnu-which --with-default-names
grep --with-default-names
gzip
screen

# GNU programs existing in macOS which are outdated
bash
emacs
gpatch
less
m4
make --with-default-names
nano
bison

# BSD programs existing in macOS which are outdated
flex

# Other common/preferred programs in GNU/Linux distributions
libressl
file-formula
git
openssh
perl
python
rsync
unzip
vim --override-system-vi

and with the following line brew install and it should pick up the Brewfile correctly

brew inconsistencies

Fix upstream

  • binutils has no caveats about ld (see #17794)
  • gawk does not allow --with-default-names and man page is useless because it is still called gawk
  • diffutils is unprefixed
  • gzip is unprefixed
  • screen is unprefixed
  • bash caveats are incomplete

Feature request - add tools gnutls gnupg gnu-getopt tree

Hi, I just installed another package from Homebrew, and I noticed that some more gnu or common linux tools are available which are not "featured" in this nice project:

######################################################################## 100.0% ==> Installing dependencies for pass: gnu-getopt, ... , tree ... ==> Installing pass dependency: gnu-getopt ==> Pouring gnu-getopt-2.36.1.catalina.bottle.tar.gz ... ==> Installing pass dependency: gnutls ==> Pouring gnutls-3.6.15.catalina.bottle.tar.gz ... ==> Installing pass dependency: gnupg ==> Pouring gnupg-2.2.27.catalina.bottle.tar.gz ... ==> Installing pass dependency: tree ==> Pouring tree-1.8.0.catalina.bottle.tar.gz

Can these be added to the scripts?

Add .linuxify.fish for Fish shell?

I tried porting the .linuxify to a script you run once with source .linuxify.fish.

set -l BREW_HOME (brew --prefix)

# Keep default manpath
echo 'set -gx MANPATH $MANPATH (cat /private/etc/manpaths | tr \'\n\' \':\')' >> "$__fish_config_dir/conf.d/linuxify.fish"

# most programs
fish_add_path --prepend "$BREW_HOME/bin"
echo 'set -gx MANPATH "'$BREW_HOME'/share/man" $MANPATH' >> "$__fish_config_dir/conf.d/linuxify.fish"
echo 'set -gx INFOPATH "'$BREW_HOME'/share/info" $INFOPATH' >> "$__fish_config_dir/conf.d/linuxify.fish"

# coreutils
fish_add_path --prepend "$BREW_HOME/opt/coreutils/libexec/gnubin"
echo 'set -gx MANPATH "'$BREW_HOME'/opt/coreutils/libexec/gnuman" $MANPATH' >> "$__fish_config_dir/conf.d/linuxify.fish"

# make
fish_add_path --prepend "$BREW_HOME/opt/make/libexec/gnubin"
echo 'set -gx MANPATH "'$BREW_HOME'/opt/make/libexec/gnuman" $MANPATH' >> "$__fish_config_dir/conf.d/linuxify.fish"

# m4
fish_add_path --prepend "$BREW_HOME/opt/m4/bin"

# file-formula
fish_add_path --prepend "$BREW_HOME/opt/file-formula/bin"

# unzip
fish_add_path --prepend "$BREW_HOME/opt/unzip/bin"

# python
fish_add_path --prepend "$BREW_HOME/opt/python/libexec/bin"

# flex
fish_add_path --prepend "$BREW_HOME/opt/flex/bin"
echo 'set -gx LDFLAGS "-L'$BREW_HOME'/opt/flex/lib"' >> "$__fish_config_dir/conf.d/linuxify.fish"
echo 'set -gx CPPFLAGS "-I'$BREW_HOME'/opt/flex/include"' >> "$__fish_config_dir/conf.d/linuxify.fish"

# bison
fish_add_path --prepend "$BREW_HOME/opt/bison/bin"
echo 'set -gx LDFLAGS "-L'$BREW_HOME'/opt/bison/lib"' >> "$__fish_config_dir/conf.d/linuxify.fish"

# libressl
fish_add_path --prepend "$BREW_HOME/opt/libressl/bin"
echo 'set -gx LDFLAGS "-L'$BREW_HOME'/opt/libressl/lib"' >> "$__fish_config_dir/conf.d/linuxify.fish"
echo 'set -gx CPPFLAGS "-I'$BREW_HOME'/opt/libressl/include"' >> "$__fish_config_dir/conf.d/linuxify.fish"
echo 'set -gx PKG_CONFIG_PATH "'$BREW_HOME'/opt/libressl/lib/pkgconfig"' >> "$__fish_config_dir/conf.d/linuxify.fish"

# ed
fish_add_path --prepend "$BREW_HOME/opt/ed/libexec/gnubin"

# findutils
fish_add_path --prepend "$BREW_HOME/opt/findutils/libexec/gnubin"
set -gx MANPATH "/opt/homebrew/opt/findutils/libexec/gnuman" $MANPATH

# gnu-indent
fish_add_path --prepend "$BREW_HOME/opt/gnu-indent/libexec/gnubin"

# gnu-sed
fish_add_path --prepend "$BREW_HOME/opt/gnu-sed/libexec/gnubin"

# gnu-tar
fish_add_path --prepend "$BREW_HOME/opt/gnu-tar/libexec/gnubin"

# gnu-which
fish_add_path --prepend "$BREW_HOME/opt/gnu-which/libexec/gnubin"

# grep
fish_add_path --prepend "$BREW_HOME/opt/grep/libexec/gnubin"

set -e BREW_HOME
  • Also, the CPPFLAGS and LDFLAGS are set several times, overwriting the previous. Is this wrong?
  • Another thing, man xargs doesn't work when MANPATH is set. I think /usr/share/man is missing. When manpath is set, the default folders are no longer checked. The file /private/etc/manpaths contains the paths to use. I added those

source ~/.linuxify

For everything to work correctly, the script adds source ~/.linuxify to ~/.bashrc. But this assumes:

  1. that the user is using bash
  2. that ~/.bashrc does not use commands that will only work after the $PATH has been patched (e.g. export MAKEFLAGS="-j$(nproc)" will fail if declared before source ~/.linuxify because nproc is not yet in the $PATH)

Should the script continue to try to add source ~/.linuxify to ~/.bashrc. like this or should the users be responsible for handling this stitching themselves?

OpenSSL rather than LibreSSL

Have you considered replacing LibreSSL with OpenSSL as part of linuxify?

I had some inconsistencies with LibreSSL making scripts that ran on linux not work on my Mac. Switching to GNU OpenSSL removed these inconsistencies. Unfortunately, I can't remember the specifics.

Looking for maintainers

I still occasionally find time to maintain this project, but could use some help. Is anyone interested in helping maintain this? Ideally your daily driver is macOS.

Duplicate entry in path

Not sure when this changed, but at least in Catalina and Mojave, the top of the /etc/paths already contains /usr/local/bin. So the first entry in the .linuxify that you source in .bashrc is unnecessary. For reference, it's this in line 2: export PATH="/usr/local/bin:$PATH".

linuxify.sh expects ~/.bashrc file

When I ran this on macOS High Sierra (MacBook Pro (Retina, 15-inch, Mid 2015)) I got an error on this line.

I didn't have a ~/.bashrc file on my system but I did have ~/.bash_profile. Should the script create the ~/.bashrc file during the install process or source to ~/.bash_profile instead?

(Side note: It might be helpful to echo what it’s about to do before running a few of the commands so that it’s easier to tell where it failed at.)

macOS Catalina

Has of Catalina, zsh is now the default shell instead of bash.

However using linuxify switches back to bash, maybe it could be on option rather than being automatic ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.