Received: from mail-yb1-f178.google.com (mail-yb1-f178.google.com [209.85.219.178]) by nld3-dev1.alpinelinux.org (Postfix) with ESMTPS id 40052781A5B for <~alpine/devel@lists.alpinelinux.org>; Wed, 31 Jul 2019 19:59:39 +0000 (UTC) Received: by mail-yb1-f178.google.com with SMTP id a5so24857593ybo.13 for <~alpine/devel@lists.alpinelinux.org>; Wed, 31 Jul 2019 12:59:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=dNkr9DD3Xt9iXfNs0+ibhzzxnvcvnxWAscducS+sA74=; b=dLf2XD79aUO7/mTce/3Q9rfr2ELFV4lsGFIChTj7tzKtmqtKQbbQzY+j1zD7dvwqd6 Xpx0zCqLAX7o7r0mvfvPDmp/smvs8aVtxNNnYlhvd38JPRG/tMsdno1PgGsdwq99Y4BJ PXNKup5G/uE5PsTi6fBeFhqnKHMIHdOeYgAxZvIpKv4i8yX51/tfYuBMFsZ8ggUrfhGr U2USxf3saG2ChQMyfMud9IW1Ui/8ukpHD4q87vZCr3CyLVmqkvuJEHvGX45YrRq/R8yq gLppI+AHY/5kyDLxDN15QnKkXHNUknbOkzGr76hJ3jzUCBtF5MqlvgV4WQJQE9Pp4Nf0 pbgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=dNkr9DD3Xt9iXfNs0+ibhzzxnvcvnxWAscducS+sA74=; b=InJKnfifgDbNA67YktuwDxNU79eaw20OmB3mqS8XFOc9WeYDGeoO2ghom8j1p2ZsAE 3sSK2oDabpk3kIql32yCVF9UbtZgxVAWndOcO1yh5TKPXalpjrD0dkbabKMdkS/F3Xfe tM0FlRjK45WujWTZUZWv447XZNk/NdcWNVOz9DEsdMyTIYtTiJMTItKfc8tr/UqcOIXR swiLO8md2kDu/IbP1McBaigltQDNRAYp03jilnsAb8mWUm0C7WytFzJUAC+HIEFFvKhr iBlrYQBkP1Urpi1eg0BxL1CCsVEnIQjqzmpERBgfqQZ8guOaf6S/wYEqnGYki9R4NQvj DC1w== X-Gm-Message-State: APjAAAVYcvwfImhnvpXWtSbigDZ4gJl+ksLw1XeysV+/oMVHl+OGFhM5 WFNrMJpz1wjDgpKSLsK7zphhBYHm6ijgVwa3ztzVFkXuN0c= X-Google-Smtp-Source: =?utf-8?q?APXvYqwZpDxyh8K0H9Xj0VPECLWnnaSGG6rl9PAycPDW?= =?utf-8?q?SCN7hs8slRprm95dlbeXx3N9KMpvo+khlSA7x0yz9WBn9kY=3D?= X-Received: by 2002:a25:f202:: with SMTP id i2mr77826908ybe.462.1564603177420; Wed, 31 Jul 2019 12:59:37 -0700 (PDT) MIME-Version: 1.0 From: Konstantin Kulikov Date: Wed, 31 Jul 2019 19:59:26 +0000 Message-ID: Subject: Packaging go projects To: ~alpine/devel@lists.alpinelinux.org Content-Type: text/plain; charset="UTF-8" Hey everyone. I'm trying to package a go project which uses modules. This is what I came up with. https://github.com/alpinelinux/aports/pull/9800 Notes below: 1. fetch() depends on go command which means that abuild checksum will fail if go is not installed. 2. $SRCDEST will contain "go" directory with module archives using layout defined by goproxy protocol (see https://godoc.org/cmd/go#hdr-Module_proxy_protocol). The good thing is that directory can be served over http and used as real GOPROXY, avoiding contacting google or other proxies unnecessarily. Current go projects in aports run "glide install" or "dep ensure" inside prepare() or build() and do not cache sources at all. 3. GOPROXY should be defined in abuild.conf and default to https://proxy.golang.org or any other proxy to avoid depending on git,svn,bzr and others and allow users to use their own proxies (googles proxy is unavailable in China for example). 4. sha512sums doesn't record hashes of module files, instead they are recorded in go.sum file and go tool verifies them itself. 5. chmod line in fetch() is unfortunate, without it cleanup step will fail. Go devs previously refused to add option to make unpacked module files writable. 6. fetch() will be the same for every go project and can be defined in abuild and used with options="gomodule" for example, same goes for GOPATH var which should be set to the same value for all steps. 7. To build a project we create dummy module which I called "apk" (but can be any name). It allows to record exact version of every used dependency, selectively upgrade or replace those dependencies and record that info in binaries (it can be inspected using rsc.io/goversion or, since go 1.13, "go version"). 8. Patching is undoable in a way it's done in alpine (using .patch files) because checksums are recorded in binaries and can be verified against google's sumdb. Instead maintainer will need to fork project, apply patches, tag release and use their fork in APKBUILD. 9. To create new package contibutor would need to create apk.go and "blank import" all binaries in it, run "go mod init apk && go mod tidy", then write APKBUILD as usual. 10. To update a package `go get $(go list -f '{{ join .Imports " " }}')` can be used. If specific version is wanted instead of @latest, run manually "go get github.com/9seconds/mtg@v0.16" Does this look sane to you? Should we package it like this? Any other ideas?