Skip to content

Instantly share code, notes, and snippets.

@elieux
Created May 6, 2015 11:08
Show Gist options
  • Save elieux/f7d98933943806c43777 to your computer and use it in GitHub Desktop.
Save elieux/f7d98933943806c43777 to your computer and use it in GitHub Desktop.
MSYS2 package spreadsheet generation script
#!/usr/bin/bash
scrape_db() {
local var=$1
local file=$2
local url=$3
[ "$DB_UPDATE" != 'no' ] && wget -nv -O /tmp/$file $url >&2
while read pkg ver; do
eval pkg_${var}[$pkg]=$ver
done < <(bsdtar -xJOf /tmp/$file "*/desc" | grep -E -A 1 "%(NAME|VERSION)%" | sed -r -e '/^%.+%$/d' -e '/^--$/d' -e 's/^mingw-w64-i686-//' -e 's/^mingw-w64-x86_64-//' | sed 'N;s/\n/ /')
}
scrape_repo() {
local var=$1
local repo=$2
local url=$3
local subdir=$4
local isbase=$5
(
[ -d $repo ] || git clone $url $repo
if [ "$GIT_UPDATE" != 'no' ]; then
cd $repo
git checkout master
git pull
cd ..
fi
) >&2
while read dir; do
pkgbase=$(basename $dir)
if [ -n "${isbase}${repo_msys[$pkgbase]}${repo_msys_mingw[$pkgbase]}" ]; then
if [ -e $dir$subdir/PKGBUILD ]; then
temp=$(. $dir$subdir/PKGBUILD; echo $pkgver-$pkgrel) eval repo_${var}[$pkgbase]=\$temp
temp=$(. $dir$subdir/PKGBUILD; echo "${pkgname[@]}") eval split_${var}[$pkgbase]=$\temp
else
echo "WARNING: $dir$subdir/PKGBUILD does not exist." >&2
fi
fi
done < <(find $repo -mindepth 1 -maxdepth 1 -type d -not -name 'mingw-w64-*' | grep -v .git)
while read dir; do
pkgbase=$(basename $dir | sed -r 's/^mingw-w64-//')
if [ -n "${isbase}${repo_msys[$pkgbase]}${repo_msys_mingw[$pkgbase]}" ]; then
if [ -e $dir$subdir/PKGBUILD ]; then
temp=$(MINGW_PACKAGE_PREFIX=mingw-w64 . $dir$subdir/PKGBUILD; echo $pkgver-$pkgrel) eval repo_${var}_mingw[$pkgbase]=\$temp
temp=$(MINGW_PACKAGE_PREFIX=mingw-w64 . $dir$subdir/PKGBUILD; echo "${pkgname[@]#mingw-w64-}") eval split_${var}_mingw[$pkgbase]=\$temp
else
echo "WARNING: $dir$subdir/PKGBUILD does not exist." >&2
fi
fi
done < <(find $repo -mindepth 1 -maxdepth 1 -type d -name 'mingw-w64-*' | grep -v .git)
}
declare -A pkg_msys32 pkg_msys64 pkg_mingw32 pkg_mingw64
scrape_db msys32 msys32.db http://downloads.sourceforge.net/project/msys2/REPOS/MSYS2/i686/msys.db
scrape_db msys64 msys64.db http://downloads.sourceforge.net/project/msys2/REPOS/MSYS2/x86_64/msys.db
scrape_db mingw32 mingw32.db http://downloads.sourceforge.net/project/msys2/REPOS/MINGW/i686/mingw32.db
scrape_db mingw64 mingw64.db http://downloads.sourceforge.net/project/msys2/REPOS/MINGW/x86_64/mingw64.db
declare -A split_msys split_msys_mingw split_arch split_arch_mingw split_aur split_aur_mingw
declare -A repo_msys repo_msys_mingw repo_arch repo_arch_mingw repo_aur repo_aur_mingw
scrape_repo msys msys2-packages https://github.com/alexpux/msys2-packages.git "" base
scrape_repo msys mingw-packages https://github.com/alexpux/mingw-packages.git "" base
scrape_repo arch arch-packages git://projects.archlinux.org/svntogit/packages.git "/trunk"
scrape_repo arch arch-community git://projects.archlinux.org/svntogit/community.git "/trunk"
scrape_repo aur aur-packages git://pkgbuild.com/aur-mirror.git ""
echo '"pkgbase";"msys2 pkgver";"msys32 pkgs";"msys64 pkgs";"mingw pkgver";"mingw32 pkgs";"mingw64 pkgs";"arch pkgver";"arch pkgs";"arch mingw pkgver";"arch mingw pkgs";"aur pkgver";"aur pkgs";"aur mingw pkgver";"aur mingw pkgs"'
while read pkgbase; do
echo -n ${pkgbase}
echo -n ';'
echo -n ${repo_msys[$pkgbase]}
echo -n ';'
echo -n '"'
for pkg in ${split_msys[$pkgbase]}; do echo $pkg ${pkg_msys32[$pkg]}; done | perl -pe 'chomp if eof'
echo -n '"'
echo -n ';'
echo -n '"'
for pkg in ${split_msys[$pkgbase]}; do echo $pkg ${pkg_msys64[$pkg]}; done | perl -pe 'chomp if eof'
echo -n '"'
echo -n ';'
echo -n ${repo_msys_mingw[$pkgbase]}
echo -n ';'
echo -n '"'
for pkg in ${split_msys_mingw[$pkgbase]}; do echo mingw-w64-i686-$pkg ${pkg_mingw32[$pkg]}; done | perl -pe 'chomp if eof'
echo -n '"'
echo -n ';'
echo -n '"'
for pkg in ${split_msys_mingw[$pkgbase]}; do echo mingw-w64-x86_64-$pkg ${pkg_mingw64[$pkg]}; done | perl -pe 'chomp if eof'
echo -n '"'
echo -n ';'
echo -n ${repo_arch[$pkgbase]}
echo -n ';'
echo -n '"'
for pkg in ${split_arch[$pkgbase]}; do echo $pkg; done | perl -pe 'chomp if eof'
echo -n '"'
echo -n ';'
echo -n ${repo_arch_mingw[$pkgbase]}
echo -n ';'
echo -n '"'
for pkg in ${split_arch_mingw[$pkgbase]}; do echo mingw-w64-$pkg; done | perl -pe 'chomp if eof'
echo -n '"'
echo -n ';'
echo -n ${repo_aur[$pkgbase]}
echo -n ';'
echo -n '"'
for pkg in ${split_aur[$pkgbase]}; do echo $pkg; done | perl -pe 'chomp if eof'
echo -n '"'
echo -n ';'
echo -n ${repo_aur_mingw[$pkgbase]}
echo -n ';'
echo -n '"'
for pkg in ${split_aur_mingw[$pkgbase]}; do echo mingw-w64-$pkg; done | perl -pe 'chomp if eof'
echo -n '"'
echo
done < <(echo ${!repo_msys[@]} ${!repo_msys_mingw[@]} | tr ' ' '\n' | sort | uniq)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment