rpms/gnome-commander/F-8 gnome-commander.sh, NONE, 1.1 mimeedit-svn1958.diff, NONE, 1.1 mimeedit-svn1958.sh, NONE, 1.1 gnome-commander.spec, 1.16, 1.17

Mamoru Tasaka (mtasaka) fedora-extras-commits at redhat.com
Tue Aug 12 15:07:29 UTC 2008


Author: mtasaka

Update of /cvs/extras/rpms/gnome-commander/F-8
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv14127/F-8

Modified Files:
	gnome-commander.spec 
Added Files:
	gnome-commander.sh mimeedit-svn1958.diff mimeedit-svn1958.sh 
Log Message:
* Wed Aug 13 2008 Mamoru Tasaka <mtasaka at ioa.s.u-tokyo.ac.jp> - 1.2.7-4
- More fix for mimeedit.sh to remove potentially unsafe tmpfile
  creation



--- NEW FILE gnome-commander.sh ---
#!/bin/bash

export PATH=/usr/libexec/gnome-commander:$PATH
exec gnome-commander $@

mimeedit-svn1958.diff:

--- NEW FILE mimeedit-svn1958.diff ---
Index: mimeedit.sh
===================================================================
--- mimeedit.sh	(revision 1962)
+++ mimeedit.sh	(working copy)
@@ -63,11 +63,13 @@
 # Build a list with registered apps for this mimetype.
 #
 function deflist (){
-  if [ -e "$UTMP.avail" ]; then cleanup;fi
+  TMP_AVAIL="`mktemp /tmp/gnome-commander.XXXXXX`"
+  TMP_CHOSEN="`mktemp /tmp/gnome-commander.XXXXXX`"
+  # if [ -e "$UTMP.avail" ]; then cleanup;fi
   # Create the list in "$UTMP.avail" to be used by the zenity list-box
   if [ "$NONEW" == 1 ]
   then
-   echo "FALSE Add_New_App New" > "$UTMP.avail"
+   echo "FALSE Add_New_App New" > $TMP_AVAIL
   fi
   # Get all sub-mimetypes, one per row.
   SUB="$(grep -hs "^$MTPE" $SUBC $G_CACHE $U_CACHE | awk -F= '{print $1}' | sed 's/ /\n/g')"
@@ -77,14 +79,14 @@
   then
     for i in $(echo "$MTPEs" | sort -u); do
       echo "FALSE $i $(grep -hs "^Name=" $GDATA_DIR/$i $DATA_DIR/$i | \
-      sed 's/Name=//;s/ /_/g')" >> "$UTMP.avail"
+      sed 's/Name=//;s/ /_/g')" >> $TMP_AVAIL
     done
   fi
   # Change FALSE to TRUE for the default app. 
-  if grep -q "desktop" "$UTMP.avail"
+  if grep -q "desktop" $TMP_AVAIL
   then
     DEF_APP=$(gnomevfs-info -s "$ARGU" | grep "Default app" | sed 's/.*: //')
-    sed -i "s|FALSE $DEF_APP|TRUE $DEF_APP|" "$UTMP.avail"
+    sed -i "s|FALSE $DEF_APP|TRUE $DEF_APP|" $TMP_AVAIL
   fi
   # Show the list
   zenity --height="350" --width="550" --list --radiolist --text \
@@ -99,17 +101,17 @@
 
 Please select" \
   --column "Pick" --column ".desktop file" --column "Application" \
-  $(cat "$UTMP.avail") > "$UTMP.chosen" 
+  $(cat $TMP_AVAIL ) > $TMP_CHOSEN 
   retval=$?
-  choice=$(cat "$UTMP.chosen")
+  choice=$(cat $TMP_CHOSEN )
   if grep -q "$MTPE=$choice" $U_DEF
   then
     retval=2
   fi
   case $retval in
   0)
-    DEF_CH=$(grep -s "$choice" "$UTMP.avail" | awk '{print $2}')
-    DEF_NME=$(grep -s "$choice" "$UTMP.avail" | awk '{print $3}')
+    DEF_CH=$(grep -s "$choice" $TMP_AVAIL | awk '{print $2}')
+    DEF_NME=$(grep -s "$choice" $TMP_AVAIL | awk '{print $3}')
     if [ "$DEF_CH" = Add_New_App ]
     then
       newmime
@@ -305,8 +307,8 @@
 # Remove tempfiles.
 #
 function cleanup (){
-  rm -f "$UTMP.avail"
-  rm -f "$UTMP.chosen"
+  rm -f $TMP_AVAIL
+  rm -f $TMP_CHOSEN
 }
 
 #
@@ -342,6 +344,7 @@
 # The .desktop file editor
 #
 function dtfedit (){ 
+  TMPFILE=`mktemp /tmp/gnome-commander.XXXXXX`
   USER_DTF="$DT_FILE-$EXT"
   if [ -n "$DT_FILE" ]
   then 
@@ -350,15 +353,22 @@
     then
       TO_EDIT="$DATA_DIR/$USER_DTF"
     else
-      TO_EDIT="$GDATA_DIR/$DT_FILE.desktop"
+      DT_FILE_PREFIX=$(echo $DT_FILE | sed -e 's|-[0-9][0-9]*||')
+      DT_FILE_SUFFIX=$(echo $DT_FILE | sed -n -e 's|^.*-\([0-9][0-9]*\)$|\1|p')
+      if [ -e $DATA_DIR/${DT_FILE_PREFIX}-usercreated-$DT_FILE_SUFFIX.desktop ]
+      then
+	TO_EDIT="$DATA_DIR/${DT_FILE_PREFIX}-usercreated-$DT_FILE_SUFFIX.desktop"
+      else
+        TO_EDIT="$GDATA_DIR/$DT_FILE.desktop"
+      fi
     fi
     cat "$TO_EDIT" | zenity --height="350" --width="550" --text-info --editable \
-    --title "Edititng the file: $USER_DTF" > $UTMP.$USER_DTF 
-    if [ -s $UTMP.$USER_DTF ]
+    --title "Edititng the file: $USER_DTF" > $TMPFILE
+    if [ -s $TMPFILE ]
     then 
-      mv $UTMP.$USER_DTF $DATA_DIR/$USER_DTF 
+      mv $TMPFILE $DATA_DIR/$USER_DTF
     else 
-      rm -f $UTMP.$USER_DTF 
+      rm -f $TMPFILE
       DT_FILE=""
     fi
   fi


--- NEW FILE mimeedit-svn1958.sh ---
#!/bin/bash
#
# gnome-file-types-properties - 
# A zenity-script for chosing preferred applications. 
# Written by Magnus Stålnacke (jemamo at telia.com) 
# Version 0.8.4 Nov. 30 2007
#
export LANG=en_US.utf8 

ARGU="$1"
UTMP="/tmp/$(whoami)"
DATA_DIR="$HOME/.local/share/applications"
GDATA_DIR="/usr/share/applications"
G_CACHE="$GDATA_DIR/mimeinfo.cache"
U_CACHE="$DATA_DIR/mimeinfo.cache"
SUBC="/usr/share/mime/subclasses"
U_DEF="$DATA_DIR/defaults.list"
EXT="usercreated.desktop"
NONEW=1

#
# Create dirs in users home if missing. 
#
if [ -e "$DATA_DIR" ]; then :; else mkdir $DATA_DIR;fi
if [ -e "$U_DEF" ] 
then :; 
else 
  echo "[Default Applications]" > $DATA_DIR/defaults.list 
fi

#
# Check how we got started. 
#
function checkarg (){
  if [ -n "$ARGU" ]
  then
    if [ -e "$ARGU" ]
    then
      chkmtpe 
      deflist
    else
      showhelp
    fi
  else
    selfile
    dtfedit
    if [ -n "$DT_FILE" ]
    then
      update
    fi
  fi
}

#
# Mimetype check.
#
function chkmtpe (){
  MTPE=$(gnomevfs-info -s "$ARGU" | grep "MIME type" | sed 's/.*: //')
  echo "The mimetype is: $MTPE"
}

#
# Build a list with registered apps for this mimetype.
#
function deflist (){
  if [ -e "$UTMP.avail" ]; then cleanup;fi
  # Create the list in "$UTMP.avail" to be used by the zenity list-box
  if [ "$NONEW" == 1 ]
  then
   echo "FALSE Add_New_App New" > "$UTMP.avail"
  fi
  # Get all sub-mimetypes, one per row.
  SUB="$(grep -hs "^$MTPE" $SUBC $G_CACHE $U_CACHE | awk -F= '{print $1}' | sed 's/ /\n/g')"
  # Get all .desktopfiles for the above mimetypes
  MTPEs=$(grep -hs "$SUB" $U_CACHE $G_CACHE | sed 's/.*=//g;s/;$//g;s/;/\n/g;')
  if [ -n "$SUB" ]
  then
    for i in $(echo "$MTPEs" | sort -u); do
      echo "FALSE $i $(grep -hs "^Name=" $GDATA_DIR/$i $DATA_DIR/$i | \
      sed 's/Name=//;s/ /_/g')" >> "$UTMP.avail"
    done
  fi
  # Change FALSE to TRUE for the default app. 
  if grep -q "desktop" "$UTMP.avail"
  then
    DEF_APP=$(gnomevfs-info -s "$ARGU" | grep "Default app" | sed 's/.*: //')
    sed -i "s|FALSE $DEF_APP|TRUE $DEF_APP|" "$UTMP.avail"
  fi
  # Show the list
  zenity --height="350" --width="550" --list --radiolist --text \
"The list below show applications that already have an entry for the mimetype: 
$MTPE on your system, meaning they are registered to be able 
to deal with this mimetype. You can choose your preferred default application 
by checking the radiobutton. The script will adjust the mimetype settings in 
your local home directory, thus not changing anything systemwide.

If you wish you can add an application that is not in the list by checking the first 
option in list named Add_New_App 

Please select" \
  --column "Pick" --column ".desktop file" --column "Application" \
  $(cat "$UTMP.avail") > "$UTMP.chosen" 
  retval=$?
  choice=$(cat "$UTMP.chosen")
  if grep -q "$MTPE=$choice" $U_DEF
  then
    retval=2
  fi
  case $retval in
  0)
    DEF_CH=$(grep -s "$choice" "$UTMP.avail" | awk '{print $2}')
    DEF_NME=$(grep -s "$choice" "$UTMP.avail" | awk '{print $3}')
    if [ "$DEF_CH" = Add_New_App ]
    then
      newmime
    fi
    if [ -z "$NOCH" ]
    then
      if grep -q "$MTPE" $U_DEF
      then
        # Set the users chosen default app for the existing mime.
        sed -i "s|$MTPE=.*|$MTPE=$DEF_CH|" $U_DEF
      else
        # If no user default for this mimetype, add it.
         echo "$MTPE=$DEF_CH" >> $U_DEF
      fi
     update
     zenity --info --text "Default application to handle $MTPE is set to $DEF_NME"
    fi;;
  1)
    echo "Cancel pressed.";;
  -1)
    echo "ESC pressed.";;
  2)
    zenity --info --text "Default was not changed.";;
  esac
  cleanup
}

#
# Show an input box for new app to handle the mimetype.
#
function newmime (){
  NEWAPP=$(zenity --entry --text \
"Fill in the Name and command for the application you want to handle the 
mimetype: $MTPE separate them with a colon (:)

Separate Name and Command with a colon. If you omit the command, or 
type something that is not in your path, you will get the chance to 
provide the command with full path by a file chooser dialog.")

  case $? in 
  0)
   if echo "$NEWAPP" | grep -q ":"
   then
     NAME=$(echo "$NEWAPP" | awk -F: '{print $1}')
     CMD=$(echo "$NEWAPP" | awk -F: '{print $2}')
     if [ -n "$NAME" ]
     then
       check
       usercreate
     else
       zenity --error --text "Application name is missing"
       newmime
     fi
   else
     zenity --error --text "Separator missing"
     newmime
   fi
   ;;
  1)
   deflist
   ;;
  -1)
   deflist
   ;;
  esac
  NOCH=yes
}

#
# Check if the command exists in path, if not give the 
# user a filechooser.
#
function check (){
  if which $CMD >&/dev/null
  then
    CMD=`which $CMD`
  else
    CMD=$(zenity --file-selection --filename=/ --title="Chose application")
    if [ -z $CMD ]
    then
      newmime
    fi
  fi
}

#
# Create a new *.desktop file for the added app that can handle 
# the mimetype in question.
#
function usercreate(){
  APP=$(basename "$CMD")
  USER_APP="$DATA_DIR/$APP-$EXT"
  if cat $G_CACHE $U_CACHE | grep "$MTPE" | grep -q "$APP" 
  then
    zenity --error --text "The mime type: $MTPE is alredy assigned to: $APP"
    NOCH=yes
  else
    if [ -e "$USER_APP" ]
    then
      sed -i "s|MimeType=|MimeType=$MTPE;|g" $USER_APP
      update
      zenity --info --text \
      "The mime type: $MTPE is now registered to be handled by: $APP"
    else
      cat <<EOF >$USER_APP 
[Desktop Entry]
Encoding=UTF-8
Name=$NAME
Exec=$CMD
Type=Application
Terminal=false
NoDisplay=true
MimeType=$MTPE;
EOF
    fi
  fi
  if [ -z "$NOCH" ]
  then
    zenity --question --text \
"The created $(basename "$USER_APP") can now be edited manually, to add, remove or change options, do you want to do this now? 

This file should work as is, so you can safely cancel this operation, but advanced users may want to edit options to their liking. But due to a bug this editor cannot handle '%' charachters and replaces them with garbage." 
    VAL=$?
    if [ "$VAL" == 0 ]
    then 
      DT_FILE="$APP"
      dtfedit
      update
    else 
      update
    fi
    zenity --info --text "$APP is now registered to handle: $MTPE"
  fi
  NONEW=2
  deflist
}

#
# Update the users mime chache and set the defaults 
# first from the defaults.list file
#
function update (){
  update-desktop-database $DATA_DIR
  for i in $(sed '/\[.*\]/d' $U_DEF); do
    MTYPE=$(echo "$i" | awk -F= '{print $1}')
    M_FIL=$(echo "$i" | awk -F= '{print $2}')
    if grep -q "$MTYPE" $U_CACHE
    then
     sed -i "\|$MTYPE|s|$M_FIL||;s|$MTYPE=|$i;|;s|;;|;|" $U_CACHE
    else
     echo "$i" >> $U_CACHE
    fi
  done
  # If there are rows with empty mimetypes, delete them.
  sed -i '/.*=$/d' $U_CACHE
}

#
# Give the user a helping hand. 
#
function showhelp (){
echo
echo "Usage: $(basename $0) [ARGUMENT]"
echo '''
  -h, -?, --help  Show this help and exit. 

DESCRIPTION
  This script is dependent on zenity for creating its GUI. It is 
  to be used as a tool for choosing the default application or to 
  run for different type of files (mimetypes). It modifies or add 
  files in "$HOME/.local/share/applications" 

  When passed a valid filename it checks its mimetype as interpreted  
  by gnomevfs, it will show a list of already registered applications 
  able to handle the mimetype in question, the user can change default 
  application in this list. The list also contains an option to add 
  the Name and command of a program that is not registered to be able 
  to open files of the mimetype. After any changes this script will 
  run the update-desktop-database to update the users mime cache. 

  When executed without any argument, the script will list all 
  applications associated with a mimetype. When selecting an item from 
  this list, the user will be able to edit the options for the selected 
  application. The edited file will be saved in the above path and the 
  update-desktop-database is executed.

  When given an invalid argument or any of the options -h -? --help, 
  this text is shown. 
'''
}

#
# Remove tempfiles.
#
function cleanup (){
  rm -f "$UTMP.avail"
  rm -f "$UTMP.chosen"
}

#
# The .desktop file selector
#
function selfile (){
  DT_FILE=$(for i in $GDATA_DIR/*.desktop $DATA_DIR/*.desktop; do
    if grep -q "MimeType" $i 
    then
      BNME=$(basename $i | sed 's/\.desktop//;s/-usercreated//')
      if [ -e $DATA_DIR/$BNME-$EXT ] 
      then 
        i="$DATA_DIR/$BNME-$EXT"
      fi
      CMD=$(grep -m 1 "^Exec" $i | sed "s/^Exec=//")
      NME=$(grep -m 1 "^Name=" $i | sed 's/^Name=//')
      echo "$BNME---$NME---\"$CMD\""
    fi
  done | sort -u | sed 's/---/\n/g' |  zenity --list --width="550" --height="400" \
  --column="Base name" --column="Program name" --column="Program command" \
  --print-column="1" --text "Select item below. 

By selecting an item in this list and klick OK, you will get another window where 
you can edit the file that contains the options of the selected application. The 
edited file will end up in your: $DATA_DIR 

Pressing "Esc", click Cancel or use the window close (X) button will close without 
any changes in this or the following editor window. Be aware that the editor do 
have problems with the (%)percent charachter and may replace it by garbage.")
}

#
# The .desktop file editor
#
function dtfedit (){ 
  USER_DTF="$DT_FILE-$EXT"
  if [ -n "$DT_FILE" ]
  then 
    # Chose to edit users own file if exist
    if [ -e $DATA_DIR/$USER_DTF ]
    then
      TO_EDIT="$DATA_DIR/$USER_DTF"
    else
      TO_EDIT="$GDATA_DIR/$DT_FILE.desktop"
    fi
    cat "$TO_EDIT" | zenity --height="350" --width="550" --text-info --editable \
    --title "Edititng the file: $USER_DTF" > $UTMP.$USER_DTF 
    if [ -s $UTMP.$USER_DTF ]
    then 
      mv $UTMP.$USER_DTF $DATA_DIR/$USER_DTF 
    else 
      rm -f $UTMP.$USER_DTF 
      DT_FILE=""
    fi
  fi
} 

#
# Check if we have zenity installed then start this mess.
#
if which zenity >&/dev/null 
then
 checkarg 
else 
 echo "Error: zenity not found!"
fi



Index: gnome-commander.spec
===================================================================
RCS file: /cvs/extras/rpms/gnome-commander/F-8/gnome-commander.spec,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- gnome-commander.spec	29 Jul 2008 16:40:45 -0000	1.16
+++ gnome-commander.spec	12 Aug 2008 15:06:59 -0000	1.17
@@ -4,14 +4,21 @@
 # mv trunk %%{name}-%%{version}-%%{extratag}
 # tar cjf %%{name}-%%{version}-%%{extratag}.tar.bz2 %%{name}-%%{version}-%%{extratag}
 
+# Source10 is created by:
+# svn co http://svn.gnome.org/svn/gnome-commander/branches/gcmd-1-3/tools/mimeedit/
+# cp -p mimeedit/mimeedit.sh mimeedit-rev%%{mimeedit_rev}.sh
+#
+# ref: http://lists.gnu.org/archive/html/gcmd-devel/2007-11/msg00076.html
+
 %define        EXIV2_REQ             0.14
 %define        TAGLIB_REQ            1.4
 %define        LIBGSF_REQ            1.12.0
 
 %define        use_autotool          0
 %define        if_pre                0
-%define        main_release          1
+%define        main_release          4
 #%%define        extratag              svn1901_trunk
+%define        mimeedit_rev          1958
 
 %if 0%{?if_pre} > 0
 %define        use_autotool          1
@@ -30,7 +37,10 @@
 License:       GPLv2+
 URL:           http://www.nongnu.org/gcmd/
 Source0:       ftp://ftp.gnome.org/pub/GNOME/sources/%{name}/1.2/%{name}-%{version}%{?extratag:-%extratag}.tar.bz2
+Source1:       gnome-commander.sh
+Source10:      mimeedit-svn%{mimeedit_rev}.sh
 #Patch0:        gnome-commander-rev1874-hexmode-display.patch
+Patch10:       mimeedit-svn1958.diff
 BuildRoot:     %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 
 BuildRequires: desktop-file-utils
@@ -99,12 +109,38 @@
 sh autogen.sh
 %endif
 
+cp -p %SOURCE10 mimeedit.sh
+%patch10 -p0
+
 %{__sed} -i.pylib \
    -e 's|\$PY_EXEC_PREFIX/lib|%{_libdir}|' \
    configure
 
+%if 0%{?fedora} >= 10
+function replace_icon(){
+	find . -name \*.cc | xargs grep -l $1 | \
+		xargs %{__sed} -i -e "s|\"$1\"|\"$2\"|"
+}
+
+
+# Replace icon name due to gnome-icon-theme 2.23.x change
+# (many icons are removed)
+replace_icon	gnome-fs-directory	gtk-directory
+replace_icon	gnome-fs-ftp		folder-remote
+replace_icon	gnome-fs-home		user-home
+replace_icon	gnome-fs-network	gtk-network
+replace_icon	gnome-fs-smb		network-workgroup
+replace_icon	gnome-fs-ssh		folder-remote
+replace_icon	gnome-fs-web		folder-remote
+
+%endif
+
 %build
+# Install wrapper script, and move binaries to
+# %%{_libexecdir}/%%{name}
+
 %configure \
+   --bindir=%{_libexecdir}/%{name} \
    --disable-scrollkeeper \
    --enable-python
 %{__make} %{?_smp_mflags}
@@ -116,6 +152,7 @@
    DESTDIR=%{buildroot} \
    install
 
+# Desktop file
 desktop-file-install \
    --delete-original \
    --vendor '' \
@@ -123,6 +160,14 @@
    --dir %{buildroot}%{_datadir}/applications \
    %{buildroot}%{_datadir}/applications/%{name}.desktop
 
+# Install wrapper
+%{__mkdir_p} %{buildroot}%{_bindir}
+%{__install} -cpm 0755 %SOURCE1 %{buildroot}%{_bindir}/%{name}
+
+# install gnome-file-types-properties (bug 458667)
+%{__install} -cpm 0755 mimeedit.sh \
+	%{buildroot}%{_libexecdir}/%{name}/gnome-file-types-properties
+
 %{__rm} -f %{buildroot}%{_libdir}/%{name}/*.{a,la}
 %{__rm} -f %{buildroot}%{_libdir}/%{name}/*/*.{a,la}
 
@@ -149,6 +194,7 @@
 %doc doc/*.txt
 
 %{_bindir}/*
+%{_libexecdir}/%{name}/
 %{_libdir}/%{name}/
 %{_mandir}/man1/%{name}.1*
 
@@ -161,6 +207,17 @@
 %{_datadir}/pixmaps/%{name}/
 
 %changelog
+* Wed Aug 13 2008 Mamoru Tasaka <mtasaka at ioa.s.u-tokyo.ac.jp> - 1.2.7-4
+- More fix for mimeedit.sh to remove potentially unsafe tmpfile
+  creation
+
+* Tue Aug 12 2008 Mamoru Tasaka <mtasaka at ioa.s.u-tokyo.ac.jp> - 1.2.7-3
+- Install mimeedit script pulled from svn to support mime edit
+  menu (bug 458667)
+
+* Wed Jul 30 2008 Mamoru Tasaka <mtasaka at ioa.s.u-tokyo.ac.jp> - 1.2.7-2
+- F-10+: Fix icon name due to gnome-icon-theme 2.23.x change
+
 * Wed Jul 30 2008 Mamoru Tasaka <mtasaka at ioa.s.u-tokyo.ac.jp> - 1.2.7-1
 - 1.2.7
 




More information about the fedora-extras-commits mailing list