summarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Bermond2020-05-04 14:09:00 +0000
committerDaniel Bermond2020-05-04 14:09:00 +0000
commit5453e08c47e84dd2075d211e5fb030367012d7c4 (patch)
treed7d1593f0bbd142722a1c49623603eb1c2a83b6c
parent31b904c6cf73ceff1d8ab10002dfca1c92aacfc4 (diff)
downloadaur-5453e08c47e84dd2075d211e5fb030367012d7c4.tar.gz
Updated to version 0.3.4
-rw-r--r--.SRCINFO22
-rw-r--r--020-xd-torrent-use-trimpath-and-ldflags.patch12
-rw-r--r--030-xd-torrent-build-pie-binaries.patch22
-rw-r--r--060-xd-torrent-fix-tests-01.patch427
-rw-r--r--070-xd-torrent-fix-tests-02.patch191
-rw-r--r--PKGBUILD41
6 files changed, 29 insertions, 686 deletions
diff --git a/.SRCINFO b/.SRCINFO
index dcdb9d13b1e7..6080a5e92755 100644
--- a/.SRCINFO
+++ b/.SRCINFO
@@ -1,36 +1,26 @@
pkgbase = xd-torrent
pkgdesc = An I2P BitTorrent client
- pkgver = 0.3.3
- pkgrel = 2
+ pkgver = 0.3.4
+ pkgrel = 1
url = https://xd-torrent.github.io/
arch = x86_64
license = MIT
makedepends = go
depends = glibc
backup = etc/xd.conf
- source = xd-torrent-0.3.3.tar.gz::https://github.com/majestrate/XD/archive/v0.3.3.tar.gz
+ source = xd-torrent-0.3.4.tar.gz::https://github.com/majestrate/XD/archive/v0.3.4.tar.gz
source = 010-xd-torrent-fix-webui-target.patch
source = 020-xd-torrent-use-trimpath-and-ldflags.patch
source = 030-xd-torrent-build-pie-binaries.patch
source = 040-xd-torrent-rename-service-paths.patch
- source = 050-xd-torrent-fix-announcing-error.patch::https://github.com/majestrate/XD/commit/4a7084e35a709fd38166167742cf0a72d88f358d.patch
- source = 060-xd-torrent-fix-tests-01.patch
- source = 070-xd-torrent-fix-tests-02.patch
- source = 080-xd-torrent-fix-tests-03.patch::https://github.com/majestrate/XD/commit/baa497aea9146af703cc56434c2bc02077a19814.patch
- source = 090-xd-torrent-update-lokinet-tracker.patch::https://github.com/majestrate/XD/commit/d79ff87780d95e6ce1684d5fedd55f9f4ac4e40b.patch
source = xd-torrent.sysusers
source = xd-torrent.tmpfiles
source = xd.conf
- sha256sums = 90ad43883f9eb792e17054e8563a6260238c4ab513fa5a637be2d520d9b24b2a
+ sha256sums = 90a3df7a52ec30effe4a287728c1fd2d93a3a08b59cd2c6a971513d487d9d48a
sha256sums = 53c9b91bceabfbb33c42d5dee73b50c79c81e5d2ef219b8c4e7d8f40f1bd9b3f
- sha256sums = 77e71f4c5a825bc8144d733fbdc1d3e092321098930d84c215f916d7a9f68213
- sha256sums = 14b09ec95dcf87f5a56674344cfca3826a435eefdac73ca17ddf6593a18b8a5c
+ sha256sums = 929cfcd461debe96ea5efaa0497e38203186004dd86eb0b5ceecd183e339bfdc
+ sha256sums = 6e8ddb41d5f51e77a714baa08c225917eb9229c4847e449b73e7a26522d31805
sha256sums = e9dcf92897f2ece84ae8ee6aa8212bcd1ba945c942a01bfabe82a85867034b25
- sha256sums = f89eecd3f8663ff0f8d90d95f7ac4f00d97685fa479edde76034baa7a39bd895
- sha256sums = 0e28c3314b583f6e5a19f950e3254f3a8e0acc65b20c2d1831ec92d3a5defdb7
- sha256sums = 0deb4e4665e00886b27e4eb1b4fae4184542e2a64422f5d466fca6500dd10b51
- sha256sums = e1ef031e4d3e9bbbf6ce995b3f6666e3266f2594019fb87a819595aa3d4d66da
- sha256sums = 7e8665e4395ba0ea12813a28ee153c16b469f892b2d1253101222b27712b4165
sha256sums = 5f2fb392c2fec68bb3861ece85b5bbdd4929c4ccccf3caeb835060213c309761
sha256sums = 2688bb1f6a9812d0c926a105fd14815a285392514d639383f27e51615ff082fa
sha256sums = 2817f5eb6e204dd8e37fb4963a9b60d958ae063c6f082c41f92760802ea99530
diff --git a/020-xd-torrent-use-trimpath-and-ldflags.patch b/020-xd-torrent-use-trimpath-and-ldflags.patch
index fc57a81eba81..4e6ddeab60dc 100644
--- a/020-xd-torrent-use-trimpath-and-ldflags.patch
+++ b/020-xd-torrent-use-trimpath-and-ldflags.patch
@@ -1,4 +1,4 @@
-commit a6bbfa764557ea51a5b3e5f997dd908359c90c37
+commit 429cd6c9a1ba23847ce424cd07f5788930d0687b
Author: Daniel Bermond <danielbermond@gmail.com>
Date: Fri Sep 27 17:36:52 2019 +0000
@@ -13,7 +13,7 @@ Date: Fri Sep 27 17:36:52 2019 +0000
Signed-off-by: Daniel Bermond <danielbermond@gmail.com>
diff --git a/Makefile b/Makefile
-index fdb90f9..5870621 100644
+index fdb90f9..10b0e2d 100644
--- a/Makefile
+++ b/Makefile
@@ -51,16 +51,16 @@ build: $(CLI)
@@ -21,18 +21,18 @@ index fdb90f9..5870621 100644
$(GO_ASSETS):
- GOPATH=$(REPO) $(GO) build -o $(GO_ASSETS) -v github.com/jessevdk/go-assets-builder
-+ GOPATH=$(REPO) $(GO) build -gcflags "all=-trimpath=$${PWD}" -asmflags "all=-trimpath=$${PWD}" -o $(GO_ASSETS) -v github.com/jessevdk/go-assets-builder
++ GOPATH=$(REPO) $(GO) build -trimpath -ldflags "-extldflags ${LDFLAGS}" -o $(GO_ASSETS) -v github.com/jessevdk/go-assets-builder
$(ASSETS): $(GO_ASSETS) $(WEBUI_CORE)
$(GO_ASSETS) -p assets -s $(WEBUI_PREFIX) -o $(ASSETS) $(WEB_FILES)
$(XD): $(ASSETS)
- GOPATH=$(REPO) $(GO) build -a -ldflags "-X xd/lib/version.Git=$(GIT_VERSION)" -tags='$(TAGS)' -o $(XD)
-+ GOPATH=$(REPO) $(GO) build -gcflags "all=-trimpath=$${PWD}" -asmflags "all=-trimpath=$${PWD}" -a -ldflags "-X xd/lib/version.Git=$(GIT_VERSION) -s -w -extldflags '${LDFLAGS}'" -tags='$(TAGS)' -o $(XD)
++ GOPATH=$(REPO) $(GO) build -trimpath -a -ldflags "-X xd/lib/version.Git=$(GIT_VERSION) -extldflags ${LDFLAGS}" -tags='$(TAGS)' -o $(XD)
dev: $(ASSETS)
- GOPATH=$(REPO) $(GO) build -race -v -a -ldflags "-X xd/lib/version.Git=$(GIT_VERSION)" -tags='$(TAGS)' -o $(XD)
-+ GOPATH=$(REPO) $(GO) build -gcflags "all=-trimpath=$${PWD}" -asmflags "all=-trimpath=$${PWD}" -race -v -a -ldflags "-X xd/lib/version.Git=$(GIT_VERSION) -s -w -extldflags '${LDFLAGS}'" -tags='$(TAGS)' -o $(XD)
++ GOPATH=$(REPO) $(GO) build -trimpath -race -v -a -ldflags "-X xd/lib/version.Git=$(GIT_VERSION) -extldflags ${LDFLAGS}" -tags='$(TAGS)' -o $(XD)
$(CLI): $(XD)
$(RM) $(CLI)
@@ -41,7 +41,7 @@ index fdb90f9..5870621 100644
no-webui:
- GOPATH=$(REPO) $(GO) build -ldflags "-X xd/lib/version.Git=$(GIT_VERSION)" -o $(XD)
-+ GOPATH=$(REPO) $(GO) build -gcflags "all=-trimpath=$${PWD}" -asmflags "all=-trimpath=$${PWD}" -ldflags "-X xd/lib/version.Git=$(GIT_VERSION) -s -w -extldflags '${LDFLAGS}'" -o $(XD)
++ GOPATH=$(REPO) $(GO) build -trimpath -ldflags "-X xd/lib/version.Git=$(GIT_VERSION) -extldflags ${LDFLAGS}" -o $(XD)
install: $(XD) $(CLI)
$(MKDIR) $(PREFIX)/bin
diff --git a/030-xd-torrent-build-pie-binaries.patch b/030-xd-torrent-build-pie-binaries.patch
index 809bb61e936f..c0566abb9a2a 100644
--- a/030-xd-torrent-build-pie-binaries.patch
+++ b/030-xd-torrent-build-pie-binaries.patch
@@ -1,32 +1,32 @@
-commit b99a0976c2c6489b3b5c312b79af768acd9bc80f
+commit 0b3eb302d13fbd2c508ae2eba9374e8427ba1cc0
Author: Daniel Bermond <danielbermond@gmail.com>
-Date: Fri Sep 27 17:43:44 2019 +0000
+Date: Mon May 4 13:50:24 2020 +0000
Makefile: build PIE binaries
Signed-off-by: Daniel Bermond <danielbermond@gmail.com>
diff --git a/Makefile b/Makefile
-index 5870621..a5b5723 100644
+index 10b0e2d..ff9bda4 100644
--- a/Makefile
+++ b/Makefile
@@ -51,16 +51,16 @@ build: $(CLI)
assets: $(ASSETS)
$(GO_ASSETS):
-- GOPATH=$(REPO) $(GO) build -gcflags "all=-trimpath=$${PWD}" -asmflags "all=-trimpath=$${PWD}" -o $(GO_ASSETS) -v github.com/jessevdk/go-assets-builder
-+ GOPATH=$(REPO) $(GO) build -buildmode=pie -gcflags "all=-trimpath=$${PWD}" -asmflags "all=-trimpath=$${PWD}" -o $(GO_ASSETS) -v github.com/jessevdk/go-assets-builder
+- GOPATH=$(REPO) $(GO) build -trimpath -ldflags "-extldflags ${LDFLAGS}" -o $(GO_ASSETS) -v github.com/jessevdk/go-assets-builder
++ GOPATH=$(REPO) $(GO) build -buildmode=pie -trimpath -ldflags "-extldflags ${LDFLAGS}" -o $(GO_ASSETS) -v github.com/jessevdk/go-assets-builder
$(ASSETS): $(GO_ASSETS) $(WEBUI_CORE)
$(GO_ASSETS) -p assets -s $(WEBUI_PREFIX) -o $(ASSETS) $(WEB_FILES)
$(XD): $(ASSETS)
-- GOPATH=$(REPO) $(GO) build -gcflags "all=-trimpath=$${PWD}" -asmflags "all=-trimpath=$${PWD}" -a -ldflags "-X xd/lib/version.Git=$(GIT_VERSION) -s -w -extldflags '${LDFLAGS}'" -tags='$(TAGS)' -o $(XD)
-+ GOPATH=$(REPO) $(GO) build -buildmode=pie -gcflags "all=-trimpath=$${PWD}" -asmflags "all=-trimpath=$${PWD}" -a -ldflags "-X xd/lib/version.Git=$(GIT_VERSION) -s -w -extldflags '${LDFLAGS}'" -tags='$(TAGS)' -o $(XD)
+- GOPATH=$(REPO) $(GO) build -trimpath -a -ldflags "-X xd/lib/version.Git=$(GIT_VERSION) -extldflags ${LDFLAGS}" -tags='$(TAGS)' -o $(XD)
++ GOPATH=$(REPO) $(GO) build -buildmode=pie -trimpath -a -ldflags "-X xd/lib/version.Git=$(GIT_VERSION) -extldflags ${LDFLAGS}" -tags='$(TAGS)' -o $(XD)
dev: $(ASSETS)
-- GOPATH=$(REPO) $(GO) build -gcflags "all=-trimpath=$${PWD}" -asmflags "all=-trimpath=$${PWD}" -race -v -a -ldflags "-X xd/lib/version.Git=$(GIT_VERSION) -s -w -extldflags '${LDFLAGS}'" -tags='$(TAGS)' -o $(XD)
-+ GOPATH=$(REPO) $(GO) build -buildmode=pie -gcflags "all=-trimpath=$${PWD}" -asmflags "all=-trimpath=$${PWD}" -race -v -a -ldflags "-X xd/lib/version.Git=$(GIT_VERSION) -s -w -extldflags '${LDFLAGS}'" -tags='$(TAGS)' -o $(XD)
+- GOPATH=$(REPO) $(GO) build -trimpath -race -v -a -ldflags "-X xd/lib/version.Git=$(GIT_VERSION) -extldflags ${LDFLAGS}" -tags='$(TAGS)' -o $(XD)
++ GOPATH=$(REPO) $(GO) build -buildmode=pie -trimpath -race -v -a -ldflags "-X xd/lib/version.Git=$(GIT_VERSION) -extldflags ${LDFLAGS}" -tags='$(TAGS)' -o $(XD)
$(CLI): $(XD)
$(RM) $(CLI)
@@ -34,8 +34,8 @@ index 5870621..a5b5723 100644
webui: $(WEBUI_CORE)
no-webui:
-- GOPATH=$(REPO) $(GO) build -gcflags "all=-trimpath=$${PWD}" -asmflags "all=-trimpath=$${PWD}" -ldflags "-X xd/lib/version.Git=$(GIT_VERSION) -s -w -extldflags '${LDFLAGS}'" -o $(XD)
-+ GOPATH=$(REPO) $(GO) build -buildmode=pie -gcflags "all=-trimpath=$${PWD}" -asmflags "all=-trimpath=$${PWD}" -ldflags "-X xd/lib/version.Git=$(GIT_VERSION) -s -w -extldflags '${LDFLAGS}'" -o $(XD)
+- GOPATH=$(REPO) $(GO) build -trimpath -ldflags "-X xd/lib/version.Git=$(GIT_VERSION) -extldflags ${LDFLAGS}" -o $(XD)
++ GOPATH=$(REPO) $(GO) build -buildmode=pie -trimpath -ldflags "-X xd/lib/version.Git=$(GIT_VERSION) -extldflags ${LDFLAGS}" -o $(XD)
install: $(XD) $(CLI)
$(MKDIR) $(PREFIX)/bin
diff --git a/060-xd-torrent-fix-tests-01.patch b/060-xd-torrent-fix-tests-01.patch
deleted file mode 100644
index c5bda5b92452..000000000000
--- a/060-xd-torrent-fix-tests-01.patch
+++ /dev/null
@@ -1,427 +0,0 @@
-backport of https://github.com/majestrate/XD/commit/e320c7c796fdd6d9587fd82a1f466ce196b827f2
-
-diff --git a/src/xd/lib/bittorrent/extensions/extensions.go b/src/xd/lib/bittorrent/extensions/extensions.go
-index d2b7640..29c255b 100644
---- a/src/xd/lib/bittorrent/extensions/extensions.go
-+++ b/src/xd/lib/bittorrent/extensions/extensions.go
-@@ -4,7 +4,6 @@ import (
- "errors"
- "github.com/zeebo/bencode"
- "xd/lib/common"
-- "xd/lib/log"
- "xd/lib/util"
- "xd/lib/version"
- )
-@@ -117,7 +116,6 @@ func (opts Message) ToWireMessage() common.WireMessage {
- body = opts.PayloadRaw
- } else {
- // wtf? invalid message
-- log.Errorf("cannot create invalid extended message: %q", opts)
- return nil
- }
- return common.NewWireMessage(common.Extended, []byte{opts.ID}, body)
-diff --git a/src/xd/lib/bittorrent/swarm/peer.go b/src/xd/lib/bittorrent/swarm/peer.go
-index d627d84..4a9221e 100644
---- a/src/xd/lib/bittorrent/swarm/peer.go
-+++ b/src/xd/lib/bittorrent/swarm/peer.go
-@@ -227,11 +227,11 @@ func (c *PeerConn) Unchoke() {
- }
- }
-
--func (c *PeerConn) gotDownload(p common.PieceData) {
-+func (c *PeerConn) gotDownload(p *common.PieceData) {
- c.access.Lock()
- var downloading []common.PieceRequest
- for idx := range c.downloading {
-- if c.downloading[idx].Matches(&p) {
-+ if c.downloading[idx].Matches(p) {
- c.t.pt.handlePieceData(p)
- } else {
- downloading = append(downloading, c.downloading[idx])
-@@ -411,8 +411,6 @@ func (c *PeerConn) metaInfoDownload() {
- } else {
- log.Debugf("metainfo len=%d", len(c.t.metaInfo))
- }
-- } else {
-- log.Debugf("no metainfo size: %q", c.theirOpts)
- }
- id, ok := c.theirOpts.Extensions[extensions.UTMetaData.String()]
- if ok {
-@@ -633,7 +631,6 @@ func (c *PeerConn) sendLNPEX(connected, disconnected []common.Peer) {
- }
-
- func (c *PeerConn) handleExtendedOpts(opts extensions.Message) {
-- log.Debugf("got extended opts from %s: %q", c.id.String(), opts)
- if opts.ID == 0 {
- // handshake
- c.theirOpts = opts.Copy()
-@@ -749,7 +746,7 @@ func (c *PeerConn) tickDownload() {
- }
- } else if (c.usInterested || c.peerInterested) && !c.closing {
- if c.RemoteChoking() {
-- log.Debugf("will not download this tick, %s is choking", c.id.String())
-+ //log.Debugf("will not download this tick, %s is choking", c.id.String())
- return
- }
- // pending request
-diff --git a/src/xd/lib/bittorrent/swarm/piece.go b/src/xd/lib/bittorrent/swarm/piece.go
-index 328882f..d796aa4 100644
---- a/src/xd/lib/bittorrent/swarm/piece.go
-+++ b/src/xd/lib/bittorrent/swarm/piece.go
-@@ -224,14 +224,14 @@ func (pt *pieceTracker) canceledRequest(r common.PieceRequest) {
- })
- }
-
--func (pt *pieceTracker) handlePieceData(d common.PieceData) {
-+func (pt *pieceTracker) handlePieceData(d *common.PieceData) {
- idx := d.Index
- pt.visitCached(idx, func(pc *cachedPiece) {
- if !pc.accept(d.Begin, uint32(len(d.Data))) {
- log.Errorf("invalid piece data: index=%d offset=%d length=%d", d.Index, d.Begin, len(d.Data))
- return
- }
-- err := pt.st.PutChunk(idx, d.Begin, d.Data)
-+ err := pt.st.PutChunk(d)
- if err == nil {
- pc.put(d.Begin)
- } else {
-diff --git a/src/xd/lib/bittorrent/swarm/torrent.go b/src/xd/lib/bittorrent/swarm/torrent.go
-index fdbd907..43c6ad7 100644
---- a/src/xd/lib/bittorrent/swarm/torrent.go
-+++ b/src/xd/lib/bittorrent/swarm/torrent.go
-@@ -832,7 +832,7 @@ func (t *Torrent) handlePieceRequest(c *PeerConn, r common.PieceRequest) {
- c.Close()
- }
- } else {
-- log.Infof("%s asked for oversized piece bytes=%d", r.Length)
-+ log.Infof("%s asked for oversized piece bytes=%d", c.id.String(), r.Length)
- c.Close()
- }
- } else {
-diff --git a/src/xd/lib/common/wire.go b/src/xd/lib/common/wire.go
-index ecfc609..e33778f 100644
---- a/src/xd/lib/common/wire.go
-+++ b/src/xd/lib/common/wire.go
-@@ -185,7 +185,7 @@ func (req PieceRequest) ToWireMessage() WireMessage {
- }
-
- // VisitPieceData gets this wire message as a PieceData if applicable
--func (msg WireMessage) VisitPieceData(v func(PieceData)) {
-+func (msg WireMessage) VisitPieceData(v func(*PieceData)) {
-
- if msg.MessageID() == Piece {
- data := msg.Payload()
-@@ -194,7 +194,7 @@ func (msg WireMessage) VisitPieceData(v func(PieceData)) {
- p.Index = binary.BigEndian.Uint32(data[:])
- p.Begin = binary.BigEndian.Uint32(data[4:])
- p.Data = data[8:]
-- v(p)
-+ v(&p)
- }
- }
- return
-diff --git a/src/xd/lib/fs/fs.go b/src/xd/lib/fs/fs.go
-index ff69b01..e17a7d5 100644
---- a/src/xd/lib/fs/fs.go
-+++ b/src/xd/lib/fs/fs.go
-@@ -2,6 +2,7 @@ package fs
-
- import (
- "io"
-+ "os"
- )
-
- type ReadFile interface {
-@@ -12,6 +13,7 @@ type ReadFile interface {
- type WriteFile interface {
- io.WriteCloser
- io.WriterAt
-+ Sync() error
- }
-
- type Driver interface {
-@@ -40,4 +42,6 @@ type Driver interface {
- Move(oldPath, newPath string) error
- // split path into dirname, basename
- Split(path string) (string, string)
-+ // call stat()
-+ Stat(path string) (os.FileInfo, error)
- }
-diff --git a/src/xd/lib/fs/sftp.go b/src/xd/lib/fs/sftp.go
-index 26f718e..79ee6d2 100644
---- a/src/xd/lib/fs/sftp.go
-+++ b/src/xd/lib/fs/sftp.go
-@@ -23,6 +23,10 @@ func (f *sftpFile) Write(data []byte) (int, error) {
- return f.f.Write(data)
- }
-
-+func (f *sftpFile) Sync() error {
-+ return nil
-+}
-+
- func (f *sftpFile) Read(data []byte) (int, error) {
- return f.f.Read(data)
- }
-@@ -303,6 +307,14 @@ func (fs *sftpFS) Remove(fpath string) error {
- })
- }
-
-+func (fs *sftpFS) Stat(fpath string) (fi os.FileInfo, err error) {
-+ err = fs.ensureConn(func(c *sftp.Client) error {
-+ fi, err = c.Stat(fpath)
-+ return err
-+ })
-+ return
-+}
-+
- func (fs *sftpFS) RemoveAll(fpath string) error {
- return fs.ensureConn(func(c *sftp.Client) error {
- st, err := c.Stat(fpath)
-diff --git a/src/xd/lib/fs/std.go b/src/xd/lib/fs/std.go
-index c1618a9..2e2c9f8 100644
---- a/src/xd/lib/fs/std.go
-+++ b/src/xd/lib/fs/std.go
-@@ -67,3 +67,7 @@ func (f stdFs) Split(path string) (base, file string) {
- base, file = filepath.Split(path)
- return
- }
-+
-+func (f stdFs) Stat(path string) (os.FileInfo, error) {
-+ return os.Stat(path)
-+}
-diff --git a/src/xd/lib/metainfo/metainfo.go b/src/xd/lib/metainfo/metainfo.go
-index 3e096ff..5ad082e 100644
---- a/src/xd/lib/metainfo/metainfo.go
-+++ b/src/xd/lib/metainfo/metainfo.go
-@@ -3,6 +3,7 @@ package metainfo
- import (
- "bytes"
- "crypto/sha1"
-+ "encoding/hex"
- "github.com/zeebo/bencode"
- "io"
- "path/filepath"
-@@ -76,7 +77,11 @@ func (i Info) CheckPiece(p *common.PieceData) bool {
- if i.NumPieces() > p.Index {
- h := sha1.Sum(p.Data)
- expected := i.Pieces[idx : idx+20]
-- return bytes.Equal(h[:], expected)
-+ if bytes.Equal(h[:], expected) {
-+ return true
-+ }
-+ log.Warnf("piece missmatch: %s != %s", hex.EncodeToString(h[:]), hex.EncodeToString(expected))
-+ return false
- }
- log.Error("piece index out of bounds")
- return false
-diff --git a/src/xd/lib/mktorrent/mktorrent.go b/src/xd/lib/mktorrent/mktorrent.go
-new file mode 100644
-index 0000000..b6a58f7
---- /dev/null
-+++ b/src/xd/lib/mktorrent/mktorrent.go
-@@ -0,0 +1,56 @@
-+package mktorrent
-+
-+import (
-+ "crypto/sha1"
-+ "errors"
-+ "io"
-+ "path/filepath"
-+ "xd/lib/fs"
-+ "xd/lib/metainfo"
-+)
-+
-+func mkTorrentSingle(f fs.Driver, fpath string, pieceLength uint32) (*metainfo.TorrentFile, error) {
-+ var info metainfo.Info
-+
-+ info.PieceLength = pieceLength
-+ info.Path = filepath.Base(fpath)
-+
-+ r, err := f.OpenFileReadOnly(fpath)
-+ if err != nil {
-+ return nil, err
-+ }
-+ buff := make([]byte, info.PieceLength)
-+ for {
-+ n, err := io.ReadFull(r, buff)
-+ if err == io.ErrUnexpectedEOF {
-+ err = nil
-+ d := sha1.Sum(buff[0:n])
-+ info.Pieces = append(info.Pieces, d[:]...)
-+ break
-+ } else if err == nil {
-+ d := sha1.Sum(buff)
-+ info.Pieces = append(info.Pieces, d[:]...)
-+ } else {
-+ return nil, err
-+ }
-+ }
-+
-+ return &metainfo.TorrentFile{
-+ Info: info,
-+ }, nil
-+}
-+
-+func mkTorrentDir(f fs.Driver, fpath string, pieceLength uint32) (*metainfo.TorrentFile, error) {
-+ return nil, errors.New("not implemented")
-+}
-+
-+func MakeTorrent(f fs.Driver, fpath string, pieceLength uint32) (*metainfo.TorrentFile, error) {
-+ st, err := f.Stat(fpath)
-+ if err != nil {
-+ return nil, err
-+ }
-+ if st.IsDir() {
-+ return mkTorrentDir(f, fpath, pieceLength)
-+ }
-+ return mkTorrentSingle(f, fpath, pieceLength)
-+}
-diff --git a/src/xd/lib/storage/fs.go b/src/xd/lib/storage/fs.go
-index ad92604..fbe8e91 100644
---- a/src/xd/lib/storage/fs.go
-+++ b/src/xd/lib/storage/fs.go
-@@ -198,6 +198,7 @@ func (t *fsTorrent) WriteAt(p []byte, off int64) (n int, err error) {
- return
- }
- n1, err = f.WriteAt(p[:n1], off)
-+ f.Sync()
- f.Close()
- if err != nil {
- return
-@@ -378,7 +379,12 @@ func (t *fsTorrent) VerifyAll() (err error) {
- return
- }
-
--func (t *fsTorrent) PutChunk(idx, offset uint32, data []byte) (err error) {
-+func (t *fsTorrent) PutChunk(d *common.PieceData) (err error) {
-+ err = t.putChunk(d.Index, d.Begin, d.Data)
-+ return
-+}
-+
-+func (t *fsTorrent) putChunk(idx, offset uint32, data []byte) (err error) {
- if t.meta == nil {
- err = ErrNoMetaInfo
- return
-@@ -386,6 +392,7 @@ func (t *fsTorrent) PutChunk(idx, offset uint32, data []byte) (err error) {
- t.access.Lock()
- sz := int64(t.meta.Info.PieceLength)
- off := (sz * int64(idx)) + int64(offset)
-+ log.Debugf("put chunk idx=%d off=%d globaloff=%d len=%d", idx, offset, off, len(data))
- if t.st.pooledIO() {
- iop := writeIOP{
- data: data,
-diff --git a/src/xd/lib/storage/storage.go b/src/xd/lib/storage/storage.go
-index fa8a6d7..2b1c51f 100644
---- a/src/xd/lib/storage/storage.go
-+++ b/src/xd/lib/storage/storage.go
-@@ -23,8 +23,8 @@ type Torrent interface {
- // return true if we are currently doing a deep check
- Checking() bool
-
-- // put a chunk of data at index and offset
-- PutChunk(idx, offset uint32, data []byte) error
-+ // put a chunk of data
-+ PutChunk(pc *common.PieceData) error
-
- // visit a piece from storage
- GetPiece(r common.PieceRequest, pc *common.PieceData) error
-diff --git a/src/xd/lib/storage/storage_test.go b/src/xd/lib/storage/storage_test.go
-new file mode 100644
-index 0000000..1f57421
---- /dev/null
-+++ b/src/xd/lib/storage/storage_test.go
-@@ -0,0 +1,86 @@
-+package storage
-+
-+import (
-+ "crypto/rand"
-+ "io"
-+ "testing"
-+ "xd/lib/common"
-+ "xd/lib/fs"
-+ "xd/lib/metainfo"
-+ "xd/lib/mktorrent"
-+)
-+
-+const testPieceLen = 65536
-+
-+func createRandomTorrent(testFname string) (*metainfo.TorrentFile, error) {
-+ f, err := fs.STD.OpenFileWriteOnly(testFname)
-+ if err != nil {
-+ return nil, err
-+ }
-+ _, err = io.CopyN(f, rand.Reader, (testPieceLen*8)+128)
-+ f.Sync()
-+ f.Close()
-+
-+ return mktorrent.MakeTorrent(fs.STD, testFname, testPieceLen)
-+}
-+
-+func TestStorage(t *testing.T) {
-+
-+ st := &FsStorage{
-+ MetaDir: "storage",
-+ DataDir: "data",
-+ SeedingDir: "seeding",
-+ FS: fs.STD,
-+ }
-+
-+ err := st.Init()
-+ if err != nil {
-+ t.Log("failed to init storage")
-+ t.Fail()
-+ return
-+ }
-+ fname := st.FS.Join(st.DataDir, "test.bin")
-+ meta, err := createRandomTorrent(fname)
-+ if err != nil {
-+ t.Logf("failed to make torrent: %s", err.Error())
-+ t.Fail()
-+ return
-+ }
-+
-+ torrent, err := st.OpenTorrent(meta)
-+ if err != nil {
-+ t.Log("failed to open torrent")
-+ t.Fail()
-+ return
-+ }
-+ err = torrent.VerifyAll()
-+ if err != nil {
-+ t.Log("verify all failed")
-+ t.Fail()
-+ return
-+ }
-+ var pc common.PieceData
-+ err = torrent.GetPiece(common.PieceRequest{
-+ Index: 0,
-+ Begin: 0,
-+ Length: 16384,
-+ }, &pc)
-+
-+ if err != nil {
-+ t.Fail()
-+ return
-+ }
-+
-+ err = torrent.PutChunk(&pc)
-+ if err != nil {
-+ t.Fail()
-+ return
-+ }
-+
-+ err = torrent.VerifyPiece(0)
-+ if err != nil {
-+ t.Fail()
-+ return
-+ }
-+
-+}
-diff --git a/vendor b/vendor
-deleted file mode 120000
-index e831038..0000000
---- a/vendor
-+++ /dev/null
-@@ -1 +0,0 @@
--src
-\ No newline at end of file
diff --git a/070-xd-torrent-fix-tests-02.patch b/070-xd-torrent-fix-tests-02.patch
deleted file mode 100644
index 8f290dcbe5f2..000000000000
--- a/070-xd-torrent-fix-tests-02.patch
+++ /dev/null
@@ -1,191 +0,0 @@
-backport of https://github.com/majestrate/XD/commit/4ce9d0ac14a84fcc8a419b46b996de984b1fce79
-
-diff --git a/src/xd/lib/fs/std.go b/src/xd/lib/fs/std.go
-index 2e2c9f8..76615b2 100644
---- a/src/xd/lib/fs/std.go
-+++ b/src/xd/lib/fs/std.go
-@@ -39,7 +39,7 @@ func (f stdFs) OpenFileReadOnly(fname string) (ReadFile, error) {
- }
-
- func (f stdFs) OpenFileWriteOnly(fname string) (WriteFile, error) {
-- return os.OpenFile(fname, os.O_CREATE|os.O_WRONLY, 0600)
-+ return os.OpenFile(fname, os.O_WRONLY|os.O_CREATE, 0755)
- }
-
- func (f stdFs) RemoveAll(fname string) error {
-diff --git a/src/xd/lib/mktorrent/mktorrent.go b/src/xd/lib/mktorrent/mktorrent.go
-index b6a58f7..a7dcaca 100644
---- a/src/xd/lib/mktorrent/mktorrent.go
-+++ b/src/xd/lib/mktorrent/mktorrent.go
-@@ -26,10 +26,12 @@ func mkTorrentSingle(f fs.Driver, fpath string, pieceLength uint32) (*metainfo.T
- err = nil
- d := sha1.Sum(buff[0:n])
- info.Pieces = append(info.Pieces, d[:]...)
-+ info.Length += uint64(n)
- break
- } else if err == nil {
- d := sha1.Sum(buff)
- info.Pieces = append(info.Pieces, d[:]...)
-+ info.Length += uint64(n)
- } else {
- return nil, err
- }
-diff --git a/src/xd/lib/storage/fs.go b/src/xd/lib/storage/fs.go
-index fbe8e91..cd6c630 100644
---- a/src/xd/lib/storage/fs.go
-+++ b/src/xd/lib/storage/fs.go
-@@ -100,7 +100,7 @@ func (t *fsTorrent) Allocate() (err error) {
- return
- }
-
--func (t fsTorrent) openfileRead(i metainfo.FileInfo) (f fs.ReadFile, err error) {
-+func (t *fsTorrent) openfileRead(i metainfo.FileInfo) (f fs.ReadFile, err error) {
- var fname string
- if t.meta.IsSingleFile() {
- fname = t.FilePath()
-@@ -111,7 +111,7 @@ func (t fsTorrent) openfileRead(i metainfo.FileInfo) (f fs.ReadFile, err error)
- return
- }
-
--func (t fsTorrent) openfileWrite(i metainfo.FileInfo) (f fs.WriteFile, err error) {
-+func (t *fsTorrent) openfileWrite(i metainfo.FileInfo) (f fs.WriteFile, err error) {
- var fname string
- if t.meta.IsSingleFile() {
- fname = t.FilePath()
-@@ -122,7 +122,7 @@ func (t fsTorrent) openfileWrite(i metainfo.FileInfo) (f fs.WriteFile, err error
- return
- }
-
--func (t fsTorrent) readFileAt(fi metainfo.FileInfo, b []byte, off int64) (n int, err error) {
-+func (t *fsTorrent) readFileAt(fi metainfo.FileInfo, b []byte, off int64) (n int, err error) {
-
- // from github.com/anacrolix/torrent
- var f fs.ReadFile
-@@ -149,6 +149,7 @@ func (t fsTorrent) readFileAt(fi metainfo.FileInfo, b []byte, off int64) (n int,
- }
-
- func (t *fsTorrent) ReadAt(b []byte, off int64) (n int, err error) {
-+ l := len(b)
- files := t.meta.Info.GetFiles()
- // from github.com/anacrolix/torrent
- for _, fi := range files {
-@@ -158,6 +159,7 @@ func (t *fsTorrent) ReadAt(b []byte, off int64) (n int, err error) {
- n += n1
- off += int64(n1)
- b = b[n1:]
-+
- if len(b) == 0 {
- // Got what we need.
- return
-@@ -299,9 +301,8 @@ func (t *fsTorrent) GetPiece(r common.PieceRequest, pc *common.PieceData) (err e
- t.access.Lock()
- sz := t.meta.Info.PieceLength
- offset := int64(r.Begin) + (int64(sz) * int64(r.Index))
-- if pc.Data == nil || uint32(len(pc.Data)) != r.Length {
-- pc.Data = make([]byte, r.Length)
-- }
-+ pc.Data = make([]byte, r.Length)
-+ log.Debugf("get piece %d offset=%d len=%d", r.Index, r.Begin, r.Length)
- if t.st.pooledIO() {
- iop := readIOP{
- offset: offset,
-@@ -324,20 +325,17 @@ func (t *fsTorrent) GetPiece(r common.PieceRequest, pc *common.PieceData) (err e
- }
-
- func (t *fsTorrent) VerifyPiece(idx uint32) (err error) {
-- var pc common.PieceData
-- err = t.verifyPiece(idx, &pc)
-- return
--}
--
--func (t *fsTorrent) verifyPiece(idx uint32, pc *common.PieceData) (err error) {
- l := t.meta.LengthOfPiece(idx)
- r := common.PieceRequest{
- Index: idx,
- Length: l,
- }
-- err = t.GetPiece(r, pc)
-+ var pc common.PieceData
-+ pc.Data = make([]byte, l)
-+ pc.Index = idx
-+ err = t.GetPiece(r, &pc)
- if err == nil {
-- if t.meta.Info.CheckPiece(pc) {
-+ if t.meta.Info.CheckPiece(&pc) {
- t.bf.Set(pc.Index)
- } else {
- t.bf.Unset(pc.Index)
-@@ -352,18 +350,15 @@ func (t *fsTorrent) VerifyAll() (err error) {
- err = ErrNoMetaInfo
- return
- }
-- var pc common.PieceData
- t.bfmtx.Lock()
- t.checking = true
- log.Infof("checking local data for %s", t.Name())
- t.ensureBitfield()
- info := t.MetaInfo().Info
- sz := info.NumPieces()
-- pc.Data = make([]byte, info.PieceLength)
- idx := uint32(0)
- for idx < sz {
-- t := t
-- err = t.verifyPiece(uint32(idx), &pc)
-+ err = t.VerifyPiece(uint32(idx))
- if err == common.ErrInvalidPiece {
- err = nil
- } else if err != nil {
-diff --git a/src/xd/lib/storage/storage_test.go b/src/xd/lib/storage/storage_test.go
-index 1f57421..12339c3 100644
---- a/src/xd/lib/storage/storage_test.go
-+++ b/src/xd/lib/storage/storage_test.go
-@@ -6,6 +6,7 @@ import (
- "testing"
- "xd/lib/common"
- "xd/lib/fs"
-+ "xd/lib/log"
- "xd/lib/metainfo"
- "xd/lib/mktorrent"
- )
-@@ -26,6 +27,8 @@ func createRandomTorrent(testFname string) (*metainfo.TorrentFile, error) {
-
- func TestStorage(t *testing.T) {
-
-+ log.SetLevel("debug")
-+
- st := &FsStorage{
- MetaDir: "storage",
- DataDir: "data",
-@@ -61,24 +64,30 @@ func TestStorage(t *testing.T) {
- }
- var pc common.PieceData
- err = torrent.GetPiece(common.PieceRequest{
-- Index: 0,
-+ Index: 1,
- Begin: 0,
- Length: 16384,
- }, &pc)
-
- if err != nil {
-+ t.Log(err.Error())
- t.Fail()
- return
- }
-
-+ log.Infof("put chunk: idx=%d offset=%d", pc.Index, pc.Begin)
-+
- err = torrent.PutChunk(&pc)
- if err != nil {
-+ t.Log(err.Error())
- t.Fail()
- return
- }
-
-- err = torrent.VerifyPiece(0)
-+ log.Infof("verify piece 1")
-+ err = torrent.VerifyPiece(1)
- if err != nil {
-+ t.Log(err.Error())
- t.Fail()
- return
- }
diff --git a/PKGBUILD b/PKGBUILD
index fc724bd842da..3baf7747a6d9 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -1,8 +1,8 @@
-# Maintainer: Daniel Bermond < gmail-com: danielbermond >
+# Maintainer: Daniel Bermond <dbermond@archlinux.org>
pkgname=xd-torrent
-pkgver=0.3.3
-pkgrel=2
+pkgver=0.3.4
+pkgrel=1
pkgdesc='An I2P BitTorrent client'
arch=('x86_64')
url='https://xd-torrent.github.io/'
@@ -15,52 +15,23 @@ source=("${pkgname}-${pkgver}.tar.gz"::"https://github.com/majestrate/XD/archive
'020-xd-torrent-use-trimpath-and-ldflags.patch'
'030-xd-torrent-build-pie-binaries.patch'
'040-xd-torrent-rename-service-paths.patch'
- '050-xd-torrent-fix-announcing-error.patch'::'https://github.com/majestrate/XD/commit/4a7084e35a709fd38166167742cf0a72d88f358d.patch'
- '060-xd-torrent-fix-tests-01.patch'
- '070-xd-torrent-fix-tests-02.patch'
- '080-xd-torrent-fix-tests-03.patch'::'https://github.com/majestrate/XD/commit/baa497aea9146af703cc56434c2bc02077a19814.patch'
- '090-xd-torrent-update-lokinet-tracker.patch'::'https://github.com/majestrate/XD/commit/d79ff87780d95e6ce1684d5fedd55f9f4ac4e40b.patch'
'xd-torrent.sysusers'
'xd-torrent.tmpfiles'
'xd.conf')
-sha256sums=('90ad43883f9eb792e17054e8563a6260238c4ab513fa5a637be2d520d9b24b2a'
+sha256sums=('90a3df7a52ec30effe4a287728c1fd2d93a3a08b59cd2c6a971513d487d9d48a'
'53c9b91bceabfbb33c42d5dee73b50c79c81e5d2ef219b8c4e7d8f40f1bd9b3f'
- '77e71f4c5a825bc8144d733fbdc1d3e092321098930d84c215f916d7a9f68213'
- '14b09ec95dcf87f5a56674344cfca3826a435eefdac73ca17ddf6593a18b8a5c'
+ '929cfcd461debe96ea5efaa0497e38203186004dd86eb0b5ceecd183e339bfdc'
+ '6e8ddb41d5f51e77a714baa08c225917eb9229c4847e449b73e7a26522d31805'
'e9dcf92897f2ece84ae8ee6aa8212bcd1ba945c942a01bfabe82a85867034b25'
- 'f89eecd3f8663ff0f8d90d95f7ac4f00d97685fa479edde76034baa7a39bd895'
- '0e28c3314b583f6e5a19f950e3254f3a8e0acc65b20c2d1831ec92d3a5defdb7'
- '0deb4e4665e00886b27e4eb1b4fae4184542e2a64422f5d466fca6500dd10b51'
- 'e1ef031e4d3e9bbbf6ce995b3f6666e3266f2594019fb87a819595aa3d4d66da'
- '7e8665e4395ba0ea12813a28ee153c16b469f892b2d1253101222b27712b4165'
'5f2fb392c2fec68bb3861ece85b5bbdd4929c4ccccf3caeb835060213c309761'
'2688bb1f6a9812d0c926a105fd14815a285392514d639383f27e51615ff082fa'
'2817f5eb6e204dd8e37fb4963a9b60d958ae063c6f082c41f92760802ea99530')
prepare() {
- # fix the 'webui' target for not compiling a second time at 'make install'
patch -d "XD-${pkgver}" -Np1 -i "${srcdir}/010-xd-torrent-fix-webui-target.patch"
-
- # use -trimpath and Arch Linux LDFLAGS
patch -d "XD-${pkgver}" -Np1 -i "${srcdir}/020-xd-torrent-use-trimpath-and-ldflags.patch"
-
- # build PIE binaries
patch -d "XD-${pkgver}" -Np1 -i "${srcdir}/030-xd-torrent-build-pie-binaries.patch"
-
- # rename working directory and config file on systemd service
patch -d "XD-${pkgver}" -Np1 -i "${srcdir}/040-xd-torrent-rename-service-paths.patch"
-
- # fix announcing error
- # https://github.com/majestrate/XD/issues/71
- patch -d "XD-${pkgver}" -Np1 -i "${srcdir}/050-xd-torrent-fix-announcing-error.patch"
-
- # fix tests
- patch -d "XD-${pkgver}" -Np1 -i "${srcdir}/060-xd-torrent-fix-tests-01.patch"
- patch -d "XD-${pkgver}" -Np1 -i "${srcdir}/070-xd-torrent-fix-tests-02.patch"
- patch -d "XD-${pkgver}" -Np1 -i "${srcdir}/080-xd-torrent-fix-tests-03.patch"
-
- # update lokinet tracker
- patch -d "XD-${pkgver}" -Np1 -i "${srcdir}/090-xd-torrent-update-lokinet-tracker.patch"
}
build() {