Commits

Jack Frost committed 346e2cf

moving wine stuff to fbt/corkscrew

  • Participants
  • Parent commits cd786d3

Comments (0)

Files changed (3)

 
 	OTHER:
 	-h     Show this message
-
-scotch
-------
-A wine helper designed mostly for games and apps that need specific configuration that potentially conflicts with others.
-
-	$ scotch -h
-	Scotch — a wine helper script
-	Usage: scotch [-lnks] <app>
-	Flags:
-		-l          Launch the app (default).*
-		-a			Provide an alternative executabe (relative to app/)
-		-n          Create a new app dir in /home/trash/wine.d.**
-		-t			Specify an alternative prefix template.
-		-k          Kill all processes in the wine prefix of an app.
-		-s          Get a shell with all environment variables ready to work with the wine prefix.
-		-W			Ignore — if present — custom wine installation.
-		-i			Populate /home/trash/wine.d/.bin with links to /home/fbt/bin/scotch.
-		-b			Build a custom wine version for an app with vintner.
-	
-	* Scotch takes the app binary from /home/trash/wine.d/${app}/.app_bin. The path is relative to the app dir.
-	** You should really create /home/trash/wine.d/.template for scotch to copy it into new prefixes.
-
-Another cool feature (shamelessly ripped off from busybox) that I can't explain properly with my crappy english, so here's an example:
-
-	[fbt@cetaganda ~]$ cd ~/bin
-	[fbt@cetaganda bin]$ ln -s scotch steam-win
-	[fbt@cetaganda bin]$ steam-win
-	[scotch] Launching steam-win...
-	[fbt@cetaganda bin]$ steam-win -k
-	[scotch] Killing steam-win...
-
-vintner
--------
-A script that builds wine with specified patches. Nothing special here
-
-	$ vintner -h
-	Vintner — wine builder
-	Usage: vintner [-p <patch>] [-P <prefix>] [-c <configure_options>]
-	Flags:
-		-p <patch>					Specify a patch file to apply. Multiple patches can be applied at the same time.
-		-P <prefix>					Specify a prefix ($cfg_prefix) to install to. Vintner won't run “make install” if this parameter isn't set by this flag or in /home/fbt/.vintnerrc.
-		-c <configure_options>		Specify additional configure options.

scotch

-#!/bin/bash
-# Copyright (c) 2012 fbt <fbt@fleshless.org>
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are met:
-# 	- Redistributions of source code must retain the above copyright notice, 
-#		this list of conditions and the following disclaimer.
-# 	- Redistributions in binary form must reproduce the above copyright notice,
-#		this list of conditions and the following disclaimer in the
-#		documentation and/or other materials provided with the distribution.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
-# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
-# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
-# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
-# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
-# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-# config
-
-cfg_apps_dir="$HOME/.scotch.d"
-cfg_tmp_dir="/tmp/$USER/scotch"
-cfg_run_dir="$cfg_tmp_dir/run"
-cfg_log_dir="$cfg_tmp_dir/log"
-cfg_bin_dir="$cfg_apps_dir/.bin"
-
-cfg_wine_debug_level='fixme-all'
-
-cfg_desktop="1280x720"
-
-[[ -f "$HOME/.scotchrc" ]] && { source "$HOME/.scotchrc"; }
-
-# functions
-
-scotch.usage() {
-	echo "Scotch — a wine helper script"
-	echo "Usage: `basename $0` [-lnks] <app>"
-	echo "Flags:"
-	echo "	-l			Launch the app (default).*"
-	echo "	-a			Provide an alternative executabe (relative to app/)"
-	echo "	-L			List available apps"
-	echo "	-n			Create a new app dir in $cfg_apps_dir.**"
-	echo "	-t			Specify an alternative prefix template."
-	echo "	-k			Kill all processes in the wine prefix of an app."
-	echo "	-s			Get a shell with all environment variables ready to work with the wine prefix."
-	echo "	-W			Ignore — if present — custom wine installation"
-	echo "	-i			Populate $cfg_bin_dir with links to $0"
-	echo "	-b			Build a custom wine version for an app with vintner"
-	echo
-	echo "* Scotch takes the app binary from $cfg_apps_dir/\${app}/.app_bin. The path is relative to the app dir."
-	echo "** You should really create $cfg_apps_dir/.template for scotch to copy it into new prefixes."
-}
-
-scotch.msg() { echo "[scotch] $1"; }
-scotch.err() { scotch.msg "(err) $1" >&2; }
-scotch.die() {
-	[[ "$2" ]] && { scotch.err "$2"; }
-	exit "$1"
-}
-
-scotch.env() {
-	export WINEPREFIX="$cfg_apps_dir/$app/wine"
-	export WINEDEBUG="$cfg_wine_debug_level"
-
-	[[ -d "$cfg_apps_dir/$app/opt/bin" ]] && {
-		[[ "$flag_nocustomwine" ]] && {
-			scotch.msg "Custom wine install found, but overriden by -W, ignoring"
-		} || {
-			scotch.msg "Custom wine install found, adding it to \$PATH..."
-			export PATH="$cfg_apps_dir/$app/opt/bin:$PATH"
-			scotch.msg "done: using `which wine`"
-		}
-	}
-
-	[[ "$app_bin" ]] || { export app_bin=`cat $cfg_apps_dir/$app/.app_bin | cut -d ' ' -f 1`; }
-	[[ "$app_bin_args" ]] || { export app_bin_args=`cat $cfg_apps_dir/$app/.app_bin | cut -d ' ' -f 2-`; }
-}
-
-scotch.launch() {
-	[[ -d "$cfg_apps_dir/$app" ]] || {
-		scotch.err "$app not found in $cfg_apps_dir"
-		return 1
-	}
-
-	[[ -f "$cfg_run_dir/$app.pid" ]] && {
-		app_pid=`cat "$cfg_run_dir/$app.pid"`
-
-		ps -p "$app_pid" &>/dev/null && {
-			scotch.err "$app is already running with PID $app_pid"
-			return 1
-		}
-	}
-
-	scotch.msg "Launching $app..."
-
-	[[ "$flag_nodesktop" ]] || { wine_args="explorer /desktop='$app','$cfg_desktop'"; }
-
-	scotch.env
-	cd "$cfg_apps_dir/$app/app"
-
-	[[ "$flag_nodesktop" ]] && {
-		wine "$app_bin" &>"$cfg_log_dir/$app.log" &
-	} || {
-		wine explorer /desktop="$app","$cfg_desktop" "$app_bin" $app_bin_args &>"$cfg_log_dir/$app.log" &
-	}
-
-	echo "$!" > "$cfg_run_dir/$app.pid"
-}
-
-scotch.new() {
-	[[ "$alt_template" ]] && {
-		prefix_template="$alt_template"
-	} || {
-		prefix_template="$cfg_apps_dir/.template"
-	}
-
-	[[ -e "$cfg_apps_dir/$app" ]] && {
-		scotch.err "$cfg_apps_dir/$app already exists!"
-		return 1
-	}
-
-	[[ -d "$cfg_apps_dir/.template" ]] && {
-		scotch.msg "Cloning $cfg_apps_dir/.template into $cfg_apps_dir/${app}..."
-		cp -r "$cfg_apps_dir/.template" "$cfg_apps_dir/$app"
-	} || {
-		scotch.msg "(warn) Prefix template ($prefix_template) not found, a new prefix will be created."
-		mkdir -p "$cfg_apps_dir/$app"
-	}
-	
-	ln -s "$0" "$cfg_bin_dir/$app"
-
-	"$0" -s "$app"
-}
-
-scotch.install() {
-	for i in `ls "$cfg_apps_dir"`; do
-		[[ -e "$cfg_bin_dir/$i" ]] || {
-			ln -vs "$0" "$cfg_bin_dir/$i"
-		}
-	done
-}
-
-scotch.kill() {
-	scotch.msg "Killing $app..."
-	scotch.env
-	wineserver -k
-}
-
-scotch.shell() {
-	scotch.env
-	cd "$cfg_apps_dir/$app"
-	$SHELL
-}
-
-scotch.list() {
-	ls "$cfg_apps_dir"
-}
-
-scotch.build() {
-	[[ "$cfg_vintner" ]] || { cfg_vintner=`which vintner`; }
-	[[ "$cfg_vintner" ]] || {
-		scotch.msg "vintner is required for this function to work, but I can't find it anywhere."
-		scotch.msg "Either specify a custom location with \$cfg_vintner or add it to \$PATH."
-		scotch.msg "In case you didn't get this script bundled with vintner, you can find it here: https://github.com/fbt/misc."
-	}
-
-	[[ -e "$cfg_apps_dir/$app" ]] || {
-		scotch.msg "$app not found in $cfg_apps_dir"
-		return 1
-	}
-
-	scotch.env
-	cd "$cfg_apps_dir/$app"
-
-	scotch.msg "Building custom wine for ${app}..."
-	"$cfg_vintner" -P "$cfg_apps_dir/$app/opt" "$@" || {
-		scotch.err 'vintner failed'
-		return 1
-	}
-	scotch.msg "done"
-}
-
-# main
-
-for i in "$cfg_run_dir" "$cfg_log_dir" "$cfg_bin_dir"; do
-	mkdir -p "$i" || { scotch.err "$i does not exist and cannot be created."; exit 7; }
-done
-
-while getopts "slLnkibdWha:t:" option; do
-	case "$option" in
-		s) action='shell';;
-		l) action='launch';;
-		L) action='list';;
-		n) action='new';;
-		k) action='kill';;
-		i) action='install';;
-		b) action='build';;
-
-		a) alt_exec="$OPTARG";;
-		t) alt_template="$OPTARG";;
-
-		d) flag_nodesktop='1';;
-		W) flag_nocustomwine='1';;
-
-		h|?) scotch.usage; exit 3;;
-	esac
-done
-
-[[ "$OPTIND" ]] && { shift $[OPTIND-1]; }
-
-[[ "$action" ]] || { action='launch'; }
-
-for i in shell launch new kill build; do
-	[[ "$action" == "$i" ]] && {
-		self_exec_name=`basename $0`
-		for i in `ls "$cfg_apps_dir"`; do
-			[[ "$i" == "$self_exec_name" ]] && { app="$self_exec_name"; }
-		done
-	}
-done
-
-[[ "$app" ]] || { app="$1"; shift; }
-
-[[ "$alt_exec" ]] && {
-	app_bin="$alt_exec"
-	app_bin_args="$@"
-}
-
-scotch.$action "$@"
-
-exit "$?"

vintner

-#!/bin/bash
-# Copyright (c) 2012 fbt <fbt@fleshless.org>
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are met:
-#   - Redistributions of source code must retain the above copyright notice, 
-#       this list of conditions and the following disclaimer.
-#   - Redistributions in binary form must reproduce the above copyright notice,
-#       this list of conditions and the following disclaimer in the
-#       documentation and/or other materials provided with the distribution.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
-# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
-# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
-# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
-# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
-# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-cfg_cache_dir="$HOME/.cache/vintner"
-cfg_tmp_dir="/tmp/$USER/vintner"
-cfg_log_dir="$cfg_tmp_dir/log"
-cfg_build_dir="$cfg_tmp_dir/build"
-cfg_git_repo='git://source.winehq.org/git/wine.git'
-cfg_download_mirror='http://ibiblio.org/pub/linux/system/emulators/wine'
-cfg_prefix="$HOME/.local"
-
-[[ -f "$HOME/.vintnerrc" ]] && { source "$HOME/.vintnerrc"; }
-
-vintner.usage() {
-echo "Vintner — wine builder"
-echo "Usage: `basename $0` [-p <patch>] [-P <prefix>] [-c <configure_options>]"
-echo "Flags:"
-echo "	-p <patch>					Specify a patch file to apply. Multiple patches can be applied at the same time."
-echo "	-P <prefix>					Specify a prefix (\$cfg_prefix) to install to. Vintner won't run “make install” if this parameter isn't set by this flag or in "$HOME/.vintnerrc"."
-echo "	-c <configure_options>		Specify additional configure options."
-}
-
-vintner.msg() { echo "[vintner] $1"; }
-vintner.err() { vintner.msg "(error) $1" >&2; }
-
-vintner.init() {
-	for i in "$cfg_log_dir" "$cfg_cache_dir" "$cfg_build_dir"; do
-		[[ -e "$i" ]] || {
-			mkdir -p "$i" || {
-				vintner.err "Cannot create $i, aborting"
-				return 1
-			}
-		}
-	done
-}
-
-vintner.download() {
-	case "$wine_version" in
-		git)
-			[[ -d "$cfg_cache_dir/wine-git" ]] && {
-				cd "$cfg_cache_dir/wine-git"
-				git pull || { return 1; }
-			} || {
-				git clone "$cfg_git_repo" "$cfg_cache_dir/wine-git"
-			}
-		;;
-
-		*)
-			[[ -f "$cfg_cache_dir/wine-${wine_version}.tar.bz2" ]] || {
-				vintner.msg "Downloading wine version ${wine_version}..."
-				wget "$cfg_download_mirror/wine-${wine_version}.tar.bz2" -O "$cfg_cache_dir/wine-${wine_version}.tar.bz2" &>"$cfg_log_dir/wget.log" && {
-					vintner.msg 'done'
-				} || {
-					vintner.err 'wget failed:'
-					cat "$cfg_log_dir/wget.log"
-					return 1
-				}
-			}
-		;;
-	esac
-
-	return 0
-}
-
-vintner.make() {
-	make -j5 depend &>"$cfg_log_dir/make_depend.log" || return 1
-	make -j5 &>"$cfg_log_dir/make.log" || return 1
-	[[ "$cfg_prefix" ]] && {
-		make -j5 install &>"$cfg_log_dir/make_install.log" || return 1
-	}
-}
-
-vintner.build() {
-	cd "$cfg_build_dir"
-	vintner.download || { return 1; }
-
-	vintner.msg "Extracting..."
-	case "$wine_version" in
-		git) cp -r "$cfg_cache_dir/wine-git" .;;
-		*) bzip2 -cd "$cfg_cache_dir/wine-${wine_version}.tar.bz2" | tar xf -
-	esac
-
-	cd "wine-$wine_version"
-
-	for i in "${patchlist[@]}"; do
-		vintner.msg "Applying patch from $i..."
-		git apply "$i" &>>"$cfg_log_dir/patch.log" || {
-			vintner.err "failed"
-			return 1
-		}
-
-		./tools/make_requests
-		vintner.msg 'done'
-	done
-
-	vintner.msg "Configuring..."
-	./configure --prefix="$cfg_prefix" ${configure_options} &> "$cfg_log_dir/configure.log" || {
-		vintner.err "failed"
-		return 1
-	}
-	vintner.msg 'done'
-
-	make_start_time=`date +%s`
-
-	vintner.msg "Making wine..."
-	vintner.make || {
-		vintner.err "failed"
-		return 1
-	}
-
-	make_end_time=`date +%s`
-
-	vintner.msg "done in $((make_end_time-make_start_time)) seconds"
-}
-
-while getopts "hp:P:c:" option; do
-	case "$option" in
-		p) patchlist+=( "$OPTARG" );;
-		P) cfg_prefix="$OPTARG";;
-		c) cfg_options="$OPTARG";;
-		h|*) vintner.usage; exit 1;;
-	esac
-done
-
-[[ "$OPTIND" ]] && { shift $(($OPTIND-1)); }
-
-wine_version="$1"
-
-[[ "$wine_version" ]] || {
-	vintner.usage
-	exit 7
-}
-
-vintner.init || { exit 3; }
-vintner.build || { exit 5; }
-vintner.msg 'vintner done'