From DONOTREPLY at icculus.org Fri Feb 1 23:46:01 2008 From: DONOTREPLY at icculus.org (DONOTREPLY at icculus.org) Date: 1 Feb 2008 23:46:01 -0500 Subject: r481 - in trunk: . bzip2-1.0.4 examples/duke3d examples/duke3d/data examples/duke3d/scripts examples/ut3-dedicated examples/ut3-dedicated/scripts libfetch lua-5.1.1 lua-5.1.1/doc lua-5.1.1/etc lua-5.1.1/src lua-5.1.1/test scripts zlib-1.2.3 Message-ID: <20080202044601.2575.qmail@icculus.org> Author: icculus Date: 2008-02-01 23:46:01 -0500 (Fri, 01 Feb 2008) New Revision: 481 Modified: trunk/CMakeLists.txt trunk/LICENSE.txt trunk/archive_tar.c trunk/archive_zip.c trunk/buildver.c trunk/bzip2-1.0.4/blocksort.c trunk/bzip2-1.0.4/bzip.css trunk/bzip2-1.0.4/bzip2.c trunk/bzip2-1.0.4/bzip2.txt trunk/bzip2-1.0.4/bzip2recover.c trunk/bzip2-1.0.4/bzlib.c trunk/bzip2-1.0.4/bzlib.h trunk/bzip2-1.0.4/bzlib_private.h trunk/bzip2-1.0.4/compress.c trunk/bzip2-1.0.4/crctable.c trunk/bzip2-1.0.4/decompress.c trunk/bzip2-1.0.4/dlltest.c trunk/bzip2-1.0.4/entities.xml trunk/bzip2-1.0.4/huffman.c trunk/bzip2-1.0.4/manual.html trunk/bzip2-1.0.4/manual.xml trunk/bzip2-1.0.4/mk251.c trunk/bzip2-1.0.4/randtable.c trunk/bzip2-1.0.4/spewG.c trunk/bzip2-1.0.4/unzcrash.c trunk/bzip2-1.0.4/xmlproc.sh trunk/checksum_crc32.c trunk/checksum_md5.c trunk/checksum_sha1.c trunk/docs.txt trunk/examples/duke3d/data/duke3d_readme.txt trunk/examples/duke3d/data/gpl.txt trunk/examples/duke3d/data/mojosetup_readme.txt trunk/examples/duke3d/make.sh trunk/examples/duke3d/scripts/app_localization.lua trunk/examples/duke3d/scripts/config.lua trunk/examples/ut3-dedicated/make.sh trunk/examples/ut3-dedicated/scripts/config.lua trunk/fileio.c trunk/fileio.h trunk/gui.c trunk/gui.h trunk/gui_gtkplus2.c trunk/gui_macosx.c trunk/gui_ncurses.c trunk/gui_stdio.c trunk/gui_www.c trunk/libfetch/README.txt trunk/libfetch/common.c trunk/libfetch/common.h trunk/libfetch/fetch.c trunk/libfetch/fetch.h trunk/libfetch/ftp.c trunk/libfetch/ftperr.h trunk/libfetch/http.c trunk/libfetch/httperr.h trunk/libfetch/mojosetup_libfetch.h trunk/libfetch/regen_error_headers.sh trunk/lua-5.1.1/COPYRIGHT trunk/lua-5.1.1/HISTORY trunk/lua-5.1.1/INSTALL trunk/lua-5.1.1/Makefile trunk/lua-5.1.1/README trunk/lua-5.1.1/doc/contents.html trunk/lua-5.1.1/doc/lua.css trunk/lua-5.1.1/doc/lua.html trunk/lua-5.1.1/doc/luac.html trunk/lua-5.1.1/doc/manual.html trunk/lua-5.1.1/doc/readme.html trunk/lua-5.1.1/etc/all.c trunk/lua-5.1.1/etc/lua.hpp trunk/lua-5.1.1/etc/luavs.bat trunk/lua-5.1.1/etc/min.c trunk/lua-5.1.1/etc/noparser.c trunk/lua-5.1.1/etc/strict.lua trunk/lua-5.1.1/src/lapi.c trunk/lua-5.1.1/src/lapi.h trunk/lua-5.1.1/src/lauxlib.c trunk/lua-5.1.1/src/lauxlib.h trunk/lua-5.1.1/src/lbaselib.c trunk/lua-5.1.1/src/lcode.c trunk/lua-5.1.1/src/lcode.h trunk/lua-5.1.1/src/ldblib.c trunk/lua-5.1.1/src/ldebug.c trunk/lua-5.1.1/src/ldebug.h trunk/lua-5.1.1/src/ldo.c trunk/lua-5.1.1/src/ldo.h trunk/lua-5.1.1/src/ldump.c trunk/lua-5.1.1/src/lfunc.c trunk/lua-5.1.1/src/lfunc.h trunk/lua-5.1.1/src/lgc.c trunk/lua-5.1.1/src/lgc.h trunk/lua-5.1.1/src/linit.c trunk/lua-5.1.1/src/liolib.c trunk/lua-5.1.1/src/llex.c trunk/lua-5.1.1/src/llex.h trunk/lua-5.1.1/src/llimits.h trunk/lua-5.1.1/src/lmathlib.c trunk/lua-5.1.1/src/lmem.c trunk/lua-5.1.1/src/lmem.h trunk/lua-5.1.1/src/loadlib.c trunk/lua-5.1.1/src/lobject.c trunk/lua-5.1.1/src/lobject.h trunk/lua-5.1.1/src/lopcodes.c trunk/lua-5.1.1/src/lopcodes.h trunk/lua-5.1.1/src/loslib.c trunk/lua-5.1.1/src/lparser.c trunk/lua-5.1.1/src/lparser.h trunk/lua-5.1.1/src/lstate.c trunk/lua-5.1.1/src/lstate.h trunk/lua-5.1.1/src/lstring.c trunk/lua-5.1.1/src/lstring.h trunk/lua-5.1.1/src/lstrlib.c trunk/lua-5.1.1/src/ltable.c trunk/lua-5.1.1/src/ltable.h trunk/lua-5.1.1/src/ltablib.c trunk/lua-5.1.1/src/ltm.c trunk/lua-5.1.1/src/ltm.h trunk/lua-5.1.1/src/lua.c trunk/lua-5.1.1/src/lua.h trunk/lua-5.1.1/src/luac.c trunk/lua-5.1.1/src/luaconf.h trunk/lua-5.1.1/src/lualib.h trunk/lua-5.1.1/src/lundump.c trunk/lua-5.1.1/src/lundump.h trunk/lua-5.1.1/src/lvm.c trunk/lua-5.1.1/src/lvm.h trunk/lua-5.1.1/src/lzio.c trunk/lua-5.1.1/src/lzio.h trunk/lua-5.1.1/src/print.c trunk/lua-5.1.1/test/bisect.lua trunk/lua-5.1.1/test/cf.lua trunk/lua-5.1.1/test/echo.lua trunk/lua-5.1.1/test/env.lua trunk/lua-5.1.1/test/factorial.lua trunk/lua-5.1.1/test/fib.lua trunk/lua-5.1.1/test/fibfor.lua trunk/lua-5.1.1/test/globals.lua trunk/lua-5.1.1/test/hello.lua trunk/lua-5.1.1/test/life.lua trunk/lua-5.1.1/test/luac.lua trunk/lua-5.1.1/test/printf.lua trunk/lua-5.1.1/test/readonly.lua trunk/lua-5.1.1/test/sieve.lua trunk/lua-5.1.1/test/sort.lua trunk/lua-5.1.1/test/table.lua trunk/lua-5.1.1/test/trace-calls.lua trunk/lua-5.1.1/test/trace-globals.lua trunk/lua-5.1.1/test/xd.lua trunk/lua_glue.c trunk/lua_glue.h trunk/mojosetup.c trunk/platform.h trunk/platform_beos.cpp trunk/platform_unix.c trunk/platform_windows.c trunk/scripts/app_localization.lua trunk/scripts/config.lua trunk/scripts/localization.lua trunk/scripts/mojosetup_init.lua trunk/scripts/mojosetup_mainline.lua trunk/stb_image.c trunk/universal.h trunk/zlib-1.2.3/adler32.c trunk/zlib-1.2.3/compress.c trunk/zlib-1.2.3/crc32.c trunk/zlib-1.2.3/crc32.h trunk/zlib-1.2.3/deflate.c trunk/zlib-1.2.3/deflate.h trunk/zlib-1.2.3/gzio.c trunk/zlib-1.2.3/infback.c trunk/zlib-1.2.3/inffast.c trunk/zlib-1.2.3/inffast.h trunk/zlib-1.2.3/inffixed.h trunk/zlib-1.2.3/inflate.c trunk/zlib-1.2.3/inflate.h trunk/zlib-1.2.3/inftrees.c trunk/zlib-1.2.3/inftrees.h trunk/zlib-1.2.3/trees.c trunk/zlib-1.2.3/trees.h trunk/zlib-1.2.3/uncompr.c trunk/zlib-1.2.3/zconf.h trunk/zlib-1.2.3/zlib.h trunk/zlib-1.2.3/zutil.c trunk/zlib-1.2.3/zutil.h Log: Flagged just about everything as svn:eol-style=native...I hope I don't regret this... Property changes on: trunk/CMakeLists.txt ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/LICENSE.txt ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/archive_tar.c ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/archive_zip.c ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/buildver.c ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/bzip2-1.0.4/blocksort.c ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/bzip2-1.0.4/bzip.css ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/bzip2-1.0.4/bzip2.c ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/bzip2-1.0.4/bzip2.txt ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/bzip2-1.0.4/bzip2recover.c ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/bzip2-1.0.4/bzlib.c ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/bzip2-1.0.4/bzlib.h ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/bzip2-1.0.4/bzlib_private.h ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/bzip2-1.0.4/compress.c ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/bzip2-1.0.4/crctable.c ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/bzip2-1.0.4/decompress.c ___________________________________________________________________ Name: svn:eol-style + native Modified: trunk/bzip2-1.0.4/dlltest.c =================================================================== --- trunk/bzip2-1.0.4/dlltest.c 2008-01-26 04:36:39 UTC (rev 480) +++ trunk/bzip2-1.0.4/dlltest.c 2008-02-02 04:46:01 UTC (rev 481) @@ -1,175 +1,175 @@ -/* - minibz2 - libbz2.dll test program. - by Yoshioka Tsuneo (tsuneo at rr.iij4u.or.jp) - This file is Public Domain. Welcome any email to me. - - usage: minibz2 [-d] [-{1,2,..9}] [[srcfilename] destfilename] -*/ - -#define BZ_IMPORT -#include -#include -#include "bzlib.h" -#ifdef _WIN32 -#include -#endif - - -#ifdef _WIN32 - -#define BZ2_LIBNAME "libbz2-1.0.2.DLL" - -#include -static int BZ2DLLLoaded = 0; -static HINSTANCE BZ2DLLhLib; -int BZ2DLLLoadLibrary(void) -{ - HINSTANCE hLib; - - if(BZ2DLLLoaded==1){return 0;} - hLib=LoadLibrary(BZ2_LIBNAME); - if(hLib == NULL){ - fprintf(stderr,"Can't load %s\n",BZ2_LIBNAME); - return -1; - } - BZ2_bzlibVersion=GetProcAddress(hLib,"BZ2_bzlibVersion"); - BZ2_bzopen=GetProcAddress(hLib,"BZ2_bzopen"); - BZ2_bzdopen=GetProcAddress(hLib,"BZ2_bzdopen"); - BZ2_bzread=GetProcAddress(hLib,"BZ2_bzread"); - BZ2_bzwrite=GetProcAddress(hLib,"BZ2_bzwrite"); - BZ2_bzflush=GetProcAddress(hLib,"BZ2_bzflush"); - BZ2_bzclose=GetProcAddress(hLib,"BZ2_bzclose"); - BZ2_bzerror=GetProcAddress(hLib,"BZ2_bzerror"); - - if (!BZ2_bzlibVersion || !BZ2_bzopen || !BZ2_bzdopen - || !BZ2_bzread || !BZ2_bzwrite || !BZ2_bzflush - || !BZ2_bzclose || !BZ2_bzerror) { - fprintf(stderr,"GetProcAddress failed.\n"); - return -1; - } - BZ2DLLLoaded=1; - BZ2DLLhLib=hLib; - return 0; - -} -int BZ2DLLFreeLibrary(void) -{ - if(BZ2DLLLoaded==0){return 0;} - FreeLibrary(BZ2DLLhLib); - BZ2DLLLoaded=0; -} -#endif /* WIN32 */ - -void usage(void) -{ - puts("usage: minibz2 [-d] [-{1,2,..9}] [[srcfilename] destfilename]"); -} - -int main(int argc,char *argv[]) -{ - int decompress = 0; - int level = 9; - char *fn_r = NULL; - char *fn_w = NULL; - -#ifdef _WIN32 - if(BZ2DLLLoadLibrary()<0){ - fprintf(stderr,"Loading of %s failed. Giving up.\n", BZ2_LIBNAME); - exit(1); - } - printf("Loading of %s succeeded. Library version is %s.\n", - BZ2_LIBNAME, BZ2_bzlibVersion() ); -#endif - while(++argv,--argc){ - if(**argv =='-' || **argv=='/'){ - char *p; - - for(p=*argv+1;*p;p++){ - if(*p=='d'){ - decompress = 1; - }else if('1'<=*p && *p<='9'){ - level = *p - '0'; - }else{ - usage(); - exit(1); - } - } - }else{ - break; - } - } - if(argc>=1){ - fn_r = *argv; - argc--;argv++; - }else{ - fn_r = NULL; - } - if(argc>=1){ - fn_w = *argv; - argc--;argv++; - }else{ - fn_w = NULL; - } - { - int len; - char buff[0x1000]; - char mode[10]; - - if(decompress){ - BZFILE *BZ2fp_r = NULL; - FILE *fp_w = NULL; - - if(fn_w){ - if((fp_w = fopen(fn_w,"wb"))==NULL){ - printf("can't open [%s]\n",fn_w); - perror("reason:"); - exit(1); - } - }else{ - fp_w = stdout; - } - if((fn_r == NULL && (BZ2fp_r = BZ2_bzdopen(fileno(stdin),"rb"))==NULL) - || (fn_r != NULL && (BZ2fp_r = BZ2_bzopen(fn_r,"rb"))==NULL)){ - printf("can't bz2openstream\n"); - exit(1); - } - while((len=BZ2_bzread(BZ2fp_r,buff,0x1000))>0){ - fwrite(buff,1,len,fp_w); - } - BZ2_bzclose(BZ2fp_r); - if(fp_w != stdout) fclose(fp_w); - }else{ - BZFILE *BZ2fp_w = NULL; - FILE *fp_r = NULL; - - if(fn_r){ - if((fp_r = fopen(fn_r,"rb"))==NULL){ - printf("can't open [%s]\n",fn_r); - perror("reason:"); - exit(1); - } - }else{ - fp_r = stdin; - } - mode[0]='w'; - mode[1] = '0' + level; - mode[2] = '\0'; - - if((fn_w == NULL && (BZ2fp_w = BZ2_bzdopen(fileno(stdout),mode))==NULL) - || (fn_w !=NULL && (BZ2fp_w = BZ2_bzopen(fn_w,mode))==NULL)){ - printf("can't bz2openstream\n"); - exit(1); - } - while((len=fread(buff,1,0x1000,fp_r))>0){ - BZ2_bzwrite(BZ2fp_w,buff,len); - } - BZ2_bzclose(BZ2fp_w); - if(fp_r!=stdin)fclose(fp_r); - } - } -#ifdef _WIN32 - BZ2DLLFreeLibrary(); -#endif - return 0; -} +/* + minibz2 + libbz2.dll test program. + by Yoshioka Tsuneo (tsuneo at rr.iij4u.or.jp) + This file is Public Domain. Welcome any email to me. + + usage: minibz2 [-d] [-{1,2,..9}] [[srcfilename] destfilename] +*/ + +#define BZ_IMPORT +#include +#include +#include "bzlib.h" +#ifdef _WIN32 +#include +#endif + + +#ifdef _WIN32 + +#define BZ2_LIBNAME "libbz2-1.0.2.DLL" + +#include +static int BZ2DLLLoaded = 0; +static HINSTANCE BZ2DLLhLib; +int BZ2DLLLoadLibrary(void) +{ + HINSTANCE hLib; + + if(BZ2DLLLoaded==1){return 0;} + hLib=LoadLibrary(BZ2_LIBNAME); + if(hLib == NULL){ + fprintf(stderr,"Can't load %s\n",BZ2_LIBNAME); + return -1; + } + BZ2_bzlibVersion=GetProcAddress(hLib,"BZ2_bzlibVersion"); + BZ2_bzopen=GetProcAddress(hLib,"BZ2_bzopen"); + BZ2_bzdopen=GetProcAddress(hLib,"BZ2_bzdopen"); + BZ2_bzread=GetProcAddress(hLib,"BZ2_bzread"); + BZ2_bzwrite=GetProcAddress(hLib,"BZ2_bzwrite"); + BZ2_bzflush=GetProcAddress(hLib,"BZ2_bzflush"); + BZ2_bzclose=GetProcAddress(hLib,"BZ2_bzclose"); + BZ2_bzerror=GetProcAddress(hLib,"BZ2_bzerror"); + + if (!BZ2_bzlibVersion || !BZ2_bzopen || !BZ2_bzdopen + || !BZ2_bzread || !BZ2_bzwrite || !BZ2_bzflush + || !BZ2_bzclose || !BZ2_bzerror) { + fprintf(stderr,"GetProcAddress failed.\n"); + return -1; + } + BZ2DLLLoaded=1; + BZ2DLLhLib=hLib; + return 0; + +} +int BZ2DLLFreeLibrary(void) +{ + if(BZ2DLLLoaded==0){return 0;} + FreeLibrary(BZ2DLLhLib); + BZ2DLLLoaded=0; +} +#endif /* WIN32 */ + +void usage(void) +{ + puts("usage: minibz2 [-d] [-{1,2,..9}] [[srcfilename] destfilename]"); +} + +int main(int argc,char *argv[]) +{ + int decompress = 0; + int level = 9; + char *fn_r = NULL; + char *fn_w = NULL; + +#ifdef _WIN32 + if(BZ2DLLLoadLibrary()<0){ + fprintf(stderr,"Loading of %s failed. Giving up.\n", BZ2_LIBNAME); + exit(1); + } + printf("Loading of %s succeeded. Library version is %s.\n", + BZ2_LIBNAME, BZ2_bzlibVersion() ); +#endif + while(++argv,--argc){ + if(**argv =='-' || **argv=='/'){ + char *p; + + for(p=*argv+1;*p;p++){ + if(*p=='d'){ + decompress = 1; + }else if('1'<=*p && *p<='9'){ + level = *p - '0'; + }else{ + usage(); + exit(1); + } + } + }else{ + break; + } + } + if(argc>=1){ + fn_r = *argv; + argc--;argv++; + }else{ + fn_r = NULL; + } + if(argc>=1){ + fn_w = *argv; + argc--;argv++; + }else{ + fn_w = NULL; + } + { + int len; + char buff[0x1000]; + char mode[10]; + + if(decompress){ + BZFILE *BZ2fp_r = NULL; + FILE *fp_w = NULL; + + if(fn_w){ + if((fp_w = fopen(fn_w,"wb"))==NULL){ + printf("can't open [%s]\n",fn_w); + perror("reason:"); + exit(1); + } + }else{ + fp_w = stdout; + } + if((fn_r == NULL && (BZ2fp_r = BZ2_bzdopen(fileno(stdin),"rb"))==NULL) + || (fn_r != NULL && (BZ2fp_r = BZ2_bzopen(fn_r,"rb"))==NULL)){ + printf("can't bz2openstream\n"); + exit(1); + } + while((len=BZ2_bzread(BZ2fp_r,buff,0x1000))>0){ + fwrite(buff,1,len,fp_w); + } + BZ2_bzclose(BZ2fp_r); + if(fp_w != stdout) fclose(fp_w); + }else{ + BZFILE *BZ2fp_w = NULL; + FILE *fp_r = NULL; + + if(fn_r){ + if((fp_r = fopen(fn_r,"rb"))==NULL){ + printf("can't open [%s]\n",fn_r); + perror("reason:"); + exit(1); + } + }else{ + fp_r = stdin; + } + mode[0]='w'; + mode[1] = '0' + level; + mode[2] = '\0'; + + if((fn_w == NULL && (BZ2fp_w = BZ2_bzdopen(fileno(stdout),mode))==NULL) + || (fn_w !=NULL && (BZ2fp_w = BZ2_bzopen(fn_w,mode))==NULL)){ + printf("can't bz2openstream\n"); + exit(1); + } + while((len=fread(buff,1,0x1000,fp_r))>0){ + BZ2_bzwrite(BZ2fp_w,buff,len); + } + BZ2_bzclose(BZ2fp_w); + if(fp_r!=stdin)fclose(fp_r); + } + } +#ifdef _WIN32 + BZ2DLLFreeLibrary(); +#endif + return 0; +} Property changes on: trunk/bzip2-1.0.4/dlltest.c ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/bzip2-1.0.4/entities.xml ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/bzip2-1.0.4/huffman.c ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/bzip2-1.0.4/manual.html ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/bzip2-1.0.4/manual.xml ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/bzip2-1.0.4/mk251.c ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/bzip2-1.0.4/randtable.c ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/bzip2-1.0.4/spewG.c ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/bzip2-1.0.4/unzcrash.c ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/bzip2-1.0.4/xmlproc.sh ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/checksum_crc32.c ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/checksum_md5.c ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/checksum_sha1.c ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/docs.txt ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/examples/duke3d/data/duke3d_readme.txt ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/examples/duke3d/data/gpl.txt ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/examples/duke3d/data/mojosetup_readme.txt ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/examples/duke3d/make.sh ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/examples/duke3d/scripts/app_localization.lua ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/examples/duke3d/scripts/config.lua ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/examples/ut3-dedicated/make.sh ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/examples/ut3-dedicated/scripts/config.lua ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/fileio.c ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/fileio.h ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/gui.c ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/gui.h ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/gui_gtkplus2.c ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/gui_macosx.c ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/gui_ncurses.c ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/gui_stdio.c ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/gui_www.c ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/libfetch/README.txt ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/libfetch/common.c ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/libfetch/common.h ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/libfetch/fetch.c ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/libfetch/fetch.h ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/libfetch/ftp.c ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/libfetch/ftperr.h ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/libfetch/http.c ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/libfetch/httperr.h ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/libfetch/mojosetup_libfetch.h ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/libfetch/regen_error_headers.sh ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/lua-5.1.1/COPYRIGHT ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/lua-5.1.1/HISTORY ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/lua-5.1.1/INSTALL ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/lua-5.1.1/Makefile ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/lua-5.1.1/README ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/lua-5.1.1/doc/contents.html ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/lua-5.1.1/doc/lua.css ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/lua-5.1.1/doc/lua.html ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/lua-5.1.1/doc/luac.html ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/lua-5.1.1/doc/manual.html ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/lua-5.1.1/doc/readme.html ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/lua-5.1.1/etc/all.c ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/lua-5.1.1/etc/lua.hpp ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/lua-5.1.1/etc/luavs.bat ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/lua-5.1.1/etc/min.c ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/lua-5.1.1/etc/noparser.c ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/lua-5.1.1/etc/strict.lua ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/lua-5.1.1/src/lapi.c ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/lua-5.1.1/src/lapi.h ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/lua-5.1.1/src/lauxlib.c ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/lua-5.1.1/src/lauxlib.h ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/lua-5.1.1/src/lbaselib.c ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/lua-5.1.1/src/lcode.c ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/lua-5.1.1/src/lcode.h ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/lua-5.1.1/src/ldblib.c ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/lua-5.1.1/src/ldebug.c ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/lua-5.1.1/src/ldebug.h ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/lua-5.1.1/src/ldo.c ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/lua-5.1.1/src/ldo.h ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/lua-5.1.1/src/ldump.c ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/lua-5.1.1/src/lfunc.c ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/lua-5.1.1/src/lfunc.h ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/lua-5.1.1/src/lgc.c ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/lua-5.1.1/src/lgc.h ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/lua-5.1.1/src/linit.c ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/lua-5.1.1/src/liolib.c ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/lua-5.1.1/src/llex.c ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/lua-5.1.1/src/llex.h ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/lua-5.1.1/src/llimits.h ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/lua-5.1.1/src/lmathlib.c ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/lua-5.1.1/src/lmem.c ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/lua-5.1.1/src/lmem.h ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/lua-5.1.1/src/loadlib.c ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/lua-5.1.1/src/lobject.c ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/lua-5.1.1/src/lobject.h ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/lua-5.1.1/src/lopcodes.c ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/lua-5.1.1/src/lopcodes.h ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/lua-5.1.1/src/loslib.c ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/lua-5.1.1/src/lparser.c ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/lua-5.1.1/src/lparser.h ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/lua-5.1.1/src/lstate.c ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/lua-5.1.1/src/lstate.h ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/lua-5.1.1/src/lstring.c ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/lua-5.1.1/src/lstring.h ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/lua-5.1.1/src/lstrlib.c ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/lua-5.1.1/src/ltable.c ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/lua-5.1.1/src/ltable.h ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/lua-5.1.1/src/ltablib.c ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/lua-5.1.1/src/ltm.c ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/lua-5.1.1/src/ltm.h ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/lua-5.1.1/src/lua.c ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/lua-5.1.1/src/lua.h ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/lua-5.1.1/src/luac.c ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/lua-5.1.1/src/luaconf.h ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/lua-5.1.1/src/lualib.h ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/lua-5.1.1/src/lundump.c ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/lua-5.1.1/src/lundump.h ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/lua-5.1.1/src/lvm.c ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/lua-5.1.1/src/lvm.h ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/lua-5.1.1/src/lzio.c ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/lua-5.1.1/src/lzio.h ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/lua-5.1.1/src/print.c ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/lua-5.1.1/test/bisect.lua ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/lua-5.1.1/test/cf.lua ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/lua-5.1.1/test/echo.lua ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/lua-5.1.1/test/env.lua ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/lua-5.1.1/test/factorial.lua ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/lua-5.1.1/test/fib.lua ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/lua-5.1.1/test/fibfor.lua ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/lua-5.1.1/test/globals.lua ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/lua-5.1.1/test/hello.lua ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/lua-5.1.1/test/life.lua ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/lua-5.1.1/test/luac.lua ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/lua-5.1.1/test/printf.lua ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/lua-5.1.1/test/readonly.lua ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/lua-5.1.1/test/sieve.lua ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/lua-5.1.1/test/sort.lua ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/lua-5.1.1/test/table.lua ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/lua-5.1.1/test/trace-calls.lua ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/lua-5.1.1/test/trace-globals.lua ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/lua-5.1.1/test/xd.lua ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/lua_glue.c ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/lua_glue.h ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/mojosetup.c ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/platform.h ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/platform_beos.cpp ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/platform_unix.c ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/platform_windows.c ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/scripts/app_localization.lua ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/scripts/config.lua ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/scripts/localization.lua ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/scripts/mojosetup_init.lua ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/scripts/mojosetup_mainline.lua ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/stb_image.c ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/universal.h ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/zlib-1.2.3/adler32.c ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/zlib-1.2.3/compress.c ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/zlib-1.2.3/crc32.c ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/zlib-1.2.3/crc32.h ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/zlib-1.2.3/deflate.c ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/zlib-1.2.3/deflate.h ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/zlib-1.2.3/gzio.c ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/zlib-1.2.3/infback.c ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/zlib-1.2.3/inffast.c ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/zlib-1.2.3/inffast.h ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/zlib-1.2.3/inffixed.h ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/zlib-1.2.3/inflate.c ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/zlib-1.2.3/inflate.h ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/zlib-1.2.3/inftrees.c ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/zlib-1.2.3/inftrees.h ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/zlib-1.2.3/trees.c ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/zlib-1.2.3/trees.h ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/zlib-1.2.3/uncompr.c ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/zlib-1.2.3/zconf.h ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/zlib-1.2.3/zlib.h ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/zlib-1.2.3/zutil.c ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/zlib-1.2.3/zutil.h ___________________________________________________________________ Name: svn:eol-style + native From DONOTREPLY at icculus.org Sat Feb 2 00:57:13 2008 From: DONOTREPLY at icculus.org (DONOTREPLY at icculus.org) Date: 2 Feb 2008 00:57:13 -0500 Subject: r482 - trunk Message-ID: <20080202055713.4288.qmail@icculus.org> Author: icculus Date: 2008-02-02 00:57:12 -0500 (Sat, 02 Feb 2008) New Revision: 482 Modified: trunk/CMakeLists.txt trunk/fileio.c trunk/gui.h trunk/gui_www.c trunk/lua_glue.c trunk/mojosetup.c trunk/platform_windows.c trunk/universal.h Log: Windows fixes. Modified: trunk/CMakeLists.txt =================================================================== --- trunk/CMakeLists.txt 2008-02-02 04:46:01 UTC (rev 481) +++ trunk/CMakeLists.txt 2008-02-02 05:57:12 UTC (rev 482) @@ -59,6 +59,7 @@ ADD_DEFINITIONS(-DPLATFORM_WINDOWS=1) ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS=1) SET(USES_WINMAIN WIN32) + SET(OPTIONAL_LIBS ${OPTIONAL_LIBS} shell32) ENDIF(WINDOWS) IF(MACOSX) Modified: trunk/fileio.c =================================================================== --- trunk/fileio.c 2008-02-02 04:46:01 UTC (rev 481) +++ trunk/fileio.c 2008-02-02 05:57:12 UTC (rev 482) @@ -149,7 +149,7 @@ MojoPlatform_sleep(100); else { - br = in->read(in, scratchbuf_128k, maxread); + br = in->read(in, scratchbuf_128k, (uint32) maxread); if (br == 0) // we're done! break; else if (br < 0) Modified: trunk/gui.h =================================================================== --- trunk/gui.h 2008-02-02 04:46:01 UTC (rev 481) +++ trunk/gui.h 2008-02-02 05:57:12 UTC (rev 482) @@ -115,6 +115,13 @@ void MojoGui_deinitGuiPlugin(void); #else +// can't use normal STUBBED in gui plugins, since it references logDebug +// without entry-> ... +#ifndef DOXYGEN_SHOULD_IGNORE_THIS +#undef STUBBED +#define STUBBED(x) STUBBED2(entry->,x) +#endif + __EXPORT__ const MojoGui *MOJOGUI_ENTRY_POINT(int revision, const MojoSetupEntryPoints *e); Modified: trunk/gui_www.c =================================================================== --- trunk/gui_www.c 2008-02-02 04:46:01 UTC (rev 481) +++ trunk/gui_www.c 2008-02-02 05:57:12 UTC (rev 482) @@ -43,6 +43,7 @@ static const char *sockStrErrVal(int val) { STUBBED("Windows strerror"); + return "sockStrErrVal() is unimplemented."; } // sockStrErrVal Modified: trunk/lua_glue.c =================================================================== --- trunk/lua_glue.c 2008-02-02 04:46:01 UTC (rev 481) +++ trunk/lua_glue.c 2008-02-02 05:57:12 UTC (rev 482) @@ -1567,9 +1567,9 @@ char *locale = (envr != NULL) ? xstrdup(envr) : MojoPlatform_locale(); char *ostype = MojoPlatform_osType(); char *osversion = MojoPlatform_osVersion(); - lua_Integer uid = MojoPlatform_getuid(); - lua_Integer euid = MojoPlatform_geteuid(); - lua_Integer gid = MojoPlatform_getgid(); + lua_Integer uid = (lua_Integer) MojoPlatform_getuid(); + lua_Integer euid = (lua_Integer) MojoPlatform_geteuid(); + lua_Integer gid = (lua_Integer) MojoPlatform_getgid(); #if DISABLE_LUA_PARSER const boolean luaparser = false; Modified: trunk/mojosetup.c =================================================================== --- trunk/mojosetup.c 2008-02-02 04:46:01 UTC (rev 481) +++ trunk/mojosetup.c 2008-02-02 05:57:12 UTC (rev 482) @@ -675,7 +675,7 @@ #if MOJOSETUP_INTERNAL_BZLIB && BZ_NO_STDIO void bz_internal_error(int errcode) { - fatal(_("bzlib triggered an internal error: %0"), numstr(numbuf)); + fatal(_("bzlib triggered an internal error: %0"), numstr(errcode)); } // bz_internal_error #endif Modified: trunk/platform_windows.c =================================================================== --- trunk/platform_windows.c 2008-02-02 04:46:01 UTC (rev 481) +++ trunk/platform_windows.c 2008-02-02 05:57:12 UTC (rev 482) @@ -20,7 +20,9 @@ #undef UNICODE #endif +#define WIN32_LEAN_AND_MEAN 1 #include +#include // is Win95/Win98/WinME? (no Unicode, etc) static boolean osIsWin9x = false; @@ -640,7 +642,7 @@ // msdn says: // "Returns a value greater than 32 if successful, or an error value that // is less than or equal to 32 otherwise." - return (ShellExecuteA(NULL, "open", url, NULL, NULL, SW_SHOWNORMAL) > 32); + return (((int) ShellExecuteA(NULL, "open", url, NULL, NULL, SW_SHOWNORMAL)) > 32); } // MojoPlatform_launchBrowser @@ -968,9 +970,9 @@ char *MojoPlatform_osVersion(void) { return format("%0.%1.%2", - numStr(osMajorVer), - numStr(osMinorVer), - numStr(osBuildVer)); + numstr(osMajorVer), + numstr(osMinorVer), + numstr(osBuildVer)); } // MojoPlatform_osversion Modified: trunk/universal.h =================================================================== --- trunk/universal.h 2008-02-02 04:46:01 UTC (rev 481) +++ trunk/universal.h 2008-02-02 05:57:12 UTC (rev 482) @@ -365,16 +365,17 @@ #define DEFINE_TO_STR(x) DEFINE_TO_STR2(x) #ifndef DOXYGEN_SHOULD_IGNORE_THIS -#define STUBBED(x) \ +#define STUBBED2(prelog, x) \ do { \ static boolean seen_this = false; \ if (!seen_this) \ { \ seen_this = true; \ - logDebug("STUBBED: %0 at %1 (%2:%3)\n", x, __FUNCTION__, \ - __FILE__, DEFINE_TO_STR(__LINE__)); \ + prelog logDebug("STUBBED: %0 at %1 (%2:%3)\n", x, __FUNCTION__, \ + __FILE__, DEFINE_TO_STR(__LINE__)); \ } \ } while (false) +#define STUBBED(x) STUBBED2(,x) #endif #define STATICARRAYLEN(x) ( (sizeof ((x))) / (sizeof ((x)[0])) ) From DONOTREPLY at icculus.org Tue Feb 12 14:59:30 2008 From: DONOTREPLY at icculus.org (DONOTREPLY at icculus.org) Date: 12 Feb 2008 14:59:30 -0500 Subject: r483 - trunk/meta/xdg-utils Message-ID: <20080212195930.31697.qmail@icculus.org> Author: icculus Date: 2008-02-12 14:59:30 -0500 (Tue, 12 Feb 2008) New Revision: 483 Added: trunk/meta/xdg-utils/xdg-desktop-menu Log: Initial add of pristine xdg-desktop-menu from xdg-utils-1.0.2 Added: trunk/meta/xdg-utils/xdg-desktop-menu =================================================================== --- trunk/meta/xdg-utils/xdg-desktop-menu (rev 0) +++ trunk/meta/xdg-utils/xdg-desktop-menu 2008-02-12 19:59:30 UTC (rev 483) @@ -0,0 +1,1264 @@ +#!/bin/sh +#--------------------------------------------- +# xdg-desktop-menu +# +# Utility script to install menu items on a Linux desktop. +# Refer to the usage() function below for usage. +# +# Copyright 2006, Kevin Krammer +# Copyright 2006, Jeremy White +# +# LICENSE: +# +# 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. +# +#--------------------------------------------- + +manualpage() +{ +cat << _MANUALPAGE +Name + +xdg-desktop-menu - command line tool for (un)installing desktop menu items + +Synopsis + +xdg-desktop-menu install [--noupdate] [--novendor] [--mode mode] directory-file +(s) desktop-file(s) + +xdg-desktop-menu uninstall [--noupdate] [--mode mode] directory-file(s) +desktop-file(s) + +xdg-desktop-menu forceupdate [--mode mode] + +xdg-desktop-menu { --help | --manual | --version } + +Description + +The xdg-desktop-menu program can be used to install new menu entries to the +desktop's application menu. + +The application menu works according to the XDG Desktop Menu Specification at +http://www.freedesktop.org/Standards/menu-spec + +Commands + +install + + Install one or more applications in a submenu of the desktop menu system. + + desktop-file: A desktop file represents a single menu entry in the menu. + Desktop files are defined by the freedesktop.org Desktop Entry + Specification. The most important aspects of *.desktop files are summarized + below. + + Menu entries can be added to the menu system in two different ways. They + can either be added to a predefined submenu in the menu system based on one + or more category keywords, or they can be added to a new submenu. + + To add a menu entry to a predefined submenu the desktop file that + represents the menu entry must have a Categories= entry that lists one or + more keywords. The menu item will be included in an appropriate submenu + based on the included keywords. + + To add menu items to a new submenu the desktop-files must be preceded by a + directory-file that describes the submenu. If multiple desktop-files are + specified, all entries will be added to the same menu. If entries are + installed to a menu that has been created with a previous call to + xdg-desktop-menu the entries will be installed in addition to any already + existing entries. + + directory-file: The *.directory file indicated by directory-file represents + a submenu. The directory file provides the name and icon for a submenu. The + name of the directory file is used to identify the submenu. + + If multiple directory files are provided each file will represent a submenu + within the menu that preceeds it, creating a nested menu hierarchy + (sub-sub-menus). The menu entries themselves will be added to the last + submenu. + + Directory files follow the syntax defined by the freedesktop.org Desktop + Entry Specification. + +uninstall + + Remove applications or submenus from the desktop menu system previously + installed with xdg-desktop-menu install. + + A submenu and the associated directory file is only removed when the + submenu no longer contains any menu entries. + +forceupdate + + Force an update of the menu system. + + This command is only useful if the last call to xdg-desktop-menu included + the --noupdate option. + +Options + +--noupdate + Postpone updating the menu system. If multiple updates to the menu system + are made in sequence this flag can be used to indicate that additional + changes will follow and that it is not necassery to update the menu system + right away. +--novendor + + Normally, xdg-desktop-menu checks to ensure that any *.directory and + *.desktop files to be installed has a vendor prefix. This option can be + used to disable that check. + + A vendor prefix consists of alpha characters ([a-zA-Z]) and is terminated + with a dash ("-"). Companies and organizations are encouraged to use a word + or phrase, preferably the organizations name, for which they hold a + trademark as their vendor prefix. The purpose of the vendor prefix is to + prevent name conflicts. + +--mode mode + + mode can be user or system. In user mode the file is (un)installed for the + current user only. In system mode the file is (un)installed for all users + on the system. Usually only root is allowed to install in system mode. + + The default is to use system mode when called by root and to use user mode + when called by a non-root user. + +--help + Show command synopsis. +--manual + Show this manualpage. +--version + Show the xdg-utils version information. + +Desktop Files + +An application item in the application menu is represented by a *.desktop file. +A *.desktop file consists of a [Desktop Entry] header followed by several Key= +Value lines. + +A *.desktop file can provide a name and description for an application in +several different languages. This is done by adding a language code as used by +LC_MESSAGES in square brackets behind the Key. This way one can specify +different values for the same Key depending on the currently selected language. + +The following keys are often used: + +Value=1.0 + This is a mandatory field to indicate that the *.desktop file follows the + 1.0 version of the specification. +Type=Application + This is a mandatory field that indicates that the *.desktop file describes + an application launcher. +Name=Application Name + The name of the application. For example Mozilla +GenericName=Generic Name + A generic description of the application. For example Web Browser +Comment=Comment + Optional field to specify a tooltip for the application. For example Visit + websites on the Internet +Icon=Icon File + The icon to use for the application. This can either be an absolute path to + an image file or an icon-name. If an icon-name is provided an image lookup + by name is done in the user's current icon theme. The xdg-icon-resource + command can be used to install image files into icon themes. The advantage + of using an icon-name instead of an absolute path is that with an icon-name + the application icon can be provided in several different sizes as well as + in several differently themed styles. +Exec=Command Line + The command line to start the application. If the application can open + files the %f placeholder should be specified. When a file is dropped on the + application launcher the %f is replaced with the file path of the dropped + file. If multiple files can be specified on the command line the %F + placeholder should be used instead of %f. If the application is able to + open URLs in addition to local files then %u or %U can be used instead of + %f or %F. +Categories=Categories + + A list of categories separated by semi-colons. A category is a keyword that + describes and classifies the application. By default applications are + organized in the application menu based on category. When menu entries are + explicitly assigned to a new submenu it is not necassery to list any + categories. + + When using categories it is recommended to include one of the following + categories: AudioVideo, Development, Education, Game, Graphics, Network, + Office, Settings, System, Utility. + + See Appendix A of the XDG Desktop Menu Specification for information about + additional categories. http://standards.freedesktop.org/menu-spec/ + menu-spec-1.0.html + +MimeType=Mimetypes + A list of mimetypes separated by semi-colons. This field is used to + indicate which file types the application is able to open. + +For a complete oveview of the *.desktop file format please visit http:// +www.freedesktop.org/wiki/Standards/desktop-entry-spec + +Directory Files + +The appearance of submenu in the application menu is provided by a *.directory +file. In particular it provides the title of the submenu and a possible icon. A +*.directory file consists of a [Desktop Entry] header followed by several Key= +Value lines. + +A *.directory file can provide a title (name) for the submenu in several +different languages. This is done by adding a language code as used by +LC_MESSAGES in square brackets behind the Key. This way one can specify +different values for the same Key depending on the currently selected language. + +The following keys are relevqnt for submenus: + +Value=1.0 + This is a mandatory field to indicate that the *.directory file follows the + 1.0 version of the Desktop Entry specification. +Type=Directory + This is a mandatory field that indicates that the *.directory file + describes a submenu. +Name=Menu Name + The title of submenu. For example Mozilla +Comment=Comment + Optional field to specify a tooltip for the submenu. +Icon=Icon File + The icon to use for the submenu. This can either be an absolute path to an + image file or an icon-name. If an icon-name is provided an image lookup by + name is done in the user's current icon theme. The xdg-icon-resource + command can be used to install image files into icon themes. The advantage + of using an icon-name instead of an absolute path is that with an icon-name + the submenu icon can be provided in several different sizes as well as in + several differently themed styles. + +Environment Variables + +xdg-desktop-menu honours the following environment variables: + +XDG_UTILS_DEBUG_LEVEL + Setting this environment variable to a non-zero numerical value makes + xdg-desktop-menu do more verbose reporting on stderr. Setting a higher + value increases the verbosity. +XDG_UTILS_INSTALL_MODE + This environment variable can be used by the user or administrator to + override the installation mode. Valid values are user and system. + +Exit Codes + +An exit code of 0 indicates success while a non-zero exit code indicates +failure. The following failure codes can be returned: + +1 + Error in command line syntax. +2 + One of the files passed on the command line did not exist. +3 + A required tool could not be found. +4 + The action failed. +5 + No permission to read one of the files passed on the command line. + +See Also + +xdg-desktop-icon(1), xdg-icon-resource(1), xdg-mime(1) + +Examples + +The company ShinyThings Inc. has developed an application named "WebMirror" and +would like to add it to the application menu. The company will use +"shinythings" as its vendor id. In order to add the application to the menu +there needs to be a .desktop file with a suitable Categories entry: + +shinythings-webmirror.desktop: + + [Desktop Entry] + Encoding=UTF-8 + Type=Application + + Exec=webmirror + Icon=webmirror + + Name=WebMirror + Name[nl]=WebSpiegel + + Categories=Network;WebDevelopment; + +Now the xdg-desktop-menu tool can be used to add the +shinythings-webmirror.desktop file to the desktop application menu: + +xdg-desktop-menu install ./shinythings-webmirror.desktop + +Note that for the purpose of this example the menu items are available in two +languages, English and Dutch. The language code for Dutch is nl. + +In the next example the company ShinyThings Inc. will add its own submenu to +the desktop application menu consisting of a "WebMirror" menu item and a +"WebMirror Admin Tool" menu item. + +First the company needs to create two .desktop files that describe the two menu +items. Since the items are to be added to a new submenu it is not necassery to +include a Categories= line: + +shinythings-webmirror.desktop: + + [Desktop Entry] + Encoding=UTF-8 + Type=Application + + Exec=webmirror + Icon=shinythings-webmirror + + Name=WebMirror + Name[nl]=WebSpiegel + + +shinythings-webmirror-admin.desktop: + + [Desktop Entry] + Encoding=UTF-8 + Type=Application + + Exec=webmirror-admintool + Icon=shinythings-webmirror-admintool + + Name=WebMirror Admin Tool + Name[nl]=WebSpiegel Administratie Tool + +In addition a .directory file needs to be created to provide a title and icon +for the sub-menu itself: + +shinythings-webmirror.directory: + + [Desktop Entry] + Encoding=UTF-8 + + Icon=shinythings-webmirror-menu + + Name=WebMirror + Name[nl]=WebSpiegel + +These file can now be installed with: + +xdg-desktop-menu install ./shinythings-webmirror.directory \ + ./shinythings-webmirror.desktop ./shinythings-webmirror-admin.desktop + +The menu entries could also be installed one by one: + +xdg-desktop-menu install --noupdate ./shinythings-webmirror.directory \ + ./shinythings-webmirror.desktop +xdg-desktop-menu install --noupdate ./shinythings-webmirror.directory \ + ./shinythings-webmirror-admin.desktop +xdg-desktop-menu forceupdate + +Although the result is the same it is slightly more efficient to install all +files at the same time. + +The *.desktop and *.directory files reference icons with the names webmirror, +webmirror-admin and webmirror-menu which should also be installed. In this +example the icons are installed in two different sizes, once with a size of +22x22 pixels and once with a size of 64x64 pixels: + +xdg-icon-resource install --size 22 ./wmicon-22.png shinythings-webmirror +xdg-icon-resource install --size 22 ./wmicon-menu-22.png shinythings-webmirror-menu +xdg-icon-resource install --size 22 ./wmicon-admin-22.png shinythings-webmirror-admin +xdg-icon-resource install --size 64 ./wmicon-64.png shinythings-webmirror +xdg-icon-resource install --size 64 ./wmicon-menu-64.png shinythings-webmirror-menu +xdg-icon-resource install --size 64 ./wmicon-admin-64.png shinythings-webmirror-admin + +_MANUALPAGE +} + +usage() +{ +cat << _USAGE +xdg-desktop-menu - command line tool for (un)installing desktop menu items + +Synopsis + +xdg-desktop-menu install [--noupdate] [--novendor] [--mode mode] directory-file +(s) desktop-file(s) + +xdg-desktop-menu uninstall [--noupdate] [--mode mode] directory-file(s) +desktop-file(s) + +xdg-desktop-menu forceupdate [--mode mode] + +xdg-desktop-menu { --help | --manual | --version } + +_USAGE +} + +#@xdg-utils-common@ + +#---------------------------------------------------------------------------- +# Common utility functions included in all XDG wrapper scripts +#---------------------------------------------------------------------------- + +DEBUG() +{ + [ -z "${XDG_UTILS_DEBUG_LEVEL}" ] && return 0; + [ ${XDG_UTILS_DEBUG_LEVEL} -lt $1 ] && return 0; + shift + echo "$@" >&2 +} + +#------------------------------------------------------------- +# Exit script on successfully completing the desired operation + +exit_success() +{ + if [ $# -gt 0 ]; then + echo "$@" + echo + fi + + exit 0 +} + + +#----------------------------------------- +# Exit script on malformed arguments, not enough arguments +# or missing required option. +# prints usage information + +exit_failure_syntax() +{ + if [ $# -gt 0 ]; then + echo "xdg-desktop-menu: $@" >&2 + echo "Try 'xdg-desktop-menu --help' for more information." >&2 + else + usage + echo "Use 'man xdg-desktop-menu' or 'xdg-desktop-menu --manual' for additional info." + fi + + exit 1 +} + +#------------------------------------------------------------- +# Exit script on missing file specified on command line + +exit_failure_file_missing() +{ + if [ $# -gt 0 ]; then + echo "xdg-desktop-menu: $@" >&2 + fi + + exit 2 +} + +#------------------------------------------------------------- +# Exit script on failure to locate necessary tool applications + +exit_failure_operation_impossible() +{ + if [ $# -gt 0 ]; then + echo "xdg-desktop-menu: $@" >&2 + fi + + exit 3 +} + +#------------------------------------------------------------- +# Exit script on failure returned by a tool application + +exit_failure_operation_failed() +{ + if [ $# -gt 0 ]; then + echo "xdg-desktop-menu: $@" >&2 + fi + + exit 4 +} + +#------------------------------------------------------------ +# Exit script on insufficient permission to read a specified file + +exit_failure_file_permission_read() +{ + if [ $# -gt 0 ]; then + echo "xdg-desktop-menu: $@" >&2 + fi + + exit 5 +} + +#------------------------------------------------------------ +# Exit script on insufficient permission to read a specified file + +exit_failure_file_permission_write() +{ + if [ $# -gt 0 ]; then + echo "xdg-desktop-menu: $@" >&2 + fi + + exit 6 +} + +check_input_file() +{ + if [ ! -e "$1" ]; then + exit_failure_file_missing "file '$1' does not exist" + fi + if [ ! -r "$1" ]; then + exit_failure_file_permission_read "no permission to read file '$1'" + fi +} + +check_vendor_prefix() +{ + file_label="$2" + [ -n "$file_label" ] || file_label="filename" + file=`basename "$1"` + case "$file" in + [a-zA-Z]*-*) + return + ;; + esac + + echo "xdg-desktop-menu: $file_label '$file' does not have a proper vendor prefix" >&2 + echo 'A vendor prefix consists of alpha characters ([a-zA-Z]) and is terminated' >&2 + echo 'with a dash ("-"). An example '"$file_label"' is '"'example-$file'" >&2 + echo "Use --novendor to override or 'xdg-desktop-menu --manual' for additional info." >&2 + exit 1 +} + +check_output_file() +{ + # if the file exists, check if it is writeable + # if it does not exists, check if we are allowed to write on the directory + if [ -e "$1" ]; then + if [ ! -w "$1" ]; then + exit_failure_file_permission_write "no permission to write to file '$1'" + fi + else + DIR=`dirname "$1"` + if [ ! -w "$DIR" -o ! -x "$DIR" ]; then + exit_failure_file_permission_write "no permission to create file '$1'" + fi + fi +} + +#---------------------------------------- +# Checks for shared commands, e.g. --help + +check_common_commands() +{ + while [ $# -gt 0 ] ; do + parm="$1" + shift + + case "$parm" in + --help) + usage + echo "Use 'man xdg-desktop-menu' or 'xdg-desktop-menu --manual' for additional info." + exit_success + ;; + + --manual) + manualpage + exit_success + ;; + + --version) + echo "xdg-desktop-menu 1.0.1" + exit_success + ;; + esac + done +} + +check_common_commands "$@" + +[ -z "${XDG_UTILS_DEBUG_LEVEL}" ] && unset XDG_UTILS_DEBUG_LEVEL; +if [ ${XDG_UTILS_DEBUG_LEVEL-0} -lt 1 ]; then + # Be silent + xdg_redirect_output=" > /dev/null 2> /dev/null" +else + # All output to stderr + xdg_redirect_output=" >&2" +fi + +#-------------------------------------- +# Checks for known desktop environments +# set variable DE to the desktop environments name, lowercase + +detectDE() +{ + if [ x"$KDE_FULL_SESSION" = x"true" ]; then DE=kde; + elif [ x"$GNOME_DESKTOP_SESSION_ID" != x"" ]; then DE=gnome; + elif xprop -root _DT_SAVE_MODE | grep ' = \"xfce4\"$' >/dev/null 2>&1; then DE=xfce; + fi +} + +#---------------------------------------------------------------------------- +# kfmclient exec/openURL can give bogus exit value in KDE <= 3.5.4 +# It also always returns 1 in KDE 3.4 and earlier +# Simply return 0 in such case + +kfmclient_fix_exit_code() +{ + version=`kde-config --version 2>/dev/null | grep KDE` + major=`echo $version | sed 's/KDE: \([0-9]\).*/\1/'` + minor=`echo $version | sed 's/KDE: [0-9]*\.\([0-9]\).*/\1/'` + release=`echo $version | sed 's/KDE: [0-9]*\.[0-9]*\.\([0-9]\).*/\1/'` + test "$major" -gt 3 && return $1 + test "$minor" -gt 5 && return $1 + test "$release" -gt 4 && return $1 + return 0 +} + +update_desktop_database() +{ +# echo Update desktop database: $mode + if [ "$mode" = "system" ] ; then + for x in `echo $PATH | sed 's/:/ /g'` /opt/gnome/bin; do + if [ -x $x/update-desktop-database ] ; then + DEBUG 1 "Running $x/update-desktop-database" + eval '$x/update-desktop-database'$xdg_redirect_output + return + fi + done + fi +} + +fixup_mandriva_categories() +{ + DEBUG 1 "fixup_mandriva_categories $1" + awk ' +BEGIN { + xlat["AudioVideo"]="X-Mandrakelinux-Multimedia;X-MandrivaLinux-Multimedia" + xlat["Development"]="X-Mandrakelinux-MoreApplications-Development;X-MandrivaLinux-MoreApplications-Development" + xlat["Education"]="X-Mandrakelinux-MoreApplications;X-MandrivaLinux-MoreApplications-Education" + xlat["Game"]="X-Mandrakelinux-MoreApplications;X-MandrivaLinux-MoreApplications-Games" + xlat["Graphics"]="X-Mandrakelinux-Multimedia-Graphics" + xlat["Network"]="X-Mandrakelinux-Internet;X-MandrivaLinux-Internet" + xlat["Office"]="X-Mandrakelinux-Office;X-MandrivaLinux-Office" + xlat["System"]="X-Mandrakelinux-System;X-MandrivaLinux-System" + xlat["Utility"]="X-Mandrakelinux-Office-Accessories;X-MandrivaLinux-Office-Accessories" +} +{ + if (match($0,/Categories=/)) { + split(substr($0,RSTART+11),categories,";") + result="" + for (n in categories) + { + if (categories[n] in xlat) + categories[n]=categories[n] ";" xlat[categories[n]] + if (categories[n]) + result=result categories[n] ";" + } + print "Categories=" result + } + else + { + print $0 + } +}' $1 > $1.new + mv $1.new $1 +} + +# Make application $1/$2 the default for all the mimetypes it support, +# iff such mimetype didn't had a default application already. +# $1 Install dir for desktop file +# $2 base name of desktop file +make_lazy_default() +{ + local mimetypes + local xdg_user_dir + local xdg_default_dirs + + DEBUG 1 "make_lazy_default $1/$2" + mimetypes=`awk ' +{ + if (match($0,/MimeType=/)) { + split(substr($0,RSTART+9),mimetypes,";") + for (n in mimetypes) + { + if (mimetypes[n]) + print mimetypes[n] + } + } +}' "$1/$2" 2> /dev/null` + + for MIME in $mimetypes ; do + xdg_default_dirs="$XDG_DATA_DIRS" + [ -n "$xdg_default_dirs" ] || xdg_default_dirs=/usr/local/share/:/usr/share/ + if [ x"$mode" = x"user" ] ; then + xdg_user_dir="$XDG_DATA_HOME" + [ -n "$xdg_user_dir" ] || xdg_user_dir="$HOME/.local/share" + xdg_default_dirs="$xdg_user_dir:$xdg_default_dirs" + fi + local default_app + for x in `echo "$xdg_default_dirs" | sed 's/:/ /g'`; do + DEBUG 2 "Checking $x/applications/defaults.list" + default_app=`grep "$MIME=" $x/applications/defaults.list 2> /dev/null | cut -d '=' -f 2` + if [ -n "$default_app" ] ; then + DEBUG 2 "Found default apps for $MIME: $default_app" + default_app="$default_app;" + break; + fi + done + DEBUG 2 "Current default apps for $MIME: $default_app" + if echo "$default_app" | grep "$2" > /dev/null 2> /dev/null; then + # App already listed as default + continue; + fi + default_file="$1/defaults.list" + DEBUG 1 "Updating $default_file" + grep -v "$MIME=" $default_file > ${default_file}.new 2> /dev/null + if ! grep "[Default Applications]" ${default_file}.new > /dev/null; then + echo "[Default Applications]" >> ${default_file}.new + fi + echo $MIME="$default_app$2" >> ${default_file}.new + mv ${default_file}.new $default_file + done +} + +update_submenu() +{ + DEBUG 1 "update_submenu $1" + menu_file="$1" + + xdg_dir_name=menus + xdg_user_dir="$XDG_CONFIG_HOME" + [ -n "$xdg_user_dir" ] || xdg_user_dir="$HOME/.config" + xdg_user_dir="$xdg_user_dir/$xdg_dir_name" + + xdg_system_dirs="$XDG_CONFIG_DIRS" + [ -n "$xdg_system_dirs" ] || xdg_system_dirs=/etc/xdg + xdg_global_dir= + for x in `echo $xdg_system_dirs | sed 's/:/ /g'` ; do + if [ -w $x/$xdg_dir_name ] ; then + xdg_global_dir="$x/$xdg_dir_name" + break + fi + done + xdg_user_dir="$xdg_user_dir/applications-merged" + xdg_global_dir="$xdg_global_dir/applications-merged" + + DEBUG 3 "Install locations for *.menu file:" + DEBUG 3 "xdg_user_dir: $xdg_user_dir" + DEBUG 3 "xdg_global_dir: $xdg_global_dir" + DEBUG 3 "kde_user_dir: $kde_user_dir" + DEBUG 3 "kde_global_dir: $kde_global_dir" + DEBUG 3 "gnome_user_dir: $gnome_user_dir" + DEBUG 3 "gnome_global_dir: $gnome_global_dir" + + if [ x"$mode" = x"user" ] ; then + xdg_dir="$xdg_user_dir" + kde_dir="$kde_user_dir" + gnome_dir="$gnome_user_dir" + my_umask=077 + my_chmod=0600 + else + xdg_dir="$xdg_global_dir" + kde_dir="$kde_global_dir" + gnome_dir="$gnome_global_dir" + my_umask=022 + my_chmod=0644 + if [ -z "${xdg_dir}${kde_dir}${gnome_dir}" ] ; then + exit_failure_operation_impossible "No writable system menu directory found." + fi + fi + + if [ -z "$menu_file" ] ; then + # Work around for SUSE/gnome 2.12 to pick up new ~/.local/share/applications + save_umask=`umask` + umask $my_umask + + mkdir -p $xdg_dir + touch $xdg_dir/xdg-desktop-menu-dummy.menu + + umask $save_umask + return + fi + + if [ $action = "install" -a -f "/etc/xdg/menus/gnome-applications.menu" ] ; then + # Work around for Debian Gnome + gnome_xdg_dir=`echo "$xdg_dir" | sed -e 's^/applications-merged^/gnome-applications-merged^'` + if [ ! -e "$gnome_xdg_dir" ] ; then + DEBUG 1 "Debian Workaround: Link '$xdg_dir' to '$gnome_xdg_dir'" + mkdir -p `dirname "$gnome_xdg_dir"` + eval 'ln -s "applications-merged" "$gnome_xdg_dir"'$xdg_redirect_output + fi + fi + if [ $action = "install" -a -f "/etc/mandrake-release" ] ; then + # Work around for Mandriva 2006 + mandrake_xdg_dir=`echo "$xdg_dir" | sed -e 's^/applications-merged^/applications-mdk-merged^'` + if [ ! -e "$mandrake_xdg_dir" ] ; then + DEBUG 1 "Mandriva Workaround: Link '$xdg_dir' to '$mandrake_xdg_dir'" + mkdir -p `dirname "$mandrake_xdg_dir"` + eval 'ln -s "applications-merged" "$mandrake_xdg_dir"'$xdg_redirect_output + fi + fi + if [ $action = "install" -a x"$mode" = x"user" -a -d "/etc/xdg/menus/kde-applications-merged" ] ; then + # Work around for Fedora Core 5 + patched KDE + kde_xdg_dir=`echo "$xdg_dir" | sed -e 's^/applications-merged^/kde-applications-merged^'` + if [ ! -e "$kde_xdg_dir" ] ; then + DEBUG 1 "Fedora Workaround: Link '$xdg_dir' to '$kde_xdg_dir'" + mkdir -p `dirname "$kde_xdg_dir"` + eval 'ln -s "applications-merged" "$kde_xdg_dir"'$xdg_redirect_output + fi + fi + if [ $action = "install" -a x"$mode" = x"system" -a -d "/etc/xdg/menus/kde-applications-merged" -a ! -d "/etc/xdg/menus/applications-merged" ] ; then + # Work around for Kubuntu 6.06 + kde_xdg_dir=`echo "$xdg_dir" | sed -e 's^/applications-merged^/kde-applications-merged^'` + DEBUG 1 "Kubuntu Workaround: Link '$xdg_dir' to 'kde-applications-merged'" + eval 'ln -s "kde-applications-merged" "$xdg_dir"'$xdg_redirect_output + fi + + orig_menu_file=$xdg_dir/$menu_file + + DEBUG 1 "Updating $orig_menu_file ($action)" + + test "${TMPDIR+set}" = set || TMPDIR=/tmp + tmpfile=`mktemp $TMPDIR/tmp.XXXXXXXXXX` + orig_desktop_files= + if [ -r "$orig_menu_file" ] ; then + awk ' +# List all files within tags +BEGIN { + RS="<" +} +/^Filename/ { + if (match($0,/>/)) { + print substr($0,RSTART+1) + } +}' $orig_menu_file > $tmpfile + fi + + orig_desktop_files=`cat $tmpfile` + new_desktop_files= + if [ $action = "install" ] ; then + for desktop_file in $desktop_files; do + basefile=`basename $desktop_file` + if ! grep '^'$basefile'$' $tmpfile > /dev/null 2> /dev/null ; then + # Append + echo "$basefile" >> $tmpfile + fi + done + new_desktop_files=`cat $tmpfile` + fi + if [ $action = "uninstall" ] ; then + echo > $tmpfile + for desktop_file in $desktop_files; do + echo "$desktop_file" >> $tmpfile + done + # Files to uninstall are listed in $tmpfile + # Existing files are in $orig_desktop_files + for desktop_file in $orig_desktop_files; do + if ! grep '^'$desktop_file'$' $tmpfile > /dev/null 2> /dev/null; then + # Keep this file, it's not in the uninstall list + new_desktop_files="$new_desktop_files $desktop_file" + fi + done + fi + rm -f "$tmpfile" + + DEBUG 3 "Files to list in $menu_file: $new_desktop_files" + + if [ -n "$new_desktop_files" ] ; then + # Install/update + test "${TMPDIR+set}" = set || TMPDIR=/tmp + tmpfile=`mktemp $TMPDIR/tmp.XXXXXXXXXX` + ( + echo '' + echo '' + echo '' + echo ' Applications' + + for desktop_file in $directory_files; do + basefile=`basename $desktop_file` + basefilename=`echo "$basefile"|cut -d '.' -f 1` + echo "" + echo " $basefilename" + echo " $basefile" + done + + echo " " + for desktop_file in $new_desktop_files; do + echo " $desktop_file" + done + echo " " + + for desktop_file in $directory_files; do + echo "" + done + + echo '' + ) > $tmpfile + chmod $my_chmod $tmpfile + + save_umask=`umask` + umask $my_umask + + mkdir -p $xdg_dir + eval 'cp $tmpfile $xdg_dir/$menu_file'$xdg_redirect_output + + umask $save_umask + rm -f "$tmpfile" + else + # Uninstall + rm -f $xdg_dir/$menu_file + fi + + # Uninstall .directory files only if no longer referenced + if [ $action = "uninstall" ] ; then + test "${TMPDIR+set}" = set || TMPDIR=/tmp + tmpfile=`mktemp $TMPDIR/tmp.XXXXXXXXXX` + for menu_file in $xdg_dir/*; do + if grep 'generated and managed by xdg-desktop-menu' $menu_file > /dev/null 2> /dev/null; then + awk ' +# List all files within tags +BEGIN { + RS="<" +} +/^Directory/ { + if (match($0,/>/)) { + print substr($0,RSTART+1) + } +}' $menu_file >> $tmpfile + fi + done + orig_directory_files="$directory_files" + directory_files= + for desktop_file in $orig_directory_files; do + if ! grep '^'$desktop_file'$' $tmpfile > /dev/null 2> /dev/null; then + # No longer in use, safe to delete + directory_files="$directory_files $desktop_file" + fi + done + rm -f "$tmpfile" + fi +} + + +[ x"$1" != x"" ] || exit_failure_syntax + +mode= +action= +update=yes +desktop_files= +directory_files= + +case $1 in + install) + action=install + ;; + + uninstall) + action=uninstall + ;; + + forceupdate) + action=forceupdate + ;; + + *) + exit_failure_syntax "unknown command '$1'" + ;; +esac + +shift + +vendor=true +while [ $# -gt 0 ] ; do + parm="$1" + shift + + case "$parm" in + --noupdate) + update=no + ;; + + --mode) + if [ -z "$1" ] ; then + exit_failure_syntax "mode argument missing for --mode" + fi + case "$1" in + user) + mode="user" + ;; + + system) + mode="system" + ;; + + *) + exit_failure_syntax "unknown mode '$1'" + ;; + esac + shift + ;; + + --novendor) + vendor=false + ;; + + -*) + exit_failure_syntax "unexpected option '$parm'" + ;; + + *) + if [ "$action" = "install" ] ; then + check_input_file "$parm" + fi + case "$parm" in + *.directory) + if [ -n "$desktop_files" ] ; then + exit_failure_syntax "'$parm' must preceed any *.desktop file" + fi + directory_files="$directory_files $parm" + ;; + *.desktop) + desktop_files="$desktop_files $parm" + ;; + *) + exit_failure_syntax "file to $action must be a *.directory or *.desktop file" + ;; + esac + ;; + esac +done + +# Shouldn't happen +if [ -z "$action" ] ; then + exit_failure_syntax "command argument missing" +fi + +if [ -n "$XDG_UTILS_INSTALL_MODE" ] ; then + if [ "$XDG_UTILS_INSTALL_MODE" = "system" ] ; then + mode="system" + elif [ "$XDG_UTILS_INSTALL_MODE" = "user" ] ; then + mode="user" + fi +fi + +if [ -z "$mode" ] ; then + if [ `whoami` = "root" ] ; then + mode="system" + else + mode="user" + fi +fi + +if [ x"$action" = x"forceupdate" ] ; then + update_desktop_database + exit_success +fi + +if [ -z "$desktop_files" ] ; then + exit_failure_syntax "desktop-file argument missing" +fi + +menu_name= +for desktop_file in $directory_files; do + if [ "$vendor" = "true" -a "$action" = "install" ] ; then + check_vendor_prefix "$desktop_file" + fi + + basefilename=`basename "$desktop_file"|cut -d '.' -f 1` + if [ -z "$menu_name" ] ; then + menu_name="$basefilename" + else + menu_name="$menu_name-$basefilename" + fi +done + +if [ -n "$menu_name" ] ; then + if [ x"$mode" = x"user" ] ; then + update_submenu "user-$menu_name.menu" + else + update_submenu "$menu_name.menu" + fi +else + # Work around for SUSE/gnome 2.12 to pick up new ~/.local/share/applications + if [ x"$mode" = x"user" ] ; then + update_submenu + fi +fi + +# Install *.directory files + +xdg_dir_name=desktop-directories + +xdg_user_dir="$XDG_DATA_HOME" +[ -n "$xdg_user_dir" ] || xdg_user_dir="$HOME/.local/share" +xdg_user_dir="$xdg_user_dir/$xdg_dir_name" + +xdg_system_dirs="$XDG_DATA_DIRS" +[ -n "$xdg_system_dirs" ] || xdg_system_dirs=/usr/local/share/:/usr/share/ +xdg_global_dir= +for x in `echo $xdg_system_dirs | sed 's/:/ /g'` ; do + if [ -w $x/$xdg_dir_name ] ; then + xdg_global_dir="$x/$xdg_dir_name" + break + fi +done + +DEBUG 3 "Install locations for *.directory files:" +DEBUG 3 "xdg_user_dir: $xdg_user_dir" +DEBUG 3 "xdg_global_dir: $xdg_global_dir" +DEBUG 3 "kde_user_dir: $kde_user_dir" +DEBUG 3 "kde_global_dir: $kde_global_dir" +DEBUG 3 "gnome_user_dir: $gnome_user_dir" +DEBUG 3 "gnome_global_dir: $gnome_global_dir" + +if [ x"$mode" = x"user" ] ; then + xdg_dir="$xdg_user_dir" + kde_dir="$kde_user_dir" + gnome_dir="$gnome_user_dir" + my_umask=077 +else + xdg_dir="$xdg_global_dir" + kde_dir="$kde_global_dir" + gnome_dir="$gnome_global_dir" + my_umask=022 + if [ -z "${xdg_dir}${kde_dir}${gnome_dir}" ] ; then + exit_failure_operation_impossible "No writable system menu directory found." + fi +fi + +for desktop_file in $directory_files; do + basefile=`basename $desktop_file` + + DEBUG 1 "$action $desktop_file in $xdg_dir $kde_dir $gnome_dir" + + case $action in + install) + save_umask=`umask` + umask $my_umask + + for x in $xdg_dir $kde_dir $gnome_dir ; do + mkdir -p $x + eval 'cp $desktop_file $x/$basefile'$xdg_redirect_output + done + + umask $save_umask + ;; + + uninstall) + for x in $xdg_dir $kde_dir $gnome_dir ; do + rm -f $x/$basefile + done + + ;; + esac +done + +# Install *.desktop files +xdg_dir_name=applications + +xdg_user_dir="$XDG_DATA_HOME" +[ -n "$xdg_user_dir" ] || xdg_user_dir="$HOME/.local/share" +xdg_user_dir="$xdg_user_dir/$xdg_dir_name" + +xdg_system_dirs="$XDG_DATA_DIRS" +[ -n "$xdg_system_dirs" ] || xdg_system_dirs=/usr/local/share/:/usr/share/ +xdg_global_dir= +for x in `echo $xdg_system_dirs | sed 's/:/ /g'` ; do + if [ -w $x/$xdg_dir_name ] ; then + xdg_global_dir="$x/$xdg_dir_name" + break + fi +done + +kde_user_dir="$HOME/.kde/share/applnk" +kde_global_dir="/usr/share/applnk" +[ -w $kde_global_dir ] || kde_global_dir= + +gnome_user_dir="$HOME/.gnome/apps" +gnome_global_dir="/usr/share/gnome/apps" +[ -w $gnome_global_dir ] || gnome_global_dir= + +[ -f /etc/mandriva-release ] && need_mandriva_fix=true +[ -n "$need_mandriva_fix" ] && DEBUG 1 "Fixing up .desktop categories (Mandriva work around)" + +DEBUG 3 "Install locations for *.desktop files:" +DEBUG 3 "xdg_user_dir: $xdg_user_dir" +DEBUG 3 "xdg_global_dir: $xdg_global_dir" +DEBUG 3 "kde_user_dir: $kde_user_dir" +DEBUG 3 "kde_global_dir: $kde_global_dir" +DEBUG 3 "gnome_user_dir: $gnome_user_dir" +DEBUG 3 "gnome_global_dir: $gnome_global_dir" + +if [ x"$mode" = x"user" ] ; then + xdg_dir="$xdg_user_dir" + kde_dir="$kde_user_dir" + gnome_dir="$gnome_user_dir" + my_umask=077 +else + xdg_dir="$xdg_global_dir" + kde_dir="$kde_global_dir" + gnome_dir="$gnome_global_dir" + my_umask=022 + if [ -z "${xdg_dir}${kde_dir}${gnome_dir}" ] ; then + exit_failure_operation_impossible "No writable system menu directory found." + fi +fi + +for desktop_file in $desktop_files; do + if [ "$vendor" = "true" -a "$action" = "install" ] ; then + check_vendor_prefix "$desktop_file" + fi + + basefile=`basename $desktop_file` + + DEBUG 1 "$action $desktop_file in $xdg_dir $kde_dir $gnome_dir" + + case $action in + install) + save_umask=`umask` + umask $my_umask + + for x in $xdg_dir $kde_dir $gnome_dir ; do + mkdir -p $x + eval 'cp $desktop_file $x/$basefile'$xdg_redirect_output + done + + if [ -n "$need_mandriva_fix" ] ; then + fixup_mandriva_categories $xdg_dir/$basefile + fi + + if [ -f $kde_dir/$basefile ] ; then + echo "OnlyShowIn=Old;" >> $kde_dir/$basefile + fi + + if [ -f $gnome_dir/$basefile ] ; then + echo "OnlyShowIn=Old;" >> $gnome_dir/$basefile + fi + + make_lazy_default "$xdg_dir" "$basefile" + + umask $save_umask + ;; + + uninstall) + for x in $xdg_dir $kde_dir $gnome_dir ; do + rm -f $x/$basefile + done + + ;; + esac +done + +if [ x"$update" = x"yes" ] ; then + update_desktop_database +fi + +exit_success Property changes on: trunk/meta/xdg-utils/xdg-desktop-menu ___________________________________________________________________ Name: svn:executable + * From DONOTREPLY at icculus.org Wed Feb 13 03:52:25 2008 From: DONOTREPLY at icculus.org (DONOTREPLY at icculus.org) Date: 13 Feb 2008 03:52:25 -0500 Subject: r484 - in trunk: . examples/duke3d/scripts examples/ut3-dedicated/scripts scripts Message-ID: <20080213085225.21229.qmail@icculus.org> Author: icculus Date: 2008-02-13 03:52:23 -0500 (Wed, 13 Feb 2008) New Revision: 484 Modified: trunk/docs.txt trunk/examples/duke3d/scripts/config.lua trunk/examples/ut3-dedicated/scripts/config.lua trunk/lua_glue.c trunk/platform.h trunk/platform_unix.c trunk/scripts/config.lua trunk/scripts/localization.lua trunk/scripts/mojosetup_init.lua trunk/scripts/mojosetup_mainline.lua Log: First shot at desktop menu items. Modified: trunk/docs.txt =================================================================== --- trunk/docs.txt 2008-02-12 19:59:30 UTC (rev 483) +++ trunk/docs.txt 2008-02-13 08:52:23 UTC (rev 484) @@ -182,6 +182,20 @@ Setup.Package attributes: + vendor (no default, mustExist, mustBeString, cantBeEmpty) + + This is a unique identifier for your organization. This should be in the + format "companyname.dom" ... the hope is that your primary website is + a unique identifier for your company. If your website is www.icculus.org, + you'd enter your vendor setting as "icculus.org" ... just the hostname and + top-level domain. This is used largely by the OS to maintain packages + (Mac OS X application bundles, vendor IDs for Unix desktop menus, etc). + This is, in theory, never shown to the user, so you don't need this to + actually exist as a website with meaningful content, so long as you can + reasonably assure that the string is unique and follows the "host.dom" + format. + + id (no default, mustExist, mustBeString, cantBeEmpty) This is a unique identifier for your package. Currently it is used as Modified: trunk/examples/duke3d/scripts/config.lua =================================================================== --- trunk/examples/duke3d/scripts/config.lua 2008-02-12 19:59:30 UTC (rev 483) +++ trunk/examples/duke3d/scripts/config.lua 2008-02-13 08:52:23 UTC (rev 484) @@ -22,6 +22,7 @@ Setup.Package { + vendor = "icculus.org", id = "duke3d", description = "Duke Nukem 3D", version = "1.5", Modified: trunk/examples/ut3-dedicated/scripts/config.lua =================================================================== --- trunk/examples/ut3-dedicated/scripts/config.lua 2008-02-12 19:59:30 UTC (rev 483) +++ trunk/examples/ut3-dedicated/scripts/config.lua 2008-02-13 08:52:23 UTC (rev 484) @@ -3,6 +3,7 @@ Setup.Package { + vendor = "epicgames.com", id = "ut3-dedicated", description = "Unreal Tournament 3 Dedicated Server", version = "3487", Modified: trunk/lua_glue.c =================================================================== --- trunk/lua_glue.c 2008-02-12 19:59:30 UTC (rev 483) +++ trunk/lua_glue.c 2008-02-13 08:52:23 UTC (rev 484) @@ -1057,6 +1057,20 @@ } // luahook_platform_mkdir +static int luahook_platform_installdesktopmenuitem(lua_State *L) +{ + const char *data = luaL_checkstring(L, 1); + return retvalBoolean(L, MojoPlatform_installDesktopMenuItem(data)); +} // luahook_platform_installdesktopmenuitem + + +static int luahook_platform_uninstalldesktopmenuitem(lua_State *L) +{ + const char *data = luaL_checkstring(L, 1); + return retvalBoolean(L, MojoPlatform_uninstallDesktopMenuItem(data)); +} // luahook_platform_uninstalldesktopmenuitem + + static int luahook_movefile(lua_State *L) { boolean retval = false; @@ -1669,6 +1683,8 @@ set_cfunc(luaState, luahook_platform_isfile, "isfile"); set_cfunc(luaState, luahook_platform_symlink, "symlink"); set_cfunc(luaState, luahook_platform_mkdir, "mkdir"); + set_cfunc(luaState, luahook_platform_installdesktopmenuitem, "installdesktopmenuitem"); + set_cfunc(luaState, luahook_platform_uninstalldesktopmenuitem, "uninstalldesktopmenuitem"); lua_setfield(luaState, -2, "platform"); // Set the GUI functions... Modified: trunk/platform.h =================================================================== --- trunk/platform.h 2008-02-12 19:59:30 UTC (rev 483) +++ trunk/platform.h 2008-02-13 08:52:23 UTC (rev 484) @@ -231,6 +231,20 @@ // the browser will inform the user if there's a problem loading the URL. boolean MojoPlatform_launchBrowser(const char *url); +// Add a menu item to the Application menu or Start bar or whatever. +// (data) is 100% platform dependent right now, and this interface will +// likely change as we come to understand various systems' needs better. +// On Unix, it expects this to be a path to a FreeDesktop .desktop file. +// Returns (true) on success and (false) on failure. +boolean MojoPlatform_installDesktopMenuItem(const char *data); + +// Remove a menu item from the Application menu or Start bar or whatever. +// (data) is 100% platform dependent right now, and this interface will +// likely change as we come to understand various systems' needs better. +// On Unix, it expects this to be a path to a FreeDesktop .desktop file. +// Returns (true) on success and (false) on failure. +boolean MojoPlatform_uninstallDesktopMenuItem(const char *data); + #if !SUPPORT_MULTIARCH #define MojoPlatform_switchBin(img, len) #else Modified: trunk/platform_unix.c =================================================================== --- trunk/platform_unix.c 2008-02-12 19:59:30 UTC (rev 483) +++ trunk/platform_unix.c 2008-02-13 08:52:23 UTC (rev 484) @@ -26,7 +26,7 @@ #include #include #include -#include +#include #if MOJOSETUP_HAVE_SYS_UCRED_H # ifdef MOJOSETUP_HAVE_MNTENT_H @@ -1063,28 +1063,47 @@ } // shellEscape -static boolean unix_launchBrowser(const char *url) +static boolean unix_launchXdgUtil(const char *util, const char **argv) { boolean retval = false; - char *path = findBinaryInPath("xdg-open"); + char *path = findBinaryInPath(util); if (path != NULL) // it's installed on the system; use that. { - char *escapedurl = shellEscape(url); - char *cmd = format("xdg-open %0 >/dev/null 2>&1", escapedurl); + char *cmd = path; + char *tmp = NULL; + int i; + for (i = 0; argv[i]; i++) + { + char *escaped = shellEscape(argv[i]); + tmp = format("%0 %1", cmd, escaped); + free(escaped); + free(cmd); + cmd = tmp; + } // for + + tmp = format("%0 >/dev/null 2>&1", cmd); + free(cmd); + cmd = tmp; retval = (system(cmd) == 0); free(cmd); - free(escapedurl); - free(path); } // if else // try our fallback copy of xdg-utils in GBaseArchive? { - const char *argv[] = { url, NULL }; - retval = (runScript("meta/xdg-utils/xdg-open", true, argv) == 0); + char *script = format("meta/xdg-utils/%0", util); + retval = (runScript(script, true, argv) == 0); + free(script); } // if return retval; +} // unix_launchXdgUtil + + +static boolean unix_launchBrowser(const char *url) +{ + const char *argv[] = { url, NULL }; + return unix_launchXdgUtil("xdg-open", argv); } // unix_launchBrowser #endif @@ -1106,6 +1125,32 @@ } // MojoPlatform_launchBrowser +boolean MojoPlatform_installDesktopMenuItem(const char *data) +{ +#if PLATFORM_MACOSX || PLATFORM_BEOS + // !!! FIXME: write me. + STUBBED("desktop menu support"); + return false; +#else + const char *argv[] = { "install", data, NULL }; + return unix_launchXdgUtil("xdg-desktop-menu", argv); +#endif +} // MojoPlatform_installDesktopMenuItem + + +boolean MojoPlatform_uninstallDesktopMenuItem(const char *data) +{ +#if PLATFORM_MACOSX || PLATFORM_BEOS + // !!! FIXME: write me. + STUBBED("desktop menu support"); + return false; +#else + const char *argv[] = { "uninstall", data, NULL }; + return unix_launchXdgUtil("xdg-desktop-menu", argv); +#endif +} // MojoPlatform_uninstallDesktopMenuItem + + #if SUPPORT_MULTIARCH void MojoPlatform_switchBin(const uint8 *img, size_t len) { Modified: trunk/scripts/config.lua =================================================================== --- trunk/scripts/config.lua 2008-02-12 19:59:30 UTC (rev 483) +++ trunk/scripts/config.lua 2008-02-13 08:52:23 UTC (rev 484) @@ -35,6 +35,7 @@ Setup.Package { + vendor = "com.mycompany", id = "mygame", description = "My Game", version = "1.0", @@ -131,6 +132,19 @@ end }, + Setup.DesktopMenuItem + { + disabled = false, + name = "My Game", + genericname = "Shoot-em up", + comment = "A game for shooting aliens.", + builtin_icon = false, + icon = "icon.png", -- relative to the dest; you must install it! + commandline = "command-line", + categories = "Game", + mimetype = { 'application/x-mygame-map', 'application/x-mygame-url' }, + }, + -- Here's an option that has it's own EULA. Setup.Option { Modified: trunk/scripts/localization.lua =================================================================== --- trunk/scripts/localization.lua 2008-02-12 19:59:30 UTC (rev 483) +++ trunk/scripts/localization.lua 2008-02-13 08:52:23 UTC (rev 484) @@ -303,6 +303,13 @@ nb = "FEIL: write_manifest krever st?tte for Lua-parser", }; + -- This is shown if the config file wants us to add desktop menu items + -- but uninstaller support isn't enabled. This is considered bad taste + -- to add system menu items without a way to remove them. This is + -- a bug the developer must fix before shipping her installer. + ["BUG: Setup.DesktopMenuItem requires support_uninstall"] = { + }; + -- This is a file's permissions. Programmers give these as strings, and -- if one isn't valid, the program will report this. So, on Unix, they -- might specify "0600" as a valid string, but "sdfksjdfk" wouldn't be @@ -1014,6 +1021,18 @@ ["[Make the window taller!]"] = { nb = "[Gj?r vinduet h?yere!]", }; + + -- This is written out if we failed to add an item to the desktop + -- application menu (or "Start" bar on Windows, or maybe the Dock on + -- Mac OS X, etc). + ["Failed to install desktop menu item"] = { + }; + + -- This is written out if we failed to remove an item from the desktop + -- application menu (or "Start" bar on Windows, or maybe the Dock on + -- Mac OS X, etc). + ["Failed to uninstall desktop menu item"] = { + }; }; -- end of localization.lua ... Modified: trunk/scripts/mojosetup_init.lua =================================================================== --- trunk/scripts/mojosetup_init.lua 2008-02-12 19:59:30 UTC (rev 483) +++ trunk/scripts/mojosetup_init.lua 2008-02-13 08:52:23 UTC (rev 484) @@ -245,6 +245,7 @@ tab = sanitize("Package", tab, { + { "vendor", nil, mustExist, mustBeString, cantBeEmpty }, { "id", nil, mustExist, mustBeString, cantBeEmpty }, { "disabled", nil, mustBeBool }, { "description", nil, mustExist, mustBeString, cantBeEmpty }, @@ -406,6 +407,20 @@ }) end +function Setup.DesktopMenuItem(tab) + return sanitize("DesktopMenuItem", tab, + { + { "disabled", nil, mustBeBool }, + { "name", nil, mustExist, mustBeString, cantBeEmpty }, + { "genericname", nil, mustExist, mustBeString, cantBeEmpty }, + { "comment", nil, mustExist, mustBeString, cantBeEmpty }, + { "builtin_icon", nil, mustBeBool }, + { "icon", nil, mustExist, mustBeString, cantBeEmpty }, + { "commandline", nil, mustExist, mustBeString, cantBeEmpty }, + { "category", nil, mustExist, mustBeStringOrTableOfStrings }, + { "mimetype", nil, mustBeStringOrTableOfStrings }, + }) +end local function prepare_localization() -- Map some legacy language identifiers into updated equivalents. Modified: trunk/scripts/mojosetup_mainline.lua =================================================================== --- trunk/scripts/mojosetup_mainline.lua 2008-02-12 19:59:30 UTC (rev 483) +++ trunk/scripts/mojosetup_mainline.lua 2008-02-13 08:52:23 UTC (rev 484) @@ -125,6 +125,24 @@ end +local function flatten_list(list) + local retval = list + if type(list) == "table" then + retval = '' + local first = true + for i,v in ipairs(list) do + if first then + retval = v + first = false + else + retval = retval .. ';' .. v + end + end + end + return retval +end + + local function do_delete(fname) local retval = false if fname == nil then @@ -228,21 +246,7 @@ -- (The real revertinstall is set later. This is a stub for startup.) end -local function real_revertinstall() - if MojoSetup.gui_started then - MojoSetup.gui.final(_("Incomplete installation. We will revert any changes we made.")) - end - MojoSetup.loginfo("Cleaning up half-finished installation...") - - -- !!! FIXME: callbacks here. - delete_files(MojoSetup.downloads) - delete_files(flatten_manifest(MojoSetup.manifest, prepend_dest_dir)) - do_rollbacks() - delete_scratchdirs() -end - - local function calc_percent(current, total) if total == 0 then return 0 @@ -605,7 +609,7 @@ if #wildcards > 1 then single_match = false else - for k,v in ipairs(wildcards) do + for i,v in ipairs(wildcards) do if string.find(v, "[*?]") ~= nil then single_match = false break -- no reason to keep iterating... @@ -632,7 +636,7 @@ if wildcards == nil then should_install = true else - for k,v in ipairs(wildcards) do + for i,v in ipairs(wildcards) do if MojoSetup.wildcardmatch(ent.filename, v) then should_install = true break -- no reason to keep iterating... @@ -927,10 +931,10 @@ -- Man, I hate escaping shell strings... local bin = "\"`dirname $0`\"'/" .. MojoSetup.metadatadirname .. "/" .. MojoSetup.controlappname .. "'" - string.gsub(bin, "'", "'\\''") -- Escape single quotes for shell. + string.gsub(bin, "'", "'\\''") -- !!! FIXME: no-op!-- Escape single quotes for shell. local id = MojoSetup.install.id - string.gsub(id, "'", "'\\''") + string.gsub(id, "'", "'\\''") -- !!! FIXME: no-op! local script = "#!/bin/sh\n" .. @@ -965,12 +969,14 @@ local package = { id = MojoSetup.install.id, + vendor = MojoSetup.install.vendor, description = MojoSetup.install.description, root = MojoSetup.destination, update_url = MojoSetup.install.updateurl, version = MojoSetup.install.version, manifest = MojoSetup.manifest, - splash = MojoSetup.install.splash + splash = MojoSetup.install.splash, + desktopmenuitems = MojoSetup.install.desktopmenuitems } -- now build these things... @@ -981,6 +987,90 @@ end +local function freedesktop_menuitem_filename(pkg, idx) -- only for Unix. + local vendor = string.gsub(pkg.vendor, "%..*$", "", 1) -- chop off TLD. + local fname = vendor .. "-" .. pkg.id .. idx .. ".desktop" + return MojoSetup.metadatadir .. "/" .. fname +end + + +local function uninstall_desktop_menu_items(pkg) + -- !!! FIXME: GUI progress? + if pkg.desktopmenuitems ~= nil then + for i,v in ipairs(pkg.desktopmenuitems) do + if MojoSetup.info.platform == "windows" then + MojoSetup.fatal(_("Unimplemented")) -- !!! FIXME: write me. + elseif MojoSetup.info.platform == "macosx" then + MojoSetup.fatal(_("Unimplemented")) -- !!! FIXME: write me. + elseif MojoSetup.info.platform == "beos" then + MojoSetup.fatal(_("Unimplemented")) -- !!! FIXME: write me. + else -- freedesktop, we hope. + local fname = freedesktop_menuitem_filename(pkg, idx) + if not MojoSetup.platform.uninstalldesktopmenuitem(fname) then + MojoSetup.fatal(_("Failed to uninstall desktop menu item")) + end + end + end + end +end + + +local function install_freedesktop_menuitem(pkg, idx, item) -- only for Unix. + local icon + if item.builtin_icon then + icon = item.icon + else + icon = MojoSetup.destination .. "/" .. item.icon + end + + local str = "[Desktop Entry]\n" .. + "Encoding=UTF-8\n" .. + "Value=1.0\n" .. + "Type=Application\n" .. + "Name=" .. item.name .. "\n" .. + "GenericName=" .. item.genericname .. "\n" .. + "Comment=" .. item.comment .. "\n" .. + "Icon=" .. icon .. "\n" .. + "Exec=" .. item.commandline .. "\n" .. + "Categories=" .. flatten_list(item.categories) .. "\n" + + if item.mimetype ~= nil then + str = str .. "MimeType=" .. flatten_list(item.mimetype) .. "\n" + end + + str = str .. "\n" + + local dest = freedesktop_menuitem_filename(pkg, idx) + local perms = "0644" -- !!! FIXME + local key = MojoSetup.metadatakey + local desc = MojoSetup.metadatadesc + install_file_from_string(dest, str, perms, desc, key) + if not MojoSetup.platform.installdesktopmenuitem(dest) then + MojoSetup.fatal(_("Failed to install desktop menu item")) + end +end + + +local function install_desktop_menu_items(pkg) + -- !!! FIXME: GUI progress? + if pkg.desktopmenuitems ~= nil then + for i,item in ipairs(pkg.desktopmenuitems) do + if not item.disabled then + if MojoSetup.info.platform == "windows" then + MojoSetup.fatal(_("Unimplemented")) -- !!! FIXME: write me. + elseif MojoSetup.info.platform == "macosx" then + MojoSetup.fatal(_("Unimplemented")) -- !!! FIXME: write me. + elseif MojoSetup.info.platform == "beos" then + MojoSetup.fatal(_("Unimplemented")) -- !!! FIXME: write me. + else -- freedesktop, we hope. + install_freedesktop_menuitem(pkg, i, item) + end + end + end + end +end + + local function start_gui(desc, splashfname) if splashfname ~= nil then splashfname = 'meta/' .. splashfname @@ -1022,6 +1112,12 @@ MojoSetup.fatal(_("BUG: support_uninstall requires write_manifest")) end + -- Desktop icons should probably require uninstall so we don't clutter + -- the system with no option for reversal later. + if (install.desktopmenuitems ~= nil) and (not install.support_uninstall) then + MojoSetup.fatal(_("BUG: Setup.DesktopMenuItem requires support_uninstall")) + end + -- Manifest support requires the Lua parser. if (install.write_manifest) and (not MojoSetup.info.luaparser) then MojoSetup.fatal(_("BUG: write_manifest requires Lua parser support")) @@ -1408,7 +1504,7 @@ end end - run_config_defined_hook(install.postinstall, install) + install_desktop_menu_items(install) if install.support_uninstall then if MojoSetup.info.platform == "windows" then @@ -1418,6 +1514,8 @@ end end + run_config_defined_hook(install.postinstall, install) + if install.write_manifest then install_control_app(MojoSetup.metadatadesc, MojoSetup.metadatakey) install_manifests(MojoSetup.metadatadesc, MojoSetup.metadatakey) @@ -1500,6 +1598,22 @@ end +local function real_revertinstall() + if MojoSetup.gui_started then + MojoSetup.gui.final(_("Incomplete installation. We will revert any changes we made.")) + end + + MojoSetup.loginfo("Cleaning up half-finished installation...") + + -- !!! FIXME: callbacks here. + uninstall_desktop_menu_items(MojoSetup.install) + delete_files(MojoSetup.downloads) + delete_files(flatten_manifest(MojoSetup.manifest, prepend_dest_dir)) + do_rollbacks() + delete_scratchdirs() +end + + local function installer() MojoSetup.loginfo("Installer starting") @@ -1650,7 +1764,9 @@ if uninstall_permitted then start_gui(package.description, package.splash) - -- Upvalued so we don't look this up each time... + uninstall_desktop_menu_items(package) + + -- Upvalued in callback so we don't look this up each time... local ptype = _("Uninstalling") local callback = function(fname, current, total) fname = make_relative(fname, MojoSetup.destination) From DONOTREPLY at icculus.org Wed Feb 13 04:36:16 2008 From: DONOTREPLY at icculus.org (DONOTREPLY at icculus.org) Date: 13 Feb 2008 04:36:16 -0500 Subject: r485 - in trunk: . scripts Message-ID: <20080213093616.17150.qmail@icculus.org> Author: icculus Date: 2008-02-13 04:36:04 -0500 (Wed, 13 Feb 2008) New Revision: 485 Modified: trunk/docs.txt trunk/scripts/config.lua trunk/scripts/mojosetup_init.lua trunk/scripts/mojosetup_mainline.lua Log: More menu item work. Modified: trunk/docs.txt =================================================================== --- trunk/docs.txt 2008-02-13 08:52:23 UTC (rev 484) +++ trunk/docs.txt 2008-02-13 09:36:04 UTC (rev 485) @@ -706,6 +706,83 @@ non-nil permission, the filter takes precedence. + Setup.DesktopMenuItem: + + This element specifies a menu item that will be installed in the system + desktop menu: this might be the "Applications" dropdown in the Gnome panel, + or the "Start" bar on Windows, for example. This can be a child of + Setup.Option (in which case it is only considered for installation if the + option itself is too), or Setup.Package (in which case it is always + considered for installation). Some of this element's properties are ignored + on some operating systems, but they are still required both for + cross-platform safety and future expansion. + + Setup.DesktopMenuItem attributes: + + disabled (no default, mustBeBool) + + If this is true, the menu item will be skipped by the installer. You + probably want this to be true, but you might need to programmatically shut + off specific menu items. + + + name (no default, mustExist, mustBeString, cantBeEmpty) + + This is the proper name of the item to be installed ("Firefox"). + + + genericname (no default, mustExist, mustBeString, cantBeEmpty) + + This is a generic name for the item to be installed ("Web Browser"). + + + tooltip (no default, mustExist, mustBeString, cantBeEmpty) + + This is used as a tooltip for the item by the OS when the user hovers + the mouse pointer over it. + + builtin_icon (no default, mustBeBool) + + If this is true, then "icon" refers to a platform-dependent standard + icon. Currently, this only makes sense on Unix systems that follow + the freedesktop.org standards. If this is false, then "icon" refers + to a file, relative to the installation's destination directory, which + the must be installed through a Setup.File. Most installers should set + this to false (the default) unless they know what they are doing. + + icon (no default, mustExist, mustBeString, cantBeEmpty) + + The icon to use with this menu item. Please see builtin_icon for info + on what this string means. The format of files that may be used as icons + varies from platform to platform; you may need to install a different + file programmatically, based on the value of MojoSetup.info.platform. + + commandline (no default, mustExist, mustBeString, cantBeEmpty) + + This is the command line that will be used to launch the application + when the end user clicks on the desktop menu item. + + category (no default, mustExist, mustBeStringOrTableOfStrings) + + This is a category (or array of categories) that the menu item applies + to. You can choose several, but one is usually less confusing. Valid + choices are currently: AudioVideo, Development, Education, Game, Graphics, Network, + Office, Settings, System, Utility. + + mimetype (no default, mustBeStringOrTableOfStrings) + + This is a MIME type (or array of MIME types) that the menu item can handle. + For example, if you are installing an image viewer, you might specify: + mimetype={"image/jpeg", "image/png"}; ... this is optional, you don't + have to specify any mimetypes at all. + + !!! FIXME: there is currently no way for an installer to inform the system + !!! FIXME: of associations between new file extensions and mimetypes. + !!! FIXME: Things that collect mime info themselves, like web browsers + !!! FIXME: and email clients, can use new apps this way, however. + + + Add any localized strings: If you added strings to the installer or your config file that you want Modified: trunk/scripts/config.lua =================================================================== --- trunk/scripts/config.lua 2008-02-13 08:52:23 UTC (rev 484) +++ trunk/scripts/config.lua 2008-02-13 09:36:04 UTC (rev 485) @@ -96,7 +96,21 @@ bytes = megabytes(600), description = "Base Install", - -- File(s) to install. + -- Install a desktop menu item with the base install. + Setup.DesktopMenuItem + { + disabled = false, + name = "My Game", + genericname = "Shoot-em up", + tooltip = "A game of alien hunting.", + builtin_icon = false, + icon = "icon.png", -- relative to the dest; you must install it! + commandline = "command-line", + categories = "Game", + mimetype = { 'application/x-mygame-map', 'application/x-mygame-url' }, + }, + + -- File(s) to install with this option. Setup.File { -- source can be a directory, an archive, or a supported URL. @@ -132,20 +146,7 @@ end }, - Setup.DesktopMenuItem - { - disabled = false, - name = "My Game", - genericname = "Shoot-em up", - comment = "A game for shooting aliens.", - builtin_icon = false, - icon = "icon.png", -- relative to the dest; you must install it! - commandline = "command-line", - categories = "Game", - mimetype = { 'application/x-mygame-map', 'application/x-mygame-url' }, - }, - - -- Here's an option that has it's own EULA. + -- Here's a suboption that has it's own EULA. Setup.Option { value = true, Modified: trunk/scripts/mojosetup_init.lua =================================================================== --- trunk/scripts/mojosetup_init.lua 2008-02-13 08:52:23 UTC (rev 484) +++ trunk/scripts/mojosetup_init.lua 2008-02-13 09:36:04 UTC (rev 485) @@ -413,7 +413,7 @@ { "disabled", nil, mustBeBool }, { "name", nil, mustExist, mustBeString, cantBeEmpty }, { "genericname", nil, mustExist, mustBeString, cantBeEmpty }, - { "comment", nil, mustExist, mustBeString, cantBeEmpty }, + { "tooltip", nil, mustExist, mustBeString, cantBeEmpty }, { "builtin_icon", nil, mustBeBool }, { "icon", nil, mustExist, mustBeString, cantBeEmpty }, { "commandline", nil, mustExist, mustBeString, cantBeEmpty }, Modified: trunk/scripts/mojosetup_mainline.lua =================================================================== --- trunk/scripts/mojosetup_mainline.lua 2008-02-13 08:52:23 UTC (rev 484) +++ trunk/scripts/mojosetup_mainline.lua 2008-02-13 09:36:04 UTC (rev 485) @@ -1029,7 +1029,7 @@ "Type=Application\n" .. "Name=" .. item.name .. "\n" .. "GenericName=" .. item.genericname .. "\n" .. - "Comment=" .. item.comment .. "\n" .. + "Comment=" .. item.tooltip .. "\n" .. "Icon=" .. icon .. "\n" .. "Exec=" .. item.commandline .. "\n" .. "Categories=" .. flatten_list(item.categories) .. "\n" @@ -1114,6 +1114,7 @@ -- Desktop icons should probably require uninstall so we don't clutter -- the system with no option for reversal later. + -- !!! FIXME: will miss menu items that are Setup.Option children... if (install.desktopmenuitems ~= nil) and (not install.support_uninstall) then MojoSetup.fatal(_("BUG: Setup.DesktopMenuItem requires support_uninstall")) end @@ -1349,6 +1350,15 @@ process_file(option, v) end end + + if option.desktopmenuitems ~= nil then + for i,item in ipairs(option.desktopmenuitems) do + if install.desktopmenuitems == nil then + install.desktopmenuitems = {} + end + install.desktopmenuitems[#install.desktopmenuitems] = item + end + end end local function build_source_tables(opts) From DONOTREPLY at icculus.org Wed Feb 13 06:25:00 2008 From: DONOTREPLY at icculus.org (DONOTREPLY at icculus.org) Date: 13 Feb 2008 06:25:00 -0500 Subject: r486 - in trunk: . examples/duke3d/data examples/duke3d/scripts scripts Message-ID: <20080213112500.19199.qmail@icculus.org> Author: icculus Date: 2008-02-13 06:24:47 -0500 (Wed, 13 Feb 2008) New Revision: 486 Added: trunk/examples/duke3d/data/duke3d.png Modified: trunk/docs.txt trunk/examples/duke3d/scripts/config.lua trunk/platform_unix.c trunk/scripts/config.lua trunk/scripts/mojosetup_mainline.lua Log: More desktop menu item fixes, and updated duke3d example...appears to work now! Modified: trunk/docs.txt =================================================================== --- trunk/docs.txt 2008-02-13 09:36:04 UTC (rev 485) +++ trunk/docs.txt 2008-02-13 11:24:47 UTC (rev 486) @@ -781,8 +781,10 @@ !!! FIXME: Things that collect mime info themselves, like web browsers !!! FIXME: and email clients, can use new apps this way, however. + !!! FIXME: there is currently no way for an installer to add submenus. + Add any localized strings: If you added strings to the installer or your config file that you want Added: trunk/examples/duke3d/data/duke3d.png =================================================================== (Binary files differ) Property changes on: trunk/examples/duke3d/data/duke3d.png ___________________________________________________________________ Name: svn:mime-type + image/png Modified: trunk/examples/duke3d/scripts/config.lua =================================================================== --- trunk/examples/duke3d/scripts/config.lua 2008-02-13 09:36:04 UTC (rev 485) +++ trunk/examples/duke3d/scripts/config.lua 2008-02-13 11:24:47 UTC (rev 486) @@ -69,6 +69,19 @@ uniquefile = "atominst/duke3d.grp" }, + -- Install a desktop menu item with all install types. + Setup.DesktopMenuItem + { + disabled = false, + name = "Duke Nukem 3D", + genericname = "Duke Nukem 3D", + tooltip = "Always bet on Duke!", + builtin_icon = false, + icon = "duke3d.png", -- relative to the dest; you must install it! + commandline = "/home/icculus/duke3d/duke3d", + category = "Game", + }, + Setup.OptionGroup { description = _("Installation type"), @@ -87,7 +100,8 @@ Setup.File { - wildcards = "*.txt"; -- catch all the EULAs and READMEs. + -- catch all the EULAs and READMEs, and the desktop menu icon. + wildcards = { "*.txt", "duke3d.png" } }, Setup.File { @@ -114,7 +128,8 @@ Setup.File { - wildcards = "*.txt"; -- catch all the EULAs and READMEs. + -- catch all the EULAs and READMEs, and the desktop menu icon. + wildcards = { "*.txt", "duke3d.png" } }, Setup.File Modified: trunk/platform_unix.c =================================================================== --- trunk/platform_unix.c 2008-02-13 09:36:04 UTC (rev 485) +++ trunk/platform_unix.c 2008-02-13 11:24:47 UTC (rev 486) @@ -1070,7 +1070,7 @@ if (path != NULL) // it's installed on the system; use that. { - char *cmd = path; + char *cmd = xstrdup(util); char *tmp = NULL; int i; for (i = 0; argv[i]; i++) @@ -1082,7 +1082,7 @@ cmd = tmp; } // for - tmp = format("%0 >/dev/null 2>&1", cmd); + tmp = format("%0/%1 >/dev/null 2>&1", path, cmd); free(cmd); cmd = tmp; retval = (system(cmd) == 0); Modified: trunk/scripts/config.lua =================================================================== --- trunk/scripts/config.lua 2008-02-13 09:36:04 UTC (rev 485) +++ trunk/scripts/config.lua 2008-02-13 11:24:47 UTC (rev 486) @@ -106,7 +106,7 @@ builtin_icon = false, icon = "icon.png", -- relative to the dest; you must install it! commandline = "command-line", - categories = "Game", + category = "Game", mimetype = { 'application/x-mygame-map', 'application/x-mygame-url' }, }, Modified: trunk/scripts/mojosetup_mainline.lua =================================================================== --- trunk/scripts/mojosetup_mainline.lua 2008-02-13 09:36:04 UTC (rev 485) +++ trunk/scripts/mojosetup_mainline.lua 2008-02-13 11:24:47 UTC (rev 486) @@ -820,7 +820,7 @@ local objtype = type(obj) if objtype == "nil" then retval = "nil" - elseif objtype == "number" then + elseif (objtype == "number") or (objtype == "boolean") then retval = tostring(obj) elseif objtype == "string" then retval = string.format("%q", obj) @@ -988,8 +988,8 @@ local function freedesktop_menuitem_filename(pkg, idx) -- only for Unix. - local vendor = string.gsub(pkg.vendor, "%..*$", "", 1) -- chop off TLD. - local fname = vendor .. "-" .. pkg.id .. idx .. ".desktop" + local vendor = string.gsub(pkg.vendor, "%.", "_") + local fname = vendor .. "-" .. pkg.id .. "_" .. idx .. ".desktop" return MojoSetup.metadatadir .. "/" .. fname end @@ -1005,7 +1005,7 @@ elseif MojoSetup.info.platform == "beos" then MojoSetup.fatal(_("Unimplemented")) -- !!! FIXME: write me. else -- freedesktop, we hope. - local fname = freedesktop_menuitem_filename(pkg, idx) + local fname = freedesktop_menuitem_filename(pkg, i) if not MojoSetup.platform.uninstalldesktopmenuitem(fname) then MojoSetup.fatal(_("Failed to uninstall desktop menu item")) end @@ -1032,7 +1032,7 @@ "Comment=" .. item.tooltip .. "\n" .. "Icon=" .. icon .. "\n" .. "Exec=" .. item.commandline .. "\n" .. - "Categories=" .. flatten_list(item.categories) .. "\n" + "Categories=" .. flatten_list(item.category) .. "\n" if item.mimetype ~= nil then str = str .. "MimeType=" .. flatten_list(item.mimetype) .. "\n" @@ -1044,6 +1044,10 @@ local perms = "0644" -- !!! FIXME local key = MojoSetup.metadatakey local desc = MojoSetup.metadatadesc + + --MojoSetup.logdebug("Install FreeDesktop file") + --MojoSetup.logdebug(dest) + --MojoSetup.logdebug(str) install_file_from_string(dest, str, perms, desc, key) if not MojoSetup.platform.installdesktopmenuitem(dest) then MojoSetup.fatal(_("Failed to install desktop menu item")) From DONOTREPLY at icculus.org Wed Feb 13 19:42:31 2008 From: DONOTREPLY at icculus.org (DONOTREPLY at icculus.org) Date: 13 Feb 2008 19:42:31 -0500 Subject: r487 - trunk/meta/xdg-utils Message-ID: <20080214004231.14065.qmail@icculus.org> Author: icculus Date: 2008-02-13 19:42:30 -0500 (Wed, 13 Feb 2008) New Revision: 487 Modified: trunk/meta/xdg-utils/xdg-desktop-menu trunk/meta/xdg-utils/xdg-open Log: Serious obfuscation for shrinkage in the xdg-utils scripts. Possibly broken. Modified: trunk/meta/xdg-utils/xdg-desktop-menu =================================================================== --- trunk/meta/xdg-utils/xdg-desktop-menu 2008-02-13 11:24:47 UTC (rev 486) +++ trunk/meta/xdg-utils/xdg-desktop-menu 2008-02-14 00:42:30 UTC (rev 487) @@ -1,644 +1,59 @@ #!/bin/sh -#--------------------------------------------- -# xdg-desktop-menu -# -# Utility script to install menu items on a Linux desktop. -# Refer to the usage() function below for usage. -# -# Copyright 2006, Kevin Krammer -# Copyright 2006, Jeremy White -# -# LICENSE: -# -# 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. -# -#--------------------------------------------- - -manualpage() +#(obfuscated to shrink download size by ryan.) +#Copyright 2006, Kevin Krammer +#Copyright 2006, Jeremy White +#LICENSE: +#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. +f1() { -cat << _MANUALPAGE -Name - -xdg-desktop-menu - command line tool for (un)installing desktop menu items - -Synopsis - -xdg-desktop-menu install [--noupdate] [--novendor] [--mode mode] directory-file -(s) desktop-file(s) - -xdg-desktop-menu uninstall [--noupdate] [--mode mode] directory-file(s) -desktop-file(s) - -xdg-desktop-menu forceupdate [--mode mode] - -xdg-desktop-menu { --help | --manual | --version } - -Description - -The xdg-desktop-menu program can be used to install new menu entries to the -desktop's application menu. - -The application menu works according to the XDG Desktop Menu Specification at -http://www.freedesktop.org/Standards/menu-spec - -Commands - -install - - Install one or more applications in a submenu of the desktop menu system. - - desktop-file: A desktop file represents a single menu entry in the menu. - Desktop files are defined by the freedesktop.org Desktop Entry - Specification. The most important aspects of *.desktop files are summarized - below. - - Menu entries can be added to the menu system in two different ways. They - can either be added to a predefined submenu in the menu system based on one - or more category keywords, or they can be added to a new submenu. - - To add a menu entry to a predefined submenu the desktop file that - represents the menu entry must have a Categories= entry that lists one or - more keywords. The menu item will be included in an appropriate submenu - based on the included keywords. - - To add menu items to a new submenu the desktop-files must be preceded by a - directory-file that describes the submenu. If multiple desktop-files are - specified, all entries will be added to the same menu. If entries are - installed to a menu that has been created with a previous call to - xdg-desktop-menu the entries will be installed in addition to any already - existing entries. - - directory-file: The *.directory file indicated by directory-file represents - a submenu. The directory file provides the name and icon for a submenu. The - name of the directory file is used to identify the submenu. - - If multiple directory files are provided each file will represent a submenu - within the menu that preceeds it, creating a nested menu hierarchy - (sub-sub-menus). The menu entries themselves will be added to the last - submenu. - - Directory files follow the syntax defined by the freedesktop.org Desktop - Entry Specification. - -uninstall - - Remove applications or submenus from the desktop menu system previously - installed with xdg-desktop-menu install. - - A submenu and the associated directory file is only removed when the - submenu no longer contains any menu entries. - -forceupdate - - Force an update of the menu system. - - This command is only useful if the last call to xdg-desktop-menu included - the --noupdate option. - -Options - ---noupdate - Postpone updating the menu system. If multiple updates to the menu system - are made in sequence this flag can be used to indicate that additional - changes will follow and that it is not necassery to update the menu system - right away. ---novendor - - Normally, xdg-desktop-menu checks to ensure that any *.directory and - *.desktop files to be installed has a vendor prefix. This option can be - used to disable that check. - - A vendor prefix consists of alpha characters ([a-zA-Z]) and is terminated - with a dash ("-"). Companies and organizations are encouraged to use a word - or phrase, preferably the organizations name, for which they hold a - trademark as their vendor prefix. The purpose of the vendor prefix is to - prevent name conflicts. - ---mode mode - - mode can be user or system. In user mode the file is (un)installed for the - current user only. In system mode the file is (un)installed for all users - on the system. Usually only root is allowed to install in system mode. - - The default is to use system mode when called by root and to use user mode - when called by a non-root user. - ---help - Show command synopsis. ---manual - Show this manualpage. ---version - Show the xdg-utils version information. - -Desktop Files - -An application item in the application menu is represented by a *.desktop file. -A *.desktop file consists of a [Desktop Entry] header followed by several Key= -Value lines. - -A *.desktop file can provide a name and description for an application in -several different languages. This is done by adding a language code as used by -LC_MESSAGES in square brackets behind the Key. This way one can specify -different values for the same Key depending on the currently selected language. - -The following keys are often used: - -Value=1.0 - This is a mandatory field to indicate that the *.desktop file follows the - 1.0 version of the specification. -Type=Application - This is a mandatory field that indicates that the *.desktop file describes - an application launcher. -Name=Application Name - The name of the application. For example Mozilla -GenericName=Generic Name - A generic description of the application. For example Web Browser -Comment=Comment - Optional field to specify a tooltip for the application. For example Visit - websites on the Internet -Icon=Icon File - The icon to use for the application. This can either be an absolute path to - an image file or an icon-name. If an icon-name is provided an image lookup - by name is done in the user's current icon theme. The xdg-icon-resource - command can be used to install image files into icon themes. The advantage - of using an icon-name instead of an absolute path is that with an icon-name - the application icon can be provided in several different sizes as well as - in several differently themed styles. -Exec=Command Line - The command line to start the application. If the application can open - files the %f placeholder should be specified. When a file is dropped on the - application launcher the %f is replaced with the file path of the dropped - file. If multiple files can be specified on the command line the %F - placeholder should be used instead of %f. If the application is able to - open URLs in addition to local files then %u or %U can be used instead of - %f or %F. -Categories=Categories - - A list of categories separated by semi-colons. A category is a keyword that - describes and classifies the application. By default applications are - organized in the application menu based on category. When menu entries are - explicitly assigned to a new submenu it is not necassery to list any - categories. - - When using categories it is recommended to include one of the following - categories: AudioVideo, Development, Education, Game, Graphics, Network, - Office, Settings, System, Utility. - - See Appendix A of the XDG Desktop Menu Specification for information about - additional categories. http://standards.freedesktop.org/menu-spec/ - menu-spec-1.0.html - -MimeType=Mimetypes - A list of mimetypes separated by semi-colons. This field is used to - indicate which file types the application is able to open. - -For a complete oveview of the *.desktop file format please visit http:// -www.freedesktop.org/wiki/Standards/desktop-entry-spec - -Directory Files - -The appearance of submenu in the application menu is provided by a *.directory -file. In particular it provides the title of the submenu and a possible icon. A -*.directory file consists of a [Desktop Entry] header followed by several Key= -Value lines. - -A *.directory file can provide a title (name) for the submenu in several -different languages. This is done by adding a language code as used by -LC_MESSAGES in square brackets behind the Key. This way one can specify -different values for the same Key depending on the currently selected language. - -The following keys are relevqnt for submenus: - -Value=1.0 - This is a mandatory field to indicate that the *.directory file follows the - 1.0 version of the Desktop Entry specification. -Type=Directory - This is a mandatory field that indicates that the *.directory file - describes a submenu. -Name=Menu Name - The title of submenu. For example Mozilla -Comment=Comment - Optional field to specify a tooltip for the submenu. -Icon=Icon File - The icon to use for the submenu. This can either be an absolute path to an - image file or an icon-name. If an icon-name is provided an image lookup by - name is done in the user's current icon theme. The xdg-icon-resource - command can be used to install image files into icon themes. The advantage - of using an icon-name instead of an absolute path is that with an icon-name - the submenu icon can be provided in several different sizes as well as in - several differently themed styles. - -Environment Variables - -xdg-desktop-menu honours the following environment variables: - -XDG_UTILS_DEBUG_LEVEL - Setting this environment variable to a non-zero numerical value makes - xdg-desktop-menu do more verbose reporting on stderr. Setting a higher - value increases the verbosity. -XDG_UTILS_INSTALL_MODE - This environment variable can be used by the user or administrator to - override the installation mode. Valid values are user and system. - -Exit Codes - -An exit code of 0 indicates success while a non-zero exit code indicates -failure. The following failure codes can be returned: - -1 - Error in command line syntax. -2 - One of the files passed on the command line did not exist. -3 - A required tool could not be found. -4 - The action failed. -5 - No permission to read one of the files passed on the command line. - -See Also - -xdg-desktop-icon(1), xdg-icon-resource(1), xdg-mime(1) - -Examples - -The company ShinyThings Inc. has developed an application named "WebMirror" and -would like to add it to the application menu. The company will use -"shinythings" as its vendor id. In order to add the application to the menu -there needs to be a .desktop file with a suitable Categories entry: - -shinythings-webmirror.desktop: - - [Desktop Entry] - Encoding=UTF-8 - Type=Application - - Exec=webmirror - Icon=webmirror - - Name=WebMirror - Name[nl]=WebSpiegel - - Categories=Network;WebDevelopment; - -Now the xdg-desktop-menu tool can be used to add the -shinythings-webmirror.desktop file to the desktop application menu: - -xdg-desktop-menu install ./shinythings-webmirror.desktop - -Note that for the purpose of this example the menu items are available in two -languages, English and Dutch. The language code for Dutch is nl. - -In the next example the company ShinyThings Inc. will add its own submenu to -the desktop application menu consisting of a "WebMirror" menu item and a -"WebMirror Admin Tool" menu item. - -First the company needs to create two .desktop files that describe the two menu -items. Since the items are to be added to a new submenu it is not necassery to -include a Categories= line: - -shinythings-webmirror.desktop: - - [Desktop Entry] - Encoding=UTF-8 - Type=Application - - Exec=webmirror - Icon=shinythings-webmirror - - Name=WebMirror - Name[nl]=WebSpiegel - - -shinythings-webmirror-admin.desktop: - - [Desktop Entry] - Encoding=UTF-8 - Type=Application - - Exec=webmirror-admintool - Icon=shinythings-webmirror-admintool - - Name=WebMirror Admin Tool - Name[nl]=WebSpiegel Administratie Tool - -In addition a .directory file needs to be created to provide a title and icon -for the sub-menu itself: - -shinythings-webmirror.directory: - - [Desktop Entry] - Encoding=UTF-8 - - Icon=shinythings-webmirror-menu - - Name=WebMirror - Name[nl]=WebSpiegel - -These file can now be installed with: - -xdg-desktop-menu install ./shinythings-webmirror.directory \ - ./shinythings-webmirror.desktop ./shinythings-webmirror-admin.desktop - -The menu entries could also be installed one by one: - -xdg-desktop-menu install --noupdate ./shinythings-webmirror.directory \ - ./shinythings-webmirror.desktop -xdg-desktop-menu install --noupdate ./shinythings-webmirror.directory \ - ./shinythings-webmirror-admin.desktop -xdg-desktop-menu forceupdate - -Although the result is the same it is slightly more efficient to install all -files at the same time. - -The *.desktop and *.directory files reference icons with the names webmirror, -webmirror-admin and webmirror-menu which should also be installed. In this -example the icons are installed in two different sizes, once with a size of -22x22 pixels and once with a size of 64x64 pixels: - -xdg-icon-resource install --size 22 ./wmicon-22.png shinythings-webmirror -xdg-icon-resource install --size 22 ./wmicon-menu-22.png shinythings-webmirror-menu -xdg-icon-resource install --size 22 ./wmicon-admin-22.png shinythings-webmirror-admin -xdg-icon-resource install --size 64 ./wmicon-64.png shinythings-webmirror -xdg-icon-resource install --size 64 ./wmicon-menu-64.png shinythings-webmirror-menu -xdg-icon-resource install --size 64 ./wmicon-admin-64.png shinythings-webmirror-admin - -_MANUALPAGE +if [ ! -e "$1" ]; then +exit 2 +fi +if [ ! -r "$1" ]; then +exit 5 +fi } - -usage() +f2() { -cat << _USAGE -xdg-desktop-menu - command line tool for (un)installing desktop menu items - -Synopsis - -xdg-desktop-menu install [--noupdate] [--novendor] [--mode mode] directory-file -(s) desktop-file(s) - -xdg-desktop-menu uninstall [--noupdate] [--mode mode] directory-file(s) -desktop-file(s) - -xdg-desktop-menu forceupdate [--mode mode] - -xdg-desktop-menu { --help | --manual | --version } - -_USAGE +aa="$2" +[ -n "$aa" ] || aa="filename" +ab=`basename "$1"` +case "$ab" in +[a-zA-Z]*-*) +return +;; +esac +exit 1 } - -#@xdg-utils-common@ - -#---------------------------------------------------------------------------- -# Common utility functions included in all XDG wrapper scripts -#---------------------------------------------------------------------------- - -DEBUG() +ac=" > /dev/null 2> /dev/null" +f3() { - [ -z "${XDG_UTILS_DEBUG_LEVEL}" ] && return 0; - [ ${XDG_UTILS_DEBUG_LEVEL} -lt $1 ] && return 0; - shift - echo "$@" >&2 -} - -#------------------------------------------------------------- -# Exit script on successfully completing the desired operation - -exit_success() -{ - if [ $# -gt 0 ]; then - echo "$@" - echo - fi - - exit 0 -} - - -#----------------------------------------- -# Exit script on malformed arguments, not enough arguments -# or missing required option. -# prints usage information - -exit_failure_syntax() -{ - if [ $# -gt 0 ]; then - echo "xdg-desktop-menu: $@" >&2 - echo "Try 'xdg-desktop-menu --help' for more information." >&2 - else - usage - echo "Use 'man xdg-desktop-menu' or 'xdg-desktop-menu --manual' for additional info." - fi - - exit 1 -} - -#------------------------------------------------------------- -# Exit script on missing file specified on command line - -exit_failure_file_missing() -{ - if [ $# -gt 0 ]; then - echo "xdg-desktop-menu: $@" >&2 - fi - - exit 2 -} - -#------------------------------------------------------------- -# Exit script on failure to locate necessary tool applications - -exit_failure_operation_impossible() -{ - if [ $# -gt 0 ]; then - echo "xdg-desktop-menu: $@" >&2 - fi - - exit 3 -} - -#------------------------------------------------------------- -# Exit script on failure returned by a tool application - -exit_failure_operation_failed() -{ - if [ $# -gt 0 ]; then - echo "xdg-desktop-menu: $@" >&2 - fi - - exit 4 -} - -#------------------------------------------------------------ -# Exit script on insufficient permission to read a specified file - -exit_failure_file_permission_read() -{ - if [ $# -gt 0 ]; then - echo "xdg-desktop-menu: $@" >&2 - fi - - exit 5 -} - -#------------------------------------------------------------ -# Exit script on insufficient permission to read a specified file - -exit_failure_file_permission_write() -{ - if [ $# -gt 0 ]; then - echo "xdg-desktop-menu: $@" >&2 - fi - - exit 6 -} - -check_input_file() -{ - if [ ! -e "$1" ]; then - exit_failure_file_missing "file '$1' does not exist" - fi - if [ ! -r "$1" ]; then - exit_failure_file_permission_read "no permission to read file '$1'" - fi -} - -check_vendor_prefix() -{ - file_label="$2" - [ -n "$file_label" ] || file_label="filename" - file=`basename "$1"` - case "$file" in - [a-zA-Z]*-*) - return - ;; - esac - - echo "xdg-desktop-menu: $file_label '$file' does not have a proper vendor prefix" >&2 - echo 'A vendor prefix consists of alpha characters ([a-zA-Z]) and is terminated' >&2 - echo 'with a dash ("-"). An example '"$file_label"' is '"'example-$file'" >&2 - echo "Use --novendor to override or 'xdg-desktop-menu --manual' for additional info." >&2 - exit 1 -} - -check_output_file() -{ - # if the file exists, check if it is writeable - # if it does not exists, check if we are allowed to write on the directory - if [ -e "$1" ]; then - if [ ! -w "$1" ]; then - exit_failure_file_permission_write "no permission to write to file '$1'" - fi - else - DIR=`dirname "$1"` - if [ ! -w "$DIR" -o ! -x "$DIR" ]; then - exit_failure_file_permission_write "no permission to create file '$1'" - fi - fi -} - -#---------------------------------------- -# Checks for shared commands, e.g. --help - -check_common_commands() -{ - while [ $# -gt 0 ] ; do - parm="$1" - shift - - case "$parm" in - --help) - usage - echo "Use 'man xdg-desktop-menu' or 'xdg-desktop-menu --manual' for additional info." - exit_success - ;; - - --manual) - manualpage - exit_success - ;; - - --version) - echo "xdg-desktop-menu 1.0.1" - exit_success - ;; - esac - done -} - -check_common_commands "$@" - -[ -z "${XDG_UTILS_DEBUG_LEVEL}" ] && unset XDG_UTILS_DEBUG_LEVEL; -if [ ${XDG_UTILS_DEBUG_LEVEL-0} -lt 1 ]; then - # Be silent - xdg_redirect_output=" > /dev/null 2> /dev/null" -else - # All output to stderr - xdg_redirect_output=" >&2" +if [ "$as" = "system" ] ; then +for x in `echo $PATH | sed 's/:/ /g'` /opt/gnome/bin; do +if [ -x $x/update-desktop-database ] ; then +eval '$x/update-desktop-database'$ac +return fi - -#-------------------------------------- -# Checks for known desktop environments -# set variable DE to the desktop environments name, lowercase - -detectDE() -{ - if [ x"$KDE_FULL_SESSION" = x"true" ]; then DE=kde; - elif [ x"$GNOME_DESKTOP_SESSION_ID" != x"" ]; then DE=gnome; - elif xprop -root _DT_SAVE_MODE | grep ' = \"xfce4\"$' >/dev/null 2>&1; then DE=xfce; - fi +done +fi } - -#---------------------------------------------------------------------------- -# kfmclient exec/openURL can give bogus exit value in KDE <= 3.5.4 -# It also always returns 1 in KDE 3.4 and earlier -# Simply return 0 in such case - -kfmclient_fix_exit_code() +f4() { - version=`kde-config --version 2>/dev/null | grep KDE` - major=`echo $version | sed 's/KDE: \([0-9]\).*/\1/'` - minor=`echo $version | sed 's/KDE: [0-9]*\.\([0-9]\).*/\1/'` - release=`echo $version | sed 's/KDE: [0-9]*\.[0-9]*\.\([0-9]\).*/\1/'` - test "$major" -gt 3 && return $1 - test "$minor" -gt 5 && return $1 - test "$release" -gt 4 && return $1 - return 0 -} - -update_desktop_database() -{ -# echo Update desktop database: $mode - if [ "$mode" = "system" ] ; then - for x in `echo $PATH | sed 's/:/ /g'` /opt/gnome/bin; do - if [ -x $x/update-desktop-database ] ; then - DEBUG 1 "Running $x/update-desktop-database" - eval '$x/update-desktop-database'$xdg_redirect_output - return - fi - done - fi -} - -fixup_mandriva_categories() -{ - DEBUG 1 "fixup_mandriva_categories $1" - awk ' +awk ' BEGIN { xlat["AudioVideo"]="X-Mandrakelinux-Multimedia;X-MandrivaLinux-Multimedia" xlat["Development"]="X-Mandrakelinux-MoreApplications-Development;X-MandrivaLinux-MoreApplications-Development" @@ -651,614 +66,469 @@ xlat["Utility"]="X-Mandrakelinux-Office-Accessories;X-MandrivaLinux-Office-Accessories" } { - if (match($0,/Categories=/)) { - split(substr($0,RSTART+11),categories,";") - result="" - for (n in categories) - { - if (categories[n] in xlat) - categories[n]=categories[n] ";" xlat[categories[n]] - if (categories[n]) - result=result categories[n] ";" - } - print "Categories=" result - } - else - { - print $0 - } +if (match($0,/Categories=/)) { +split(substr($0,RSTART+11),categories,";") +result="" +for (n in categories) +{ +if (categories[n] in xlat) +categories[n]=categories[n] ";" xlat[categories[n]] +if (categories[n]) +result=result categories[n] ";" +} +print "Categories=" result +} +else +{ +print $0 +} }' $1 > $1.new - mv $1.new $1 +mv $1.new $1 } - -# Make application $1/$2 the default for all the mimetypes it support, -# iff such mimetype didn't had a default application already. -# $1 Install dir for desktop file -# $2 base name of desktop file -make_lazy_default() +f5() { - local mimetypes - local xdg_user_dir - local xdg_default_dirs - - DEBUG 1 "make_lazy_default $1/$2" - mimetypes=`awk ' +local ad +local ae +local af +ad=`awk ' { - if (match($0,/MimeType=/)) { - split(substr($0,RSTART+9),mimetypes,";") - for (n in mimetypes) - { - if (mimetypes[n]) - print mimetypes[n] - } - } +if (match($0,/MimeType=/)) { +split(substr($0,RSTART+9),mimetypes,";") +for (n in mimetypes) +{ +if (mimetypes[n]) +print mimetypes[n] +} +} }' "$1/$2" 2> /dev/null` - - for MIME in $mimetypes ; do - xdg_default_dirs="$XDG_DATA_DIRS" - [ -n "$xdg_default_dirs" ] || xdg_default_dirs=/usr/local/share/:/usr/share/ - if [ x"$mode" = x"user" ] ; then - xdg_user_dir="$XDG_DATA_HOME" - [ -n "$xdg_user_dir" ] || xdg_user_dir="$HOME/.local/share" - xdg_default_dirs="$xdg_user_dir:$xdg_default_dirs" - fi - local default_app - for x in `echo "$xdg_default_dirs" | sed 's/:/ /g'`; do - DEBUG 2 "Checking $x/applications/defaults.list" - default_app=`grep "$MIME=" $x/applications/defaults.list 2> /dev/null | cut -d '=' -f 2` - if [ -n "$default_app" ] ; then - DEBUG 2 "Found default apps for $MIME: $default_app" - default_app="$default_app;" - break; - fi - done - DEBUG 2 "Current default apps for $MIME: $default_app" - if echo "$default_app" | grep "$2" > /dev/null 2> /dev/null; then - # App already listed as default - continue; - fi - default_file="$1/defaults.list" - DEBUG 1 "Updating $default_file" - grep -v "$MIME=" $default_file > ${default_file}.new 2> /dev/null - if ! grep "[Default Applications]" ${default_file}.new > /dev/null; then - echo "[Default Applications]" >> ${default_file}.new - fi - echo $MIME="$default_app$2" >> ${default_file}.new - mv ${default_file}.new $default_file - done +for MIME in $ad ; do +af="$XDG_DATA_DIRS" +[ -n "$af" ] || af=/usr/local/share/:/usr/share/ +if [ x"$as" = x"user" ] ; then +ae="$XDG_DATA_HOME" +[ -n "$ae" ] || ae="$HOME/.local/share" +af="$ae:$af" +fi +local ag +for x in `echo "$af" | sed 's/:/ /g'`; do +ag=`grep "$MIME=" $x/applications/defaults.list 2> /dev/null | cut -d '=' -f 2` +if [ -n "$ag" ] ; then +ag="$ag;" +break; +fi +done +if echo "$ag" | grep "$2" $ac ; then +continue; +fi +aj="$1/defaults.list" +grep -v "$MIME=" $aj > ${aj}.new 2> /dev/null +if ! grep "[Default Applications]" ${aj}.new > /dev/null; then +echo "[Default Applications]" >> ${aj}.new +fi +echo $MIME="$ag$2" >> ${aj}.new +mv ${aj}.new $aj +done } - -update_submenu() +f6() { - DEBUG 1 "update_submenu $1" - menu_file="$1" - - xdg_dir_name=menus - xdg_user_dir="$XDG_CONFIG_HOME" - [ -n "$xdg_user_dir" ] || xdg_user_dir="$HOME/.config" - xdg_user_dir="$xdg_user_dir/$xdg_dir_name" - - xdg_system_dirs="$XDG_CONFIG_DIRS" - [ -n "$xdg_system_dirs" ] || xdg_system_dirs=/etc/xdg - xdg_global_dir= - for x in `echo $xdg_system_dirs | sed 's/:/ /g'` ; do - if [ -w $x/$xdg_dir_name ] ; then - xdg_global_dir="$x/$xdg_dir_name" - break - fi - done - xdg_user_dir="$xdg_user_dir/applications-merged" - xdg_global_dir="$xdg_global_dir/applications-merged" - - DEBUG 3 "Install locations for *.menu file:" - DEBUG 3 "xdg_user_dir: $xdg_user_dir" - DEBUG 3 "xdg_global_dir: $xdg_global_dir" - DEBUG 3 "kde_user_dir: $kde_user_dir" - DEBUG 3 "kde_global_dir: $kde_global_dir" - DEBUG 3 "gnome_user_dir: $gnome_user_dir" - DEBUG 3 "gnome_global_dir: $gnome_global_dir" - - if [ x"$mode" = x"user" ] ; then - xdg_dir="$xdg_user_dir" - kde_dir="$kde_user_dir" - gnome_dir="$gnome_user_dir" - my_umask=077 - my_chmod=0600 - else - xdg_dir="$xdg_global_dir" - kde_dir="$kde_global_dir" - gnome_dir="$gnome_global_dir" - my_umask=022 - my_chmod=0644 - if [ -z "${xdg_dir}${kde_dir}${gnome_dir}" ] ; then - exit_failure_operation_impossible "No writable system menu directory found." - fi - fi - - if [ -z "$menu_file" ] ; then - # Work around for SUSE/gnome 2.12 to pick up new ~/.local/share/applications - save_umask=`umask` - umask $my_umask - - mkdir -p $xdg_dir - touch $xdg_dir/xdg-desktop-menu-dummy.menu - - umask $save_umask - return - fi - - if [ $action = "install" -a -f "/etc/xdg/menus/gnome-applications.menu" ] ; then - # Work around for Debian Gnome - gnome_xdg_dir=`echo "$xdg_dir" | sed -e 's^/applications-merged^/gnome-applications-merged^'` - if [ ! -e "$gnome_xdg_dir" ] ; then - DEBUG 1 "Debian Workaround: Link '$xdg_dir' to '$gnome_xdg_dir'" - mkdir -p `dirname "$gnome_xdg_dir"` - eval 'ln -s "applications-merged" "$gnome_xdg_dir"'$xdg_redirect_output - fi - fi - if [ $action = "install" -a -f "/etc/mandrake-release" ] ; then - # Work around for Mandriva 2006 - mandrake_xdg_dir=`echo "$xdg_dir" | sed -e 's^/applications-merged^/applications-mdk-merged^'` - if [ ! -e "$mandrake_xdg_dir" ] ; then - DEBUG 1 "Mandriva Workaround: Link '$xdg_dir' to '$mandrake_xdg_dir'" - mkdir -p `dirname "$mandrake_xdg_dir"` - eval 'ln -s "applications-merged" "$mandrake_xdg_dir"'$xdg_redirect_output - fi - fi - if [ $action = "install" -a x"$mode" = x"user" -a -d "/etc/xdg/menus/kde-applications-merged" ] ; then - # Work around for Fedora Core 5 + patched KDE - kde_xdg_dir=`echo "$xdg_dir" | sed -e 's^/applications-merged^/kde-applications-merged^'` - if [ ! -e "$kde_xdg_dir" ] ; then - DEBUG 1 "Fedora Workaround: Link '$xdg_dir' to '$kde_xdg_dir'" - mkdir -p `dirname "$kde_xdg_dir"` - eval 'ln -s "applications-merged" "$kde_xdg_dir"'$xdg_redirect_output - fi - fi - if [ $action = "install" -a x"$mode" = x"system" -a -d "/etc/xdg/menus/kde-applications-merged" -a ! -d "/etc/xdg/menus/applications-merged" ] ; then - # Work around for Kubuntu 6.06 - kde_xdg_dir=`echo "$xdg_dir" | sed -e 's^/applications-merged^/kde-applications-merged^'` - DEBUG 1 "Kubuntu Workaround: Link '$xdg_dir' to 'kde-applications-merged'" - eval 'ln -s "kde-applications-merged" "$xdg_dir"'$xdg_redirect_output - fi - - orig_menu_file=$xdg_dir/$menu_file - - DEBUG 1 "Updating $orig_menu_file ($action)" - - test "${TMPDIR+set}" = set || TMPDIR=/tmp - tmpfile=`mktemp $TMPDIR/tmp.XXXXXXXXXX` - orig_desktop_files= - if [ -r "$orig_menu_file" ] ; then - awk ' -# List all files within tags +ah="$1" +ai=menus +ae="$XDG_CONFIG_HOME" +[ -n "$ae" ] || ae="$HOME/.config" +ae="$ae/$ai" +bm="$XDG_CONFIG_DIRS" +[ -n "$bm" ] || bm=/etc/xdg +ak= +for x in `echo $bm | sed 's/:/ /g'` ; do +if [ -w $x/$ai ] ; then +ak="$x/$ai" +break +fi +done +ae="$ae/applications-merged" +ak="$ak/applications-merged" +if [ x"$as" = x"user" ] ; then +ao="$ae" +at="$aw" +au="$av" +ax=077 +ay=0600 +else +ao="$ak" +at="$al" +au="$am" +ax=022 +ay=0644 +if [ -z "${ao}${at}${au}" ] ; then +exit 3 +fi +fi +if [ -z "$ah" ] ; then +bo=`umask` +umask $ax +mkdir -p $ao +touch $ao/xdg-desktop-menu-dummy.menu +umask $bo +return +fi +if [ $be = "install" -a -f "/etc/xdg/menus/gnome-applications.menu" ] ; then +aq=`echo "$ao" | sed -e 's^/applications-merged^/gnome-applications-merged^'` +if [ ! -e "$aq" ] ; then +mkdir -p `dirname "$aq"` +eval 'ln -s "applications-merged" "$aq"'$ac +fi +fi +if [ $be = "install" -a -f "/etc/mandrake-release" ] ; then +ar=`echo "$ao" | sed -e 's^/applications-merged^/applications-mdk-merged^'` +if [ ! -e "$ar" ] ; then +mkdir -p `dirname "$ar"` +eval 'ln -s "applications-merged" "$ar"'$ac +fi +fi +if [ $be = "install" -a x"$as" = x"user" -a -d "/etc/xdg/menus/kde-applications-merged" ] ; then +ap=`echo "$ao" | sed -e 's^/applications-merged^/kde-applications-merged^'` +if [ ! -e "$ap" ] ; then +mkdir -p `dirname "$ap"` +eval 'ln -s "applications-merged" "$ap"'$ac +fi +fi +if [ $be = "install" -a x"$as" = x"system" -a -d "/etc/xdg/menus/kde-applications-merged" -a ! -d "/etc/xdg/menus/applications-merged" ] ; then +ap=`echo "$ao" | sed -e 's^/applications-merged^/kde-applications-merged^'` +eval 'ln -s "kde-applications-merged" "$ao"'$ac +fi +bp=$ao/$ah +test "${TMPDIR+set}" = set || TMPDIR=/tmp +az=`mktemp $TMPDIR/tmp.XXXXXXXXXX` +bi= +if [ -r "$bp" ] ; then +awk ' BEGIN { RS="<" } /^Filename/ { - if (match($0,/>/)) { - print substr($0,RSTART+1) - } -}' $orig_menu_file > $tmpfile - fi - - orig_desktop_files=`cat $tmpfile` - new_desktop_files= - if [ $action = "install" ] ; then - for desktop_file in $desktop_files; do - basefile=`basename $desktop_file` - if ! grep '^'$basefile'$' $tmpfile > /dev/null 2> /dev/null ; then - # Append - echo "$basefile" >> $tmpfile - fi - done - new_desktop_files=`cat $tmpfile` - fi - if [ $action = "uninstall" ] ; then - echo > $tmpfile - for desktop_file in $desktop_files; do - echo "$desktop_file" >> $tmpfile - done - # Files to uninstall are listed in $tmpfile - # Existing files are in $orig_desktop_files - for desktop_file in $orig_desktop_files; do - if ! grep '^'$desktop_file'$' $tmpfile > /dev/null 2> /dev/null; then - # Keep this file, it's not in the uninstall list - new_desktop_files="$new_desktop_files $desktop_file" - fi - done - fi - rm -f "$tmpfile" - - DEBUG 3 "Files to list in $menu_file: $new_desktop_files" - - if [ -n "$new_desktop_files" ] ; then - # Install/update - test "${TMPDIR+set}" = set || TMPDIR=/tmp - tmpfile=`mktemp $TMPDIR/tmp.XXXXXXXXXX` - ( - echo '' - echo '' - echo '' - echo ' Applications' - - for desktop_file in $directory_files; do - basefile=`basename $desktop_file` - basefilename=`echo "$basefile"|cut -d '.' -f 1` - echo "" - echo " $basefilename" - echo " $basefile" - done - - echo " " - for desktop_file in $new_desktop_files; do - echo " $desktop_file" - done - echo " " - - for desktop_file in $directory_files; do - echo "" - done - - echo '' - ) > $tmpfile - chmod $my_chmod $tmpfile - - save_umask=`umask` - umask $my_umask - - mkdir -p $xdg_dir - eval 'cp $tmpfile $xdg_dir/$menu_file'$xdg_redirect_output - - umask $save_umask - rm -f "$tmpfile" - else - # Uninstall - rm -f $xdg_dir/$menu_file - fi - - # Uninstall .directory files only if no longer referenced - if [ $action = "uninstall" ] ; then - test "${TMPDIR+set}" = set || TMPDIR=/tmp - tmpfile=`mktemp $TMPDIR/tmp.XXXXXXXXXX` - for menu_file in $xdg_dir/*; do - if grep 'generated and managed by xdg-desktop-menu' $menu_file > /dev/null 2> /dev/null; then - awk ' -# List all files within tags +if (match($0,/>/)) { +print substr($0,RSTART+1) +} +}' $bp > $az +fi +bi=`cat $az` +bj= +if [ $be = "install" ] ; then +for bl in $bk; do +bc=`basename $bl` +if ! grep '^'$bc'$' $az $ac ; then +echo "$bc" >> $az +fi +done +bj=`cat $az` +fi +if [ $be = "uninstall" ] ; then +echo > $az +for bl in $bk; do +echo "$bl" >> $az +done +for bl in $bi; do +if ! grep '^'$bl'$' $az $ac ; then +bj="$bj $bl" +fi +done +fi +rm -f "$az" +if [ -n "$bj" ] ; then +test "${TMPDIR+set}" = set || TMPDIR=/tmp +az=`mktemp $TMPDIR/tmp.XXXXXXXXXX` +( +echo '' +echo '' +echo '' +echo ' Applications' +for bl in $bg; do +bc=`basename $bl` +bb=`echo "$bc"|cut -d '.' -f 1` +echo "" +echo " $bb" +echo " $bc" +done +echo " " +for bl in $bj; do +echo " $bl" +done +echo " " +for bl in $bg; do +echo "" +done +echo '' +) > $az +chmod $ay $az +bo=`umask` +umask $ax +mkdir -p $ao +eval 'cp $az $ao/$ah'$ac +umask $bo +rm -f "$az" +else +rm -f $ao/$ah +fi +if [ $be = "uninstall" ] ; then +test "${TMPDIR+set}" = set || TMPDIR=/tmp +az=`mktemp $TMPDIR/tmp.XXXXXXXXXX` +for ah in $ao/*; do +if grep 'generated and managed by xdg-desktop-menu' $ah $ac ; then +awk ' BEGIN { RS="<" } /^Directory/ { - if (match($0,/>/)) { - print substr($0,RSTART+1) - } -}' $menu_file >> $tmpfile - fi - done - orig_directory_files="$directory_files" - directory_files= - for desktop_file in $orig_directory_files; do - if ! grep '^'$desktop_file'$' $tmpfile > /dev/null 2> /dev/null; then - # No longer in use, safe to delete - directory_files="$directory_files $desktop_file" - fi - done - rm -f "$tmpfile" - fi +if (match($0,/>/)) { +print substr($0,RSTART+1) } - - -[ x"$1" != x"" ] || exit_failure_syntax - -mode= -action= -update=yes -desktop_files= -directory_files= - +}' $ah >> $az +fi +done +bh="$bg" +bg= +for bl in $bh; do +if ! grep '^'$bl'$' $az $ac ; then +bg="$bg $bl" +fi +done +rm -f "$az" +fi +} +[ x"$1" != x"" ] || exit 1 +as= +be= +bd=yes +bk= +bg= case $1 in - install) - action=install - ;; - - uninstall) - action=uninstall - ;; - - forceupdate) - action=forceupdate - ;; - - *) - exit_failure_syntax "unknown command '$1'" - ;; +install) +be=install +;; +uninstall) +be=uninstall +;; +forceupdate) +be=forceupdate +;; +*) +exit 1 +;; esac - shift - -vendor=true +bf=true while [ $# -gt 0 ] ; do - parm="$1" - shift - - case "$parm" in - --noupdate) - update=no - ;; - - --mode) - if [ -z "$1" ] ; then - exit_failure_syntax "mode argument missing for --mode" - fi - case "$1" in - user) - mode="user" - ;; - - system) - mode="system" - ;; - - *) - exit_failure_syntax "unknown mode '$1'" - ;; - esac - shift - ;; - - --novendor) - vendor=false - ;; - - -*) - exit_failure_syntax "unexpected option '$parm'" - ;; - - *) - if [ "$action" = "install" ] ; then - check_input_file "$parm" - fi - case "$parm" in - *.directory) - if [ -n "$desktop_files" ] ; then - exit_failure_syntax "'$parm' must preceed any *.desktop file" - fi - directory_files="$directory_files $parm" - ;; - *.desktop) - desktop_files="$desktop_files $parm" - ;; - *) - exit_failure_syntax "file to $action must be a *.directory or *.desktop file" - ;; - esac - ;; - esac +bn="$1" +shift +case "$bn" in +--noupdate) +bd=no +;; +--mode) +if [ -z "$1" ] ; then +exit 1 +fi +case "$1" in +user) +as="user" +;; +system) +as="system" +;; +*) +exit 1 +;; +esac +shift +;; +--novendor) +bf=false +;; +-*) +exit 1 +;; +*) +if [ "$be" = "install" ] ; then +f1 "$bn" +fi +case "$bn" in +*.directory) +if [ -n "$bk" ] ; then +exit 1 +fi +bg="$bg $bn" +;; +*.desktop) +bk="$bk $bn" +;; +*) +exit 1 +;; +esac +;; +esac done - -# Shouldn't happen -if [ -z "$action" ] ; then - exit_failure_syntax "command argument missing" +if [ -z "$be" ] ; then +exit 1 fi - if [ -n "$XDG_UTILS_INSTALL_MODE" ] ; then - if [ "$XDG_UTILS_INSTALL_MODE" = "system" ] ; then - mode="system" - elif [ "$XDG_UTILS_INSTALL_MODE" = "user" ] ; then - mode="user" - fi +if [ "$XDG_UTILS_INSTALL_MODE" = "system" ] ; then +as="system" +elif [ "$XDG_UTILS_INSTALL_MODE" = "user" ] ; then +as="user" fi - -if [ -z "$mode" ] ; then - if [ `whoami` = "root" ] ; then - mode="system" - else - mode="user" - fi fi - -if [ x"$action" = x"forceupdate" ] ; then - update_desktop_database - exit_success +if [ -z "$as" ] ; then +if [ `whoami` = "root" ] ; then +as="system" +else +as="user" fi - -if [ -z "$desktop_files" ] ; then - exit_failure_syntax "desktop-file argument missing" fi - -menu_name= -for desktop_file in $directory_files; do - if [ "$vendor" = "true" -a "$action" = "install" ] ; then - check_vendor_prefix "$desktop_file" - fi - - basefilename=`basename "$desktop_file"|cut -d '.' -f 1` - if [ -z "$menu_name" ] ; then - menu_name="$basefilename" - else - menu_name="$menu_name-$basefilename" - fi +if [ x"$be" = x"forceupdate" ] ; then +f3 +exit 0 +fi +if [ -z "$bk" ] ; then +exit 1 +fi +ba= +for bl in $bg; do +if [ "$bf" = "true" -a "$be" = "install" ] ; then +f2 "$bl" +fi +bb=`basename "$bl"|cut -d '.' -f 1` +if [ -z "$ba" ] ; then +ba="$bb" +else +ba="$ba-$bb" +fi done - -if [ -n "$menu_name" ] ; then - if [ x"$mode" = x"user" ] ; then - update_submenu "user-$menu_name.menu" - else - update_submenu "$menu_name.menu" - fi +if [ -n "$ba" ] ; then +if [ x"$as" = x"user" ] ; then +f6 "user-$ba.menu" else - # Work around for SUSE/gnome 2.12 to pick up new ~/.local/share/applications - if [ x"$mode" = x"user" ] ; then - update_submenu - fi +f6 "$ba.menu" fi - -# Install *.directory files - -xdg_dir_name=desktop-directories - -xdg_user_dir="$XDG_DATA_HOME" -[ -n "$xdg_user_dir" ] || xdg_user_dir="$HOME/.local/share" -xdg_user_dir="$xdg_user_dir/$xdg_dir_name" - -xdg_system_dirs="$XDG_DATA_DIRS" -[ -n "$xdg_system_dirs" ] || xdg_system_dirs=/usr/local/share/:/usr/share/ -xdg_global_dir= -for x in `echo $xdg_system_dirs | sed 's/:/ /g'` ; do - if [ -w $x/$xdg_dir_name ] ; then - xdg_global_dir="$x/$xdg_dir_name" - break - fi +else +if [ x"$as" = x"user" ] ; then +f6 +fi +fi +ai=desktop-directories +ae="$XDG_DATA_HOME" +[ -n "$ae" ] || ae="$HOME/.local/share" +ae="$ae/$ai" +bm="$XDG_DATA_DIRS" +[ -n "$bm" ] || bm=/usr/local/share/:/usr/share/ +ak= +for x in `echo $bm | sed 's/:/ /g'` ; do +if [ -w $x/$ai ] ; then +ak="$x/$ai" +break +fi done - -DEBUG 3 "Install locations for *.directory files:" -DEBUG 3 "xdg_user_dir: $xdg_user_dir" -DEBUG 3 "xdg_global_dir: $xdg_global_dir" -DEBUG 3 "kde_user_dir: $kde_user_dir" -DEBUG 3 "kde_global_dir: $kde_global_dir" -DEBUG 3 "gnome_user_dir: $gnome_user_dir" -DEBUG 3 "gnome_global_dir: $gnome_global_dir" - -if [ x"$mode" = x"user" ] ; then - xdg_dir="$xdg_user_dir" - kde_dir="$kde_user_dir" - gnome_dir="$gnome_user_dir" - my_umask=077 +if [ x"$as" = x"user" ] ; then +ao="$ae" +at="$aw" +au="$av" +ax=077 else - xdg_dir="$xdg_global_dir" - kde_dir="$kde_global_dir" - gnome_dir="$gnome_global_dir" - my_umask=022 - if [ -z "${xdg_dir}${kde_dir}${gnome_dir}" ] ; then - exit_failure_operation_impossible "No writable system menu directory found." - fi +ao="$ak" +at="$al" +au="$am" +ax=022 +if [ -z "${ao}${at}${au}" ] ; then +exit 3 fi - -for desktop_file in $directory_files; do - basefile=`basename $desktop_file` - - DEBUG 1 "$action $desktop_file in $xdg_dir $kde_dir $gnome_dir" - - case $action in - install) - save_umask=`umask` - umask $my_umask - - for x in $xdg_dir $kde_dir $gnome_dir ; do - mkdir -p $x - eval 'cp $desktop_file $x/$basefile'$xdg_redirect_output - done - - umask $save_umask - ;; - - uninstall) - for x in $xdg_dir $kde_dir $gnome_dir ; do - rm -f $x/$basefile - done - - ;; - esac +fi +for bl in $bg; do +bc=`basename $bl` +case $be in +install) +bo=`umask` +umask $ax +for x in $ao $at $au ; do +mkdir -p $x +eval 'cp $bl $x/$bc'$ac done - -# Install *.desktop files -xdg_dir_name=applications - -xdg_user_dir="$XDG_DATA_HOME" -[ -n "$xdg_user_dir" ] || xdg_user_dir="$HOME/.local/share" -xdg_user_dir="$xdg_user_dir/$xdg_dir_name" - -xdg_system_dirs="$XDG_DATA_DIRS" -[ -n "$xdg_system_dirs" ] || xdg_system_dirs=/usr/local/share/:/usr/share/ -xdg_global_dir= -for x in `echo $xdg_system_dirs | sed 's/:/ /g'` ; do - if [ -w $x/$xdg_dir_name ] ; then - xdg_global_dir="$x/$xdg_dir_name" - break - fi +umask $bo +;; +uninstall) +for x in $ao $at $au ; do +rm -f $x/$bc done - -kde_user_dir="$HOME/.kde/share/applnk" -kde_global_dir="/usr/share/applnk" -[ -w $kde_global_dir ] || kde_global_dir= - -gnome_user_dir="$HOME/.gnome/apps" -gnome_global_dir="/usr/share/gnome/apps" -[ -w $gnome_global_dir ] || gnome_global_dir= - -[ -f /etc/mandriva-release ] && need_mandriva_fix=true -[ -n "$need_mandriva_fix" ] && DEBUG 1 "Fixing up .desktop categories (Mandriva work around)" - -DEBUG 3 "Install locations for *.desktop files:" -DEBUG 3 "xdg_user_dir: $xdg_user_dir" -DEBUG 3 "xdg_global_dir: $xdg_global_dir" -DEBUG 3 "kde_user_dir: $kde_user_dir" -DEBUG 3 "kde_global_dir: $kde_global_dir" -DEBUG 3 "gnome_user_dir: $gnome_user_dir" -DEBUG 3 "gnome_global_dir: $gnome_global_dir" - -if [ x"$mode" = x"user" ] ; then - xdg_dir="$xdg_user_dir" - kde_dir="$kde_user_dir" - gnome_dir="$gnome_user_dir" - my_umask=077 +;; +esac +done +ai=applications +ae="$XDG_DATA_HOME" +[ -n "$ae" ] || ae="$HOME/.local/share" +ae="$ae/$ai" +bm="$XDG_DATA_DIRS" +[ -n "$bm" ] || bm=/usr/local/share/:/usr/share/ +ak= +for x in `echo $bm | sed 's/:/ /g'` ; do +if [ -w $x/$ai ] ; then +ak="$x/$ai" +break +fi +done +aw="$HOME/.kde/share/applnk" +al="/usr/share/applnk" +[ -w $al ] || al= +av="$HOME/.gnome/apps" +am="/usr/share/gnome/apps" +[ -w $am ] || am= +[ -f /etc/mandriva-release ] && an=true +if [ x"$as" = x"user" ] ; then +ao="$ae" +at="$aw" +au="$av" +ax=077 else - xdg_dir="$xdg_global_dir" - kde_dir="$kde_global_dir" - gnome_dir="$gnome_global_dir" - my_umask=022 - if [ -z "${xdg_dir}${kde_dir}${gnome_dir}" ] ; then - exit_failure_operation_impossible "No writable system menu directory found." - fi +ao="$ak" +at="$al" +au="$am" +ax=022 +if [ -z "${ao}${at}${au}" ] ; then +exit 3 fi - -for desktop_file in $desktop_files; do - if [ "$vendor" = "true" -a "$action" = "install" ] ; then - check_vendor_prefix "$desktop_file" - fi - - basefile=`basename $desktop_file` - - DEBUG 1 "$action $desktop_file in $xdg_dir $kde_dir $gnome_dir" - - case $action in - install) - save_umask=`umask` - umask $my_umask - - for x in $xdg_dir $kde_dir $gnome_dir ; do - mkdir -p $x - eval 'cp $desktop_file $x/$basefile'$xdg_redirect_output - done - - if [ -n "$need_mandriva_fix" ] ; then - fixup_mandriva_categories $xdg_dir/$basefile - fi - - if [ -f $kde_dir/$basefile ] ; then - echo "OnlyShowIn=Old;" >> $kde_dir/$basefile - fi - - if [ -f $gnome_dir/$basefile ] ; then - echo "OnlyShowIn=Old;" >> $gnome_dir/$basefile - fi - - make_lazy_default "$xdg_dir" "$basefile" - - umask $save_umask - ;; - - uninstall) - for x in $xdg_dir $kde_dir $gnome_dir ; do - rm -f $x/$basefile - done - - ;; - esac +fi +for bl in $bk; do +if [ "$bf" = "true" -a "$be" = "install" ] ; then +f2 "$bl" +fi +bc=`basename $bl` +case $be in +install) +bo=`umask` +umask $ax +for x in $ao $at $au ; do +mkdir -p $x +eval 'cp $bl $x/$bc'$ac done - -if [ x"$update" = x"yes" ] ; then - update_desktop_database +if [ -n "$an" ] ; then +f4 $ao/$bc fi - -exit_success +if [ -f $at/$bc ] ; then +echo "OnlyShowIn=Old;" >> $at/$bc +fi +if [ -f $au/$bc ] ; then +echo "OnlyShowIn=Old;" >> $au/$bc +fi +f5 "$ao" "$bc" +umask $bo +;; +uninstall) +for x in $ao $at $au ; do +rm -f $x/$bc +done +;; +esac +done +if [ x"$bd" = x"yes" ] ; then +f3 +fi +exit 0 Modified: trunk/meta/xdg-utils/xdg-open =================================================================== --- trunk/meta/xdg-utils/xdg-open 2008-02-13 11:24:47 UTC (rev 486) +++ trunk/meta/xdg-utils/xdg-open 2008-02-14 00:42:30 UTC (rev 487) @@ -1,27 +1,23 @@ #!/bin/sh -# (obfuscated for size by shrinksh.sh) -# Copyright 2006, Kevin Krammer -# Copyright 2006, Jeremy White -# -# LICENSE: -# -# 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. +#(obfuscated for size by shrinksh.sh) +#Copyright 2006, Kevin Krammer +#Copyright 2006, Jeremy White +#LICENSE: +#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. f1() { if [ $# -gt 0 ]; then @@ -42,12 +38,6 @@ { exit 4 } -[ -z "${XDG_UTILS_DEBUG_LEVEL}" ] && unset XDG_UTILS_DEBUG_LEVEL; -if [ ${XDG_UTILS_DEBUG_LEVEL-0} -lt 1 ]; then -xdg_redirect_output=" > /dev/null 2> /dev/null" -else -xdg_redirect_output=" >&2" -fi f5() { if [ x"$KDE_FULL_SESSION" = x"true" ]; then DE=kde; From DONOTREPLY at icculus.org Fri Feb 15 03:50:34 2008 From: DONOTREPLY at icculus.org (DONOTREPLY at icculus.org) Date: 15 Feb 2008 03:50:34 -0500 Subject: r488 - in trunk: . examples/duke3d/scripts scripts Message-ID: <20080215085034.6757.qmail@icculus.org> Author: icculus Date: 2008-02-15 03:50:33 -0500 (Fri, 15 Feb 2008) New Revision: 488 Modified: trunk/docs.txt trunk/examples/duke3d/scripts/config.lua trunk/scripts/mojosetup_mainline.lua Log: Desktop menu item fixes: format command line string to insert Destination dir, don't dereference a nil value in revert if fatal() happens before destination is set. Modified: trunk/docs.txt =================================================================== --- trunk/docs.txt 2008-02-14 00:42:30 UTC (rev 487) +++ trunk/docs.txt 2008-02-15 08:50:33 UTC (rev 488) @@ -760,7 +760,10 @@ commandline (no default, mustExist, mustBeString, cantBeEmpty) This is the command line that will be used to launch the application - when the end user clicks on the desktop menu item. + when the end user clicks on the desktop menu item. The string "%0" is + replaced with the install destination, so if you need an absolute path + to mygame.exe, and the user is installing to /home/user/mygame, you should + specify "%0/mygame.exe" to get "/home/user/mygame/mygame.exe". category (no default, mustExist, mustBeStringOrTableOfStrings) Modified: trunk/examples/duke3d/scripts/config.lua =================================================================== --- trunk/examples/duke3d/scripts/config.lua 2008-02-14 00:42:30 UTC (rev 487) +++ trunk/examples/duke3d/scripts/config.lua 2008-02-15 08:50:33 UTC (rev 488) @@ -78,7 +78,7 @@ tooltip = "Always bet on Duke!", builtin_icon = false, icon = "duke3d.png", -- relative to the dest; you must install it! - commandline = "/home/icculus/duke3d/duke3d", + commandline = "%0/duke3d", category = "Game", }, Modified: trunk/scripts/mojosetup_mainline.lua =================================================================== --- trunk/scripts/mojosetup_mainline.lua 2008-02-14 00:42:30 UTC (rev 487) +++ trunk/scripts/mojosetup_mainline.lua 2008-02-15 08:50:33 UTC (rev 488) @@ -1017,12 +1017,15 @@ local function install_freedesktop_menuitem(pkg, idx, item) -- only for Unix. local icon + local dest = MojoSetup.destination if item.builtin_icon then icon = item.icon else - icon = MojoSetup.destination .. "/" .. item.icon + icon = dest .. "/" .. item.icon end + local cmdline = MojoSetup.format(item.commandline, dest) + local str = "[Desktop Entry]\n" .. "Encoding=UTF-8\n" .. "Value=1.0\n" .. @@ -1031,7 +1034,7 @@ "GenericName=" .. item.genericname .. "\n" .. "Comment=" .. item.tooltip .. "\n" .. "Icon=" .. icon .. "\n" .. - "Exec=" .. item.commandline .. "\n" .. + "Exec=" .. cmdline .. "\n" .. "Categories=" .. flatten_list(item.category) .. "\n" if item.mimetype ~= nil then @@ -1040,16 +1043,16 @@ str = str .. "\n" - local dest = freedesktop_menuitem_filename(pkg, idx) + local fname = freedesktop_menuitem_filename(pkg, idx) local perms = "0644" -- !!! FIXME local key = MojoSetup.metadatakey local desc = MojoSetup.metadatadesc --MojoSetup.logdebug("Install FreeDesktop file") - --MojoSetup.logdebug(dest) + --MojoSetup.logdebug(fname) --MojoSetup.logdebug(str) - install_file_from_string(dest, str, perms, desc, key) - if not MojoSetup.platform.installdesktopmenuitem(dest) then + install_file_from_string(fname, str, perms, desc, key) + if not MojoSetup.platform.installdesktopmenuitem(fname) then MojoSetup.fatal(_("Failed to install desktop menu item")) end end @@ -1101,6 +1104,7 @@ MojoSetup.downloaded = 0 MojoSetup.totaldownload = 0 MojoSetup.install = install + MojoSetup.installed_menu_items = false -- !!! FIXME: try to sanity check everything we can here -- !!! FIXME: (unsupported URLs, bogus media IDs, etc.) @@ -1518,7 +1522,10 @@ end end - install_desktop_menu_items(install) + if install.desktopmenuitems ~= nil then + install_desktop_menu_items(install) + MojoSetup.installed_menu_items = true + end if install.support_uninstall then if MojoSetup.info.platform == "windows" then @@ -1602,6 +1609,7 @@ MojoSetup.downloaddir = nil MojoSetup.install = nil MojoSetup.forceoverwrite = nil + MojoSetup.installed_menu_items = nil MojoSetup.stages = nil MojoSetup.files = nil MojoSetup.media = nil @@ -1620,7 +1628,10 @@ MojoSetup.loginfo("Cleaning up half-finished installation...") -- !!! FIXME: callbacks here. - uninstall_desktop_menu_items(MojoSetup.install) + if MojoSetup.installed_menu_items then + uninstall_desktop_menu_items(MojoSetup.install) + end + delete_files(MojoSetup.downloads) delete_files(flatten_manifest(MojoSetup.manifest, prepend_dest_dir)) do_rollbacks() From DONOTREPLY at icculus.org Fri Feb 15 05:22:21 2008 From: DONOTREPLY at icculus.org (DONOTREPLY at icculus.org) Date: 15 Feb 2008 05:22:21 -0500 Subject: r489 - trunk/scripts Message-ID: <20080215102221.1694.qmail@icculus.org> Author: icculus Date: 2008-02-15 05:22:11 -0500 (Fri, 15 Feb 2008) New Revision: 489 Modified: trunk/scripts/mojosetup_mainline.lua Log: Fixed manifest string. Modified: trunk/scripts/mojosetup_mainline.lua =================================================================== --- trunk/scripts/mojosetup_mainline.lua 2008-02-15 08:50:33 UTC (rev 488) +++ trunk/scripts/mojosetup_mainline.lua 2008-02-15 10:22:11 UTC (rev 489) @@ -59,7 +59,7 @@ ftype = "symlink" -- !!! FIXME: linkdest? elseif MojoSetup.platform.isdir(fullpath) then - ftype = "directory" + ftype = "dir" else -- !!! FIXME: other types? ftype = "file" sums = MojoSetup.checksum(fullpath) @@ -774,6 +774,9 @@ retval = retval .. '\t\t