[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Packaging GRASS 7



On 02/07/2015 10:47 PM, Sebastiaan Couwenberg wrote:
> On 02/07/2015 05:31 PM, Sebastiaan Couwenberg wrote:
> [...] the build on Hurd now fails because of several type errors like:
> 
>  TypeError: second item in _fields_ tuple (index 17) must be a C type

This TypeError occurs for several (277) Python scripts, and all these
are caused by the same error in the generated gis.py file:

  File
"/home/sebastic/git/pkg-grass/grass/dist.i686-unknown-gnu0.5/etc/python/grass/lib/gis.py",
line 869, in <module>
    ('st_spare', c_int * (sizeof(__fsid_t) == sizeof(c_int)) and 9 or 8),
TypeError: second item in _fields_ tuple (index 17) must be a C type

This seems like an issue with Python ctypes on Hurd in general rather
than something GRASS specific.

The struct stat64 is not converted properly from the C definition.

The generated gis.py contains:

# /usr/include/i386-gnu/bits/stat.h: 107
class struct_stat64(Structure):
    pass

struct_stat64.__slots__ = [
    'st_fstype',
    'st_fsid',
    'st_ino',
    'st_gen',
    'st_rdev',
    'st_mode',
    'st_nlink',
    'st_uid',
    'st_gid',
    'st_size',
    'st_atim',
    'st_mtim',
    'st_ctim',
    'st_blksize',
    'st_blocks',
    'st_author',
    'st_flags',
    'st_spare',
]
struct_stat64._fields_ = [
    ('st_fstype', c_int),
    ('st_fsid', __fsid_t),
    ('st_ino', __ino64_t),
    ('st_gen', c_uint),
    ('st_rdev', __dev_t),
    ('st_mode', __mode_t),
    ('st_nlink', __nlink_t),
    ('st_uid', __uid_t),
    ('st_gid', __gid_t),
    ('st_size', __off64_t),
    ('st_atim', struct_timespec),
    ('st_mtim', struct_timespec),
    ('st_ctim', struct_timespec),
    ('st_blksize', __blksize_t),
    ('st_blocks', __blkcnt64_t),
    ('st_author', __uid_t),
    ('st_flags', c_uint),
    ('st_spare', c_int * (sizeof(__fsid_t) == sizeof(c_int)) and 9 or 8),
]

Whereas stat.h contains:

#ifdef __USE_LARGEFILE64
struct stat64
  {
    int st_fstype;              /* File system type.  */
    __fsid_t st_fsid;           /* File system ID.  */
# define st_dev st_fsid

    __ino64_t st_ino;           /* File number.  */
    unsigned int st_gen;        /* To detect reuse of file numbers.  */
    __dev_t st_rdev;            /* Device if special file.  */
    __mode_t st_mode;           /* File mode.  */
    __nlink_t st_nlink;         /* Number of links.  */

    __uid_t st_uid;             /* Owner.  */
    __gid_t st_gid;             /* Owning group.  */

    __off64_t st_size;          /* Size in bytes.  */

#if defined __USE_MISC || defined __USE_XOPEN2K8
    /* Nanosecond resolution timestamps are stored in a format
       equivalent to 'struct timespec'.  This is the type used
       whenever possible but the Unix namespace rules do not allow the
       identifier 'timespec' to appear in the <sys/stat.h> header.
       Therefore we have to handle the use of this header in strictly
       standard-compliant sources special.  */
    struct timespec st_atim;            /* Time of last access.  */
    struct timespec st_mtim;            /* Time of last modification.  */
    struct timespec st_ctim;            /* Time of last status change.  */
#else
    __time_t st_atime;                  /* Time of last access.  */
    unsigned long int st_atimensec;     /* Nscecs of last access.  */
    __time_t st_mtime;                  /* Time of last modification.  */
    unsigned long int st_mtimensec;     /* Nsecs of last modification.  */
    __time_t st_ctime;                  /* Time of last status change.  */
    unsigned long int st_ctimensec;     /* Nsecs of last status change.  */
#endif

    __blksize_t st_blksize;     /* Optimal size for I/O.  */

    __blkcnt64_t st_blocks;     /* Number of 512-byte blocks allocated.
                                   Not related to `st_blksize'.  */

    __uid_t st_author;          /* File author.  */

    unsigned int st_flags;      /* User-defined flags.
                                   High 16 bits can be set only by root.  */

#define _SPARE_SIZE     ((sizeof (__fsid_t) == sizeof (int)) ? 9 : 8)
    int st_spare[_SPARE_SIZE];  /* Room for future expansion.  */
#undef _SPARE_SIZE
  };
#endif


While I'm not familiar with Python ctypes, I suspect the proper
conversion should to be:

 ('st_spare', c_int * 8),

based on the evaluated _SPARE_SIZE expression.

A workaround on Hurd may be to disable LARGEFILE64 so the stat struct is
used instead of stat64. On Linux & kFreeBSD stat64 isn't used either.

Kind Regards,

Bas

-- 
 GPG Key ID: 4096R/E88D4AF1
Fingerprint: 8182 DE41 7056 408D 6146  50D1 6750 F10A E88D 4AF1


Reply to: