You are not logged in.

#1 2009-11-26 15:30:28

quarkup
Member
From: Portugal
Registered: 2008-09-07
Posts: 497
Website

AUR pkgver parsing and updates

Hello there,

I'm currently maintainer of the opera-g4 package in the AUR which PKGBUILD is the following

# Contributor: Nuno Aniceto (quarkup) <nuno (dot) aja (at) gmail (dot) com>
# Contributor: Arkham <arkham (at) archlinux (dot) us>
# Contributor: Kaos <gianlucaatlas (at) gmail (dot) com>
# Contributor: Julius Bullinger <julius (dot) bullinger (at) gmail (dot) com>
# Contributor: Daniel Isenmann <daniel (at) archlinux (dot) org>
# Contributor: dorphell <dorphell (at) archlinux (dot) org>
# Contributor: Sigitas Mazaliauskas <sigis (at) archlinux (dot) us>

#  Maintainer: Nuno Aniceto (quarkup) <nuno.aja@gmail.com>


# for details check: "http://my.opera.com/ruario/blog/2009/09 … ch-version"
#
# notes:
# - set both the $_beta and $_snapshot flags to "no" to get the latest final release
# - if you have the $_snapshot flag set to "yes" the $_beta flag will have no meaning
# - the betas and the snapshot versions may not use the qt4/kde4 theme
#


######################################################################################################
#
# WARNING:
#     The default setup options of this PKGBUILD will install a development snapshot.
#     Opera snapshots contain the latest changes, but may also have severe known issues,
#    including crashes and data loss situations. In fact, they may not work at all.
#     Please read the Opera Desktop Team Blog first so that you are aware of possible known issues,
#    or consider using the options below to select a more stable build.
#
#     
#      For more info about the snapshot versions, read the snapshot's FAQ
#      >  http://snapshot.opera.com/faq.html
#      >  http://my.opera.com/desktopteam/blog/
#
#    For more info about the 'qt' styles
#      >  http://my.opera.com/ruario/blog/2009/11/09/qt-styles
#
#    For more info on opera's launch flags (switches)
#    >  http://www.opera.com/docs/switches/
#
######################################################################################################


###  user options
_bundled="no"        # set to "yes" to build the package with the 'qt' bundled
_beta="no"        # set this flag to "yes" to get the latest beta release
_snapshot="yes"     # set this flag to "yes" to get the latest snapshot build

### switches (opera launch flags)

_patch="no"        # set this flag to "no" to use the opera's default switches
_systemstyle="yes"    # the '--systemstyle' flag >  http://my.opera.com/ruario/blog/2009/11/09/qt-styles

###  PKGBUILD  ###

pkgname="opera-g4"
pkgdesc="The Opera web browser - gcc4 and qt4 (g4)"
url="http://opera.com/"
pkgver=LATEST
pkgrel=9
license=('custom:opera')

arch=('i686' 'x86_64')
makedepends=('gcc-libs')
conflicts=('opera' 'opera-b1' 'opera-beta' 'opera-bundled' 'opera-china-qt3' 'opera-china-qt4'\
        'opera-dev' 'opera-devel-qt4' 'opera-dev-qt4' 'opera-g3' 'opera-mini' 'opera-qt3' \
        'opera-qt4' 'opera-shared-b1' 'opera-static' 'opera-unite-devel-qt3')
provides=('opera')

# check if its installing a snapshot version or not
[[ "${_snapshot}" = "yes" ]] && _beta="no"

# check the dependencies according to the machine architecture
[[ "${CARCH}" = "x86_64" ]] && _carch="x86_64" || _carch="i386"
[[ "${_bundled}" != "yes" ]] && depends=(${depends[@]} 'qt')
[[ "${_bundled}" = "yes" ]] && depends=(${depends[@]} 'nas')

# parse the opera's desktop team for the latest snapshot's build and version
[[ "${_snapshot}" = "yes" ]] && _build="$(wget -U 'Opera/9.80 (X11; Linux i686; U; en-GB) Presto/2.2.15 Version/10.10' \
                        -q -O - 'http://my.opera.com/desktopteam/blog/' \
                | grep 'snapshot.opera.com/unix' \
                | head -n 1 \
                | sed -e 's|.*/unix/||; s|/.*||')"
[[ "${_snapshot}" = "yes" ]] && _pkgver="$(wget -U 'Opera/9.80 (X11; Linux i686; U; en-GB) Presto/2.2.15 Version/10.10' \
                         -q -O - "http://snapshot.opera.com/unix/${_build}/intel-linux/" \
                | grep 'gcc4-qt4.i386.tar.gz' \
                | sed -e 's|<img.*> <a href=".*">||g; s|opera-||g' \
                      -e "s|${_build/*-/-}.gcc4-qt4.i386.tar.gz</a>.*||g")"

# parse the opera's ftp for the latest release's version
[[ "${_beta}" = "no" ]] && _bfilter='s|^.*b.*||g' || _bfilter=''
[[ "${_snapshot}" = "no" ]] && _pkgver="$(wget -q -O - 'ftp://ftp.opera.com/pub/opera/linux/' \
        | grep '/pub/opera/linux/' \
        | sed -e 's|.*<a.*\">||g' -e 's|/</a>||g' -e "${_bfilter}" \
        | sort -g | tail -n 1 \
        | sed -e 's|^..|\0\.|g' -e 's|\ ||g')"

[[ "${_snapshot}" = "yes" ]] && pkgver="${_pkgver}.${_build/-/}" || pkgver="${_pkgver}"

source=('opera.desktop')
md5sums=('a31d1d5fd833ee573524cda4b9e9f1ae')

build() {

  cd "${srcdir}"

  if [ "${_snapshot}" = "no" ];
  then
    [[ "${_beta}" = "no" ]] && msg2 'Checking the latest final release...' \
                || msg2 'Checking the latest version...'

    # get the filename (_fname)
    _fname="opera-${_pkgver/b/-b}.gcc4-qt4.${_carch}.tar.gz"
    [[ "${_bundled}" == "yes" ]] && _fname="opera-${_pkgver/b/-b}.gcc4-bundled-qt4.${_carch}.tar.gz"

    # get the url (_url)
    _url="ftp://ftp.opera.com/pub/opera/linux/${_pkgver/./}/final/en/${_carch}/${_fname}"
    [[ "${_beta}" != "no" ]] && _url="ftp://ftp.opera.com/pub/opera/linux/${_pkgver/./}/beta${_pkgver/*b/}/en/${_carch}/${_fname}"


  else
    msg2 'Checking the latest snapshot build...'

    _buildver="${_build/*-/}"
    _buildtype="${_build/-*/}"

    # get the filename (_fname)
    _fname="opera-${_pkgver}-${_buildver}.gcc4-qt4.${_carch}.tar.gz"
    [[ "${_bundled}" == "yes" ]] && _fname="opera-${_pkgver}-${_buildver}.gcc4-bundled-qt4.${_carch}.tar.gz"

    # get the url (_url)
    _url="http://snapshot.opera.com/unix/${_build}/intel-linux/${_fname}"
    [[ "${_carch}" != "i386" ]] && _url="http://snapshot.opera.com/unix/${_build}/${_carch}-linux/${_fname}"

  fi

  # download the package
  msg 'Downloading the source...'
  msg2 "${_url}"
  wget -q -c "${_url}" -O "${SRCDEST}/${_fname}" || return $?
  ln -fs "${SRCDEST}/${_fname}" "${srcdir}/${_fname}" || return $?
 
  msg 'Extracting binaries...'
  _dir="$(bsdtar -tzf ${SRCDEST}/${_fname} | head -n 1)" || return $?
  bsdtar -xzf ${SRCDEST}/${_fname} || return $?
  cd "${_dir}" || return $?
 
  # make the binaries
  msg2 'Checking md5sums...'
  ./install.sh DESTDIR="${pkgdir}" > /dev/null|| return $?

  if [ "${_patch}" != "no" ];
  then
    msg2 'Patching files...'

    [[ "${_systemstyle}" = "yes" ]] && sed -i "${pkgdir}/usr/bin/opera" \
                        -e 's|^exec "${OPERA_BINARYDIR}opera" "$@"|\0 -systemstyle "$@"|g'
  fi

  msg2 'Installing files...'
  install -D -m 444 "LICENSE" "${pkgdir}/usr/share/licenses/opera/license.txt"
  install -D -m 644 'usr/share/icons/hicolor/scalable/apps/opera.svg' "${pkgdir}/usr/share/opera/images/opera.svg"
  install -D -m 644 "${srcdir}/opera.desktop" "${pkgdir}/usr/share/applications/opera.desktop"
}

(the latest is on http://aur.archlinux.org/packages/opera … 4/PKGBUILD )

all I want is just to update the package only if needed but yet automatically check if there is a new version (as you can see in the beginning _pkgver variables).

I'm not sure if it is possible to check if the local installed package's version if the package has been installed before (i mean, if it's an upgrade).
Also, Is there any way to change the pkgver inside the build() ??
i heard about the FORCEVER but I can't really understand it's purposes.


Help would be appreciated.
Thanks in advance.


If people do not believe that mathematics is simple, it is only because they do not realize how complicated life is.
Simplicity is the ultimate sophistication.

Offline

Board footer

Powered by FluxBB