source: adobe-flashplugin/trunk/fuentes/update_flash.sh @ 561

Last change on this file since 561 was 561, checked in by mabarracus, 4 years ago

Fix update script:

  • allow one or two filters
  • if there is more than one result, gets the newer
  • Property svn:executable set to *
File size: 2.8 KB
Line 
1#!/bin/bash
2
3echo ""
4
5if [ "$1" = "" ];then
6
7
8        #echo "USAGE: update_flash adobe-flash-url.dsc"
9        #echo -e "\n\tDSC file can be found in http://archive.canonical.com/pool/partner/a/adobe-flashplugin/\n"
10        #exit 0
11
12        echo "* Scanning for newest version ..."
13
14        DSC_FILE=$(python -c "
15
16import urllib
17import os
18import tempfile
19
20# Base url to get package list
21URL='http://archive.canonical.com/pool/partner/a/adobe-flashplugin/'
22
23# First filter
24BASE_NAME='adobe-flashplugin_'
25
26# Second filter (can be innactive or empty)
27#DISTRO='15.10'
28
29fd,tmp_file=tempfile.mkstemp()
30os.close(fd)
31
32urllib.urlretrieve(URL,tmp_file)
33
34f=open(tmp_file)
35
36# Filter the results
37item_dsc=[]
38for line in f:
39        if BASE_NAME in line and \".dsc\" in line:
40            try:
41                DISTRO
42                if DISTRO=='':
43                    DISTRO=None
44            except NameError:
45                DISTRO=None
46            if DISTRO != None:
47                if DISTRO in line:
48                    DSC_FILE=line.strip('\n').split('<a href=\"')[1].split('\">')[0]
49                    item_dsc.append(URL+DSC_FILE)
50            else:
51                DSC_FILE=line.strip('\n').split('<a href=\"')[1].split('\">')[0]
52                item_dsc.append(URL+DSC_FILE)
53               
54f.close()
55
56# Always select the newer that meets the criteria
57item_dsc.sort()
58
59# The last is the newer
60if len(item_dsc) > 1:
61    print item_dsc[-1]
62else:
63    print item_dsc[0]
64")
65       
66       
67        echo "* Using $DSC_FILE ..."
68        echo ""
69       
70       
71else
72        DSC_FILE="$1"
73       
74fi
75
76
77
78TMP_DIR=$(mktemp -d)
79
80echo "* Downloading to $TMP_DIR ... "
81exit
82cd $TMP_DIR
83dget -xu $DSC_FILE 1>/dev/null 2>/dev/null
84
85ADOBE_DIR=$(ls *.orig.tar.gz | cut -d / -f4 | sed -e "s%\.orig\.tar\.gz$%%g" | sed -e "s%_%-%g")
86ADOBE_VERSION=$(ls *.diff.gz | cut -d _ -f2 | sed -e "s%\.diff.gz%+lliurex1%g")
87
88echo "* Updating files..."
89
90cd - 1>/dev/null 2>/dev/null
91
92cp -r $TMP_DIR/$ADOBE_DIR/amd64/* amd64/
93cp -r $TMP_DIR/$ADOBE_DIR/i386/* i386/
94cp $TMP_DIR/$ADOBE_DIR/debian/changelog debian/changelog
95
96API_VERSION=$(cat i386/readme.txt | grep Version | cut -d " " -f2)
97
98echo "* Done updating Adobe-flashplugin Version $API_VERSION $ADOBE_VERSION"
99
100dch -b --release-heuristic trusty -v 1:$ADOBE_VERSION "Updating version to $ADOBE_VERSION"
101
102python -c "
103f=open('debian/adobe-flashplugin.postinst')
104lines=f.readlines()
105f.close()
106new_file=''
107oldv=''
108count=0
109for line in lines:
110
111        if 'sed -i' in line:
112                old_line=line
113                rule=line.split(' ')[2]
114                oldv=rule.split('%')[2]
115                newv='$API_VERSION'.replace('.','\.')
116                line=line.replace(oldv,newv)
117                               
118                if 'sed -i' not in lines[count+1]:
119                        rule=old_line.split(' ')[2]
120                        oldr=rule.split('%')[2]
121                        oldl=rule.split('%')[1]
122                        if oldr!=newv:
123                                new_line=old_line.replace(oldr,newv)
124                                new_line=new_line.replace(oldl,oldr)
125                                line+=new_line
126                                       
127        count+=1
128        new_file+=line
129
130f=open('debian/adobe-flashplugin.postinst','w')
131f.write(new_file)
132f.close()
133"
134
135echo ""
136svn st
137echo ""
138
Note: See TracBrowser for help on using the repository browser.