Hi

Introduce yourself to the community

Hi

Postby gnumaru » Wed Aug 04, 2010 2:35 am

Hi everyone.

I don't know exactly if I can post on the "AppImageKit developers" session, since I'm not an AppImageKit developer yet.
Anyway, here am I.

I'm doing researches about alternative methods of application management on gnu/linux since the beginning of this year. Recently, I came to know the AppImages from PortableLinuxApps.

I think I already have some knowledge about the issues concerning making portable applications for gnu/linux, that can be summarized into two points: "make the app find it's files" and "make the app access it's libraries".

I think I understand the approach klik used to have on these problems, and the approach klik2 was planning to have. However, I don't understand yet the AppRun aproach.

AppRun used to be a shell script, as can be seen here.
http://www.youtube.com/watch?v=jGdVRvhCPLs

But now, it is a compiled application. I tried to find it's source code, but I could not find a link in this forum. Is it closed source, or it's just not available yet?

The AppRun approach intrigues me because I could not imagine one simpler (simpler in theory) aproach than that of klik2 (the unionfs+fakechroot stuff), which seems to be used now by PAFL.
http://www.portools.com/

I would like to help on the development, if help is needed. If not, I would like just to know better probono's AppRun approach.

For now, I think that's all.

Auf wiedersehen für alle.
gnumaru
 
Posts: 3
Joined: Sat Jul 17, 2010 12:55 am

Re: Hi

Postby joehms22 » Wed Aug 04, 2010 5:07 pm

I know that it was going to be re-written in C, I'm sure it is not proprietary, because that would dissuade a large proportion of the community from using appimages.
joehms22
 
Posts: 9
Joined: Fri Jul 30, 2010 6:40 pm

Re: Hi

Postby gnumaru » Wed Aug 04, 2010 9:43 pm

I'm relieved i'ts not closed source, and if it's written in C, it makes me even more happy :D
No doubt that make AppRun closed source would dissuade many from using it as a solution for open-source portable applications. See Ermine, by example:
http://www.magicermine.com/
I've tried it before. I'ts cool and It works. But I never ever heard of an application distributed by these means, be it open or closed source (except for the demos on the developer's page).
gnumaru
 
Posts: 3
Joined: Sat Jul 17, 2010 12:55 am

Re: Hi

Postby probono » Thu Aug 05, 2010 11:39 pm

Welcome gnumaru.

gnumaru wrote:AppRun used to be a shell script, as can be seen here.
http://www.youtube.com/watch?v=jGdVRvhCPLs

But now, it is a compiled application. I tried to find it's source code, but I could not find a link in this forum. Is it closed source, or it's just not available yet?

Here is the bash version:

Code: Select all
#!/bin/sh
cd $(dirname "${0}")/usr
EXEC=$(grep -m 1 -r Exec= ../*.desktop | cut -d "=" -f 2 | cut -d % -f 1)
LD_LIBRARY_PATH="./lib:${LD_LIBRARY_PATH}" PATH="./bin/:./sbin/:./games/:${PATH}" exec $EXEC $@

And here is the C version:

Code: Select all
/**************************************************************************

Copyright (c) 2010 RazZziel
Copyright (c) 2005-10 Simon Peter

All Rights Reserved.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

**************************************************************************/

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <libgen.h>
#include <dirent.h>
#include <string.h>

#define die(...)                                \
    do {                                        \
        fprintf( stderr, "!! " __VA_ARGS__ );   \
        exit( 1 );                              \
    } while (0);

#define NEW_LD_LIBRARY_PATH "LD_LIBRARY_PATH=./lib:%s"
#define NEW_PATH "PATH=./bin/:./sbin/:./games/:%s"
#define LINE_SIZE 255

int filter (const struct dirent *dir)
{
    char *p = (char*) &dir->d_name;
    while (*++p);
    while (*--p != '.');

    return !strcmp(p, ".desktop");
}

int main(int argc, char *argv[])
{
    char path[LINE_SIZE];
    int ret;
    FILE *f;

    char *dir = realpath( "/proc/self/exe", NULL );
    if (!dir)
    {
        die( "Could not access /proc/self/exe\n" );
    }

    sprintf( path, "%s", dirname(dir) );

    printf( "Moving to %s ...\n", path );

    ret = chdir(path);

    if ( ret != 0 )
    {
        die( "Could not cd into %s\n", path );
    }

    struct dirent **namelist;

    ret = scandir( ".", &namelist, filter, NULL );

    if ( ret == 0 )
    {
        die( "No .desktop files found\n" );
    }
    else if ( ret == -1 )
    {
        die( "Could not scan directory %s\n", path );
    }


    /* Extract executable from .desktop file */
    printf( "Extracting executable name from '%s' ...\n",
            namelist[0]->d_name );

    f = fopen(namelist[0]->d_name, "r");

    char *line = malloc(LINE_SIZE);
    unsigned int n = LINE_SIZE;
    int found = 0;

    while (getline( &line, &n, f ) != -1)
    {
        if (!strncmp(line,"Exec=",5))
        {
            char *p = line+5;
            while (*++p && *p != ' ' &&  *p != '%'  &&  *p != '\n' );
            *p = 0;
            found = 1;
            break;
        }
    }

    fclose( f );

    if (!found)
    {
        die( "Executable not found, make sure there's a line starting with 'Exec='\n" );
    }

    /* Execution */
    char *executable = basename(line+5);
    printf( "Executing '%s' ...\n", executable );

    ret = chdir("usr");
    if ( ret != 0 )
    {
        die( "Could not cd into %s\n", "usr" );
    }

    /* Build environment */
    char *env, *new_env[2];

    env = getenv("LD_LIBRARY_PATH") ?: "";
    new_env[0] = malloc( strlen(NEW_LD_LIBRARY_PATH) + strlen(env) );
    sprintf( new_env[0], NEW_LD_LIBRARY_PATH, env );
    printf( "  using %s\n", new_env[0] );
    putenv( new_env[0] );

    env = getenv("PATH") ?: "";
    new_env[1] = malloc( strlen(NEW_PATH) + strlen(env) );
    sprintf( new_env[1], NEW_PATH, env );
    printf( "  using %s\n", new_env[1] );
    putenv( new_env[1] );

    /* Run */
    ret = execvp(executable, argv);

    if (ret == -1)
    {
        die( "Error executing '%s'\n", line+5 );
    }

    free(new_env[0]);
    free(new_env[1]);
    free(line);
    return 0;
}
If you like PortableLinuxApps and the AppImage format, you might consider a donation --> Image
probono
Site Admin
 
Posts: 429
Joined: Sun Apr 25, 2010 9:41 am


Return to Introduction

Who is online

Users browsing this forum: No registered users and 1 guest