Skip to content

Instantly share code, notes, and snippets.

@Wolfer
Last active December 21, 2015 00:49
Show Gist options
  • Save Wolfer/6223586 to your computer and use it in GitHub Desktop.
Save Wolfer/6223586 to your computer and use it in GitHub Desktop.
* Package: net-misc/netkit-telnetd-0.17-r10
* Repository: gentoo
* Maintainer: maintainer-needed@gentoo.org
* USE: abi_x86_32 cdistro_CLD cdistro_desktop elibc_glibc kernel_linux userland_GNU x86
* FEATURES: preserve-libs sandbox usersandbox
>>> Unpacking source...
>>> Unpacking netkit-telnet-0.17.tar.gz to /var/tmp/portage/net-misc/netkit-telnetd-0.17-r10/work
>>> Unpacking netkit-telnet_0.17-36.diff.gz to /var/tmp/portage/net-misc/netkit-telnetd-0.17-r10/work
* Applying netkit-telnet_0.17-36.diff ... [ ok ]
* Applying netkit-telnetd-0.17-cflags-gnu_source.patch ... [ ok ]
>>> Source unpacked in /var/tmp/portage/net-misc/netkit-telnetd-0.17-r10/work
>>> Compiling source in /var/tmp/portage/net-misc/netkit-telnetd-0.17-r10/work/netkit-telnet-0.17 ...
Directories: /usr/bin /usr/sbin /usr/man
Looking for a C compiler... gcc
Checking if gcc accepts gcc warnings... yes
Looking for a C++ compiler... g++
Checking if g++ accepts gcc warnings... yes
Checking if gcc accepts -O2... yes
Checking if g++ accepts -O2... yes
Checking if g++ accepts -fno-rtti... yes
Checking if g++ accepts -fno-exceptions... yes
Checking for BSD signal semantics... yes
Checking for ncurses... yes
Checking for GNU libc... yes
Checking for forkpty... -lutil
Checking for logwtmp... -lutil
Checking for snprintf declaration... ok
Checking for snprintf implementation... ok
Generating MCONFIG...
make -j3
(cd telnet && make)
(cd telnetd && make)
(cd telnetlogin && make)
make[1]: Вход в каталог `/var/tmp/portage/net-misc/netkit-telnetd-0.17-r10/work/netkit-telnet-0.17/telnet'
i686-pc-linux-gnu-g++ -O2 -march=i686 -O2 -march=i686 -pipe -fno-rtti -fno-exceptions -Wall -Wno-trigraphs -DUSE_TERMIO -DKLUDGELINEMODE -D_GNU_SOURCE commands.cc -c
make[1]: Вход в каталог `/var/tmp/portage/net-misc/netkit-telnetd-0.17-r10/work/netkit-telnet-0.17/telnetlogin'
i686-pc-linux-gnu-gcc -O2 -march=i686 -O2 -march=i686 -pipe -Wall -Wno-trigraphs telnetlogin.c -c
make[1]: Вход в каталог `/var/tmp/portage/net-misc/netkit-telnetd-0.17-r10/work/netkit-telnet-0.17/telnetd'
i686-pc-linux-gnu-gcc -O2 -march=i686 -O2 -march=i686 -pipe -Wall -Wno-trigraphs '-DISSUE_FILE="/etc/issue.net"' -DPARANOID_TTYS -DNO_REVOKE -DKLUDGELINEMODE -DDIAGNOSTICS -DLOGIN_WRAPPER=\"/usr/sbin/telnetlogin\" -D_GNU_SOURCE telnetd.c -c
telnetlogin.c: В функции «main»:
telnetlogin.c:135:16: предупреждение: variable «rh» set but not used [-Wunused-but-set-variable]
i686-pc-linux-gnu-gcc -Wl,--as-needed telnetlogin.o -lutil -lutil -o telnetlogin
commands.cc: В функции «int shell(int, const char**)»:
commands.cc:1350:49: предупреждение: missing sentinel in function call [-Wformat]
commands.cc:1352:29: предупреждение: missing sentinel in function call [-Wformat]
commands.cc: В функции «int setescape(int, const char**)»:
commands.cc:1284:40: предупреждение: ignoring return value of «char* fgets(char*, int, FILE*)», declared with attribute warn_unused_result [-Wunused-result]
commands.cc: В функции «int tn(int, const char**)»:
commands.cc:1651:71: предупреждение: ignoring return value of «char* fgets(char*, int, FILE*)», declared with attribute warn_unused_result [-Wunused-result]
make[1]: Выход из каталога `/var/tmp/portage/net-misc/netkit-telnetd-0.17-r10/work/netkit-telnet-0.17/telnetlogin'
i686-pc-linux-gnu-gcc -O2 -march=i686 -O2 -march=i686 -pipe -Wall -Wno-trigraphs '-DISSUE_FILE="/etc/issue.net"' -DPARANOID_TTYS -DNO_REVOKE -DKLUDGELINEMODE -DDIAGNOSTICS -DLOGIN_WRAPPER=\"/usr/sbin/telnetlogin\" -D_GNU_SOURCE state.c -c
state.c: В функции «suboption»:
state.c:1206:10: предупреждение: сравнение различных указательных типов без приведения типов [по умолчанию включена]
state.c: В функции «send_status»:
state.c:1367:5: предупреждение: ignoring return value of «fwrite», declared with attribute warn_unused_result [-Wunused-result]
i686-pc-linux-gnu-gcc -O2 -march=i686 -O2 -march=i686 -pipe -Wall -Wno-trigraphs '-DISSUE_FILE="/etc/issue.net"' -DPARANOID_TTYS -DNO_REVOKE -DKLUDGELINEMODE -DDIAGNOSTICS -DLOGIN_WRAPPER=\"/usr/sbin/telnetlogin\" -D_GNU_SOURCE termstat.c -c
i686-pc-linux-gnu-gcc -O2 -march=i686 -O2 -march=i686 -pipe -Wall -Wno-trigraphs '-DISSUE_FILE="/etc/issue.net"' -DPARANOID_TTYS -DNO_REVOKE -DKLUDGELINEMODE -DDIAGNOSTICS -DLOGIN_WRAPPER=\"/usr/sbin/telnetlogin\" -D_GNU_SOURCE slc.c -c
i686-pc-linux-gnu-gcc -O2 -march=i686 -O2 -march=i686 -pipe -Wall -Wno-trigraphs '-DISSUE_FILE="/etc/issue.net"' -DPARANOID_TTYS -DNO_REVOKE -DKLUDGELINEMODE -DDIAGNOSTICS -DLOGIN_WRAPPER=\"/usr/sbin/telnetlogin\" -D_GNU_SOURCE sys_term.c -c
sys_term.c: В функции «start_login»:
sys_term.c:669:12: предупреждение: ignoring return value of «write», declared with attribute warn_unused_result [-Wunused-result]
i686-pc-linux-gnu-gcc -O2 -march=i686 -O2 -march=i686 -pipe -Wall -Wno-trigraphs '-DISSUE_FILE="/etc/issue.net"' -DPARANOID_TTYS -DNO_REVOKE -DKLUDGELINEMODE -DDIAGNOSTICS -DLOGIN_WRAPPER=\"/usr/sbin/telnetlogin\" -D_GNU_SOURCE utility.c -c
utility.c: В функции «nextitem»:
utility.c:212:2: предупреждение: при возврате результата указуемые типы различаются знаковостью [-Wpointer-sign]
utility.c: В функции «printsub»:
utility.c:893:8: предупреждение: формат не является строковой константой, и не заданы аргументы форматирования [-Wformat-security]
utility.c:898:8: предупреждение: формат не является строковой константой, и не заданы аргументы форматирования [-Wformat-security]
utility.c:903:8: предупреждение: формат не является строковой константой, и не заданы аргументы форматирования [-Wformat-security]
utility.c: В функции «netwrite»:
utility.c:1165:3: предупреждение: при передаче аргумента 1 «nextitem»: указуемые типы различаются знаковостью [-Wpointer-sign]
utility.c:156:1: замечание: expected «const unsigned char *» but argument is of type «char *»
utility.c:1165:3: предупреждение: при передаче аргумента 2 «nextitem»: указуемые типы различаются знаковостью [-Wpointer-sign]
utility.c:156:1: замечание: expected «const unsigned char *» but argument is of type «char *»
utility.c:1165:3: предупреждение: при передаче аргумента 3 «nextitem»: указуемые типы различаются знаковостью [-Wpointer-sign]
utility.c:156:1: замечание: expected «const unsigned char *» but argument is of type «const char *»
utility.c:1165:3: предупреждение: при передаче аргумента 4 «nextitem»: указуемые типы различаются знаковостью [-Wpointer-sign]
utility.c:156:1: замечание: expected «const unsigned char *» but argument is of type «const char * const»
utility.c:1219:3: предупреждение: при передаче аргумента 1 «nextitem»: указуемые типы различаются знаковостью [-Wpointer-sign]
utility.c:156:1: замечание: expected «const unsigned char *» but argument is of type «const char *»
utility.c:1219:3: предупреждение: при передаче аргумента 2 «nextitem»: указуемые типы различаются знаковостью [-Wpointer-sign]
utility.c:156:1: замечание: expected «const unsigned char *» but argument is of type «const char * const»
utility.c: В функции «sendurg»:
utility.c:1259:9: предупреждение: ignoring return value of «fwrite», declared with attribute warn_unused_result [-Wunused-result]
utility.c: В функции «fatal»:
utility.c:354:2: предупреждение: ignoring return value of «write», declared with attribute warn_unused_result [-Wunused-result]
i686-pc-linux-gnu-gcc -O2 -march=i686 -O2 -march=i686 -pipe -Wall -Wno-trigraphs '-DISSUE_FILE="/etc/issue.net"' -DPARANOID_TTYS -DNO_REVOKE -DKLUDGELINEMODE -DDIAGNOSTICS -DLOGIN_WRAPPER=\"/usr/sbin/telnetlogin\" -D_GNU_SOURCE global.c -c
i686-pc-linux-gnu-gcc -O2 -march=i686 -O2 -march=i686 -pipe -Wall -Wno-trigraphs '-DISSUE_FILE="/etc/issue.net"' -DPARANOID_TTYS -DNO_REVOKE -DKLUDGELINEMODE -DDIAGNOSTICS -DLOGIN_WRAPPER=\"/usr/sbin/telnetlogin\" -D_GNU_SOURCE setproctitle.c -c
i686-pc-linux-gnu-g++ -O2 -march=i686 -O2 -march=i686 -pipe -fno-rtti -fno-exceptions -Wall -Wno-trigraphs -DUSE_TERMIO -DKLUDGELINEMODE -D_GNU_SOURCE main.cc -c
commands.cc:1833:52: предупреждение: «srlen» may be used uninitialized in this function [-Wuninitialized]
i686-pc-linux-gnu-gcc -Wl,--as-needed telnetd.o state.o termstat.o slc.o sys_term.o utility.o global.o setproctitle.o -lutil -lutil -o telnetd
make[1]: Выход из каталога `/var/tmp/portage/net-misc/netkit-telnetd-0.17-r10/work/netkit-telnet-0.17/telnetd'
i686-pc-linux-gnu-g++ -O2 -march=i686 -O2 -march=i686 -pipe -fno-rtti -fno-exceptions -Wall -Wno-trigraphs -DUSE_TERMIO -DKLUDGELINEMODE -D_GNU_SOURCE network.cc -c
i686-pc-linux-gnu-g++ -O2 -march=i686 -O2 -march=i686 -pipe -fno-rtti -fno-exceptions -Wall -Wno-trigraphs -DUSE_TERMIO -DKLUDGELINEMODE -D_GNU_SOURCE ring.cc -c
i686-pc-linux-gnu-g++ -O2 -march=i686 -O2 -march=i686 -pipe -fno-rtti -fno-exceptions -Wall -Wno-trigraphs -DUSE_TERMIO -DKLUDGELINEMODE -D_GNU_SOURCE sys_bsd.cc -c
i686-pc-linux-gnu-g++ -O2 -march=i686 -O2 -march=i686 -pipe -fno-rtti -fno-exceptions -Wall -Wno-trigraphs -DUSE_TERMIO -DKLUDGELINEMODE -D_GNU_SOURCE telnet.cc -c
i686-pc-linux-gnu-g++ -O2 -march=i686 -O2 -march=i686 -pipe -fno-rtti -fno-exceptions -Wall -Wno-trigraphs -DUSE_TERMIO -DKLUDGELINEMODE -D_GNU_SOURCE terminal.cc -c
telnet.cc: В функции «const char* gettermname()»:
telnet.cc:638:7: предупреждение: неиспользуемая переменная «err» [-Wunused-variable]
i686-pc-linux-gnu-g++ -O2 -march=i686 -O2 -march=i686 -pipe -fno-rtti -fno-exceptions -Wall -Wno-trigraphs -DUSE_TERMIO -DKLUDGELINEMODE -D_GNU_SOURCE tn3270.cc -c
i686-pc-linux-gnu-g++ -O2 -march=i686 -O2 -march=i686 -pipe -fno-rtti -fno-exceptions -Wall -Wno-trigraphs -DUSE_TERMIO -DKLUDGELINEMODE -D_GNU_SOURCE utilities.cc -c
i686-pc-linux-gnu-g++ -O2 -march=i686 -O2 -march=i686 -pipe -fno-rtti -fno-exceptions -Wall -Wno-trigraphs -DUSE_TERMIO -DKLUDGELINEMODE -D_GNU_SOURCE genget.cc -c
utilities.cc: В функции «void printsub(int, unsigned char*, int)»:
utilities.cc:586:45: предупреждение: формат не является строковой константой, и не заданы аргументы форматирования [-Wformat-security]
utilities.cc:591:47: предупреждение: формат не является строковой константой, и не заданы аргументы форматирования [-Wformat-security]
utilities.cc:596:45: предупреждение: формат не является строковой константой, и не заданы аргументы форматирования [-Wformat-security]
utilities.cc: В функции «void ExitString(const char*, int)»:
utilities.cc:673:46: предупреждение: ignoring return value of «size_t fwrite(const void*, size_t, size_t, FILE*)», declared with attribute warn_unused_result [-Wunused-result]
i686-pc-linux-gnu-g++ -O2 -march=i686 -O2 -march=i686 -pipe -fno-rtti -fno-exceptions -Wall -Wno-trigraphs -DUSE_TERMIO -DKLUDGELINEMODE -D_GNU_SOURCE environ.cc -c
telnet.cc: At global scope:
telnet.cc:611:12: предупреждение: «int my_setupterm(const char*, int, int*)» определена, но нигде не используется [-Wunused-function]
i686-pc-linux-gnu-g++ -O2 -march=i686 -O2 -march=i686 -pipe -fno-rtti -fno-exceptions -Wall -Wno-trigraphs -DUSE_TERMIO -DKLUDGELINEMODE -D_GNU_SOURCE netlink.cc -c
i686-pc-linux-gnu-g++ -Wl,--as-needed commands.o main.o network.o ring.o sys_bsd.o telnet.o terminal.o tn3270.o utilities.o genget.o environ.o netlink.o -lncurses -o telnet
make[1]: Выход из каталога `/var/tmp/portage/net-misc/netkit-telnetd-0.17-r10/work/netkit-telnet-0.17/telnet'
make -j3
make: Цель `all' не требует выполнения команд.
>>> Source compiled.
>>> Test phase [not enabled]: net-misc/netkit-telnetd-0.17-r10
>>> Install netkit-telnetd-0.17-r10 into /var/tmp/portage/net-misc/netkit-telnetd-0.17-r10/image/ category net-misc
>>> Completed installing netkit-telnetd-0.17-r10 into /var/tmp/portage/net-misc/netkit-telnetd-0.17-r10/image/
strip: i686-pc-linux-gnu-strip --strip-unneeded -R .comment -R .GCC.command.line -R .note.gnu.gold-version
usr/sbin/telnetd
usr/bin/telnet
usr/sbin/telnetlogin
ecompressdir: bzip2 -9 /usr/share/man
* checking 16 files for package collisions
>>> Merging net-misc/netkit-telnetd-0.17-r10 to /
* QA Notice: Global shell options changed and were not restored while calling 'post_pkg_preinst'
/var/tmp/portage/net-misc/netkit-telnetd-0.17-r10/temp/environment: line 2001: syntax error near unexpected token `('
/var/tmp/portage/net-misc/netkit-telnetd-0.17-r10/temp/environment: line 2001: ` *-* | +([[:digit:]]).+([[:digit:]])*)'
* ERROR: net-misc/netkit-telnetd-0.17-r10::gentoo failed:
* error sourcing environment
*
* Call stack:
* misc-functions.sh, line 17: Called source 'preinst_selinux_labels'
* ebuild.sh, line 489: Called die
* The specific snippet of code:
* source "${T}"/environment || \
* die "error sourcing environment"
*
* If you need support, post the output of `emerge --info '=net-misc/netkit-telnetd-0.17-r10::gentoo'`,
* the complete build log and the output of `emerge -pqv '=net-misc/netkit-telnetd-0.17-r10::gentoo'`.
* The complete build log is located at '/var/tmp/portage/net-misc/netkit-telnetd-0.17-r10/temp/build.log'.
* The ebuild environment file is located at '/var/tmp/portage/net-misc/netkit-telnetd-0.17-r10/temp/environment'.
* Working directory: '/usr/lib/portage/pym'
* S: '/var/tmp/portage/net-misc/netkit-telnetd-0.17-r10/work/netkit-telnet-0.17'
!!! post preinst failed; exiting.
/var/tmp/portage/net-misc/netkit-telnetd-0.17-r10/temp/environment: line 2001: syntax error near unexpected token `('
/var/tmp/portage/net-misc/netkit-telnetd-0.17-r10/temp/environment: line 2001: ` *-* | +([[:digit:]]).+([[:digit:]])*)'
* ERROR: net-misc/netkit-telnetd-0.17-r10::gentoo failed:
* error sourcing environment
*
* Call stack:
* misc-functions.sh, line 17: Called source '/usr/lib/portage/bin/ebuild.sh'
* ebuild.sh, line 489: Called die
* The specific snippet of code:
* source "${T}"/environment || \
* die "error sourcing environment"
*
* If you need support, post the output of `emerge --info '=net-misc/netkit-telnetd-0.17-r10::gentoo'`,
* the complete build log and the output of `emerge -pqv '=net-misc/netkit-telnetd-0.17-r10::gentoo'`.
* The complete build log is located at '/var/tmp/portage/net-misc/netkit-telnetd-0.17-r10/temp/build.log'.
* The ebuild environment file is located at '/var/tmp/portage/net-misc/netkit-telnetd-0.17-r10/temp/environment'.
* Working directory: '/usr/lib/portage/pym'
* S: '/var/tmp/portage/net-misc/netkit-telnetd-0.17-r10/work/netkit-telnet-0.17'
!!! FAILED preinst: 1
/var/tmp/portage/net-misc/netkit-telnetd-0.17-r10/temp/environment: line 2001: syntax error near unexpected token `('
/var/tmp/portage/net-misc/netkit-telnetd-0.17-r10/temp/environment: line 2001: ` *-* | +([[:digit:]]).+([[:digit:]])*)'
* ERROR: net-misc/netkit-telnetd-0.17-r10::gentoo failed:
* error sourcing environment
*
* Call stack:
* misc-functions.sh, line 17: Called source '/usr/lib/portage/bin/ebuild.sh'
* ebuild.sh, line 489: Called die
* The specific snippet of code:
* source "${T}"/environment || \
* die "error sourcing environment"
*
* If you need support, post the output of `emerge --info '=net-misc/netkit-telnetd-0.17-r10::gentoo'`,
* the complete build log and the output of `emerge -pqv '=net-misc/netkit-telnetd-0.17-r10::gentoo'`.
* The complete build log is located at '/var/tmp/portage/net-misc/netkit-telnetd-0.17-r10/temp/build.log'.
* The ebuild environment file is located at '/var/tmp/portage/net-misc/netkit-telnetd-0.17-r10/temp/environment'.
* Working directory: '/usr/lib/portage/pym'
* S: '/var/tmp/portage/net-misc/netkit-telnetd-0.17-r10/work/netkit-telnet-0.17'
declare -x ABI_X86="32"
declare -x ALSA_CARDS=""
declare -x APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias proxy proxy_http"
declare -x ARCH="x86"
declare -x AUDIODEV="default"
declare -x BOOTSTRAP_USE="cxx unicode python_targets_python3_2 python_targets_python2_7"
declare -x CALLIGRA_FEATURES="kexi words flow plan sheets stage tables krita karbon braindump author"
declare -x CBUILD="i686-pc-linux-gnu"
declare -x CDISTRO="CLD desktop"
declare -x CFLAGS="-O2 -march=i686 -pipe"
declare -x CFLAGS_default
declare -x CHOST="i686-pc-linux-gnu"
declare -x CHOST_default="i686-pc-linux-gnu"
declare -x CL="builder client desktop console consolegui"
declare -- CL_CORE_PATCH="/usr/sbin/cl-core-patch"
declare -- CL_UPDATE_PROG="/usr/sbin/cl-core-setup"
declare -x COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog"
declare -x COLORFGBG="15;0"
declare -x CONFIG_PROTECT="/usr/share/gnupg/qualified.txt /usr/share/config /usr/share/themes/oxygen-gtk/gtk-2.0 /usr/share/themes/oxygen-gtk/gtk-3.0"
declare -x CONFIG_PROTECT_MASK="/etc/gentoo-release /etc/sandbox.d /etc/php/cli-php5.4/ext-active/ /etc/php/cgi-php5.4/ext-active/ /etc/php/apache2-php5.4/ext-active/ /etc/fonts/fonts.conf /etc/terminfo /etc/ca-certificates.conf /etc/revdep-rebuild /etc/splash"
declare -x CTARGET_default="i686-pc-linux-gnu"
declare -x CXXFLAGS="-O2 -march=i686 -pipe"
declare -x DBUS_SESSION_BUS_ADDRESS="unix:abstract=/tmp/dbus-mx1Kk6fYHI,guid=a4d959e4c45050191dc72425520a631f"
declare -x DEFAULT_ABI="default"
declare -x DEFINED_PHASES=" compile install unpack"
declare DEPEND=">=sys-libs/ncurses-5.2
!net-misc/telnet-bsd "
declare DESCRIPTION="Standard Linux telnet client and server"
declare -x DESKTOP_SESSION="default"
declare -x DESTTREE="/usr"
declare -x DIROPTIONS="-m0755"
declare -x DM_CONTROL="/var/run/xdmctl"
declare -x EAPI="0"
declare -x ELIBC="glibc"
declare -- EPATCH_COMMON_OPTS="-g0 -E --no-backup-if-mismatch"
declare -- EPATCH_EXCLUDE=""
declare -- EPATCH_FORCE="no"
declare -- EPATCH_MULTI_MSG="Applying various patches (bugfixes/updates) ..."
declare -- EPATCH_OPTS=""
declare -- EPATCH_SINGLE_MSG=""
declare -- EPATCH_SOURCE="/var/tmp/portage/net-misc/netkit-telnetd-0.17-r10/work/patch"
declare -- EPATCH_SUFFIX="patch.bz2"
declare -x EXEOPTIONS="-m0755"
declare -x FCFLAGS="-O2 -march=i686 -pipe"
declare -x FETCHCOMMAND_SSH="bash -c \"x=\\\${2#ssh://} ; host=\\\${x%%/*} ; port=\\\${host##*:} ; host=\\\${host%:*} ; [[ \\\${host} = \\\${port} ]] && port=22 ; exec rsync --rsh=\\\"ssh -p\\\${port} \\\${3}\\\" -avP \\\"\\\${host}:/\\\${x#*/}\\\" \\\"\\\$1\\\"\" rsync \"\${DISTDIR}/\${FILE}\" \"\${URI}\" \"\${PORTAGE_SSH_OPTS}\""
declare -x FFLAGS="-O2 -march=i686 -pipe"
declare -x GCC_SPECS=""
declare -x GEM_HOME="/usr/local/rvm/gems/ruby-2.0.0-p247"
declare -x GEM_PATH="/usr/local/rvm/gems/ruby-2.0.0-p247:/usr/local/rvm/gems/ruby-2.0.0-p247@global"
declare -x GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf superstar2 timing tsip tripmate tnt ubx"
declare -x GRUB_PLATFORMS="pc"
declare -x GS_LIB="/home/wolfer/.fonts"
declare -x GTK2_RC_FILES="/etc/gtk-2.0/gtkrc:/home/wolfer/.gtkrc-2.0:/home/wolfer/.kde4/share/config/gtkrc-2.0"
declare -x GTK_RC_FILES="/etc/gtk/gtkrc:/home/wolfer/.gtkrc:/home/wolfer/.kde4/share/config/gtkrc"
declare -x GUILE_LOAD_PATH="/usr/share/guile/1.8"
declare HDEPEND=""
declare HOMEPAGE="https://launchpad.net/netkit-telnet"
declare -x INFOPATH="/usr/share/info:/usr/share/gcc-data/i686-pc-linux-gnu/4.6.3/info:/usr/share/binutils-data/i686-pc-linux-gnu/2.23.1/info"
declare -x INHERITED=" multilib toolchain-funcs user eutils"
declare -x INPUT_DEVICES="keyboard mouse evdev mutouch synaptics"
declare -x INSDESTTREE="/etc/xinetd.d"
declare -x INSOPTIONS="-m0644"
declare -x IRBRC="/usr/local/rvm/rubies/ruby-2.0.0-p247/.irbrc"
declare IUSE=""
declare -x IUSE_IMPLICIT="prefix"
declare -x KDE_FULL_SESSION="true"
declare -x KDE_IS_PRELINKED="1"
declare -x KDE_MULTIHEAD="false"
declare -x KDE_SESSION_UID="1000"
declare -x KDE_SESSION_VERSION="4"
declare -x KERNEL="linux"
declare -x KERNEL_ABI="default"
declare -x KEYWORDS="alpha amd64 arm hppa ia64 ~mips ppc ppc64 s390 sh sparc x86"
declare -x KONSOLE_DBUS_SERVICE=":1.37"
declare -x KONSOLE_DBUS_SESSION="/Sessions/3"
declare -x KONSOLE_PROFILE_NAME="Командная оболочка"
declare -x KV="3.10.4-calculate"
declare -x LANG="ru_RU.UTF-8"
declare -x LANGUAGE=""
declare -x LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text"
declare -x LC_NUMERIC="POSIX"
declare -x LDFLAGS="-Wl,--as-needed"
declare -x LDFLAGS_default
declare -x LIBDIR_default="lib"
declare -x LIBOPTIONS="-m0644"
declare -x LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer"
declare -x LICENSE="BSD"
declare -x LINGUAS="ru"
declare -x LIRC_DEVICES="devinput"
declare -x MAIL="/var/mail/wolfer"
declare -x MAKEOPTS="-j3"
declare -x MANPATH="/usr/local/share/man:/usr/share/man:/usr/share/gcc-data/i686-pc-linux-gnu/4.6.3/man:/usr/share/binutils-data/i686-pc-linux-gnu/2.23.1/man:/usr/lib/php5.4/man/:/usr/share/postgresql/man/:/usr/share/postgresql-9.2/man/"
declare -x MULTILIB_ABIS="default"
declare -x MULTIOSDIRS="../lib"
declare -x MY_RUBY_HOME="/usr/local/rvm/rubies/ruby-2.0.0-p247"
declare -x NETBEANS="apisupport cnd groovy gsf harness ide identity j2ee java mobility nb php profiler soa visualweb webcommon websvccommon xml"
declare -x NPTL_KERN_VER="3.0.0"
declare -x OFFICE_IMPLEMENTATION="libreoffice"
declare -x OPENCL_PROFILE="nvidia"
declare -x OPENGL_PROFILE="nvidia"
declare -- PATCHLEVEL="36"
declare -- PATCH_OVERLAY="/var/lib/layman/calculate/profiles/patches"
declare -x PATH="/usr/local/rvm/gems/ruby-2.0.0-p247/bin:/usr/local/rvm/gems/ruby-2.0.0-p247@global/bin:/usr/local/rvm/rubies/ruby-2.0.0-p247/bin:/usr/local/rvm/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin:/usr/i686-pc-linux-gnu/gcc-bin/4.6.3"
declare PDEPEND=""
declare -x PHP_TARGETS=""
declare -a PORTAGE_DOCOMPRESS='([0]="/usr/share/doc" [1]="/usr/share/info" [2]="/usr/share/man")'
declare -a PORTAGE_DOCOMPRESS_SKIP='([0]="/usr/share/doc/netkit-telnetd-0.17-r10/html")'
declare -x PORTAGE_NICENESS="19"
declare -x PRELINK_PATH_MASK="/usr/lib/klibc:/usr/lib/libfreebl3.so:/usr/lib/libnssdbm3.so:/usr/lib/libsoftokn3.so:/usr/lib64/gimp/2.0/plug-ins/hot:/usr/lib/*nvidia*:/opt/bin/skype"
declare -x PROFILEHOME=""
declare -x PROFILE_ONLY_VARIABLES="ARCH ELIBC IUSE_IMPLICIT KERNEL USERLAND USE_EXPAND_IMPLICIT USE_EXPAND_UNPREFIXED USE_EXPAND_VALUES_ARCH USE_EXPAND_VALUES_ELIBC USE_EXPAND_VALUES_KERNEL USE_EXPAND_VALUES_USERLAND"
declare -x PROPERTIES=""
declare -x PROVIDE=""
declare -x PYTHONDONTWRITEBYTECODE="1"
declare -x PYTHON_SINGLE_TARGET=""
declare -x PYTHON_TARGETS=""
declare -x QT_GRAPHICSSYSTEM="raster"
declare -x QT_PLUGIN_PATH="/usr/lib/kde4/plugins"
declare -x RDEPEND=">=sys-libs/ncurses-5.2
!net-misc/telnet-bsd "
declare REPOSITORY
declare REQUIRED_USE=""
declare -x RESTRICT=""
declare -x RESUMECOMMAND_SSH="bash -c \"x=\\\${2#ssh://} ; host=\\\${x%%/*} ; port=\\\${host##*:} ; host=\\\${host%:*} ; [[ \\\${host} = \\\${port} ]] && port=22 ; exec rsync --rsh=\\\"ssh -p\\\${port} \\\${3}\\\" -avP \\\"\\\${host}:/\\\${x#*/}\\\" \\\"\\\$1\\\"\" rsync \"\${DISTDIR}/\${FILE}\" \"\${URI}\" \"\${PORTAGE_SSH_OPTS}\""
declare -x RUBY_TARGETS=""
declare -x RUBY_VERSION="ruby-2.0.0-p247"
declare -x S="/var/tmp/portage/net-misc/netkit-telnetd-0.17-r10/work/netkit-telnet-0.17"
declare -x SANDBOX_DEBUG="0"
declare -x SANDBOX_DENY=""
declare -x SANDBOX_PID="29635"
declare -x SANDBOX_PREDICT="/var/tmp/portage/net-misc/netkit-telnetd-0.17-r10/homedir:/dev/crypto:/var/cache/fontconfig"
declare -x SANDBOX_READ="/:/var/tmp"
declare -x SANDBOX_VERBOSE="1"
declare -x SANDBOX_WRITE=":/dev/console:/dev/fd:/dev/full:/dev/null:/dev/pts/:/dev/pty:/dev/shm:/dev/tts:/dev/tty:/dev/vc/:/dev/zero:/proc/self/fd:/tmp/:/usr/lib32/cf:/usr/lib32/conftest:/usr/lib64/cf:/usr/lib64/conftest:/usr/lib/cf:/usr/lib/conftest:/usr/tmp/cf:/usr/tmp/conftest:/var/tmp:/var/tmp/:/var/tmp/portage/net-misc/netkit-telnetd-0.17-r10/homedir/.bash_history"
declare -x SDL_AUDIODRIVER="alsa"
declare -x SESSION_MANAGER="local/calculate:@/tmp/.ICE-unix/14322,unix/calculate:/tmp/.ICE-unix/14322"
declare -x SHELL="/bin/bash"
declare -x SHELL_SESSION_ID="a2ea932988b44000bd8bde49f949b120"
declare -x SLOT="0"
declare SRC_URI="mirror://gentoo/netkit-telnet-0.17.tar.gz
mirror://debian/pool/main/n/netkit-telnet/netkit-telnet_0.17-36.diff.gz"
declare -x THEMES="CLD"
declare -x USE="abi_x86_32 cdistro_CLD cdistro_desktop elibc_glibc kernel_linux userland_GNU x86"
declare -x USERLAND="GNU"
declare -x USE_EXPAND_IMPLICIT="ARCH ELIBC KERNEL USERLAND"
declare -x USE_EXPAND_UNPREFIXED="ARCH"
declare -x USE_EXPAND_VALUES_ARCH="alpha amd64 amd64-fbsd amd64-linux arm arm-linux hppa hppa-hpux ia64 ia64-hpux ia64-linux m68k m68k-mint mips ppc ppc64 ppc64-linux ppc-aix ppc-macos ppc-openbsd s390 sh sparc sparc64-freebsd sparc64-solaris sparc-fbsd sparc-solaris x64-freebsd x64-macos x64-openbsd x64-solaris x86 x86-cygwin x86-fbsd x86-freebsd x86-interix x86-linux x86-macos x86-netbsd x86-openbsd x86-solaris x86-winnt"
declare -x USE_EXPAND_VALUES_ELIBC="AIX Cygwin Darwin FreeBSD glibc HPUX Interix mintlib musl NetBSD OpenBSD SunOS uclibc Winnt"
declare -x USE_EXPAND_VALUES_KERNEL="AIX Cygwin Darwin FreeBSD freemint HPUX Interix linux NetBSD OpenBSD SunOS Winnt"
declare -x USE_EXPAND_VALUES_USERLAND="BSD GNU"
declare -x USE_PYTHON="2.7"
declare -x VIDEO_CARDS=""
declare -x WINDOWID="16777242"
declare -x WINDOWPATH="7"
declare -x XCURSOR_THEME="Oxygen_Black"
declare -x XDG_CONFIG_DIRS="/etc/xdg"
declare -x XDG_CURRENT_DESKTOP="KDE"
declare -x XDG_DATA_DIRS="/usr/local/share:/usr/share"
declare -x XDG_SESSION_COOKIE="8e62495c44f11df8a798ed9f001e5722-1376413022.26559-1357368065"
declare -x XDM_MANAGED="method=classic"
declare -x XSESSION="KDE-4"
declare -x XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account"
declare -x _E_DOCDESTTREE_=""
declare -x _E_EXEDESTTREE_=""
declare -- ___ECLASS_ONCE_EUTILS="recur -_+^+_- spank"
declare -- ___ECLASS_ONCE_MULTILIB="recur -_+^+_- spank"
declare -- ___ECLASS_ONCE_TOOLCHAIN_FUNCS="recur -_+^+_- spank"
declare -- ___ECLASS_ONCE_USER="recur -_+^+_- spank"
declare -- calcver="3.1.1"
declare -- f="*netkit-telnetd*"
declare -- file="/var/tmp/portage/net-misc/netkit-telnetd-0.17-r10/homedir/.rvmrc"
declare -- phase_func
declare -x rvm_alias_expanded
declare -x rvm_bin_flag
declare -x rvm_bin_path="/usr/local/rvm/bin"
declare -x rvm_configure_flags
declare -x rvm_delete_flag
declare -x rvm_docs_type
declare -x rvm_file_name
declare -x rvm_gemstone_package_file
declare -x rvm_gemstone_url
declare -x rvm_hook
declare -- rvm_ignore_rvmrc="0"
declare -x rvm_make_flags
declare -x rvm_niceness
declare -x rvm_nightly_flag
declare -x rvm_only_path_flag
declare -x rvm_path="/usr/local/rvm"
declare -x rvm_prefix="/usr/local"
declare -x rvm_proxy
declare -x rvm_quiet_flag
declare -x rvm_ruby_alias
declare -x rvm_ruby_bits
declare -x rvm_ruby_configure
declare -x rvm_ruby_file
declare -x rvm_ruby_global_gems_path
declare -x rvm_ruby_make
declare -x rvm_ruby_make_install
declare -x rvm_ruby_mode
declare -x rvm_ruby_string
declare -x rvm_ruby_url
declare -- rvm_rubygems_path="/usr/local/rvm/rubygems"
declare -a rvm_saved_env='()'
declare -x rvm_script_name
declare -x rvm_sdk
declare -x rvm_silent_flag
declare -x rvm_sticky_flag
declare -x rvm_system_flag
declare -x rvm_use_flag
declare -x rvm_user_flag
declare -x rvm_version="1.22.1 (stable)"
declare -x rvm_wrapper_name
declare -- rvmrc="/usr/local/.rvmrc"
declare -- script="override_gem"
declare -- userBashrc="/etc/portage/bashrc"
__function_on_stack ()
{
__rvm_string_includes "${FUNCNAME[*]}" "$@" || return $?
}
__function_unset ()
{
if [[ -n "${ZSH_VERSION:-}" ]]; then
unset -f "$1";
else
unset "$1";
fi
}
__list_remote_all_for ()
{
{
__list_remote_rubies_for "$1";
__list_remote_rbx_for "$1";
__list_remote_jruby_for "$1"
} | sort -u
}
__list_remote_jruby_for ()
{
typeset rvm_ruby_url;
rvm_ruby_url="$1";
__rvm_curl -s "http://jruby.org.s3.amazonaws.com/?prefix=downloads/&delimiter=/" | __rvm_grep -oE "<Key>[^<]*</Key>" | __rvm_grep -o '[[:digit:]][^_]*' | __rvm_awk '{print "http://jruby.org.s3.amazonaws.com/downloads/"$1"/jruby-bin-"$1".tar.gz"}' | __rvm_grep "${rvm_ruby_url}"
}
__list_remote_rbx_for ()
{
__rvm_curl -s http://binaries.rubini.us/index.txt | __rvm_grep -E "$1.*\.tar\.bz2$"
}
__list_remote_rubies_for ()
{
typeset rvm_ruby_url;
rvm_ruby_url="$1";
__rvm_awk '/'"${rvm_ruby_url//\//\/}"'/{print}' < $rvm_path/config/remote;
if [[ -f $rvm_user_path/remote ]]; then
__rvm_awk '/'"${rvm_ruby_url//\//\/}"'/{print}' < $rvm_user_path/remote;
fi
}
__rvm_add_to_path ()
{
export PATH;
if (( $# != 2 )) || [[ -z "$2" ]]; then
rvm_error "__rvm_add_to_path requires two parameters";
return 1;
fi;
__rvm_remove_from_path "$2";
case "$1" in
prepend)
PATH="$2:$PATH"
;;
append)
PATH="$PATH:$2"
;;
esac;
if [[ -n "${rvm_user_path_prefix:-}" ]]; then
__rvm_remove_from_path "${rvm_user_path_prefix}";
PATH="${rvm_user_path_prefix}:$PATH";
fi;
builtin hash -r
}
__rvm_after_cd ()
{
typeset rvm_hook;
rvm_hook="after_cd";
if [[ -n "${rvm_scripts_path:-}" || -n "${rvm_path:-}" ]]; then
source "${rvm_scripts_path:-$rvm_path/scripts}/hook";
fi
}
__rvm_array_add_or_update ()
{
typeset _array_name _variable _separator _value _local_value;
typeset -a _array_value_old _array_value_new;
_array_name="$1";
_variable="$2";
_separator="$3";
_value="${4##${_separator}}";
_array_value_new=();
eval "_array_value_old=( \"\${${_array_name}[@]}\" )";
case " ${_array_value_old[*]} " in
*[[:space:]]${_variable}*)
for _local_value in "${_array_value_old[@]}";
do
case "${_local_value}" in
${_variable}*)
_array_value_new+=("${_local_value}${_separator}${_value}")
;;
*)
_array_value_new+=("${_local_value}")
;;
esac;
done
;;
*)
_array_value_new=("${_array_value_old[@]}" "${_variable}${_value}")
;;
esac;
eval "${_array_name}=( \"\${_array_value_new[@]}\" )"
}
__rvm_array_contains ()
{
typeset _search _iterator;
_search="$1";
shift;
for _iterator in "$@";
do
case "${_iterator}" in
${_search})
return 0
;;
esac;
done;
return 1
}
__rvm_array_prepend_or_ignore ()
{
typeset _array_name _variable _separator _value _local_value;
typeset -a _array_value_old _array_value_new;
_array_name="$1";
_variable="$2";
_separator="$3";
_value="$4";
_array_value_new=();
eval "_array_value_old=( \"\${${_array_name}[@]}\" )";
case " ${_array_value_old[*]} " in
*[[:space:]]${_variable}*)
for _local_value in "${_array_value_old[@]}";
do
case "${_local_value}" in
${_variable}*)
rvm_debug "__rvm_array_prepend_or_ignore ${_array_name} ${_variable}\"${_value}${_separator}${_local_value#${_variable}}\"";
_array_value_new+=("${_variable}${_value}${_separator}${_local_value#${_variable}}")
;;
*)
_array_value_new+=("${_local_value}")
;;
esac;
done;
eval "${_array_name}=( \"\${_array_value_new[@]}\" )"
;;
esac
}
__rvm_ask_for ()
{
typeset response;
rvm_warn "$1";
printf "%b" "(anything other than '$2' will cancel) > ";
if read response && [[ "$2" == "$response" ]]; then
return 0;
else
return 1;
fi
}
__rvm_ask_to_trust ()
{
typeset trusted value anykey _rvmrc;
_rvmrc="${1}";
if [[ ! -t 0 || -n "$MC_SID" ]] || (( ${rvm_promptless:=0} == 1 )); then
return 2;
fi;
__rvm_table "NOTICE" <<-TEXT
RVM has encountered a new or modified $(basename "${_rvmrc}") file in the current directory, this is a shell script and therefore may contain any shell commands.
Examine the contents of this file carefully to be sure the contents are safe before trusting it!
Do you wish to trust '${_rvmrc}'?
Choose v[iew] below to view the contents
TEXT
trusted=0;
while (( ! trusted )); do
printf "%b" 'y[es], n[o], v[iew], c[ancel]> ';
builtin read response;
value="$(echo -n "${response}" | \tr '[[:upper:]]' '[[:lower:]]' | __rvm_strip)";
case "${value:-n}" in
v | view)
__rvm_display_rvmrc
;;
y | yes)
trusted=1
;;
n | no)
break
;;
c | cancel)
return 1
;;
esac;
done;
if (( trusted )); then
__rvm_trust_rvmrc "$1";
return 0;
else
__rvm_untrust_rvmrc "$1";
return 1;
fi
}
__rvm_awk ()
{
\awk "$@" || return $?
}
__rvm_become ()
{
typeset string rvm_rvmrc_flag;
string="$1";
rvm_rvmrc_flag=0;
[[ -n "$string" ]] && {
rvm_ruby_string="$string";
rvm_gemset_name=""
};
__rvm_use > /dev/null || return $?;
rvm_ruby_string="${rvm_ruby_string}${rvm_gemset_name:+${rvm_gemset_separator:-'@'}}${rvm_gemset_name:-}";
return 0
}
__rvm_calculate_remote_file ()
{
rvm_remote_server_url="$( __rvm_db "rvm_remote_server_url${3:-}" )";
[[ -n "$rvm_remote_server_url" ]] || {
rvm_debug "rvm_remote_server_url${3:-} not found";
return $1
};
__rvm_system_path "" "${3:-}";
__rvm_ruby_package_file "${4:-}";
__remote_file="${rvm_remote_server_url}/${rvm_remote_server_path}${rvm_ruby_package_file}"
}
__rvm_call_with_restored_umask ()
{
rvm_umask="$(umask)";
if [[ -n "${rvm_stored_umask:-}" ]]; then
umask ${rvm_stored_umask};
fi;
"$@";
umask "${rvm_umask}";
unset rvm_umask
}
__rvm_cd ()
{
typeset old_cdpath ret;
ret=0;
old_cdpath="${CDPATH}";
CDPATH=".";
chpwd_functions="" builtin cd "$@" || ret=$?;
CDPATH="${old_cdpath}";
return $ret
}
__rvm_cd_functions_set ()
{
__rvm_do_with_env_before;
__rvm_project_rvmrc && __rvm_after_cd || true;
__rvm_do_with_env_after;
return 0
}
__rvm_check_pipestatus ()
{
for __iterator in "$@";
do
case "${__iterator}" in
"")
true
;;
0)
true
;;
*)
return ${__iterator}
;;
esac;
done;
return 0
}
__rvm_check_rvmrc_trustworthiness ()
{
(( ${rvm_trust_rvmrcs_flag:-0} == 0 )) || return 0;
[[ -n "$1" ]] || return 1;
typeset _first _second saveIFS;
if [[ -n "${ZSH_VERSION:-}" ]]; then
_first=1;
else
_first=0;
fi;
_second=$(( _first + 1 ));
saveIFS="$IFS";
IFS=';';
typeset -a trust;
trust=($( __rvm_rvmrc_stored_trust "$1" ));
IFS="$saveIFS";
if [[ "${trust[${_second}]:-'#'}" == "$(__rvm_checksum_for_contents "$1")" ]]; then
[[ "${trust[${_first}]}" == '1' ]] || return $?;
else
__rvm_ask_to_trust "$1" || return $?;
fi;
true
}
__rvm_checksum_all ()
{
[[ -n "${_checksum_md5:-}" && -n "${_checksum_sha512:-}" ]]
}
__rvm_checksum_any ()
{
[[ -n "${_checksum_md5:-}" || -n "${_checksum_sha512:-}" ]]
}
__rvm_checksum_calculate_file ()
{
_checksum_md5="$( __rvm_md5_calculate "${1:-}" )";
_checksum_sha512="$( __rvm_sha__calculate 512 "${1:-}" )"
}
__rvm_checksum_for_contents ()
{
typeset __sum;
__sum=$( echo "$1" | \cat - "$1" | __rvm_md5_for_contents ) || {
rvm_error "Neither md5 nor md5sum were found in the PATH";
return 1
};
__sum+=$( echo "$1" | \cat - "$1" | __rvm_sha256_for_contents ) || {
rvm_error "Neither sha256sum nor shasum found in the PATH";
return 1
};
echo ${__sum}
}
__rvm_checksum_none ()
{
[[ -z "${_checksum_md5:-}" && -z "${_checksum_sha512:-}" ]]
}
__rvm_checksum_read ()
{
__rvm_checksum_none || return 0;
typeset _type _value _name;
typeset -a _list;
list=();
for _name in "$@";
do
list+=("$_name");
if [[ "$_name" =~ "?" ]]; then
list+=("${_name%\?*}");
fi;
done;
for _name in "${list[@]}";
do
_checksum_md5="$( "$rvm_scripts_path/db" "$rvm_path/config/md5" "$_name" | head -n 1 )";
[[ -n "${_checksum_md5:-}" ]] || _checksum_md5="$( "$rvm_scripts_path/db" "$rvm_user_path/md5" "$_name" | head -n 1 )";
_checksum_sha512="$( "$rvm_scripts_path/db" "$rvm_path/config/sha512" "$_name" | head -n 1 )";
[[ -n "${_checksum_sha512:-}" ]] || _checksum_sha512="$( "$rvm_scripts_path/db" "$rvm_user_path/sha512" "$_name" | head -n 1 )";
__rvm_checksum_none || return 0;
done;
return 1
}
__rvm_checksum_validate_file ()
{
__rvm_checksum_any || return 1;
if [[ -n "${_checksum_md5:-}" ]]; then
[[ "$(__rvm_md5_calculate "${1:-}")" == "${_checksum_md5:-}" ]] || return 2;
fi;
if [[ -n "${_checksum_sha512:-}" ]]; then
[[ "$(__rvm_sha__calculate 512 "${1:-}")" == "${_checksum_sha512:-}" ]] || return 3;
fi;
return 0
}
__rvm_checksum_write ()
{
[[ -n "${1:-}" ]] || return 1;
__rvm_checksum_any || return 1;
[[ -z "${_checksum_md5:-}" ]] || "$rvm_scripts_path/db" "$rvm_user_path/md5" "${1:-}" "${_checksum_md5:-}";
[[ -z "${_checksum_sha512:-}" ]] || "$rvm_scripts_path/db" "$rvm_user_path/sha512" "${1:-}" "${_checksum_sha512:-}";
return 0
}
__rvm_clean_path ()
{
export PATH;
typeset IFS _iterator_path;
typeset -a _old_path _new_path;
IFS=:;
_old_path=();
_new_path=();
__rvm_custom_separated_array _old_path : "${PATH}";
for _iterator_path in "${_old_path[@]}";
do
case ":${_new_path[*]}:" in
*:${_iterator_path}:*)
true
;;
*)
_new_path+=("${_iterator_path}")
;;
esac;
done;
PATH="${_new_path[*]}";
builtin hash -r
}
__rvm_cleanse_variables ()
{
__rvm_unset_ruby_variables;
if [[ ${rvm_sticky_flag:-0} -eq 1 ]]; then
export rvm_gemset_name;
else
unset rvm_gemset_name;
fi;
unset rvm_configure_flags rvm_patch_names rvm_make_flags;
unset rvm_env_string rvm_ruby_string rvm_action rvm_irbrc_file rvm_command rvm_error_message rvm_force_flag rvm_all_flag rvm_reconfigure_flag rvm_bin_flag rvm_import_flag rvm_export_flag rvm_self_flag rvm_gem_flag rvm_rubygems_flag rvm_debug_flag rvm_delete_flag rvm_summary_flag rvm_test_flag _rvm_spec_flag rvm_json_flag rvm_yaml_flag rvm_shebang_flag rvm_env_flag rvm_tail_flag rvm_use_flag rvm_dir_flag rvm_list_flag rvm_empty_flag rvm_file_name rvm_benchmark_flag rvm_clear_flag rvm_name_flag rvm_verbose_flag rvm_user_flag rvm_system_flag rvm_uninstall_flag rvm_install_flag rvm_llvm_flag rvm_ruby_bits rvm_sticky_flag rvm_rvmrc_flag rvm_gems_flag rvm_only_path_flag rvm_docs_flag rvm_dump_environment_flag rvm_ruby_alias rvm_static_flag rvm_archive_extension rvm_hook rvm_ruby_name rvm_remote_flag;
__rvm_load_rvmrc
}
__rvm_cleanup_tmp ()
{
if [[ -d "${rvm_tmp_path}/" ]]; then
case "${rvm_tmp_path%\/}" in
*tmp)
__rvm_rm_rf "${rvm_tmp_path}/${1:-$$}*"
;;
esac;
fi;
return 0
}
__rvm_conditionally_add_bin_path ()
{
[[ ":${PATH}:" =~ ":${rvm_bin_path}:" ]] || {
case "${rvm_ruby_string:-"system"}" in
system)
PATH="$PATH:${rvm_bin_path}"
;;
*)
PATH="${rvm_bin_path}:$PATH"
;;
esac;
builtin hash -r
}
}
__rvm_conditionally_do_with_env ()
{
if (( __rvm_env_loaded > 0 )); then
"$@";
else
__rvm_do_with_env "$@";
fi
}
__rvm_curl ()
{
( __rvm_which curl > /dev/null || {
rvm_error "RVM requires 'curl'. Install 'curl' first and try again.";
return 200
};
typeset -a __flags;
__flags=(--fail --location --max-redirs 10);
if [[ -n "${rvm_proxy:-}" ]]; then
__flags+=(--proxy "${rvm_proxy:-}");
fi;
__rvm_curl_output_control;
unset curl;
__rvm_debug_command \curl "${__flags[@]}" "$@" || return $? )
}
__rvm_curl_output_control ()
{
if (( ${rvm_quiet_curl_flag:-0} == 1 )); then
__flags+=("--silent" "--show-error");
else
if [[ " $*" =~ " -s" || " $*" =~ " --silent" ]]; then
[[ " $*" =~ " -S" || " $*" =~ " -sS" || " $*" =~ " --show-error" ]] || {
__flags+=("--show-error")
};
fi;
fi
}
__rvm_current_gemcache_dir ()
{
if __rvm_using_gemset_globalcache; then
echo "$rvm_gems_cache_path";
else
echo "${rvm_ruby_gem_home:-"$GEM_HOME"}/cache";
fi;
return 0
}
__rvm_current_gemset ()
{
typeset current_gemset;
current_gemset="${GEM_HOME:-}";
current_gemset="${current_gemset##*${rvm_gemset_separator:-@}}";
if [[ "${current_gemset}" == "${GEM_HOME:-}" ]]; then
echo '';
else
echo "${current_gemset}";
fi
}
__rvm_custom_separated_array ()
{
typeset IFS;
IFS=$2;
if [[ -n "${ZSH_VERSION:-}" ]]; then
eval "$1+=( \${=3} )";
else
eval "$1+=( \$3 )";
fi
}
__rvm_db ()
{
typeset value key variable;
key=${1:-""};
key=${key#go};
variable=${2:-""};
if [[ -f "$rvm_user_path/db" ]]; then
value="$("$rvm_scripts_path/db" "$rvm_user_path/db" "$key")";
fi;
if [[ -z "$value" ]]; then
value="$("$rvm_scripts_path/db" "$rvm_path/config/db" "$key")";
fi;
if [[ -n "$value" ]]; then
if [[ -z "$variable" ]]; then
echo $value;
else
eval "$variable='$value'";
fi;
fi;
return 0
}
__rvm_debug_command ()
{
rvm_debug "Running($#): $*";
"$@" || return $?
}
__rvm_default_flags ()
{
true ${rvm_head_flag:=0} ${rvm_delete_flag:=0}
}
__rvm_detect_system ()
{
unset _system_type _system_name _system_version _system_arch;
export _system_type _system_name _system_version _system_arch;
_system_type="unknown";
_system_name="unknown";
_system_version="unknown";
_system_arch="$(uname -m)";
case "$(uname)" in
Linux | GNU*)
_system_type="linux";
if [[ -f /etc/lsb-release ]] && __rvm_grep "DISTRIB_ID=Ubuntu" /etc/lsb-release > /dev/null; then
_system_name="ubuntu";
_system_version="$(awk -F'=' '$1=="DISTRIB_RELEASE"{print $2}' /etc/lsb-release)";
_system_arch="$( dpkg --print-architecture )";
else
if [[ -f /etc/lsb-release ]] && __rvm_grep "DISTRIB_ID=LinuxMint" /etc/lsb-release > /dev/null; then
_system_name="mint";
_system_version="$(awk -F'=' '$1=="DISTRIB_RELEASE"{print $2}' /etc/lsb-release)";
_system_arch="$( dpkg --print-architecture )";
else
if [[ -f /etc/lsb-release ]] && __rvm_grep "DISTRIB_ID=ManjaroLinux" /etc/lsb-release > /dev/null; then
_system_name="manjaro";
_system_version="$(awk -F'=' '$1=="DISTRIB_RELEASE"{print $2}' /etc/lsb-release)";
else
if [[ -f /etc/os-release ]] && __rvm_grep "ID=opensuse" /etc/os-release > /dev/null; then
_system_name="opensuse";
_system_version="$(awk -F'=' '$1=="VERSION_ID"{gsub(/"/,"");print $2}' /etc/os-release)";
else
if [[ -f /etc/SuSE-release ]]; then
_system_name="suse";
_system_version="$(
__rvm_awk -F'=' '{gsub(/ /,"")} $1~/VERSION/ {version=$2} $1~/PATCHLEVEL/ {patch=$2} END {print version"."patch}' < /etc/SuSE-release
)";
else
if [[ -f /etc/debian_version ]]; then
_system_name="debian";
_system_version="$(\cat /etc/debian_version | __rvm_awk -F. '{print $1}')";
_system_arch="$( dpkg --print-architecture )";
else
if [[ -f /etc/os-release ]] && __rvm_grep "ID=debian" /etc/os-release > /dev/null; then
_system_name="debian";
_system_version="$(awk -F'=' '$1=="VERSION_ID"{gsub(/"/,"");print $2}' /etc/os-release | __rvm_awk -F. '{print $1}')";
_system_arch="$( dpkg --print-architecture )";
else
if [[ -f /etc/fedora-release ]]; then
_system_name="fedora";
_system_version="$(__rvm_grep -Eo '[[:digit:]]+' /etc/fedora-release)";
else
if [[ -f /etc/centos-release ]]; then
_system_name="centos";
_system_version="$(__rvm_grep -Eo '[[:digit:]\.]+' /etc/centos-release | __rvm_awk -F. '{print $1}')";
else
if [[ -f /etc/redhat-release ]]; then
if __rvm_grep -E 'CentOS|ClearOS' /etc/redhat-release > /dev/null; then
_system_name="centos";
else
_system_name="redhat";
fi;
_system_version="$(__rvm_grep -Eo '[[:digit:]\.]+' /etc/redhat-release | __rvm_awk -F. '{print $1}')";
else
if [[ -f /etc/system-release ]] && __rvm_grep "Amazon Linux AMI" /etc/system-release > /dev/null; then
_system_name="amazon";
_system_version="$(__rvm_grep -Eo '[[:digit:]\.]+' /etc/system-release | __rvm_awk -F. '{print $1"."$2}')";
else
if [[ -f /etc/sabayon-release ]]; then
_system_name="sabayon";
_system_version="$(\cat /etc/sabayon-release | __rvm_awk 'NR==1 {print $NF}' | __rvm_awk -F. '{print $1"."$2}')";
else
if [[ -f /etc/gentoo-release ]]; then
_system_name="gentoo";
_system_version="base-$(\cat /etc/gentoo-release | __rvm_awk 'NR==1 {print $NF}' | __rvm_awk -F. '{print $1"."$2}')";
else
if [[ -f /etc/arch-release ]]; then
_system_name="arch";
_system_version="libc-$(ldd --version | __rvm_awk 'NR==1 {print $NF}' | __rvm_awk -F. '{print $1"."$2}')";
else
_system_version="libc-$(ldd --version | __rvm_awk 'NR==1 {print $NF}' | __rvm_awk -F. '{print $1"."$2}')";
fi;
fi;
fi;
fi;
fi;
fi;
fi;
fi;
fi;
fi;
fi;
fi;
fi;
fi
;;
SunOS)
_system_type="sunos";
_system_name="solaris";
_system_version="$(uname -v)";
if __rvm_string_match "${_system_version}" "joyent*"; then
_system_name="smartos";
_system_version="${_system_version#* }";
else
if __rvm_string_match "${_system_version}" "oi*"; then
_system_name="openindiana";
_system_version="${_system_version#* }";
fi;
fi
;;
OpenBSD)
_system_type="bsd";
_system_name="openbsd";
_system_version="$(uname -r)"
;;
Darwin)
_system_type="darwin";
_system_name="osx";
_system_version="$(sw_vers -productVersion | __rvm_awk -F. '{print $1"."$2}')"
;;
FreeBSD)
_system_type="bsd";
_system_name="freebsd";
_system_version="$(uname -r)";
_system_version="${_system_version%%-*}"
;;
DragonFly)
_system_type="bsd";
_system_name="dragonfly";
_system_version="$(uname -r)";
_system_version="${_system_version%%-*}"
;;
*)
return 1
;;
esac;
_system_type="${_system_type//[ \/]/_}";
_system_name="${_system_name//[ \/]/_}";
_system_version="${_system_version//[ \/]/_}";
_system_arch="${_system_arch//[ \/]/_}";
_system_arch="${_system_arch/amd64/x86_64}";
_system_arch="${_system_arch/i[123456789]86/i386}"
}
__rvm_detect_xcode_version ()
{
typeset version_file;
for version_file in /Applications/Xcode.app/Contents/version.plist /Developer/Applications/Xcode.app/Contents/version.plist;
do
if [[ -f $version_file ]]; then
if [[ -x /usr/libexec/PlistBuddy ]]; then
/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" $version_file;
else
__rvm_sed -n '/<key>CFBundleShortVersionString<\/key>/{n; s/^.*>\(.*\)<.*$/\1/; p;}' < $version_file;
fi;
return 0;
fi;
done;
if builtin command -v xcodebuild > /dev/null; then
xcodebuild -version | __rvm_sed -n '/Xcode/ {s/Xcode //; p;}';
return 0;
fi;
return 1
}
__rvm_detect_xcode_version_at_least ()
{
typeset __xcode_version="$(__rvm_detect_xcode_version)";
[[ -n "$__xcode_version" ]] || return 0;
__rvm_version_compare "$__xcode_version" -ge "$1" || return $?;
true
}
__rvm_display_rvmrc ()
{
typeset _rvmrc_base;
_rvmrc_base="$(basename "${_rvmrc}")";
__rvm_table <<-TEXT
The contents of the ${_rvmrc_base} file will now be displayed.
After reading the file, you will be prompted again for 'yes or no' to set the trust level for this particular version of the file.
Note: You will be re-prompted each time the ${_rvmrc_base} file's contents change
changes, and may change the trust setting manually at any time.
TEXT
__rvm_wait_anykey "(( press a key to review the ${_rvmrc_base} file ))";
printf "%b" "${rvm_warn_clr}";
command cat -v "${_rvmrc}";
printf "%b" "${rvm_reset_clr}";
__rvm_table "Viewing of ${_rvmrc} complete." <<-TEXT
Trusting an ${_rvmrc_base} file means that whenever you cd into this directory, RVM will run this ${_rvmrc_base} shell script.
Note that if the contents of the file change, you will be re-prompted to review the file and adjust its trust settings. You may also change the trust settings manually at any time with the 'rvm rvmrc' command.
TEXT
}
__rvm_do_with_env ()
{
typeset result;
__rvm_do_with_env_before;
"$@";
result=$?;
__rvm_do_with_env_after;
return ${result:-0}
}
__rvm_do_with_env_after ()
{
__rvm_teardown
}
__rvm_do_with_env_before ()
{
if [[ -n "${rvm_scripts_path:-}" || -n "${rvm_path:-}" ]]; then
source "${rvm_scripts_path:-"$rvm_path/scripts"}/initialize";
__rvm_setup;
fi
}
__rvm_dotted ()
{
typeset flush __show_nth_dot;
__show_nth_dot=${rvm_show_every_nth_dot:-1};
unset rvm_show_every_nth_dot;
if (( __show_nth_dot == 1 )); then
__show_nth_dot="";
else
__show_nth_dot="if (NR%${__show_nth_dot}==1)";
fi;
if __rvm_awk '{fflush;}' <<< EO 2> /dev/null; then
flush=fflush;
else
flush=flush;
fi;
if (( $# )); then
__rvm_awk 'BEGIN{printf "'"${rvm_notify_clr:-}$*${rvm_reset_clr:-}"'";} {'"$__show_nth_dot"' printf "."; '$flush'} END{print ""}';
else
__rvm_awk '{printf "."; '$flush';} END{if (NR>0) print ""}';
fi
}
__rvm_dotted_run ()
{
typeset __message="$1";
shift;
if [[ -n "${ZSH_VERSION:-}" ]]; then
rvm_log "${__message} - using Zsh, can not show progress, be patient...";
"$@" > "${__log_file}" 2>&1 || return $?;
else
"$@" | tee -a "${__log_file}" | __rvm_dotted "${__message}";
__rvm_check_pipestatus ${PIPESTATUS[@]} ${pipestatus[@]} || return $?;
fi
}
__rvm_ensure_has_environment_files ()
{
typeset environment_id file_name directory identifier variable value variables;
environment_id="$(__rvm_env_string)";
file_name="${rvm_environments_path}/$environment_id";
if [[ ! -d "$rvm_environments_path" ]]; then
\mkdir -p "$rvm_environments_path";
fi;
if [[ ! -s "$file_name" ]] || ! __rvm_grep 'rvm_env_string=' "$file_name" > /dev/null; then
\rm -f "$file_name";
printf "%b" "export PATH ; PATH=\"${rvm_ruby_gem_home}/bin:${rvm_ruby_global_gems_path}/bin:${rvm_ruby_home}/bin:${rvm_bin_path}:\$PATH\"\n" > "$file_name";
for variable in rvm_env_string rvm_path rvm_ruby_string rvm_gemset_name RUBY_VERSION GEM_HOME GEM_PATH MY_RUBY_HOME IRBRC MAGLEV_HOME RBXOPT;
do
eval "export $variable";
eval "value=\${${variable}:-""}";
if [[ -n "$value" ]]; then
printf "export %b ; %b='%b'\n" "${variable}" "${variable}" "${value}" >> "$file_name";
else
printf "unset %b\n" "${variable}" >> "$file_name";
fi;
done;
fi;
if (( ${rvm_create_default_wrappers:=0} == 1 )) || [[ ! -f "$rvm_wrappers_path/$environment_id/ruby" ]]; then
for identifier in "$environment_id" "${environment_id//@*/}@global";
do
rvm_create_default_wrappers=1;
directory="$rvm_wrappers_path/$identifier";
if [[ ! -L "$directory" && ! -d "$directory" ]]; then
\mkdir -p "$directory";
"$rvm_scripts_path/wrapper" "$identifier" &>/dev/null;
fi;
done;
rvm_create_default_wrappers=0;
fi;
return 0
}
__rvm_ensure_is_a_function ()
{
if [[ ${rvm_reload_flag:=0} == 1 ]] || ! is_a_function rvm; then
for script in version selector selector_gemsets cd cli override_gem;
do
if [[ -f "$rvm_scripts_path/$script" ]]; then
source "$rvm_scripts_path/$script";
else
printf "%b" "WARNING:
Could not source '$rvm_scripts_path/$script' as file does not exist.
RVM will likely not work as expected.\n";
fi;
done;
fi
}
__rvm_env_string ()
{
typeset _path _string;
_path="${GEM_HOME:-""}";
_string="${_path//*gems\//}";
_string="${_string//\/*/}";
printf "%b" "${_string:-system}\n"
}
__rvm_every_nth_dot ()
{
typeset result=0;
export rvm_show_every_nth_dot=$1;
shift;
"$@" || result=$?;
unset rvm_show_every_nth_dot;
return $result
}
__rvm_expand_ruby_string ()
{
typeset string current_ruby;
string="$1";
case "${string:-all}" in
all)
"$rvm_scripts_path/list" strings | \tr ' ' "\n"
;;
all-gemsets)
"$rvm_scripts_path/list" gemsets strings
;;
default-with-rvmrc | rvmrc)
"$rvm_scripts_path/tools" path-identifier "$PWD"
;;
all-rubies | rubies)
"$rvm_scripts_path/list" rubies strings
;;
current-ruby | gemsets)
current_ruby="$(__rvm_env_string)";
current_ruby="${current_ruby%@*}";
rvm_silence_logging=1 "$rvm_scripts_path/gemsets" list strings | __rvm_sed "s/ (default)//; s/^/$current_ruby${rvm_gemset_separator:-@}/ ; s/@default// ;"
;;
current)
__rvm_env_string
;;
aliases)
__rvm_awk -F= '{print $string}' < "$rvm_path/config/alias"
;;
*)
__rvm_ruby_strings_exist $( echo "$string" | \tr "," "\n" | __rvm_strip )
;;
esac
}
__rvm_export ()
{
typeset name;
name=${1%%\=*};
builtin export rvm_old_$name=${!name};
export "$@";
return $?
}
__rvm_find ()
{
\find "$@" || return $?
}
__rvm_find_first_file ()
{
typeset _first_file _variable_first_file __file_enum;
_first_file="";
_variable_first_file="$1";
shift;
for __file_enum in "$@";
do
if [[ -f "$__file_enum" ]]; then
eval "$_variable_first_file=\"\$__file_enum\"";
return 0;
fi;
done;
eval "$_variable_first_file=\"\"";
return 1
}
__rvm_fix_group_permissions ()
{
if umask -S | __rvm_grep 'g=rw' > /dev/null; then
chmod -R g+rwX "$@";
fi
}
__rvm_fix_path_from_gem_path ()
{
[[ -n "${GEM_PATH:-}" ]] || return 0;
export PATH;
typeset IFS _iterator_path;
typeset -a _gem_path _new_path;
IFS=:;
_gem_path=();
_new_path=();
__rvm_custom_separated_array _gem_path : "${GEM_PATH}";
for _iterator_path in "${_gem_path[@]}";
do
_new_path+=("${_iterator_path}/bin");
done;
_new_path+=("${MY_RUBY_HOME:-${GEM_HOME/gems/rubies}}/bin");
_new_path+=("${rvm_bin_path}");
PATH="${_new_path[*]}:$PATH";
builtin hash -r
}
__rvm_fix_selected_ruby ()
{
typeset __ret=0;
if (( $# )); then
"$@" || __ret=$?;
fi;
[[ -d "$GEM_HOME" && -d "$MY_RUBY_HOME" ]] || {
if [[ -d ${MY_RUBY_HOME%/*}/defaul ]]; then
__rvm_use default;
else
__rvm_use system;
fi
}
}
__rvm_fold ()
{
if fold -s -w 10 <<< bla > /dev/null; then
fold -s -w $1;
else
fold -w $1;
fi
}
__rvm_gemset_clear ()
{
export rvm_gemset_name;
rvm_gemset_name="";
__rvm_use
}
__rvm_gemset_handle_default ()
{
rvm_gemset_name="@${rvm_gemset_name:-}@";
rvm_gemset_name="${rvm_gemset_name/@default@/@@}";
rvm_gemset_name="${rvm_gemset_name#@}";
rvm_gemset_name="${rvm_gemset_name%@}"
}
__rvm_gemset_pristine ()
{
__rvm_log_command "gemset.pristine-$1" "Making gemset $1 pristine." __rvm_with "$1" "$rvm_scripts_path/gemsets" pristine
}
__rvm_gemset_select ()
{
__rvm_gemset_select_only && __rvm_gemset_select_validation && __rvm_gemset_select_ensure
}
__rvm_gemset_select_cli ()
{
__rvm_gemset_select_cli_validation && __rvm_gemset_select
}
__rvm_gemset_select_cli_validation ()
{
typeset orig_gemset;
if ! builtin command -v gem > /dev/null; then
rvm_log "'gem' command not found, cannot select a gemset.";
return 0;
fi;
orig_gemset="${rvm_gemset_name:-}";
__rvm_gemset_handle_default;
if [[ -z "${rvm_gemset_name:-}" && "$orig_gemset" != "default" && ${rvm_sticky_flag:-0} -eq 1 ]]; then
if [[ -n "${rvm_ruby_gem_home:-}" ]]; then
rvm_gemset_name="$rvm_ruby_gem_home";
else
if [[ -n "${GEM_HOME:-}" ]]; then
rvm_gemset_name="$GEM_HOME";
fi;
fi;
rvm_gemset_name="${rvm_gemset_name##*/}";
rvm_gemset_name="${rvm_gemset_name#*${rvm_gemset_separator:-"@"}}";
fi;
if [[ -z "${rvm_ruby_string:-}" && -n "${GEM_HOME:-}" && -n "${GEM_HOME%@*}" ]]; then
rvm_ruby_string="${GEM_HOME%@*}";
rvm_ruby_string="${rvm_ruby_string##*/}";
fi;
if [[ -z "${rvm_ruby_string:-}" ]]; then
rvm_error "Gemsets can not be used with non rvm controlled rubies (currently).";
return 3;
fi
}
__rvm_gemset_select_ensure ()
{
\mkdir -p "$rvm_ruby_gem_home";
if __rvm_using_gemset_globalcache && [[ ! -L "$rvm_ruby_gem_home/cache" ]]; then
: rvm_gems_cache_path:${rvm_gems_cache_path:=${rvm_gems_path:-"$rvm_path/gems"}/cache};
\mv "$rvm_ruby_gem_home/cache/"*.gem "$rvm_gems_cache_path/" 2> /dev/null;
__rvm_rm_rf "$rvm_ruby_gem_home/cache";
\ln -fs "$rvm_gems_cache_path" "$rvm_ruby_gem_home/cache";
fi
}
__rvm_gemset_select_only ()
{
rvm_ruby_gem_home="${rvm_gems_path:-"$rvm_path/gems"}/$rvm_ruby_string";
: rvm_ignore_gemsets_flag:${rvm_ignore_gemsets_flag:=0}:;
if (( rvm_ignore_gemsets_flag )); then
rvm_ruby_global_gems_path="${rvm_ruby_gem_home}";
rvm_ruby_gem_path="${rvm_ruby_gem_home}";
rvm_gemset_name="";
else
rvm_ruby_global_gems_path="${rvm_ruby_gem_home}${rvm_gemset_separator:-"@"}global";
__rvm_gemset_handle_default;
[[ -z "$rvm_gemset_name" ]] || rvm_ruby_gem_home="${rvm_ruby_gem_home}${rvm_gemset_separator:-"@"}${rvm_gemset_name}";
if [[ "$rvm_gemset_name" == "global" ]]; then
rvm_ruby_gem_path="${rvm_ruby_gem_home}";
else
rvm_ruby_gem_path="${rvm_ruby_gem_home}:${rvm_ruby_global_gems_path}";
fi;
fi;
if [[ -n "${rvm_gemset_name}" ]]; then
rvm_env_string="${rvm_ruby_string}@${rvm_gemset_name}";
else
rvm_env_string=${rvm_ruby_string};
fi;
true
}
__rvm_gemset_select_validation ()
{
if [[ ! -d "${rvm_ruby_gem_home}" ]]; then
if (( ${rvm_gemset_create_on_use_flag:=0} == 0 && ${rvm_create_flag:=0} == 0 && ${rvm_delete_flag:=0} == 0 )); then
rvm_expected_gemset_name="${rvm_gemset_name}";
rvm_gemset_name="";
__rvm_gemset_select_only;
return 2;
fi;
else
if (( ${rvm_delete_flag:=0} == 1 )); then
return 4;
fi;
fi;
case "${rvm_gemset_name}" in
*/*)
rvm_error "Gemsets can not contain path separator '/'.";
return 5
;;
*:*)
rvm_error "Gemsets can not contain PATH separator ':'.";
return 5
;;
esac;
typeset rvm_ruby_gem_home_254;
if [[ -n "${ZSH_VERSION:-}" ]]; then
rvm_ruby_gem_home_254="${rvm_ruby_gem_home[0,254]}";
else
rvm_ruby_gem_home_254="${rvm_ruby_gem_home:0:254}";
fi;
if [[ "${rvm_ruby_gem_home}" != "${rvm_ruby_gem_home_254}" ]]; then
rvm_error "Gemset gem home to long ${#rvm_ruby_gem_home}.";
return 6;
fi
}
__rvm_gemset_use ()
{
if __rvm_gemset_select_cli; then
rvm_log "Using $rvm_ruby_string with gemset ${rvm_gemset_name:-default}";
__rvm_use;
else
if [[ ! -d "$rvm_ruby_gem_home" || -n "${rvm_expected_gemset_name}" ]]; then
if (( ${rvm_gemset_create_on_use_flag:=0} == 1 || ${rvm_create_flag:=0} == 1 )); then
rvm_warn "gemset $rvm_gemset_name is not existing, creating.";
"$rvm_scripts_path/gemsets" create "$rvm_gemset_name";
else
rvm_error "Gemset '${rvm_expected_gemset_name}' does not exist, 'rvm $rvm_ruby_string do rvm gemset create ${rvm_expected_gemset_name}' first, or append '--create'.";
return 2;
fi;
else
rvm_error "Gemset was not given.\n Usage:\n rvm gemset use <gemsetname>\n";
return 1;
fi;
fi
}
__rvm_gemsets_initial ()
{
if (( ${rvm_skip_gemsets_flag:-0} == 0 )); then
__rvm_log_command "gemsets.initial" "$rvm_ruby_string - #importing default gemsets, this may take time" __rvm_with "$rvm_ruby_string" "$rvm_scripts_path/gemsets" initial;
else
mkdir -p "$rvm_gems_path/$rvm_ruby_string/bin" "$rvm_gems_path/$rvm_ruby_string@global/bin";
rvm_log "Skipped importing default gemsets";
fi
}
__rvm_generate_wrappers ()
{
"$rvm_scripts_path/wrapper" "$rvm_ruby_string" --no-links --all
}
__rvm_get_user_shell ()
{
case "$(uname)" in
*BSD | Linux | SunOS | DragonFly)
__rvm_awk -F: "/$USER/"'{print $NF}' < /etc/passwd || {
rvm_error "Error checking user shell via /etc/passwd - make sure this file is world readable.";
return 2
}
;;
Darwin)
typeset __version;
__version="$(dscl localhost -read "/Local/Default/Users/$USER" shell)" || {
rvm_error "Error checking user shell via dscl ... something went wrong, report a bug.";
return 3
};
echo ${__version#*: }
;;
*)
rvm_error "Do not know how to check user shell on '$(uname)'.";
return 1
;;
esac
}
__rvm_grep ()
{
GREP_OPTIONS="" \grep "$@" || return $?
}
__rvm_has_opt ()
{
if [[ -n "${ZSH_VERSION}" ]] && setopt | GREP_OPTIONS="" \grep "^${1}$" > /dev/null 2>&1; then
return 0;
else
if [[ -n "${BASH_VERSION}" ]] && [[ ":$SHELLOPTS:" =~ ":${1}:" ]]; then
return 0;
else
return 1;
fi;
fi
}
__rvm_initialize ()
{
true ${rvm_scripts_path:="$rvm_path/scripts"};
source "$rvm_scripts_path/base";
__rvm_clean_path;
__rvm_conditionally_add_bin_path;
export PATH;
if [[ ! -d "${rvm_tmp_path:-/tmp}" ]]; then
command mkdir -p "${rvm_tmp_path}";
fi;
return 0
}
__rvm_join_array ()
{
typeset IFS;
IFS="$2";
eval "$1=\"\${$3[*]}\""
}
__rvm_load_environment ()
{
typeset string __hook;
string="$1";
if [[ -f "$rvm_environments_path/$string" ]]; then
__rvm_remove_rvm_from_path;
\. "$rvm_environments_path/$string";
for __hook in "${rvm_path:-$HOME/.rvm}/hooks/after_use"*;
do
if [[ -f "${__hook}" && -x "${__hook}" && -s "${__hook}" ]]; then
\. "${__hook}" || true;
fi;
done;
builtin hash -r;
else
if [[ -n "$string" ]]; then
rvm "$string";
else
:;
fi;
fi
}
__rvm_load_project_config ()
{
typeset __gemfile __gem_names _gem _bundle_install __env_vars_prefix __env_vars_file;
__gemfile="";
__gem_names="";
__env_vars_file="";
: rvm_autoinstall_bundler_flag:${rvm_autoinstall_bundler_flag:=0};
case "$1" in
*/.rvmrc)
__rvmrc_warning_display_for_rvmrc "$1";
if __rvm_check_rvmrc_trustworthiness "$1"; then
__rvm_remove_rvm_from_path;
__rvm_conditionally_add_bin_path;
rvm_previous_environment="$(__rvm_env_string)";
rvm_current_rvmrc="$1";
__rvm_ensure_is_a_function;
unset GEM_HOME GEM_PATH;
rvm_ruby_string="${rvm_previous_environment/system/default}" rvm_action=use source "$1";
else
return $?;
fi
;;
*/.versions.conf)
__rvm_ensure_is_a_function;
rvm_previous_environment="$(__rvm_env_string)";
rvm_current_rvmrc="$1";
rvm_ruby_string="$( \tr -d '\r' <"$1" | __rvm_sed -n '/^ruby=/ {s/ruby=//;p;}' )";
[[ -n "${rvm_ruby_string}" ]] || return 2;
rvm_gemset_name="$( \tr -d '\r' <"$1" | __rvm_sed -n '/^ruby-gemset=/ {s/ruby-gemset=//;p;}' )";
rvm_create_flag=1 __rvm_use || return 3;
__env_vars_prefix="env-";
__env_vars_file="$1";
__gem_names="$( \tr -d '\r' <"$1" | __rvm_sed -n '/^ruby-gem-install=/ {s/ruby-gem-install=//;p;}' )";
if [[ -z "${__gem_names:-}" ]]; then
__gem_names=bundler;
else
if [[ ! ",${__gem_names:-}," =~ ",bundler," ]]; then
__gem_names="${__gem_names:-},bundler";
fi;
fi;
_bundle_install="$( \tr -d '\r' <"$1" | __rvm_sed -n '/^ruby-bundle-install=/ {s/ruby-bundle-install=//;p;}' )";
if [[ -n "${_bundle_install}" ]] || [[ "${rvm_autoinstall_bundler_flag:-0}" == 1 ]]; then
if [[ "${_bundle_install}" == true ]]; then
__gemfile="${1%/*}/Gemfile";
else
if [[ -f "${_bundle_install}" ]]; then
__gemfile="${_bundle_install}";
else
if [[ "${rvm_autoinstall_bundler_flag:-0}" == 1 ]]; then
__gemfile="${1%/*}/Gemfile";
fi;
fi;
fi;
fi
;;
*/Gemfile)
__rvm_ensure_is_a_function;
rvm_previous_environment="$(__rvm_env_string)";
rvm_current_rvmrc="$1";
rvm_ruby_string="$( \tr -d '\r' <"$1" | __rvm_sed -n '/^#ruby=/ {s/#ruby=//;p;}' )";
[[ -n "${rvm_ruby_string}" ]] || {
rvm_ruby_string="$( \tr -d '\r' <"$1" | __rvm_sed -n "s/ rescue nil$//; /^\s*ruby/ {s/^\s*ruby//; s/[ ()'\"]//g; p;}" )";
[[ -n "${rvm_ruby_string}" ]] || return 2
};
rvm_gemset_name="$( \tr -d '\r' <"$1" | __rvm_sed -n '/^#ruby-gemset=/ {s/#ruby-gemset=//;p;}' )";
__rvmrc_warning_display_for_Gemfile "$1";
rvm_create_flag=1 __rvm_use || return 3;
__env_vars_prefix="#ruby-env-";
__env_vars_file="$1";
if [[ "${rvm_autoinstall_bundler_flag:-0}" == "1" ]]; then
__gemfile="$1";
__gem_names=bundler;
fi
;;
*/.ruby-version | */.rbfu-version | */.rbenv-version)
__rvm_ensure_is_a_function;
rvm_previous_environment="$(__rvm_env_string)";
rvm_current_rvmrc="$1";
rvm_ruby_string="$( \tr -d '\r' <"$1" )";
[[ -n "${rvm_ruby_string}" ]] || return 2;
if [[ -f "${1%/*}/.ruby-gemset" ]]; then
rvm_gemset_name="$( \tr -d '\r' <"${1%/*}/.ruby-gemset" )";
fi;
rvm_create_flag=1 __rvm_use || return 3;
if [[ -f "${1%/*}/.ruby-env" ]]; then
__env_vars_prefix="";
__env_vars_file="${1%/*}/.ruby-env";
else
if [[ -f "${1%/*}/.rbenv-vars" ]]; then
__env_vars_prefix="";
__env_vars_file="${1%/*}/.rbenv-vars";
fi;
fi;
if [[ "${rvm_autoinstall_bundler_flag:-0}" == 1 && -f "${1%/*}/Gemfile" ]]; then
__gemfile="${1%/*}/Gemfile";
__gem_names=bundler;
fi
;;
*)
rvm_error "Unsupported file format for '$1'";
return 1
;;
esac;
if [[ -n "${__env_vars_file:-}" && -f "${__env_vars_file:-}" ]]; then
__rvm_project_ruby_env_load "${__env_vars_file:-}" "${__env_vars_prefix:-}";
fi;
for _gem in ${__gem_names//,/ };
do
gem list | __rvm_grep "^${_gem} " > /dev/null || gem install "${_gem}";
done;
if [[ -n "${__gemfile:-}" && -f "${__gemfile:-}" ]]; then
bundle install --gemfile="${__gemfile}" | __rvm_grep -vE '^Using|Your bundle is complete';
fi
}
__rvm_load_rvmrc ()
{
typeset _file;
typeset -a rvm_rvmrc_files;
if (( ${rvm_ignore_rvmrc:=0} == 1 )); then
return 0;
fi;
[[ -n "${rvm_stored_umask:-}" ]] || export rvm_stored_umask=$(umask);
rvm_rvmrc_files=("/etc/rvmrc" "$HOME/.rvmrc");
if [[ -n "${rvm_prefix:-}" ]] && ! [[ "$HOME/.rvmrc" -ef "${rvm_prefix}/.rvmrc" ]]; then
rvm_rvmrc_files+=("${rvm_prefix}/.rvmrc");
fi;
for _file in "${rvm_rvmrc_files[@]}";
do
if [[ -s "$_file" ]]; then
if __rvm_grep '^\s*rvm .*$' "$_file" > /dev/null 2>&1; then
rvm_error "
$_file is for rvm settings only.
rvm CLI may NOT be called from within $_file.
Skipping the loading of $_file
";
return 1;
else
source "$_file";
fi;
fi;
done;
return 0
}
__rvm_log_command ()
{
typeset name message _log _command_start _command_name;
typeset -a _command;
name="${1:-}";
message="${2:-}";
shift 2;
_command=("$@");
_command_start="$1";
while (( $# )) && [[ "$1" =~ "=" ]]; do
shift;
done;
_command_name="$1";
[[ ! "${_command_start}" =~ "=" ]] || _command=("env" "${_command[@]}");
(( ${rvm_niceness:-0} == 0 )) || _command=(nice -n $rvm_niceness "${_command[@]}");
__rvm_log_command_caclulate_log_file_name;
rvm_debug "Log file: ${_log}";
[[ -d "${_log%\/*}" ]] || \mkdir -p "${_log%\/*}";
[[ -f "${_log}" ]] || \rm -f "${_log}";
{
printf "%b" "[$(date +'%Y-%m-%d %H:%M:%S')] ${_command_name}\n";
if is_a_function "${_command_name}"; then
typeset -f "${_command_name}";
fi;
printf "%b" "current path: $PWD\n";
printf "%b" "command(${#_command[@]}): ${_command[*]}\n"
} | tee "${_log}" | rvm_debug_stream;
__rvm_log_dotted "${_log}" "$message" "${_command[@]}" || {
typeset result=$?;
rvm_error "Error running '${_command[*]}',
please read ${_log}";
return ${result}
}
}
__rvm_log_command_caclulate_log_file_name ()
{
[[ -n "${rvm_log_timestamp:-}" ]] || __rvm_log_command_caclulate_log_timestamp;
[[ -n "${rvm_log_filesystem:-}" ]] || __rvm_log_command_caclulate_log_filesystem;
[[ -n "${rvm_log_namelen:-}" ]] || __rvm_log_command_caclulate_log_namelen;
name="${name//[ \/]/_}";
_log="${rvm_log_path}/${rvm_log_timestamp}${rvm_ruby_string:+_}${rvm_ruby_string:-}/${name}";
if [[ -n "${ZSH_VERSION:-}" ]]; then
_log="${_log[0,${rvm_log_namelen}]}.log";
else
_log="${_log:0:${rvm_log_namelen}}.log";
fi
}
__rvm_log_command_caclulate_log_filesystem ()
{
export rvm_log_filesystem="$(
mount | __rvm_awk -v rvm_path=$rvm_path '
BEGIN{longest=""; fstype=""}
{if (index(rvm_path,$3)==1 && length($3)>length(longest)){longest=$3; fstype=$5}}
END{print fstype}
'
)";
rvm_debug "Log filesystem: ${rvm_log_filesystem}"
}
__rvm_log_command_caclulate_log_namelen ()
{
case "${rvm_log_filesystem}" in
ecryptfs)
export rvm_log_namelen=138
;;
*)
export rvm_log_namelen=250
;;
esac;
rvm_debug "Log max name length: ${rvm_log_namelen}"
}
__rvm_log_command_caclulate_log_timestamp ()
{
export rvm_log_timestamp="$(date "+%s")";
rvm_debug "Log prefix: ${rvm_log_path}/${rvm_log_timestamp}${rvm_ruby_string:+_}${rvm_ruby_string:-}/"
}
__rvm_log_dotted ()
{
typeset __log_file __message __iterator;
__log_file="$1";
__message="$2";
shift 2;
if [[ -n "${ZSH_VERSION:-}" ]]; then
rvm_log "${__message} - using Zsh, can not show progress, be patient...";
"$@" > "${__log_file}" 2>&1 || return $?;
else
"$@" 2>&1 | tee -a "${__log_file}" | __rvm_dotted "${__message}";
__rvm_check_pipestatus ${PIPESTATUS[@]} ${pipestatus[@]} || return $?;
fi
}
__rvm_make ()
{
\make "$@" || return $?
}
__rvm_md5_calculate ()
{
typeset _sum;
if builtin command -v md5 > /dev/null 2>&1; then
_sum=$(md5 "$@");
echo ${_sum##* };
return 0;
else
if builtin command -v md5sum > /dev/null 2>&1; then
_sum=$(md5sum "$@");
echo ${_sum%% *};
return 0;
else
for _path in /usr/gnu/bin /sbin /bin /usr/bin /usr/sbin;
do
if [[ -x "${_path}/md5" ]]; then
_sum=$(${_path}/md5 "$@");
echo ${_sum##* };
return 0;
else
if [[ -x "${_path}/md5sum" ]]; then
_sum=$(${_path}/md5sum "$@");
echo ${_sum%% *};
return 0;
fi;
fi;
done;
fi;
fi;
rvm_error "Neither md5sum nor md5 found in the PATH";
return 1
}
__rvm_md5_for_contents ()
{
if builtin command -v md5 > /dev/null; then
md5 | __rvm_awk '{print $1}';
else
if builtin command -v md5sum > /dev/null; then
md5sum | __rvm_awk '{print $1}';
else
if builtin command -v openssl > /dev/null; then
openssl md5 | __rvm_awk '{print $1}';
else
return 1;
fi;
fi;
fi;
true
}
__rvm_meta ()
{
rvm_meta_author="Wayne E. Seguin";
rvm_meta_author_email="wayneeseguin@gmail.com";
rvm_meta_authors=("Wayne E. Seguin <wayneeseguin@gmail.com>" "Michal Papis <mpapis@gmail.com>");
rvm_meta_website="https://rvm.io/";
rvm_meta_version="${rvm_version}"
}
__rvm_nuke_rvm_variables ()
{
unset rvm_head_flag $(env | __rvm_awk -F= '/^rvm_/{print $1" "}')
}
__rvm_package_create ()
{
rvm_debug __rvm_package_create:$#: "$@";
case "$1" in
*.tar.bz2)
if [[ -z "${3:-}" ]]; then
${rvm_tar_command:-tar} cjf "$1" "$2";
else
${rvm_tar_command:-tar} cjf "$1" -C "$2" "$3";
fi
;;
*.tar.gz | *.tgz)
if [[ -z "${3:-}" ]]; then
${rvm_tar_command:-tar} czf "$1" "$2";
else
${rvm_tar_command:-tar} czf "$1" -C "$2" "$3";
fi
;;
*)
return 199
;;
esac
}
__rvm_package_extract ()
{
rvm_debug __rvm_package_extract:$#: "$@";
typeset __tempdir __path __file __return;
__return=0;
__tempdir="$( TMPDIR="${rvm_tmp_path}" mktemp -d -t rvm-tmp.XXXXXXXXX )";
__rvm_package_extract_run "$1" "$__tempdir" || __return=$?;
if (( __return == 0 )); then
for __path in "$__tempdir"/*;
do
__file="${__path##*/}";
if [[ -n "${__file}" && -e "$2/${__file}" ]]; then
\rm -rf "$2/${__file}" || __return=$?;
fi;
\mv -f "${__path}" "$2/" || __return=$?;
done;
fi;
if [[ -n "$__tempdir" ]]; then
\rm -rf "$__tempdir";
fi;
return $__return
}
__rvm_package_extract_run ()
{
[[ -d "$2" ]] || mkdir -p "$2";
case "$1" in
*.zip)
unzip -q -o "$1" -d "$2"
;;
*.tar.bz2)
if [[ -n "$ZSH_VERSION" ]]; then
${rvm_tar_command:-tar} xjf "$1" -C "$2" ${=rvm_tar_options:-};
else
${rvm_tar_command:-tar} xjf "$1" -C "$2" ${rvm_tar_options:-};
fi
;;
*.tar.gz | *.tgz)
if [[ -n "$ZSH_VERSION" ]]; then
${rvm_tar_command:-tar} xzf "$1" -C "$2" ${=rvm_tar_options:-};
else
${rvm_tar_command:-tar} xzf "$1" -C "$2" ${rvm_tar_options:-};
fi
;;
*)
return 199
;;
esac && __rvm_fix_group_permissions "$2"/* || return $?
}
__rvm_package_list ()
{
rvm_debug __rvm_package_list:$#: "$@";
case "$1" in
*.zip)
unzip -Z -1 "$1"
;;
*.tar.bz2)
${rvm_tar_command:-tar} tjf "$1"
;;
*.tar.gz | *.tgz)
${rvm_tar_command:-tar} tzf "$1"
;;
*)
return 199
;;
esac
}
__rvm_pager_or_cat_v ()
{
eval "${PAGER:-\cat -v} '$1'"
}
__rvm_parse_args ()
{
typeset _string;
export rvm_ruby_string;
rvm_action="${rvm_action:-""}";
rvm_parse_break=0;
if [[ " $* " =~ " --trace " ]]; then
echo "$@";
__rvm_version;
fi;
while [[ -n "$next_token" ]]; do
rvm_token="$next_token";
if (( $# > 0 )); then
next_token="$1";
shift;
else
next_token="";
fi;
case "$rvm_token" in
[[:alnum:]]* | @*)
case "$rvm_token" in
use)
rvm_action="$rvm_token";
rvm_verbose_flag=1
;;
install | uninstall | reinstall | try_install)
export ${rvm_token}_flag=1;
rvm_action=$rvm_token
;;
gemset)
rvm_action=$rvm_token;
rvm_ruby_gem_home="${GEM_HOME:-""}";
rvm_ruby_args=();
__rvm_parse_args_find_known_flags rvm_ruby_args "$next_token" "$@";
: rvm_ruby_args:${#rvm_ruby_args[@]}:${rvm_ruby_args[*]}:;
next_token="${rvm_ruby_args[__array_start]}";
rvm_gemset_name="${rvm_ruby_args[__array_start+1]}";
case "${next_token:-help}" in
help)
true
;;
clear)
__rvm_gemset_clear
;;
use | delete)
[[ "delete" != "$next_token" ]] || rvm_delete_flag=1;
[[ "use" != "$next_token" ]] || rvm_action+="_$next_token";
case "$rvm_gemset_name" in
*${rvm_gemset_separator:-"@"}*)
rvm_ruby_string="${rvm_gemset_name%%${rvm_gemset_separator:-"@"}*}";
rvm_gemset_name="${rvm_gemset_name##*${rvm_gemset_separator:-"@"}}";
if [[ "${rvm_ruby_string:-""}" != "${rvm_gemset_name:-""}" ]]; then
rvm_ruby_string="$rvm_ruby_string${rvm_gemset_separator:-"@"}$rvm_gemset_name";
fi;
rvm_ruby_gem_home="$rvm_ruby_gem_home${rvm_gemset_separator:-"@"}$rvm_gemset_name"
;;
"")
rvm_error "Gemset was not given.\n Usage:\n rvm gemset $rvm_gemset_name <gemsetname>\n";
return 1
;;
esac
;;
esac;
rvm_parse_break=1
;;
gemdir | gempath | gemhome)
rvm_ruby_args=("$rvm_token");
rvm_action="gemset";
rvm_gemdir_flag=1;
if [[ "system" == "$next_token" ]]; then
rvm_system_flag=1;
next_token="${1:-}";
(( $# == 0 )) || shift;
fi;
if [[ "user" == "$next_token" ]]; then
rvm_user_flag=1;
next_token="${1:-}";
(( $# == 0 )) || shift;
fi
;;
pkg)
rvm_action="$rvm_token";
__rvm_parse_args_find_known_flags rvm_ruby_args "$next_token" "$@";
rvm_parse_break=1
;;
do | exec)
if [[ -z "$next_token" ]]; then
rvm_action="error";
rvm_error_message="'rvm $rvm_token' must be followed by arguments.";
break;
fi;
rvm_action="do";
rvm_ruby_args=("$next_token" "$@");
rvm_parse_break=1
;;
gem | rake | ruby)
[[ "$rvm_token" == "ruby" ]] && case $rvm_action in
install | reinstall | use | remove)
rvm_ruby_string=ruby;
rvm_ruby_strings=ruby;
continue
;;
esac;
rvm_action=error;
rvm_error_message="Please note that \`rvm $rvm_token ...\` was removed, try \`$rvm_token $next_token $*\` or \`rvm all do $rvm_token $next_token $*\` instead."
;;
fetch | version | srcdir | reset | debug | reload | update | monitor | notes | implode | seppuku | question | answer | env | unexport | automount | prepare)
rvm_action=$rvm_token
;;
doctor)
rvm_action=notes
;;
mount)
rvm_action=$rvm_token;
while [[ -n "${next_token:-}" ]] && [[ -x "${next_token:-}" || -d "${next_token:-}" || "${next_token:-}" =~ ^http || "${next_token:-}" =~ tar.bz2$ ]]; do
rvm_ruby_args=("$next_token" "${rvm_ruby_args[@]}");
next_token="${1:-}";
(( $# == 0 )) || shift;
done
;;
rm | remove)
rvm_action="remove";
rvm_remove_flag=1
;;
rtfm | RTFM | rvmrc | usage | help | inspect | list | ls | info | strings | get | current | docs | alias | rubygems | cleanup | tools | disk-usage | snapshot | repair | migrate | downgrade | upgrade | cron | group | switch | which | config-get | requirements | autolibs | osx-ssl-certs | fix-permissions)
case "$rvm_token" in
downgrade)
rvm_action="upgrade"
;;
ls)
rvm_action="list"
;;
usage)
rvm_action="help"
;;
RTFM)
rvm_action="rtfm"
;;
*)
rvm_action="$rvm_token"
;;
esac;
rvm_ruby_args=();
__rvm_parse_args_find_known_flags rvm_ruby_args "$next_token" "$@";
rvm_parse_break=1
;;
user)
rvm_action="tools";
rvm_ruby_args=("$rvm_token" "$next_token" "$@");
rvm_parse_break=1
;;
load-rvmrc)
rvm_action="rvmrc";
rvm_ruby_args=("load" "$next_token" "$@");
rvm_parse_break=1
;;
benchmark | bench)
rvm_action="benchmark"
;;
specs | tests)
rvm_action="rake";
rvm_ruby_args=("${rvm_token/%ss/s}")
;;
export)
if [[ -n "$next_token" ]]; then
rvm_export_args="$next_token$@";
rvm_action="export";
rvm_parse_break=1;
else
rvm_action="error";
rvm_error_message="rvm export must be followed by a NAME=VALUE argument";
fi
;;
alt*)
rvm_action="help";
rvm_ruby_args=("alt.md");
rvm_parse_break=1
;;
wrapper)
rvm_action="wrapper";
rvm_ruby_string="$next_token";
rvm_wrapper_name="$1";
(( $# == 0 )) || shift;
rvm_ruby_args=("$@");
rvm_parse_break=1
;;
reboot | damnit | wtf | argh | BOOM | boom | wth)
rvm_action="reboot"
;;
in)
rvm_token="${next_token}";
next_token="${1:-}";
(( $# == 0 )) || shift;
if __rvm_project_dir_check "$rvm_token"; then
export rvm_in_flag="$rvm_token";
__rvm_rvmrc_tools try_to_read_ruby $rvm_token;
else
export "rvm_in_flag"=1;
fi
;;
*,*)
rvm_ruby_strings="$rvm_token";
[[ -n "${rvm_action:-""}" ]] || rvm_action="ruby"
;;
${rvm_gemset_separator:-"@"}*)
rvm_action="${rvm_action:-use}";
rvm_gemset_name="${rvm_token/*${rvm_gemset_separator:-"@"}/}";
rvm_ruby_string="${rvm_ruby_string:-""}";
rvm_ruby_strings="${rvm_ruby_string}${rvm_gemset_separator:-"@"}${rvm_gemset_name}"
;;
*${rvm_gemset_separator:-"@"}*)
rvm_action="${rvm_action:-use}";
rvm_gemset_name="${rvm_token/*${rvm_gemset_separator:-"@"}/}";
rvm_ruby_string="$rvm_token";
rvm_ruby_strings="$rvm_token"
;;
*+*)
rvm_action="${rvm_action:-use}";
rvm_ruby_alias="${rvm_token/*+/}";
rvm_ruby_string="${rvm_token/+*/}";
rvm_ruby_strings="$rvm_ruby_string"
;;
*-* | +([[:digit:]]).+([[:digit:]])*)
rvm_action="${rvm_action:-use}";
rvm_ruby_string="$rvm_token";
rvm_ruby_strings="$rvm_token"
;;
opal* | jruby* | ree* | kiji* | macruby* | rbx* | rubinius* | goruby | mruby | ironruby* | default* | maglev* | topaz* | tcs* | jamesgolick* | ruby* | system | default | all)
rvm_action="${rvm_action:-use}";
case "$rvm_token" in
rubinius)
rvm_token="rbx"
;;
esac;
rvm_ruby_interpreter="$rvm_token";
rvm_ruby_string="$rvm_token";
rvm_ruby_strings="$rvm_token"
;;
old)
case "${rvm_action:-action-missing}" in
remove)
rvm_ruby_strings="old:${next_token:-}";
next_token="${1:-}";
(( $# == 0 )) || shift
;;
action-missing)
rvm_error_message="what do you want to do with old rubies? rvm can only remove old rubies.";
rvm_action="error"
;;
*)
rvm_error_message="rvm can not $rvm_action old rubies, rvm can only remove old rubies.";
rvm_action="error"
;;
esac
;;
*.rb)
rvm_ruby_args=("$rvm_token");
rvm_ruby_file="$rvm_token";
if [[ -z "${rvm_action:-""}" || "$rvm_action" == "use" ]]; then
rvm_action="ruby";
fi
;;
*.gems)
rvm_file_name="${rvm_token}"
;;
"")
rvm_action="error";
rvm_error_message="Unrecognized command line argument(s): '$@'"
;;
*)
if [[ "gemset" == "$rvm_action" ]]; then
rvm_gemset_name="${rvm_token/.gems/}";
rvm_file_name="$rvm_gemset_name.gems";
else
if [[ -f "$rvm_rubies_path/$rvm_token" || -L "$rvm_rubies_path/$rvm_token" ]]; then
rvm_ruby_string=$rvm_token;
rvm_ruby_strings="$rvm_token";
rvm_action="${rvm_action:-use}";
else
if __rvm_project_dir_check "$rvm_token"; then
__rvm_rvmrc_tools try_to_read_ruby $rvm_token;
else
rvm_action="error";
rvm_error_message="Unrecognized command line argument: '$rvm_token'";
fi;
fi;
fi
;;
esac
;;
-*)
case "$rvm_token" in
-S)
rvm_action="ruby";
rvm_ruby_args=("$rvm_token" "$next_token" "$@");
rvm_parse_break=1
;;
-e)
rvm_action="ruby";
IFS="\n";
rvm_ruby_args=("$rvm_token" "'$next_token $@'");
IFS=" ";
rvm_parse_break=1
;;
-v | --version)
if [[ -z "$next_token" ]]; then
rvm_action="version";
else
rvm_ruby_version="$next_token";
next_token="${1:-}";
(( $# == 0 )) || shift;
fi
;;
-n | --name)
rvm_ruby_name="$next_token";
next_token="${1:-}";
(( $# == 0 )) || shift
;;
--branch)
rvm_ruby_repo_branch="$next_token";
next_token="${1:-}";
(( $# == 0 )) || shift;
rvm_disable_binary_flag=1
;;
--repository | --repo | --url)
rvm_ruby_repo_url="$next_token";
next_token="${1:-}";
(( $# == 0 )) || shift;
rvm_disable_binary_flag=1
;;
-r | --remote | --binary | --latest-binary)
rvm_remote_flag=1;
if [[ "$rvm_token" == "--latest-binary" ]]; then
rvm_latest_binary_flag=1;
fi;
while [[ -n "${next_token:-}" ]] && [[ "${next_token:-}" =~ ^http || "${next_token:-}" =~ tar.bz2$ || "${next_token:-}" =~ ":" ]]; do
rvm_ruby_args=("${rvm_ruby_args[@]}" "$next_token");
next_token="${1:-}";
(( $# == 0 )) || shift;
done
;;
--ree-options)
if [[ -n "$next_token" ]]; then
__rvm_custom_separated_array rvm_ree_options , "${next_token}";
next_token="${1:-}";
(( $# == 0 )) || shift;
else
rvm_action="error";
rvm_error_message="--ree-options *must* be followed by... well... comma,separated,list,of,options.";
fi
;;
--patches | --patch)
export -a rvm_patch_names;
__rvm_custom_separated_array rvm_patch_names , "$next_token";
next_token="${1:-}";
(( $# == 0 )) || shift;
rvm_patch_original_pwd="$PWD";
rvm_disable_binary_flag=1
;;
--arch | --archflags)
rvm_architectures+=("${next_token#-arch }");
next_token="${1:-}";
(( $# == 0 )) || shift;
rvm_disable_binary_flag=1
;;
--with-arch=*)
rvm_architectures+=("${rvm_token#--with-arch=}");
rvm_disable_binary_flag=1
;;
--32 | --64)
rvm_architectures+=("${rvm_token#--}");
rvm_disable_binary_flag=1
;;
--universal)
rvm_architectures+=("32" "64");
rvm_disable_binary_flag=1
;;
--bin)
if [[ "update" == "${rvm_action:-""}" ]]; then
rvm_bin_flag=1;
else
rvm_bin_path="$next_token";
next_token="${1:-}";
(( $# == 0 )) || shift;
fi
;;
--rdoc | --yard)
rvm_docs_type="$rvm_token";
rvm_docs_type
;;
-f | --file)
rvm_action="ruby";
rvm_ruby_file="$next_token";
next_token="${1:-}";
(( $# == 0 )) || shift
;;
--passenger)
rvm_log "NOTE: If you are using Passenger 3 you no longer need the passenger_ruby,\nuse the wrapper script for your ruby instead (see 'rvm wrapper')";
rvm_wrapper_name="${rvm_token/--/}"
;;
--editor)
rvm_wrapper_name="${rvm_token/--/}"
;;
--symlink)
rvm_warn "--symlink has been removed, please see 'rvm wrapper'.";
next_token="${1:-}";
(( $# == 0 )) || shift
;;
-h | --help)
rvm_action=help
;;
-l | --level)
rvm_ruby_patch_level="p$next_token";
next_token="${1:-}";
(( $# == 0 )) || shift
;;
--sha | --make | --make-install)
rvm_token=${rvm_token#--};
rvm_token=${rvm_token//-/_};
export "rvm_ruby_${rvm_token}"="$next_token";
next_token="${1:-}";
rvm_disable_binary_flag=1;
(( $# == 0 )) || shift
;;
--nice | --sdk | --autoconf-flags | --proxy)
rvm_token=${rvm_token#--};
rvm_token=${rvm_token//-/_};
export "rvm_${rvm_token}"="$next_token";
next_token="${1:-}";
(( $# == 0 )) || shift
;;
--disable-llvm | --disable-jit)
rvm_llvm_flag=0
;;
--enable-llvm | --enable-jit)
rvm_llvm_flag=1
;;
--install)
rvm_install_on_use_flag=1
;;
--autolibs=*)
export rvm_autolibs_flag="${rvm_token#*=}"
;;
--color=*)
rvm_pretty_print_flag=${rvm_token#--color=}
;;
--pretty)
rvm_pretty_print_flag=auto
;;
--1.8 | --1.9 | --2.0 | --18 | --19 | --20)
rvm_token=${rvm_token#--};
rvm_token=${rvm_token//\./};
export "rvm_${rvm_token}_flag"=1;
rvm_disable_binary_flag=1
;;
--rvmrc | --versions-conf | --ruby-version)
rvm_token=${rvm_token#--};
rvm_token=${rvm_token//-/_};
export rvm_rvmrc_flag="${rvm_token}"
;;
--head | --static | --self | --gem | --reconfigure | --default | --force | --export | --summary | --latest | --yaml | --json | --archive | --shebang | --env | --path | --cron | --tail | --delete | --verbose | --import | --sticky | --create | --gems | --docs | --skip-autoreconf | --force-autoconf | --auto-dotfiles | --autoinstall-bundler | --disable-binary | --ignore-gemsets | --skip-gemsets | --debug | --quiet | --silent | --skip-openssl | --fuzzy | --quiet-curl)
rvm_token=${rvm_token#--};
rvm_token=${rvm_token//-/_};
export "rvm_${rvm_token}_flag"=1
;;
--auto)
export "rvm_auto_dotfiles_flag"=1;
rvm_warn "Warning, --auto is deprecated in favor of --auto-dotfiles."
;;
--rubygems)
rvm_token=${rvm_token#--};
rvm_token=${rvm_token//-/_};
export "rvm_${rvm_token}_version"="$next_token";
next_token="${1:-}";
(( $# == 0 )) || shift
;;
--dump-environment | --verify-downloads | --max-time)
rvm_token=${rvm_token#--};
rvm_token=${rvm_token//-/_};
export "rvm_${rvm_token}_flag"="$next_token";
next_token="${1:-}";
(( $# == 0 )) || shift
;;
--clang)
export CC=clang
;;
-M)
if [[ -n "$next_token" ]]; then
__rvm_custom_separated_array rvm_make_flags , "${next_token}";
next_token="${1:-}";
(( $# == 0 )) || shift;
rvm_disable_binary_flag=1;
else
rvm_action="error";
rvm_error_message="--make *must* be followed by make flags.";
fi
;;
-j)
if [[ -n "$next_token" ]]; then
rvm_make_flags+=(-j$next_token);
next_token="${1:-}";
(( $# == 0 )) || shift;
else
rvm_action="error";
rvm_error_message="-j *must* be followed by an integer (normally the # of CPU's in your machine).";
fi
;;
--with-rubies)
rvm_ruby_strings="$next_token";
next_token="${1:-}";
(( $# == 0 )) || shift
;;
-C | --configure)
if [[ -n "$next_token" ]]; then
__rvm_custom_separated_array rvm_configure_flags , "${next_token}";
next_token="${1:-}";
(( $# == 0 )) || shift;
rvm_disable_binary_flag=1;
else
rvm_action="error";
rvm_error_message="--configure *must* be followed by configure flags.";
fi
;;
--movable)
rvm_movable_flag=1;
rvm_disable_binary_flag=1
;;
--with-* | --without-* | --enable-* | --disable-*)
rvm_configure_flags+=("$rvm_token");
rvm_disable_binary_flag=1
;;
--trace)
export rvm_trace_flag=1;
set -o xtrace;
[[ -n "${ZSH_VERSION:-""}" ]] || {
set -o errtrace;
export PS4="+ \$(date \"+%s.%N\") \${BASH_SOURCE##\${rvm_path:-}} : \${FUNCNAME[0]:+\${FUNCNAME[0]}()} \${LINENO} > "
}
;;
--)
if [[ "${rvm_action}" == *install ]]; then
rvm_configure_flags+=("$next_token" "$@");
else
rvm_ruby_args=("$next_token" "$@");
fi;
rvm_disable_binary_flag=1;
rvm_parse_break=1
;;
*)
rvm_action="error";
rvm_error_message="Unrecognized command line flag: '$rvm_token'"
;;
esac
;;
*)
if __rvm_project_dir_check "$rvm_token"; then
__rvm_rvmrc_tools try_to_read_ruby "$rvm_token";
else
rvm_action="error";
rvm_error_message="Unrecognized command line argument(s): '$rvm_token $@'";
fi
;;
esac;
if [[ -z "${rvm_action:-""}" && -n "${rvm_ruby_string:-""}" ]]; then
rvm_action="use";
fi;
if [[ "error" == "${rvm_action:-""}" || ${rvm_parse_break:-0} -eq 1 || -n "${rvm_error_message:-""}" ]]; then
break;
fi;
done;
: rvm_ruby_args:${#rvm_ruby_args[@]}:${rvm_ruby_args[*]}:;
if [[ -n "${rvm_error_message:-""}" ]]; then
rvm_error "$rvm_error_message ( see: 'rvm usage' )";
unset rvm_error_message;
return 1;
fi
}
__rvm_parse_args_find_known_flags ()
{
typeset _args_array_name _temp_var;
typeset -a _new_args;
_args_array_name="$1";
(( $# == 0 )) || shift;
_new_args=();
while (( $# )); do
case "$1" in
--verify-downloads)
export "rvm_verify_downloads_flag"="${2:-}";
shift
;;
--force | --verbose | --debug | --quiet | --silent | --create)
export "rvm_${1#--}_flag=1"
;;
--only-path)
_temp_var="${1#--}";
export "rvm_${_temp_var//-/_}_flag=1"
;;
--32 | --64)
rvm_architectures+=("${1#--}");
rvm_disable_binary_flag=1
;;
--universal)
rvm_architectures+=("32" "64");
rvm_disable_binary_flag=1
;;
--patches | --patch)
export -a rvm_patch_names;
__rvm_custom_separated_array rvm_patch_names , "${2:-}";
rvm_patch_original_pwd="$PWD";
rvm_disable_binary_flag=1;
shift
;;
--autolibs=*)
export rvm_autolibs_flag="${1#*=}"
;;
--)
shift;
_new_args+=("$@");
shift $#
;;
*)
_new_args+=("$1")
;;
esac;
(( $# == 0 )) || shift;
done;
eval "${_args_array_name}+=( \"\${_new_args[@]}\" )"
}
__rvm_path_match_gem_home_check ()
{
(( ${rvm_silence_path_mismatch_check_flag:-0} == 0 )) || return 0;
[[ -n "${GEM_HOME:-}" ]] || return 0;
case "$PATH" in
$GEM_HOME/bin:*)
true
;;
*:$GEM_HOME/bin:*)
__rvm_path_match_gem_home_check_warning "is not at first place"
;;
*)
__rvm_path_match_gem_home_check_warning "is not available"
;;
esac
}
__rvm_path_match_gem_home_check_warning ()
{
rvm_warn "Warning! PATH is not properly set up, '$GEM_HOME/bin' $1,
usually this is caused by shell initialization files - check them for 'PATH=...' entries,
it might also help to re-add RVM to your dotfiles: 'rvm get stable --auto-dotfiles',
to fix temporarily in this shell session run: 'rvm use ${GEM_HOME##*/}'."
}
__rvm_project_dir_check ()
{
typeset _found_file path_to_check variable variable_default;
typeset -a _valid_files;
path_to_check="$1";
variable="${2:-}";
variable_default="${3:-}";
_valid_files=("$path_to_check" "$path_to_check/.rvmrc" "$path_to_check/.versions.conf" "$path_to_check/.ruby-version" "$path_to_check/.rbfu-version" "$path_to_check/.rbenv-version" "$path_to_check/Gemfile");
__rvm_find_first_file _found_file "${_valid_files[@]}" || true;
if [[ "${_found_file##*/}" == "Gemfile" ]]; then
[[ -s "$_found_file" ]] && {
__rvm_grep "^#ruby=" "$_found_file" > /dev/null || __rvm_grep "^\s*ruby" "$_found_file" > /dev/null
} || _found_file="";
fi;
if [[ -n "$variable" ]]; then
eval "$variable=\"\${_found_file:-$variable_default}\"";
fi;
[[ -n "${_found_file:-$variable_default}" ]] || return $?
}
__rvm_project_ruby_env_check_unload ()
{
if (( ${#rvm_saved_env[@]} > 0 )); then
__rvm_project_ruby_env_load_set_env "" "${rvm_saved_env[@]}";
fi;
rvm_saved_env=()
}
__rvm_project_ruby_env_load ()
{
typeset -a __variables;
export -a rvm_saved_env;
__rvm_project_ruby_env_check_unload;
__rvm_project_ruby_env_load_parse_file "$@";
__rvm_project_ruby_env_load_set_env "rvm_saved_env" "${__variables[@]}"
}
__rvm_project_ruby_env_load_parse_file ()
{
typeset -a __sed_commands;
__sed_commands=();
if [[ -n "${2:-}" ]]; then
__sed_commands+=(-e "/^$2/ !d" -e "s/^$2//");
else
__sed_commands+=(-e "/^#/ d");
fi;
__sed_commands+=(-e 's/`/\\`/g' -e 's/$(/\\$(/g');
__sed_commands+=(-e "/^$/ d");
__rvm_read_lines __variables <( { cat "$1"; echo ""; } | __rvm_sed "${__sed_commands[@]}" )
}
__rvm_project_ruby_env_load_set_env ()
{
typeset __save_to __key __value;
__save_to="$1";
shift;
for __set in "$@";
do
__key="${__set%%=*}";
__value="${__set#*=}";
if [[ -n "${__save_to}" ]]; then
eval "${__save_to}+=( \"\${__key}=\${${__key}}\" )";
fi;
eval "export \${__key}=\"${__value}\"";
done
}
__rvm_project_rvmrc ()
{
export __rvm_project_rvmrc_lock;
: __rvm_project_rvmrc_lock:${__rvm_project_rvmrc_lock:=0};
: __rvm_project_rvmrc_lock:$((__rvm_project_rvmrc_lock+=1));
if (( __rvm_project_rvmrc_lock > 1 )); then
return 0;
fi;
typeset working_dir found_file rvm_trustworthiness_result save_PATH;
working_dir="${1:-"$PWD"}";
save_PATH="${PATH}";
while :; do
if [[ -z "$working_dir" || "$HOME" == "$working_dir" || "${rvm_prefix:-}" == "$working_dir" || "" == "$working_dir" ]]; then
if (( ${rvm_project_rvmrc_default:-0} == 1 )); then
rvm_previous_environment="default";
fi;
if [[ -n "${rvm_previous_environment:-""}" ]]; then
unset GEM_HOME GEM_PATH;
__rvm_remove_rvm_from_path;
__rvm_conditionally_add_bin_path;
__rvm_load_environment "$rvm_previous_environment";
fi;
__rvm_project_ruby_env_check_unload;
unset rvm_current_rvmrc rvm_previous_environment;
break;
else
if __rvm_project_dir_check "$working_dir" found_file && [[ "${found_file}" != "$HOME/.rvmrc" ]]; then
rvm_trustworthiness_result=0;
if [[ "${rvm_current_rvmrc:-""}" != "${found_file}" ]]; then
__rvm_conditionally_do_with_env __rvm_load_project_config "${found_file}" || {
rvm_trustworthiness_result=$?;
PATH="${save_PATH}"
};
fi;
unset __rvm_project_rvmrc_lock;
return "$rvm_trustworthiness_result";
else
working_dir="${working_dir%/*}";
fi;
fi;
done;
unset __rvm_project_rvmrc_lock;
return 1
}
__rvm_read_lines ()
{
typeset IFS;
IFS="
";
if [[ "${2:--}" == "-" ]]; then
eval "$1=( \$( \cat - ) )";
else
eval "$1=( \$( \cat \"\${2:--}\" ) )";
fi
}
__rvm_reboot ()
{
rvm_warn "Do you wish to reboot rvm?\n('yes', or 'no')> ";
typeset response;
response="no";
read response;
if [[ "yes" == "$response" ]]; then
__rvm_cd $rvm_path;
command -v __rvm_reset >> /dev/null 2>&1 || source "$rvm_scripts_path/functions/reset";
__rvm_reset;
\mv "$rvm_archives_path" "$HOME/.archives";
if [[ "/" == "$rvm_path" ]]; then
rvm_error "remove '/' ?!... NO!";
else
if [[ -d "$rvm_path" ]]; then
__rvm_rm_rf "$rvm_path";
fi;
fi;
gem install rvm $rvm_gem_options;
"$rvm_scripts_path/get" latest;
source "$rvm_scripts_path/rvm";
else
rvm_log "Carry on then...";
fi;
return 0
}
__rvm_record_install ()
{
[[ -n "$1" ]] || return;
typeset recorded_ruby_name rvm_install_record_file;
recorded_ruby_name="$( "$rvm_scripts_path/tools" strings "$1" )";
rvm_install_record_file="$rvm_user_path/installs";
[[ -f "$rvm_install_record_file" ]] || \touch "$rvm_install_record_file";
__rvm_sed_i "$rvm_install_record_file" -e "/^$recorded_ruby_name/d";
printf "%b" "$recorded_ruby_name -- ${rvm_configure_flags[*]}\n" >> "$rvm_install_record_file"
}
__rvm_record_ruby_configs ()
{
for dir in "$rvm_path/rubies/"*;
do
if [[ ! -L "${dir}" && ! -s "${dir}/config" && -x "${dir}/bin/ruby" ]]; then
__rvm_ruby_config_save "${dir}/bin/ruby" || {
typeset string="${dir##*/}";
rvm_error " Can not save config data for ruby: '${string}', most likely it is broken installation and you can:
- try fix it: 'rvm reinstall ${string}', OR:
- remove it: 'rvm uninstall ${string} --gems'"
};
fi;
done
}
__rvm_recorded_install_command ()
{
typeset recorded_ruby_name;
recorded_ruby_name="$( "$rvm_scripts_path/tools" strings "$1" )";
recorded_ruby_name=${recorded_ruby_name%%${rvm_gemset_seperator:-"@"}*};
[[ -n "$recorded_ruby_name" ]] || return 1;
if [[ -s "$rvm_user_path/installs" ]] && __rvm_grep "^$recorded_ruby_name " "$rvm_user_path/installs" > /dev/null 2>&1; then
__rvm_grep "^$recorded_ruby_name " "$rvm_user_path/installs" | head -n 1;
else
return 1;
fi
}
__rvm_remote_extension ()
{
case "$1" in
*.tar.*)
rvm_remote_extension="tar${1##*tar}"
;;
jruby-*)
rvm_remote_extension="tar.gz"
;;
*)
rvm_remote_extension="tar.bz2"
;;
esac;
[[ "$2" != "-" ]] || printf "%b" "${rvm_remote_extension}"
}
__rvm_remote_server_path ()
{
typeset _iterator;
_iterator="";
while ! __rvm_remote_server_path_single 0 1 "${_iterator}" "${1:-}"; do
: $(( _iterator+=1 ));
done
}
__rvm_remote_server_path_single ()
{
typeset __remote_file;
__rvm_calculate_remote_file "$@" || return $?;
if [[ -z "${__remote_file:-}" ]]; then
rvm_debug "No remote file name found";
return $1;
else
if file_exists_at_url "${__remote_file}"; then
rvm_debug "Found remote file ${__remote_file}";
printf "%b" "$( __rvm_db "rvm_remote_server_verify_downloads${3:-}" ):${__remote_file}";
else
rvm_debug "Remote file does not exist ${__remote_file}";
return $2;
fi;
fi
}
__rvm_remove_from_array ()
{
typeset _array_name _search _iterator;
typeset -a _temp_array;
_array_name="$1";
_search="$2";
shift 2;
_temp_array=();
for _iterator in "$@";
do
__rvm_string_match "$_iterator" "$_search" || _temp_array+=("$_iterator");
done;
eval "$_array_name=( \"\${_temp_array[@]}\" )"
}
__rvm_remove_from_path ()
{
export PATH;
typeset _value;
_value="${1//+(\/)//}";
if [[ "$PATH" =~ "//" ]]; then
if [[ `uname -s` = "Darwin" ]]; then
PATH="$(sed -E 's#/+#/#g' <<<$PATH)";
else
PATH="$(sed -r 's#/+#/#g' <<<$PATH)";
fi;
fi;
if __rvm_string_match ":$PATH:" "*:${_value}:*"; then
typeset -a _path;
_path=();
__rvm_custom_separated_array _path : "${PATH}";
__rvm_remove_from_array _path "${_value}" "${_path[@]}";
__rvm_join_array PATH : _path;
fi
}
__rvm_remove_install_record ()
{
typeset recorded_ruby_name rvm_install_record_file;
recorded_ruby_name="$( "$rvm_scripts_path/tools" strings "$1" )";
rvm_install_record_file="$rvm_user_path/installs";
if [[ -s "$rvm_install_record_file" ]]; then
__rvm_sed_i "$rvm_install_record_file" -e "/^$recorded_ruby_name/d";
fi
}
__rvm_remove_rvm_from_path ()
{
typeset local_rvm_path;
__rvm_remove_from_path "${rvm_path%/}/*";
__rvm_remove_from_path "${rvm_bin_path}";
while local_rvm_path="$( __rvm_which rvm 2>/dev/null )"; do
__rvm_remove_from_path "${local_rvm_path%/*}";
done;
builtin hash -r
}
__rvm_reset_rvmrc_trust ()
{
if [[ "$1" == all ]]; then
echo "" > "$rvm_user_path/rvmrcs";
else
"$rvm_scripts_path/db" "$rvm_user_path/rvmrcs" "$(__rvm_rvmrc_key "$1")" "delete" > /dev/null 2>&1;
fi
}
__rvm_rm_rf ()
{
__rvm_rm_rf_verbose "$@"
}
__rvm_rm_rf_verbose ()
{
typeset target;
target="${1%%+(/|.)}";
if [[ -n "${ZSH_VERSION:-}" ]]; then
setopt extendedglob;
else
if [[ -n "${BASH_VERSION:-}" ]]; then
shopt -s extglob;
else
rvm_error "What the heck kind of shell are you running here???";
fi;
fi;
case "${target}" in
*(/|.)@(|/Applications|/Developer|/Guides|/Information|/Library|/Network|/System|/User|/Users|/Volumes|/backups|/bdsm|/bin|/boot|/cores|/data|/dev|/etc|/home|/lib|/lib64|/mach_kernel|/media|/misc|/mnt|/net|/opt|/private|/proc|/root|/sbin|/selinux|/srv|/sys|/tmp|/usr|/var))
rvm_debug "__rvm_rm_rf target is not valid - can not remove";
return 1
;;
*)
[[ -n "${target}" ]] || {
rvm_debug "__rvm_rm_rf target not given";
return 1
};
if [[ -d "${target}" ]]; then
\rm -rf "${target}" || {
typeset ret=$?;
rvm_debug "__rvm_rm_rf error removing target dir '${target}'.";
return $ret
};
else
if [[ -f "${target}" || -L "${target}" ]]; then
\rm -f "${target}" || {
typeset ret=$?;
rvm_debug "__rvm_rm_rf error removing target file/link '${target}'.";
return $ret
};
else
rvm_debug "__rvm_rm_rf already gone: $*";
return 0;
fi;
fi
;;
esac
}
__rvm_ruby_config_get ()
{
typeset variable_name ruby_path;
variable_name="$1";
ruby_path="${2:-$rvm_ruby_home/bin/ruby}";
case "${variable_name:---all}" in
--all)
"$ruby_path" -rrbconfig -e 'puts RbConfig::CONFIG.sort.map{|k,v| "#{k}: #{v}" }' 2> /dev/null
;;
*)
"$ruby_path" -rrbconfig -e 'puts RbConfig::CONFIG["'"$variable_name"'"]' 2> /dev/null
;;
esac
}
__rvm_ruby_config_save ()
{
typeset ruby_path config_path default_config_path;
ruby_path="${1:-$rvm_ruby_home/bin/ruby}";
default_config_path="#{RbConfig::CONFIG[\"prefix\"]}/config";
config_path="${2:-$default_config_path}";
"$ruby_path" -rrbconfig -e '\
File.open("'"$config_path"'","w") { |file|
RbConfig::CONFIG.sort.each{|key,value|
file.write("#{key.gsub(/\.|-/,"_")}=\"#{value.gsub("$","\\$")}\"\n")
}
}
' > /dev/null 2>&1
}
__rvm_ruby_package_file ()
{
case "$1" in
*.tar.*)
rvm_ruby_package_file="/$1"
;;
rbx-*)
rvm_ruby_package_file="/${1//rbx-/rubinius-}.$(__rvm_remote_extension "$1" -)"
;;
jruby-*)
typeset __version;
__version="$(
rvm_ruby_string="$1"
__rvm_ruby_string
echo "$rvm_ruby_version"
)";
rvm_ruby_package_file="/${__version}/jruby-bin-${__version}.$(__rvm_remote_extension "$1" -)"
;;
"")
rvm_ruby_package_file=""
;;
*)
rvm_ruby_package_file="/$1.$(__rvm_remote_extension "$1" -)"
;;
esac
}
__rvm_ruby_string ()
{
typeset ruby_string gemset_name expanded_alias_name repo_url branch_name ruby_name;
__rvm_default_flags;
rvm_expanding_aliases=;
true "${rvm_ruby_version:=}" "${rvm_gemset_name:=}" "${rvm_ruby_interpreter:=}" "${rvm_ruby_version:=}" "${rvm_ruby_tag:=}" "${rvm_ruby_patch_level:=}" "${rvm_ruby_revision:=}" ${rvm_gemset_separator:="@"} "${rvm_ruby_string:=}" ${rvm_expanding_aliases:=0} ${rvm_head_flag:=0};
if echo "$rvm_ruby_string" | __rvm_grep "${rvm_gemset_separator}" > /dev/null 2>&1; then
rvm_gemset_name="${rvm_ruby_string/*${rvm_gemset_separator}/}";
rvm_ruby_string="${rvm_ruby_string/${rvm_gemset_separator}*/}";
fi;
if (( rvm_expanding_aliases == 0 )) && [[ -n "${rvm_ruby_string}" && "$rvm_ruby_string" != "system" ]]; then
if [[ -f "$rvm_path/config/alias" && -s "$rvm_path/config/alias" ]] && expanded_alias_name="$("$rvm_scripts_path"/db "$rvm_path/config/alias" "$rvm_ruby_string")" && [[ -n "$expanded_alias_name" ]]; then
rvm_ruby_string="$expanded_alias_name";
else
if [[ "$rvm_ruby_string" == default ]]; then
rvm_ruby_string="system";
fi;
fi;
fi;
if echo "$rvm_ruby_string" | __rvm_grep "${rvm_gemset_separator}" > /dev/null 2>&1; then
rvm_gemset_name="${rvm_ruby_string/*${rvm_gemset_separator}/}";
rvm_ruby_string="${rvm_ruby_string/${rvm_gemset_separator}*/}";
fi;
ruby_string="${rvm_ruby_string:-}";
gemset_name="${rvm_gemset_name:-}";
repo_url="${rvm_ruby_repo_url:-}";
branch_name="${rvm_ruby_repo_branch:-}";
ruby_name="${rvm_ruby_name:-}";
__rvm_unset_ruby_variables;
rvm_ruby_repo_url="${repo_url:-}";
rvm_ruby_repo_branch="${branch_name:-}";
rvm_ruby_name="$ruby_name";
if [[ -n "$gemset_name" ]]; then
rvm_gemset_name="$gemset_name";
rvm_sticky_flag=1;
fi;
strings=();
__rvm_custom_separated_array strings - "${ruby_string}";
if (( ${#strings[@]} == 0 )); then
if echo "${GEM_HOME:-}" | __rvm_grep "${rvm_gems_path}" > /dev/null 2>&1; then
strings="${GEM_HOME##*\/}";
strings="${strings/%${rvm_gemset_separator:-"@"}*}";
rvm_ruby_string="$strings";
strings=($(echo ${rvm_ruby_string//-/ }));
else
strings=(system);
rvm_ruby_string="system";
fi;
fi;
for string in ${strings[@]};
do
case "$string" in
head)
rvm_ruby_patch_level="";
rvm_ruby_revision="";
rvm_ruby_tag="";
export rvm_head_flag=1
;;
system)
rvm_ruby_interpreter="system";
rvm_ruby_patch_level="";
rvm_ruby_tag="";
rvm_ruby_revision="";
rvm_ruby_version="";
rvm_gemset_name="";
rvm_head_flag=0;
return 0
;;
ext | external)
rvm_ruby_interpreter="ext";
rvm_ruby_patch_level="";
rvm_ruby_tag="";
rvm_ruby_revision="";
rvm_ruby_version="";
rvm_head_flag=0;
rvm_ruby_name="${ruby_string:-${rvm_ruby_string}}";
rvm_ruby_name="${rvm_ruby_name#*-}";
break
;;
nightly | weekly | monthly)
case "${rvm_ruby_interpreter}" in
rbx | rubinius)
rvm_ruby_patch_level="$string"
;;
*)
rvm_ruby_version="$string"
;;
esac;
rvm_nightly_flag=1
;;
nightly* | weekly* | monthly*)
case "${rvm_ruby_interpreter}" in
rbx | rubinius)
rvm_ruby_patch_level="$string"
;;
*)
rvm_ruby_version="$string"
;;
esac
;;
preview*)
rvm_ruby_patch_level="$string"
;;
rc[[:digit:]]*)
rvm_ruby_patch_level="$string"
;;
[[:digit:]].[[:digit:]]* | [[:digit:]][[:digit:]].[[:digit:]]*)
if [[ "${rvm_ruby_interpreter}" == "rbx" ]]; then
if [[ -z "${rvm_ruby_version}" ]]; then
rvm_ruby_version="${string}";
else
if [[ -z "${rvm_ruby_patch_level}" ]]; then
rvm_ruby_patch_level="${string}";
else
rvm_error "Unknown ruby interpreter string component: '$string'.";
return 1;
fi;
fi;
else
case "$string" in
1.8)
rvm_ruby_version="$string.7";
rvm_ruby_revision="";
rvm_ruby_tag=""
;;
1.9)
rvm_ruby_version="$string.3";
rvm_ruby_revision="";
rvm_ruby_tag=""
;;
2.0)
rvm_ruby_version="$string.0";
rvm_ruby_revision="";
rvm_ruby_tag=""
;;
0.+([[:digit:]]) | 0.+([[:digit:]]).+([[:digit:]]) | 1.+([[:digit:]]).+([[:digit:]]) | 2.+([[:digit:]]).+([[:digit:]]) | 1.+([[:digit:]]).+([[:digit:]]).+([[:digit:]]) | 1.+([[:digit:]]))
rvm_ruby_version="$string";
rvm_ruby_revision="";
rvm_ruby_tag=""
;;
1.+([[:digit:]]).+([[:digit:]]).+([[:alnum:]]))
case "${rvm_ruby_interpreter:-""}" in
jruby)
rvm_ruby_version="$string"
;;
*)
rvm_error "Unknown ruby interpreter version: '$string'.";
return 1
;;
esac
;;
*)
rvm_error "Unknown ruby interpreter version: '$string'.";
return 1
;;
esac;
fi
;;
p[[:digit:]]*)
rvm_ruby_patch_level="$string"
;;
[[:digit:]][[:digit:]]*)
case "${rvm_ruby_interpreter:-""}" in
ree)
rvm_ruby_patch_level="$string";
rvm_ruby_revision=""
;;
kiji)
rvm_ruby_patch_level="$string";
rvm_ruby_revision=""
;;
rbx)
rvm_ruby_patch_level="$string"
;;
maglev)
rvm_ruby_version="$string";
rvm_ruby_revision="";
rvm_ruby_patch_level=""
;;
*)
rvm_ruby_revision="r$string"
;;
esac
;;
r[[:digit:]]*)
rvm_ruby_patch_level="";
rvm_ruby_revision="$string"
;;
s[[:alnum:]]*)
rvm_ruby_revision="";
rvm_ruby_sha="${string#s}"
;;
tv[[:digit:]]* | t[[:digit:]]*)
rvm_ruby_patch_level="";
rvm_ruby_revision="";
rvm_ruby_tag="$string"
;;
m[[:digit:]]*)
rvm_ruby_mode="$string"
;;
u[[:alnum:]]*)
rvm_ruby_patch_level="";
rvm_ruby_revision="";
rvm_ruby_tag="";
rvm_ruby_patch="";
rvm_ruby_user_tag="$string"
;;
a[[:digit:]][[:digit:]]*)
rvm_ruby_bits="$string"
;;
b[[:digit:]]*)
rvm_ruby_repo_branch="${string}";
rvm_head_flag=1
;;
opal | ruby | rbx | jruby | macruby | ree | kiji | rubinius | maglev | ironruby | goruby | mruby | tcs | jamesgolick | topaz)
rvm_ruby_interpreter="$string"
;;
[[:alpha:]]*([[:alnum:]]|_))
rvm_ruby_name="$string"
;;
*)
rvm_error "Unknown ruby interpreter string component: '$string'.";
return 1
;;
esac;
done;
if [[ -z "${rvm_ruby_interpreter:-""}" ]]; then
case "$rvm_ruby_version" in
0.[5-6]*)
rvm_ruby_interpreter="macruby"
;;
1.[0-4]*)
rvm_ruby_interpreter="rbx"
;;
1.[5-7]*)
rvm_ruby_interpreter="jruby"
;;
1.[8-9]*)
rvm_ruby_interpreter="ruby"
;;
2.*)
rvm_ruby_interpreter="ruby"
;;
esac;
fi;
rvm_ruby_version="${rvm_ruby_version:-}";
if [[ -z "${rvm_ruby_version:-}" && "${rvm_ruby_interpreter}" != "ext" ]] && (( ${rvm_head_flag:=0} == 0 )); then
if (( ${rvm_fuzzy_flag:-0} == 1 )); then
rvm_ruby_version="$(
"${rvm_scripts_path:-$rvm_path/scripts}/list" strings |
__rvm_grep "^${rvm_ruby_interpreter}-.*${rvm_ruby_name:-}" |
__rvm_awk -F- '{print $2}' | sort | __rvm_tail -n 1
)";
fi;
rvm_ruby_version="${rvm_ruby_version:-"$(
__rvm_db "${rvm_ruby_interpreter}_version"
)"}";
fi;
rvm_ruby_string="${rvm_ruby_interpreter}${rvm_ruby_version:+-}${rvm_ruby_version:-}";
if [[ "${rvm_ruby_interpreter}" == "ext" ]]; then
true;
else
if [[ "${rvm_head_flag:=0}" == "1" || -n "${rvm_ruby_sha:-}" || -n "${rvm_ruby_tag:-}" ]]; then
if [[ "${rvm_head_flag:=0}" == "1" ]]; then
rvm_ruby_string="${rvm_ruby_string}-head";
fi;
if [[ -n "${rvm_ruby_sha:-}" ]]; then
rvm_ruby_string="${rvm_ruby_string}-s${rvm_ruby_sha}";
else
if [[ -n "${rvm_ruby_tag:-}" ]]; then
rvm_ruby_string="${rvm_ruby_string}-${rvm_ruby_tag}";
fi;
fi;
if [[ ! -d "${rvm_rubies_path}/${rvm_ruby_string}" ]] && (( ${rvm_fuzzy_flag:-0} == 1 )); then
rvm_ruby_string="$(
"${rvm_scripts_path:-$rvm_path/scripts}/list" strings |
__rvm_grep "^${rvm_ruby_string}.*${rvm_ruby_name:-}" |
sort | __rvm_tail -n 1
)";
fi;
else
if [[ -n "${rvm_ruby_revision:-}" ]]; then
rvm_ruby_string="${rvm_ruby_string}-${rvm_ruby_revision}";
else
if [[ -n "${rvm_ruby_patch_level:-}" ]]; then
rvm_ruby_string="${rvm_ruby_string}-${rvm_ruby_patch_level}";
else
if [[ -n "${rvm_ruby_user_tag:-}" ]]; then
rvm_ruby_string="${rvm_ruby_string}-${rvm_ruby_user_tag}";
else
if (( ${rvm_fuzzy_flag:-0} == 1 )) && [[ "${rvm_ruby_interpreter}" == "ruby" || "${rvm_ruby_interpreter}" == "ree" ]]; then
rvm_ruby_patch_level="$(
"${rvm_scripts_path:-$rvm_path/scripts}/list" strings |
__rvm_grep "^${rvm_ruby_interpreter}-${rvm_ruby_version}-.*${rvm_ruby_name:-}" |
__rvm_awk -F- '{print $3}' | sort | __rvm_tail -n 1
)";
fi;
if (( ${rvm_latest_binary_flag:-0} == 1 )) && [[ "${rvm_ruby_interpreter}" == "ruby" || "${rvm_ruby_interpreter}" == "ree" ]]; then
rvm_ruby_patch_level="$(
__list_remote_rubies_for $( __rvm_system_path_for rubies ) |
__rvm_awk -F/ '{x=$NF; gsub(".tar.*","",x); print x}' |
__rvm_grep "${rvm_ruby_interpreter}-${rvm_ruby_version}-" |
__rvm_awk -F- '{print $3}' | sort | __rvm_tail -n 1
)";
fi;
[[ -n "${rvm_ruby_patch_level:-""}" ]] || rvm_ruby_patch_level="$(
__rvm_db "${rvm_ruby_interpreter}_${rvm_ruby_version}_patch_level"
)";
if [[ -n "${rvm_ruby_patch_level:-""}" ]]; then
rvm_ruby_string="${rvm_ruby_string}-${rvm_ruby_patch_level}";
fi;
fi;
fi;
fi;
fi;
fi;
if [[ -n "${rvm_ruby_name:-}" ]]; then
rvm_ruby_string="${rvm_ruby_string}-${rvm_ruby_name}";
detected_rvm_ruby_name="${rvm_ruby_name}";
rvm_ruby_name="";
else
detected_rvm_ruby_name="";
fi;
true
}
__rvm_ruby_string_paths_under ()
{
typeset __search_path part parts IFS;
IFS=" ";
__search_path="${1%/}";
if [[ -n "${ZSH_VERSION:-}" ]]; then
parts=(${=rvm_ruby_string//-/ });
else
parts=(${rvm_ruby_string//-/ });
fi;
echo "$__search_path";
for part in "${parts[@]}";
do
__search_path="$__search_path/$part";
echo "$__search_path";
done
}
__rvm_ruby_strings_exist ()
{
for rvm_ruby_string in ${@//,/ };
do
rvm_gemset_name="";
rvm_verbose_flag=0 __rvm_use "${rvm_ruby_string}" > /dev/null 2>&1 || return $?;
printf "%b" "${rvm_ruby_string}${rvm_gemset_name:+@}${rvm_gemset_name:-}\n";
done;
unset rvm_ruby_string
}
__rvm_rubygems_create_link ()
{
\mkdir -p "$rvm_ruby_gem_home" "$rvm_ruby_global_gems_path";
typeset ruby_lib_gem_path;
rubygems_detect_ruby_lib_gem_path "${1:-ruby}" || return 0;
\mkdir -p "$(dirname $ruby_lib_gem_path)";
if [[ -d "$ruby_lib_gem_path" && ! -L "$ruby_lib_gem_path" ]]; then
if [[ "$rvm_ruby_gem_home" != "$rvm_ruby_global_gems_path" ]]; then
\cp -f "$ruby_lib_gem_path"/* "$rvm_ruby_global_gems_path"/ 2> /dev/null;
fi;
\mv -f "$ruby_lib_gem_path"/* "$rvm_ruby_gem_home"/ 2> /dev/null;
fi;
__rvm_rm_rf "$ruby_lib_gem_path";
ln -fs "$rvm_ruby_gem_home" "$ruby_lib_gem_path"
}
__rvm_run ()
{
typeset name message;
typeset -a _command_array;
name="${1:-}";
eval "_command_array=( ${2:-} )";
message="${3:-}";
__rvm_log_command "$name" "$message" "${_command_array[@]}" || return $?
}
__rvm_run_script ()
{
"$rvm_scripts_path/${1:-"$rvm_action"}" "${rvm_ruby_args[@]}"
}
__rvm_run_wrapper ()
{
( file="$1";
action="${2:-}";
shift 2;
rubies_string="${1:-}";
export -a args;
args=($@);
source "$rvm_scripts_path"/$file )
}
__rvm_rvmrc_key ()
{
printf "%b" "$1" | \tr '[#/.=()]' _;
return $?
}
__rvm_rvmrc_match_all ()
{
[[ "${1:-}" == "all" || "${1:-}" == "all.rvmrcs" || "${1:-}" == "allGemfiles" ]]
}
__rvm_rvmrc_stored_trust ()
{
[[ -f "$1" ]] || return 1;
"${rvm_scripts_path:-"$rvm_path/scripts"}/db" "$rvm_user_path/rvmrcs" "$(__rvm_rvmrc_key "$1")" || return $?
}
__rvm_rvmrc_stored_trust_check ()
{
typeset _first _second rvmrc_path;
if [[ -n "${ZSH_VERSION:-}" ]]; then
_first=1;
else
_first=0;
fi;
_second=$(( _first + 1 ));
rvmrc_path="$1";
if [[ -f "$rvmrc_path" ]]; then
saveIFS=$IFS;
IFS=';';
trust=($(__rvm_rvmrc_stored_trust "$rvmrc_path"));
IFS=$saveIFS;
if [[ "${trust[${_second}]:-'#'}" != "$(__rvm_checksum_for_contents "$rvmrc_path")" ]]; then
echo "The rvmrc at '$rvmrc_path' contains unreviewed changes.";
return 1;
else
if [[ "${trust[${_first}]}" == '1' ]]; then
echo "The rvmrc at '$rvmrc_path' is currently trusted.";
return 0;
else
if [[ "${trust[${_first}]}" == '0' ]]; then
echo "The rvmrc at '$rvmrc_path' is currently untrusted.";
return 1;
else
echo "The trustiworthiness of '$rvmrc_path' is currently unknown.";
return 1;
fi;
fi;
fi;
else
echo "There is no $rvmrc_path";
return 1;
fi
}
__rvm_rvmrc_to ()
{
case "${1:-help}" in
.ruby-version | ruby-version)
__rvm_rvmrc_to_ruby_version || return $?
;;
help)
rvm_help rvmrc to;
return 0
;;
*)
rvm_error_help "Unknown subcommand '$1'" rvmrc to;
return 1
;;
esac
}
__rvm_rvmrc_to_ruby_version ()
{
( [[ -s "$PWD/.rvmrc" ]] || {
rvm_error "No .rvmrc to convert";
return 2
};
__rvm_load_project_config "$PWD/.rvmrc" || {
rvm_error "Could not load .rvmrc";
return 3
};
__rvm_set_ruby_version;
\rm .rvmrc || {
rvm_error "Could not remove .rvmrc";
return 4
} )
}
__rvm_rvmrc_tools ()
{
typeset rvmrc_action rvmrc_warning_action rvmrc_path saveIFS trust rvmrc_ruby;
rvmrc_action="$1";
(( $# )) && shift || true;
if [[ "${rvmrc_action}" == "warning" ]]; then
rvmrc_warning_action="${1:-}";
(( $# )) && shift || true;
fi;
if [[ "${rvmrc_action}" == "create" ]]; then
rvmrc_ruby="${1:-${GEM_HOME##*/}}";
rvmrc_path="$(__rvm_cd "$PWD" >/dev/null 2>&1; pwd)";
else
if [[ "${rvmrc_action}" == "to" ]]; then
rvmrc_path="$1";
else
if __rvm_rvmrc_match_all "${1:-}"; then
rvmrc_path="$1";
else
if [[ -n "${1:-}" ]]; then
rvmrc_path="${1%/.rvmrc}";
else
rvmrc_path="$PWD";
fi;
rvmrc_path="$(__rvm_cd "${rvmrc_path}" >/dev/null 2>&1; pwd)";
fi;
fi;
fi;
(( $# )) && shift || true;
if (( $# )); then
rvmrc_path="${rvmrc_path}/$1";
else
if [[ "${rvmrc_action}" == "to" ]] || __rvm_rvmrc_match_all "${rvmrc_path:-}"; then
true;
else
__rvm_project_dir_check "${rvmrc_path}" rvmrc_path "${rvmrc_path}/.rvmrc";
fi;
fi;
case "$rvmrc_action" in
warning)
__rvmrc_warning "${rvmrc_warning_action:-}" "$rvmrc_path" || return $?
;;
to)
__rvm_rvmrc_to "$rvmrc_path" || return $?
;;
create)
( rvm_create_flag=1 __rvm_use "${rvmrc_ruby}";
case "${rvmrc_path}" in
*/.rvmrc | */--rvmrc)
__rvm_set_rvmrc
;;
*/.ruby-version | */--ruby-version)
__rvm_set_ruby_version
;;
*/.versions.conf | */--versions-conf)
__rvm_set_versions_conf
;;
*)
rvm_error "Unrecognized project file format.";
return 1
;;
esac )
;;
reset)
__rvm_reset_rvmrc_trust "$rvmrc_path" && rvm_log "Reset trust for $rvmrc_path" || rvm_error "Reset trust for $rvmrc_path - failed"
;;
trust)
__rvm_trust_rvmrc "$rvmrc_path" && rvm_log "Marked $rvmrc_path as trusted" || rvm_error "Marked $rvmrc_path as trusted - failed"
;;
untrust)
__rvm_untrust_rvmrc "$rvmrc_path" && rvm_log "Marked $rvmrc_path as untrusted" || rvm_error "Marked $rvmrc_path as untrusted - failed"
;;
trusted)
__rvm_rvmrc_stored_trust_check "$rvmrc_path" || return $?
;;
is_trusted)
__rvm_rvmrc_stored_trust_check "$rvmrc_path" > /dev/null
;;
load)
rvm_current_rvmrc="" rvm_trust_rvmrcs_flag=1 __rvm_project_rvmrc "$rvmrc_path"
;;
try_to_read_ruby)
case "$rvmrc_path" in
*/.rvmrc)
if ! __rvm_rvmrc_tools is_trusted "$(dirname "$rvmrc_path")" "$(basename "$rvmrc_path")"; then
( rvm_promptless=1 __rvm_project_rvmrc "$rvmrc_path" > /dev/null 2>&1 );
fi;
if __rvm_rvmrc_tools is_trusted "$(dirname "$rvmrc_path")" "$(basename "$rvmrc_path")"; then
rvm_action="${rvm_action:-use}";
rvm_ruby_string="$(
rvm_current_rvmrc=""
rvm_trust_rvmrcs_flag=1
rvm_is_not_a_shell_function=0
__rvm_project_rvmrc "$rvmrc_path" >/dev/null 2>&1
__rvm_env_string
)";
rvm_ruby_strings="$rvm_ruby_string";
else
rvm_action="error";
rvm_error_message="The give path does not contain '$(basename "$rvmrc_path")' (or it is not trusted): '$(dirname "$rvmrc_path")' rest of params: '$@'";
fi
;;
*)
rvm_action="${rvm_action:-use}";
rvm_ruby_string="$(
rvm_current_rvmrc=""
rvm_trust_rvmrcs_flag=1
__rvm_project_rvmrc "$rvmrc_path" >/dev/null 2>&1
__rvm_env_string
)";
rvm_ruby_strings="$rvm_ruby_string"
;;
esac
;;
*)
rvm_error "Usage: rvm rvmrc {trust,untrust,trusted,load,reset,is_trusted,try_to_read_ruby,create}";
return 1
;;
esac;
return $?
}
__rvm_sed ()
{
\sed "$@" || return $?
}
__rvm_sed_i ()
{
typeset _filename _executable;
[[ -n "${1:-}" ]] || {
rvm_debug "no file given for __rvm_sed_i";
return 0
};
_filename="$1";
shift;
if [[ -x "${_filename}" ]]; then
_executable=true;
fi;
{
__rvm_sed "$@" < "${_filename}" > "${_filename}.new" && \mv -f "${_filename}.new" "${_filename}"
} 2>&1 | rvm_debug_stream;
if [[ -n "${_executable:-}" ]]; then
chmod +x "${_filename}";
fi
}
__rvm_select ()
{
true ${rvm_gemset_name:=};
typeset _original_env_string;
_original_env_string=${rvm_env_string};
export -a rvm_configure_flags rvm_patch_names rvm_ree_options rvm_make_flags;
export GEM_HOME GEM_PATH MY_RUBY_HOME RUBY_VERSION IRBRC;
export rvm_env_string rvm_action rvm_alias_expanded rvm_archive_extension rvm_bin_flag rvm_bin_path rvm_debug_flag rvm_default_flag rvm_delete_flag rvm_docs_type rvm_dump_environment_flag rvm_error_message rvm_expanding_aliases rvm_file_name rvm_gemdir_flag rvm_gemset_name rvm_gemstone_package_file rvm_gemstone_url rvm_head_flag rvm_hook rvm_install_on_use_flag rvm_llvm_flag rvm_loaded_flag rvm_niceness rvm_nightly_flag rvm_only_path_flag rvm_parse_break rvm_patch_original_pwd rvm_pretty_print_flag rvm_proxy rvm_quiet_flag rvm_reload_flag rvm_remove_flag rvm_ruby_alias rvm_ruby_args rvm_ruby_binary rvm_ruby_bits rvm_ruby_configure rvm_ruby_file rvm_ruby_gem_home rvm_ruby_gem_path rvm_ruby_global_gems_path rvm_ruby_home rvm_ruby_interpreter rvm_ruby_irbrc rvm_ruby_major_version rvm_ruby_make rvm_ruby_make_install rvm_ruby_minor_version rvm_ruby_mode rvm_ruby_name rvm_ruby_package_file rvm_ruby_package_name rvm_ruby_patch rvm_ruby_patch_level rvm_ruby_release_version rvm_ruby_repo_url rvm_ruby_revision rvm_ruby_selected_flag rvm_ruby_sha rvm_ruby_string rvm_ruby_strings rvm_ruby_tag rvm_ruby_url rvm_ruby_user_tag rvm_ruby_version rvm_script_name rvm_sdk rvm_silent_flag rvm_sticky_flag rvm_system_flag rvm_token rvm_trace_flag rvm_use_flag rvm_user_flag rvm_verbose_flag rvm_wrapper_name;
rvm_ruby_string="${1:-${rvm_ruby_string:-}}";
if [[ -z "${rvm_ruby_string:-}" ]]; then
rvm_ruby_string="${rvm_ruby_interpreter:-}";
rvm_ruby_string="${rvm_ruby_string:-}${rvm_ruby_version:+-}${rvm_ruby_version:-}";
rvm_ruby_string="${rvm_ruby_string:-}${rvm_ruby_patch_level:+-}${rvm_ruby_patch_level:-}";
rvm_ruby_string="${rvm_ruby_string:-}${rvm_ruby_revision:+-}${rvm_ruby_revision:-}";
if [[ -n "${rvm_ruby_name:-}" ]]; then
rvm_ruby_name="$rvm_ruby_string-$rvm_ruby_name";
fi;
fi;
__rvm_ruby_string || return $?;
rvm_archive_extension="tar.gz";
if [[ -z "${rvm_ruby_interpreter:-}" ]]; then
rvm_ruby_interpreter="${rvm_ruby_string//-*/}";
fi;
case "${rvm_ruby_interpreter:-missing}" in
missing)
return 2
;;
opal)
rvm_ruby_version="head";
rvm_ruby_revision="head";
rvm_ruby_interpreter="opal";
rvm_ruby_repo_url="${rvm_ruby_repo_url:-$(__rvm_db "jruby_repo_url")}";
rvm_ruby_url="${rvm_ruby_repo_url:-$(__rvm_db "jruby_repo_url")}";
rvm_disable_binary_flag=1
;;
topaz)
rvm_ruby_version="head";
rvm_ruby_revision="head";
rvm_ruby_interpreter="topaz";
rvm_ruby_repo_url="${rvm_ruby_repo_url:-$(__rvm_db "topaz_repo_url")}";
rvm_ruby_url="${rvm_ruby_url:-$(__rvm_db "topaz_url")}";
rvm_disable_binary_flag=1
;;
macruby)
if [[ "Darwin" == "$(uname)" ]]; then
rvm_ruby_package_name="${rvm_ruby_interpreter}-${rvm_ruby_version}";
if (( ${rvm_head_flag:=0} == 1 )); then
rvm_ruby_version="";
rvm_ruby_tag="";
rvm_ruby_revision="head";
__rvm_db "macruby_repo_url" "rvm_ruby_repo_url";
rvm_ruby_url="$rvm_ruby_repo_url";
rvm_disable_binary_flag=1;
else
if [[ "${rvm_ruby_version:-}" =~ "nightly" ]]; then
__rvm_select_macruby_nightly;
else
if [[ -n "${rvm_ruby_version:-}" ]]; then
__rvm_db "macruby_${rvm_ruby_version}_url" "rvm_ruby_url";
[[ -n "${rvm_ruby_url:-}" ]] || __rvm_db "macruby_url" "rvm_ruby_url";
rvm_ruby_package_name="MacRuby%20${rvm_ruby_version}.zip";
rvm_ruby_package_file="$rvm_ruby_package_name";
rvm_ruby_url="$rvm_ruby_url/$rvm_ruby_package_name";
else
__rvm_db "macruby_version" "rvm_ruby_version";
__rvm_db "macruby_url" "rvm_ruby_url";
rvm_ruby_package_name="MacRuby%20${rvm_ruby_version}.zip";
rvm_ruby_package_file="$rvm_ruby_package_name";
rvm_ruby_url="$rvm_ruby_url/$rvm_ruby_package_name";
fi;
fi;
fi;
rvm_ruby_patch_level="";
else
rvm_error "MacRuby can only be installed on a Darwin OS.";
fi
;;
rbx | rubinius)
__rvm_select_rbx_nightly || return $?;
rvm_archive_extension="tar.gz";
rvm_ruby_interpreter="rbx";
rvm_ruby_version=${rvm_ruby_version:-$(__rvm_db "rbx_version")};
rvm_ruby_repo_url=${rvm_rbx_repo_url:-$(__rvm_db "rubinius_repo_url")};
rbx_url=${rbx_url:-$(__rvm_db "rbx_url")};
case "${rvm_ruby_version}" in
2.0pre)
rvm_ruby_repo_branch="master"
;;
2.0.testing)
rvm_ruby_repo_branch="${rvm_ruby_version}"
;;
esac;
if (( ${rvm_head_flag:=0} == 0 )); then
if [[ -n "${rvm_ruby_patch_level:-}" ]]; then
rbx_url="$( __rvm_db "rbx_2.0.0_url" )";
rvm_archive_extension="zip";
rvm_ruby_url="${rbx_url}";
rvm_ruby_package_file="release-${rvm_ruby_version}-${rvm_ruby_patch_level}.${rvm_archive_extension}";
rvm_ruby_url="$rvm_ruby_url/$rvm_ruby_package_file";
else
rvm_ruby_patch_level="";
rvm_ruby_url="${rbx_url}";
rvm_ruby_package_file="rubinius-${rvm_ruby_version}.${rvm_archive_extension}";
rvm_ruby_url="$rvm_ruby_url/$rvm_ruby_package_file";
fi;
else
rvm_ruby_patch_level="";
rvm_ruby_version="head";
rvm_disable_binary_flag=1;
fi;
if [[ -n "${rvm_rbx_opt:-}" ]]; then
export RBXOPT="${RBXOPT:=${rvm_rbx_opt}}";
fi
;;
jruby)
rvm_ruby_patch_level="";
rvm_ruby_repo_url="${rvm_ruby_repo_url:-$(__rvm_db "jruby_repo_url")}";
rvm_ruby_url="${rvm_ruby_repo_url:-$(__rvm_db "jruby_repo_url")}";
if (( ${rvm_head_flag:=0} == 1 )); then
rvm_disable_binary_flag=1;
rvm_ruby_version="head";
else
if (( ${rvm_18_flag:-0} || ${rvm_19_flag:-0} || ${rvm_20_flag:-0} || ${#rvm_patch_names[@]} )); then
rvm_disable_binary_flag=1;
fi;
rvm_ruby_version="${rvm_ruby_version:-"$(__rvm_db "jruby_version")"}";
rvm_ruby_tag="${rvm_ruby_tag:-${rvm_ruby_version}}";
fi;
alias jruby_ng="jruby --ng";
alias jruby_ng_server="jruby --ng-server"
;;
maglev)
rvm_ruby_patch_level="";
maglev_url="$(__rvm_db "maglev_url")";
system="$(uname -s)";
if [[ "$MACHTYPE" == x86_64-apple-darwin* ]]; then
arch="i386";
else
arch="$(uname -m)";
fi;
if (( ${rvm_head_flag:=0} == 1 )) || [[ "$rvm_ruby_version" == "head" ]]; then
rvm_head_flag=1;
rvm_ruby_version="head";
rvm_ruby_repo_url="${rvm_ruby_repo_url:-$(__rvm_db "maglev_repo_url")}";
rvm_ruby_url="${rvm_ruby_repo_url:-$(__rvm_db "maglev_repo_url")}";
rvm_gemstone_version=$(
__rvm_curl -s https://raw.github.com/MagLev/maglev/master/version.txt |
__rvm_grep "^GEMSTONE" | cut -f2 -d-
);
rvm_gemstone_package_file="GemStone-${rvm_gemstone_version}.${system}-${arch}";
rvm_disable_binary_flag=1;
else
rvm_ruby_package_file="MagLev-${rvm_ruby_version}";
rvm_ruby_version="${rvm_ruby_version:-"$(__rvm_db "maglev_version")"}";
rvm_ruby_package_name="${rvm_ruby_interpreter}-${rvm_ruby_version}";
rvm_ruby_url="${rvm_ruby_url:-"$maglev_url/${rvm_ruby_package_file}.${rvm_archive_extension}"}";
rvm_gemstone_version=$(
__rvm_curl -s https://raw.github.com/MagLev/maglev/MagLev-${rvm_ruby_version}/version.txt |
__rvm_grep "^GEMSTONE" | cut -f2 -d-
);
rvm_gemstone_package_file="GemStone-${rvm_gemstone_version}.${system}-${arch}";
export MAGLEV_HOME="$rvm_rubies_path/$rvm_ruby_string";
fi;
rvm_gemstone_url="$maglev_url/${rvm_gemstone_package_file}.${rvm_archive_extension}"
;;
ironruby)
rvm_ruby_patch_level="";
if (( ${rvm_head_flag:=0} == 1 )); then
rvm_ruby_version="head";
rvm_ruby_package_name="${rvm_ruby_string}";
rvm_ruby_repo_url="${rvm_ruby_repo_url:-$(__rvm_db "ironruby_repo_url")}";
rvm_ruby_url="${rvm_ruby_repo_url:-$(__rvm_db "ironruby_repo_url")}";
rvm_disable_binary_flag=1;
else
rvm_archive_extension="zip";
rvm_ruby_version=${rvm_ruby_version:-"$(__rvm_db "ironruby_version")"};
rvm_ruby_package_name="${rvm_ruby_interpreter}-${rvm_ruby_version}";
rvm_ruby_package_file="${rvm_ruby_interpreter}-${rvm_ruby_version}.${rvm_archive_extension}";
rvm_ruby_url="$(__rvm_db "ironruby_${rvm_ruby_version}_url")";
fi;
export rvm_ruby_version rvm_ruby_string rvm_ruby_package_name rvm_ruby_repo_url rvm_ruby_url rvm_archive_extension
;;
ree)
rvm_ruby_interpreter=ree;
rvm_ruby_version=${rvm_ruby_version:-"$(__rvm_db "ree_version")"};
case "$rvm_ruby_version" in
1.8.*)
true
;;
*)
rvm_error "Unknown Ruby Enterprise Edition version: $rvm_ruby_version"
;;
esac;
if [[ -n "${rvm_ruby_patch_level:-0}" ]]; then
rvm_ruby_patch_level="$(echo $rvm_ruby_patch_level | __rvm_sed 's#^p##')";
fi;
rvm_ruby_package_file="ruby-enterprise-$rvm_ruby_version-$rvm_ruby_patch_level";
rvm_ruby_url="$(__rvm_db "${rvm_ruby_interpreter}_${rvm_ruby_version}_${rvm_ruby_patch_level}_url")";
rvm_ruby_url="${rvm_ruby_url:-$(__rvm_db "${rvm_ruby_interpreter}_${rvm_ruby_version}_url")}";
rvm_ruby_url="${rvm_ruby_url}/$rvm_ruby_package_file.tar.gz"
;;
kiji)
rvm_ruby_interpreter="kiji";
rvm_ruby_version="head";
rvm_head_flag=1;
rvm_ruby_string="kiji-head";
rvm_ruby_patch_level="";
rvm_ruby_repo_url=${rvm_ruby_repo_url:-"$(__rvm_db "kiji_repo_url")"};
rvm_ruby_url=$rvm_ruby_repo_url;
rvm_ruby_configure="";
rvm_ruby_make="";
rvm_ruby_make_install=""
;;
goruby)
rvm_ruby_interpreter="goruby";
rvm_ruby_version="head";
rvm_ruby_string="goruby";
rvm_ruby_patch_level="";
rvm_ruby_repo_url=${rvm_ruby_repo_url:-"$(__rvm_db "goruby_repo_url")"};
rvm_ruby_url=$rvm_ruby_repo_url;
rvm_ruby_configure="";
rvm_ruby_make="";
rvm_ruby_make_install=""
;;
mruby)
rvm_ruby_interpreter="mruby";
rvm_ruby_version="head";
rvm_ruby_string="mruby-head";
rvm_ruby_patch_level="";
rvm_ruby_repo_url=${rvm_ruby_repo_url:-"$(__rvm_db "mruby_repo_url")"};
rvm_ruby_url=$rvm_ruby_repo_url;
export rvm_head_flag=1;
rvm_disable_binary_flag=1;
export rvm_skip_autoreconf_flag=1;
rvm_ruby_configure="";
rvm_ruby_make="";
rvm_ruby_make_install=""
;;
tcs)
rvm_ruby_interpreter="tcs";
rvm_ruby_version="head";
rvm_ruby_string="tcs";
rvm_ruby_patch_level="";
rvm_ruby_repo_url=${rvm_tcs_repo_url:-"$(__rvm_db "tcs_repo_url")"};
rvm_ruby_url=$rvm_ruby_repo_url;
rvm_ruby_repo_branch="${rvm_ruby_repo_branch:-"$(__rvm_db "tcs_repo_branch")"}";
export rvm_head_flag=1;
rvm_disable_binary_flag=1;
rvm_ruby_configure="";
rvm_ruby_make="";
rvm_ruby_make_install=""
;;
jamesgolick)
rvm_ruby_interpreter="jamesgolick";
rvm_ruby_version="head";
rvm_ruby_string="jamesgolick";
rvm_ruby_patch_level="";
rvm_ruby_repo_url=${rvm_jamesgolick_repo_url:-"$(__rvm_db "jamesgolick_repo_url")"};
rvm_ruby_url=$rvm_ruby_repo_url;
rvm_ruby_repo_branch="${rvm_ruby_repo_branch:-"$(__rvm_db "jamesgolick_repo_branch")"}";
export rvm_head_flag=1;
rvm_disable_binary_flag=1;
rvm_ruby_configure="";
rvm_ruby_make="";
rvm_ruby_make_install=""
;;
ruby)
if [[ -n "${rvm_ruby_patch_level}" ]]; then
rvm_ruby_package_file="${rvm_ruby_interpreter}-${rvm_ruby_version}-${rvm_ruby_patch_level}";
rvm_ruby_package_name="${rvm_ruby_interpreter}-${rvm_ruby_version}-${rvm_ruby_patch_level}";
else
rvm_ruby_package_file="${rvm_ruby_interpreter}-${rvm_ruby_version}";
rvm_ruby_package_name="${rvm_ruby_interpreter}-${rvm_ruby_version}";
fi;
if [[ -z "${rvm_ruby_version:-""}" ]] && (( ${rvm_head_flag:=0} == 0 )); then
rvm_error "Ruby version was not specified!";
else
rvm_ruby_repo_url="${rvm_ruby_repo_url:-"$(__rvm_db "ruby_repo_url")"}";
if (( ${rvm_head_flag:=0} == 0 )); then
if __rvm_version_compare "${rvm_ruby_version}" -lt "1.8.5"; then
rvm_archive_extension="tar.gz";
else
rvm_archive_extension="tar.bz2";
fi;
else
rvm_disable_binary_flag=1;
fi;
fi
;;
ext)
if [[ -z "${rvm_ruby_name:-${detected_rvm_ruby_name:-}}" ]]; then
rvm_error "External ruby name was not specified!";
fi
;;
current)
ruby_binary="$(builtin command -v ruby)";
if (( $? == 0)) && __rvm_string_match "$ruby_binary" "*rvm*"; then
rvm_ruby_string="$(dirname "$ruby_binary" | xargs dirname | xargs basename)";
else
rvm_ruby_interpreter="system";
fi
;;
default | system | user)
true
;;
*)
if [[ -n "${MY_RUBY_HOME:-""}" ]]; then
__rvm_select $(basename $MY_RUBY_HOME);
else
if [[ -z "${rvm_ruby_string:-""}" ]]; then
rvm_error "Ruby implementation '$rvm_ruby_interpreter' is not known.";
return 1;
fi;
fi
;;
esac;
if [[ -n "$rvm_ruby_version" ]]; then
case "$rvm_ruby_version" in
+([[:digit:]]).+([[:digit:]]).+([[:digit:]]))
rvm_ruby_release_version="${rvm_ruby_version/.*/}";
rvm_ruby_major_version=${rvm_ruby_version%.*};
rvm_ruby_major_version=${rvm_ruby_major_version#*.};
rvm_ruby_minor_version="${rvm_ruby_version//*.}"
;;
+([[:digit:]]).+([[:digit:]]))
rvm_ruby_release_version="${rvm_ruby_version/.*/}";
rvm_ruby_major_version="${rvm_ruby_version#*.}";
rvm_ruby_minor_version=""
;;
esac;
fi;
[[ "${rvm_ruby_interpreter}" == ext ]] || rvm_ruby_package_name="${rvm_ruby_package_name:-${rvm_ruby_string//-n*}}";
rvm_ruby_home="$rvm_rubies_path/$rvm_ruby_string";
rvm_ruby_binary="$rvm_ruby_home/bin/ruby";
rvm_ruby_irbrc="$rvm_ruby_home/.irbrc";
if [[ "maglev" == "$rvm_ruby_interpreter" ]]; then
export MAGLEV_HOME="$rvm_ruby_home";
export GEMSTONE_GLOBAL_DIR=$MAGLEV_HOME;
fi;
[[ "system" == "$rvm_ruby_interpreter" ]] || {
__rvm_gemset_select || case $? in
2)
true
;;
*)
return $?
;;
esac
};
rvm_ruby_selected_flag=1;
[[ -d "${rvm_log_path}/$rvm_ruby_string" ]] || \mkdir -p "${rvm_log_path}/$rvm_ruby_string"
}
__rvm_select_macruby_nightly ()
{
__rvm_db "macruby_nightly_url" "rvm_ruby_url";
case "${rvm_ruby_version:-}" in
nightly_*)
__rvm_select_macruby_nightly_selected
;;
*)
__rvm_select_macruby_nightly_detect
;;
esac;
rvm_ruby_url+="/${rvm_ruby_package_file}";
rvm_verify_downloads_flag=1;
rvm_debug "selected macruby $rvm_ruby_string => $rvm_ruby_url"
}
__rvm_select_macruby_nightly_detect ()
{
typeset __string_version;
rvm_ruby_version="$(
__rvm_curl -s "$rvm_ruby_url" |
__rvm_grep -oE "<a href=\"macruby_nightly-[^<]+\.pkg</a>" |
__rvm_awk -F"[<>]" '{print $3}' | sort | __rvm_tail -n 1
)";
[[ -n "${rvm_ruby_version}" ]] || {
rvm_error "Could not find MacRuby nightly binary.";
return 1
};
rvm_ruby_package_file="${rvm_ruby_version}";
rvm_ruby_package_name="${rvm_ruby_package_file%.pkg}";
__string_version="${rvm_ruby_package_name#macruby_nightly-}";
__string_version="${__string_version//-/.}";
rvm_ruby_version="nightly_${__string_version}";
rvm_ruby_string="macruby-${rvm_ruby_version}${rvm_ruby_name:+-}${rvm_ruby_name:-}"
}
__rvm_select_macruby_nightly_selected ()
{
typeset __string_version;
__string_version="${rvm_ruby_version//./-}";
__string_version="${__string_version#nightly_}";
rvm_ruby_package_name="${rvm_ruby_interpreter}_nightly-${__string_version}";
rvm_ruby_package_file="$rvm_ruby_package_name.pkg"
}
__rvm_select_rbx_nightly ()
{
(( ${rvm_nightly_flag:=0} == 1 )) || return 0;
typeset org_rvm_ruby_patch_level _rvm_ruby_name;
if [[ "$rvm_ruby_version" == head ]]; then
rvm_ruby_version="";
fi;
rvm_debug "searching for binary rbx ${rvm_ruby_version:-}${rvm_ruby_version:+-}${rvm_ruby_patch_level}*${rvm_ruby_name:+-}${rvm_ruby_name:-}";
org_rvm_ruby_patch_level="$rvm_ruby_patch_level";
_rvm_ruby_name="${rvm_ruby_name:-${detected_rvm_ruby_name:-}}";
rvm_ruby_patch_level="$(
__list_remote_rbx_for $( __rvm_system_path_for rbx ) |
__rvm_grep ${rvm_ruby_version:-}${rvm_ruby_version:+-}${org_rvm_ruby_patch_level}.*${_rvm_ruby_name:+-}${_rvm_ruby_name:-} |
__rvm_tail -n 1
)";
[[ -n "${rvm_ruby_patch_level:-}" ]] || {
rvm_error "Could not find rbx binary '${rvm_ruby_version:-}${rvm_ruby_version:+-}${org_rvm_ruby_patch_level}*${rvm_ruby_name:+-}${rvm_ruby_name:-}' release for '$( __rvm_system_path_for rbx )'.";
return 1
};
rvm_ruby_patch_level="${rvm_ruby_patch_level##*/}";
rvm_ruby_patch_level="${rvm_ruby_patch_level%.tar.*}";
if [[ -z "${rvm_ruby_version:-}" ]]; then
rvm_ruby_patch_level="${rvm_ruby_patch_level#rubinius-}";
rvm_ruby_version="${rvm_ruby_patch_level%%-*}";
fi;
if [[ -z "${rvm_ruby_name:-}" ]]; then
rvm_ruby_name="${rvm_ruby_patch_level##*-}";
fi;
rvm_ruby_patch_level="${rvm_ruby_patch_level##*${org_rvm_ruby_patch_level}}";
rvm_ruby_patch_level="${rvm_ruby_patch_level%%-*}";
rvm_ruby_patch_level="${org_rvm_ruby_patch_level}${rvm_ruby_patch_level}";
rvm_ruby_string="rubinius-${rvm_ruby_version}-${rvm_ruby_patch_level}-${rvm_ruby_name}";
rvm_debug "detected rbx ${rvm_ruby_string}";
rvm_verify_downloads_flag=1
}
__rvm_set_color ()
{
typeset __buffer __variable;
__buffer='[';
__variable="$1";
shift;
while (( $# )); do
__rvm_set_color_single "$1";
shift;
if (( $# )); then
__buffer+=';';
fi;
done;
__buffer+='m';
if [[ "${__variable}" == "" || "${__variable}" == "print" ]]; then
printf "${__buffer}";
else
eval "${__variable}='${__buffer}'";
fi
}
__rvm_set_color_single ()
{
case "$1" in
bold)
__buffer+='7'
;;
offbold)
__buffer+='27'
;;
black)
__buffer+='30'
;;
red)
__buffer+='31'
;;
green)
__buffer+='32'
;;
yellow)
__buffer+='33'
;;
blue)
__buffer+='34'
;;
magenta)
__buffer+='35'
;;
cyan)
__buffer+='36'
;;
white)
__buffer+='37'
;;
default)
__buffer+='39'
;;
bblack)
__buffer+='40'
;;
bred)
__buffer+='41'
;;
bgreen)
__buffer+='42'
;;
byellow)
__buffer+='43'
;;
bblue)
__buffer+='44'
;;
bmagenta)
__buffer+='45'
;;
bcyan)
__buffer+='46'
;;
bwhite)
__buffer+='47'
;;
bdefault)
__buffer+='49'
;;
*)
__buffer+='0'
;;
esac
}
__rvm_set_ruby_version ()
{
if [[ -s .ruby-version ]]; then
\mv .ruby-version .ruby-version.$(date +%m.%d.%Y-%H:%M:%S);
rvm_warn ".ruby-version is not empty, moving aside to preserve.";
fi;
typeset __version="$(__rvm_env_string)";
case "${__version}" in
*@*)
if [[ -s .ruby-gemset ]]; then
\mv .ruby-gemset .ruby-gemset.$(date +%m.%d.%Y-%H:%M:%S);
rvm_warn ".ruby-gemset is not empty, moving aside to preserve.";
fi;
echo "${__version##*@}" > .ruby-gemset
;;
*)
if [[ -s .ruby-gemset ]]; then
\mv .ruby-gemset .ruby-gemset.$(date +%m.%d.%Y-%H:%M:%S);
rvm_warn ".ruby-gemset not needed, moving aside to preserve.";
fi
;;
esac;
echo "${__version%@*}" > .ruby-version
}
__rvm_set_rvmrc ()
{
typeset flags identifier short_identifier gem_file;
true ${rvm_verbose_flag:=0};
if [[ "$HOME" != "$PWD" && "${rvm_prefix:-}" != "$PWD" ]]; then
if (( rvm_verbose_flag )); then
flags="use ";
fi;
if [[ -s .rvmrc ]]; then
\mv .rvmrc .rvmrc.$(date +%m.%d.%Y-%H:%M:%S);
rvm_warn ".rvmrc is not empty, moving aside to preserve.";
fi;
identifier=$(__rvm_env_string);
short_identifier="${identifier#ruby-}";
short_identifier="${short_identifier%%-*}";
printf "%b" "#!/usr/bin/env bash
# This is an RVM Project .rvmrc file, used to automatically load the ruby
# development environment upon cd'ing into the directory
# First we specify our desired <ruby>[@<gemset>], the @gemset name is optional,
# Only full ruby name is supported here, for short names use:
# echo \"rvm use ${short_identifier}\" > .rvmrc
environment_id=\"$identifier\"
# Uncomment the following lines if you want to verify rvm version per project
# rvmrc_rvm_version=\"${rvm_version}\" # 1.10.1 seems like a safe start
# eval \"\$(echo \${rvm_version}.\${rvmrc_rvm_version} | __rvm_awk -F. '{print \"[[ \"\$1*65536+\$2*256+\$3\" -ge \"\$4*65536+\$5*256+\$6\" ]]\"}' )\" || {
# echo \"This .rvmrc file requires at least RVM \${rvmrc_rvm_version}, aborting loading.\"
# return 1
# }
" >> .rvmrc;
if __rvm_string_match "$identifier" "jruby*"; then
printf "%b" "
# Uncomment following line if you want options to be set only for given project.
# PROJECT_JRUBY_OPTS=( --1.9 )
# The variable PROJECT_JRUBY_OPTS requires the following to be run in shell:
# chmod +x \${rvm_path}/hooks/after_use_jruby_opts
" >> .rvmrc;
fi;
printf "%b" "
# First we attempt to load the desired environment directly from the environment
# file. This is very fast and efficient compared to running through the entire
# CLI and selector. If you want feedback on which environment was used then
# insert the word 'use' after --create as this triggers verbose mode.
if [[ -d \"\${rvm_path:-\$HOME/.rvm}/environments\"
&& -s \"\${rvm_path:-\$HOME/.rvm}/environments/\$environment_id\" ]]
then
\\. \"\${rvm_path:-\$HOME/.rvm}/environments/\$environment_id\"
for __hook in \"\${rvm_path:-\$HOME/.rvm}/hooks/after_use\"*
do
if [[ -f \"\${__hook}\" && -x \"\${__hook}\" && -s \"\${__hook}\" ]]
then \\. \"\${__hook}\" || true
fi
done
unset __hook
" >> .rvmrc;
if [[ " $flags " =~ " use " ]]; then
printf "%b" " if (( \${rvm_use_flag:=1} >= 1 )) # display automatically" >> .rvmrc;
else
printf "%b" " if (( \${rvm_use_flag:=1} >= 2 )) # display only when forced" >> .rvmrc;
fi;
printf "%b" "
then
if [[ \$- == *i* ]] # check for interactive shells
then printf \"%b\" \"Using: \\\\E[32m\$GEM_HOME\\\\E[0m\\n\" # show the user the ruby and gemset they are using in green
else printf \"%b\" \"Using: \$GEM_HOME\\n\" # don't use colors in non-interactive shells
fi
fi
" >> .rvmrc;
printf "%b" "else
# If the environment file has not yet been created, use the RVM CLI to select.
rvm --create $flags \"\$environment_id\" || {
echo \"Failed to create RVM environment '\${environment_id}'.\"
return 1
}
fi
" >> .rvmrc;
for gem_file in *.gems;
do
case "$gem_file" in
\*.gems)
continue
;;
esac;
printf "%b" "
# If you use an RVM gemset file to install a list of gems (*.gems), you can have
# it be automatically loaded. Uncomment the following and adjust the filename if
# necessary.
#
# filename=\".gems\"
# if [[ -s \"\$filename\" ]]
# then
# rvm gemset import \"\$filename\" | GREP_OPTIONS=\"\" \grep -v already | GREP_OPTIONS=\"\" \grep -v listed | GREP_OPTIONS=\"\" \grep -v complete | \sed '/^$/d'
# fi
" >> .rvmrc;
done;
if [[ -s Gemfile ]]; then
printf "%b" "
# If you use bundler, this might be useful to you:
# if [[ -s Gemfile ]] && {
# ! builtin command -v bundle >/dev/null ||
# builtin command -v bundle | GREP_OPTIONS=\"\" \grep \$rvm_path/bin/bundle >/dev/null
# }
# then
# printf \"%b\" \"The rubygem 'bundler' is not installed. Installing it now.\\\\n\"
# gem install bundler
# fi
# if [[ -s Gemfile ]] && builtin command -v bundle >/dev/null
# then
# bundle install | GREP_OPTIONS=\"\" \grep -vE '^Using|Your bundle is complete'
# fi
" >> .rvmrc;
fi;
else
rvm_error ".rvmrc cannot be set in your home directory. \nThe home .rvmrc is for global rvm settings only.";
fi
}
__rvm_set_versions_conf ()
{
typeset gemset identifier;
if [[ -s .versions.conf ]]; then
\mv .versions.conf .versions.conf.$(date +%m.%d.%Y-%H:%M:%S);
rvm_warn ".version.conf is not empty, moving aside to preserve.";
fi;
identifier=$(__rvm_env_string);
gemset=${identifier#*@};
identifier=${identifier%@*};
printf "%b" "ruby=$identifier
" >> .versions.conf;
if [[ -n "$gemset" && "$gemset" != "$identifier" ]]; then
printf "%b" "ruby-gemset=$gemset
" >> .versions.conf;
else
printf "%b" "#ruby-gemset=my-projectit
" >> .versions.conf;
fi;
printf "%b" "#ruby-gem-install=bundler rake
#ruby-bundle-install=true
" >> .versions.conf
}
__rvm_setup ()
{
__variables_definition export;
if (( __rvm_env_loaded != 1 )); then
return 0;
fi;
if [[ -n "${BASH_VERSION:-}" ]] && ! __function_on_stack cd pushd popd; then
trap 'status=$? ; __rvm_teardown_final ; set +x ; return $status' 0 1 2 3 15;
fi;
if [[ -n "${ZSH_VERSION:-}" ]]; then
export rvm_zsh_clobber rvm_zsh_nomatch;
if setopt | __rvm_grep -s '^noclobber$' > /dev/null 2>&1; then
rvm_zsh_clobber=0;
else
rvm_zsh_clobber=1;
fi;
setopt clobber;
if setopt | __rvm_grep -s '^nonomatch$' > /dev/null 2>&1; then
rvm_zsh_nomatch=0;
else
rvm_zsh_nomatch=1;
fi;
setopt no_nomatch;
fi
}
__rvm_setup_cd ()
{
typeset __cd_prefix __command;
__cd_prefix="";
if typeset -f smartcd > /dev/null 2> /dev/null; then
__cd_prefix="smartcd";
fi;
if typeset -f exec_scmb_expand_args > /dev/null 2> /dev/null; then
__cd_prefix="exec_scmb_expand_args ${__cd_prefix:-builtin}";
fi;
[[ -n "${__cd_prefix}" ]] || __cd_prefix="builtin";
function __rvm_after_cd ()
{
typeset rvm_hook;
rvm_hook="after_cd";
if [[ -n "${rvm_scripts_path:-}" || -n "${rvm_path:-}" ]]; then
source "${rvm_scripts_path:-$rvm_path/scripts}/hook";
fi
};
function __rvm_cd_functions_set ()
{
__rvm_do_with_env_before;
__rvm_project_rvmrc && __rvm_after_cd || true;
__rvm_do_with_env_after;
return 0
};
function __rvm_setup_cd_function ()
{
typeset __cd_prefix __command;
__cd_prefix=$1;
__command=$2;
eval "
${__command}(){
if ${__cd_prefix} ${__command} \"\$@\"
then
[[ -n \"\${rvm_current_rvmrc:-""}\" && \"\$*\" == \".\" ]] && rvm_current_rvmrc=\"\" || true
__rvm_cd_functions_set
return 0
else
return \$?
fi
}"
};
if [[ -n "${ZSH_VERSION:-}" ]]; then
autoload is-at-least;
if is-at-least 4.3.4 > /dev/null 2>&1; then
export -a chpwd_functions;
chpwd_functions=("${chpwd_functions[@]}" __rvm_cd_functions_set);
else
for __command in cd popd pushd;
do
__rvm_setup_cd_function "${__cd_prefix}" "${__command}";
done;
fi;
else
for __command in cd popd pushd;
do
__rvm_setup_cd_function "${__cd_prefix}" "${__command}";
done;
fi
}
__rvm_setup_cd_function ()
{
typeset __cd_prefix __command;
__cd_prefix=$1;
__command=$2;
eval "
${__command}(){
if ${__cd_prefix} ${__command} \"\$@\"
then
[[ -n \"\${rvm_current_rvmrc:-""}\" && \"\$*\" == \".\" ]] && rvm_current_rvmrc=\"\" || true
__rvm_cd_functions_set
return 0
else
return \$?
fi
}"
}
__rvm_sha256_for_contents ()
{
if builtin command -v sha256sum > /dev/null; then
sha256sum | __rvm_awk '{print $1}';
else
if builtin command -v sha256 > /dev/null; then
sha256 | __rvm_awk '{print $1}';
else
if builtin command -v shasum > /dev/null; then
shasum -a256 | __rvm_awk '{print $1}';
else
if builtin command -v openssl > /dev/null; then
openssl sha -sha256 | __rvm_awk '{print $1}';
else
return 1;
fi;
fi;
fi;
fi;
true
}
__rvm_sha__calculate ()
{
typeset bits _sum;
bits=${1:-512};
shift;
if builtin command -v sha${bits}sum > /dev/null; then
_sum=$(sha${bits}sum "$@");
echo ${_sum% *};
return 0;
else
if builtin command -v sha${bits} > /dev/null; then
_sum=$(sha${bits} "$@");
echo ${_sum% *};
return 0;
else
if builtin command -v shasum > /dev/null; then
_sum=$(shasum -a${bits} "$@");
echo ${_sum% *};
return 0;
fi;
fi;
fi;
rvm_error "Neither sha512sum nor shasum found in the PATH";
return 1
}
__rvm_source_dir ()
{
if [[ ${rvm_ruby_selected_flag:-0} -eq 0 ]]; then
__rvm_select;
fi;
if [[ -z "$rvm_ruby_src_path" ]]; then
rvm_error "No source directory exists for the default implementation.";
else
echo "$rvm_ruby_src_path";
fi;
return 0
}
__rvm_string_includes ()
{
typeset __search __text="$1";
shift;
for __search in "$@";
do
if [[ " ${__text} " =~ " ${__search} " ]]; then
return 0;
fi;
done;
return 1
}
__rvm_string_match ()
{
typeset _string;
_string="$1";
shift;
while (( $# )); do
case "${_string}" in
$1)
return 0
;;
esac;
shift;
done;
return 1
}
__rvm_strings ()
{
typeset strings ruby_strings;
ruby_strings=($(echo ${rvm_ruby_args:-$rvm_ruby_string}));
for rvm_ruby_string in "${ruby_strings[@]}";
do
strings="$strings $(__rvm_select ; echo $rvm_ruby_string)";
done;
echo $strings;
return 0
}
__rvm_strip ()
{
__rvm_sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' -e 's/[[:space:]]\{1,\}/ /g';
return $?
}
__rvm_switch ()
{
typeset new_rvm_path new_rvm_bin_path;
(( $# )) && [[ -z "$1" ]] && shift || true;
(( $# )) && [[ -n "$1" ]] && [[ -d "$1" || -d "${1%/*}" ]] && [[ ! -f "$1" ]] || {
rvm_error "No valid path given.";
return 1
};
[[ "${rvm_path}" != "${new_rvm_path}" ]] || {
rvm_warn "Already there!";
return 2
};
rvm_log "Switching ${rvm_path} => ${1}";
new_rvm_path="${1%/}";
new_rvm_bin_path="${2:-$new_rvm_path/bin}";
new_rvm_bin_path="${new_rvm_bin_path%/}";
__rvm_use_system;
__rvm_remove_from_path "${rvm_path%/}/*";
rvm_reload_flag=1;
rvm_path="${new_rvm_path}";
rvm_bin_path="${new_rvm_bin_path}";
rvm_scripts_path="${rvm_path}/scripts";
rvm_environments_path="${rvm_path}/environments";
__rvm_remove_from_path "${rvm_path%/}/*";
__rvm_add_to_path prepend "${rvm_bin_path}"
}
__rvm_system_name_is ()
{
[[ "${_system_name}" == "$1" ]]
}
__rvm_system_path ()
{
rvm_remote_server_path="$(__rvm_db "rvm_remote_server_path${2:-}")";
[[ -n "${rvm_remote_server_path}" ]] || if __rvm_detect_system; then
rvm_remote_server_path="${_system_name}/${_system_version}/${_system_arch}";
else
return $?;
fi;
if [[ "${1:-}" == "-" ]]; then
printf "%b" "${rvm_remote_server_path}\n";
fi
}
__rvm_system_path_for ()
{
typeset _iterator rvm_remote_server_type rvm_remote_server_path;
_iterator="";
while :; do
rvm_remote_server_type="$(__rvm_db "rvm_remote_server_type${_iterator}")";
[[ -n "${rvm_remote_server_type}" ]] || return 0;
if [[ "${rvm_remote_server_type}" == "$1" || "$1" == "all" ]]; then
__rvm_system_path - "${_iterator}";
fi;
: $(( _iterator+=1 ));
done | sort -u | \tr "\n" "|" | __rvm_sed 's/|$//'
}
__rvm_table ()
{
if [[ -n "${1:-}" ]]; then
__rvm_table_br;
echo "$1" | __rvm_table_wrap_text;
fi;
__rvm_table_br;
\cat "${2:--}" | __rvm_table_wrap_text;
__rvm_table_br
}
__rvm_table_br ()
{
typeset width=${COLUMNS:-78};
width=$(( width > 116 ? 116 : width ));
printf "%-${width}s\n" " " | __rvm_sed 's/ /*/g'
}
__rvm_table_wrap_text ()
{
typeset width=${COLUMNS:-78};
width=$(( width > 116 ? 116 : width ));
width=$(( width - 4 ));
__rvm_fold $width | __rvm_awk -v width=$width '{printf "* %-"width"s *\n", $0}'
}
__rvm_tail ()
{
\tail "$@" || return $?
}
__rvm_teardown ()
{
if builtin command -v __rvm_cleanup_tmp > /dev/null 2>&1; then
__rvm_cleanup_tmp;
fi;
export __rvm_env_loaded;
: __rvm_env_loaded:${__rvm_env_loaded:=${rvm_tmp_path:+1}}:;
: __rvm_env_loaded:${__rvm_env_loaded:=0}:;
: __rvm_env_loaded:$(( __rvm_env_loaded-=1 )):;
if [[ -z "${rvm_tmp_path:-}" ]] || (( __rvm_env_loaded > 0 )); then
return 0;
fi;
if [[ -n "${BASH_VERSION:-}" ]]; then
trap - 0 1 2 3 15;
fi;
if [[ -n "${ZSH_VERSION:-""}" ]]; then
(( rvm_zsh_clobber == 0 )) && setopt noclobber;
(( rvm_zsh_nomatch == 0 )) || setopt nomatch;
unset rvm_zsh_clobber rvm_zsh_nomatch;
fi;
if [[ -n "${rvm_stored_umask:-}" ]]; then
umask ${rvm_stored_umask};
unset rvm_stored_umask;
fi;
if [[ "${rvm_stored_errexit:-""}" == "1" ]]; then
set -e;
fi;
__variables_definition unset;
if builtin command -v __rvm_cleanup_download > /dev/null 2>&1; then
__rvm_cleanup_download;
fi;
return 0
}
__rvm_teardown_final ()
{
__rvm_env_loaded=1;
unset __rvm_project_rvmrc_lock;
__rvm_teardown
}
__rvm_trust_rvmrc ()
{
[[ -f "$1" ]] || return 1;
__rvm_reset_rvmrc_trust "$1";
"$rvm_scripts_path/db" "$rvm_user_path/rvmrcs" "$(__rvm_rvmrc_key "$1")" "1;$(__rvm_checksum_for_contents "$1")" > /dev/null 2>&1 || return $?
}
__rvm_try_sudo ()
{
( typeset -a command_to_run;
command_to_run=("$@");
(( UID == 0 )) || case "$rvm_autolibs_flag_number" in
0)
rvm_debug "Running '$*' would require sudo.";
return 0
;;
1)
rvm_warn "Running '$*' would require sudo.";
return 0
;;
2)
rvm_requiremnts_fail error "Running '$*' would require sudo.";
return 1
;;
*)
if __rvm_which sudo > /dev/null; then
command_to_run=(sudo -p "%p password required for '${command_to_run[*]}': " "${command_to_run[@]}");
else
rvm_requiremnts_fail error "Running '$*' would require sudo, but 'sudo' is not available!";
return 1;
fi
;;
esac;
"${command_to_run[@]}" || return $? )
}
__rvm_unload ()
{
typeset _element;
typeset -a _list;
__rvm_remove_rvm_from_path;
if [[ -n "${ZSH_VERSION:-}" ]]; then
__rvm_remove_from_array fpath "$rvm_path/scripts/extras/completion.zsh" "${fpath[@]}";
fi;
__rvm_unload_action unalias <(
if [[ -n "${ZSH_VERSION:-}" ]]
then alias | __rvm_awk -F"=" '/rvm/ {print $1}'
else alias | __rvm_awk -F"[= ]" '/rvm/ {print $2}'
fi
);
__rvm_unload_action unset <(
set |
__rvm_awk -F"=" 'BEGIN{v=0;} /^[a-zA-Z_][a-zA-Z0-9_]*=/{v=1;} v==1&&$2~/^['\''\$]/{v=2;}
v==1&&$2~/^\(/{v=3;} v==2&&/'\''$/&&!/'\'\''$/{v=1;} v==3&&/\)$/{v=1;} v{print;} v==1{v=0;}' |
__rvm_awk -F"=" '/^[^ ]*(RUBY|GEM|IRB|gem|rubies|rvm)[^ ]*=/ {print $1} /^[^ ]*=.*rvm/ {print $1}' |
__rvm_grep -vE "^PROMPT|^prompt|^PS|^BASH_SOURCE"
);
__rvm_unload_action __function_unset <(
typeset -f | __rvm_awk '$2=="()" {fun=$1} /rvm/{print fun}' | sort -u | __rvm_grep -v __rvm_unload_action
);
if [[ -n "${ZSH_VERSION:-}" ]]; then
unset -f __rvm_unload_action;
unset -f __function_unset;
if [[ -n "${_comp_dumpfile:-}" ]]; then
\rm -f "$_comp_dumpfile";
compinit -d "$_comp_dumpfile";
fi;
else
unset __rvm_unload_action __function_unset;
fi
}
__rvm_unload_action ()
{
typeset _element IFS;
typeset -a _list;
IFS='
';
_list=($( \cat ${2:--} | sort -u ));
for _element in "${_list[@]}";
do
$1 "${_element}";
done
}
__rvm_unset_exports ()
{
typeset wrap_name name value;
while IFS== read -d "" wrap_name value; do
case "$wrap_name" in
rvm_old_*)
name=${wrap_name#rvm_old_};
if [[ -n "${value:-}" ]]; then
export $name="${value}";
else
unset $name;
fi;
unset $wrap_name
;;
esac;
done < <(printenv_null)
}
__rvm_unset_ruby_variables ()
{
unset rvm_env_string rvm_ruby_string rvm_ruby_strings rvm_ruby_binary rvm_ruby_gem_home rvm_ruby_gem_path rvm_ruby_home rvm_ruby_interpreter rvm_ruby_irbrc rvm_ruby_log_path rvm_ruby_major_version rvm_ruby_minor_version rvm_ruby_package_name rvm_ruby_patch_level rvm_ruby_release_version rvm_ruby_repo_url rvm_ruby_repo_branch rvm_ruby_revision rvm_ruby_selected_flag rvm_ruby_tag rvm_ruby_version rvm_head_flag rvm_ruby_package_file rvm_ruby_configure rvm_ruby_name rvm_ruby_url rvm_ruby_global_gems_path rvm_ruby_args rvm_ruby_name rvm_llvm_flag;
__rvm_load_rvmrc
}
__rvm_untrust_rvmrc ()
{
[[ -f "$1" ]] || return 1;
__rvm_reset_rvmrc_trust "$1";
"${rvm_scripts_path:-"$rvm_path/scripts"}/db" "$rvm_user_path/rvmrcs" "$(__rvm_rvmrc_key "$1")" "0;$(__rvm_checksum_for_contents "$1")" > /dev/null 2>&1 || return $?
}
__rvm_use ()
{
typeset new_path binary full_binary_path rvm_ruby_gem_home;
__rvm_select "$@" || return $?;
if [[ "system" == ${rvm_ruby_interpreter:="system"} ]]; then
__rvm_use_system;
else
if [[ ! -d "$rvm_ruby_home" ]]; then
if [[ ${rvm_install_on_use_flag:-0} -eq 1 ]]; then
rvm_warn "$rvm_ruby_string is not installed.";
__rvm_run_wrapper manage "install" "$rvm_ruby_string";
else
rvm_error "$rvm_ruby_string is not installed.";
rvm_log "To install do: 'rvm install $rvm_ruby_string'";
export rvm_recommended_ruby="rvm install $rvm_ruby_string";
return 1;
fi;
fi;
if [[ ! -d "$rvm_ruby_gem_home" || -n "${rvm_expected_gemset_name}" ]]; then
if (( ${rvm_gemset_create_on_use_flag:=0} == 1 || ${rvm_create_flag:=0} == 1 )); then
rvm_warn "gemset $rvm_gemset_name is not existing, creating.";
"$rvm_scripts_path/gemsets" create "$rvm_gemset_name";
else
rvm_error "Gemset '${rvm_expected_gemset_name}' does not exist, 'rvm $rvm_ruby_string do rvm gemset create ${rvm_expected_gemset_name}' first, or append '--create'.";
return 2;
fi;
fi;
export GEM_HOME GEM_PATH MY_RUBY_HOME RUBY_VERSION IRBRC;
GEM_HOME="$rvm_ruby_gem_home";
GEM_PATH="$rvm_ruby_gem_path";
MY_RUBY_HOME="$rvm_ruby_home";
RUBY_VERSION="$rvm_ruby_string";
IRBRC="$rvm_ruby_irbrc";
unset BUNDLE_PATH;
if [[ "maglev" == "$rvm_ruby_interpreter" ]]; then
GEM_PATH="$GEM_PATH:$MAGLEV_HOME/lib/maglev/gems/1.8/";
fi;
[[ -n "${IRBRC:-}" ]] || unset IRBRC;
__rvm_ensure_has_environment_files;
if (( ${rvm_use_flag:-1} >= 2 )) || (( ${rvm_use_flag:-1} == 1 && ${rvm_verbose_flag:-0} == 1 )); then
rvm_log "Using ${GEM_HOME/${rvm_gemset_separator:-'@'}/ with gemset }";
fi;
if [[ "$GEM_HOME" != "$rvm_ruby_global_gems_path" ]]; then
new_path="$GEM_HOME/bin:$rvm_ruby_global_gems_path/bin:${rvm_ruby_binary%/*}:${rvm_bin_path}:$(__rvm_remove_rvm_from_path ;printf "%b" "$PATH")";
else
new_path="$GEM_HOME/bin:${rvm_ruby_binary%/*}:${rvm_bin_path}:$(__rvm_remove_rvm_from_path ;printf "%b" "$PATH")";
fi;
fi;
[[ -z "${rvm_ruby_string:-}" ]] || export rvm_ruby_string;
[[ -z "${rvm_gemset_name:-}" ]] || export rvm_gemset_name;
if [[ -n "$new_path" ]]; then
export PATH="$new_path";
unset new_path;
builtin hash -r;
fi;
if [[ "$rvm_ruby_string" != "system" ]]; then
case "${rvm_rvmrc_flag:-0}" in
rvmrc | versions_conf | ruby_version)
__rvm_set_${rvm_rvmrc_flag}
;;
esac;
typeset environment_id;
environment_id="$(__rvm_env_string)";
if (( ${rvm_default_flag:=0} == 1 )) && [[ "default" != "${rvm_ruby_interpreter:-}" ]] && [[ "system" != "${rvm_ruby_interpreter:-}" ]]; then
"$rvm_scripts_path/alias" delete default &>/dev/null;
"$rvm_scripts_path/alias" create default "$environment_id" &>/dev/null;
fi;
rvm_default_flag=0;
if [[ -n "${rvm_wrapper_name:-}" ]]; then
"$rvm_scripts_path/wrapper" "$environment_id" "$rvm_wrapper_name" > /dev/null 2>&1;
rvm_wrapper_name="";
fi;
if [[ -n "${rvm_ruby_alias:-}" ]]; then
rvm_log "Attempting to alias $environment_id to $rvm_ruby_alias";
"$rvm_scripts_path/alias" delete "$rvm_ruby_alias" > /dev/null 2>&1;
rvm_alias_expanded=1 "$rvm_scripts_path/alias" create "$rvm_ruby_alias" "$environment_id" > /dev/null 2>&1;
ruby_alias="";
rvm_ruby_alias="";
fi;
else
if (( ${rvm_default_flag:=0} == 1 )); then
if ! builtin command -v __rvm_reset >> /dev/null 2>&1; then
source "$rvm_scripts_path/functions/reset";
__rvm_reset;
fi;
fi;
fi;
rvm_hook="after_use";
source "$rvm_scripts_path/hook";
return 0
}
__rvm_use_ruby_warnings ()
{
if [[ "${rvm_ruby_string}" == "system" ]]; then
return 0;
fi;
typeset __executable __gem_version;
for __executable in ruby gem irb;
do
[[ -x "$MY_RUBY_HOME/bin/${__executable}" ]] || rvm_warn "Warning! Executable '${__executable}' missing, something went wrong with this ruby installation!";
done;
if [[ "${rvm_ruby_interpreter}" == "ruby" ]] && {
__rvm_version_compare "${rvm_ruby_version}" -ge 2.0.0 || [[ "${rvm_ruby_version}" == "head" ]]
} && __rvm_which gem > /dev/null && __gem_version="$(gem --version)" && [[ -n "${__gem_version}" ]] && __rvm_version_compare "${__gem_version}" -lt "2.0.0"; then
rvm_warn "Warning! You have just used ruby 2.0.0 or newer, which is not fully compatible with rubygems 1.8.x or older,
consider upgrading rubygems with: 'rvm rubygems latest'.";
fi
}
__rvm_use_system ()
{
unset GEM_HOME GEM_PATH MY_RUBY_HOME RUBY_VERSION IRBRC;
new_path="$(__rvm_remove_rvm_from_path ; printf "%b" "$PATH"):${rvm_bin_path}";
if [[ -s "$rvm_path/config/system" ]]; then
if __rvm_grep "MY_RUBY_HOME='$rvm_rubies_path" "$rvm_path/config/system" > /dev/null; then
if [[ -f "$rvm_path/config/system" ]]; then
\rm -f "$rvm_path/config/system";
fi;
else
source "$rvm_path/config/system";
fi;
fi;
if (( ${rvm_default_flag:=0} == 1 )); then
"$rvm_scripts_path/alias" delete default &>/dev/null;
__rvm_find "${rvm_bin_path}" -maxdepth 0 -name 'default_*' -delete;
\rm -f "$rvm_path/config/default";
\rm -f "$rvm_environments_path/default";
__rvm_rm_rf "$rvm_wrappers_path/default";
fi;
if (( ${rvm_verbose_flag:=0} == 1 )); then
rvm_log "Now using system ruby.";
fi;
__rvm_remove_rvm_from_path;
new_path="$PATH:${rvm_bin_path}";
export rvm_ruby_string="system"
}
__rvm_using_gemset_globalcache ()
{
"$rvm_scripts_path/db" "$rvm_user_path/db" "use_gemset_globalcache" | __rvm_grep '^true$' > /dev/null 2>&1;
return $?
}
__rvm_version ()
{
__rvm_meta;
typeset IFS release;
IFS=':';
rvm_meta_authors="${rvm_meta_authors[*]}";
rvm_meta_authors="${rvm_meta_authors//:/, }";
echo -e "\nrvm ${rvm_meta_version} by ${rvm_meta_authors} [${rvm_meta_website}]\n"
}
__rvm_version_compare ()
{
typeset first;
first="$( printf "%b" "$1\n$3\n" | __rvm_version_sort | head -n1 )";
case "$2" in
-eq | == | =)
[[ "$1" == "$3" ]] || return $?
;;
-ne | !=)
[[ "$1" != "$3" ]] || return $?
;;
-gt | \>)
[[ "$first" == "$3" && "$1" != "$3" ]] || return $?
;;
-ge | \>=)
[[ "$first" == "$3" || "$1" == "$3" ]] || return $?
;;
-lt | \<)
[[ "$first" == "$1" && "$1" != "$3" ]] || return $?
;;
-le | \<=)
[[ "$first" == "$1" || "$1" == "$3" ]] || return $?
;;
*)
rvm_error "Unsupported operator '$2'.";
return 1
;;
esac;
return 0
}
__rvm_version_sort ()
{
LC_ALL=C sort -t. -k 1,1n -k 2,2n -k 3,3n -k 4,4n -k 5,5n
}
__rvm_wait_anykey ()
{
if [[ -n "${1:-}" ]]; then
echo "$1";
fi;
typeset _read_char_flag;
if [[ -n "${ZSH_VERSION:-}" ]]; then
_read_char_flag=k;
else
_read_char_flag=n;
fi;
builtin read -${_read_char_flag} 1 -s -r anykey
}
__rvm_which ()
{
if command which --skip-alias --skip-functions which > /dev/null 2>&1; then
command which --skip-alias --skip-functions "$@";
else
if command whence whence > /dev/null 2>&1; then
command whence -p "$@";
else
if command which which > /dev/null 2>&1; then
command which "$@";
else
if which which > /dev/null 2>&1; then
which "$@";
else
return 1;
fi;
fi;
fi;
fi
}
__rvm_with ()
{
( __rvm_use "$1";
shift;
"$@" || return $? )
}
__rvmrc_full_path_to_file ()
{
if [[ "$1" == "all.rvmrcs" || "$1" == "allGemfiles" ]]; then
__rvmrc_warning_file="$1";
else
if [[ -d "$1" && -s "$1/.rvmrc" ]]; then
__rvmrc_warning_file="$( __rvm_cd "$1" >/dev/null 2>&1; pwd )/.rvmrc";
else
if [[ -d "$1" && -s "$1/Gemfile" ]]; then
__rvmrc_warning_file="$( __rvm_cd "$1" >/dev/null 2>&1; pwd )/Gemfile";
else
if [[ -f "$1" || "$1" =~ "*.rvmrc" || "$1" =~ "*Gemfile" ]]; then
__rvmrc_warning_file="$( dirname "$1" )";
: __rvmrc_warning_file:${__rvmrc_warning_file:=$PWD};
__rvmrc_warning_file="${__rvmrc_warning_file}/${1##*/}";
else
rvm_warn "Do not know how to handle '$1', please report: http://bit.ly/rvm-issues ~ __rvmrc_full_path_to_file" 1>&2;
return 1;
fi;
fi;
fi;
fi
}
__rvmrc_warning ()
{
typeset __rvmrc_warning_path __rvmrc_warning_file;
__rvmrc_warning_path="$rvm_user_path/rvmrc_ignored";
case "${1:-help}" in
list)
__rvmrc_warning_$1 "${2:-}" || return $?
;;
check | check_quiet | ignore | reset)
__rvmrc_full_path_to_file "${2:-}" && __rvmrc_warning_$1 "${__rvmrc_warning_file:-${2:-}}" || return $?
;;
help)
rvm_help rvmrc warning
;;
*)
rvm_error_help "Unknown subcommand '$1'" rvmrc warning;
return 1
;;
esac
}
__rvmrc_warning_check ()
{
if __rvmrc_warning_check_quiet "$1"; then
rvm_log "path '$1' is ignored.";
else
typeset ret=$?;
rvm_log "path '$1' is not ignored.";
return $ret;
fi
}
__rvmrc_warning_check_quiet ()
{
typeset __rvmrc_type;
case "$1" in
all.rvmrcs | allGemfiles)
__rvmrc_type="${1#all}";
__rvmrc_type="/${__rvmrc_type%s}"
;;
*)
__rvmrc_type="^all${1##*/}s"
;;
esac;
[[ -f "$__rvmrc_warning_path" ]] && {
__rvm_grep "^$1$" "$__rvmrc_warning_path" > /dev/null || __rvm_grep "${__rvmrc_type}$" "$__rvmrc_warning_path" > /dev/null
} || return $?
}
__rvmrc_warning_display_for_Gemfile ()
{
typeset __rvmrc_warning_path __rvmrc_warning_file;
__rvmrc_warning_path="$rvm_user_path/rvmrc_ignored";
if [[ -t 2 ]] && __rvmrc_full_path_to_file "${1:-}" && ! __rvmrc_warning_check_quiet "${__rvmrc_warning_file:-${2:-}}"; then
rvm_log "RVM used your Gemfile for selecting Ruby, it is all fine - Heroku does that too,
you can ignore these warnings with 'rvm rvmrc warning ignore $1'.
To ignore the warning for all files run 'rvm rvmrc warning ignore allGemfiles'.
" 1>&2;
fi
}
__rvmrc_warning_display_for_rvmrc ()
{
typeset __rvmrc_warning_path __rvmrc_warning_file;
__rvmrc_warning_path="$rvm_user_path/rvmrc_ignored";
if [[ -t 2 ]] && __rvmrc_full_path_to_file "${1:-}" && ! __rvmrc_warning_check_quiet "${__rvmrc_warning_file:-${2:-}}"; then
rvm_warn "You are using '.rvmrc', it requires trusting, it is slower and it is not compatible with other ruby managers,
you can switch to '.ruby-version' using 'rvm rvmrc to [.]ruby-version'
or ignore this warning with 'rvm rvmrc warning ignore $1',
'.rvmrc' will continue to be the default project file in RVM 1 and RVM 2,
to ignore the warning for all files run 'rvm rvmrc warning ignore all.rvmrcs'.
" 1>&2;
fi
}
__rvmrc_warning_ignore ()
{
__rvmrc_warning_check_quiet "$1" || case "$1" in
all.rvmrcs | allGemfiles)
echo "$1" >> "$__rvmrc_warning_path"
;;
*)
echo "$1" >> "$__rvmrc_warning_path"
;;
esac
}
__rvmrc_warning_list ()
{
rvm_log "# List of project files that ignore warnings:";
if [[ -s "$__rvmrc_warning_path" ]]; then
\cat "$__rvmrc_warning_path";
fi
}
__rvmrc_warning_reset ()
{
typeset __rvmrc_type;
case "${1:-}" in
all.rvmrcs | allGemfiles)
if __rvmrc_warning_check_quiet "$1"; then
__rvm_sed_i "$__rvmrc_warning_path" -e "/^${1//\//\/}\$/ d" -e '/^$/ d';
__rvmrc_type="${1#all}";
__rvmrc_type="${__rvmrc_type%s}";
__rvm_sed_i "$__rvmrc_warning_path" -e "/\/${__rvmrc_type//\//\/}\$/ d" -e '/^$/ d';
else
rvm_debug "Already removed warning ignore from '$1'.";
fi
;;
*)
if __rvmrc_warning_check_quiet "$1"; then
__rvm_sed_i "$__rvmrc_warning_path" -e "/^${1//\//\/}\$/ d" -e '/^$/ d';
else
rvm_debug "Already removed warning ignore from '$1'.";
fi
;;
esac
}
__variables_definition ()
{
typeset -a __variables_list __array_list;
typeset __method;
__method="$1";
__variables_list=(rvm_head_flag rvm_ruby_selected_flag rvm_user_install_flag rvm_path_flag rvm_cron_flag rvm_static_flag rvm_default_flag rvm_loaded_flag rvm_llvm_flag rvm_skip_autoreconf_flag rvm_18_flag rvm_19_flag rvm_20_flag rvm_force_autoconf_flag rvm_dump_environment_flag rvm_verbose_flag rvm_debug_flag rvm_trace_flag __array_start rvm_pretty_print_flag rvm_create_flag rvm_remove_flag rvm_movable_flag rvm_gemdir_flag rvm_reload_flag rvm_auto_reload_flag rvm_disable_binary_flag rvm_ignore_gemsets_flag rvm_skip_gemsets_flag rvm_install_on_use_flag rvm_remote_flag rvm_verify_downloads_flag rvm_skip_openssl_flag rvm_gems_cache_path rvm_gems_path rvm_man_path rvm_ruby_gem_path rvm_ruby_log_path rvm_gems_cache_path rvm_archives_path rvm_docs_path rvm_environments_path rvm_examples_path rvm_gems_path rvm_gemsets_path rvm_help_path rvm_hooks_path rvm_lib_path rvm_log_path rvm_patches_path rvm_repos_path rvm_rubies_path rvm_scripts_path rvm_src_path rvm_tmp_path rvm_user_path rvm_usr_path rvm_wrappers_path rvm_stored_errexit rvm_ruby_strings rvm_ruby_binary rvm_ruby_gem_home rvm_ruby_home rvm_ruby_interpreter rvm_ruby_irbrc rvm_ruby_major_version rvm_ruby_minor_version rvm_ruby_package_name rvm_ruby_patch_level rvm_ruby_release_version rvm_ruby_repo_url rvm_ruby_repo_branch rvm_ruby_revision rvm_ruby_tag rvm_ruby_sha rvm_ruby_version rvm_ruby_package_file rvm_ruby_name rvm_ruby_name rvm_ruby_args rvm_ruby_user_tag rvm_ruby_patch detected_rvm_ruby_name __rvm_env_loaded next_token rvm_error_message rvm_gemset_name rvm_parse_break rvm_token rvm_action rvm_export_args rvm_gemset_separator rvm_expanding_aliases rvm_tar_command rvm_tar_options rvm_patch_original_pwd rvm_project_rvmrc rvm_archive_extension rvm_autoinstall_bundler_flag rvm_codesign_identity rvm_expected_gemset_name rvm_with_gems rvm_without_gems rvm_ignore_dotfiles_flag rvm_latest_binary_flag rvm_fuzzy_flag rvm_autolibs_flag rvm_autolibs_flag_number rvm_autolibs_flag_runner rvm_quiet_curl_flag rvm_max_time_flag rvm_error_clr rvm_warn_clr rvm_debug_clr rvm_notify_clr rvm_reset_clr rvm_error_color rvm_warn_color rvm_debug_color rvm_notify_color rvm_reset_color rvm_log_timestamp rvm_log_filesystem rvm_log_namelen);
__array_list=(rvm_patch_names rvm_ree_options rvm_autoconf_flags rvm_architectures);
case "${__method}" in
export)
export -a "${__array_list[@]}"
;;
unset)
unset "${__array_list[@]}"
;;
*)
rvm_error "Unknown action given to __variables_definition: ${__method}";
return 1
;;
esac;
${__method} "${__variables_list[@]}"
}
_assert_pkg_ebuild_phase ()
{
case ${EBUILD_PHASE} in
setup | preinst | postinst)
;;
*)
eerror "'$1()' called from '${EBUILD_PHASE}' phase which is not OK:";
eerror "You may only call from pkg_{setup,preinst,postinst} functions.";
eerror "Package fails at QA and at life. Please file a bug.";
die "Bad package! $1 is only for use in some pkg_* functions!"
;;
esac
}
_epatch_draw_line ()
{
[[ -z $1 ]] && set "$(printf "%65s" '')";
echo "${1//?/=}"
}
_gcc-install-dir ()
{
echo "$(LC_ALL=C $(tc-getCC) -print-search-dirs 2> /dev/null | awk '$1=="install:" {print $2}')"
}
_gcc-specs-directive_raw ()
{
local cc=$(tc-getCC);
local specfiles=$(LC_ALL=C ${cc} -v 2>&1 | awk '$1=="Reading" {print $NF}');
${cc} -dumpspecs 2> /dev/null | cat - ${specfiles} | awk -v directive=$1 'BEGIN { pspec=""; spec=""; outside=1 }
$1=="*"directive":" { pspec=spec; spec=""; outside=0; next }
outside || NF==0 || ( substr($1,1,1)=="*" && substr($1,length($1),1)==":" ) { outside=1; next }
spec=="" && substr($0,1,1)=="+" { spec=pspec " " substr($0,2); next }
{ spec=spec $0 }
END { print spec }';
return 0
}
_gcc-specs-exists ()
{
[[ -f $(_gcc-install-dir)/$1 ]]
}
_gcc_fullversion ()
{
local ver="$1";
shift;
set -- `$(tc-getCPP "$@") -E -P - <<<"__GNUC__ __GNUC_MINOR__ __GNUC_PATCHLEVEL__"`;
eval echo "$ver"
}
_iconins ()
{
( local funcname=$1;
shift;
local size dir;
local context=apps;
local theme=hicolor;
while [[ $# -gt 0 ]]; do
case $1 in
-s | --size)
if [[ ${2%%x*}x${2%%x*} == "$2" ]]; then
size=${2%%x*};
else
size=${2};
fi;
case ${size} in
16 | 22 | 24 | 32 | 36 | 48 | 64 | 72 | 96 | 128 | 192 | 256)
size=${size}x${size}
;;
scalable)
;;
*)
eerror "${size} is an unsupported icon size!";
exit 1
;;
esac;
shift 2
;;
-t | --theme)
theme=${2};
shift 2
;;
-c | --context)
context=${2};
shift 2
;;
*)
if [[ -z ${size} ]]; then
insinto /usr/share/pixmaps;
else
insinto /usr/share/icons/${theme}/${size}/${context};
fi;
if [[ ${funcname} == doicon ]]; then
if [[ -f $1 ]]; then
doins "${1}";
else
if [[ -d $1 ]]; then
shopt -s nullglob;
doins "${1}"/*.{png,svg};
shopt -u nullglob;
else
eerror "${1} is not a valid file/directory!";
exit 1;
fi;
fi;
else
break;
fi;
shift 1
;;
esac;
done;
if [[ ${funcname} == newicon ]]; then
newins "$@";
fi ) || die
}
_maglev_gemstone ()
{
case "$1" in
start)
export MAGLEV_HOME="$rvm_ruby_home";
export GEMSTONE_GLOBAL_DIR=$MAGLEV_HOME;
if [[ -x "$MAGLEV_HOME/gemstone/bin/gslist" ]]; then
if "$MAGLEV_HOME/gemstone/bin/gslist" -clv > /dev/null 2>&1; then
true;
else
"$rvm_ruby_home/bin/maglev" start;
fi;
fi
;;
esac
}
_tc-getPROG ()
{
local tuple=$1;
local v var vars=$2;
local prog=$3;
var=${vars%% *};
for v in ${vars};
do
if [[ -n ${!v} ]]; then
export ${var}="${!v}";
echo "${!v}";
return 0;
fi;
done;
local search=;
[[ -n $4 ]] && search=$(type -p "$4-${prog}");
[[ -z ${search} && -n ${!tuple} ]] && search=$(type -p "${!tuple}-${prog}");
[[ -n ${search} ]] && prog=${search##*/};
export ${var}=${prog};
echo "${!var}"
}
apecho ()
{
:
}
built_with_use ()
{
local hidden="no";
if [[ $1 == "--hidden" ]]; then
hidden="yes";
shift;
fi;
local missing_action="die";
if [[ $1 == "--missing" ]]; then
missing_action=$2;
shift;
shift;
case ${missing_action} in
true | false | die)
;;
*)
die "unknown action '${missing_action}'"
;;
esac;
fi;
local opt=$1;
[[ ${opt:0:1} = "-" ]] && shift || opt="-a";
local PKG=$(best_version $1);
[[ -z ${PKG} ]] && die "Unable to resolve $1 to an installed package";
shift;
local USEFILE=${ROOT}/var/db/pkg/${PKG}/USE;
local IUSEFILE=${ROOT}/var/db/pkg/${PKG}/IUSE;
if [[ ! -e ${USEFILE} ]] || [[ ! -e ${IUSEFILE} && ${hidden} == "no" ]]; then
case ${missing_action} in
true)
return 0
;;
false)
return 1
;;
die)
die "Unable to determine what USE flags $PKG was built with"
;;
esac;
fi;
if [[ ${hidden} == "no" ]]; then
local IUSE_BUILT=($(<"${IUSEFILE}"));
local expand;
for expand in $(echo ${USE_EXPAND} | tr '[:upper:]' '[:lower:]');
do
if [[ $1 == ${expand}_* ]]; then
expand="";
break;
fi;
done;
if [[ -n ${expand} ]]; then
if ! has $1 ${IUSE_BUILT[@]#[-+]}; then
case ${missing_action} in
true)
return 0
;;
false)
return 1
;;
die)
die "$PKG does not actually support the $1 USE flag!"
;;
esac;
fi;
fi;
fi;
local USE_BUILT=$(<${USEFILE});
while [[ $# -gt 0 ]]; do
if [[ ${opt} = "-o" ]]; then
has $1 ${USE_BUILT} && return 0;
else
has $1 ${USE_BUILT} || return 1;
fi;
shift;
done;
[[ ${opt} = "-a" ]]
}
cd ()
{
if builtin cd "$@"; then
[[ -n "${rvm_current_rvmrc:-}" && "$*" == "." ]] && rvm_current_rvmrc="" || true;
__rvm_cd_functions_set;
return 0;
else
return $?;
fi
}
change_permissions ()
{
local directory=$1;
[[ -d $1 ]] || return;
addwrite ${directory};
local dirowner=$(stat -c"%u:%g" ${directory});
local dirmode=0$(stat -c%a ${directory});
local dirmode=0$(stat -c%a ${directory});
if which bc &>/dev/null; then
local filemode=0$(echo "obase=8;$(( $dirmode & 0666 ))" | bc);
else
if which printf &>/dev/null; then
local filemode=$(printf "0%o" $(( $dirmode & 0666 )) );
else
local filemode=;
fi;
fi;
chown -R ${dirowner} ${directory};
find ${directory} \! -perm ${dirmode} -type d -exec chmod ${dirmode} {} \;;
if [[ -n $filemode ]]; then
find ${directory} \! -perm ${filemode} -type f -exec chmod ${filemode} {} \;;
fi
}
check_license ()
{
die "you no longer need this as portage supports ACCEPT_LICENSE itself"
}
doicon ()
{
_iconins ${FUNCNAME} "$@"
}
domenu ()
{
( local i j ret=0;
insinto /usr/share/applications;
for i in "$@";
do
if [[ -f ${i} ]]; then
doins "${i}";
((ret+=$?));
else
if [[ -d ${i} ]]; then
for j in "${i}"/*.desktop;
do
doins "${j}";
((ret+=$?));
done;
else
((++ret));
fi;
fi;
done;
exit ${ret} )
}
ebeep ()
{
local n;
if [[ -z ${EBEEP_IGNORE} ]]; then
for ((n=1 ; n <= ${1:-5} ; n++))
do
echo -ne "\a";
sleep 0.1 &>/dev/null;
sleep 0,1 &>/dev/null;
echo -ne "\a";
sleep 1;
done;
fi
}
econf_build ()
{
tc-env_build econf --build=${CBUILD:-${CHOST}} "$@"
}
ecvs_clean ()
{
[[ -z $* ]] && set -- .;
find "$@" -type d -name 'CVS' -prune -print0 | xargs -0 rm -rf;
find "$@" -type f -name '.cvs*' -print0 | xargs -0 rm -rf
}
edos2unix ()
{
[[ $# -eq 0 ]] && return 0;
sed -i 's/\r$//' -- "$@" || die
}
egetent ()
{
local db=$1 key=$2;
[[ $# -ge 3 ]] && die "usage: egetent <database> <key>";
case ${db} in
passwd | group)
;;
*)
die "sorry, database '${db}' not yet supported; file a bug"
;;
esac;
case ${CHOST} in
*-darwin[678])
case ${key} in
*[!0-9]*)
nidump ${db} . | awk -F: "(\$1 ~ /^${key}\$/) {print;exit;}"
;;
*)
nidump ${db} . | awk -F: "(\$3 == ${key}) {print;exit;}"
;;
esac
;;
*-darwin*)
local mykey;
case ${db} in
passwd)
db="Users" mykey="UniqueID"
;;
group)
db="Groups" mykey="PrimaryGroupID"
;;
esac;
case ${key} in
*[!0-9]*)
dscl . -read /${db}/${key} 2> /dev/null | grep RecordName
;;
*)
dscl . -search /${db} ${mykey} ${key} 2> /dev/null
;;
esac
;;
*-freebsd* | *-dragonfly*)
case ${db} in
passwd)
db="user"
;;
*)
;;
esac;
local opts;
if [[ ${key} == [[:digit:]]* ]]; then
[[ ${db} == "user" ]] && opts="-u" || opts="-g";
fi;
pw show ${db} ${opts} "${key}" -q
;;
*-netbsd* | *-openbsd*)
grep "${key}:\*:" /etc/${db}
;;
*)
nscd -i "${db}" 2> /dev/null;
getent "${db}" "${key}"
;;
esac
}
egethome ()
{
local pos;
[[ $# -eq 1 ]] || die "usage: egethome <user>";
case ${CHOST} in
*-darwin* | *-freebsd* | *-dragonfly*)
pos=9
;;
*)
pos=6
;;
esac;
egetent passwd "$1" | cut -d: -f${pos}
}
egetshell ()
{
local pos;
[[ $# -eq 1 ]] || die "usage: egetshell <user>";
case ${CHOST} in
*-darwin* | *-freebsd* | *-dragonfly*)
pos=10
;;
*)
pos=7
;;
esac;
egetent passwd "$1" | cut -d: -f${pos}
}
emktemp ()
{
local exe="touch";
[[ $1 == -d ]] && exe="mkdir" && shift;
local topdir=$1;
if [[ -z ${topdir} ]]; then
[[ -z ${T} ]] && topdir="/tmp" || topdir=${T};
fi;
if ! type -P mktemp > /dev/null; then
local tmp=/;
while [[ -e ${tmp} ]]; do
tmp=${topdir}/tmp.${RANDOM}.${RANDOM}.${RANDOM};
done;
${exe} "${tmp}" || ${exe} -p "${tmp}";
echo "${tmp}";
else
if [[ ${exe} == "touch" ]]; then
TMPDIR="${topdir}" mktemp -t tmp.XXXXXXXXXX;
else
TMPDIR="${topdir}" mktemp -dt tmp.XXXXXXXXXX;
fi;
fi
}
enewgroup ()
{
_assert_pkg_ebuild_phase ${FUNCNAME};
local egroup=$1;
shift;
if [[ -z ${egroup} ]]; then
eerror "No group specified !";
die "Cannot call enewgroup without a group";
fi;
if [[ -n $(egetent group "${egroup}") ]]; then
return 0;
fi;
einfo "Adding group '${egroup}' to your system ...";
local egid=$1;
shift;
if [[ ! -z ${egid} ]]; then
if [[ ${egid} -gt 0 ]]; then
if [[ -n $(egetent group ${egid}) ]]; then
egid="next available; requested gid taken";
fi;
else
eerror "Groupid given but is not greater than 0 !";
die "${egid} is not a valid GID";
fi;
else
egid="next available";
fi;
einfo " - Groupid: ${egid}";
if [[ $# -gt 0 ]]; then
die "extra arguments no longer supported; please file a bug";
fi;
function _enewgroup_next_gid ()
{
if [[ ${egid} == *[!0-9]* ]]; then
for ((egid = 101; egid <= 999; egid++))
do
[[ -z $(egetent group ${egid}) ]] && break;
done;
fi
};
case ${CHOST} in
*-darwin*)
_enewgroup_next_gid;
dscl . create "/groups/${egroup}" gid ${egid};
dscl . create "/groups/${egroup}" passwd '*'
;;
*-freebsd* | *-dragonfly*)
_enewgroup_next_gid;
pw groupadd "${egroup}" -g ${egid} || die
;;
*-netbsd*)
_enewgroup_next_gid;
groupadd -g ${egid} "${egroup}" || die
;;
*)
local opts;
if [[ ${egid} == *[!0-9]* ]]; then
opts="";
else
opts="-g ${egid}";
fi;
groupadd -r ${opts} "${egroup}" || die
;;
esac
}
enewuser ()
{
_assert_pkg_ebuild_phase ${FUNCNAME};
local euser=$1;
shift;
if [[ -z ${euser} ]]; then
eerror "No username specified !";
die "Cannot call enewuser without a username";
fi;
if [[ -n $(egetent passwd "${euser}") ]]; then
return 0;
fi;
einfo "Adding user '${euser}' to your system ...";
local opts=();
local euid=$1;
shift;
if [[ -n ${euid} && ${euid} != -1 ]]; then
if [[ ${euid} -gt 0 ]]; then
if [[ -n $(egetent passwd ${euid}) ]]; then
euid="next";
fi;
else
eerror "Userid given but is not greater than 0 !";
die "${euid} is not a valid UID";
fi;
else
euid="next";
fi;
if [[ ${euid} == "next" ]]; then
for ((euid = 101; euid <= 999; euid++))
do
[[ -z $(egetent passwd ${euid}) ]] && break;
done;
fi;
opts+=(-u ${euid});
einfo " - Userid: ${euid}";
local eshell=$1;
shift;
if [[ ! -z ${eshell} ]] && [[ ${eshell} != "-1" ]]; then
if [[ ! -e ${ROOT}${eshell} ]]; then
eerror "A shell was specified but it does not exist !";
die "${eshell} does not exist in ${ROOT}";
fi;
if [[ ${eshell} == */false || ${eshell} == */nologin ]]; then
eerror "Do not specify ${eshell} yourself, use -1";
die "Pass '-1' as the shell parameter";
fi;
else
for eshell in /sbin/nologin /usr/sbin/nologin /bin/false /usr/bin/false /dev/null;
do
[[ -x ${ROOT}${eshell} ]] && break;
done;
if [[ ${eshell} == "/dev/null" ]]; then
eerror "Unable to identify the shell to use, proceeding with userland default.";
case ${USERLAND} in
GNU)
eshell="/bin/false"
;;
BSD)
eshell="/sbin/nologin"
;;
Darwin)
eshell="/usr/sbin/nologin"
;;
*)
die "Unable to identify the default shell for userland ${USERLAND}"
;;
esac;
fi;
fi;
einfo " - Shell: ${eshell}";
opts+=(-s "${eshell}");
local ehome=$1;
shift;
if [[ -z ${ehome} ]] || [[ ${ehome} == "-1" ]]; then
ehome="/dev/null";
fi;
einfo " - Home: ${ehome}";
opts+=(-d "${ehome}");
local egroups=$1;
shift;
local g egroups_arr;
IFS="," read -r -a egroups_arr <<< "${egroups}";
shift;
if [[ ${#egroups_arr[@]} -gt 0 ]]; then
local defgroup exgroups;
for g in "${egroups_arr[@]}";
do
if [[ -z $(egetent group "${g}") ]]; then
eerror "You must add group ${g} to the system first";
die "${g} is not a valid GID";
fi;
if [[ -z ${defgroup} ]]; then
defgroup=${g};
else
exgroups+=",${g}";
fi;
done;
opts+=(-g "${defgroup}");
if [[ ! -z ${exgroups} ]]; then
opts+=(-G "${exgroups:1}");
fi;
fi;
einfo " - Groups: ${egroups:-(none)}";
if [[ $# -gt 0 ]]; then
die "extra arguments no longer supported; please file a bug";
else
local comment="added by portage for ${PN}";
opts+=(-c "${comment}");
einfo " - GECOS: ${comment}";
fi;
case ${CHOST} in
*-darwin*)
dscl . create "/users/${euser}" uid ${euid};
dscl . create "/users/${euser}" shell "${eshell}";
dscl . create "/users/${euser}" home "${ehome}";
dscl . create "/users/${euser}" realname "added by portage for ${PN}";
for g in "${egroups_arr[@]}";
do
dscl . merge "/groups/${g}" users "${euser}";
done
;;
*-freebsd* | *-dragonfly*)
pw useradd "${euser}" "${opts[@]}" || die
;;
*-netbsd*)
useradd "${opts[@]}" "${euser}" || die
;;
*-openbsd*)
useradd -u ${euid} -s "${eshell}" -d "${ehome}" -g "${egroups}" "${euser}" || die
;;
*)
useradd -r "${opts[@]}" "${euser}" || die
;;
esac;
if [[ ! -e ${ROOT}/${ehome} ]]; then
einfo " - Creating ${ehome} in ${ROOT}";
mkdir -p "${ROOT}/${ehome}";
chown "${euser}" "${ROOT}/${ehome}";
chmod 755 "${ROOT}/${ehome}";
fi
}
epatch ()
{
function _epatch_draw_line ()
{
[[ -z $1 ]] && set "$(printf "%65s" '')";
echo "${1//?/=}"
};
unset P4CONFIG P4PORT P4USER;
local EPATCH_OPTS=(${EPATCH_OPTS[*]});
while [[ $# -gt 0 ]]; do
case $1 in
-*)
EPATCH_OPTS+=("$1")
;;
*)
break
;;
esac;
shift;
done;
if [[ $# -gt 1 ]]; then
local m;
for m in "$@";
do
epatch "${m}";
done;
return 0;
fi;
local SINGLE_PATCH="no";
[[ $# -eq 0 ]] && set -- "${EPATCH_SOURCE}";
if [[ -f $1 ]]; then
SINGLE_PATCH="yes";
set -- "$1";
local EPATCH_SUFFIX=$1;
else
if [[ -d $1 ]]; then
evar_push_set LC_COLLATE C;
set -- "$1"/*${EPATCH_SUFFIX:+."${EPATCH_SUFFIX}"};
evar_pop;
else
if [[ -f ${EPATCH_SOURCE}/$1 ]]; then
epatch "${EPATCH_SOURCE}/$1";
return $?;
else
[[ $# -ne 0 ]] && EPATCH_SOURCE=$1;
echo;
eerror "Cannot find \$EPATCH_SOURCE! Value for \$EPATCH_SOURCE is:";
eerror;
eerror " ${EPATCH_SOURCE}";
eerror " ( ${EPATCH_SOURCE##*/} )";
echo;
die "Cannot find \$EPATCH_SOURCE!";
fi;
fi;
fi;
EPATCH_OPTS="${EPATCH_COMMON_OPTS} ${EPATCH_OPTS[*]}";
local PIPE_CMD;
case ${EPATCH_SUFFIX##*\.} in
xz)
PIPE_CMD="xz -dc"
;;
lzma)
PIPE_CMD="lzma -dc"
;;
bz2)
PIPE_CMD="bzip2 -dc"
;;
gz | Z | z)
PIPE_CMD="gzip -dc"
;;
ZIP | zip)
PIPE_CMD="unzip -p"
;;
*)
;;
esac;
[[ ${SINGLE_PATCH} == "no" ]] && einfo "${EPATCH_MULTI_MSG}";
local x;
for x in "$@";
do
[[ ! -f ${x} ]] && continue;
local patchname=${x##*/};
local a=${patchname#*_};
a=${a%%_*};
if ! [[ ${SINGLE_PATCH} == "yes" || ${EPATCH_FORCE} == "yes" || ${a} == all || ${a} == ${ARCH} ]]; then
continue;
fi;
if [[ -n ${EPATCH_EXCLUDE} ]]; then
eshopts_push -o noglob;
local ex;
for ex in ${EPATCH_EXCLUDE};
do
if [[ ${patchname} == ${ex} ]]; then
einfo " Skipping ${patchname} due to EPATCH_EXCLUDE ...";
eshopts_pop;
continue 2;
fi;
done;
for ex in ${EPATCH_USER_EXCLUDE};
do
if [[ ${patchname} == ${ex} ]]; then
einfo " Skipping ${patchname} due to EPATCH_USER_EXCLUDE ...";
eshopts_pop;
continue 2;
fi;
done;
eshopts_pop;
fi;
if [[ ${SINGLE_PATCH} == "yes" ]]; then
if [[ -n ${EPATCH_SINGLE_MSG} ]]; then
einfo "${EPATCH_SINGLE_MSG}";
else
einfo "Applying ${patchname} ...";
fi;
else
einfo " ${patchname} ...";
fi;
local STDERR_TARGET="${T}/${patchname}.out";
if [[ -e ${STDERR_TARGET} ]]; then
STDERR_TARGET="${T}/${patchname}-$$.out";
fi;
printf "***** %s *****\nPWD: %s\n\n" "${patchname}" "${PWD}" > "${STDERR_TARGET}";
local count=0;
local PATCH_TARGET;
if [[ -n ${PIPE_CMD} ]]; then
PATCH_TARGET="${T}/$$.patch";
echo "PIPE_COMMAND: ${PIPE_CMD} ${x} > ${PATCH_TARGET}" >> "${STDERR_TARGET}";
if ! ( ${PIPE_CMD} "${x}" > "${PATCH_TARGET}" ) >> "${STDERR_TARGET}" 2>&1; then
echo;
eerror "Could not extract patch!";
count=5;
break;
fi;
else
PATCH_TARGET=${x};
fi;
local abs_paths=$(egrep -n '^[-+]{3} /' "${PATCH_TARGET}" | awk '$2 != "/dev/null" { print }');
if [[ -n ${abs_paths} ]]; then
count=1;
printf "NOTE: skipping -p0 due to absolute paths in patch:\n%s\n" "${abs_paths}" >> "${STDERR_TARGET}";
fi;
local rel_paths=$(egrep -n '^[-+]{3} [^ ]*[.][.]/' "${PATCH_TARGET}");
if [[ -n ${rel_paths} ]]; then
echo;
eerror "Rejected Patch: ${patchname} !";
eerror " ( ${PATCH_TARGET} )";
eerror;
eerror "Your patch uses relative paths '../':";
eerror "${rel_paths}";
echo;
die "you need to fix the relative paths in patch";
fi;
local patch_cmd;
local patch="patch";
eval $(alias patch 2>/dev/null | sed 's:^alias ::');
while [[ ${count} -lt 5 ]]; do
patch_cmd="${patch} -p${count} ${EPATCH_OPTS}";
( _epatch_draw_line "***** ${patchname} *****";
echo;
echo "PATCH COMMAND: ${patch_cmd} < '${PATCH_TARGET}'";
echo;
_epatch_draw_line "***** ${patchname} *****";
${patch_cmd} --dry-run -f < "${PATCH_TARGET}" 2>&1;
ret=$?;
echo;
echo "patch program exited with status ${ret}";
exit ${ret} ) >> "${STDERR_TARGET}";
if [ $? -eq 0 ]; then
( _epatch_draw_line "***** ${patchname} *****";
echo;
echo "ACTUALLY APPLYING ${patchname} ...";
echo;
_epatch_draw_line "***** ${patchname} *****";
${patch_cmd} < "${PATCH_TARGET}" 2>&1;
ret=$?;
echo;
echo "patch program exited with status ${ret}";
exit ${ret} ) >> "${STDERR_TARGET}";
if [ $? -ne 0 ]; then
echo;
eerror "A dry-run of patch command succeeded, but actually";
eerror "applying the patch failed!";
count=5;
fi;
break;
fi;
: $(( count++ ));
done;
if [[ -n ${PIPE_CMD} ]]; then
rm -f "${PATCH_TARGET}";
fi;
if [[ ${count} -ge 5 ]]; then
echo;
eerror "Failed Patch: ${patchname} !";
eerror " ( ${PATCH_TARGET} )";
eerror;
eerror "Include in your bugreport the contents of:";
eerror;
eerror " ${STDERR_TARGET}";
echo;
die "Failed Patch: ${patchname}!";
fi;
rm -f "${STDERR_TARGET}";
cat >> "${T}/epatch.log" <<-EOF
PATCH: ${x}
CMD: ${patch_cmd}
PWD: ${PWD}
EOF
eend 0;
done;
[[ ${SINGLE_PATCH} == "no" ]] && einfo "Done with patching";
:
}
epatch_user ()
{
[[ $# -ne 0 ]] && die "epatch_user takes no options";
local applied="${T}/epatch_user.log";
[[ -e ${applied} ]] && return 2;
local EPATCH_SOURCE check base=${PORTAGE_CONFIGROOT%/}/etc/portage/patches;
for check in ${CATEGORY}/{${P}-${PR},${P},${PN}}{,:${SLOT}};
do
EPATCH_SOURCE=${base}/${CTARGET}/${check};
[[ -r ${EPATCH_SOURCE} ]] || EPATCH_SOURCE=${base}/${CHOST}/${check};
[[ -r ${EPATCH_SOURCE} ]] || EPATCH_SOURCE=${base}/${check};
if [[ -d ${EPATCH_SOURCE} ]]; then
EPATCH_SOURCE=${EPATCH_SOURCE} EPATCH_SUFFIX="patch" EPATCH_FORCE="yes" EPATCH_MULTI_MSG="Applying user patches from ${EPATCH_SOURCE} ..." epatch;
echo "${EPATCH_SOURCE}" > "${applied}";
return 0;
fi;
done;
echo "none" > "${applied}";
return 1
}
epause ()
{
[[ -z ${EPAUSE_IGNORE} ]] && sleep ${1:-5}
}
epunt_cxx ()
{
local dir=$1;
[[ -z ${dir} ]] && dir=${S};
ebegin "Removing useless C++ checks";
local f p any_found;
while IFS= read -r -d '' f; do
for p in "${PORTDIR}"/eclass/ELT-patches/nocxx/*.patch;
do
if patch --no-backup-if-mismatch -p1 "${f}" "${p}" > /dev/null; then
any_found=1;
break;
fi;
done;
done < <(find "${dir}" -name configure -print0);
if [[ -z ${any_found} ]]; then
eqawarn "epunt_cxx called unnecessarily (no C++ checks to punt).";
fi;
eend 0
}
esethome ()
{
_assert_pkg_ebuild_phase ${FUNCNAME};
local euser=$1;
shift;
if [[ -z ${euser} ]]; then
eerror "No username specified !";
die "Cannot call esethome without a username";
fi;
if [[ -z $(egetent passwd "${euser}") ]]; then
ewarn "User does not exist, cannot set home dir -- skipping.";
return 1;
fi;
local ehome=$1;
shift;
if [[ -z ${ehome} ]]; then
eerror "No home directory specified !";
die "Cannot call esethome without a home directory or '-1'";
fi;
if [[ ${ehome} == "-1" ]]; then
ehome="/dev/null";
fi;
if [[ $(egethome "${euser}") == ${ehome} ]]; then
return 0;
fi;
einfo "Updating home for user '${euser}' ...";
einfo " - Home: ${ehome}";
if [[ ! -e ${ROOT}/${ehome} ]]; then
einfo " - Creating ${ehome} in ${ROOT}";
mkdir -p "${ROOT}/${ehome}";
chown "${euser}" "${ROOT}/${ehome}";
chmod 755 "${ROOT}/${ehome}";
fi;
case ${CHOST} in
*-darwin*)
dscl . change "/users/${euser}" home "${ehome}"
;;
*-freebsd* | *-dragonfly*)
pw usermod "${euser}" -d "${ehome}" && return 0;
[[ $? == 8 ]] && eerror "${euser} is in use, cannot update home";
eerror "There was an error when attempting to update the home directory for ${euser}";
eerror "Please update it manually on your system:";
eerror "\t pw usermod \"${euser}\" -d \"${ehome}\""
;;
*)
usermod -d "${ehome}" "${euser}" && return 0;
[[ $? == 8 ]] && eerror "${euser} is in use, cannot update home";
eerror "There was an error when attempting to update the home directory for ${euser}";
eerror "Please update it manually on your system (as root):";
eerror "\t usermod -d \"${ehome}\" \"${euser}\""
;;
esac
}
eshopts_pop ()
{
local s;
estack_pop eshopts s || die "${FUNCNAME}: unbalanced push";
if [[ ${s} == "shopt -"* ]]; then
eval "${s}" || die "${FUNCNAME}: sanity: invalid shopt options: ${s}";
else
set +$- || die "${FUNCNAME}: sanity: invalid shell settings: $-";
set -${s} || die "${FUNCNAME}: sanity: unable to restore saved shell settings: ${s}";
fi
}
eshopts_push ()
{
if [[ $1 == -[su] ]]; then
estack_push eshopts "$(shopt -p)";
[[ $# -eq 0 ]] && return 0;
shopt "$@" || die "${FUNCNAME}: bad options to shopt: $*";
else
estack_push eshopts $-;
[[ $# -eq 0 ]] && return 0;
set "$@" || die "${FUNCNAME}: bad options to set: $*";
fi
}
estack_pop ()
{
[[ $# -eq 0 || $# -gt 2 ]] && die "estack_pop: incorrect # of arguments";
local __estack_name="__ESTACK_$1__";
shift;
local __estack_retvar=$1;
shift;
eval local __estack_i=\${#${__estack_name}\[@\]};
[[ $(( --__estack_i )) -eq -1 ]] && return 1;
if [[ -n ${__estack_retvar} ]]; then
eval ${__estack_retvar}=\"\${${__estack_name}\[${__estack_i}\]}\";
fi;
eval unset ${__estack_name}\[${__estack_i}\]
}
estack_push ()
{
[[ $# -eq 0 ]] && die "estack_push: incorrect # of arguments";
local stack_name="__ESTACK_$1__";
shift;
eval ${stack_name}+=\( \"\$@\" \)
}
esvn_clean ()
{
[[ -z $* ]] && set -- .;
find "$@" -type d -name '.svn' -prune -print0 | xargs -0 rm -rf
}
eumask_pop ()
{
[[ $# -eq 0 ]] || die "${FUNCNAME}: we take no options";
local s;
estack_pop eumask s || die "${FUNCNAME}: unbalanced push";
umask ${s} || die "${FUNCNAME}: sanity: could not restore umask: ${s}"
}
eumask_push ()
{
estack_push eumask "$(umask)";
umask "$@" || die "${FUNCNAME}: bad options to umask: $*"
}
evar_pop ()
{
local cnt=${1:-bad};
case $# in
0)
cnt=1
;;
1)
isdigit "${cnt}" || die "${FUNCNAME}: first arg must be a number: $*"
;;
*)
die "${FUNCNAME}: only accepts one arg: $*"
;;
esac;
local var val;
while (( cnt-- )); do
estack_pop evar val || die "${FUNCNAME}: unbalanced push";
estack_pop evar var || die "${FUNCNAME}: unbalanced push";
[[ ${val} == "${___ECLASS_ONCE_EUTILS}" ]] && unset ${var} || printf -v "${var}" '%s' "${val}";
done
}
evar_push ()
{
local var val;
for var in "$@";
do
[[ ${!var+set} == "set" ]] && val=${!var} || val="${___ECLASS_ONCE_EUTILS}";
estack_push evar "${var}" "${val}";
done
}
evar_push_set ()
{
local var=$1;
evar_push ${var};
case $# in
1)
unset ${var}
;;
2)
printf -v "${var}" '%s' "$2"
;;
*)
die "${FUNCNAME}: incorrect # of args: $*"
;;
esac
}
file_exists_at_url ()
{
( if [[ -n "${1:-}" ]]; then
unset curl;
\curl --silent --insecure --location --list-only --max-time ${rvm_max_time_flag:-3} --head "$1" 2>&1 | __rvm_grep -E 'HTTP/[0-9\.]+ 200 OK' > /dev/null 2>&1 || {
typeset __ret=$?;
case ${__ret} in
28)
rvm_warn "RVM was not able to check existence of remote files with timeout of ${rvm_max_time_flag:-3} seconds
you can increase the timeout by setting it in ~/.rvmrc => rvm_max_time_flag=10"
;;
esac;
return ${__ret}
};
else
rvm_warn "Warning: URL was not passed to file_exists_at_url";
return 1;
fi )
}
gcc-fullversion ()
{
_gcc_fullversion '$1.$2.$3' "$@"
}
gcc-major-version ()
{
_gcc_fullversion '$1' "$@"
}
gcc-micro-version ()
{
_gcc_fullversion '$3' "$@"
}
gcc-minor-version ()
{
_gcc_fullversion '$2' "$@"
}
gcc-specs-directive ()
{
local directive subdname subdirective;
directive="$(_gcc-specs-directive_raw $1)";
while [[ ${directive} == *%\(*\)* ]]; do
subdname=${directive/*%\(};
subdname=${subdname/\)*};
subdirective="$(_gcc-specs-directive_raw ${subdname})";
directive="${directive//\%(${subdname})/${subdirective}}";
done;
echo "${directive}";
return 0
}
gcc-specs-nostrict ()
{
local directive;
directive=$(gcc-specs-directive cc1);
return $([[ "${directive/\{!fstrict-overflow:}" != "${directive}" ]])
}
gcc-specs-now ()
{
local directive;
directive=$(gcc-specs-directive link_command);
return $([[ "${directive/\{!nonow:}" != "${directive}" ]])
}
gcc-specs-pie ()
{
local directive;
directive=$(gcc-specs-directive cc1);
return $([[ "${directive/\{!nopie:}" != "${directive}" ]])
}
gcc-specs-relro ()
{
local directive;
directive=$(gcc-specs-directive link_command);
return $([[ "${directive/\{!norelro:}" != "${directive}" ]])
}
gcc-specs-ssp ()
{
local directive;
directive=$(gcc-specs-directive cc1);
return $([[ "${directive/\{!fno-stack-protector:}" != "${directive}" ]])
}
gcc-specs-ssp-to-all ()
{
local directive;
directive=$(gcc-specs-directive cc1);
return $([[ "${directive/\{!fno-stack-protector-all:}" != "${directive}" ]])
}
gcc-version ()
{
_gcc_fullversion '$1.$2' "$@"
}
gem ()
{
typeset result;
( typeset rvmrc;
rvm_rvmrc_files=("/etc/rvmrc" "$HOME/.rvmrc");
if [[ -n "${rvm_prefix:-}" ]] && ! [[ "$HOME/.rvmrc" -ef "${rvm_prefix}/.rvmrc" ]]; then
rvm_rvmrc_files+=("${rvm_prefix}/.rvmrc");
fi;
for rvmrc in "${rvm_rvmrc_files[@]}";
do
[[ -s "${rvmrc}" ]] && source "${rvmrc}" || true;
done;
unset rvm_rvmrc_files;
command gem "$@" ) || result=$?;
hash -r;
return ${result:-0}
}
gen_usr_ldscript ()
{
local lib libdir=$(get_libdir) output_format="" auto=false suffix=$(get_libname);
[[ -z ${ED+set} ]] && local ED=${D%/}${EPREFIX}/;
tc-is-static-only && return;
case ${CTARGET:-${CHOST}} in
*-darwin*)
;;
*linux* | *-freebsd* | *-openbsd* | *-netbsd*)
use prefix && return 0
;;
*)
return 0
;;
esac;
dodir /usr/${libdir};
if [[ $1 == "-a" ]]; then
auto=true;
shift;
dodir /${libdir};
fi;
output_format=$($(tc-getCC) ${CFLAGS} ${LDFLAGS} -Wl,--verbose 2>&1 | sed -n 's/^OUTPUT_FORMAT("\([^"]*\)",.*/\1/p');
[[ -n ${output_format} ]] && output_format="OUTPUT_FORMAT ( ${output_format} )";
for lib in "$@";
do
local tlib;
if ${auto}; then
lib="lib${lib}${suffix}";
else
[[ -r ${ED}/${libdir}/${lib} ]] || continue;
fi;
case ${CTARGET:-${CHOST}} in
*-darwin*)
if ${auto}; then
tlib=$(scanmacho -qF'%S#F' "${ED}"/usr/${libdir}/${lib});
else
tlib=$(scanmacho -qF'%S#F' "${ED}"/${libdir}/${lib});
fi;
[[ -z ${tlib} ]] && die "unable to read install_name from ${lib}";
tlib=${tlib##*/};
if ${auto}; then
mv "${ED}"/usr/${libdir}/${lib%${suffix}}.*${suffix#.} "${ED}"/${libdir}/ || die;
if [[ ${tlib} != ${lib%${suffix}}.*${suffix#.} ]]; then
mv "${ED}"/usr/${libdir}/${tlib%${suffix}}.*${suffix#.} "${ED}"/${libdir}/ || die;
fi;
rm -f "${ED}"/${libdir}/${lib};
fi;
if [[ ! -w "${ED}/${libdir}/${tlib}" ]]; then
chmod u+w "${ED}${libdir}/${tlib}";
local nowrite=yes;
fi;
install_name_tool -id "${EPREFIX}"/${libdir}/${tlib} "${ED}"/${libdir}/${tlib} || die "install_name_tool failed";
[[ -n ${nowrite} ]] && chmod u-w "${ED}${libdir}/${tlib}";
pushd "${ED}/usr/${libdir}" > /dev/null;
ln -snf "../../${libdir}/${tlib}" "${lib}";
popd > /dev/null
;;
*)
if ${auto}; then
tlib=$(scanelf -qF'%S#F' "${ED}"/usr/${libdir}/${lib});
[[ -z ${tlib} ]] && die "unable to read SONAME from ${lib}";
mv "${ED}"/usr/${libdir}/${lib}* "${ED}"/${libdir}/ || die;
if [[ ${tlib} != ${lib}* ]]; then
mv "${ED}"/usr/${libdir}/${tlib}* "${ED}"/${libdir}/ || die;
fi;
rm -f "${ED}"/${libdir}/${lib};
else
tlib=${lib};
fi;
cat > "${ED}/usr/${libdir}/${lib}" <<-END_LDSCRIPT
/* GNU ld script
Since Gentoo has critical dynamic libraries in /lib, and the static versions
in /usr/lib, we need to have a "fake" dynamic lib in /usr/lib, otherwise we
run into linking problems. This "fake" dynamic lib is a linker script that
redirects the linker to the real lib. And yes, this works in the cross-
compiling scenario as the sysroot-ed linker will prepend the real path.
See bug http://bugs.gentoo.org/4411 for more info.
*/
${output_format}
GROUP ( ${EPREFIX}/${libdir}/${tlib} )
END_LDSCRIPT
;;
esac
fperms a+x "/usr/${libdir}/${lib}" || die "could not change perms on ${lib}";
done
}
get_abi_CFLAGS ()
{
get_abi_var CFLAGS "$@"
}
get_abi_CHOST ()
{
get_abi_var CHOST "$@"
}
get_abi_CTARGET ()
{
get_abi_var CTARGET "$@"
}
get_abi_FAKE_TARGETS ()
{
get_abi_var FAKE_TARGETS "$@"
}
get_abi_LDFLAGS ()
{
get_abi_var LDFLAGS "$@"
}
get_abi_LIBDIR ()
{
get_abi_var LIBDIR "$@"
}
get_abi_var ()
{
local flag=$1;
local abi=${2:-${ABI:-${DEFAULT_ABI:-default}}};
local var="${flag}_${abi}";
echo ${!var}
}
get_all_abis ()
{
local x order="" mvar dvar;
mvar="MULTILIB_ABIS";
dvar="DEFAULT_ABI";
if [[ -n $1 ]]; then
mvar="$1_${mvar}";
dvar="$1_${dvar}";
fi;
if [[ -z ${!mvar} ]]; then
echo "default";
return 0;
fi;
for x in ${!mvar};
do
if [[ ${x} != ${!dvar} ]]; then
order="${order:+${order} }${x}";
fi;
done;
order="${order:+${order} }${!dvar}";
echo ${order};
return 0
}
get_all_libdirs ()
{
local libdirs abi;
for abi in ${MULTILIB_ABIS};
do
libdirs+=" $(get_abi_LIBDIR ${abi})";
done;
[[ " ${libdirs} " != *" lib "* ]] && libdirs+=" lib";
echo "${libdirs}"
}
get_install_abis ()
{
local x order="";
if [[ -z ${MULTILIB_ABIS} ]]; then
echo "default";
return 0;
fi;
if [[ ${EMULTILIB_PKG} == "true" ]]; then
for x in ${MULTILIB_ABIS};
do
if [[ ${x} != "${DEFAULT_ABI}" ]]; then
has ${x} ${ABI_DENY} || order="${order} ${x}";
fi;
done;
has ${DEFAULT_ABI} ${ABI_DENY} || order="${order} ${DEFAULT_ABI}";
if [[ -n ${ABI_ALLOW} ]]; then
local ordera="";
for x in ${order};
do
if has ${x} ${ABI_ALLOW}; then
ordera="${ordera} ${x}";
fi;
done;
order=${ordera};
fi;
else
order=${DEFAULT_ABI};
fi;
if [[ -z ${order} ]]; then
die "The ABI list is empty. Are you using a proper multilib profile? Perhaps your USE flags or MULTILIB_ABIS are too restrictive for this package.";
fi;
echo ${order};
return 0
}
get_libdir ()
{
local CONF_LIBDIR;
if [ -n "${CONF_LIBDIR_OVERRIDE}" ]; then
echo ${CONF_LIBDIR_OVERRIDE};
else
get_abi_LIBDIR;
fi
}
get_libname ()
{
local libname;
local ver=$1;
case ${CHOST} in
*-cygwin | mingw* | *-mingw*)
libname="dll"
;;
*-darwin*)
libname="dylib"
;;
*-mint*)
libname="irrelevant"
;;
hppa*-hpux*)
libname="sl"
;;
*)
libname="so"
;;
esac;
if [[ -z $* ]]; then
echo ".${libname}";
else
for ver in "$@";
do
case ${CHOST} in
*-darwin*)
echo ".${ver}.${libname}"
;;
*-mint*)
echo ".${libname}"
;;
*)
echo ".${libname}.${ver}"
;;
esac;
done;
fi
}
get_modname ()
{
local modname;
local ver=$1;
case ${CHOST} in
*-darwin*)
modname="bundle"
;;
*)
modname="so"
;;
esac;
echo ".${modname}"
}
has_multilib_profile ()
{
[ -n "${MULTILIB_ABIS}" -a "${MULTILIB_ABIS}" != "${MULTILIB_ABIS/ /}" ]
}
in_iuse ()
{
debug-print-function ${FUNCNAME} "${@}";
[[ ${#} -eq 1 ]] || die "Invalid args to ${FUNCNAME}()";
local flag=${1};
local liuse=(${IUSE});
has "${flag}" "${liuse[@]#[+-]}"
}
is_a_function ()
{
typeset -f $1 > /dev/null 2>&1 || return $?
}
is_final_abi ()
{
has_multilib_profile || return 0;
set -- $(get_install_abis);
local LAST_ABI=$#;
[[ ${!LAST_ABI} == ${ABI} ]]
}
is_parent_of ()
{
typeset name pid ppid pname;
name=$1;
pid=$2;
while [[ -n "$pid" && "$pid" != "0" ]]; do
read ppid pname < <(ps -p $pid -o ppid= -o comm=);
if [[ -n "$ppid" && -n "$pname" ]]; then
if [[ "$pname" == "$name" ]]; then
echo $pid;
return 0;
else
pid=$ppid;
fi;
else
break;
fi;
done;
return 1
}
isdigit ()
{
local d;
for d in "$@";
do
[[ ${d:-bad} == *[!0-9]* ]] && return 1;
done;
return 0
}
make_desktop_entry ()
{
[[ -z $1 ]] && die "make_desktop_entry: You must specify the executable";
local exec=${1};
local name=${2:-${PN}};
local icon=${3:-${PN}};
local type=${4};
local fields=${5};
if [[ -z ${type} ]]; then
local catmaj=${CATEGORY%%-*};
local catmin=${CATEGORY##*-};
case ${catmaj} in
app)
case ${catmin} in
accessibility)
type="Utility;Accessibility"
;;
admin)
type=System
;;
antivirus)
type=System
;;
arch)
type="Utility;Archiving"
;;
backup)
type="Utility;Archiving"
;;
cdr)
type="AudioVideo;DiscBurning"
;;
dicts)
type="Office;Dictionary"
;;
doc)
type=Documentation
;;
editors)
type="Utility;TextEditor"
;;
emacs)
type="Development;TextEditor"
;;
emulation)
type="System;Emulator"
;;
laptop)
type="Settings;HardwareSettings"
;;
office)
type=Office
;;
pda)
type="Office;PDA"
;;
vim)
type="Development;TextEditor"
;;
xemacs)
type="Development;TextEditor"
;;
esac
;;
dev)
type="Development"
;;
games)
case ${catmin} in
action | fps)
type=ActionGame
;;
arcade)
type=ArcadeGame
;;
board)
type=BoardGame
;;
emulation)
type=Emulator
;;
kids)
type=KidsGame
;;
puzzle)
type=LogicGame
;;
roguelike)
type=RolePlaying
;;
rpg)
type=RolePlaying
;;
simulation)
type=Simulation
;;
sports)
type=SportsGame
;;
strategy)
type=StrategyGame
;;
esac;
type="Game;${type}"
;;
gnome)
type="Gnome;GTK"
;;
kde)
type="KDE;Qt"
;;
mail)
type="Network;Email"
;;
media)
case ${catmin} in
gfx)
type=Graphics
;;
*)
case ${catmin} in
radio)
type=Tuner
;;
sound)
type=Audio
;;
tv)
type=TV
;;
video)
type=Video
;;
esac;
type="AudioVideo;${type}"
;;
esac
;;
net)
case ${catmin} in
dialup)
type=Dialup
;;
ftp)
type=FileTransfer
;;
im)
type=InstantMessaging
;;
irc)
type=IRCClient
;;
mail)
type=Email
;;
news)
type=News
;;
nntp)
type=News
;;
p2p)
type=FileTransfer
;;
voip)
type=Telephony
;;
esac;
type="Network;${type}"
;;
sci)
case ${catmin} in
astro*)
type=Astronomy
;;
bio*)
type=Biology
;;
calc*)
type=Calculator
;;
chem*)
type=Chemistry
;;
elec*)
type=Electronics
;;
geo*)
type=Geology
;;
math*)
type=Math
;;
physics)
type=Physics
;;
visual*)
type=DataVisualization
;;
esac;
type="Education;Science;${type}"
;;
sys)
type="System"
;;
www)
case ${catmin} in
client)
type=WebBrowser
;;
esac;
type="Network;${type}"
;;
*)
type=
;;
esac;
fi;
if [ "${SLOT}" == "0" ]; then
local desktop_name="${PN}";
else
local desktop_name="${PN}-${SLOT}";
fi;
local desktop="${T}/$(echo ${exec} | sed 's:[[:space:]/:]:_:g')-${desktop_name}.desktop";
type=${type%;}${type:+;};
eshopts_push -s extglob;
if [[ -n ${icon} && ${icon} != /* ]] && [[ ${icon} == *.xpm || ${icon} == *.png || ${icon} == *.svg ]]; then
ewarn "As described in the Icon Theme Specification, icon file extensions are not";
ewarn "allowed in .desktop files if the value is not an absolute path.";
icon=${icon%.@(xpm|png|svg)};
fi;
eshopts_pop;
cat > "${desktop}" <<-EOF
[Desktop Entry]
Name=${name}
Type=Application
Comment=${DESCRIPTION}
Exec=${exec}
TryExec=${exec%% *}
Icon=${icon}
Categories=${type}
EOF
if [[ ${fields:-=} != *=* ]]; then
ewarn "make_desktop_entry: update your 5th arg to read Path=${fields}";
fields="Path=${fields}";
fi;
[[ -n ${fields} ]] && printf '%b\n' "${fields}" >> "${desktop}";
( insinto /usr/share/applications;
doins "${desktop}" ) || die "installing desktop file failed"
}
make_session_desktop ()
{
[[ -z $1 ]] && eerror "$0: You must specify the title" && return 1;
[[ -z $2 ]] && eerror "$0: You must specify the command" && return 1;
local title=$1;
local command=$2;
local desktop=${T}/${wm:-${PN}}.desktop;
shift 2;
cat > "${desktop}" <<-EOF
[Desktop Entry]
Name=${title}
Comment=This session logs you into ${title}
Exec=${command} $*
TryExec=${command}
Type=XSession
EOF
( insinto /usr/share/xsessions;
doins "${desktop}" )
}
make_wrapper ()
{
local wrapper=$1 bin=$2 chdir=$3 libdir=$4 path=$5;
local tmpwrapper=$(emktemp);
( echo '#!/bin/sh';
[[ -n ${chdir} ]] && printf 'cd "%s"\n' "${chdir}";
if [[ -n ${libdir} ]]; then
cat <<-EOF
if [ "\${LD_LIBRARY_PATH+set}" = "set" ] ; then
export LD_LIBRARY_PATH="\${LD_LIBRARY_PATH}:${libdir}"
else
export LD_LIBRARY_PATH="${libdir}"
fi
EOF
fi
printf 'exec %s "$@"\n' "${bin}" ) > "${tmpwrapper}";
chmod go+rx "${tmpwrapper}";
if [[ -n ${path} ]]; then
( exeinto "${path}";
newexe "${tmpwrapper}" "${wrapper}" ) || die;
else
newbin "${tmpwrapper}" "${wrapper}" || die;
fi
}
multilib_env ()
{
local CTARGET=${1:-${CTARGET}};
case ${CTARGET} in
x86_64*)
export CFLAGS_x86=${CFLAGS_x86--m32};
export CHOST_x86=${CTARGET/x86_64/i686};
CHOST_x86=${CHOST_x86/%-gnux32/-gnu};
export CTARGET_x86=${CHOST_x86};
if [[ ${SYMLINK_LIB} == "yes" ]]; then
export LIBDIR_x86="lib32";
else
export LIBDIR_x86="lib";
fi;
export CFLAGS_amd64=${CFLAGS_amd64--m64};
export CHOST_amd64=${CTARGET/%-gnux32/-gnu};
export CTARGET_amd64=${CHOST_amd64};
export LIBDIR_amd64="lib64";
export CFLAGS_x32=${CFLAGS_x32--mx32};
export CHOST_x32=${CTARGET/%-gnu/-gnux32};
export CTARGET_x32=${CHOST_x32};
export LIBDIR_x32="libx32";
case ${CTARGET} in
*-gnux32)
: ${MULTILIB_ABIS=x32 amd64 x86};
: ${DEFAULT_ABI=x32}
;;
*)
: ${MULTILIB_ABIS=amd64 x86};
: ${DEFAULT_ABI=amd64}
;;
esac
;;
mips64*)
export CFLAGS_o32=${CFLAGS_o32--mabi=32};
export CHOST_o32=${CTARGET/mips64/mips};
export CTARGET_o32=${CHOST_o32};
export LIBDIR_o32="lib";
export CFLAGS_n32=${CFLAGS_n32--mabi=n32};
export CHOST_n32=${CTARGET};
export CTARGET_n32=${CHOST_n32};
export LIBDIR_n32="lib32";
export CFLAGS_n64=${CFLAGS_n64--mabi=64};
export CHOST_n64=${CTARGET};
export CTARGET_n64=${CHOST_n64};
export LIBDIR_n64="lib64";
: ${MULTILIB_ABIS=n64 n32 o32};
: ${DEFAULT_ABI=n32}
;;
powerpc64*)
export CFLAGS_ppc=${CFLAGS_ppc--m32};
export CHOST_ppc=${CTARGET/powerpc64/powerpc};
export CTARGET_ppc=${CHOST_ppc};
export LIBDIR_ppc="lib";
export CFLAGS_ppc64=${CFLAGS_ppc64--m64};
export CHOST_ppc64=${CTARGET};
export CTARGET_ppc64=${CHOST_ppc64};
export LIBDIR_ppc64="lib64";
: ${MULTILIB_ABIS=ppc64 ppc};
: ${DEFAULT_ABI=ppc64}
;;
s390x*)
export CFLAGS_s390=${CFLAGS_s390--m31};
export CHOST_s390=${CTARGET/s390x/s390};
export CTARGET_s390=${CHOST_s390};
export LIBDIR_s390="lib";
export CFLAGS_s390x=${CFLAGS_s390x--m64};
export CHOST_s390x=${CTARGET};
export CTARGET_s390x=${CHOST_s390x};
export LIBDIR_s390x="lib64";
: ${MULTILIB_ABIS=s390x s390};
: ${DEFAULT_ABI=s390x}
;;
sparc64*)
export CFLAGS_sparc32=${CFLAGS_sparc32--m32};
export CHOST_sparc32=${CTARGET/sparc64/sparc};
export CTARGET_sparc32=${CHOST_sparc32};
export LIBDIR_sparc32="lib";
export CFLAGS_sparc64=${CFLAGS_sparc64--m64};
export CHOST_sparc64=${CTARGET};
export CTARGET_sparc64=${CHOST_sparc64};
export LIBDIR_sparc64="lib64";
: ${MULTILIB_ABIS=sparc64 sparc32};
: ${DEFAULT_ABI=sparc64}
;;
*)
: ${MULTILIB_ABIS=default};
: ${DEFAULT_ABI=default}
;;
esac;
export MULTILIB_ABIS DEFAULT_ABI
}
multilib_toolchain_setup ()
{
local v vv;
export ABI=$1;
if [[ ${__DEFAULT_ABI_SAVED} == "true" ]]; then
for v in CHOST CBUILD AS CC CXX LD PKG_CONFIG_{LIBDIR,PATH};
do
vv="__abi_saved_${v}";
[[ ${!vv+set} == "set" ]] && export ${v}="${!vv}" || unset ${v};
unset ${vv};
done;
unset __DEFAULT_ABI_SAVED;
fi;
if [[ ${ABI} != ${DEFAULT_ABI} ]]; then
for v in CHOST CBUILD AS CC CXX LD PKG_CONFIG_{LIBDIR,PATH};
do
vv="__abi_saved_${v}";
[[ ${!v+set} == "set" ]] && export ${vv}="${!v}" || unset ${vv};
done;
export __DEFAULT_ABI_SAVED="true";
export CHOST=$(get_abi_CHOST ${DEFAULT_ABI});
export CC="$(tc-getCC) $(get_abi_CFLAGS)";
export CXX="$(tc-getCXX) $(get_abi_CFLAGS)";
export LD="$(tc-getLD) $(get_abi_LDFLAGS)";
export CHOST=$(get_abi_CHOST $1);
export CBUILD=$(get_abi_CHOST $1);
export PKG_CONFIG_LIBDIR=${EPREFIX}/usr/$(get_libdir)/pkgconfig;
export PKG_CONFIG_PATH=${EPREFIX}/usr/share/pkgconfig;
fi
}
newicon ()
{
_iconins ${FUNCNAME} "$@"
}
newmenu ()
{
( insinto /usr/share/applications;
newins "$@" )
}
number_abis ()
{
set -- `get_install_abis`;
echo $#
}
path_exists ()
{
local opt=$1;
[[ ${opt} == -[ao] ]] && shift || opt="-a";
[[ $# -eq 0 ]] && return 1;
local p r=0;
for p in "$@";
do
[[ -e ${p} ]];
: $(( r += $? ));
done;
case ${opt} in
-a)
return $(( r != 0 ))
;;
-o)
return $(( r == $# ))
;;
esac
}
pkg_checkver ()
{
PATCH_PV=(`echo $1 | sed 's/[._]/ /g' | sed -r 's/([a-z]+)/ \1 /g'`);
EBUILD_PV=(`echo $2 | sed 's/[._]/ /g' | sed -r 's/([a-z]+)/ \1 /g'`);
for i in $(seq 0 10);
do
if [[ -n ${PATCH_PV[$i]} ]]; then
if [[ ${PATCH_PV[$i]} != ${EBUILD_PV[$i]} ]]; then
if [[ ${PATCH_PV[$i]} =~ ^([0-9]+)-([0-9]+)$ ]]; then
if [[ ${EBUILD_PV[$i]} -lt ${BASH_REMATCH[1]} || ${EBUILD_PV[$i]} -gt ${BASH_REMATCH[2]} ]]; then
return 1;
fi;
else
return 1;
fi;
fi;
else
return 0;
fi;
done;
return 0
}
pkg_nofetch ()
{
__eapi0_pkg_nofetch "$@"
}
pkg_pick_patches ()
{
apecho " * entering pick_patches ${1}";
pushd "${1}" > /dev/null 2>&1;
local VERSION='(-(cvs[.])?[0-9]+([.][0-9]+(-[0-9]+)?)*[a-z]?(_(pre|p|beta|alpha|rc)[0-9]*)*)?';
for f in *${PN}*;
do
[[ ! -e ${f} ]] && continue;
apecho " > processing file: ${f}.";
if [[ ${f} =~ ^(..-)?${PN}${VERSION}(-r[0-9]+)?(_[0-9a-zA-Z-]+_)?([0-9a-zA-Z_.-]+[.](${patch_extens}))?$ ]]; then
local MATCHED_PV=${BASH_REMATCH[2]/-};
local MATCHED_PR=${BASH_REMATCH[7]/-};
local MATCHED_ARCH=${BASH_REMATCH[8]//_};
local MATCHED_EXT=${BASH_REMATCH[10]};
apecho " | parsed: PV=$MATCHED_PV, PR=$MATCHED_PR, ARCH=$MATCHED_ARCH, ext=$MATCHED_EXT.";
if [[ -n ${MATCHED_ARCH} && ( ${MATCHED_ARCH} != ${ARCH} && ${MATCHED_ARCH} != all ) ]]; then
apecho " X ARCH does not match. Skipping...";
continue;
fi;
if [[ -n ${MATCHED_PR} && ${MATCHED_PR} != ${PR} ]]; then
apecho " X PR does not match. Skipping...";
continue;
fi;
if [[ -n ${MATCHED_PV} ]] && ! pkg_checkver ${MATCHED_PV} ${PV}; then
apecho " X PV=${MATCHED_PV} does not match. Skipping...";
continue;
fi;
if [[ -d ${f} ]]; then
apecho " -> $f is a direcrory. Delving...";
pkg_pick_patches ${f};
apecho "<- Back. Continuing...";
continue;
else
if [[ -z ${MATCHED_EXT} ]]; then
apecho " X Is $f a file without patch|diff extension. Skipping.";
continue;
fi;
fi;
apecho " + Adding '$(pwd)/${f}' to patches.";
patches=("${patches[@]}" "$(pwd)/${f}");
fi;
done;
popd > /dev/null;
apecho " < ${patches[@]}"
}
pkg_try2apply ()
{
local patch=${1};
for l in `seq 0 4`;
do
patch -g0 --dry-run -p${l} > /dev/null < "${patch}";
if [ $? = 0 ]; then
echo "auto patching succeeded (-p${l}) ${patch}" > "${S}/.$(basename ${patch})";
patch -g0 -p${l} < "${patch}" > /dev/null && return 0;
fi;
done;
return 1
}
pkgpatch ()
{
local -a patches=();
local -i runautomake=0 runautoconf=0;
[[ ! -d "${PATCH_OVERLAY}/${CATEGORY}" ]] && return 0;
if [[ ${EBUILD_PHASE} == compile ]]; then
local patch_extens="diff|patch|sh";
else
local patch_extens="sh";
fi;
pkg_pick_patches "${PATCH_OVERLAY}/${CATEGORY}";
apecho " ! GRAND RESULT: ${patches[@]}";
if ! pushd "${S}" &>/dev/null; then
pushd "`pwd`" > /dev/null;
fi;
for patch in "${patches[@]}";
do
if [[ $patch =~ \.sh$ ]]; then
source $patch;
else
ebegin "Trying to apply $(basename ${patch})";
if pkg_try2apply "${patch}"; then
eend 0;
else
eend 1;
continue;
fi;
fi;
if grep -E '^[+][+][+][[:space:]]+.*Makefile[.]am[[:space:]]+.*$' "${patch}" > /dev/null; then
einfo "Need to rerun automake";
(( ++runautomake ));
fi;
if grep -E '^[+][+][+][[:space:]]+.*configure[.](ac|in)[[:space:]]+.*$' "${patch}" > /dev/null; then
einfo "Need to rerun autoconf";
(( ++runautoconf ));
fi;
done;
if [[ ${runautomake} -gt 0 || ${runautoconf} -gt 0 ]]; then
inherit autotools;
fi;
if [[ ${runautomake} -gt 0 && ${runautoconf} -gt 0 ]]; then
eautoreconf;
else
if [[ ${runautomake} -gt 0 ]]; then
eautomake;
else
if [[ ${runautoconf} -gt 0 ]]; then
eautoconf;
fi;
fi;
fi;
popd > /dev/null
}
popd ()
{
if builtin popd "$@"; then
[[ -n "${rvm_current_rvmrc:-}" && "$*" == "." ]] && rvm_current_rvmrc="" || true;
__rvm_cd_functions_set;
return 0;
else
return $?;
fi
}
post_pkg_postinst ()
{
if [ -e "${PORTAGE_BUILDDIR}/.patched" ]; then
rm -f "${PORTAGE_BUILDDIR}/.patched";
fi
}
post_pkg_preinst ()
{
CL_UPDATE_PROG=/usr/lib/calculate-2.2/calculate-lib/bin/cl-update-config;
if [ -e ${CL_UPDATE_PROG} ]; then
[[ -z ${CONFIG_PROTECT} && -e /etc/profile ]] && source /etc/profile;
CONFIG_PROTECT=${CONFIG_PROTECT} ${CL_UPDATE_PROG} --desktop --system --pkg_version ${PVR} --pkg_category ${CATEGORY} --path ${D} $PN;
fi;
CL_UPDATE_PROG=/usr/sbin/cl-core-setup;
if [ -e ${CL_UPDATE_PROG} ] && [[ -z $calcver ]]; then
${CL_UPDATE_PROG} --no-progress --pkg-version ${PVR} --pkg-category ${CATEGORY} --pkg-path ${D} --pkg-name ${PN};
fi
}
post_src_unpack ()
{
:
}
pre_pkg_postinst ()
{
if [[ -n $calcver ]]; then
CL_UPDATE_PROG=/usr/sbin/cl-core-setup;
if [ -e ${CL_UPDATE_PROG} ]; then
${CL_UPDATE_PROG} --no-progress --pkg-version ${PVR} --pkg-slot ${SLOT} --pkg-category ${CATEGORY} --pkg-path "/" --pkg-name ${PN};
fi;
fi;
rm -f /var/lib/calculate/-merge-$PN-*;
rm -f /var/lib/calculate/-CONTENTS-*
}
pre_pkg_preinst ()
{
:
}
preserve_old_lib ()
{
if [[ ${EBUILD_PHASE} != "preinst" ]]; then
eerror "preserve_old_lib() must be called from pkg_preinst() only";
die "Invalid preserve_old_lib() usage";
fi;
[[ -z $1 ]] && die "Usage: preserve_old_lib <library to preserve> [more libraries to preserve]";
has preserve-libs ${FEATURES} && return 0;
local lib dir;
for lib in "$@";
do
[[ -e ${ROOT}/${lib} ]] || continue;
dir=${lib%/*};
dodir ${dir} || die "dodir ${dir} failed";
cp "${ROOT}"/${lib} "${D}"/${lib} || die "cp ${lib} failed";
touch "${D}"/${lib};
done
}
preserve_old_lib_notify ()
{
if [[ ${EBUILD_PHASE} != "postinst" ]]; then
eerror "preserve_old_lib_notify() must be called from pkg_postinst() only";
die "Invalid preserve_old_lib_notify() usage";
fi;
has preserve-libs ${FEATURES} && return 0;
local lib notice=0;
for lib in "$@";
do
[[ -e ${ROOT}/${lib} ]] || continue;
if [[ ${notice} -eq 0 ]]; then
notice=1;
ewarn "Old versions of installed libraries were detected on your system.";
ewarn "In order to avoid breaking packages that depend on these old libs,";
ewarn "the libraries are not being removed. You need to run revdep-rebuild";
ewarn "in order to remove these old dependencies. If you do not have this";
ewarn "helper program, simply emerge the 'gentoolkit' package.";
ewarn;
fi;
ewarn " # revdep-rebuild --library '${lib}' && rm '${lib}'";
done
}
printenv_null ()
{
if printenv --null > /dev/null 2> /dev/null; then
printenv --null;
else
printenv | __rvm_sed '/=/ { s/=.*$//; p; }; d;' | while read name; do
zero="\0";
eval "eval \"printf '%b' '$name=\$$name$zero'\"";
done;
fi
}
prune_libtool_files ()
{
debug-print-function ${FUNCNAME} "$@";
local removing_all removing_modules opt;
for opt in "$@";
do
case "${opt}" in
--all)
removing_all=1;
removing_modules=1
;;
--modules)
removing_modules=1
;;
*)
die "Invalid argument to ${FUNCNAME}(): ${opt}"
;;
esac;
done;
local f;
local queue=();
while IFS= read -r -d '' f; do
local archivefile=${f/%.la/.a};
if ! sed -n -e '/^# Generated by .*libtool/q0;4q1' "${f}"; then
continue;
fi;
[[ ${f} != ${archivefile} ]] || die 'regex sanity check failed';
local reason pkgconfig_scanned;
local snotlink=$(sed -n -e 's:^shouldnotlink=::p' "${f}");
if [[ ${snotlink} == yes ]]; then
if [[ -f ${archivefile} ]]; then
einfo "Removing unnecessary ${archivefile#${D%/}} (static plugin)";
queue+=("${archivefile}");
fi;
if [[ -n ${removing_modules} ]]; then
reason='module';
fi;
else
if [[ -n ${removing_all} ]]; then
reason='requested';
else
if [[ ! -f ${archivefile} ]]; then
reason='no static archive';
else
if [[ ! -n $(sed -nre "s/^(dependency_libs|inherited_linker_flags)='(.*)'$/\2/p" "${f}") ]]; then
reason='no libs & flags';
else
if [[ ! -n ${pkgconfig_scanned} ]]; then
local pc_libs=();
if [[ ! -n ${removing_all} ]]; then
local pc;
local tf=${T}/prune-lt-files.pc;
local pkgconf=$(tc-getPKG_CONFIG);
while IFS= read -r -d '' pc; do
local arg libs;
if ${pkgconf} --exists "${pc}" &>/dev/null; then
sed -e '/^Requires:/d' "${pc}" > "${tf}";
libs=$(${pkgconf} --libs "${tf}");
else
libs=$(sed -ne 's/^Libs://p' "${pc}");
fi;
for arg in ${libs};
do
if [[ ${arg} == -l* ]]; then
if [[ ${arg} == '*$*' ]]; then
eqawarn "${FUNCNAME}: variable substitution likely failed in ${pc}";
eqawarn "(arg: ${arg})";
eqawarn "Most likely, you need to add virtual/pkgconfig to DEPEND.";
fi;
pc_libs+=(lib${arg#-l}.la);
fi;
done;
done < <(find "${D}" -type f -name '*.pc' -print0);
rm -f "${tf}";
fi;
pkgconfig_scanned=1;
fi;
has "${f##*/}" "${pc_libs[@]}" && reason='covered by .pc';
fi;
fi;
fi;
fi;
if [[ -n ${reason} ]]; then
einfo "Removing unnecessary ${f#${D%/}} (${reason})";
queue+=("${f}");
fi;
done < <(find "${D}" -xtype f -name '*.la' -print0);
if [[ -n ${queue[@]} ]]; then
rm -f "${queue[@]}";
fi
}
pushd ()
{
if builtin pushd "$@"; then
[[ -n "${rvm_current_rvmrc:-}" && "$*" == "." ]] && rvm_current_rvmrc="" || true;
__rvm_cd_functions_set;
return 0;
else
return $?;
fi
}
rubygems_detect_ruby_lib_gem_path ()
{
typeset ruby_path="$( __rvm_which "${1:-ruby}" )";
while [[ -L "$ruby_path" ]]; do
ruby_path="$( readlink "$ruby_path" )";
done;
ruby_lib_gem_path="$( "$ruby_path" -rrubygems -e 'puts Gem.default_dir' 2>/dev/null )";
[[ -n "$ruby_lib_gem_path" ]] || rubygems_detect_ruby_lib_gem_path_fallback || return $?
}
rubygems_detect_ruby_lib_gem_path_fallback ()
{
rubygems_detect_ruby_lib_gem_path_from "rubylib" || rubygems_detect_ruby_lib_gem_path_from "lib" || return $?;
ruby_lib_gem_path+="/gems";
typeset ruby_version;
ruby_version="$( __rvm_ruby_config_get ruby_version "$ruby_path")";
if [[ -d "${ruby_lib_gem_path}/$ruby_version" ]]; then
ruby_lib_gem_path+="$ruby_version";
else
if [[ -d "${ruby_lib_gem_path}/shared" ]]; then
ruby_lib_gem_path+="shared";
else
return 3;
fi;
fi
}
rubygems_detect_ruby_lib_gem_path_from ()
{
ruby_lib_gem_path="$( __rvm_ruby_config_get ${1}prefix "$ruby_path" )";
[[ -z "${ruby_lib_gem_path:-}" ]] || {
ruby_lib_gem_path="$( __rvm_ruby_config_get ${1}dir "$ruby_path" )";
ruby_lib_gem_path="${ruby_lib_gem_path%/*}"
};
[[ -n "${ruby_lib_gem_path:-}" ]] || return 1;
[[ -d "${ruby_lib_gem_path}/gems" ]] || return 2
}
rvm ()
{
if __rvm_has_opt "posix"; then
echo "RVM can not be run with \`set -o posix\`, please turn it off and try again.";
return 100;
fi;
typeset result current_result;
export -a rvm_ruby_args > /dev/null 2> /dev/null;
rvm_ruby_args=();
if (( ${rvm_ignore_rvmrc:=0} == 0 )); then
[[ -n "${rvm_stored_umask:-}" ]] || export rvm_stored_umask=$(umask);
rvm_rvmrc_files=("/etc/rvmrc" "$HOME/.rvmrc");
if [[ -n "${rvm_prefix:-}" ]] && [[ ! "$HOME/.rvmrc" -ef "${rvm_prefix}/.rvmrc" ]]; then
rvm_rvmrc_files+=("${rvm_prefix}/.rvmrc");
fi;
for rvmrc in "${rvm_rvmrc_files[@]}";
do
if [[ -f "$rvmrc" ]]; then
if __rvm_grep '^\s*rvm .*$' "$rvmrc" > /dev/null 2>&1; then
printf "%b" "
Error:
$rvmrc is for rvm settings only.
rvm CLI may NOT be called from within $rvmrc.
Skipping the loading of $rvmrc";
return 1;
else
source "$rvmrc";
fi;
fi;
done;
unset rvm_rvmrc_files;
fi;
disk_version="$(\cat "$rvm_path/VERSION") ($(\cat "$rvm_path/RELEASE" 2>/dev/null))";
if [[ -s "$rvm_path/VERSION" && "${rvm_version:-}" != "${disk_version:-}" && "reload" != "${1:-}" ]]; then
if (( ${rvm_auto_reload_flag:-0} )); then
__rvm_project_rvmrc_lock=0;
rvm_reload_flag=1;
source "${rvm_scripts_path:-${rvm_path}/scripts}/rvm";
else
printf "%b" "
A RVM version ${disk_version} is installed yet ${rvm_version} is loaded.
Please do one of the following:
* 'rvm reload'
* open a new shell
* 'echo rvm_auto_reload_flag=1 >> ~/.rvmrc' # for auto reload with msg.
* 'echo rvm_auto_reload_flag=2 >> ~/.rvmrc' # for silent auto reload.
";
return 1;
fi;
fi;
__rvm_path_match_gem_home_check;
__rvm_initialize;
__rvm_setup;
next_token="$1";
(( $# == 0 )) || shift;
__rvm_parse_args "$@";
(( rvm_trace_flag == 0 )) || {
export PS4;
if [[ -n "$ZSH_VERSION" ]]; then
PS4="%F{red}%x:%I %F{green}%N:%i%F{white} %_";
else
PS4="+ \$(date \"+%s.%N\") \${BASH_SOURCE##\${rvm_path:-}} : \${FUNCNAME[0]:+\${FUNCNAME[0]}()} \${LINENO} > ";
fi;
set -x
};
result=$?;
: rvm_ruby_args:${#rvm_ruby_args[@]}:${rvm_ruby_args[*]}:;
(( result )) || case "${rvm_action:=help}" in
use)
if rvm_is_a_shell_function; then
__rvm_use && __rvm_use_ruby_warnings;
fi
;;
switch)
if rvm_is_a_shell_function; then
__rvm_switch "${rvm_ruby_args[@]}";
fi
;;
srcdir)
__rvm_source_dir
;;
inspect | strings | version)
__rvm_${rvm_action}
;;
ls | list)
"$rvm_scripts_path/list" "${rvm_ruby_args[@]}"
;;
debug)
rvm_is_not_a_shell_function="${rvm_is_not_a_shell_function}" "$rvm_scripts_path/info" '' debug
;;
info)
rvm_is_not_a_shell_function="${rvm_is_not_a_shell_function}" "$rvm_scripts_path/${rvm_action}" "${rvm_ruby_args[@]}"
;;
benchmark | reset)
source "$rvm_scripts_path/functions/${rvm_action}";
__rvm_${rvm_action}
;;
update)
printf "%b" "ERROR: rvm update has been removed. Try 'rvm get head' or see the 'rvm get' and rvm 'rubygems' CLI API instead\n"
;;
reboot)
source "$rvm_scripts_path/functions/cleanup";
__rvm_reboot
;;
implode | seppuku)
source "$rvm_scripts_path/functions/implode";
__rvm_implode
;;
get)
next_token="${1:-}";
(( $# == 0 )) || shift;
[[ "$next_token" == "${rvm_action}" ]] && shift;
tmpdir="${TMPDIR:-/tmp}";
\cp -f "$rvm_scripts_path/get" "$tmpdir/$$";
if bash "$tmpdir/$$" "${rvm_ruby_args[@]}"; then
rvm_reload_flag=1;
else
rvm_error "Could not update RVM, get some help at #rvm IRC channel at freenode servers.";
fi;
\rm -f $tmpdir/$$
;;
current)
__rvm_env_string
;;
help | rtfm | env | list | monitor | notes | pkg | requirements)
next_token="${1:-}";
(( $# == 0 )) || shift;
if (( $# )) && [[ "$next_token" == "${rvm_action}" ]]; then
shift;
fi;
"$rvm_scripts_path/${rvm_action}" "${rvm_ruby_args[@]}"
;;
cleanup | tools | snapshot | disk-usage | repair | alias | docs | rubygems | migrate | cron | group)
__rvm_run_script "$rvm_action" "${rvm_ruby_args[@]}"
;;
upgrade)
__rvm_fix_selected_ruby __rvm_run_wrapper "$rvm_action" "$rvm_action" "${rvm_ruby_args[@]}"
;;
autolibs | osx-ssl-certs | fix-permissions)
__rvm_run_wrapper "$rvm_action" "$rvm_action" "${rvm_ruby_args[@]}"
;;
wrapper)
"$rvm_scripts_path/wrapper" "$rvm_ruby_string" "$rvm_wrapper_name" "${rvm_ruby_args[@]}";
result=$?;
unset rvm_wrapper_name
;;
do)
old_rvm_ruby_string=${rvm_ruby_string:-};
unset rvm_ruby_string;
export rvm_ruby_strings;
( if [[ -n "${rvm_in_flag}" && -d "${rvm_in_flag}" ]]; then
__rvm_cd "${rvm_in_flag}";
fi;
"$rvm_scripts_path/set" "$rvm_action" "${rvm_ruby_args[@]}" );
result=$?;
[[ -n "$old_rvm_ruby_string" ]] && rvm_ruby_string=$old_rvm_ruby_string;
unset old_rvm_ruby_string
;;
rvmrc)
__rvm_rvmrc_tools "${rvm_ruby_args[@]}"
;;
config-get)
typeset __ruby __var;
__ruby=$( __rvm_which ruby );
for __var in "${rvm_ruby_args[@]}";
do
__rvm_ruby_config_get "${__var}" "${__ruby}";
done
;;
gemset_use)
if rvm_is_a_shell_function; then
__rvm_gemset_use;
fi
;;
gemset)
export rvm_ruby_strings;
"$rvm_scripts_path/gemsets" "${rvm_ruby_args[@]}";
result=$?;
rvm_ruby_strings="";
if rvm_is_a_shell_function no_warning; then
if [[ ${rvm_delete_flag:-0} -eq 1 ]]; then
if [[ "${GEM_HOME:-""}" == "${GEM_HOME%%${rvm_gemset_separator:-@}*}${rvm_gemset_separator:-@}${rvm_gemset_name}" ]]; then
rvm_delete_flag=0;
__rvm_use "@default";
fi;
unset gem_prefix;
else
if [[ "${rvm_ruby_args[*]}" =~ ^rename ]]; then
typeset _command _from _to;
read _command _from _to <<< "${rvm_ruby_args[*]}";
if [[ "${GEM_HOME:-""}" == "${GEM_HOME%%${rvm_gemset_separator:-@}*}${rvm_gemset_separator:-@}${_from}" ]]; then
__rvm_use "@${_to}";
fi;
fi;
fi;
fi
;;
reload)
rvm_reload_flag=1
;;
tests | specs)
rvm_action="rake";
__rvm_do
;;
remove)
export rvm_path;
if [[ -n "${rvm_ruby_strings}" ]]; then
__rvm_run_wrapper manage "$rvm_action" "${rvm_ruby_strings//*-- }";
else
__rvm_run_wrapper manage "$rvm_action";
fi;
__rvm_use default
;;
fetch | uninstall | reinstall)
export rvm_path;
if [[ -n "${rvm_ruby_strings}" ]]; then
__rvm_run_wrapper manage "$rvm_action" "${rvm_ruby_strings//*-- }";
else
__rvm_run_wrapper manage "$rvm_action";
fi
;;
try_install | install)
export rvm_path;
if [[ -n "${rvm_ruby_strings}" ]]; then
typeset save_ruby;
selected_ruby="$( __rvm_select && echo $rvm_env_string )";
if [[ -z "${selected_ruby}" ]]; then
rvm_error "Could not detect ruby version/name for installation, please be more specific.";
false;
else
if (( ${rvm_force_flag:-0} == 0 )) && "$rvm_scripts_path"/list strings | __rvm_grep "^${selected_ruby%${rvm_gemset_separator:-'@'}*}$" > /dev/null; then
rvm_log "Already installed ${selected_ruby%${rvm_gemset_separator:-'@'}*}.
To reinstall use:
rvm reinstall ${rvm_ruby_strings}
";
else
__rvm_run_wrapper manage install "${rvm_ruby_strings}";
fi;
fi;
else
rvm_error "Can not use or install 'all' rubies.";
false;
fi
;;
mount | automount | prepare)
if [[ -n "$rvm_ruby_string" ]]; then
rvm_ruby_args=("$rvm_ruby_string" "${rvm_ruby_args[@]}");
fi;
"${rvm_scripts_path}/external" "$rvm_action" "${rvm_ruby_args[@]}"
;;
export)
__rvm_export "$rvm_export_args"
;;
unexport)
__rvm_unset_exports
;;
error)
false
;;
answer)
source "$rvm_scripts_path/functions/fun";
__rvm_Answer_to_the_Ultimate_Question_of_Life_the_Universe_and_Everything;
result=42
;;
question)
source "$rvm_scripts_path/functions/fun";
__rvm_ultimate_question;
result=42
;;
which)
__rvm_which "${rvm_ruby_args[@]}"
;;
*)
rvm_error "unknown action '$rvm_action'";
false
;;
esac;
current_result=$?;
(( result )) || result=${current_result};
(( result )) || case "$rvm_action" in
reinstall | try_install | install)
if [[ $(__rvm_find $rvm_rubies_path -maxdepth 1 -mindepth 1 -type d 2>/dev/null | wc -l) -eq 1 ]] && [[ ! -f "${rvm_environments_path}/default" ]] && rvm_is_a_shell_function no_warning; then
rvm_log "";
rvm_verbose_flag=0 rvm_default_flag=1 __rvm_use;
fi
;;
esac;
current_result=$?;
(( result )) || result=${current_result};
typeset __local_rvm_trace_flag;
__local_rvm_trace_flag=${rvm_trace_flag:-0};
if [[ ${rvm_reload_flag:-0} -eq 1 ]]; then
if [[ -s "$rvm_scripts_path/rvm" ]]; then
__rvm_project_rvmrc_lock=0;
source "$rvm_scripts_path/rvm";
else
echo "rvm not found in $rvm_path, please install and run 'rvm reload'";
__rvm_teardown;
fi;
else
__rvm_teardown;
fi;
if (( __local_rvm_trace_flag > 0 )); then
set +o verbose;
set +o xtrace;
[[ -n "${ZSH_VERSION:-""}" ]] || set +o errtrace;
fi;
return ${result:-0}
}
rvm_debug ()
{
(( ${rvm_debug_flag:-0} )) || return 0;
if rvm_pretty_print stderr; then
printf "%b" "${rvm_debug_clr:-}$*${rvm_reset_clr:-}\n";
else
printf "%b" "$*\n";
fi 1>&2
}
rvm_debug_stream ()
{
if (( ${rvm_debug_flag:-0} == 0 && ${rvm_trace_flag:-0} == 0 )); then
cat - > /dev/null;
else
if rvm_pretty_print stdout; then
\cat - | __rvm_awk '{print "'"${rvm_debug_clr:-}"'"$0"'"${rvm_reset_clr:-}"'"}' 1>&2;
else
\cat - 1>&2;
fi;
fi
}
rvm_error ()
{
if rvm_pretty_print stderr; then
printf "%b" "${rvm_error_clr:-}$*${rvm_reset_clr:-}\n";
else
printf "%b" "$*\n";
fi 1>&2
}
rvm_error_help ()
{
rvm_error "$1";
shift;
rvm_help "$@"
}
rvm_fail ()
{
rvm_error "$1";
exit "${2:-1}"
}
rvm_help ()
{
"${rvm_scripts_path}/help" "$@"
}
rvm_is_a_shell_function ()
{
typeset _message;
if (( ${rvm_is_not_a_shell_function:-0} )) && [[ "${1:-}" != "no_warning" ]]; then
if rvm_pretty_print stderr; then
rvm_log "";
fi;
if rvm_pretty_print stderr; then
rvm_log "RVM is not a function, selecting rubies with '${rvm_error_clr:-}rvm use ...${rvm_notify_clr:-}' will not work." 1>&2;
else
rvm_error "RVM is not a function, selecting rubies with 'rvm use ...' will not work.";
fi;
rvm_warn '
You need to change your terminal emulator preferences to allow login shell.
Sometimes it is required to use `/bin/bash --login` as the command.
Please visit https://rvm.io/integration/gnome-terminal/ for a example.
';
fi;
return ${rvm_is_not_a_shell_function:-0}
}
rvm_log ()
{
if rvm_pretty_print stdout; then
printf "%b" "${rvm_notify_clr:-}$*${rvm_reset_clr:-}\n";
else
printf "%b" "$*\n";
fi
}
rvm_out ()
{
printf "$*\n"
}
rvm_pretty_print ()
{
case "${rvm_pretty_print_flag:=auto}" in
0 | no)
return 1
;;
1 | auto)
case "${TERM:-dumb}" in
dumb | unknown)
return 1
;;
esac;
case "$1" in
stdout)
[[ -t 1 ]] || return 1
;;
stderr)
[[ -t 2 ]] || return 1
;;
[[:digit:]])
[[ -t $1 ]] || return 1
;;
any)
[[ -t 1 || -t 2 ]] || return 1
;;
*)
[[ -t 1 && -t 2 ]] || return 1
;;
esac;
return 0
;;
2 | force)
return 0
;;
esac
}
rvm_warn ()
{
if rvm_pretty_print stdout; then
printf "%b" "${rvm_warn_clr:-}$*${rvm_reset_clr:-}\n";
else
printf "%b" "$*\n";
fi
}
src_compile ()
{
./configure --prefix=/usr || die;
sed -i -e "s:-pipe -O2:${CFLAGS}:" -e "s:^\(LDFLAGS=\).*:\1${LDFLAGS}:" -e "s:-Wpointer-arith::" -e "s:^CC=.*:CC=$(tc-getCC):" -e "s:^CXX=.*:CXX=$(tc-getCXX):" MCONFIG || die;
emake || die;
cd telnetlogin && emake || die
}
src_install ()
{
dobin telnet/telnet || die;
dosbin telnetd/telnetd || die;
dosym telnetd /usr/sbin/in.telnetd || die;
dosbin telnetlogin/telnetlogin || die;
doman telnet/telnet.1 || die;
doman telnetd/*.8 || die;
doman telnetd/issue.net.5 || die;
dosym telnetd.8 /usr/share/man/man8/in.telnetd.8 || die;
doman telnetlogin/telnetlogin.8 || die;
dodoc BUGS ChangeLog README || die;
dodoc "${FILESDIR}"/net.issue.sample || die;
newdoc telnet/README README.telnet || die;
newdoc telnet/TODO TODO.telnet || die;
insinto /etc/xinetd.d;
newins "${FILESDIR}"/telnetd.xinetd telnetd || die
}
src_test ()
{
__eapi0_src_test "$@"
}
src_unpack ()
{
unpack ${A};
cd "${S}";
epatch "${WORKDIR}"/netkit-telnet_0.17-${PATCHLEVEL}.diff;
epatch "${FILESDIR}"/netkit-telnetd-0.17-cflags-gnu_source.patch
}
strip-linguas ()
{
local ls newls nols;
if [[ $1 == "-i" ]] || [[ $1 == "-u" ]]; then
local op=$1;
shift;
ls=$(find "$1" -name '*.po' -exec basename {} .po ';');
shift;
local d f;
for d in "$@";
do
if [[ ${op} == "-u" ]]; then
newls=${ls};
else
newls="";
fi;
for f in $(find "$d" -name '*.po' -exec basename {} .po ';');
do
if [[ ${op} == "-i" ]]; then
has ${f} ${ls} && newls="${newls} ${f}";
else
has ${f} ${ls} || newls="${newls} ${f}";
fi;
done;
ls=${newls};
done;
else
ls="$@";
fi;
nols="";
newls="";
for f in ${LINGUAS};
do
if has ${f} ${ls}; then
newls="${newls} ${f}";
else
nols="${nols} ${f}";
fi;
done;
[[ -n ${nols} ]] && einfo "Sorry, but ${PN} does not support the LINGUAS:" ${nols};
export LINGUAS=${newls:1}
}
tc-arch ()
{
tc-ninja_magic_to_arch portage "$@"
}
tc-arch-kernel ()
{
tc-ninja_magic_to_arch kern "$@"
}
tc-endian ()
{
local host=$1;
[[ -z ${host} ]] && host=${CTARGET:-${CHOST}};
host=${host%%-*};
case ${host} in
aarch64*be)
echo big
;;
aarch64)
echo little
;;
alpha*)
echo big
;;
arm*b*)
echo big
;;
arm*)
echo little
;;
cris*)
echo little
;;
hppa*)
echo big
;;
i?86*)
echo little
;;
ia64*)
echo little
;;
m68*)
echo big
;;
mips*l*)
echo little
;;
mips*)
echo big
;;
powerpc*)
echo big
;;
s390*)
echo big
;;
sh*b*)
echo big
;;
sh*)
echo little
;;
sparc*)
echo big
;;
x86_64*)
echo little
;;
*)
echo wtf
;;
esac
}
tc-env_build ()
{
tc-export_build_env;
CFLAGS=${BUILD_CFLAGS} CXXFLAGS=${BUILD_CXXFLAGS} CPPFLAGS=${BUILD_CPPFLAGS} LDFLAGS=${BUILD_LDFLAGS} AR=$(tc-getBUILD_AR) AS=$(tc-getBUILD_AS) CC=$(tc-getBUILD_CC) CPP=$(tc-getBUILD_CPP) CXX=$(tc-getBUILD_CXX) LD=$(tc-getBUILD_LD) NM=$(tc-getBUILD_NM) PKG_CONFIG=$(tc-getBUILD_PKG_CONFIG) RANLIB=$(tc-getBUILD_RANLIB) "$@"
}
tc-export ()
{
local var;
for var in "$@";
do
[[ $(type -t tc-get${var}) != "function" ]] && die "tc-export: invalid export variable '${var}'";
eval tc-get${var} > /dev/null;
done
}
tc-export_build_env ()
{
tc-export "$@";
: ${BUILD_CFLAGS:=-O1 -pipe};
: ${BUILD_CXXFLAGS:=-O1 -pipe};
: ${BUILD_CPPFLAGS:=};
: ${BUILD_LDFLAGS:=};
export BUILD_{C,CXX,CPP,LD}FLAGS
}
tc-getAR ()
{
tc-getPROG AR ar "$@"
}
tc-getAS ()
{
tc-getPROG AS as "$@"
}
tc-getBUILD_AR ()
{
tc-getBUILD_PROG AR ar "$@"
}
tc-getBUILD_AS ()
{
tc-getBUILD_PROG AS as "$@"
}
tc-getBUILD_CC ()
{
tc-getBUILD_PROG CC gcc "$@"
}
tc-getBUILD_CPP ()
{
tc-getBUILD_PROG CPP cpp "$@"
}
tc-getBUILD_CXX ()
{
tc-getBUILD_PROG CXX g++ "$@"
}
tc-getBUILD_LD ()
{
tc-getBUILD_PROG LD ld "$@"
}
tc-getBUILD_NM ()
{
tc-getBUILD_PROG NM nm "$@"
}
tc-getBUILD_OBJCOPY ()
{
tc-getBUILD_PROG OBJCOPY objcopy "$@"
}
tc-getBUILD_PKG_CONFIG ()
{
tc-getBUILD_PROG PKG_CONFIG pkg-config "$@"
}
tc-getBUILD_PROG ()
{
_tc-getPROG CBUILD "BUILD_$1 $1_FOR_BUILD HOST$1" "${@:2}"
}
tc-getBUILD_RANLIB ()
{
tc-getBUILD_PROG RANLIB ranlib "$@"
}
tc-getBUILD_STRIP ()
{
tc-getBUILD_PROG STRIP strip "$@"
}
tc-getCC ()
{
tc-getPROG CC gcc "$@"
}
tc-getCPP ()
{
tc-getPROG CPP cpp "$@"
}
tc-getCXX ()
{
tc-getPROG CXX g++ "$@"
}
tc-getDLLWRAP ()
{
tc-getPROG DLLWRAP dllwrap "$@"
}
tc-getF77 ()
{
tc-getPROG F77 gfortran "$@"
}
tc-getFC ()
{
tc-getPROG FC gfortran "$@"
}
tc-getGCJ ()
{
tc-getPROG GCJ gcj "$@"
}
tc-getLD ()
{
tc-getPROG LD ld "$@"
}
tc-getNM ()
{
tc-getPROG NM nm "$@"
}
tc-getOBJCOPY ()
{
tc-getPROG OBJCOPY objcopy "$@"
}
tc-getPKG_CONFIG ()
{
tc-getPROG PKG_CONFIG pkg-config "$@"
}
tc-getPROG ()
{
_tc-getPROG CHOST "$@"
}
tc-getRANLIB ()
{
tc-getPROG RANLIB ranlib "$@"
}
tc-getRC ()
{
tc-getPROG RC windres "$@"
}
tc-getSTRIP ()
{
tc-getPROG STRIP strip "$@"
}
tc-has-openmp ()
{
local base="${T}/test-tc-openmp";
cat > "${base}.c" <<-EOF
#include <omp.h>
int main() {
int nthreads, tid, ret = 0;
#pragma omp parallel private(nthreads, tid)
{
tid = omp_get_thread_num();
nthreads = omp_get_num_threads(); ret += tid + nthreads;
}
return ret;
}
EOF
$(tc-getCC "$@") -fopenmp "${base}.c" -o "${base}" &>/dev/null;
local ret=$?;
rm -f "${base}"*;
return ${ret}
}
tc-has-tls ()
{
local base="${T}/test-tc-tls";
cat > "${base}.c" <<-EOF
int foo(int *i) {
static __thread int j = 0;
return *i ? j : *i;
}
EOF
local flags;
case $1 in
-s)
flags="-S"
;;
-c)
flags="-c"
;;
-l)
;;
-*)
die "Usage: tc-has-tls [-c|-l] [toolchain prefix]"
;;
esac;
: ${flags:=-fPIC -shared -Wl,-z,defs};
[[ $1 == -* ]] && shift;
$(tc-getCC "$@") ${flags} "${base}.c" -o "${base}" &>/dev/null;
local ret=$?;
rm -f "${base}"*;
return ${ret}
}
tc-is-cross-compiler ()
{
return $([[ ${CBUILD:-${CHOST}} != ${CHOST} ]])
}
tc-is-softfloat ()
{
local CTARGET=${CTARGET:-${CHOST}};
case ${CTARGET} in
bfin* | h8300*)
echo "only"
;;
*)
if [[ ${CTARGET//_/-} == *-softfloat-* ]]; then
echo "yes";
else
if [[ ${CTARGET//_/-} == *-softfp-* ]]; then
echo "softfp";
else
echo "no";
fi;
fi
;;
esac
}
tc-is-static-only ()
{
local host=${CTARGET:-${CHOST}};
return $([[ ${host} == *-mint* ]])
}
tc-ninja_magic_to_arch ()
{
function ninj ()
{
[[ ${type} == "kern" ]] && echo $1 || echo $2
};
local type=$1;
local host=$2;
[[ -z ${host} ]] && host=${CTARGET:-${CHOST}};
local KV=${KV:-${KV_FULL}};
[[ ${type} == "kern" ]] && [[ -z ${KV} ]] && ewarn "QA: Kernel version could not be determined, please inherit kernel-2 or linux-info";
case ${host} in
aarch64*)
ninj arm64 arm
;;
alpha*)
echo alpha
;;
arm*)
echo arm
;;
avr*)
ninj avr32 avr
;;
bfin*)
ninj blackfin bfin
;;
c6x)
echo c6x
;;
cris*)
echo cris
;;
frv)
echo frv
;;
hexagon)
echo hexagon
;;
hppa*)
ninj parisc hppa
;;
i?86*)
if [[ ${type} == "kern" ]] && [[ $(KV_to_int ${KV}) -lt $(KV_to_int 2.6.24) || ${host} == *freebsd* ]]; then
echo i386;
else
echo x86;
fi
;;
ia64*)
echo ia64
;;
m68*)
echo m68k
;;
metag)
echo metag
;;
mips*)
echo mips
;;
nios2*)
echo nios2
;;
nios*)
echo nios
;;
or32)
echo openrisc
;;
powerpc*)
if [[ ${type} == "kern" ]] && [[ $(KV_to_int ${KV}) -ge $(KV_to_int 2.6.16) ]]; then
echo powerpc;
else
if [[ ${type} == "kern" ]] && [[ $(KV_to_int ${KV}) -eq $(KV_to_int 2.6.15) ]]; then
if [[ ${host} == powerpc64* ]] || [[ ${PROFILE_ARCH} == "ppc64" ]]; then
echo powerpc;
else
echo ppc;
fi;
else
if [[ ${host} == powerpc64* ]]; then
echo ppc64;
else
if [[ ${PROFILE_ARCH} == "ppc64" ]]; then
ninj ppc64 ppc;
else
echo ppc;
fi;
fi;
fi;
fi
;;
s390*)
echo s390
;;
score)
echo score
;;
sh64*)
ninj sh64 sh
;;
sh*)
echo sh
;;
sparc64*)
ninj sparc64 sparc
;;
sparc*)
[[ ${PROFILE_ARCH} == "sparc64" ]] && ninj sparc64 sparc || echo sparc
;;
tile*)
echo tile
;;
vax*)
echo vax
;;
x86_64*freebsd*)
echo amd64
;;
x86_64*)
if [[ ${type} == "kern" ]] && [[ $(KV_to_int ${KV}) -ge $(KV_to_int 2.6.24) ]]; then
echo x86;
else
ninj x86_64 amd64;
fi
;;
xtensa*)
echo xtensa
;;
*)
echo unknown
;;
esac
}
use_if_iuse ()
{
in_iuse $1 || return 1;
use $1
}
usex ()
{
use "$1" && echo "${2-yes}$4" || echo "${3-no}$5"
}
validate_desktop_entries ()
{
if [[ -x /usr/bin/desktop-file-validate ]]; then
einfo "Checking desktop entry validity";
local directories="";
for d in /usr/share/applications $@;
do
[[ -d ${D}${d} ]] && directories="${directories} ${D}${d}";
done;
if [[ -n ${directories} ]]; then
for FILE in $(find ${directories} -name "*\.desktop" -not -path '*.hidden*' | sort -u 2>/dev/null);
do
local temp=$(desktop-file-validate ${FILE} | grep -v "warning:" | sed -e "s|error: ||" -e "s|${FILE}:|--|g" );
[[ -n $temp ]] && elog ${temp/--/${FILE/${D}/}:};
done;
fi;
echo "";
else
einfo "Passing desktop entry validity check. Install dev-util/desktop-file-utils, if you want to help to improve Gentoo.";
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment