Diff

Differences From Artifact [dcf6e62dd7]:

To Artifact [71498ef42a]:


1







2
3
4
5
6
7
8
9
10
11
12
13
#! /usr/bin/env bash








pkg="$(echo "$1" | sed 's@/*$@@;s@^\.*/*@@')"

if [ -z "${pkg}" ]; then
	echo "Usage: build <package>" 2>&1

	exit 1
fi

function determineOsArch() {
	os="$(uname -s | dd conv=lcase 2>/dev/null)"
	arch="$(uname -m | dd conv=lcase 2>/dev/null)"

>
>
>
>
>
>
>




|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#! /usr/bin/env bash

targetmode='install'
if [ "$1" == '--cpio' ]; then
	targetmode='archive'

	shift
fi

pkg="$(echo "$1" | sed 's@/*$@@;s@^\.*/*@@')"

if [ -z "${pkg}" ]; then
	echo "Usage: build [--cpio] <package>" 2>&1

	exit 1
fi

function determineOsArch() {
	os="$(uname -s | dd conv=lcase 2>/dev/null)"
	arch="$(uname -m | dd conv=lcase 2>/dev/null)"
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
}

function postbuild() {
	:
}

function build() {
	grep "DESTDIR" Makefile || die "Don't know how to build this software"

	make
}

function preinstall() {
	:
}







|







62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
}

function postbuild() {
	:
}

function build() {
	grep "DESTDIR" Makefile >/dev/null || die "Don't know how to build this software"

	make
}

function preinstall() {
	:
}
92
93
94
95
96
97
98
99







100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
	fi

	cleanup

	exit 1
}

cd "$(dirname "$(which "$0")")" || exit 1








if [ -f 'build.conf' ]; then
	. 'build.conf'
fi

if [ -d "pkgs/${pkg}" ]; then
	pkgdir="pkgs/${pkg}"
	pkgfile="${pkgdir}/info"
else
	pkgfile="pkgs/${pkg}"
	pkgdir="${pkgfile}"
fi

if [ ! -e "${pkgfile}" ]; then
	echo "Invalid package." >&2

	exit 1
fi

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)"
if [ -z "${pkgdate}" ]; then
	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)"
fi

. "${pkgfile}"

archivedir="$(pwd)/ARCHIVE"







|
>
>
>
>
>
>
>



















|







99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
	fi

	cleanup

	exit 1
}

scriptdir="$(cd "$(dirname "$(which "$0")")" && pwd)"
if [ -z "${scriptdir}" ]; then
	echo "Unable to locate script directory" >&2

	exit 1
fi

cd "${scriptdir}" || exit 1

if [ -f 'build.conf' ]; then
	. 'build.conf'
fi

if [ -d "pkgs/${pkg}" ]; then
	pkgdir="pkgs/${pkg}"
	pkgfile="${pkgdir}/info"
else
	pkgfile="pkgs/${pkg}"
	pkgdir="${pkgfile}"
fi

if [ ! -e "${pkgfile}" ]; then
	echo "Invalid package." >&2

	exit 1
fi

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)"
if [ -z "${pkgdate}" ]; then
	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)"
fi

. "${pkgfile}"

archivedir="$(pwd)/ARCHIVE"
208
209
210
211
212
213
214


215
216
217
218

219
220
221













222
223
224
225
postbuild || die 'postbuild failed'

preinstall || die 'preinstall failed'
install || die 'install failed'
postinstall || die 'postinstall failed'

(


	appdir="$(appfsinstalldir)/${prefixsuffix}"
	mkdir -p "${appdir}"

	cd "${destdir}/${prefix}" || exit 1

	cp -rp * "${appdir}"
	find "${appdir}" -print0 | xargs -0 touch -t "${pkgdate}"
)














cleanup

exit 0







>
>
|
|

|
>
|
|
<
>
>
>
>
>
>
>
>
>
>
>
>
>




222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237

238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
postbuild || die 'postbuild failed'

preinstall || die 'preinstall failed'
install || die 'install failed'
postinstall || die 'postinstall failed'

(
	case "${targetmode}" in
		install)
			appdir="$(appfsinstalldir)/${prefixsuffix}"
			mkdir -p "${appdir}"

			cd "${destdir}/${prefix}" || exit 1

			cp -rp * "${appdir}"
			find "${appdir}" -print0 | xargs -0 touch -t "${pkgdate}"

			find "${appdir}" -print0 | xargs -0 touch -m -t "${pkgdate}"
			find "${appdir}" -print0 | xargs -0 touch -a -t "${pkgdate}"
			;;
		archive)
			archivefile="${scriptdir}/${pkg}-${version}-$(echo "${pkgdate}" | sed 's@\.@@g')-${domain}.cpio"
			cd "${destdir}/${prefix}/../../.." || exit 1
			find "${prefixsuffix}" -print0 | xargs -0 touch -t "${pkgdate}"
			find "${prefixsuffix}" -print0 | xargs -0 touch -m -t "${pkgdate}"
			find "${prefixsuffix}" -print0 | xargs -0 touch -a -t "${pkgdate}"
			find "${prefixsuffix}" | sort | cpio --owner 0:0 -H newc -o > "${archivefile}"
			;;
	esac
) || die 'final installation failed'

cleanup

exit 0