Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add debian packaging files #75

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

SCOTT-HAMILTON
Copy link

This PR is a follow up of ParallelSSH/ssh2-python#190 in an attempt to package all the parallel-ssh ecosystem to debian, the end goal being to have a python3-parallel-ssh package.
I've already started working on parallel-ssh so it's coming next.

I had to disable two tests tests/test_channel.py:test_write_stdin and tests/test_sftp.py:test_mkdir in order to make it build locally, otherwise I had these errors:

_________________________ ChannelTest.test_write_stdin _________________________

self = <tests.test_channel.ChannelTest testMethod=test_write_stdin>

    def test_write_stdin(self):
        self._auth()
        _in = u'writing to stdin'
        chan = self.session.channel_new()
        chan.open_session()
        chan.request_exec('cat')
        chan.write(_in + '\n')
        self.assertEqual(chan.send_eof(), 0)
        size, data = chan.read()
        self.assertTrue(size > 0)
        lines = [line.decode('utf-8') for line in data.splitlines()]
        self.assertListEqual([_in], lines)
        chan.close()
>       chan.read()

tests/test_channel.py:173:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
ssh/channel.pyx:170: in ssh.channel.Channel.read
    ???
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

>   ???
E   ssh.exceptions.SSHError: (-1, b'Remote channel is closed.')                                                                                                                               
                                                                                                                                                                                              
ssh/utils.pyx:94: SSHError

I don't know much about libssh but reading a closed channel might be the issue.
And

_____________________________ SFTPTest.test_mkdir ______________________________

self = <tests.test_sftp.SFTPTest testMethod=test_mkdir>

    def test_mkdir(self):
        mode = int("0644") if version_info <= (2,) else 0o644
        _path = 'tmp'
        abspath = os.path.join(os.path.expanduser('~'), _path)
        self._auth()
        sftp = self.session.sftp_init()
        try:
            shutil.rmtree(abspath)
        except OSError:
            pass
>       sftp.mkdir(_path, mode)

tests/test_sftp.py:357: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
ssh/sftp.pyx:165: in ssh.sftp.SFTP.mkdir
    ???
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

>   ???
E   ssh.exceptions.SSHError: (-1, b'SFTP server: Failure')

ssh/utils.pyx:94: SSHError

I doubt '~' expansion works in a build environment

This builds fine locally, the steps are as follow (on a debian machine with buildessentials and debhelper installed, and maybe more):

# We copy the debian folder but we want to build with the 1.0.0 tree
git clone https://github.com/SCOTT-HAMILTON/ssh-python
mv ssh-python/debian .
rm -rf ssh-python

# we get the 1.0.0 tree
wget https://github.com/ParallelSSH/ssh-python/archive/refs/tags/1.0.0.tar.gz
tar -xf 1.0.0.tar.gz
mv ssh-python-1.0.0/ python3-ssh-1.0.0
mv debian python3-ssh-1.0.0

# we make the tar file
tar -czf python3-ssh_1.0.0.orig.tar.gz python3-ssh-1.0.0

# we install the build deps
cd python3-ssh-1.0.0
sudo mk-build-deps --install debian/control
rm -f python3-ssh-build-deps_1.0.0-1_all.deb

# and we finally build
debuild -us -uc

This works for me locally on ZorinOS 16.2. It also builds fine on OBS with debian testing and ubuntu 22.04 https://build.opensuse.org/package/show/home:ScottHamilton/python3-ssh.

PS:

I've noticed that the tests don't buid locally if the working directory is under /tmp. Maybe this is why the OBS build is failing, very strange ?
Here is the error that I get for almost all the tests:

__________________________ SFTPTest.test_sftp_setstat __________________________

self = <tests.test_sftp.SFTPTest testMethod=test_sftp_setstat>

    def test_sftp_setstat(self):
>       self._auth()

tests/test_sftp.py:237: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
tests/base_case.py:89: in _auth
    self.session.userauth_publickey(self.pkey), 0)
ssh/session.pyx:445: in ssh.session.Session.userauth_publickey
    ???
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

>   ???
E   ssh.exceptions.AuthenticationDenied: b"Access denied for 'publickey'. Authentication that can continue: publickey,password,keyboard-interactive"

ssh/utils.pyx:109: AuthenticationDenied

Seems like an auth error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant