Page 3 of 5 FirstFirst 12345 LastLast
Results 21 to 30 of 43

Thread: a cmg in a .desktop file(alpha release)!

  1. #21
    Senior Member registered user
    Join Date
    Feb 2003
    Location
    Germany
    Posts
    1,159
    You can do the same but still use cramfs/zisofs - just need to figure out the offset= paramenter of loop-mount

    For cramfs, you can get the offset with
    Code:
    grep Compressed filename -ab | cut -d: -f1
    For zisofs, you can get the offset with
    Code:
    grep CDROM filename -ab | cut -d: -f1
    For both, you can get the offset with
    Code:
    grep -e '\ \ \ CDROM\ \ \ \ \|Compressed\ ROMFS' /home/knoppix/Desktop/xvier.cmg -ab | cut -d: -f1
    Greetings,
    probono

  2. #22
    Senior Member registered user
    Join Date
    Feb 2003
    Location
    Germany
    Posts
    1,159
    Ok, here is a new .zAppRun that can handle cmg files embedded into desktop files:

    Code:
    #!/bin/sh
    
    #
    # by probono at myrealbox dot com
    # GPL
    #
    # This script mounts and executes CMG files
    #
    
    #
    # This version does NOT need fstab entries
    # but it DOES need sudo rights for mounting and unmounting CMG files
    # (these are available in Knoppix/Kanotix Live CDs by default)
    #
    
    # rewrite cmdline to use absolute instead of relative paths, thanks bfree
    NEWCMD=$(perl -e '$newcmd=shift(@ARGV);foreach $arg (@ARGV){ @part=split(/\=/,$arg); foreach $part (@part){ (-e "$ENV{PWD}/$part") && ($part="$ENV{PWD}/$part");}$newcmd.=" ".join ("=",@part);} print "$newcmd";' $@)
    set -- $NEWCMD
    
    # if no arguments are passed and 
    # there is a .cmg in the same directory as this
    # script, then use the .cmg
    DIRNAME=$(dirname $0)
    if [ -z $1 ]
    then
      CMG=$(find "$DIRNAME" -iname '*.cmg'|head -n 1) || exit 1
      echo "Found $CMG, using it"
    else
      CMG="$1"
      shift
    fi
    
    # make path to CMG absolute, thanks bfree
    case $CMG in
    /*) ;; 
    *) CMG=$(pwd)/$CMG ;; 
    esac
    
    #
    # Find out the offset where cramgfs/zisofs data begins
    # (this allows embedding the cmg into a .desktop file)
    #
    
      OFFSET=$(grep -e '\ \ \ CDROM\ \ \ \ \|Compressed\ ROMFS' $CMG -ab | cut -d: -f1)
    echo "CMG detected, Offset = $OFFSET"
    
    if [ -n "$OFFSET" ]
    then
      NUMBERS="7 6 5 4 3 2 1"
      for NUMBER in $NUMBERS
        do
        [ -e "/mnt/app/$NUMBER" ] || MNTNUM=$NUMBER
      done
    
      MOUNT=/mnt/app/$MNTNUM 
    
      mkdir -p $MOUNT || exit 1
    
      sudo mount $CMG $MOUNT -o offset=$OFFSET -t cramfs,iso9660 || echo "Unable to mount $MOUNT" >&2
    else
      # NOTE: exit now cause our cmg isn't mounted
      echo "$CMG does not appear to be a valid CMG file" >&2
      exit 1
    fi
        
    #
    # execute the wrapper
    # the wrapper should take care to keep running until its app closes
    #
      
    # we need this so that on the cmdline, pipes etc work
      CMDLINE="yes"
      ( tty | grep ^/dev/tty >/dev/null ) && CMDLINE=""
      ( tty | grep ^/dev/pts >/dev/null ) && CMDLINE=""
      if [ "$CMDLINE" = "yes" ] ; then
        RESULT=$($MOUNT/wrapper $@ 2>&1) || echo "$RESULT" >&2 
      else
        $MOUNT/wrapper $@
      fi
    
    # kill all child processes
      kill $(pidof -x -o %PPID) 2>/dev/null
      
    # unmount and clean up
      sudo umount $MOUNT
      rm -rf $MOUNT/
    Note that this requires sudo rights for mounting and unmounting. Does anyone know how a corresponding entry to the sudoers file has to look?

  3. #23
    Junior Member registered user
    Join Date
    Apr 2005
    Posts
    29
    yes i got the same problem,we need sudo but using sudo is like using root and we need to make more adjusments as root to make klik work.
    i think we need to find a better way not using sudo.

  4. #24
    Junior Member registered user
    Join Date
    Apr 2005
    Posts
    29
    So when you will put it on the site(i mean instead of cmg or with cmgs and .desktop as option)?

  5. #25
    Senior Member registered user
    Join Date
    Feb 2003
    Location
    Germany
    Posts
    1,159
    When we have found a way w/o sudo...

    Greetings,
    probono

  6. #26
    Junior Member registered user
    Join Date
    Apr 2005
    Posts
    29
    so you agree with me? ok!
    maybe without a cmg and with fast uncomppresing (uncomppresd tar or something)(just getting rid of mount).

  7. #27
    Junior Member registered user
    Join Date
    Apr 2005
    Posts
    29
    or using FUSE?
    it don`t need suid.

  8. #28
    Senior Member registered user
    Join Date
    Feb 2003
    Location
    Germany
    Posts
    1,159
    Fuse sounds interesting, can you tell me how to do it?

    Greetings,
    probono

  9. #29
    Junior Member registered user
    Join Date
    Apr 2005
    Posts
    29
    don`t know i am looking for it but i think it needs a kernel module look at this web page:
    http://fuse.sourceforge.net/

  10. #30
    Senior Member registered user
    Join Date
    Aug 2003
    Location
    Dublin, Ireland
    Posts
    164

    A new solution

    Ok, I have an alternative approach which eliminates the need to sudo ... but it doesn't overcome the problem of viewing the properties of the .desktop corrupting it. I've simplified the approach right down on the way, and basically use a fixed offset (1024 bytes) which is then set in fstab (so first step, fstabs need to be updated). e.g.
    Code:
    /mnt/app/1/image /mnt/app/1 cramfs,iso9660 offset=1024,user,noauto,ro,loop,exec 0 0
    Next you need to modify ~/.zAppRun, this is the patch to Kanotix's latest version ...
    Code:
    --- /home/knoppix/.zAppRun.safe 2005-06-07 22:01:48.630717768 +0100
    +++ /home/knoppix/.zAppRun      2005-06-07 22:58:12.242330616 +0100
    @@ -4,6 +4,8 @@
     # thanks to bfree
     # GPL
    
    +OFFSET=1024
    +
     # ok we need dialogs now
     if [ -z "$DIALOG" ] ; then
     # Determine which dialog to use in which situation:
    @@ -111,9 +113,11 @@
     esac
    
     # determine which filesystem is used as .cmg
    -file $CMG | grep ": data" >/dev/null && FS=squashfs # who knows a better way to recognize it?
    -file $CMG | grep "Compressed ROM" >/dev/null && FS=cramfs
    -file $CMG | grep "ISO 9660" >/dev/null && FS=iso9660
    +# BUG :: FIX :: TODO
    +# Add some math so these don't have to be handupdated it offset changes
    +head -c 1028 $CMG | tail -c 4| grep "hsqs" >/dev/null && FS=squashfs
    +head -c 1056 $CMG | tail -c 16 | grep "Compressed ROMFS" >/dev/null && FS=cramfs
    +head -c 33798 $CMG | tail -n 5 | grep "CD001" >/dev/null && FS=iso9660
    
     if [ -n "$FS" ]
     then
    @@ -154,7 +158,7 @@
         fi
         SUCMD="$SUCMD echo \"#Added by klik (klik.atekon.de)\" >> /etc/fstab  "
         for i in 1 2 3 4 5 6 7; do
    -      SUCMD="$SUCMD ; echo \"/mnt/app/$i/image /mnt/app/$i cramfs,iso9660 user,noauto,ro,loop,exec 0 0\" >> /etc/fstab";
    +      SUCMD="$SUCMD ; echo \"/mnt/app/$i/image /mnt/app/$i cramfs,iso9660 offset=$OFFSET,user,noauto,ro,loop,exec 0 0\" >> /etc/fstab";
         done
       fi
    
    @@ -192,13 +196,13 @@
     As root, please make /mnt/app writeable and add the following lines:
    
     #######################################################################
    -/mnt/app/1/image /mnt/app/1 cramfs,iso9660 user,noauto,ro,loop,exec 0 0
    -/mnt/app/2/image /mnt/app/2 cramfs,iso9660 user,noauto,ro,loop,exec 0 0
    -/mnt/app/3/image /mnt/app/3 cramfs,iso9660 user,noauto,ro,loop,exec 0 0
    -/mnt/app/4/image /mnt/app/4 cramfs,iso9660 user,noauto,ro,loop,exec 0 0
    -/mnt/app/5/image /mnt/app/5 cramfs,iso9660 user,noauto,ro,loop,exec 0 0
    -/mnt/app/6/image /mnt/app/6 cramfs,iso9660 user,noauto,ro,loop,exec 0 0
    -/mnt/app/7/image /mnt/app/7 cramfs,iso960 user,noauto,ro,loop,exec 0 0
    +/mnt/app/1/image /mnt/app/1 cramfs,iso9660 offset=$OFFSET,user,noauto,ro,loop,exec 0 0
    +/mnt/app/2/image /mnt/app/2 cramfs,iso9660 offset=$OFFSET,user,noauto,ro,loop,exec 0 0
    +/mnt/app/3/image /mnt/app/3 cramfs,iso9660 offset=$OFFSET,user,noauto,ro,loop,exec 0 0
    +/mnt/app/4/image /mnt/app/4 cramfs,iso9660 offset=$OFFSET,user,noauto,ro,loop,exec 0 0
    +/mnt/app/5/image /mnt/app/5 cramfs,iso9660 offset=$OFFSET,user,noauto,ro,loop,exec 0 0
    +/mnt/app/6/image /mnt/app/6 cramfs,iso9660 offset=$OFFSET,user,noauto,ro,loop,exec 0 0
    +/mnt/app/7/image /mnt/app/7 cramfs,iso960 offset=$OFFSET,user,noauto,ro,loop,exec 0 0
     #######################################################################"
         exit 1
       fi
    Right, now all you have to do is get yourself the right sort of cmg/.desktop hybrid. What I did was created a basic .desktop called xvier.desktop (and I put it on the Desktop) to start with which looks like:
    Code:
    [Desktop Entry]
    Terminal=false
    Icon=package_games
    Type=Application
    Exec=~/.zAppRun %k
    Then I got the xvier.cmg from klik as normal. Now I used the following script (named pad.pl also on Desktop) as:
    Code:
    ./pad.pl xvier.desktop xvier.cmg
    The script being (I shouldn't let anyone see this as I'm sure it can be rewritten in one line of sed/awk/???, but it's just what I did):
    Code:
    #!/usr/bin/perl
    # takes the desktop file as the first argument
    $deskname=shift(@ARGV);
    # and the cmg as the second
    $cmgname=shift(@ARGV);
    # opens the desktop file to read it in
    open(IN,"$deskname")||die "failed to open $deskname for reading : $!";
    # read in the desktop file line by line
    while(<IN>){
    # count the length of the file
            $length+=length($_);
    # check if this line is a single newline
            if (/^\n$/){
                    $blank=1;
            } else {
                    $blank=0;
            }
    }
    close(IN);
    # start what we will append to the desktop with a newline
    # if it didn't end with one
    if ($blank=0){
                    $out.="\n";
                    $length++;
    }
    # pad what we will append to the file with '#'
    for($i=$length;$i<=1021;$i++){
            $out.="#";
    }
    # finish the padding with 2 newlines
    $out.="\n\n";
    # open the desktop file for appending
    open(OUT,">>$deskname")||die "failed to open $deskname for writing : $!";
    print OUT $out;
    close(OUT);
    # append the cmg to the desktop
    system("cat $cmgname >> $deskname");
    End result you know have a xvier.desktop on your desktop which you can click on to run. You still need to have the ~/.zAppRun externally, but it can be wrapped back into a dummy shell script and then have the zAppRun as part of the .desktop also. If it was to be done this way the offset would need to be a lot higher (I set it to 1024 on the basis their may be language dependent strings we might want to add in there)! This is just the minimal changes approach for now.

    I told you I'd write long posts Congrats to all still with me!

    The only problem is ... viewing the properties and clicking ok corrupts the file, choosing cancel doesn't. I don't know if there is a way around this but I'm not too hopeful, perhaps the purveyors of the .desktop spec can be confinced to accomodate us somehow? Maybe there's something there already (going to look now).

    In the meantime consider this a barely tested proof of concept.

Page 3 of 5 FirstFirst 12345 LastLast

Similar Threads

  1. Desktop File Folders don't work
    By Keithj in forum Hdd Install / Debian / Apt
    Replies: 10
    Last Post: 09-10-2005, 05:55 AM
  2. How to have the remote smb file share on desktop
    By vi2004 in forum General Support
    Replies: 0
    Last Post: 02-13-2004, 11:04 AM
  3. Configuration file -- corrupt desktop, unusable network.
    By talyrath in forum General Support
    Replies: 0
    Last Post: 01-26-2004, 01:57 AM
  4. Help with Alpha Blending
    By Aslyum in forum General Support
    Replies: 1
    Last Post: 11-20-2003, 12:39 PM
  5. [SCRIPT] Install RealONE Player (alpha)
    By probono in forum Ideas
    Replies: 1
    Last Post: 04-23-2003, 01:19 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


ASUS H110M-R Motherboard Intel 6th/7th Gen LGA1151 DDR4 Micro-ATX i/o shield picture

ASUS H110M-R Motherboard Intel 6th/7th Gen LGA1151 DDR4 Micro-ATX i/o shield

$42.00



MSI B450M-A PRO MAX II AM4 AMD B450 SATA 6Gb/s Micro ATX Motherboard picture

MSI B450M-A PRO MAX II AM4 AMD B450 SATA 6Gb/s Micro ATX Motherboard

$69.99



ASROCK Micro ATX  Motherboard B250M PRO4 Chipset Intel 250, DDR4, LGA 1151 picture

ASROCK Micro ATX Motherboard B250M PRO4 Chipset Intel 250, DDR4, LGA 1151

$64.99



Asrock Z390 Phantom Gaming 4S/AC Wifi 8th/9th Gen Intel 1151 Motherboard Bulk picture

Asrock Z390 Phantom Gaming 4S/AC Wifi 8th/9th Gen Intel 1151 Motherboard Bulk

$99.00



MSI MAG Z590 TOMAHAWK WIFI Intel LGA1200 PCIE 4.0 WiFi 6E ATX Motherboard picture

MSI MAG Z590 TOMAHAWK WIFI Intel LGA1200 PCIE 4.0 WiFi 6E ATX Motherboard

$119.99



Gigabyte Ultra Durable B550 GAMING X V2 Desktop Motherboard picture

Gigabyte Ultra Durable B550 GAMING X V2 Desktop Motherboard

$99.99



ASUS H110M-C LGA 1151 DDR4 SDRAM MSIP-REM-MSQ-H110M-C Desktop Motherboard picture

ASUS H110M-C LGA 1151 DDR4 SDRAM MSIP-REM-MSQ-H110M-C Desktop Motherboard

$43.95



MSI A520M-A PRO AM4 AMD A520 USB3.2 Gen1 Micro-ATX Motherboard picture

MSI A520M-A PRO AM4 AMD A520 USB3.2 Gen1 Micro-ATX Motherboard

$59.99



Asus X99-A II Foxconn LGA2011 ATX Motherboard - Motherboard Only picture

Asus X99-A II Foxconn LGA2011 ATX Motherboard - Motherboard Only

$112.50



GIGABYTE MB10-Datto Motherboard Xeon D-1521- SR2DF 2.40 GHz- Open Box picture

GIGABYTE MB10-Datto Motherboard Xeon D-1521- SR2DF 2.40 GHz- Open Box

$121.50