Last active
August 29, 2015 14:20
-
-
Save Thermionix/ded74d6480ff0c2bf340 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
zip_date=`date +%Y-%m-%d` | |
rom_zip="apps-$zip_date.zip" | |
wget --timestamping https://gitlab.com/fdroid/fdroiddata/raw/master/stats/known_apks.txt | |
apk_ids=( | |
org.fdroid.fdroid # FDroid | |
com.zegoggles.smssync # SMSBackup+ | |
org.telegram.messenger # Telegram | |
com.google.zxing.client.android # Barcode Scanner | |
fr.asterope # AndroidRun | |
org.floens.chan # Clover | |
at.bitfire.davdroid # DavDroid | |
com.fsck.k9 # K9 Mail | |
com.vonglasow.michael.satstat # SatStat | |
net.osmand.plus # OsmAnd | |
org.sufficientlysecure.viewer # DocumentViewer | |
fr.xgouchet.texteditor # Ted | |
org.mozilla.fennec # Firefox | |
org.videolan.vlc # VLC | |
) | |
rm -r data/ | |
mkdir -p data/app/ | |
for apk_id in "${apk_ids[@]}" | |
do | |
: | |
echo "# checking $apk_id" | |
apk_file=$(grep -e "^$apk_id" known_apks.txt | sort -k3 | tail -n 1 | cut -f 1 -d ' ') | |
if [ -n "$apk_file" ] ; then | |
echo "# retrieving $apk_file" | |
wget -nc -P apk-cache "https://f-droid.org/repo/$apk_file" | |
#find data/app/ -name "$apk_id*" ! -name "$apk_file" -delete | |
mkdir -p "data/app/$apk_id-1" | |
cp "apk-cache/$apk_file" "data/app/$apk_id-1/base.apk" | |
fi | |
done | |
# https://github.com/CyanogenMod/android_bootable_recovery/tree/cm-12.1/edify | |
# https://android.googlesource.com/platform/build/+/master/tools/releasetools/sign_target_files_apks.py | |
if [ ! -e "update-binary" ] ; then | |
wget https://github.com/koush/AnyKernel/raw/master/META-INF/com/google/android/update-binary | |
fi | |
rm -r META-INF | |
mkdir -p META-INF/com/google/android | |
cp update-binary META-INF/com/google/android/update-binary | |
cat <<-'EOF' | tee META-INF/com/google/android/updater-script | |
ui_print("Mounting filesystem"); | |
run_program("/sbin/busybox", "mount", "/system"); | |
run_program("/sbin/busybox", "mount", "/data"); | |
ui_print("System app removal"); | |
delete("/system/app/Browser/Browser.apk"); | |
delete("/system/app/Email/Email.apk"); | |
delete("/system/app/Exchange2/Exchange2.apk"); | |
delete("/system/app/CaptivePortalLogin/CaptivePortalLogin.apk"); | |
delete("/system/app/QuickSearchBox/QuickSearchBox.apk"); | |
delete("/system/app/VideoEditor/VideoEditor.apk"); | |
delete("/system/app/LiveWallpapers/LiveWallpapers.apk"); | |
delete("/system/app/BasicDreams/BasicDreams.apk"); | |
delete("/system/app/MagicSmokeWallpapers/MagicSmokeWallpapers.apk"); | |
delete("/system/app/PhaseBeam/PhaseBeam.apk"); | |
delete("/system/app/HoloSpiralWallpaper/HoloSpiralWallpaper.apk"); | |
delete("/system/app/NoiseField/NoiseField.apk"); | |
delete("/system/app/Galaxy4/Galaxy4.apk"); | |
delete("/system/app/WhisperPush/WhisperPush.apk"); | |
delete("/system/app/CMWallpapers/CMWallpapers.apk"); | |
delete("/system/app/PhotoPhase/PhotoPhase.apk"); | |
delete("/system/priv-app/OmniSwitch/OmniSwitch.apk"); | |
delete("/system/priv-app/OneTimeInitializer/OneTimeInitializer.apk"); | |
delete("/system/priv-app/CyanogenSetupWizard/CyanogenSetupWizard.apk"); | |
delete("/system/priv-app/CMAccount/CMAccount.apk"); | |
delete("/system/priv-app/CMUpdater/CMUpdater.apk"); | |
ui_print("Installing Applications"); | |
package_extract_dir("data", "/data"); | |
set_perm_recursive(1000, 1000, 0771, 0644, "/data/app"); | |
run_program("/sbin/busybox", "umount", "/system"); | |
run_program("/sbin/busybox", "umount", "/data"); | |
EOF | |
zip --filesync -r $rom_zip META-INF/ data/ | |
if [ ! -e "signapk.jar" ] ; then | |
wget https://github.com/appium/sign/raw/master/dist/signapk.jar | |
fi | |
if [ ! -e "certificate.pem" ] ; then | |
echo "certificate missing, creating" | |
openssl genrsa -out key.pem 1024 | |
openssl req -new -key key.pem -out request.pem -batch -subj "/O=Private" | |
openssl x509 -req -days 9999 -in request.pem -signkey key.pem -out certificate.pem | |
openssl pkcs8 -topk8 -outform DER -in key.pem -inform PEM -out key.pk8 -nocrypt | |
rm request.pem | |
rm key.pem | |
fi | |
java -jar signapk.jar certificate.pem key.pk8 $rom_zip "signed-$rom_zip" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment