Created
March 6, 2019 14:33
-
-
Save stedolan/a472a32c35d892345e97effb7e879625 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
echo "Downloading OPAM repository..." | |
curl -sL https://github.com/ocaml/opam-repository/archive/master.tar.gz | tar -xz | |
echo "Downloading packages..." | |
( cd opam-repository-master/packages/; | |
for pkg in *; do ( cd $pkg; ls -v | head -n -1 | xargs rm -rf; ) done; ) | |
( cd opam-repository-master/; opam admin cache -n ../_src --link ..; ) | |
rm -rf opam-repository-master | |
echo "Unpacking sources..." | |
for archive in $(find . -maxdepth 2 -type l); do | |
case $archive in | |
*.tar.bz2|*.tbz) cmd='tar --force-local -xjf';; | |
*.tar.xz) cmd='tar --force-local -xJf';; | |
*.zip) cmd='unzip -q -n';; | |
*.tar.gz|*.tgz|*.tar.gz) cmd='tar --force-local -xzf';; | |
*) echo "Unknown archive type $archive, guessing tgz"; cmd='tar --force-local -xzf';; | |
esac | |
( cd ${archive%/*}; $cmd ${archive##*/}; ) && rm $archive | |
echo $archive | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
a shorter version in opam2 is :
opam list -a -s | xargs -I'{}' opam source {}