termux / termux-create-package

Python script to create Termux packages easily.
https://termux.com
Apache License 2.0
417 stars 95 forks source link

Created packages cannot be added to repo using termux-apt-repo #13

Closed valpogus closed 5 years ago

valpogus commented 5 years ago

Packages created with the command termux-create-package cannot be added to a repo using termux-apt-repo.

Steps to repoduce:

git clone 'https://github.com/termux/termux-apt-repo.git'
cd termux-apt-repo
python3 setup.py install --user
cd ..

git clone 'https://github.com/termux/termux-create-package.git'
cd termux-create-package
python3 setup.py install --user
cd ..

cat > helloworld << 'EOF'
#!/bin/bash
echo 'hello world!'
EOF
chmod +x helloworld

cat > helloworld_1.0_all.json << 'EOF'
{
  "name": "helloworld",
  "version": "1.0",
  "arch": "all",
  "description": "Hello World",
  "homepage": "http://localhost",
  "files": {
    "helloworld": "bin/helloworld"
  }
}
EOF

# build package and create repo
termux-create-package helloworld_1.0_all.json
mkdir pkg
cp helloworld_1.0_all.deb pkg/
mkdir repo
termux-apt-repo pkg/ repo/

Traceback (most recent call last): File "/bin/termux-apt-repo", line 86, in add_deb(deb_path, component, use_hard_links) File "/bin/termux-apt-repo", line 23, in add_deb deb_to_add_control_file = control_file_contents(deb_to_add_path) File "/bin/termux-apt-repo", line 19, in control_file_contents stderr=subprocess.DEVNULL File "/usr/lib/python3.5/subprocess.py", line 316, in check_output **kwargs).stdout File "/usr/lib/python3.5/subprocess.py", line 398, in run output=stdout, stderr=stderr) subprocess.CalledProcessError: Command '['ar p pkg/helloworld_1.0_all.deb control.tar.xz | tar --to-stdout -xJf - ./control']' returned non-zero exit status 2

In my opinion, the problem is in line 59: info = tarfile.TarInfo(name="control") should be info = tarfile.TarInfo(name="./control") so that the control.tar file has the same structure as the packages compiled using build-package.sh.

# patch
cd termux-create-package
sed -i 's|info = tarfile.TarInfo(name="control")|info = tarfile.TarInfo(name="./control")|g' termux-create-package
python3 setup.py install --user
cd ..

# rebuild
rm helloworld_1.0_all.deb
rm -Rf pkg/ repo/
termux-create-package helloworld_1.0_all.json
mkdir pkg
cp helloworld_1.0_all.deb pkg/
mkdir repo
termux-apt-repo pkg/ repo/

Adding deb file: helloworld_1.0_all.deb... Creating package file for extras and all... Done!

Make the repo/ directory accessible at $REPO_URL

Users can then access the repo by adding a file at $PREFIX/etc/apt/sources.list.d containing: deb [trusted=yes] $REPO_URL termux extras

[trusted=yes] is not needed if the repo has been signed with a gpg key

The problem occurs on Debian [GNU ar (GNU Binutils for Debian) 2.28] and Termux itself [GNU ar (GNU Binutils) 2.31.1].

Grimler91 commented 5 years ago

Thanks for the bug report! I opened https://github.com/termux/termux-create-package/pull/14 to fix it as you suggested. It does indeed fix the problem and make termux-create-package and termux-apt-repo work nice together.

valpogus commented 5 years ago

Thanks to you for the fix! :)

valpogus commented 5 years ago

@fornwall The version in setup.py is still 0.4 in the 0.5 and 0.6 release tarballs. Is that correct?

fornwall commented 5 years ago

@valpogus Thanks, fixed now (in 0.7)! It will be available in Termux and pypi in a few minutes.

valpogus commented 5 years ago

Perfect, thanks!