3 # Script to gather the ipks that were changed in a new firmware compared to an
4 # older firmware. Update the variables at the top to match your files and then
5 # just run the script. It should generate 4 output txt files as well as fetch
6 # the ipks that are to be installed.
11 # where shall the packages end?
12 PACKAGES_FOLDER=$WORKING_DIR/hotfix/packages
14 # old and new list of packages seperated by newlines
15 OLD_PACKAGES=$WORKING_DIR/installed-packages_fw1.txt
16 NEW_PACKAGES=$WORKING_DIR/installed-packages_hf6r.txt
18 # names of the output files
19 TO_BE_REMOVED=$WORKING_DIR/to_be_removed.txt
20 TO_BE_ADDED=$WORKING_DIR/to_be_added.txt
21 REALLY_REMOVED=$WORKING_DIR/really_removed.txt
22 REALLY_ADDED=$WORKING_DIR/really_added.txt
23 ERRORS=$WORKING_DIR/errors.txt
27 TMP1=$WORKING_DIR/tmp1.txt
28 TMP2=$WORKING_DIR/tmp2.txt
32 # gather list of new and removed packages based on the input files
35 if [ ! -f $OLD_PACKAGES ]
37 echo "could not find the new package list at $OLD_PACKAGES; aborting"
40 if [ ! -f $NEW_PACKAGES ]
42 echo "could not find the new package list at $NEW_PACKAGES; aborting"
46 # list of removed packages since "OLD_PACKAGES" (means also packages that were replaced in a new version!)
47 diff $OLD_PACKAGES $NEW_PACKAGES | grep "<" | cut -f 2 -d " " | sort > $TO_BE_REMOVED
49 # list of added packages in "NEW_PACKAGES" compared to "OLD_PACKAGES" (also updated versions!)
50 diff $OLD_PACKAGES $NEW_PACKAGES | grep ">" | cut -f 2 -d " " | sort > $TO_BE_ADDED
52 cat $TO_BE_REMOVED | cut -f 1 -d "_" | sort > $TMP1
53 cat $TO_BE_ADDED | cut -f 1 -d "_" | sort > $TMP2
55 diff $TMP1 $TMP2 | grep "<" | cut -f 2 -d " " | sort > $REALLY_REMOVED
56 diff $TMP1 $TMP2 | grep ">" | cut -f 2 -d " " | sort > $REALLY_ADDED
58 #cleanup temp files from "gathering package list"
63 # find out filenames for "new" packages and download the files
66 # remove existing old stamp files
67 rm -f $WORKING_DIR/Packages.stamps.all $WORKING_DIR/Packages.stamps.armv7a $WORKING_DIR/Packages.stamps.omap3-pandora
69 # get recent stamp files from the feed
70 wget --output-document=$WORKING_DIR/Packages.stamps.all http://www.openpandora.org/feeds/unstable/all/Packages.stamps
71 wget --output-document=$WORKING_DIR/Packages.stamps.armv7a http://www.openpandora.org/feeds/unstable/armv7a/Packages.stamps
72 wget --output-document=$WORKING_DIR/Packages.stamps.omap3-pandora http://www.openpandora.org/feeds/unstable/omap3-pandora/Packages.stamps
74 # convert package entries in stamp files into the correct "full" urls
75 cat $WORKING_DIR/Packages.stamps.all | cut -f 2 -d " " | sed -e 's;^;http://www.openpandora.org/feeds/unstable/all/;g' > $TMP1
76 cat $WORKING_DIR/Packages.stamps.armv7a | cut -f 2 -d " " | sed -e 's;^;http://www.openpandora.org/feeds/unstable/armv7a/;g' >> $TMP1
77 cat $WORKING_DIR/Packages.stamps.omap3-pandora | cut -f 2 -d " " | sed -e 's;^;http://www.openpandora.org/feeds/unstable/omap3-pandora/;g' >> $TMP1
80 rm -f $WORKING_DIR/Packages.stamps.all $WORKING_DIR/Packages.stamps.armv7a $WORKING_DIR/Packages.stamps.omap3-pandora
83 # get the list of the relevant (aka 'new) package URLs
84 for i in `cat $TO_BE_ADDED`;
86 grep "$i" $TMP1 >> $TMP2;
89 echo "Could not find package '$i' in download list" >> $ERRORS
93 # seperate into 'kernel' and 'other' (every packagename that starts with 'kernel' is only relevant for the kernel space
94 cat $TMP2 | grep "\/kernel" > $TMP2.kernel
95 cat $TMP2 | grep -v "\/kernel" > $TMP2.other
98 #create folders for the new packages
99 if [ ! -d $PACKAGES_FOLDER/kernel ]
101 mkdir -p $PACKAGES_FOLDER/kernel
103 if [ ! -d $PACKAGES_FOLDER/other ]
105 mkdir -p $PACKAGES_FOLDER/other
108 # download kernel ipks
109 cd $PACKAGES_FOLDER/kernel
110 wget --no-clobber -i $TMP2.kernel
112 # download other ipks
113 cd $PACKAGES_FOLDER/other
114 wget --no-clobber -i $TMP2.other
116 # move packages that are supposed to be openpandora specific into an extra folder which is installed last!
117 mkdir $PACKAGES_FOLDER/pandora
118 mv $PACKAGES_FOLDER/other/pandora*ipk $PACKAGES_FOLDER/pandora/
120 # cleanup all the remaining temp files
121 rm -f $TMP1 $TMP2 $TMP2.kernel $TMP2.other
125 # explain the results in some nice words
131 echo "Explaination of created folders and files"
133 echo "Created text files:"
134 echo " $TO_BE_REMOVED: files that are no longer included (at least not as this exact package version)"
135 echo " $TO_BE_ADDED: files that are to be installed (complete package name incl version number"
136 echo " $REALLY_REMOVED: package names of those packages that are no longer installed (and should be removed using opkg!)"
137 echo " $REALLY_ADDED: package names of packages that were added since the old version"
138 echo " $ERRORS: a list of packages that were not found on the given download server(s)"
140 echo "Saved all ("`ls $PACKAGES_FOLDER/kernel/*ipk | wc -l`") kernel related ipks to:"
141 echo " $PACKAGES_FOLDER/kernel"
142 echo "Saved all ("`ls $PACKAGES_FOLDER/other/*ipk | wc -l`") 'other' ipks to:"
143 echo " $PACKAGES_FOLDER/other"
145 echo "You can now copy the folder $PACKAGES_FOLDER into the place where you create the pnd file."
149 echo "Some packages were not found. Please have a look at $ERRORS and make sure that things actually work!"