Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(installer): Git for Windows Updater #153

Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
*.swp
/ReleaseNotes.html
edit-git-bash.exe
proxy-lookup.exe
/cached-source-packages/
/download-stats.ids
/git-extra/pkg/
Expand Down
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
CFLAGS=-O2 -Wall

all: edit-git-bash.exe
all: edit-git-bash.exe proxy-lookup.exe

edit-git-bash.exe: edit-git-bash.c
gcc -DSTANDALONE_EXE $(CFLAGS) -o $@ $^

proxy-lookup.exe: proxy-lookup.c
gcc $(CFLAGS) -Werror -o $@ $^ -lshell32 -lwinhttp
2 changes: 1 addition & 1 deletion git-extra/PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ sha256sums=('e6a17a669fe8282792b3d98a2c47718425364a0ca9a456bdbad4a69c57ec6978'
'2dba0f5f8133b8e8d1da8291efec140cd516e385f04b33b95e4f97fc40f628b3'
'f4e310c00721f8834949268167b0584b7c9323775a318574dbca960af10d7998'
'89b4d784e1c07d67c11a35abc7094709c216372e2099b2eb7abbc6eb7c34861f'
'33a49036a52442a9754240e67abeb9dc2f686e8e25e5f70d522d78a150085e0a')
'5887f1f22a1b898072decd954ab3b3bfbb79b013f14c2cc4139a878d33d70e62')

prepare() {
test $startdir/$pkgname.install -nt $startdir/$pkgname.install.in &&
Expand Down
7 changes: 7 additions & 0 deletions git-extra/git-update
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@
# when confirmation to do so is given.

git_update () {
proxy=$(proxy-lookup https://api.github.com | grep URL | awk '{ print $4}' | awk -F";" '{print $1}')
if test "$proxy" != ""
then
export https_proxy="http://$proxy"
echo "Using proxy server $https_proxy detected from Internet Explorer settings"
fi

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

yn=
while test $# -gt 0
do
Expand Down
1 change: 1 addition & 0 deletions installer/install.iss
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ Source: {#SourcePath}\ReleaseNotes.html; DestDir: {app}; Flags: replacesameversi
Source: {#SourcePath}\..\LICENSE.txt; DestDir: {app}; Flags: replacesameversion; AfterInstall: DeleteFromVirtualStore
Source: {#SourcePath}\NOTICE.txt; DestDir: {app}; Flags: replacesameversion; AfterInstall: DeleteFromVirtualStore; Check: ParamIsSet('VSNOTICE')
Source: {#SourcePath}\..\edit-git-bash.exe; Flags: dontcopy
Source: {#SourcePath}\..\proxy-lookup.exe; DestDir: {app}\{#MINGW_BITNESS}\bin; Flags: replacesameversion

[Dirs]
Name: "{app}\tmp"
Expand Down
4 changes: 4 additions & 0 deletions installer/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ echo "Compiling edit-git-bash.exe ..."
make -C ../ edit-git-bash.exe ||
die "Could not build edit-git-bash.exe"

# Compile proxy-lookup.exe
make -C ../ proxy-lookup.exe ||
die "Could not build proxy-lookup.exe."

if test t = "$skip_files"
then
LIST=
Expand Down
4 changes: 4 additions & 0 deletions msi/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ die "Could not generate ReleaseNotes.html."
make -C ../ edit-git-bash.exe ||
die "Could not build edit-git-bash.exe."

# Compile proxy-lookup.exe
make -C ../ proxy-lookup.exe ||
die "Could not build proxy-lookup.exe."

This comment was marked as off-topic.

This comment was marked as off-topic.


# Make a list of files to include
LIST="$(ARCH=$ARCH BITNESS=$BITNESS \
PACKAGE_VERSIONS_FILE="$SCRIPT_PATH"/package-versions.txt \
Expand Down
67 changes: 67 additions & 0 deletions proxy-lookup.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
// based on the sample provided here: https://github.com/git-for-windows/git/issues/387
// probably inspired by https://msdn.microsoft.com/en-us/library/aa384122(v=vs.85).aspx

#include <stdio.h>
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <winhttp.h>
#include <shellapi.h>

LPCWSTR get_proxy_for_url(LPCWSTR url)
{
WINHTTP_CURRENT_USER_IE_PROXY_CONFIG config;
WINHTTP_AUTOPROXY_OPTIONS options;
WINHTTP_PROXY_INFO info;

memset(&config, 0, sizeof(config));

if (!WinHttpGetIEProxyConfigForCurrentUser(&config))
config.fAutoDetect = FALSE;
else if (config.lpszAutoConfigUrl)
config.fAutoDetect = TRUE;

if (config.fAutoDetect) {
HINTERNET handle = WinHttpOpen(L"Proxy Lookup/1.0",
WINHTTP_ACCESS_TYPE_NO_PROXY,
WINHTTP_NO_PROXY_NAME,
WINHTTP_NO_PROXY_BYPASS, 0);

memset(&options, 0, sizeof(options));

// use pac file URL from IE proxy configuration
options.lpszAutoConfigUrl = config.lpszAutoConfigUrl;

options.fAutoLogonIfChallenged = TRUE;
options.dwFlags = options.lpszAutoConfigUrl ?
WINHTTP_AUTOPROXY_CONFIG_URL :
WINHTTP_AUTOPROXY_AUTO_DETECT;
if (!options.lpszAutoConfigUrl)
options.dwAutoDetectFlags =
WINHTTP_AUTO_DETECT_TYPE_DHCP |
WINHTTP_AUTO_DETECT_TYPE_DNS_A;

config.fAutoDetect = WinHttpGetProxyForUrl(handle, url,
&options, &info );

WinHttpCloseHandle(handle);
}

if (config.fAutoDetect)
return info.lpszProxy;
return config.lpszProxy;
}

int main(int argc, char **argv)
{
LPWSTR *wargv;
int i, wargc;

wargv = CommandLineToArgvW(GetCommandLineW(), &wargc);
wprintf(L"Proxy lookup\n");

for (i = 1; i < wargc; i++)
wprintf(L"URL: %s, proxy: %s\n",
wargv[i], get_proxy_for_url(wargv[i]));

return 0;
}