Changeset 4831
- Timestamp:
- May 18, 2017, 5:14:40 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
devtools/desktop_to_xml/desktop_to_xml.sh
r4693 r4831 4 4 #Download lliurex-artwork-default from svn 5 5 #Download the sources of the package(s) 6 #Execute this script adding the dirs of sources to analyze as parameters6 #Execute this script passing the dirs of sources to analyze as parameters 7 7 #Profit 8 8 … … 30 30 msg_desktop_not_present="\nDesktop file was not found at %s. Operation aborted\n" 31 31 msg_searching_img="\nSearching screenshots in %s...\n" 32 msg_image_found="\nScreenshoot %s f inded for app %s\n"32 msg_image_found="\nScreenshoot %s found for app %s\n" 33 33 function usage_help 34 34 { … … 39 39 } 40 40 41 function analyze_ dir41 function analyze_zmd_dir 42 42 { 43 43 printf "Analyzing $1\n" 44 rootDir=$PWD 45 svnDir=`realpath $1` 46 pkgDir=$1 47 srcDir=${1}"/trunk/fuentes" 48 debianDir=${1}"/trunk/fuentes/debian" 49 lliurexArtworkDir=${svnDir}"/../vibrancy-colors/trunk/fuentes/vibrancy-lliurex/apps" 44 if [ ! -d $lliurexArtworkDir ] || [ ! -d $vibrancyArtworkDir ] 45 then 46 printf "$msg_icons_dir_error" $lliurexArtworkDir $vibrancyArtworkDir 47 fi 48 wrkDir=$rootDir"/"$srcDir 49 cd $wrkDir 50 baseMetainfoDir=${wrkDir}"/llx-resources/" 51 zmdFiles=$(find . -name "*.app") 52 for i in ${zmdFiles} 53 do 54 echo "$i" 55 zmdName=$(basename $i) 56 zmdName=${zmdName/.app/} 57 zmdDir=$(dirname $i) 58 cd $zmdDir 59 metainfoDir=${baseMetainfoDir}"/"${zmdName}"/metainfo" 60 mkdir $metainfoDir -p 61 no_copy_desktop=1 62 sw_zomando=1 63 parse_desktop $metainfoDir ${zmdName}".app" 64 cd $wrkDir 65 done 66 add_llxsrc_helper 67 } 68 69 function analyze_desktop_dir 70 { 71 printf "Analyzing $1\n" 50 72 if [ ! -d $lliurexArtworkDir ] || [ ! -d $vibrancyArtworkDir ] 51 73 then … … 70 92 printf "$msg_install_not_found" 71 93 get_workdir 72 debhelper_mode=173 94 else 74 95 if [ $count -gt 0 ] … … 89 110 process_installFile ${installFile} 90 111 fi 112 add_llxsrc_helper 91 113 } 92 114 … … 174 196 if [ $? -ne 0 ] 175 197 then 176 #Dir doesn't seems to exists. Find t ie desktop on $svnDir and ask about the action198 #Dir doesn't seems to exists. Find the desktop on $svnDir and ask about the action 177 199 wrkDir='.' 178 200 installDir='.' … … 184 206 else 185 207 wrkDir=`dirname $wrkDir` 208 installDir=$wrkDir 186 209 cd $wrkDir 187 210 fi … … 235 258 item=`basename $desktopFile` 236 259 get_screenshot $item 237 awk -v processFile=$item -v metainfoDir=$metainfoDir -v screenshot=$imageFound - F '=' '260 awk -v processFile=$item -v metainfoDir=$metainfoDir -v screenshot=$imageFound -v zomando=$sw_zomando -F '=' ' 238 261 BEGIN{ 239 262 split(processFile,array,".",seps) … … 242 265 printf("") > outFile 243 266 xmlFile=metainfoDir"/"array[1]".appdata.xml" 244 print "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" > xmlFile 245 print "<component type=\"desktop-application\">" >> xmlFile 246 # print "<id>"revDomainName"</id>" >> xmlFile 247 print "<id>"array[1]"</id>" >> xmlFile 248 print "<metadata_license>CC0-1.0</metadata_license>" >> xmlFile 267 tagId="<id>"array[1]"</id>" 268 split(array[1],arrayKey,"-",seps) 269 for (nameIndex in arrayKey) 270 { 271 if (length(arrayKey[nameIndex])>=3) 272 { 273 if (tagKeywords!~">"arrayKey[nameIndex]"<") 274 tagKeywords=tagKeywords"<keyword>"arrayKey[nameIndex]"</keyword>\n"; 275 } 276 } 249 277 execPrinted=0 250 278 commentArrayIndex=1 251 279 nameArrayIndex=1 280 noGenerate=0 281 process=1 252 282 } 253 283 { 254 if ($1~"^Name")284 if ($0~/^\[.*\]/) 255 285 { 256 if ($1=="Name")286 if ($0~/\[Desktop.*/) 257 287 { 258 tagName="<name>"288 process=1; 259 289 } else { 260 lang=$1 261 split(lang,array,"[",seps) 262 lang=substr(array[2], 1, length(array[2])-1) 263 tagName="<name xml:lang=\""lang"\">" 264 } 265 tagName=tagName""$2"</name>" 266 nameArray[nameArrayIndex]=tagName 267 nameArrayIndex++; 268 split($2,array," ",seps) 269 for (nameIndex in array) 290 process=0; 291 } 292 } 293 294 if (process==1) 295 { 296 if ($1~/^Name/) 270 297 { 271 if (length(array[nameIndex])>=3) 272 { 273 if (tagKeywords!~">"array[nameIndex]"<") 274 tagKeywords=tagKeywords"<keyword>"array[nameIndex]"</keyword>\n"; 275 } 276 } 277 } else if ($1~"Comment") { 278 if ($1=="Comment") 279 { 280 tagSum="<summary>" 281 tagDes="<p>" 282 } else { 283 lang=$1 284 split(lang,array,"[",seps) 285 lang=substr(array[2], 1, length(array[2])-1) 286 tagSum="<summary xml:lang=\""lang"\">" 287 tagDes="<p xml:lang=\""lang"\">" 288 } 289 sumario=$2 290 split(sumario,array,".",seps) 291 $0=$1"="array[1] 292 summaryArray[commentArrayIndex]=tagSum""array[1]"</summary>" 293 descriptionArray[commentArrayIndex]=tagDes""sumario"</p>" 294 commentArrayIndex++ 295 } else if ($1=="Categories") { 296 customCat=0 297 countCat=0 298 split($2,array,";",seps) 299 for (catIndex in array) 300 { 301 if (array[catIndex]!="") 302 { 303 if (array[catIndex]~"-") 298 if ($1=="Name") 299 { 300 tagName="<name>" 301 lang="" 302 } else { 303 lang=$1 304 split(lang,array,"[",seps) 305 lang=substr(array[2], 1, length(array[2])-1) 306 tagName="<name xml:lang=\""lang"\">" 307 } 308 tagName=tagName""$2"</name>" 309 nameArray[nameArrayIndex]=tagName 310 nameArrayIndex++; 311 split($2,array," ",seps) 312 if ( lang != "") 313 { 314 tagKeywords=tagKeywords"</keywords>\n<keywords xml:lang=\""lang"\">\n"; 315 } 316 for (nameIndex in array) 317 { 318 if (length(array[nameIndex])>=3) 304 319 { 305 customCat=1 306 split(array[catIndex],lliurexCats,"-",seps) 307 for (lliurexCatIndex in lliurexCats) 320 if (tagKeywords!~">"array[nameIndex]"<") 321 tagKeywords=tagKeywords"<keyword>"array[nameIndex]"</keyword>\n"; 322 } 323 } 324 } else if ($1~"Comment") { 325 if ($1=="Comment") 326 { 327 tagSum="<summary>" 328 tagDes="<p>" 329 } else { 330 lang=$1 331 split(lang,array,"[",seps) 332 lang=substr(array[2], 1, length(array[2])-1) 333 tagSum="<summary xml:lang=\""lang"\">" 334 tagDes="<p xml:lang=\""lang"\">" 335 } 336 sumario=$2 337 split(sumario,array,".",seps) 338 $0=$1"="array[1] 339 summaryArray[commentArrayIndex]=tagSum""array[1]"</summary>" 340 descriptionArray[commentArrayIndex]=tagDes""sumario"</p>" 341 commentArrayIndex++ 342 } else if ($1=="Categories") { 343 customCat=0 344 countCat=0 345 split($2,array,";",seps) 346 for (catIndex in array) 347 { 348 if (array[catIndex]!="") 349 { 350 if (array[catIndex]~"-" && array[catIndex]!~"^X-") 308 351 { 309 lliurexCat="<category>"lliurexCats[lliurexCatIndex]"</category>\n"lliurexCat 352 customCat=1 353 split(array[catIndex],lliurexCats,"-",seps) 354 for (lliurexCatIndex in lliurexCats) 355 { 356 lliurexCat="<category>"lliurexCats[lliurexCatIndex]"</category>\n"lliurexCat 357 } 358 categoryArray[catIndex]=lliurexCat 359 } else { 360 categoryArray[catIndex]="<category>"array[catIndex]"</category>" 310 361 } 311 categoryArray[catIndex]=lliurexCat 312 } else { 313 categoryArray[catIndex]="<category>"array[catIndex]"</category>" 362 countCat++ 314 363 } 315 countCat++ 316 } 317 } 318 if (customCat==1 && countCat==1) 319 { 320 if (substr($0,length($0),1)==";") 321 $0=$0"GTK" 322 else 323 $0=$0;"GTK" 324 } 325 } else if ($1=="Icon") { 326 arrayItemNames=split($2,array,"/",seps) 327 arrayItems=split(array[arrayItemNames],array,".",seps) 328 iconBaseName=array[1] 329 $0=$1"="iconBaseName 330 # split(iconBaseName,array,".",seps) 331 tagIcon="<icon type=\"stock\">"iconBaseName"</icon>"; 332 } else if ($1=="Exec") { 333 if (execPrinted==0) 334 { 335 split($2,array," ",seps) 336 tagExec="<provides><binary>"array[1]"</binary></provides>" 337 execPrinted=1 364 } 365 366 367 if (customCat==1 && countCat==1) 368 { 369 if (substr($0,length($0),1)==";") 370 $0=$0"GTK" 371 else 372 $0=$0;"GTK" 373 catIndex++ 374 } 375 } else if ($1=="Icon") { 376 arrayItemNames=split($2,array,"/",seps) 377 arrayItems=split(array[arrayItemNames],array,".",seps) 378 iconBaseName=array[1] 379 $0=$1"="iconBaseName 380 if (zomando) 381 { 382 sub("zero-lliurex-", "",iconBaseName); 383 } 384 tagIcon="<icon type=\"stock\">"iconBaseName"</icon>"; 385 } else if ($1=="Exec") { 386 if (execPrinted==0) 387 { 388 split($2,array," ",seps) 389 tagExec="<provides><binary>"array[1]"</binary></provides>" 390 execPrinted=1 391 } 392 } else if ($1=="NoDisplay" || $1=="Terminal") { 393 if ($2 == "true" || $2=="TRUE" || $2=="True") 394 { 395 noGenerate=1 396 } 338 397 } 339 398 } … … 341 400 } 342 401 END{ 402 if (noGenerate==1) 403 { 404 print xmlFile" not generated as is a terminal app" 405 exit 1 406 } 407 print "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" > xmlFile 408 print "<component type=\"desktop-application\">" >> xmlFile 409 print tagId >> xmlFile 410 print "<metadata_license>CC0-1.0</metadata_license>" >> xmlFile 343 411 for (nameIndex in nameArray) 344 412 print nameArray[nameIndex] >> xmlFile … … 351 419 print "<categories>" >> xmlFile 352 420 for (categoryIndex in categoryArray) 421 { 353 422 print categoryArray[categoryIndex] >> xmlFile; 423 } 424 if (zomando) 425 { 426 print "<category>Zomando</category>" >> xmlFile 427 } 428 if (categoryIndex==0) 429 print "<category>Utility</category>" >> xmlFile 354 430 print "</categories>" >> xmlFile 355 431 print tagIcon >> xmlFile … … 367 443 print "</screenshots>" >> xmlFile 368 444 } 369 print "<developer_name></developer_name>" >> xmlFile445 # print "<developer_name>Lliurex Team</developer_name>" >> xmlFile 370 446 print "</component>" >> xmlFile 371 447 } 372 448 ' $desktopFile 373 printf "$msg_metainfo_generated" 374 cp /tmp/${item} $desktopFile 375 printf "$msg_desktop_updated" 449 [ $? -eq 0 ] && printf "$msg_metainfo_generated" 450 if [ -z $no_copy_desktop ] 451 then 452 cp /tmp/${item} $desktopFile 453 printf "$msg_desktop_updated" 454 fi 376 455 done 377 456 } … … 384 463 url="https://screenshots.debian.net/packages?page=1&search=${pkgName}&utf8=✓" 385 464 get_screenshot_from $url $pkgName 386 if [[ $imageFound == 0 ]]387 then388 printf "$msg_searching_img" "ubuntu"389 url="http://screenshots.ubuntu.com/packages?page=1&search=${pkgName}&utf8=✓"390 get_screenshot_from $url $pkgName391 fi465 # if [[ $imageFound == 0 ]] 466 # then 467 # printf "$msg_searching_img" "ubuntu" 468 # url="http://screenshots.ubuntu.com/packages?page=1&search=${pkgName}&utf8=✓" 469 # get_screenshot_from $url $pkgName 470 # fi 392 471 if [[ $imageFound == 'https://screenshots.debian.net/' || $imageFound == ' https://screenshots.ubuntu.com/' ]] 393 472 then … … 413 492 searchResult=${searchResult/\"/} 414 493 url=${baseUrl}${searchResult} 415 wget $url -t 2 -T 10 -o /tmp/ log -O $outFile494 wget $url -t 2 -T 10 -o /tmp/wget_desktop.log -O $outFile 416 495 if [ $? -eq 0 ] 417 496 then … … 428 507 function get_icon 429 508 { 430 iconName=$1 509 [ -z ${1} ] && echo "No icon selected" && return 510 iconName=$(basename $1) 431 511 #Check if a svg icon exists 432 512 workDir=$PWD … … 454 534 if [[ $iconFile ]] 455 535 then 536 iconFile=$(realpath $iconFile) 456 537 cd $rootDir 457 538 printf "$msg_icon_found" $iconFile … … 460 541 mkdir $resourcesDir -p 461 542 cd $OLDPWD 462 cp ${icon Path}"/"${iconFile} ${srcDir}"/"${resourcesDir}543 cp ${iconFile} ${srcDir}"/"${resourcesDir} 463 544 cd $OLDPWD 464 545 else … … 469 550 printf "$msg_icon_exists" 470 551 fi 471 add_llxsrc_helper472 552 } 473 553 … … 499 579 } 500 580 581 function get_package_type 582 { 583 cd $srcDir 584 ls *zmds 1>/dev/null 2>&1 585 if [ $? -eq 0 ] 586 then 587 echo "deb" 588 else 589 echo "zmd" 590 fi 591 } 592 593 ### MAIN PROGRAM ### 501 594 502 595 [[ $@ ]] || usage_help … … 517 610 do 518 611 cd $launchDir 519 debhelper_mode=0 520 analyze_dir $parm 612 rootDir=$launchDir 613 svnDir=`realpath $parm` 614 pkgDir=`realpath $parm` 615 srcDir=${parm}"/trunk/fuentes" 616 debianDir=${parm}"/trunk/fuentes/debian" 617 lliurexArtworkDir=${svnDir}"/../vibrancy-colors/trunk/fuentes/vibrancy-lliurex/apps" 618 no_copy_desktop="" 619 sw_zomando=0 620 [[ $(get_package_type) == 'zmd' ]] && analyze_zmd_dir $parm || analyze_desktop_dir $parm 521 621 done 522 622
Note: See TracChangeset
for help on using the changeset viewer.