Skip to content
Snippets Groups Projects
Commit be9fa503 authored by Natanael Copa's avatar Natanael Copa
Browse files

abuild: initial support for new apk format

parent 58cb2bc3
No related branches found
No related tags found
No related merge requests found
......@@ -295,19 +295,21 @@ prepare_metafiles() {
[ -z "${name##* *}" ] && die "package name contains spaces"
local dir=${subpkgdir:-$pkgdir}
local pkg="$name-$pkgver-r$pkgrel.apk"
local pkginfo="$controldir"/.PKGINFO
local sub
[ ! -d "$dir" ] && die "Missing $dir"
cd "$dir"
mkdir -p "$controldir"
local builddate=$(date -u "+%s")
local size=$(du -sk | awk '{print $1 * 1024}')
echo "# Generated by $(basename $0) $abuild_ver" >.PKGINFO
echo "# Generated by $(basename $0) $abuild_ver" >"$pkginfo"
if [ -n "$FAKEROOTKEY" ]; then
echo "# using $(fakeroot -v)" >> .PKGINFO
echo "# using $(fakeroot -v)" >> "$pkginfo"
fi
echo "# $(date -u)" >> .PKGINFO
cat >> .PKGINFO <<EOF
echo "# $(date -u)" >> "$pkginfo"
cat >> "$pkginfo" <<EOF
pkgname = $name
pkgver = $pkgver-r$pkgrel
pkgdesc = $pkgdesc
......@@ -329,32 +331,28 @@ EOF
fi
for i in $license; do
echo "license = $i" >>.PKGINFO
echo "license = $i" >> "$pkginfo"
done
for i in $replaces; do
echo "replaces = $i" >>.PKGINFO
echo "replaces = $i" >> "$pkginfo"
done
for i in $deps; do
echo "depend = $i" >>.PKGINFO
echo "depend = $i" >> "$pkginfo"
done
for i in $conflicts; do
echo "conflict = $i" >>.PKGINFO
echo "conflict = $i" >> "$pkginfo"
done
for i in $provides; do
echo "provides = $i" >>.PKGINFO
echo "provides = $i" >> "$pkginfo"
done
for i in $backup; do
echo "backup = $i" >>.PKGINFO
echo "backup = $i" >> "$pkginfo"
done
local metafiles=".PKGINFO"
for i in $install; do
script=${i#$name}
case "$script" in
.install)
warning "Deprecated .install script found."
script=.INSTALL
;;
.pre-install|.post-install|.pre-upgrade|.post-upgrade|.pre-deinstall|.post-deinstall)
msg "Adding $script"
;;
......@@ -362,23 +360,24 @@ EOF
return 1
;;
esac
cp "$srcdir/$i" "$dir/$script" || return 1
chmod +x "$dir/$script"
cp "$srcdir/$i" "$controldir/$script" || return 1
chmod +x "$controldir/$script"
metafiles="$metafiles $script"
done
echo $metafiles | tr ' ' '\n' > "$dir"/.metafiles
echo $metafiles | tr ' ' '\n' > "$controldir"/.metafiles
}
prepare_tracedeps() {
local dir=${subpkgdir:-$pkgdir}
options_has "!tracedeps" && return 0
find -name '*.so' -o -name '*.so.[0-9]*' | sed 's:.*/::' >"$dir"/.provides-so
find -name '*.so' -o -name '*.so.[0-9]*' | sed 's:.*/::' \
>"$controldir"/.provides-so
scanelf -Rn "$dir" | awk -F "\ " '$1 == "ET_DYN" || $1 == "ET_EXEC" {print $2}' \
| sed 's:,:\n:g' | sort | uniq \
| while read i; do
# only add files that are not self provided
grep "^$i$" "$dir"/.provides-so >/dev/null \
|| echo $i >> "$dir"/.needs-so
grep "^$i$" "$controldir"/.provides-so >/dev/null \
|| echo $i >> "$controldir"/.needs-so
done
}
......@@ -403,10 +402,10 @@ trace_apk_deps() {
for i in $(cat "$dir"/.needs-so 2>/dev/null); do
found=
# first check if its provide by same apkbuild
for j in "$dir"/../*/.provides-so; do
for j in "$dir"/../.control.*/.provides-so; do
grep -w "$i" "$j" >/dev/null || continue
found=${j%/.provides-so}
found=${found##*/}
found=${found##*/.control.}
break
done
# check apk db if not provided by a subpackage
......@@ -433,37 +432,33 @@ trace_apk_deps() {
create_apks() {
local file
for file in "$pkgbasedir"/*/.PKGINFO; do
for file in "$pkgbasedir"/.control.*/.PKGINFO; do
local dir="${file%/.PKGINFO}"
local name=$(pkginfo_val pkgname $file)
local ver=$(pkginfo_val pkgver $file)
local apk=$name-$ver.apk
local datadir="$pkgbasedir"/$name
trace_apk_deps "$name" "$dir" || return 1
msg "Creating $apk..."
(
cd "$datadir"
# data.tar.gz
tar -c . | abuild-tar --hash | gzip -9 >"$dir"/data.tar.gz
# append the hash for data.tar.gz
local sha256=$(sha256sum "$dir"/data.tar.gz | cut -f1 -d' ')
echo "datahash = $sha256" >> "$dir"/.PKGINFO
# control.tar.gz
cd "$dir"
set *
[ "$1" = '*' ] && set --
tar -zcf "$PKGDEST"/$apk $(cat .metafiles) $@
)
done
}
tar -c $(cat "$dir"/.metafiles) | abuild-tar --cut \
| gzip -9 > control.tar.gz
update_apkcache_index() {
local index="$apkcache"/APK_INDEX.gz
local opt=
(
for i in "$@"; do
pkg=${i##*/}
todelete="$todelete ${pkg%-[0-9]*.apk}"
# create the final apk
cat control.tar.gz data.tar.gz > "$PKGDEST"/$apk
)
done
if [ -f "$index" ]; then
apk index -q -d "$index" $todelete || exit 1
fi
apk index -q "$@" || exit 1
) > "$apkcache"/APK_INDEX.new || return 1
gzip "$apkcache"/APK_INDEX.new && mv "$apkcache/APK_INDEX.new.gz" "$index"
}
apkcache() {
......@@ -475,12 +470,11 @@ apkcache() {
set --
for apk in $(listpkg); do
ln -sf "$PKGDEST"/$apk "$apkcache"/$apk
set -- "$@" "$apkcache"/$apk
done
# update the apkcache cache here
msg "Updating the cached abuild repository index..."
update_apkcache_index "$@"
apk index -o "$apkcache"/APKINDEX.tar.gz "$apkcache"/*.apk
}
# predefined splitfunc doc
......@@ -960,6 +954,7 @@ if [ -n "$subpkgname" ]; then
install=
fi
pkgdir="$pkgbasedir/$pkgname"
controldir="$pkgbasedir"/.control.${subpkgname:-$pkgname}
trap 'die "Aborted by user"' INT
set_xterm_title "abuild: $pkgname"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment