Skip to content

Instantly share code, notes, and snippets.

@arnested
Last active August 29, 2015 13:57
Show Gist options
  • Select an option

  • Save arnested/9526828 to your computer and use it in GitHub Desktop.

Select an option

Save arnested/9526828 to your computer and use it in GitHub Desktop.
#!/bin/sh
# Copyright (C) 2014 Arne Jørgensen
FILE=$1
if [ ! -r "${FILE}" ]; then
echo \""${FILE}"\" is not readable
exit 1;
fi
FILE_MIMETYPE=$(file --mime-type --brief "${FILE}")
if [ "${FILE_MIMETYPE}" != 'application/x-tar' ] &&
[ "${FILE_MIMETYPE}" != 'text/x-lisp' ]; then
echo \""${FILE}"\" is not a lisp file or a tar archive
exit 2;
fi
read -p "Are you sure you want to upload \"${FILE}\" (yes/no)? " REPLY
if [ "${REPLY}" != 'yes' ]; then
exit 4;
fi
# Get my token from Macs Key Chain.
TOKEN=$(security find-generic-password -gws 'Marmalade Repo API' -a "${USER}")
curl --silent -F "name=${USER}" -F "token=${TOKEN}" -F "package=@${FILE}" http://marmalade-repo.org/v1/packages | json message
@arnested
Copy link
Author

Uploading to Marmalade is currently broken.

It is still possible to upload via Marmalades API though.

To upload via the API you need a token. You get your token via the API as well using you username and password.

I created this shell script to handle the upload for me.

I have stored my token in Mac OS X's Keychain. If you don't use Mac or Keychain - use something similar or put your token directly into the script.

The script goes to some length to make sure you don't upload something bogus to Marmalade:

  • The file must be readable.
  • The file must be either a Tar archive or a Lisp file (as reported by file(1)).
  • You must answer 'yes' to confirm the upload.

The upload is handled by curl(1) and I use json to parse the feedback from Marmalade (install json with npm install json).

Feel free to use and adapt the script to your needs.

@arnested
Copy link
Author

arnested commented Apr 1, 2014

You could also take a look at @lunaryorns much more streamlined implementation of this script: http://www.lunaryorn.com/2014/03/28/unbreaking-marmalade.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment