Skip to content

Commit f6b299e

Browse files
committed
Merge branch 'mbx'
2 parents e22bda5 + ff212d9 commit f6b299e

File tree

6 files changed

+83
-51
lines changed

6 files changed

+83
-51
lines changed

.gitignore

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
src/*.o
2+
src/s3
3+
debian/compat
4+
debian/files
5+
debian/apt-transport-s3
6+
debian/apt-transport-s3.substvars
7+
debian/apt-transport-s3.debhelper.log
8+
*~

README README.md

+19-17
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,34 @@
1-
apt-s3
2-
------
3-
additional "s3" protocol for apt so you can host your giant apt repository in s3 on the cheap!
1+
# apt-s3
42

5-
Author: Kyle Shank
3+
Additional "s3" protocol for apt so you can host your giant apt repository in s3 on the cheap!
64

75
We use this for pressflip.com to deploy and distribute all of our software. apt is a great packaging system and s3 is a great place to backup/store static files. apt-s3 is especially useful and fast if you are hosting your servers within EC2.
86

9-
THIS NEEDS MORE DOCUMENTATION OBVIOUSLY
7+
Original Author: Kyle Shank
8+
Contributors: Cliff Moon (@cliffmoon on GH), Jens Braeuer (@jbraeuer)
9+
Documenter: Susan Potter (@mbbx6spp on GH)
1010

11-
TODO
12-
----
13-
* Makefile
14-
* Package up binaries
15-
* Include uploader script to get repository into s3 bucket
16-
* Explain this a little more
11+
## Building
1712

18-
This has to be compiled with the source version of apt.
13+
Before building this project on Ubuntu (tested on 11.10) you will need to install the following packages:
1914

20-
You can get the source here:
15+
[sudo] apt-get install libapt-pkg-dev libcurl4-openssl-dev
2116

22-
bzr branch http://bzr.debian.org/apt/debian-sid apt-debian-sid
17+
To build this project you simply run `make`. It will produce a binary named `s3` under the `src/` dir.
18+
19+
## Installing
2320

2421
Once compiled, the resulting s3 binary must be placed in /usr/lib/apt/methods/ along with the other protocol binaries.
2522

2623
Finally, this is how you add it to the /etc/apt/sources.list file if you want your credentials in the url:
2724

28-
deb s3://AWS_ACCESS_ID:[AWS_SECRET_KEY_IN_BRACKETS]@s3.amazonaws.com/BUCKETNAME prod main
25+
deb s3://AWS_ACCESS_ID:[AWS_SECRET_KEY_IN_BRACKETS]@s3.amazonaws.com/BUCKETNAME prod main
26+
27+
otherwise leave off the credentials and it will draw them from the environment variables `AWS_ACCESS_KEY_ID` and `AWS_SECRET_KEY_ID`.
2928

30-
otherwise leave off the credentials and it will draw them from the environment variables AWS_ACCESS_KEY_ID and AWS_SECRET_KEY_ID.
29+
Simply upload all of your .deb packages and Packages.gz file into the s3 bucket you chose with the file key mapping that matches the file system layout.
3130

32-
Simply upload all of your .deb packages and Packages.gz file into the s3 bucket you chose with the file key mapping that matches the file system layout.
31+
## TODO
32+
33+
* Package up binaries
34+
* Include uploader script to get repository into s3 bucket

debian/changelog

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
apt-transport-s3 (1.1ubuntu1) oneiric; urgency=low
2+
3+
* Make apt-transport-s3 work, when locale is non-english.
4+
5+
-- Jens Braeuer <[email protected]> Mon, 31 Jan 2012 21:01:25 +0100
6+
17
apt-transport-s3 (1.0ubuntu1) lucid; urgency=low
28

39
* Working around stupid amazon s3 behaviour with filenames

src/Makefile

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
default: s3
33

44
clean:
5-
rm *.o s3
5+
rm -f *.o s3
66

77
s3: s3_main.o s3.o connect.o
8-
g++ -lapt-pkg -lapt-inst -lssl -lcrypto -o s3 s3.o s3_main.o connect.o
8+
g++ -o s3 s3.o s3_main.o connect.o -lapt-pkg -lapt-inst -lssl -lcrypto
99

1010
%.o: %.cc
1111
gcc -I /usr/include -I./ -g -c $<
1212

1313
install: s3
14-
cp s3 /usr/lib/apt/methods/
14+
cp s3 /usr/lib/apt/methods/

src/s3.cc

+45-31
Original file line numberDiff line numberDiff line change
@@ -756,37 +756,51 @@ void HttpMethod::SendReq(FetchItem *Itm,CircleBuf &Out)
756756
Req += string("Proxy-Authorization: Basic ") +
757757
Base64Encode(Proxy.User + ":" + Proxy.Password) + "\r\n";
758758

759-
/* S3 Specific */
760-
time_t rawtime;
761-
struct tm * timeinfo;
762-
char buffer [80];
763-
764-
time( &rawtime);
765-
timeinfo = gmtime( &rawtime);
766-
767-
strftime(buffer, 80, "%a, %d %b %Y %H:%M:%S +0000", timeinfo);
768-
string dateString((const char*)buffer);
769-
Req += "Date: " + dateString + "\r\n";
770-
771-
string extractedPassword;
772-
if (Uri.Password.empty() && NULL == getenv("AWS_SECRET_ACCESS_KEY")) {
773-
cerr << "E: No AWS_SECRET_ACCESS_KEY set" << endl;
774-
exit(1);
775-
} else if(Uri.Password.empty()) {
776-
extractedPassword = getenv("AWS_SECRET_ACCESS_KEY");
777-
} else {
778-
if(Uri.Password.at(0) == '['){
779-
extractedPassword = Uri.Password.substr(1,Uri.Password.size()-2);
780-
}else{
781-
extractedPassword = Uri.Password;
782-
}
783-
}
784-
785-
char headertext[SLEN], signature[SLEN];
786-
sprintf(headertext,"GET\n\n\n%s\n%s", dateString.c_str(), normalized_path.c_str());
787-
doEncrypt(headertext, signature, extractedPassword.c_str());
788-
789-
string signatureString(signature);
759+
/* S3 Specific */
760+
time_t rawtime = 0;
761+
struct tm * timeinfo = NULL;
762+
char buffer [80] = { 0 };
763+
char* wday = NULL;
764+
765+
time( &rawtime);
766+
timeinfo = gmtime( &rawtime);
767+
768+
// strftime does not seem to honour set_locale(LC_ALL, "") or
769+
// set_locale(LC_TIME, ""). So convert day of week by hand.
770+
switch (timeinfo->tm_wday) {
771+
case 0: wday = (char*)"Sun"; break;
772+
case 1: wday = (char*)"Mon"; break;
773+
case 2: wday = (char*)"Tue"; break;
774+
case 3: wday = (char*)"Wed"; break;
775+
case 4: wday = (char*)"Thu"; break;
776+
case 5: wday = (char*)"Fri"; break;
777+
case 6: wday = (char*)"Sat"; break;
778+
}
779+
780+
strcat(buffer, wday);
781+
strftime(buffer+3, 80, ", %d %b %Y %T %z", timeinfo);
782+
string dateString((const char*)buffer);
783+
Req += "Date: " + dateString + "\r\n";
784+
785+
string extractedPassword;
786+
if (Uri.Password.empty() && NULL == getenv("AWS_SECRET_ACCESS_KEY")) {
787+
cerr << "E: No AWS_SECRET_ACCESS_KEY set" << endl;
788+
exit(1);
789+
} else if(Uri.Password.empty()) {
790+
extractedPassword = getenv("AWS_SECRET_ACCESS_KEY");
791+
} else {
792+
if(Uri.Password.at(0) == '['){
793+
extractedPassword = Uri.Password.substr(1,Uri.Password.size()-2);
794+
}else{
795+
extractedPassword = Uri.Password;
796+
}
797+
}
798+
799+
char headertext[SLEN], signature[SLEN];
800+
sprintf(headertext,"GET\n\n\n%s\n%s", dateString.c_str(), normalized_path.c_str());
801+
doEncrypt(headertext, signature, extractedPassword.c_str());
802+
803+
string signatureString(signature);
790804
string user;
791805
if (Uri.User.empty() && NULL == getenv("AWS_ACCESS_KEY_ID")) {
792806
cerr << "E: No AWS_ACCESS_KEY_ID set" << endl;

src/s3.h

+2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
#ifndef APT_HTTP_H
2828
#define APT_HTTP_H
2929

30+
#include <apt-pkg/hashes.h>
31+
3032
#define MAXLEN 360
3133

3234

0 commit comments

Comments
 (0)