Skip to content

Commit

Permalink
cygwin-util-linux: add package
Browse files Browse the repository at this point in the history
Signed-off-by: Ookiineko <chiisaineko@protonmail.com>
  • Loading branch information
ookiineko committed May 23, 2024
1 parent 85976de commit ae2e811
Show file tree
Hide file tree
Showing 4 changed files with 174 additions and 0 deletions.
2 changes: 2 additions & 0 deletions cygwin-util-linux/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# licenses
/util-linux-BSD-2-Clause.txt
78 changes: 78 additions & 0 deletions cygwin-util-linux/PKGBUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
pkgbase=cygwin-util-linux
pkgname=(cygwin-util-linux-libs)
pkgver=2.39.3
pkgrel=1
pkgdesc="Miscellaneous system utilities for Linux (Cygwin)"
arch=('any')
url="https://github.com/util-linux/util-linux"
license=(
'BSD-2-Clause'
'BSD-3-Clause'
'BSD-4-Clause-UC'
'GPL-2.0-only'
'GPL-2.0-or-later'
'GPL-3.0-or-later'
'ISC'
'LGPL-2.1-or-later'
'LicenseRef-PublicDomain'
)
groups=('cygwin-toolchain')
makedepends=('cygwin-configure')
options=('!strip' 'staticlibs' '!buildflags' '!emptydirs')
source=("https://www.kernel.org/pub/linux/utils/util-linux/v${pkgver%.*}/util-linux-${pkgver}.tar.xz"
"util-linux-BSD-2-Clause.txt::https://raw.githubusercontent.com/Cyan4973/xxHash/f035303b8a86c1db9be70cbb638678ef6ef4cb2d/LICENSE"
cygwin-include.patch
cygwin-libblkid-topology-v2.patch)
sha256sums=('7b6605e48d1a49f43cc4b4cfc59f313d0dd5402fa40b96810bd572e167dfed0f'
'6ffedbc0f7878612d2b23589f1ff2ab15633e1df7963a5d9fc750ec5500c7e7a'
'224505c3624f61f085130b4bc440c6237b19536bcdda57599ea4100f8b704d42'
'a445c73c38e23f7c7c3ca4efcdca46f82bd95db4b7f0b75cd463c7b81a6a95be')

_targets="x86_64-pc-cygwin"

prepare() {
cd "$srcdir"/util-linux-${pkgver}

patch -Np2 -i ../cygwin-include.patch
patch -Np2 -i ../cygwin-libblkid-topology-v2.patch

autoreconf -fi
}

build() {
export CFLAGS+=" -D_GNU_SOURCE -Wno-char-subscripts -Wno-unused-parameter"
export CPPFLAGS+=" -D__USE_LINUX_IOCTL_DEFS"

cd "$srcdir"/util-linux-${pkgver}
for _target in ${_targets}; do
echo "Building for ${_target}"
mkdir -p build-${_target} && pushd build-${_target}
${_target}-configure \
--disable-all-programs \
--enable-libuuid \
--enable-libblkid \
--enable-libsmartcols \
--enable-libfdisk \
SOLIB_LDFLAGS=-no-undefined
make
popd
done
}

package_cygwin-util-linux-libs() {
depends=('cygwin')
conflicts=('cygwin-libutil-linux')
provides=('cygwin-libutil-linux' 'cygwin-libblkid' 'cygwin-libfdisk' 'cygwin-libsmartcols' 'cygwin-libuuid')
replaces=('cygwin-libutil-linux')

pushd "$srcdir"/util-linux-${pkgver}
for _target in ${_targets}; do
echo "Installing for ${_target}"
(cd build-${_target} && make DESTDIR="$pkgdir" install)
# remove unnecessary files
rm -rf "$pkgdir"/usr/${_target}/share
done
popd
install -vDm 644 util-linux-${pkgver}/Documentation/licenses/COPYING.{BSD*,ISC} -t "$pkgdir"/usr/share/licenses/${pkgname}/
install -vDm 644 util-linux-BSD-2-Clause.txt -t "$pkgdir"/usr/share/licenses/${pkgname}/
}
27 changes: 27 additions & 0 deletions cygwin-util-linux/cygwin-include.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
--- origsrc/util-linux-2.39.3/include/blkdev.h 2023-11-21 00:46:50.040993300 -0800
+++ src/util-linux-2.39.3/include/blkdev.h 2024-03-06 21:49:24.330239000 -0800
@@ -23,6 +23,10 @@

#define DEFAULT_SECTOR_SIZE 512

+#ifdef __CYGWIN__
+#include <cygwin/fs.h>
+#endif
+
#ifdef __linux__
/* very basic ioctls, should be available everywhere */
# ifndef BLKROSET
--- origsrc/util-linux-2.39.3/include/ttyutils.h 2023-12-01 03:25:15.854048300 -0800
+++ src/util-linux-2.39.3/include/ttyutils.h 2024-03-07 02:05:32.567596700 -0800
@@ -164,7 +164,11 @@ static inline void reset_virtual_console
tp->c_oflag &= ~(OLCUC | OCRNL | ONOCR | ONLRET | OFILL | \
NLDLY|CRDLY|TABDLY|BSDLY|VTDLY|FFDLY);
tp->c_lflag |= (ISIG | ICANON | IEXTEN | ECHO|ECHOE|ECHOK|ECHOKE|ECHOCTL);
+#ifdef ECHOPRT
tp->c_lflag &= ~(ECHONL|ECHOPRT | NOFLSH | TOSTOP);
+#else
+ tp->c_lflag &= ~(ECHONL| NOFLSH | TOSTOP);
+#endif

if ((flags & UL_TTY_KEEPCFLAGS) == 0) {
tp->c_cflag |= (CREAD | CS8 | HUPCL);
67 changes: 67 additions & 0 deletions cygwin-util-linux/cygwin-libblkid-topology-v2.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
--- origsrc/util-linux-2.39.3/libblkid/src/Makemodule.am 2023-11-21 00:46:50.047993300 -0800
+++ src/util-linux-2.39.3/libblkid/src/Makemodule.am 2024-03-06 22:10:18.882560900 -0800
@@ -104,6 +104,7 @@ libblkid_la_SOURCES = \
libblkid/src/superblocks/zonefs.c \
libblkid/src/superblocks/erofs.c \
\
+ libblkid/src/topology/ioctl.c \
libblkid/src/topology/topology.c \
libblkid/src/topology/topology.h

@@ -111,7 +112,6 @@ if LINUX
libblkid_la_SOURCES += \
libblkid/src/topology/dm.c \
libblkid/src/topology/evms.c \
- libblkid/src/topology/ioctl.c \
libblkid/src/topology/lvm.c \
libblkid/src/topology/md.c \
libblkid/src/topology/sysfs.c
--- origsrc/util-linux-2.39.3/libblkid/src/topology/topology.c 2023-12-01 03:25:15.861048300 -0800
+++ src/util-linux-2.39.3/libblkid/src/topology/topology.c 2024-03-06 22:15:59.307406200 -0800
@@ -77,7 +77,9 @@ struct blkid_struct_topology {
*/
static const struct blkid_idinfo *idinfos[] =
{
-#ifdef __linux__
+#if defined(__CYGWIN__)
+ &ioctl_tp_idinfo,
+#elif defined(__linux__)
&sysfs_tp_idinfo,
&ioctl_tp_idinfo,
&md_tp_idinfo,
--- origsrc/util-linux-2.39.3/libblkid/src/topology/topology.h 2023-11-21 00:46:50.052993200 -0800
+++ src/util-linux-2.39.3/libblkid/src/topology/topology.h 2024-03-06 22:17:36.821198100 -0800
@@ -13,8 +13,10 @@ extern int blkid_topology_set_diskseq(bl
/*
* topology probers
*/
-#ifdef __linux__
+#if defined(__linux__) || defined(__CYGWIN__)
extern const struct blkid_idinfo ioctl_tp_idinfo;
+#endif
+#ifdef __linux__
extern const struct blkid_idinfo md_tp_idinfo;
extern const struct blkid_idinfo evms_tp_idinfo;
extern const struct blkid_idinfo sysfs_tp_idinfo;
--- origsrc/util-linux-2.39.3/libblkid/src/topology/ioctl.c 2023-11-21 00:46:50.051993200 -0800
+++ src/util-linux-2.39.3/libblkid/src/topology/ioctl.c 2024-04-02 00:26:02.916377500 -0700
@@ -35,7 +35,9 @@ static const struct topology_val {
{ BLKIOMIN, blkid_topology_set_minimum_io_size },
{ BLKIOOPT, blkid_topology_set_optimal_io_size },
{ BLKPBSZGET, blkid_topology_set_physical_sector_size },
+#ifdef BLKGETDISKSEQ
{ BLKGETDISKSEQ, .set_u64 = blkid_topology_set_diskseq },
+#endif
/* we read BLKSSZGET in topology.c */
};

@@ -51,7 +53,7 @@ static int probe_ioctl_tp(blkid_probe pr
unsigned long ul;
int i;
uint64_t u64;
- } data;
+ } data = { 0 };

if (ioctl(pr->fd, val->ioc, &data) == -1)
goto nothing;

0 comments on commit ae2e811

Please sign in to comment.