@@ -342,36 +342,41 @@ main (int argc, char *argv[])
342342 }
343343
344344 /* Determine the architecture */
345- gchar * archfile ;
346- /* We use the next best .so that we can find to determine the architecture */
347- archfile = find_first_matching_file (source , "*.so.*" );
348- if (!archfile )
349- {
350- /* If we found no .so we try to guess the main executable - this might be a script though */
351- // char guessed_bin_path[PATH_MAX];
352- // sprintf (guessed_bin_path, "%s/usr/bin/%s", source, g_strsplit_set(get_desktop_entry(kf, "Exec"), " ", -1)[0]);
353- // archfile = guessed_bin_path;
354- archfile = "/proc/self/exe" ;
355- }
356- if (verbose )
357- fprintf (stderr ,"File used for determining architecture: %s\n" , archfile );
345+ gchar * arch = getenv ("ARCH" );
358346 FILE * fp ;
359- char line [PATH_MAX ];
360- char command [PATH_MAX ];
361- sprintf (command , "/usr/bin/file -L -N -b %s" , archfile );
362- fp = popen (command , "r" );
363- if (fp == NULL )
364- die ("Failed to run file command" );
365- fgets (line , sizeof (line )- 1 , fp );
366- gchar * arch = g_strstrip (g_strsplit_set (line , "," , -1 )[1 ]);
367- replacestr (arch , "-" , "_" );
368- fprintf (stderr ,"Arch: %s\n" , arch + 1 );
369- pclose (fp );
370-
371- if (!arch )
372- {
373- printf ("The architecture could not be determined, assuming 'all'\n" );
374- arch = "all" ;
347+ /* If no $ARCH variable is set check a file */
348+ if (!arch ) {
349+ gchar * archfile = NULL ;
350+ /* We use the next best .so that we can find to determine the architecture */
351+ archfile = find_first_matching_file (source , "*.so.*" );
352+ if (!archfile )
353+ {
354+ /* If we found no .so we try to guess the main executable - this might be a script though */
355+ // char guessed_bin_path[PATH_MAX];
356+ // sprintf (guessed_bin_path, "%s/usr/bin/%s", source, g_strsplit_set(get_desktop_entry(kf, "Exec"), " ", -1)[0]);
357+ // archfile = guessed_bin_path;
358+ archfile = "/proc/self/exe" ;
359+ }
360+ if (verbose )
361+ fprintf (stderr ,"File used for determining architecture: %s\n" , archfile );
362+
363+ char line [PATH_MAX ];
364+ char command [PATH_MAX ];
365+ sprintf (command , "/usr/bin/file -L -N -b %s" , archfile );
366+ fp = popen (command , "r" );
367+ if (fp == NULL )
368+ die ("Failed to run file command" );
369+ fgets (line , sizeof (line )- 1 , fp );
370+ arch = g_strstrip (g_strsplit_set (line , "," , -1 )[1 ]);
371+ replacestr (arch , "-" , "_" );
372+ fprintf (stderr ,"Arch: %s\n" , arch + 1 );
373+ pclose (fp );
374+
375+ if (!arch )
376+ {
377+ printf ("The architecture could not be determined, assuming 'all'\n" );
378+ arch = "all" ;
379+ }
375380 }
376381
377382 char app_name_for_filename [PATH_MAX ];
0 commit comments