Ignore:
Timestamp:
May 10, 2017, 12:15:56 PM (2 years ago)
Author:
Juanma
Message:

Adds screenshots from debian

File:
1 edited

Legend:

Unmodified
Added
Removed
  • devtools/desktop_to_xml/desktop_to_xml.sh

    r4641 r4648  
    1818msg_desktop_updated="\nDesktop file updated.\n"
    1919msg_icon_found="Icon %s found.\nGenerating llx-resources dir\n"
    20 msg_icon_not_found="\nNo icon named %s found on dirs %s, %s or %s\nRemember that the icon must be in SVG format and no in PNG or other image format\nOPERATION ABORTED\n"
     20msg_icon_not_found="\n********** WARNING!!!! **********\nNo icon named %s found on dirs %s, %s or %s\nRemember that the icon must be in SVG format and no in PNG or other image format\n *************************** \n"
    2121msg_icon_location_info="\nPlease add %s as svg to %s and relaunch this program or use the llxsrc debhelper. Until then the app will not be included in our software store.\n"
    2222msg_icon_exists="\nIcon package found on the right location. Checking if llxsrc helper exists in rules\n"
     
    2828msg_select_pkg="\nSelect the name of the package to process\n"
    2929msg_desktop_not_found="\nDesktop file not found at %s. Process aborted.\n"
    30 
     30msg_searching_img="\nSearching screenshots...\n"
     31msg_image_found="\nScreenshoot %s finded for app %s\n"
    3132function usage_help
    3233{
     
    4142        printf "Analyzing $1\n"
    4243        rootDir=$PWD
    43         svnDir=`dirname $1`
     44        svnDir=`realpath $1`
    4445        pkgDir=$1
    4546        srcDir=${1}"/trunk/fuentes"
    4647        debianDir=${1}"/trunk/fuentes/debian"
    47         lliurexArtworkDir=${svnDir}"/vibrancy-colors/trunk/fuentes/vibrancy-lliurex/apps"
     48        lliurexArtworkDir=${svnDir}"/../vibrancy-colors/trunk/fuentes/vibrancy-lliurex/apps"
    4849        if [ ! -d $lliurexArtworkDir ] || [ ! -d $vibrancyArtworkDir ]
    4950        then
     
    218219                printf "$msg_parsing_desktop" $desktopFile
    219220                item=`basename $desktopFile`
    220                 awk -v processFile=$item -v metainfoDir=$metainfoDir -F '=' '
     221                get_screenshot $item
     222                awk -v processFile=$item -v metainfoDir=$metainfoDir -v screenshot=$imageFound -F '=' '
    221223                BEGIN{
    222224                        split(processFile,array,".",seps)
     
    341343                        print tagKeywords >> xmlFile
    342344                        print "</keywords>" >> xmlFile
     345                        if ( screenshot != 0 )
     346                        {
     347                                print "<screenshots>" >> xmlFile
     348                                print "<screenshot type=\"default\">" >> xmlFile
     349                                print "<caption>Main window.</caption>" >> xmlFile
     350                                print "<image type=\"source\" width=\"800\" height=\"450\">"screenshot"</image>" >> xmlFile
     351                                print "</screenshot>" >> xmlFile
     352                                print "</screenshots>" >> xmlFile
     353                        }
    343354                        print "<developer_name>Lliurex Team</developer_name>" >> xmlFile
    344355                        print "</component>" >> xmlFile
     
    349360                printf "$msg_desktop_updated"
    350361        done
     362}
     363
     364function get_screenshot
     365{
     366        printf "$msg_searching_img"
     367        imageFound=0
     368        pkgName=${1/.desktop/}
     369        url="https://screenshots.debian.net/packages?page=1&search=${pkgName}&utf8=✓"
     370        outFile=$(mktemp)
     371        wget  $url -o /dev/null -O $outFile
     372        if [ $? -eq 0 ]
     373        then
     374                searchResult=$(grep  -P -o  "href=\"\/package\/".*?\" $outFile | head -n1)
     375                if [ $searchResult ]
     376                then
     377                        searchResult=${searchResult/href=\"\//}
     378                        searchResult=${searchResult/\"/}
     379                        url="https://screenshots.debian.net/${searchResult}"
     380                        wget  $url -o /tmp/log -O $outFile
     381                        if [ $? -eq 0 ]
     382                        then
     383                                imageFound=$(grep  -P -o  "href=\"\/screenshots\/".*?\" $outFile | head -n1)
     384                                imageFound=${imageFound/href=\"\//}
     385                                imageFound=${imageFound/\"/}
     386                                imageFound="https://screenshots.debian.net/${imageFound}"
     387                                printf "$msg_image_found" $imageFound $pkgName
     388                        fi
     389                fi
     390        fi
    351391}
    352392
     
    388428                        cd $OLDPWD
    389429                else
    390                         printf "$msg_icon_not_found" ${iconName} $lliurexArtworkDir $resourcesDir $installDir
    391                         printf "$msg_icon_location_info" ${iconName} $lliurexArtworkDir
    392                         exit 1
     430                        printf "$msg_icon_not_found" ${iconName} "$lliurexArtworkDir" "$resourcesDir" "$installDir"
     431                        printf "$msg_icon_location_info" ${iconName} "$lliurexArtworkDir"
    393432                fi
    394433        else
Note: See TracChangeset for help on using the changeset viewer.