summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: d51553fd58de6b16397168b9a6bd8404a6d99502 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
# Maintainer: Darren Ng <$(base64 --decode <<<VW4xR2ZuQGdtYWlsLmNvbQo=)>
pkgname=i8086emu-git
pkgver=0.9.2.r35.1143f09
pkgrel=3
epoch=1
pkgdesc="cross-platform emulator for the Intel 8086 microprocessor"
arch=($CARCH)
url=http://${pkgname%-*}.sourceforge.net/
license=(GPL2)
depends=(gtk2 beep) # shared-mime-info # namcap: W: unneeded dependency on a package run when needed by hooks.
makedepends=(cmake desktop-file-utils git nasm)
provides=(${pkgname%-*})
conflicts=(${pkgname%-*})

# (A)
# source=(file:///dev/null)
# md5sums=(SKIP)

# (B)
source=(

  # 503 Service Unavailable
  # https://downforeveryoneorjustme.com/i8086emu.sourceforge.net?proto=http
  # https://www.isitdownrightnow.com/i8086emu.sourceforge.net.html
  # http://${pkgname%-*}.sourceforge.net/dl/i8086.pdf

  ${pkgname%-*}::git+https://git.code.sf.net/p/i8086emu/git
  # https://sourceforge.net/p/i8086emu/patches/9/
  https://sourceforge.net/p/${pkgname%-*}/patches/9/attachment/extern.patch
  # https://developer.gnome.org/gtk2/stable/GtkMessageDialog.html#gtk-message-dialog-new
  # https://sourceforge.net/p/i8086emu/patches/10/
  https://sourceforge.net/p/${pkgname%-*}/patches/_discuss/thread/5e30f26d55/b83c/attachment/fmt.patch

  ${pkgname%-*}.xml
  net.sourceforge.${pkgname%-*}."${pkgname%emu*}"{gui,text}.desktop

)
sha1sums=(

  # 11d730bde4fc248fb2ae37785af564e884c62b66

  SKIP
  a5c1091422a1f9454a6fa161107781854f387896
  d6781a90dcfcec1e9164a3c7223253a556fa858e

  d3667ed6dc769ba4d7054a5eb4736f118c02bcc2
  cb75fe18ded8ed3f86ef159d08309b62e8739a11 48d414d51f66852c70e37d3c69d9613bb88eacac

)

prepare() {

  # (A)
  # cp -a ~/i8086emu.git/ ./

  # (B)
  # patch -d ${pkgname%-*} -i - -p1 --verbose <extern.patch # --dry-run
  # git -C ${pkgname%-*} apply --verbose ./extern.patch # error: can't open patch './extern.patch': No such file or directory
  git -C ${pkgname%-*} apply --verbose - <./extern.patch
  git -C ${pkgname%-*} apply --verbose - <./fmt.patch

  # cd ${pkgname%-*}/${pkgname%-*}/src

  # https://unix.stackexchange.com/a/450857
  # Insert text blob w/ sed in case any whitespace get messed up
  # diff -u {x,y}.c | sed -i -e '/^INSERT_TEXT_BLOB/{r /dev/stdin' -e 'd;}' ~/.cache/yay/i8086emu-git/PKGBUILD

  # echo
  # { for h in i8086gui.h i8086gui_paint.h i8086gui_emufuncs.h i8086gui_util.h; do
  #   echo "patch --verbose $h <<\"EOP\""
  #   diff -u "$h" ~/.cache/yay/i8086emu-git/src/i8086emu/i8086emu/src
  #   echo "EOP"
  #   echo
  # done } | sed -i -e '/^SED_BLOB/{r /dev/stdin' -e 'd;}' ~/.cache/yay/i8086emu-git/PKGBUILD

}

pkgver() {
  cd ${pkgname%-*}
  # cutting off 'v' prefix that presents in the git tag
  printf "%s" "$(git describe --long --tags | sed 's/^v//;s/\([^-]*-\)g/r\1/;s/-/./g')"
}

build() {

  cd "${pkgname%-*}/${pkgname%-*}"
  export CFLAGS="-fPIC $CFLAGS"

  # i8086text
  # ./configure --help | less; echo; pwd; echo; return 1
  # i8086emu-git W: ELF file ('usr/bin/i8086text') lacks FULL RELRO, check LDFLAGS.
  # i8086emu-git W: ELF file ('usr/lib/i8086emu/i8086beep.so') lacks FULL RELRO, check LDFLAGS.
  # i8086emu-git W: ELF file ('usr/lib/i8086emu/i8086pic.so') lacks FULL RELRO, check LDFLAGS.
  # i8086emu-git W: ELF file ('usr/lib/i8086emu/i8086pit.so') lacks FULL RELRO, check LDFLAGS.
 ./configure \
    \
    --prefix=/usr \
    --exec-prefix=/usr \
    \
    --sbindir=/usr/bin \
    --libexecdir=/usr/lib/${pkgname%-*} \
    --sysconfdir=/etc \
    --localstatedir=/var \
    --infodir=/usr/share/doc \
    --mandir=/usr/share/man \
    usegtk=1
  # gcc -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -shared -fPIC devices/i8086pic.c i8086error.o i8086messages.o i8086util.o -o devices/i8086pic.so
  # /usr/bin/ld: i8086messages.o: warning: relocation against `msgFuncs' in read-only section `.text'
  # /usr/bin/ld: i8086messages.o: relocation R_X86_64_PC32 against symbol `criticalSection' can not be used when making a shared object; recompile with -fPIC
  # make CFLAGS="-fPIC $CFLAGS"
  make

  # i8086gui
  cmake -B cmake_build_gui -S . \
    -DCMAKE_BUILD_TYPE=None \
    -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DCMAKE_VERBOSE_MAKEFILE=ON
  # ccmake -B cmake_build_gui -S .; echo; pwd; echo; return 1
  make -C cmake_build_gui
  # make -C cmake_build_gui -j1 VERBOSE=1

}

# makepkg --noextract --holdver --repackage
package() {

  cd "${pkgname%-*}/${pkgname%-*}"

  # i8086text
  make DESTDIR="$pkgdir" install
  rm -v \
    "$pkgdir/usr/bin/i8086text" \
    "$pkgdir/usr/lib/i8086emu/i8086beep.so" \
    "$pkgdir/usr/lib/i8086emu/i8086pic.so" \
    "$pkgdir/usr/lib/i8086emu/i8086pit.so"
  rmdir -v "$pkgdir/usr/lib/i8086emu"

  # only stub dirs remain
  [ -z "$(ls -A "$pkgdir/usr/bin")" ]
  [ -z "$(ls -A "$pkgdir/usr/lib")" ]

  # i8086gui
  install -vDm755 cmake_build_gui/bin/* "$pkgdir/usr/bin/"
  install -vDm755 cmake_build_gui/lib/*.so "$pkgdir/usr/lib/"
  install -vDm644 cmake_build_gui/lib/*.a "$pkgdir/usr/lib/"

  cd "$srcdir"
  [ -z "$(desktop-file-validate *.desktop 2>&1)" ]
  install -vdm755 "$pkgdir/usr/share/applications/"; install -vDm644 *.desktop "$_/"
  install -vDm644 {,"$pkgdir/usr/share/mime/packages/"}${pkgname%-*}.xml

}