Check-in [36a7e12995]
Overview
Comment:Added support for an archive format as well as fixing date format for Fossil files
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | packages
Files: files | file ages | folders
SHA1:36a7e12995cddac3c8a519c861457443b4277ee5
User & Date: rkeene on 2014-11-04 00:45:39
Other Links: manifest | tags
Context
2014-11-04
00:46
Updated to use UTC timezone everywhere check-in: b5ddc3b45b user: rkeene tags: packages
00:45
Added support for an archive format as well as fixing date format for Fossil files check-in: 36a7e12995 user: rkeene tags: packages
2014-11-03
23:49
Updated to use package data from Fossil, which is more reliable check-in: 77faad55ab user: rkeene tags: packages
Changes

Modified build from [dcf6e62dd7] to [71498ef42a].

     1      1   #! /usr/bin/env bash
            2  +
            3  +targetmode='install'
            4  +if [ "$1" == '--cpio' ]; then
            5  +	targetmode='archive'
            6  +
            7  +	shift
            8  +fi
     2      9   
     3     10   pkg="$(echo "$1" | sed 's@/*$@@;s@^\.*/*@@')"
     4     11   
     5     12   if [ -z "${pkg}" ]; then
     6         -	echo "Usage: build <package>" 2>&1
           13  +	echo "Usage: build [--cpio] <package>" 2>&1
     7     14   
     8     15   	exit 1
     9     16   fi
    10     17   
    11     18   function determineOsArch() {
    12     19   	os="$(uname -s | dd conv=lcase 2>/dev/null)"
    13     20   	arch="$(uname -m | dd conv=lcase 2>/dev/null)"
................................................................................
    55     62   }
    56     63   
    57     64   function postbuild() {
    58     65   	:
    59     66   }
    60     67   
    61     68   function build() {
    62         -	grep "DESTDIR" Makefile || die "Don't know how to build this software"
           69  +	grep "DESTDIR" Makefile >/dev/null || die "Don't know how to build this software"
    63     70   
    64     71   	make
    65     72   }
    66     73   
    67     74   function preinstall() {
    68     75   	:
    69     76   }
................................................................................
    92     99   	fi
    93    100   
    94    101   	cleanup
    95    102   
    96    103   	exit 1
    97    104   }
    98    105   
    99         -cd "$(dirname "$(which "$0")")" || exit 1
          106  +scriptdir="$(cd "$(dirname "$(which "$0")")" && pwd)"
          107  +if [ -z "${scriptdir}" ]; then
          108  +	echo "Unable to locate script directory" >&2
          109  +
          110  +	exit 1
          111  +fi
          112  +
          113  +cd "${scriptdir}" || exit 1
   100    114   
   101    115   if [ -f 'build.conf' ]; then
   102    116   	. 'build.conf'
   103    117   fi
   104    118   
   105    119   if [ -d "pkgs/${pkg}" ]; then
   106    120   	pkgdir="pkgs/${pkg}"
................................................................................
   112    126   
   113    127   if [ ! -e "${pkgfile}" ]; then
   114    128   	echo "Invalid package." >&2
   115    129   
   116    130   	exit 1
   117    131   fi
   118    132   
   119         -pkgdate="$(for artifact in $(find "${pkgdir}" -type f -print0 | xargs -n 1 -0 fossil finfo --limit 1 --width 0 2>/dev/null | grep '^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] ' | sed 's@^[^ ]* \[@@;s@\].*@@' | sort -u); do fossil info "${artifact}" | awk '/^uuid:/{ print $3 "T" $4 }' | sed 's@[-:]@@g;s@..$@\.&@'; done | sort -n | tail -n 1)"
          133  +pkgdate="$(for artifact in $(find "${pkgdir}" -type f -print0 | xargs -n 1 -0 fossil finfo --limit 1 --width 0 2>/dev/null | grep '^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] ' | sed 's@^[^ ]* \[@@;s@\].*@@' | sort -u); do fossil info "${artifact}" | awk '/^uuid:/{ print $3 $4 }' | sed 's@[-:]@@g;s@..$@\.&@'; done | sort -n | tail -n 1)"
   120    134   if [ -z "${pkgdate}" ]; then
   121    135   	pkgdate="$(find "${pkgdir}" -type f -printf '%TY%Tm%Td%TH%TM.%TS\n' 2>/dev/null | cut -f 1-2 -d '.' | sort -n | tail -n 1)"
   122    136   fi
   123    137   
   124    138   . "${pkgfile}"
   125    139   
   126    140   archivedir="$(pwd)/ARCHIVE"
................................................................................
   208    222   postbuild || die 'postbuild failed'
   209    223   
   210    224   preinstall || die 'preinstall failed'
   211    225   install || die 'install failed'
   212    226   postinstall || die 'postinstall failed'
   213    227   
   214    228   (
   215         -	appdir="$(appfsinstalldir)/${prefixsuffix}"
   216         -	mkdir -p "${appdir}"
          229  +	case "${targetmode}" in
          230  +		install)
          231  +			appdir="$(appfsinstalldir)/${prefixsuffix}"
          232  +			mkdir -p "${appdir}"
          233  +
          234  +			cd "${destdir}/${prefix}" || exit 1
   217    235   
   218         -	cd "${destdir}/${prefix}" || exit 1
   219         -	cp -rp * "${appdir}"
   220         -	find "${appdir}" -print0 | xargs -0 touch -t "${pkgdate}"
   221         -)
          236  +			cp -rp * "${appdir}"
          237  +			find "${appdir}" -print0 | xargs -0 touch -t "${pkgdate}"
          238  +			find "${appdir}" -print0 | xargs -0 touch -m -t "${pkgdate}"
          239  +			find "${appdir}" -print0 | xargs -0 touch -a -t "${pkgdate}"
          240  +			;;
          241  +		archive)
          242  +			archivefile="${scriptdir}/${pkg}-${version}-$(echo "${pkgdate}" | sed 's@\.@@g')-${domain}.cpio"
          243  +			cd "${destdir}/${prefix}/../../.." || exit 1
          244  +			find "${prefixsuffix}" -print0 | xargs -0 touch -t "${pkgdate}"
          245  +			find "${prefixsuffix}" -print0 | xargs -0 touch -m -t "${pkgdate}"
          246  +			find "${prefixsuffix}" -print0 | xargs -0 touch -a -t "${pkgdate}"
          247  +			find "${prefixsuffix}" | sort | cpio --owner 0:0 -H newc -o > "${archivefile}"
          248  +			;;
          249  +	esac
          250  +) || die 'final installation failed'
   222    251   
   223    252   cleanup
   224    253   
   225    254   exit 0