Skip to content

Instantly share code, notes, and snippets.

@genzj
Created April 9, 2015 07:17
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save genzj/9b70b9ce3134fb8c2837 to your computer and use it in GitHub Desktop.
A makefile to generate a gfw-free Firefox portable release
# The MIT License (MIT)
#
# Copyright (c) 2015 genzj
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
# =============================================================================
# Instructions
#
# * What's this?
# This is a makefile to generate a gfw-free Firefox portable release powered
# by shadowsocks
#
# * How to use it?
# To generate the release, you will need:
# - An available ShadowSocks server
# - A Firefox portable base package downloaded from
# http://portableapps.com/apps/internet/firefox_portable
#
# 1. Writing the shadowsocks server info into config.js
# 2. Install portable Firefox
# 3. Edit following makefile, mainly for:
# - SS_BIN, binary shadowsocks client, go version is recommended
# - FF_PORTABLE_BASE if its not the FirefoxPortable folder beside Makefile
# - SS_CONFIG, shadowsocks configuration file
# 4. Run `make`
# 5. Optionally, run `make prune` to remove files unnecessary to end-users
# 6. Pack the FF_PORTABLE_BASE folder and release it as you like
#
SS_BIN = $(GOPATH)/bin/shadowsocks-local.exe
SS_CONFIG = config.json
FF_PORTABLE_BASE = ./FirefoxPortable
FF_PORTABLE_DEFAULT_PROFILE = /App/DefaultData/profile/prefs.js
define ADDED_FF_PREF
user_pref("network.proxy.socks", "127.0.0.1");\n\
user_pref("network.proxy.socks_port", 1080);\n\
user_pref("network.proxy.socks_remote_dns", true);\n\
user_pref("network.proxy.type", 1);\n
endef
.PHONY: all patch-pref prune
all: patch-pref copy-ss
copy-ss: $(SS_BIN) $(SS_CONFIG)
cp $(SS_BIN) $(FF_PORTABLE_BASE) && \
cp $(SS_CONFIG) $(FF_PORTABLE_BASE)
patch-pref:
echo -e '$(ADDED_FF_PREF)' >>$(FF_PORTABLE_BASE)$(FF_PORTABLE_DEFAULT_PROFILE)
$(SS_BIN):
$(error cannot find shadowsocks client at "$(SS_BIN)")
$(SS_CONFIG):
$(error cannot find shadowsocks configuration at "$(SS_CONFIG)")
prune:
-rm -rf $(FF_PORTABLE_BASE)/Other
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment