Received: from mail-ot1-f44.google.com (mail-ot1-f44.google.com [209.85.210.44]) by nld3-dev1.alpinelinux.org (Postfix) with ESMTPS id 4EA2B782DB7 for <~alpine/apk-tools@lists.alpinelinux.org>; Sun, 8 May 2022 10:46:58 +0000 (UTC) Received: by mail-ot1-f44.google.com with SMTP id g11-20020a9d648b000000b00605e4278793so8152709otl.7 for <~alpine/apk-tools@lists.alpinelinux.org>; Sun, 08 May 2022 03:46:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=XPyQ+gmxMhA1VIdrqkbCa1WB+z5pwiNggob4dCrXjy4=; b=qGPPVI+rWPITHwYGOS7RKMTkFwrlKKNr6R2HjRkZRbDpBN12ROwM40s5Cf+ixfAvJ2 OEgS6WlaxBExiN/nJ5g8EBtEEY/F2Ym2UYejtwc23ea0Re3axh/tPBNZlAMUk7+JzTYr pqDRksqyMsIGMo1RyrlZber3TbiAYle/Ftl+98KEcnoOz5KI4y81Mq41Fh+hM2zB2NxB 5lZypLesi7AAcyZCANZwD8RDp1wFLkv+ClHyc+HWuDhKS5BqyR8kfnzHhcrjf6ClxdyW kSj6q5TYb6ZDGLIcXpNWrfjsO7/Dvd2rPXwaJkyHK6Tshc4ctNe9gV6Ci1R7iKdpn+vZ GD3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=XPyQ+gmxMhA1VIdrqkbCa1WB+z5pwiNggob4dCrXjy4=; b=vBok/pesFkFfghZUeMgMxI7rsInbVZ06nkIm1cZL5maqaJvvYDfY+pduiD3+ljBvCo V6QSJwpAfaM/hqoHs4BdFSTl0WQkzlXESXUjXfhNdS53W1Sn2VvIctyrQk/A2PKGyarp JWkjFt0W/BxUujBSbHqpFbBNZJXJa51cGoCB3+YJW9IeA5xnKg1fEMCfncjWNjX70yyD swCw38TUjvAN+SqMHURLSkot3Sp7Zl92Mirdh/DzY0h2XirNxO9DHjq+uHdpQS9g631D Zryg/eXm8dkCCYyrJXwBQ6qs+r6KqD4NtaHJeBtEBIIOTbIuvwVJgk6FArhg81fBVXt4 5oWw== X-Gm-Message-State: AOAM53170sfqWks01IwLu6YMerUsaTaxRRyguOW/GlJnXrRlcHbsPzRF ou8qOQNFsaQSMZysezH/OQjQlmaWD++pGB4rMluiVlKa810= X-Google-Smtp-Source: ABdhPJxw/f9blGp30N1s3C7lgL6eCx4xmk2NYp+lL3+0U19qGJCcqBj6GsVVhtxByLAHcywEHzlwerk8kr7d+ellzdg= X-Received: by 2002:a9d:2da8:0:b0:606:ef9:8c4b with SMTP id g37-20020a9d2da8000000b006060ef98c4bmr4199893otb.235.1652006816946; Sun, 08 May 2022 03:46:56 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Konstantin Kulikov Date: Sun, 8 May 2022 13:46:46 +0300 Message-ID: Subject: Re: Creating an .apk package from local files, without downloading and building sources To: Marc Balmer Cc: ~alpine/apk-tools@lists.alpinelinux.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Maybe you can use abuild directly? Redefine fetch() like below and you should be good. fetch() { default_fetch cp -r $path_to_your_sources $builddir } On Sun, May 8, 2022 at 10:22 AM Marc Balmer wrote: > > G'day! > > TL;DR: > > We are looking for a way to build an .apk package from locally installed = files, without going through the download and build stages that abuild norm= ally does. I.e without an APKBUILD file. > > A caveat: My first post to this list... I write this E-Mail using HTML f= or better readability of the code. If that is a no-go here, please tell me= and I will resend as plain text. > > > Our setting > > We have a large git repo with the source code for many libraries and bina= ries, much of them open source. We build and package them for various linu= x distributions and architectures. We use docker containers to build for t= he various systems. We think that our binaries, packaged for AlpineLinux,= would be a good fit for container use. We thus did setup a build containe= r for Alpine Linux, which builds all of our stuff just fine. > > We are now trying to create .apk packages using the already compiled libr= aries and binaries. Our approach is to create a directory for each package= we want to build and to describe the package using a Makefile. The packag= es Makefile then includes a Makefile fragment that drives the actual packag= e building. > > PACKAGE=3D lua > PKGVER=3D 5.4.4-r1 > DESCRIPTION=3D "Lua interpreter and compiler" > PACKAGER=3D micro systems > URL=3D https://lua.msys.ch > MAINTAINER=3D micro systems > LICENSE=3D MIT > > FILES=3D usr/bin/lua \ > usr/bin/luac > > MKDIR?=3D ../../../mk/ > > include $(MKDIR)alpine.package.mk > > The actual binaries are installed in the docker build container under /tm= p/alpine. We copy the files from there to a local staging directory "stagi= ng" and build the package from there. The Makefile Fragment alpine.package.= mk looks like this: > > LICENSE?=3D custom > PACKAGER?=3D unknown > DESCRIPTION?=3D unknwon > PACKAGER?=3D unknown > URL?=3D unknown > MAINTAINER?=3D unknown > > INSTSCRIPTS!=3D find . -name .p\*-\*install -exec basename {} \; > DATE_EPOCH!=3D date -u "+%s" > > .DEFAULT_GOAL=3D package > > package: > # Create the data part > @-mkdir -p staging > @tar -C /tmp/alpine -f - -c ${FILES} | tar -C staging -x > > find staging -exec touch -h -d @${DATE_EPOCH} {} + > > @(cd staging; tar --xattrs -f - -c *) | abuild-tar --hash | \ > gzip > data.tar.gz > > (cd staging; find . -print0) | LC_ALL=3DC sort -z | tar -C staging --xatt= rs \ > --xattrs-exclude=3Dsecurity.selinux \ > --format=3Dposix \ > --pax-option=3Dexthdr.name=3D%d/PaxHeaders/%f,atime:=3D0,ctime:=3D0 \ > --mtime=3D"@${DATE_EPOCH}" \ > --no-recursion --null -T - \ > -f - -c | abuild-tar --hash | gzip -n -9 >data.tar.gz > > # Create .PKGINFO > @echo "# Generated by alpine.package.mk" > .PKGINFO > @echo -n "# " >> .PKGINFO > @date >> .PKGINFO > @echo "package =3D ${PACKAGE}" >> .PKGINFO > @echo "pkgver =3D ${PKGVER}" >> .PKGINFO > @echo "pkgdesc =3D ${DESCRIPTION}" >> .PKGINFO > @echo "url =3D ${URL}" >> .PKGINFO > @echo "builddate =3D ${DATE_EPOCH}" >> .PKGINFO > @echo "commit =3D 5ff2c19564c162690aa5abbfb46fd6d3960c1c24" >> .PKGINFO > @echo "packager =3D ${PACKAGER}" >> .PKGINFO > @echo -n "size =3D " >> .PKGINFO > @(cd staging; du -b -c ${FILES}) | tail -n 1 | cut -f 1 >> .PKGINFO > @echo "arch =3D x86_64" >> .PKGINFO > @echo "origin =3D ${PACKAGE}" >> .PKGINFO > @echo "maintainer =3D ${MAINTAINER}" >> .PKGINFO > @echo "license =3D ${LICENSE}" >> .PKGINFO > @for dep in ${DEPENDS}; do echo "depend =3D $${dep}" >> .PKGINFO; done > @echo "# automatically detected:" >> .PKGINFO > @for f in ${FILES}; \ > do \ > find /tmp/alpine -name $${f} -type f -perm +111; \ > echo -n "provides =3D cmd:" >> .PKGINFO; \ > basename $${f} | tr -d '\n' >> .PKGINFO; \ > echo "=3D${PKGVER}" >> .PKGINFO; \ > done > @echo -n "datahash =3D " >>.PKGINFO > @sha256sum data.tar.gz | cut -d " " -f 1 >> .PKGINFO > > # Create the control part (index) > tar --format=3Dposix \ > --pax-option=3Dexthdr.name=3D%d/PaxHeaders/%f,atime:=3D0,ctime:=3D0 \ > --mtime=3D"@${DATE_EPOCH}" \ > -f - -c .PKGINFO ${INSTSCRIPTS} | abuild-tar --cut \ > | gzip -n -9 > control.tar.gz > > > #@tar --owner=3D0 --group=3D0 --numeric-owner -c .PKGINFO ${INSTSCRIPTS} = | \ > # abuild-tar --cut | gzip > control.tar.gz > @abuild-sign -q control.tar.gz > > # Produce the final apk > @cat control.tar.gz data.tar.gz > ${PACKAGE}-${PKGVER}.apk > @cat control.tar.gz data.tar.gz > /var/apk/${PACKAGE}-${PKGVER}.apk > -(cd /var/apk; apk index ${PACKAGE}-${PKGVER}.apk -o APKINDEX.tar.gz) > abuild-sign -q /var/apk/APKINDEX.tar.gz > > # Show info and clean up > @cat .PKGINFO > @rm -rf data.tar.gz control.tar.gz .PKGINFO staging > > Essentially, we try to run the packaging steps in the same way as abuild = does it (we used the abuild source > code as a reference). Of course our approach is not as elegant as abuild.= Moreover, it does not work, the > apk package being produced can not be installed. > > While the resulting .apk package looks like any other .apk package, and t= he content looks correct, apk exits > with exit code 99 when we try to add or index the package. apk add prints= "ERROR: Not supported." > > (Not supported seems to be the result from musl libc for an unknow error = code). > > Do you have any ideas what we are doing wrong? > > Thanks, > Marc > >