Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
G
gfwlist
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
gfwlist
Commits
a75ab263
Commit
a75ab263
authored
Mar 11, 2009
by
lovelywcm
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
U2NyaXB0Cg==
parent
1e2cf104
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
331 additions
and
167 deletions
+331
-167
addChecksum.pl
addChecksum.pl
+65
-0
gfwlist.txt
gfwlist.txt
+167
-167
sendGFWList.sh
sendGFWList.sh
+99
-0
No files found.
addChecksum.pl
0 → 100755
View file @
a75ab263
#!/usr/bin/perl
#############################################################################
# This is a reference script to add checksums to downloadable #
# subscriptions. The checksum will be validated by AutoProxy on download #
# and checksum mismatches (broken downloads) will be rejected. #
# #
# To add a checksum to a subscription file, run the script like this: #
# #
# perl addChecksum.pl subscription.txt #
# #
# Note: your subscription file should be saved in UTF-8 encoding, otherwise #
# the generated checksum might be incorrect. #
# #
#############################################################################
use
strict
;
use
warnings
;
use
Digest::
MD5
qw(md5_base64)
;
die
"
Usage: $^X $0 subscription.txt
\n
"
unless
@ARGV
;
my
$file
=
$ARGV
[
0
];
my
$data
=
readFile
(
$file
);
# Remove already existing checksum
$data
=~
s/^.*!\s*checksum[\s\-:]+([\w\+\/=]+).*\n//gmi
;
# Calculate new checksum: remove all CR symbols and empty
# lines and get an MD5 checksum of the result (base64-encoded,
# without the trailing = characters).
my
$checksumData
=
$data
;
$checksumData
=~
s/\r//g
;
$checksumData
=~
s/\n+/\n/g
;
# Calculate new checksum
my
$checksum
=
md5_base64
(
$checksumData
);
# Insert checksum into the file
$data
=~
s/(\r?\n)/$1! Checksum: $checksum$1/
;
writeFile
(
$file
,
$data
);
sub
readFile
{
my
$file
=
shift
;
open
(
local
*
FILE
,
"
<
",
$file
)
||
die
"
Could not read file '
$file
'
";
binmode
(
FILE
);
local
$/
;
my
$result
=
<
FILE
>
;
close
(
FILE
);
return
$result
;
}
sub
writeFile
{
my
(
$file
,
$contents
)
=
@_
;
open
(
local
*
FILE
,
"
>
",
$file
)
||
die
"
Could not write file '
$file
'
";
binmode
(
FILE
);
print
FILE
$contents
;
close
(
FILE
);
}
gfwlist.txt
View file @
a75ab263
This diff is collapsed.
Click to expand it.
sendGFWList.sh
0 → 100755
View file @
a75ab263
#!/bin/bash
#
# A simple script help to maintain AutoProxy gfwList easily.
#
# Function:
# Update local svn repository;
# Commit decoded changes(by others in your team) to local git repository
# with decoded message and authors name;
# Update "Last Modified" time;
# Update "Checksum";
# Commit your changes to local git repository;
# Commit your encoded changes to remote svn repository with encoded log.
# Usage:
# Initialize:
# $svn checkout https://autoproxy-gfwlist.googlecode.com/svn/trunk/ gfwList --username your-google-user-name
# $cd gfwList
# $git init
# $base64 gfwlist.txt > list.txt
# $git add list.txt
# $git commit -a -m "init"
# Normal Usage:
# edit list.txt as usual;
# $./synGfwList.sh "say something about this edit"
# Note:
# 1: You can use "git" to show, diff, log...what's you want;
# 2: "gfwlist.txt" is a fake file, do NOT commit "list.txt" to svn server;
# 3: Do NOT use any unicode character in the list, there is a known bug.
###############################################################################
# dependence
for
cmd
in
sed date base64
gawk svn git
do
which
$cmd
&> /dev/null
;
if
[
$?
-ne
0
]
;
then
echo
"Depends on
$cmd
, please install it first."
;
exit
1
;
fi
done
# get current revision number
oriLang
=
$LANG
;
export
LANG
=
"en_US"
;
curRevNum
=
$(
svn info | gawk
'/^Revision:/ { print $2 }'
)
;
export
LANG
=
$oriLang
;
# save local modification
git diff
>
temp.patch
&&
svn update
&&
# get formated author and log information
log
=
$(
svn log
-r
$curRevNum
:HEAD
)
&&
log
=
$(
echo
$log
| gawk
-v
RS
=
'------------------------------------------------------------------------'
\
'NR > 3 { if (NF > 10) printf "%s:%s;", $3, $NF; }'
)
&&
# convert from base64
i
=
0
&&
convertedLog
=
""
&&
while
[
"
$log
"
!=
""
]
do
if
((
$i
%2
==
0
))
;
then
# author
temp
=
${
log
%%
:
*
}
;
convertedLog+
=
$temp
;
convertedLog+
=
":
\"
"
;
log
=
${
log
#*
:
}
;
else
# log, decode it
temp
=
$(
echo
${
log
%%;*
}
|
base64
-d
)
;
convertedLog+
=
$temp
;
convertedLog+
=
"
\"
; "
;
log
=
${
log
#*;
}
;
fi
((
i++
))
;
done
# replace last ";" symbol to "."
convertedLog
=
$(
echo
$convertedLog
|
sed
's/;$/\./'
)
&&
if
[
"
$convertedLog
"
!=
""
]
;
then
# modified by others, commit to local repository.
# log format: author1:"message1"; author2:"message2"...
base64
-d
gfwlist.txt
>
list.txt
&&
git commit
-a
-m
"
$convertedLog
"
&&
# apply local modification
git apply temp.patch
;
fi
# update date and checksum
sed
-i
s/
"Last Modified:.*$"
/
"Last Modified:
$(
date
-R
-r
list.txt
)
"
/ list.txt
&&
./addChecksum.pl list.txt
&&
# save self change to git
git commit
-a
-m
"
$*
"
&&
# commit to remote svn server
base64
list.txt
>
gfwlist.txt
&&
svn ci
-m
$(
echo
"
$*
"
|
base64
)
&&
rm
temp.patch
;
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment