# sync_from_local_copy_dir = True
-# To upload the repo to an Amazon S3 bucket using `fdroid server update`.
-# Warning, this deletes and recreates the whole fdroid/ directory each
-# time. This is based on apache-libcloud, which supports basically all cloud
-# storage services, so it should be easy to port the fdroid server tools to
-# any of them.
+# To upload the repo to an Amazon S3 bucket using `fdroid server
+# update`. Warning, this deletes and recreates the whole fdroid/
+# directory each time. This prefers s3cmd, but can also use
+# apache-libcloud. To customize how s3cmd interacts with the cloud
+# provider, create a 's3cfg' file next to this file (config.py), and
+# those settings will be used instead of any 'aws' variable below.
#
# awsbucket = 'myawsfdroid'
# awsaccesskeyid = 'SEE0CHAITHEIMAUR2USA'
BINARY_TRANSPARENCY_DIR = 'binary_transparency'
+AUTO_S3CFG = '.fdroid-server-update-s3cfg'
+USER_S3CFG = 's3cfg'
+
def update_awsbucket(repo_section):
'''
logging.debug(_('Using s3cmd to sync with: {url}')
.format(url=config['awsbucket']))
- configfilename = '.s3cfg'
- fd = os.open(configfilename, os.O_CREAT | os.O_TRUNC | os.O_WRONLY, 0o600)
- os.write(fd, '[default]\n'.encode('utf-8'))
- os.write(fd, ('access_key = ' + config['awsaccesskeyid'] + '\n').encode('utf-8'))
- os.write(fd, ('secret_key = ' + config['awssecretkey'] + '\n').encode('utf-8'))
- os.close(fd)
+ if os.path.exists(USER_S3CFG):
+ logging.info(_('Using "{path}" for configuring s3cmd.').format(path=USER_S3CFG))
+ configfilename = USER_S3CFG
+ else:
+ fd = os.open(AUTO_S3CFG, os.O_CREAT | os.O_TRUNC | os.O_WRONLY, 0o600)
+ logging.debug(_('Creating "{path}" for configuring s3cmd.').format(path=AUTO_S3CFG))
+ os.write(fd, '[default]\n'.encode('utf-8'))
+ os.write(fd, ('access_key = ' + config['awsaccesskeyid'] + '\n').encode('utf-8'))
+ os.write(fd, ('secret_key = ' + config['awssecretkey'] + '\n').encode('utf-8'))
+ os.close(fd)
+ configfilename = AUTO_S3CFG
s3bucketurl = 's3://' + config['awsbucket']
s3cmd = [config['s3cmd'], '--config=' + configfilename]
_('To use awsbucket, awssecretkey and awsaccesskeyid must also be set in config.py!'))
awsbucket = config['awsbucket']
+ if os.path.exists(USER_S3CFG):
+ raise FDroidException(_('"{path}" exists but s3cmd is not installed!')
+ .format(path=USER_S3CFG))
+
cls = get_driver(Provider.S3)
driver = cls(config['awsaccesskeyid'], config['awssecretkey'])
try: