Hi,
I have automated all the packaging and installation.
Also I have
atom feed, so I know when there is a commit and can easily see what has changed.
As of now, I'm at
git_20160417_81029be, so far, so good.
The way to type less and upgrade fast:
Note: everything is happening on behalf of the invoking user, only the last step requires root privileges and the script asks for the password.
1. I have generic git fetcher and packager
Code:
$ cat git-get-mksrctarball.sh
#!/bin/sh
REPODIR=/home/software/src/01-git
PACKDIR=/home/software/src
set -e
ADDRESS=$1
DESTDIR=$2
BRANCH=${3:-master}
if [ -z "${ADDRESS}" ] || [ -z "${DESTDIR}" ]; then
echo "usage: $0 ADDRESS DESTDIR [branch]"
exit 1
fi
UMASK=$(umask)
umask 022
cd "${REPODIR}"
if [ -e "${DESTDIR}" ]; then
cd "${DESTDIR}"
git checkout master
git pull -f
cd ..
else
git clone "${ADDRESS}" "${DESTDIR}"
fi
cd "${DESTDIR}"
git checkout "${BRANCH}"
VERSION="git_$( git log -1 --format=%ad_%h --date=format:%Y%m%d )"
cd ..
cp -a "${DESTDIR}" "${DESTDIR}-${VERSION}"
( cd "${DESTDIR}-${VERSION}" && find . -type d -name ".git*" -exec rm -rf {} \; 2>/dev/null ) || true
umask ${UMASK}
tar -Jvcf "${DESTDIR}-${VERSION}.tar.xz" "${DESTDIR}-${VERSION}"
md5sum "${DESTDIR}-${VERSION}.tar.xz" > "${DESTDIR}-${VERSION}.tar.xz.md5"
rm -rf "${DESTDIR}-${VERSION}"
mv "${DESTDIR}-${VERSION}.tar.xz" "${PACKDIR}"
mv "${DESTDIR}-${VERSION}.tar.xz.md5" "${PACKDIR}"
echo
echo "${DESTDIR} packaged as ${PACKDIR}/${DESTDIR}-${VERSION}.tar.xz"
echo
echo "PACKAGE=${DESTDIR}"
echo "VERSION=${VERSION}"
echo "TARBALL=${PACKDIR}/${DESTDIR}-${VERSION}.tar.xz"
echo
This script is in my $PATH so I can invoke it from whatever directory.
It expects 2 arguments: git address and directory name.
The branch can be selected with the third argument, if empty, master branch is selected.
The two variables,
REPODIR and
PACKDIR define, respectively, where the source code from git is downloaded and where the packaged source code is placed.
So, if the script is invoked like that:
Code:
git-get-mksrctarball.sh git://git.freedesktop.org/git/xorg/driver/xf86-video-intel/ xf86-video-intel
and
Code:
REPODIR=/home/software/src/01-git
PACKDIR=/home/software/src
after the script completes, there will be:
a)
/home/software/src/01-git/xf86-video-intel git repository,
b)
/home/software/src/xf86-video-intel-git_DATE_BRANCH.tar.xz packaged source code.
Also, once the script completes, it prints the following:
Code:
xf86-video-intel packaged as /home/software/src/xf86-video-intel-git_20160417_81029be.tar.xz
PACKAGE=xf86-video-intel
VERSION=git_20160417_81029be
TARBALL=/home/software/src/xf86-video-intel-git_20160417_81029be.tar.xz
The last 3 lines are made so to ease the parsing by another script.
2. Address and directory name for the git repository
That's just a place holder for convenience and it reads like that:
Code:
$ cat /home/software/src/01-git/xf86-video-intel.url
git://git.freedesktop.org/git/xorg/driver/xf86-video-intel/ xf86-video-intel
3. Fetch/build/upgrade script:
ARCH, RELEASE and BASDIR all are set up in a way to build up path to the
x11 source directory in Slackware's source code tree.
Code:
$ cat xf86-video-intel-upgrade.sh
#!/bin/sh
set -e
ARCH=64
RELEASE=current
BASDIR=/home/software/slackware/mirror
X11SRC=${BASDIR}/slackware${ARCH}-${RELEASE}/source/x/x11
LOGFILE=$(mktemp)
git-get-mksrctarball.sh \
$(cat /home/software/src/01-git/xf86-video-intel.url) "$@" | \
tee ${LOGFILE}
TARBALL=$(grep ^TARBALL= ${LOGFILE} | tail -n1 | cut -f2 -d=)
rm ${LOGFILE}
[ ! -f "${TARBALL}" ] && exit 42
cd ${X11SRC}/src/driver
rm xf86-video-intel-*.tar.xz || true
ln -s ${TARBALL}
echo "Executing: x11.SlackBuild driver xf86-video-intel"
su -l -c "cd ${X11SRC} && ./x11.SlackBuild driver xf86-video-intel"
This script:
1) invokes
git-get-mksrctarball.sh to fetch the git source code,
2) parses
git-get-mksrctarball.sh output (through temporary file) to get the location of the packaged source code,
3) goes to
x11 source code tree, removes the current
xf86-video-intel driver source code and soft links the just downloaded source code,
4) invokes
x11.SlackBuild to build and upgrade the driver.
The arguments passed to
xf86-video-intel-upgrade.sh are passed to
git-get-mksrctarball.sh, so in the end, with the first argument to
xf86-video-intel-upgrade.sh it's possible to specify the desired commit, and if empty, the 'master' is the default.
Hope this helps (and lets you type less
).
--
Best regards,
Andrzej Telszewski