scripts

random scripts
git clone https://git.parazyd.org/scripts
Log | Files | Refs

apk (3518B)


      1 #!/bin/sh
      2                                                                   # wtfpl (c) parazyd
      3                                                                _arch="x86_64";_query="$@"
      4                                                               test -n "$_query" || exit 1
      5                                                                _url="http://pkgs.alpinel"
      6                                                                _url="${_url}inux.org" # |
      7                                                                _url="${_url}/packages?" #
      8                                                                _page="$(elinks -dump     \
      9                                                          "${_url}name=${_query}&arch=${_arch}")"
     10                                                       pkgtable="$(printf "%s\\n" "$_page"| sed 34q |
     11                                                             grep $_query | grep '^\[')"; # xxx|
     12                                                                test -n "$pkgtable" ||   {
     13                                                         printf "(*) no packages found\\n"; exit 1
     14                                                     }; pkgurl="$(printf "%s\\n" "$_page" | grep http |
     15                                                                      grep '/package/'\
     16                                                                 | sed 1q | tr -d '\t')" ;
     17                                                               eval "printf '%s\\n' $pkgurl |
     18                                                                   grep main >/dev/null"\
     19                                                                 && pkgname=main  ; eval \
     20                                                   "printf '%s\\n' $pkgurl | grep community >/dev/null"\
     21                                                                 && pkgname=community;eval \
     22                                                   "printf '%s\\n' $pkgurl | grep testing   >/dev/null" \
     23                                                                 && pkgname=testing # random
     24                                                            pkgver="$(printf "%s\\n" "$pkgtable"| \
     25                                                                   awk -F']' '{print $3}' | \
     26                                                                   awk -F'[' '{print $1}' | \
     27                                                                        tr '\n' ' ')"
     28                                                 home="$(                                      printf "%s\\n" "$_page" |
     29                                                       grep http |                          awk '/18/ {print $2}')"
     30                                                              desc="$(                  printf "%s\\n" "$_page" |
     31                                                 awk '/16\./ { for (i=2;              i<=NF; i++) print $i}' |
     32                                                           tr '\n' ' ')" ;           pkgname="$pkgname/$(\
     33                                                printf "%s\\n" $pkgtable |           awk -F']' '{print $2}' |
     34                                                 awk -F'[' '{print $1}')";           printf "* %s\\n" "$pkgname"
     35          printf "\tavailable versions: %s\\n" "$pkgver";             printf "\thomepage:           %s\\n" "$home"
     36          printf "\tdescription:        %s\\n" "$desc";                  printf "\tpackage url:        %s\\n" "$pkgurl"