MestreLion

wine-import-extensions - Register native MimeTypes in Wine

Jul 30th, 2011
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 20.07 KB | None | 0 0
  1. #!/bin/bash -u
  2. #
  3. # wine-import-extensions - Register native file extensions in Wine
  4. #
  5. #    Copyright (C) 2011 Rodrigo Silva (MestreLion) <[email protected]>
  6. #
  7. #    This program is free software: you can redistribute it and/or modify
  8. #    it under the terms of the GNU General Public License as published by
  9. #    the Free Software Foundation, either version 3 of the License, or
  10. #    (at your option) any later version.
  11. #
  12. #    This program is distributed in the hope that it will be useful,
  13. #    but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15. #    GNU General Public License for more details.
  16. #
  17. #    You should have received a copy of the GNU General Public License
  18. #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
  19. #
  20. # Huge thanks for all the gurus and friends in irc://irc.freenet.org/#bash
  21. # and the contributors of http://mywiki.wooledge.org/
  22. #
  23. # FIXME: inhibit winemenubuilder for exts that have multiple mime-types. It is a
  24. #  corner case where winemenubuilder might choose a different mime than I did.
  25. #  Currently I (must) sort and de-dupe user+sys globs, while wmb just picks the
  26. #  first match in user+sys (no sort, no de-dupe)
  27. # FIXME: Only add extensions that have default app (defauts.list+mimeapps.list)
  28. #  Will be *really* hard considering there is user and system databases,
  29. #  [Removed Apps] section in mimeapps.list, and, most important, mimetypes have
  30. #  aliases and *parents* (example: *.xml files may be opened by plain/text app,
  31. #  *.deb by application/zip, and so on - how to deal with that?)
  32. # FIXME: Properly handle cases in exts and mime-types. Windows might be case-
  33. #  insensitive but winemenubuilder is not
  34. # TODO: restore option (from backup file)
  35. # TODO: undo option (from import file)
  36. # TODO: --include-only and --force-all options
  37. # TODO: update list with status for each extension (new, updated, skipped, etc)
  38. # TODO: handle URIs (mailto:, magnet:, irc://)
  39.  
  40.  
  41. #######################################  Definitions
  42.  
  43. exec 3> /dev/null # to avoid harcoding /dev/null everywhere. For tools' stderr.
  44. SELF="${0##*/}" # buitin $(basename $0)
  45.  
  46. #user input
  47. BOTTLE=
  48. REGFILE=
  49. BACKUP=
  50. RESTORE=
  51. LIST=
  52. OVERWRITE=
  53. SKIP=
  54. PREFIX=
  55.  
  56. #parameters
  57. VERBOSE=
  58. TEST=
  59. DEBUG=
  60. GUI=
  61.  
  62. #constants
  63. CLASSTAG="WineImportedExtension"
  64. REGEX='\.[[:alnum:]_+%~-]+'
  65. WINEBOTTLEHOME="$HOME/.local/share/wineprefixes"
  66.  
  67. #global variables
  68. command=
  69. appname=
  70. icon=
  71. prefix="${WINEPREFIX:-"$HOME/.wine"}"
  72. executable="$prefix/dosdevices/c:/windows/system32/winebrowser.exe"
  73. output="REGEDIT4"$'\n'$'\n'
  74. outputfile=
  75. sysreg=
  76. native_ext=
  77. wine_ext=
  78. wine_class=
  79. classes=
  80. long=
  81. savedlocale=
  82. prev_ext=
  83. tempfile=
  84. n_ext=0
  85. n_cls=0
  86. n_dup=0
  87. n_ovr=0
  88. n_skp=0
  89. n_mim=0
  90.  
  91. #######################################  Common functions (from lib, lowercase)
  92.  
  93. fatal()
  94. {
  95.     local message="${1:-}"
  96.     local errorcode="${2:-1}"
  97.    
  98.     [[ "$message" ]] && printf "%s\n" "$SELF: ${message/%[[:punct:]]/}" >&2
  99.     exit $errorcode
  100. }
  101.  
  102. xdg_data_cat()
  103. {
  104.     local path="$1"
  105.     local user
  106.     local sys
  107.     local folder
  108.     local list=()
  109.  
  110.     user="${XDG_DATA_HOME:-$HOME/.local/share}/$path"
  111.     [[ -e "$user" ]] && list+=("$user")
  112.    
  113.     IFS=: read -ra sys <<< "${XDG_DATA_DIRS:-/usr/local/share/:/usr/share/}"
  114.    
  115.     for folder in "${sys[@]}" ; do
  116.         if [[ -e "$folder/$path" ]] ; then
  117.             list+=("${folder%/}/$path")
  118.         fi
  119.     done
  120.    
  121.     cat "${list[@]}"
  122. }
  123.  
  124. crc16()
  125. (
  126.     export LC_ALL=C
  127.     local string="${1:-}"
  128.     local crc=0
  129.     local i j xor_poly
  130.  
  131.     for ((i=0; i<${#string}; i++)); do
  132.         c=$(printf "%d" "'${string:i:1}")
  133.         for ((j=0; j<8; c>>=1, j++)); do
  134.             (( xor_poly = (c ^ crc) & 1 ))
  135.             (( crc >>= 1 ))
  136.             (( xor_poly )) && (( crc ^= 0xA001 ))
  137.         done
  138.     done
  139.  
  140.     printf "%04X\n" "$crc"
  141. )
  142.  
  143.  
  144. #######################################  Functions (this script only)
  145.  
  146. Usage ()
  147. {
  148.     local explicit="${1:-}"
  149.    
  150.     cat <<-_USAGE
  151.     Usage: $SELF [OPTIONS]
  152.     _USAGE
  153.    
  154.     if [[ -z "$explicit" ]] ; then
  155.         cat <<-_USAGE
  156.         Try '$SELF --help' for more information.
  157.         _USAGE
  158.         return
  159.     fi
  160.    
  161.     cat <<-_USAGE
  162.  
  163.     Imports all native file extensions (globs in xdg mime database) into Wine
  164.     registry, setting file handler to winebrowser. This allows Wine applications
  165.     to launch files in default native Linux applications
  166.  
  167.     Options:
  168.      -h, --help     print this message and exit
  169.      -v, --verbose  verbose output (displays extra information)
  170.      -t, --test     simulation test, do not change wine registry
  171.      -d, --debug    displays debug information on parsed options and arguments
  172.      
  173.      -k, --backup FILE
  174.          Backup current Wine Registry (system.reg) to FILE (WineRegistry format)
  175.          This is the backup file that must be provided for --restore option
  176.          
  177.      -c, --savechanges FILE
  178.          Generates a registry file with all the applied changes (Windows format)
  179.          This is the file that must be provided for --undo option
  180.          
  181.      -l, --list FILE
  182.          Generates a tab-delimited file with current native extensions and mime-
  183.          types and its associated wine classes and file handlers (if any)
  184.  
  185.      -p, --prefix PATH
  186.          Sets the wine prefix to work. If used, enviroment variable WINEPREFIX
  187.          is ignored. It is overwritten by --bottle
  188.  
  189.      -b, --bottle NAME
  190.          Sets the wine bottle to work. A bottle is a wine prefix currently
  191.          located at $WINEBOTTLEHOME/NAME
  192.          If used, enviroment variable WINEPREFIX is ignored. Overrides --prefix
  193.                          
  194.      -o, --overwrite EXT,...
  195.          Import listed native extension(s) even if there is already a registered
  196.          file handler in wine. Original class name will not be changed. If an
  197.          extension is registered to a class that has several extensions (for
  198.          example jpegfile for jpg and jpeg), all associated extensions will be
  199.          affected. Listed extensions that do not exist in native environment
  200.          will be silently ignored. List must be comma-delimited and EXT must be
  201.          the extension without any dots or asterisks.Ex: --overwrite jpg,gif,txt
  202.      
  203.      -s, --skip EXT,...
  204.          Do not import native extension even if there is no registered class or
  205.          file handler in wine. Opposite of -o. List must be comma-delimited, EXT
  206.          must be the extension without any dots or asterisks. Ex: --skip dll,cpl
  207.      
  208.      -g, --gui
  209.          Instead of winebroswer, register an alternate handler, created
  210.          on-the-fly, called winebrowser-gui. It uses GUI (zenity) for errors
  211.          (file not found and default application not registered)
  212.    
  213.      -r
  214.    
  215.    
  216.     Examples and suggested uses:
  217.     $SELF -vd --test --bottle test --backup  system.reg.bak --list ext.txt
  218.     $SELF -vd --test --bottle test --regfile import.reg --gui \
  219.                      --overwrite gif,jpg,png,txt --skip cpl,dll,lnk,msi,msp,vbs
  220.  
  221.      
  222.     Author: Rodrigo Silva (MestreLion) <linux@rodrigosilva.com>
  223.     License: GPL3 or later, at your choice.See <http://www.gnu.org/licenses/gpl>
  224.     _USAGE
  225. }
  226.  
  227. PrintFlags()
  228. {
  229.     cat <<-_PRINTFLAGS
  230.     Parsed Options  =$GETOPT
  231.     Debug           = $DEBUG
  232.     Verbose         = $VERBOSE
  233.     Simulation Test = $TEST
  234.     GUI handler     = $GUI
  235.     Wine Bottle     = $BOTTLE
  236.     Wine Prefix     = $prefix
  237.     Registry file   = $REGFILE
  238.     Backup file     = $BACKUP
  239.     List file       = $LIST
  240.     _PRINTFLAGS
  241. }
  242.  
  243. SetupWinePrefix()
  244. {
  245.     [[ -f "$sysreg" ]] && return
  246.    
  247.     [[ "$VERBOSE" ]] && {
  248.         echo "Creating wine prefix $prefix"
  249.         echo "This may take a while..."
  250.     }
  251.     wine wineboot 2>&3 || fatal "Could not create wine prefix $prefix"
  252.     while [[ ! -f "$sysreg" ]] ; do : ; done ; sleep 3
  253. }
  254.  
  255. SetupExecutable()
  256. {
  257.     local winexec
  258.  
  259.     [[ "$GUI" || "$RESTORE" ]] && executable="${executable//.exe/-gui.exe}"
  260.  
  261.     winexec="$(wine winepath -w "$executable")"
  262.     command="${winexec//\\/\\\\} \\\"%1\\\""
  263.  
  264.     appname="${executable##*/}"
  265.     appname="${appname%%\.*}"
  266.    
  267.     icon="$(crc16 "$winexec")_${appname}.0" # pray index will always be 0  
  268.    
  269.     [[ "$GUI" && ! "$TEST" && ! "$RESTORE" ]] || return
  270.  
  271.     # Since gvfs-open (used by xdg-open in modern Gnome) does not signal failure
  272.     # when no application is found to open a given extension, we cannot use $?
  273.     # to test xdg-open success. Must trust a silent execution for that.
  274.     cat > "$executable" <<-_WINEBROWSERGUI
  275.         #!/bin/bash
  276.         error=\$(xdg-open "\$(wine winepath -u "\$1")" 2>&1)
  277.         error=\${error##*:}
  278.         if [[ "\$error" ]] ; then
  279.             zenity --error --no-wrap --text="\${error//&/&amp;}"
  280.             exit 1
  281.         fi
  282.     _WINEBROWSERGUI
  283.     [[ $? -eq 0 ]] || fatal "Could not create $executable"
  284.     chmod +x "$executable"
  285.    
  286.     [[ "$VERBOSE" ]] && echo "GUI launcher created in $winexec"
  287. }
  288.  
  289. RegistryAddExt()
  290. {
  291.     local ext="$1"
  292.     local class="$2"
  293.    
  294.     output+="[HKEY_CLASSES_ROOT\.${ext}]"$'\n'
  295.     output+="@=\"${class}\""$'\n\n'
  296. }
  297.  
  298. RegistryAddClass()
  299. {
  300.     local class="$1"
  301.     local handler="$2"
  302.     local undo="${3:-}"
  303.    
  304.     output+="[HKEY_CLASSES_ROOT\\${class}\shell\open\command]"$'\n'
  305.     output+="@=\"${handler}\""$'\n'
  306.     [[ "$undo" ]] && output+="\"${CLASSTAG}_undo\"=\"${undo}\""$'\n'
  307.     output+=$'\n'
  308. }
  309.  
  310. # winemnubuilder inhibitor
  311. RegistryAddAssoc()
  312. {
  313.     local ext="$1"
  314.     local class="$2"
  315.     local mimetype="$3"
  316.    
  317.     output+="[HKEY_CURRENT_USER\\Software\\Wine\\FileOpenAssociations\\.${ext}]"$'\n'
  318.     output+="\"AppName\"=\"${appname}\""$'\n'
  319.     output+="\"MimeType\"=\"${mimetype}\""$'\n'
  320.     output+="\"OpenWithIcon\"=\"${icon}\""$'\n'
  321.     output+="\"ProgID\"=\"${class}\""$'\n\n'
  322. }
  323.  
  324. #Do NOT use in subshells!
  325. CreateTempFile()
  326. {
  327.     # See if this was called before
  328.     if [[ "$tempfile" ]]; then
  329.         # "push" previous file to end of array
  330.         tempfile+=( "$tempfile" )
  331.     else
  332.         # set the trap
  333.         trap 'rm -f -- "${tempfile[@]}"' EXIT
  334.     fi
  335.    
  336.     # set new file
  337.     tempfile=$(tempfile) || fatal "could not create temporary file"
  338. }
  339.  
  340. Restore()
  341. {
  342.     local backup="$RESTORE"
  343.  
  344.     [[ "$TEST" ]] && return
  345.  
  346.     cp "$backup" "$sysreg" || fatal "Could not restore wine's registry "
  347.    
  348.     # Force wine to update extensions
  349.     wine winemenubuilder -a -r
  350.    
  351.     # delete winebrowser-gui.exe
  352.     rm -f "$executable"
  353. }
  354.  
  355. #######################################  Command Line parsing
  356.  
  357. long="help,verbose,test,debug,gui,bottle:,prefix:,savechanges:,overwrite:,skip:,
  358. backup:,restore:,list:,undo:"
  359. GETOPT=$(getopt --alternative --name="$SELF" --options="vtdgb:k:c:"            \
  360.                 --longoptions="$long" -- "$@"
  361. ) || { Usage ; exit 1; } # error in getopt
  362.  
  363. eval set -- "$GETOPT"
  364.  
  365. while true ; do
  366.     arg="$1"
  367.     shift
  368.     case "$arg" in
  369.     -v|--verbose    ) VERBOSE=1              ;; # Set verbose
  370.     -t|--test       ) TEST=1                 ;; # Set simulation test
  371.     -d|--debug      ) DEBUG=1                ;; # Set debug mode
  372.     -g|--gui        ) GUI=1                  ;; # Set GUI flag
  373.     -e|--eudora     ) EUDORA=1               ;; # Undocumented, for now
  374.     -p|--prefix     ) PREFIX="$1"   ; shift  ;; # Set Wine prefix
  375.     -b|--bottle     ) BOTTLE="$1"   ; shift  ;; # Set Wine Bottle
  376.     -c|--savechanges) REGFILE="$1"  ; shift  ;; # Set Registry change file
  377.     -k|--backup     ) BACKUP="$1"   ; shift  ;; # Set Registry backup file
  378.     -l|--list       ) LIST="$1"     ; shift  ;; # Set list file
  379.     -r|--restore    ) RESTORE="$1"  ; shift  ;; # Set restore file
  380.     -o|--overwrite  ) OVERWRITE="$1"; shift  ;; # Set list of exts to overwrite
  381.     -s|--skip       ) SKIP="$1"     ; shift  ;; # Set list of exts to skip
  382.     -h|--help       ) Usage "HELP"  ; exit   ;; # Help requested
  383.     --              ) break                  ;;
  384.     *               ) Usage         ; exit 1 ;;
  385.     esac
  386. done
  387.  
  388.  
  389. #######################################  Main Body
  390.  
  391. [[ "$PREFIX" ]] && prefix="$PREFIX"
  392. [[ "$BOTTLE" ]] && prefix="$WINEBOTTLEHOME/$BOTTLE"
  393. [[ "$DEBUG"  ]] && { PrintFlags ; exec 3>&2 ; }
  394.  
  395. export WINEPREFIX="$prefix"
  396.  
  397. sysreg="$prefix/system.reg"
  398.  
  399. SetupWinePrefix
  400. SetupExecutable
  401.  
  402. [[ "$RESTORE" ]] && { Restore ; exit ; }
  403.  
  404.  
  405. # LC_ALL=C speed up processing and allow proper join
  406. # But should not be set for Wine commands, since locale is relevant
  407. savedlocale="$LC_ALL"
  408. export LC_ALL=C
  409.  
  410. # Native extensions (freedesktop.org xdg mime database globs)
  411. # Format: <NUMBER>:$mimetype:$glob
  412. native_ext=$( { awk -F: '$3~/^\*'"$REGEX"'$/ && !/^#/ {
  413.                            print tolower(substr($3,3)) "\t" tolower($2)
  414.                         }'                                                    \
  415.                     < <(xdg_data_cat "mime/globs2")                            \
  416.                 || fatal "Could not access mime database globs list"
  417.               }                                                                \
  418.               | sort --unique
  419. ) 2>&3
  420.  
  421. [[ "$VERBOSE" ]] && printf "%4d %s\n" $(wc -l <<< "$native_ext")               \
  422.                            "native extensions found (A)"
  423.  
  424. # Wine extensions that have associated classes (from registry)
  425. # Format:
  426. # [Software\\Classes\\.$ext]<BLANK><NUMBER>
  427. # @="$class"
  428. wine_ext=$( { awk -F= '
  429.                  tolower($0)~/^\[software\\\\classes\\\\'"$REGEX"'\]/ {
  430.                      split($0,a,/[].]/)
  431.                      ext=a[2]
  432.                      next
  433.                  }
  434.                  /^\[/ { ext="" }
  435.                  /^@="/ {
  436.                      if(ext) {
  437.                          gsub(/^@="|"$/,"")
  438.                          print tolower(ext) "\t" $0
  439.                          ext=""
  440.                      }
  441.                  }' "$sysreg"                                      \
  442.               || fatal "Could not read wine registry $sysreg"
  443.             }                                                                  \
  444.             | sort                                                             \
  445. ) 2>&3
  446.  
  447. [[ "$VERBOSE" ]] && printf "%4d %s\n" $(wc -l <<< "$wine_ext")                 \
  448.                            "wine extensions with classes found (B)"
  449.  
  450.  
  451. # Wine classes that have associated file handlers (from registry)
  452. # Format:
  453. # [Software\\Classes\\$class\\\\shell\\open\\command]<BLANK><NUMBER>
  454. # @="$handler"
  455. wine_class=$( { awk -F= '
  456. tolower($0)~/^\[software\\\\classes\\\\[^\\\]]+\\\\shell\\\\open\\\\command\]/{
  457.    split($0,a,/\\\\/)
  458.    class=a[3]
  459.    next
  460. }
  461. /^\[/ { class="" }
  462. /^@="/ {
  463.    if(class) {
  464.        gsub(/^@="|"$/,"")
  465.        print class "\t" $0
  466.        class=""
  467.    }
  468. }' "$sysreg"                                                        \
  469.                 || fatal "Could not read wine registry $sysreg"
  470.               }                                                                \
  471.               | sort --ignore-case                                             \
  472. ) 2>&3
  473.  
  474. [[ "$VERBOSE" ]] && printf "%4d %s\n" $(wc -l <<< "$wine_class")               \
  475.                            "wine classes with file handlers found (C)"
  476.  
  477. # Loop the combined list
  478. # (All native extensions with their corresponding wine class and file handler)
  479. [[ "$LIST" ]] && { printf "EXT\tMIMETYPE\tCLASS\tFILE HANDLER\n" > "$LIST"     \
  480.                    || fatal "could not create list file $LIST" ; }
  481. while IFS=$'\t' read -r -s ext mimetype class handler; do
  482.  
  483.     [[ "$LIST" ]] && {
  484.         if [[ "${LIST##*\.}" = "ods" ]]; then
  485.             printf "\"%s\"\t\"%s\"\t\"%s\"\t\"%s\"\n"             \
  486.                    "$ext" "$mimetype" "$class" "$handler" >> "$LIST"
  487.         else
  488.             printf "%s\t%s\t%s\t%s\n"                             \
  489.                    "$ext" "$mimetype" "$class" "$handler" >> "$LIST"
  490.         fi
  491.     }
  492.    
  493.     # Skip undesirable extensions
  494.     [[ ",${SKIP}," = *",${ext},"* ]] && { (( n_skp++ )); continue; }
  495.  
  496.     # Skip duplicate extensions (with different mime-types, like ogg)
  497.     if [[ "$prev_ext" = "$ext" ]]; then
  498.         (( n_mim++ )); continue;
  499.     else
  500.         prev_ext=$ext
  501.     fi
  502.    
  503.  
  504.     # See if extension has no class
  505.     if [[ -z "$class" ]]; then
  506.         class="${CLASSTAG}.${ext}"
  507.         RegistryAddExt   "$ext"   "$class"  ; (( n_ext++ ))
  508.         RegistryAddClass "$class" "$command"; (( n_cls++ ))
  509.         RegistryAddAssoc "$ext"   "$class" "$mimetype"
  510.         output+=$'\n\n'
  511.    
  512.     # See if class has no handler or is a forced extension
  513.     elif [[ -z "$handler" || ",${OVERWRITE}," = *",${ext},"* ]]; then
  514.    
  515.         # avoid duplicate classes (eg, both mht and mhtml point to mhtmlfile)
  516.         if [[ "$'\t'$classes" = *"$'\t'${class}$'\t'"* ]]; then
  517.             (( n_dup++ ))
  518.         else
  519.             classes+="${class}$'\t'"
  520.             RegistryAddClass "$class" "$command" "$handler"
  521.             RegistryAddAssoc "$ext"   "$class"   "$mimetype"
  522.             output+=$'\n\n'
  523.             if [[ "$handler" ]]; then (( n_ovr++ )) ; else (( n_cls++ )) ; fi
  524.         fi
  525.     fi
  526.  
  527. done < <(                                                                      \
  528.     join -a1 -t$'\t' -o2.2,0,1.2 <(echo "$native_ext") <(echo "$wine_ext") |   \
  529.     sort --ignore-case                                                     |   \
  530.     join -a1 -t$'\t' -i -o1.2,1.3,0,2.2 - <(echo "$wine_class")            |   \
  531.     sort
  532. ) 2>&3
  533.  
  534. [[ "$VERBOSE" ]] && {
  535.     printf "%4d %s\n" $n_ext "extensions lacking class will be added (A \ B)"
  536.     printf "%4d %s\n" $n_cls "classes lacking file handler will be added (A ∩ B) \ C"
  537.    
  538.     [[ "$n_ovr" -gt 0 ]] && printf "%4d %s\n" $n_ovr                       \
  539.       "classes with file handler will be overwrited"
  540.  
  541.     [[ "$n_skp" -gt 0 ]] && printf "%4d %s\n" $n_skp                       \
  542.       "extensions were skipped by user request"
  543.  
  544.     [[ "$n_mim" -gt 0 ]] && printf "%4d %s\n" $n_mim                       \
  545.       "extensions were duplicate with multiple mime-types and were ignored"
  546.  
  547.     [[ "$n_dup" -gt 0 ]] && printf "%4d %s\n     %s\n" $n_dup              \
  548.       "classes were duplicate and thus ignored"                            \
  549.       "(different extensions pointing to a class that was already processed)"
  550. }
  551.  
  552. # Announce if list was created
  553. [[ "$LIST" && "$VERBOSE" ]] && printf "List file was generated to \"$LIST\"\n"
  554.  
  555. # Backup current registry
  556. [[ "$BACKUP" ]] && {
  557.     cp "$sysreg" "$BACKUP" || fatal "Could not create backup file $BACKUP"
  558.     [[ "$VERBOSE" ]] && printf "Current Registry was backed up to \"$BACKUP\"\n"
  559. }
  560.  
  561. # Dump the output
  562. [[ "$REGFILE" ]] && {
  563.     printf '%s' "$output" > "$REGFILE" || fatal "Could not create registry file $REGFILE"
  564.     [[ "$VERBOSE" ]] && printf "Registry file was generated to \"$REGFILE\"\n"
  565. }
  566.  
  567. # Create temp file for regedit, or use the user generated
  568. if [[ "$REGFILE" ]]; then
  569.     outputfile="$REGFILE"
  570. else
  571.     CreateTempFile; outputfile="$tempfile"
  572.     printf '%s' "$output" > "$outputfile"
  573. fi
  574.  
  575. # Merge the registry
  576. if [[ "$TEST" ]]; then
  577.     [[ "$VERBOSE" ]] && echo "Test run, registry was not changed"
  578. else
  579.     export LC_ALL="$savedlocale"
  580.     wine regedit "$outputfile" || fatal "Registry changes could not be merged into wine"
  581.     [[ "$VERBOSE" ]] && echo "Registry changes successfully merged into wine"
  582. fi
  583.  
  584. exit 0
  585.  
  586.  
  587. # Sample outputs:
  588.  
  589. #rodrigo@desktop ~ $ wine-import-extensions -vd --bottle test --backup system.reg.bak --list ext.txt
  590. #Parsed Options  = -v --debug --bottle 'test' --backup 'system.reg.bak' --list 'ext.txt' --
  591. #Debug           = 1
  592. #Verbose         = 1
  593. #Simulation Test =
  594. #GUI handler     =
  595. #Wine Bottle     = test
  596. #Wine Prefix     = /home/rodrigo/.local/share/wineprefixes/test
  597. #Registry file   =
  598. #Backup file     = system.reg.bak
  599. #List file       = ext.txt
  600. # 758 native extensions found (A)
  601. #  29 wine extensions with classes found (B)
  602. #  21 wine classes with file handlers found (C)
  603. # 694 extensions lacking class will be added (A \ B)
  604. # 703 classes lacking file handler will be added (A ∩ B) \ C
  605. #  35 extensions were duplicate with multiple mime-types and were ignored
  606. #   1 classes were duplicate and thus ignored
  607. #     (different extensions pointing to a class that was already processed)
  608. #List file was generated to "ext.txt"
  609. #Current Registry was backed up to "system.reg.bak"
  610. #Registry changes successfully merged into wine
  611.  
  612.  
  613. #   rodrigo@desktop ~ $ /usr/bin/time -f'%E' wine-import -vdg -b teste -r reg.txt;echo $?
  614. #   Parsed Options  = -v -d --gui --bottle 'teste' --regfile 'regfile.txt' --
  615. #   Debug           = 1
  616. #   Verbose         = 1
  617. #   Non-Interactive =
  618. #   Simulation Test =
  619. #   GUI handler     = 1
  620. #   Wine Bottle     = teste
  621. #   Wine Prefix     = /home/rodrigo/.local/share/wineprefixes/teste
  622. #   Executable      = winebrowser-gui
  623. #   Registry file   = regfile.txt
  624. #    718 native extensions found (A)
  625. #     29 wine extensions with classes found (B)
  626. #     19 wine classes with file handlers found (C)
  627. #    689 extensions lacking class will be added (A \ B)
  628. #    701 classes lacking file handlers will be added (A ∩ B) \ C
  629. #   Registry file "regfile.txt" was generated
  630. #   0:00.28
  631. #   0
Advertisement
Add Comment
Please, Sign In to add comment