amarok-svn.sh
来自「Amarok是一款在LINUX或其他类UNIX操作系统中运行的音频播放器软件。 」· Shell 代码 · 共 607 行 · 第 1/2 页
SH
607 行
#!/bin/bash# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # ## Amarok-svn# ============# This script installs the current development (SVN) version of Amarok on your computer.# If you've run it once, and then run it again, it will update your version of Amarok and only compile the new files.## Made by Jocke "Firetech" Andersson.# Idea and inspiration from a small script by Greg "oggb4mp3" Meyer.# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #echoecho "Amarok-svn (Version 3.2.1)"echo "============================"echo## Define global variablesLANG="C" #Make outputs in English, like the script itself.RCFILE="amarok-svnrc" #Settings file, will end up in '`kde-config --localprefix`/share/config/'.C_STEP="1" #The current step of the installation processS_STEPS="11" #Number of steps in the installation processTMP_FILES="" #Will be filled with URLs to temporary files## Define functionsfunction Dialog { kdialog --icon "amarok" --title "Amarok-svn$KDTITLE" "$@"}function RemoveTemp { rm -f $TMP_FILES}function Error { RemoveTemp echo echo -e "ERROR: $1" if [ "$2" != "--no-dialog" ]; then Dialog --error "$1" fi exit 1 #Exit with error}function ReadConfig { kreadconfig --file "$RCFILE" --group Settings --key "$1"}function WriteConfig { kwriteconfig --file "$RCFILE" --group Settings --key "$1" "$2"}function CheckBinary { if [ ! -x "`which $1`" ]; then #check if $1 is in $PATH and can be executed ERROR_TEXT="Amarok-svn requires $1, which wasn't found in your \$PATH!" if [ "$2" ]; then ERROR_TEXT="$ERROR_TEXT ($2)" fi Error "$ERROR_TEXT" $3 fi}function FlagUsage { echo "Usage: $0 [options] [builddir]" echo echo "Amarok-svn installs the current development (SVN) version of Amarok on your computer." echo echo "Options:" echo -e " -r, --reset\t\tAsk for settings again." echo -e " -s, --select-server\tAsk which SVN server to use. (Only needed if you want to use your SVN account.)" echo -e " -c, --clean\t\tClean the source tree before compiling Amarok." echo -e " -h, --help\t\tShow this message." echo echo "Arguments:" echo -e " builddir\t\tDownload and build Amarok in this directory. Default is '[your current dir]/amarok-svn'." echo echo "Notes:" echo " * Options can NOT be fused together! (I.E. You can't use '-cr', you have to use '-c -r'.)" echo " * Amarok-svn will download the Amarok sources directly into the folder you choose, without creating any subdirectory!" echo exit 1}function Clean { unsermake clean if [ "$?" != "0" ]; then #If the command didn't finish successfully Error "Failed to clean the source tree!" fi}function Compile { COMP_START=`date +%s` #Run unsermake twice because of some files that gets forgotten sometimes #(We don't want to compile as root in unsermake install, and it doesn't hurt) unsermake && unsermake if [ "$?" = "0" ]; then #If the command did finish successfully echo #stopwatch. let COMP_TIME=`date +%s`-COMP_START let COMP_M=COMP_TIME/60 let COMP_S=COMP_TIME%60 echo "Compilation successful after $COMP_M minute(s) and $COMP_S second(s)." else echo if [ "$CLEAN_BUILD" = "0" ]; then echo "Compilation Failed!" Dialog --warningyesno "Compilation failed!\nSometimes, a clean rebuild can fix this.\nDo you want to retry compiling with a clean source tree?\nIf you answer No, Amarok-svn will exit." if [ "$?" = "0" ]; then #If user said yes echo "Retrying with a clean source tree." CLEAN_BUILD="1" Clean Compile else Error "Compilation failed! Amarok was NOT installed/updated." fi else Error "Compilation failed! Amarok was NOT installed/updated." fi fi}## Handle --flags# set default valuesRESET_CONF="0"CLEAN_BUILD="0"SELECT_SERVER="0"BUILD_DIR="`pwd`/amarok-svn"# read flags valuesBUILD_DIR_SET="0"for flag; do case "$flag" in -r|--reset) RESET_CONF="1" ;; -c|--clean) CLEAN_BUILD="1" let S_STEPS=S_STEPS+1 ;; -s|--select-server) SELECT_SERVER="1" ;; -h|--help) FlagUsage ;; -*) echo "Unknown option '$flag'." echo echo "---------------------- ---- --- -- -- -- - -" echo FlagUsage ;; *) if [ "$BUILD_DIR_SET" = "0" ]; then BUILD_DIR="$flag" BUILD_DIR_SET="1" else echo "Excessive argument: '$flag'." echo echo "---------------------- ---- --- -- -- -- - -" echo FlagUsage fi ;; esacdone## Check requirementsCheckBinary kdialog "" --no-dialogCheckBinary svn "Version 1.1 or newer is needed."CheckBinary kde-config "kde-config sometimes falls out of the \$PATH for some reason."CheckBinary kreadconfigCheckBinary kwriteconfig## Check the build directoryif [ -e "$BUILD_DIR" -a ! -f "$BUILD_DIR/.amarok-svn-dir" ]; then #if directory exist and isn't watermarked if [ -d "$BUILD_DIR" ]; then Dialog --warningyesno "The directory you choosed to build in ($BUILD_DIR) already exists, and it wasn't detected as an Amarok-svn directory.\nFiles in this directory can possibly be overwritten by the Amarok-svn procedures.\nDo you want to use this directory anyway?" if [ "$?" != "0" ]; then #If the user said no, exit. exit 1 fi else Error "The build directory you have chosen exists, but it's not a directory!" fifi## Check if user is rootif [ "`id -u`" = "0" ]; then #if user is root Dialog --warningcontinuecancel "You are running Amarok-svn as root! This is not required, and generally not a good idea.\n(Amarok-svn will get root privileges by itself when needed, see the settings for details.)\nAre you sure you want to continue anyway?" --dontagain $RCFILE:root_warning if [ "$?" != "0" ]; then #If the user said cancel. exit 1 fifi## Settingsif [ -s "`kde-config --localprefix`/share/config/$RCFILE" -a "$RESET_CONF" != "1" ]; then #If the settings exists and the user doesn't want to change them. GET_LANG="`ReadConfig get_lang`" if [ -z "$GET_LANG" ]; then #Save default value if empty GET_LANG="en_US" WriteConfig get_lang "$GET_LANG" fi CONF_FLAGS_RAW="`ReadConfig conf_flags`" CONF_FLAGS="" for flag in $CONF_FLAGS_RAW; do CONF_FLAGS="$CONF_FLAGS `echo $flag | sed -e \"s/__/--/\"`" done HOW_ROOT="`ReadConfig how_root`" if [ -z "$HOW_ROOT" ]; then #Save default value if empty HOW_ROOT="kdesu" WriteConfig how_root "$HOW_ROOT" fi USE_ID="`ReadConfig use_id`" if [ -z "$USE_ID" ]; then #Save default value if empty USE_ID="0" WriteConfig use_id "$USE_ID" fielse ## Language AUTO_LANG="`kreadconfig --group Locale --key Language | sed -re \"s/:.+//\"`" if [ "$AUTO_LANG" != "" ]; then #Generally, if the user is running KDE Dialog --yesno "I detected that you are running KDE with language '$AUTO_LANG'.\nIf this is correct (and you want it that way), I will download localization and documentation for Amarok in that language.\nDo you want this language?" fi if [ "$?" = "0" -a "$AUTO_LANG" != "" ]; then #If the user said yes, and is running KDE... GET_LANG="$AUTO_LANG" else Dialog --msgbox "Which language do you want to download localization and documentation for?\nA list of available languages is available at http://websvn.kde.org/trunk/l10n/ (It is CaSe sensitive!)\nIf you want to use the default language (American English), either leave this empty or set it to 'en_US' (it's not in the list above).\n(Click Ok to get to the input box.)" GET_LANG="`Dialog --inputbox \"Specify language to download localization and documentation for\"`" fi if [ -z "$GET_LANG" ]; then GET_LANG="en_US" fi WriteConfig get_lang "$GET_LANG" ## ./configure flags Dialog --yesno "Do you want to use any extra configuration options (in addition to '--prefix=`kde-config --prefix` --enable-debug=full')?\nNo extra options is the default, and that works fine.\n(For a list of available flags, say yes and enter 'help' (CaSe insensitive) in the box, then wait for Amarok-svn to get to the configuration step (step 8).)" if [ "$?" = "0" ]; then #If the user said yes CONF_FLAGS_RAW="`Dialog --inputbox \"Specify extra configuration options to use\"`" if [ "`echo $CONF_FLAGS_RAW | tr A-Z a-z`" != "help" ]; then CONF_FLAGS="" CONF_FLAGS_SAVE="" for flag in $CONF_FLAGS_RAW; do if [ "$flag" != "--help" ]; then CONF_FLAGS="$CONF_FLAGS $flag" CONF_FLAGS_SAVE="$CONF_FLAGS_SAVE `echo $flag | sed -e \"s/--/__/\"`" fi done WriteConfig conf_flags "$CONF_FLAGS_SAVE" else CONF_HELP="true" fi fi ## What to use to get root privileges for installation? HOW_ROOT="`kdialog --radiolist \"How do you want Amarok-svn to get root privileges for the install/uninstall commands?\" kdesu \"With 'kdesu' (default, choose this if unsure)\" on sudo \"With 'sudo'\" off \"su -c\" \"With 'su -c'\" off`" if [ -z "$HOW_ROOT" ]; then #Fallback if the user pressed cancel HOW_ROOT="kdesu" fi WriteConfig how_root "$HOW_ROOT" USE_ID="0" #Assume default answer Dialog --yesno "Do you want to use build ID?\nThis feature is generally not needed, and often makes the compiling time longer.\nIf you use it, you can tell from the About box in Amarok when your revision was compiled.\nDefault answer is No, you can get this information from other places." if [ "$?" = "0" ]; then #If the user said yes USE_ID="1" fi WriteConfig use_id "$USE_ID"fiif [ "$SELECT_SERVER" = "1" ]; then #SVN server selection WriteConfig svn_server "`kdialog --title \"$KD_TITLE\" --inputbox \"Specify which SVN server you want to use. Default is 'svn://anonsvn.kde.org'.\"`"fiSVN_SERVER="`ReadConfig svn_server`"if [ -z "$SVN_SERVER" ]; then #Save default value if empty SVN_SERVER="svn://anonsvn.kde.org" WriteConfig svn_server "$SVN_SERVER"fi## Start the installation process and show the settingsINST_START=`date +%s`echo "Used configuration"echo "--------------------"echo "(Use --help to get information on how to change it.)"echo echo -e "SVN server:\t\t\t\t\t$SVN_SERVER"echo -e "Language for localization and documentation:\t$GET_LANG"if [ "$CONF_HELP" != "true" -a "`echo $CONF_FLAGS`" ]; then echo -e "Extra configuration options:\t\t\t`echo $CONF_FLAGS`" #`echo ...` strips the preceeding space.fiecho -e "Command for getting root privileges:\t\t$HOW_ROOT"echo -en "Build ID:\t\t\t\t\t"if [ "$USE_ID" = "1" ]; then echo "On"else echo "Off"fiecho -e "Build directory:\t\t\t\t$BUILD_DIR"echo -ne "Clean source tree:\t\t\t\t"if [ "$CLEAN_BUILD" = "1" ]; then echo "On"else echo "Off"
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?