forked from MacsInSpace/MacAppStoreRedist
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrepkg.sh
83 lines (74 loc) · 3.51 KB
/
repkg.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/bin/bash
#say lol
OS_BUILD=`sw_vers -buildVersion | /usr/bin/colrm 3`
if [ $OS_BUILD = "9" ]
then
#10.6
User=`logname`
Manifest="/Users/$User/Library/Application Support/AppStore/manifest.plist"
Cache="/Users/$User/Library/Application Support/AppStore"
mkdir "/Users/$User/appstorerepkg"
#open /Users/$User/appstorerepkg
itemNumber=0
while [ $itemNumber -lt 100 ]; do
BundleID=`/usr/libexec/PlistBuddy -c "print :representations:$itemNumber:bundle-id" "$Manifest"`
if [ "$BundleID" = "" ]
then
break
fi
Title=`/usr/libexec/PlistBuddy -c "print :representations:$itemNumber:title" "$Manifest"`
SubTitle=`/usr/libexec/PlistBuddy -c "print :representations:$itemNumber:subtitle" "$Manifest"`
PKG=`/usr/libexec/PlistBuddy -c "print :representations:$itemNumber:assets:0:name" "$Manifest"`
Size=`/usr/libexec/PlistBuddy -c "print :representations:$itemNumber:assets:0:size" "$Manifest"`
ItemID=`/usr/libexec/PlistBuddy -c "print :representations:$itemNumber:item-id" "$Manifest"`
if [ "$SubTitle" = "Apple" ]
then
echo $BundleID > /Users/$User/appstorerepkg/$BundleID.txt
echo $Title >> /Users/$User/appstorerepkg/$BundleID.txt
echo $SubTitle >> /Users/$User/appstorerepkg/$BundleID.txt
echo $PKG >> /Users/$User/appstorerepkg/$BundleID.txt
echo $Size >> /Users/$User/appstorerepkg/$BundleID.txt
echo $ItemID >> /Users/$User/appstorerepkg/$BundleID.txt
ln "$Cache/$ItemID/$PKG" /Users/$User/appstorerepkg/$BundleID.pkg
else
echo "$Title is not an Apple pkg so will not redistribute"
fi
let itemNumber=itemNumber+1
done
else
#10.7/8/9/10/11/12
User=`logname`
Manifest=`find /var/folders -name manifest.plist 2>/dev/null | grep "/C/com.apple.appstore"`
Cache=`echo "${Manifest%/*}"/`
mkdir "/Users/$User/appstorerepkg"
#open /Users/$User/appstorerepkg
itemNumber=0
while [ $itemNumber -lt 100 ]; do
BundleID=`/usr/libexec/PlistBuddy -c "print :representations:$itemNumber:bundle-id" $Manifest`
if [ "$BundleID" = "" ]
then
break
fi
Title=`/usr/libexec/PlistBuddy -c "print :representations:$itemNumber:title" $Manifest`
SubTitle=`/usr/libexec/PlistBuddy -c "print :representations:$itemNumber:subtitle" $Manifest`
PKG=`/usr/libexec/PlistBuddy -c "print :representations:$itemNumber:assets:0:name" $Manifest`
Size=`/usr/libexec/PlistBuddy -c "print :representations:$itemNumber:assets:0:size" $Manifest`
ItemID=`/usr/libexec/PlistBuddy -c "print :representations:$itemNumber:item-id" $Manifest`
BundleVer=`/usr/libexec/PlistBuddy -c "print :representations:$itemNumber:bundle-version" $Manifest`
if [ "$SubTitle" = "Apple" ]
then
echo $BundleID > /Users/$User/appstorerepkg/$BundleID.$BundleVer.txt
echo $BundleVer >> /Users/$User/appstorerepkg/$BundleID.$BundleVer.txt
echo $Title >> /Users/$User/appstorerepkg/$BundleID.$BundleVer.txt
echo $SubTitle >> /Users/$User/appstorerepkg/$BundleID.$BundleVer.txt
echo $PKG >> /Users/$User/appstorerepkg/$BundleID.$BundleVer.txt
echo $Size >> /Users/$User/appstorerepkg/$BundleID.$BundleVer.txt
echo $ItemID >> /Users/$User/appstorerepkg/$BundleID.$BundleVer.txt
ln $Cache/$ItemID/$PKG /Users/$User/appstorerepkg/$BundleID.$BundleVer.pkg
else
echo "$Title is not an Apple pkg so will not redistribute"
fi
let itemNumber=itemNumber+1
done
fi
exit 0