From owner-svn-soc-all@FreeBSD.ORG Sun Jun 30 10:01:31 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 3685EB04 for ; Sun, 30 Jun 2013 10:01:31 +0000 (UTC) (envelope-from syuu@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 25CEC19A5 for ; Sun, 30 Jun 2013 10:01:31 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r5UA1Uvo027990 for ; Sun, 30 Jun 2013 10:01:30 GMT (envelope-from syuu@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r5UA1UG4027976 for svn-soc-all@FreeBSD.org; Sun, 30 Jun 2013 10:01:30 GMT (envelope-from syuu@FreeBSD.org) Date: Sun, 30 Jun 2013 10:01:30 GMT Message-Id: <201306301001.r5UA1UG4027976@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to syuu@FreeBSD.org using -f From: syuu@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r253725 - in soc2013/syuu/bhyve_usb/usr.sbin/bhyve/usb: . include/hw MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 30 Jun 2013 10:01:31 -0000 Author: syuu Date: Sun Jun 30 10:01:30 2013 New Revision: 253725 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=253725 Log: uncomment tracer, IOVector Modified: soc2013/syuu/bhyve_usb/usr.sbin/bhyve/usb/core.c soc2013/syuu/bhyve_usb/usr.sbin/bhyve/usb/hcd-uhci.c soc2013/syuu/bhyve_usb/usr.sbin/bhyve/usb/include/hw/usb.h Modified: soc2013/syuu/bhyve_usb/usr.sbin/bhyve/usb/core.c ============================================================================== --- soc2013/syuu/bhyve_usb/usr.sbin/bhyve/usb/core.c Sun Jun 30 08:59:33 2013 (r253724) +++ soc2013/syuu/bhyve_usb/usr.sbin/bhyve/usb/core.c Sun Jun 30 10:01:30 2013 (r253725) @@ -24,10 +24,20 @@ * THE SOFTWARE. */ #include +#include +#include #include "hw/usb.h" #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) +#define trace_usb_packet_state_fault(busnr, path, nr, p, state, expected) \ + fprintf(stderr, "%s:%d trace_usb_packet_state_fault busnr=%d path=%s nr=%d p=%p state=%s expected=%s\n", \ + __func__, __LINE__, busnr, path, nr, p, state, expected) +#define trace_usb_packet_state_change(busnr, path, nr, p, state, expected) \ + fprintf(stderr, "%s:%d trace_usb_packet_state_change busnr=%d path=%s nr=%d p=%p state=%s expected=%s\n", \ + __func__, __LINE__, busnr, path, nr, p, state, expected) + + void usb_attach(USBPort *port) { USBDevice *dev = port->dev; @@ -101,14 +111,12 @@ { int request, value, index; -#if 0 if (p->iov.size != 8) { p->status = USB_RET_STALL; return; } usb_packet_copy(p, s->setup_buf, p->iov.size); -#endif p->actual_length = 0; s->setup_len = (s->setup_buf[7] << 8) | s->setup_buf[6]; s->setup_index = 0; @@ -174,11 +182,9 @@ case SETUP_STATE_DATA: if (s->setup_buf[0] & USB_DIR_IN) { int len = s->setup_len - s->setup_index; -#if 0 if (len > p->iov.size) { len = p->iov.size; } -#endif usb_packet_copy(p, s->data_buf + s->setup_index, len); s->setup_index += len; if (s->setup_index >= s->setup_len) { @@ -212,11 +218,9 @@ case SETUP_STATE_DATA: if (!(s->setup_buf[0] & USB_DIR_IN)) { int len = s->setup_len - s->setup_index; -#if 0 if (len > p->iov.size) { len = p->iov.size; } -#endif usb_packet_copy(p, s->data_buf + s->setup_index, len); s->setup_index += len; if (s->setup_index >= s->setup_len) { @@ -445,12 +449,10 @@ assert(QTAILQ_FIRST(&ep->queue) == p); assert(p->status != USB_RET_ASYNC && p->status != USB_RET_NAK); -#if 0 if (p->status != USB_RET_SUCCESS || (p->short_not_ok && (p->actual_length < p->iov.size))) { ep->halted = true; } -#endif usb_packet_set_state(p, USB_PACKET_COMPLETE); QTAILQ_REMOVE(&ep->queue, p, queue); dev->port->ops->complete(dev->port, p); @@ -504,7 +506,9 @@ void usb_packet_init(USBPacket *p) { -// qemu_iovec_init(&p->iov, 1); + p->iov.iov = (struct iovec *)calloc(sizeof(struct iovec), 1); + p->iov.niov = p->iov.size = 0; + p->iov.nalloc = 1; } static const char *usb_packet_state_name(USBPacketState state) @@ -533,30 +537,24 @@ } dev = p->ep->dev; bus = usb_bus_from_device(dev); -#if 0 trace_usb_packet_state_fault(bus->busnr, dev->port->path, p->ep->nr, p, usb_packet_state_name(p->state), usb_packet_state_name(expected)); -#endif assert(!"usb packet state check failed"); } void usb_packet_set_state(USBPacket *p, USBPacketState state) { if (p->ep) { -#if 0 USBDevice *dev = p->ep->dev; USBBus *bus = usb_bus_from_device(dev); trace_usb_packet_state_change(bus->busnr, dev->port->path, p->ep->nr, p, usb_packet_state_name(p->state), usb_packet_state_name(state)); -#endif } else { -#if 0 trace_usb_packet_state_change(-1, "", -1, p, usb_packet_state_name(p->state), usb_packet_state_name(state)); -#endif } p->state = state; } @@ -566,7 +564,7 @@ uint64_t id, bool short_not_ok, bool int_req) { assert(!usb_packet_is_inflight(p)); -// assert(p->iov.iov != NULL); + assert(p->iov.iov != NULL); p->id = id; p->pid = pid; p->ep = ep; @@ -577,64 +575,72 @@ p->short_not_ok = short_not_ok; p->int_req = int_req; p->combined = NULL; -// qemu_iovec_reset(&p->iov); + assert(p->iov.nalloc != -1); + p->iov.niov = 0; + p->iov.size = 0; usb_packet_set_state(p, USB_PACKET_SETUP); } void usb_packet_addbuf(USBPacket *p, void *ptr, size_t len) { -// qemu_iovec_add(&p->iov, ptr, len); + assert(p->iov.nalloc != -1); + + if (p->iov.niov == p->iov.nalloc) { + p->iov.nalloc = 2 * p->iov.nalloc + 1; + p->iov.iov = (struct iovec *)realloc(p->iov.iov, sizeof(struct iovec) * p->iov.nalloc); + } + p->iov.iov[p->iov.niov].iov_base = ptr; + p->iov.iov[p->iov.niov].iov_len = len; + p->iov.size += len; + ++p->iov.niov; } void usb_packet_copy(USBPacket *p, void *ptr, size_t bytes) { -#if 0 - QEMUIOVector *iov = p->combined ? &p->combined->iov : &p->iov; + IOVector *iov = p->combined ? &p->combined->iov : &p->iov; assert(p->actual_length >= 0); assert(p->actual_length + bytes <= iov->size); switch (p->pid) { case USB_TOKEN_SETUP: case USB_TOKEN_OUT: - iov_to_buf(iov->iov, iov->niov, p->actual_length, ptr, bytes); +// iov_to_buf(iov->iov, iov->niov, p->actual_length, ptr, bytes); break; case USB_TOKEN_IN: - iov_from_buf(iov->iov, iov->niov, p->actual_length, ptr, bytes); +// iov_from_buf(iov->iov, iov->niov, p->actual_length, ptr, bytes); break; default: fprintf(stderr, "%s: invalid pid: %x\n", __func__, p->pid); abort(); } p->actual_length += bytes; -#endif } void usb_packet_skip(USBPacket *p, size_t bytes) { -#if 0 - QEMUIOVector *iov = p->combined ? &p->combined->iov : &p->iov; + IOVector *iov = p->combined ? &p->combined->iov : &p->iov; assert(p->actual_length >= 0); assert(p->actual_length + bytes <= iov->size); if (p->pid == USB_TOKEN_IN) { - iov_memset(iov->iov, iov->niov, p->actual_length, 0, bytes); +// iov_memset(iov->iov, iov->niov, p->actual_length, 0, bytes); } p->actual_length += bytes; -#endif } size_t usb_packet_size(USBPacket *p) { -#if 0 return p->combined ? p->combined->iov.size : p->iov.size; -#endif - return 0; } void usb_packet_cleanup(USBPacket *p) { assert(!usb_packet_is_inflight(p)); -// qemu_iovec_destroy(&p->iov); + assert(p->iov.nalloc != -1); + + free(p->iov.iov); + p->iov.size = p->iov.niov = p->iov.nalloc = 0; + p->iov.iov = NULL; } void usb_ep_reset(USBDevice *dev) Modified: soc2013/syuu/bhyve_usb/usr.sbin/bhyve/usb/hcd-uhci.c ============================================================================== --- soc2013/syuu/bhyve_usb/usr.sbin/bhyve/usb/hcd-uhci.c Sun Jun 30 08:59:33 2013 (r253724) +++ soc2013/syuu/bhyve_usb/usr.sbin/bhyve/usb/hcd-uhci.c Sun Jun 30 10:01:30 2013 (r253725) @@ -28,10 +28,111 @@ #include "hw/usb.h" #include #include +#include #define le32_to_cpus(x) le32toh(x) #define cpu_to_le32(x) htole32(x) +#define PCI_CLASS_PROG PCIR_PROGIF + +#define PCI_VENDOR_ID_INTEL 0x8086 +#define PCI_DEVICE_ID_INTEL_82801I_UHCI3 0x2936 +#define PCI_DEVICE_ID_INTEL_82801I_UHCI4 0x2937 +#define PCI_DEVICE_ID_INTEL_82801I_UHCI5 0x2938 +#define PCI_DEVICE_ID_INTEL_82801I_UHCI6 0x2939 +#define PCI_DEVICE_ID_INTEL_82371SB_2 0x7020 +#define PCI_DEVICE_ID_INTEL_82371AB_2 0x7112 + +struct PCIDevice { + uint8_t *config; +}; +struct PCIDeviceClass { +}; +struct MemoryRegion { +}; +typedef struct PCIDevice PCIDevice; +typedef struct PCIDeviceClass PCIDeviceClass; +typedef struct MemoryRegion MemoryRegion; + +#define trace_usb_uhci_queue_add(token) \ + fprintf(stderr, "%s:%d trace_usb_uhci_queue_add token=%x\n", \ + __func__, __LINE__, token) +#define trace_usb_uhci_queue_del(token, reason) \ + fprintf(stderr, "%s:%d trace_usb_uhci_queue_del token=%x reason=%s\n", \ + __func__, __LINE__, token, reason) +#define trace_usb_uhci_packet_add(token, td_addr) \ + fprintf(stderr, "%s:%d trace_usb_uhci_packet_add token=%x td_addr=%x\n", \ + __func__, __LINE__, token, td_addr) +#define trace_usb_uhci_packet_cancel(token, td_addr, done) \ + fprintf(stderr, "%s:%d trace_usb_uhci_packet_cancel token=%x td_addr=%x done=%x\n", \ + __func__, __LINE__, token, td_addr, done) +#define trace_usb_uhci_packet_link_async(token, td_addr) \ + fprintf(stderr, "%s:%d trace_usb_uhci_packet_link_async token=%x td_addr=%x\n", \ + __func__, __LINE__, token, td_addr) +#define trace_usb_uhci_packet_unlink_async(token, td_addr) \ + fprintf(stderr, "%s:%d trace_usb_uhci_packet_unlink_async token=%x td_addr=%x\n", \ + __func__, __LINE__, token, td_addr) +#define trace_usb_uhci_reset() \ + fprintf(stderr, "%s:%d trace_usb_uhci_reset\n", \ + __func__, __LINE__) +#define trace_usb_uhci_mmio_writew(addr, val) \ + fprintf(stderr, "%s:%d trace_usb_uhci_mmio_writew addr=%lx val=%lx\n", \ + __func__, __LINE__, addr, val) +#define trace_usb_uhci_mmio_readw(addr, val) \ + fprintf(stderr, "%s:%d trace_usb_uhci_mmio_readw addr=%lx val=%x\n", \ + __func__, __LINE__, addr, val) +#define trace_usb_uhci_schedule_start() \ + fprintf(stderr, "%s:%d trace_usb_uhci_schedule_start\n", \ + __func__, __LINE__) +#define trace_usb_uhci_packet_complete_stall(token, td_addr) \ + fprintf(stderr, "%s:%d trace_usb_uhci_packet_complete_stall token=%x td_addr=%x\n", \ + __func__, __LINE__, token, td_addr) +#define trace_usb_uhci_packet_complete_babble(token, td_addr) \ + fprintf(stderr, "%s:%d trace_usb_uhci_packet_complete_babble token=%x td_addr=%x\n", \ + __func__, __LINE__, token, td_addr) +#define trace_usb_uhci_packet_complete_error(token, td_addr) \ + fprintf(stderr, "%s:%d trace_usb_uhci_packet_complete_error token=%x td_addr=%x\n", \ + __func__, __LINE__, token, td_addr) +#define trace_usb_uhci_packet_complete_shortxfer(token, td_addr) \ + fprintf(stderr, "%s:%d trace_usb_uhci_packet_complete_shortxfer token=%x td_addr=%x\n", \ + __func__, __LINE__, token, td_addr) +#define trace_usb_uhci_packet_complete_success(token, td_addr) \ + fprintf(stderr, "%s:%d trace_usb_uhci_packet_complete_success token=%x td_addr=%x\n", \ + __func__, __LINE__, token, td_addr) +#define trace_usb_uhci_td_queue(link, ctrl, token) \ + fprintf(stderr, "%s:%d trace_usb_uhci_td_queue link=%x ctrl=%x token=%x\n", \ + __func__, __LINE__, link, ctrl, token) +#define trace_usb_uhci_frame_stop_bandwidth() \ + fprintf(stderr, "%s:%d trace_usb_uhci_frame_stop_bandwidth\n", \ + __func__, __LINE__) +#define trace_usb_uhci_qh_load(link) \ + fprintf(stderr, "%s:%d trace_usb_uhci_qh_load link=%x\n", \ + __func__, __LINE__, link) +#define trace_usb_uhci_frame_loop_stop_idle() \ + fprintf(stderr, "%s:%d trace_usb_uhci_frame_loop_stop_idle\n", \ + __func__, __LINE__) +#define trace_usb_uhci_frame_loop_continue() \ + fprintf(stderr, "%s:%d trace_usb_uhci_frame_loop_continue\n", \ + __func__, __LINE__) +#define trace_usb_uhci_td_load(qh, link, ctrl, token) \ + fprintf(stderr, "%s:%d trace_usb_uhci_td_load qh=%x link=%x ctrl=%x token=%x\n", \ + __func__, __LINE__, qh, link, ctrl, token) +#define trace_usb_uhci_td_nextqh(qh, link) \ + fprintf(stderr, "%s:%d trace_usb_uhci_td_nextqh qh=%x link=%x\n", \ + __func__, __LINE__, qh, link) +#define trace_usb_uhci_td_async(qh, link) \ + fprintf(stderr, "%s:%d trace_usb_uhci_td_async qh=%x link=%x\n", \ + __func__, __LINE__, qh, link) +#define trace_usb_uhci_td_complete(qh, link) \ + fprintf(stderr, "%s:%d trace_usb_uhci_td_complete qh=%x link=%x\n", \ + __func__, __LINE__, qh, link) +#define trace_usb_uhci_schedule_stop() \ + fprintf(stderr, "%s:%d trace_usb_uhci_schedule_stop\n", \ + __func__, __LINE__) +#define trace_usb_uhci_frame_start(num) \ + fprintf(stderr, "%s:%d trace_usb_uhci_frame_start num=%d\n", \ + __func__, __LINE__, num) + //#define DEBUG //#define DEBUG_DUMP_DATA @@ -101,12 +202,12 @@ uint16_t device_id; uint8_t revision; uint8_t irq_pin; -// int (*initfn)(PCIDevice *dev); + int (*initfn)(PCIDevice *dev); bool unplug; }; struct UHCIPCIDeviceClass { -// PCIDeviceClass parent_class; + PCIDeviceClass parent_class; UHCIInfo info; }; @@ -142,8 +243,8 @@ } UHCIPort; struct UHCIState { -// PCIDevice dev; -// MemoryRegion io_bar; + PCIDevice dev; + MemoryRegion io_bar; USBBus bus; /* Note unused when we're a companion controller */ uint16_t cmd; /* cmd register */ uint16_t status; @@ -213,7 +314,7 @@ QTAILQ_INIT(&queue->asyncs); QTAILQ_INSERT_HEAD(&s->queues, queue, next); queue->valid = QH_VALID; -// trace_usb_uhci_queue_add(queue->token); + trace_usb_uhci_queue_add(queue->token); return queue; } @@ -228,7 +329,7 @@ } usb_device_ep_stopped(queue->ep->dev, queue->ep); -// trace_usb_uhci_queue_del(queue->token, reason); + trace_usb_uhci_queue_del(queue->token, reason); QTAILQ_REMOVE(&s->queues, queue, next); free(queue); } @@ -264,7 +365,7 @@ async->queue = queue; async->td_addr = td_addr; usb_packet_init(&async->packet); -// trace_usb_uhci_packet_add(async->queue->token, async->td_addr); + trace_usb_uhci_packet_add(async->queue->token, async->td_addr); return async; } @@ -283,21 +384,21 @@ { UHCIQueue *queue = async->queue; QTAILQ_INSERT_TAIL(&queue->asyncs, async, next); -// trace_usb_uhci_packet_link_async(async->queue->token, async->td_addr); + trace_usb_uhci_packet_link_async(async->queue->token, async->td_addr); } static void uhci_async_unlink(UHCIAsync *async) { UHCIQueue *queue = async->queue; QTAILQ_REMOVE(&queue->asyncs, async, next); -// trace_usb_uhci_packet_unlink_async(async->queue->token, async->td_addr); + trace_usb_uhci_packet_unlink_async(async->queue->token, async->td_addr); } static void uhci_async_cancel(UHCIAsync *async) { uhci_async_unlink(async); -// trace_usb_uhci_packet_cancel(async->queue->token, async->td_addr, -// async->done); + trace_usb_uhci_packet_cancel(async->queue->token, async->td_addr, + async->done); if (!async->done) usb_cancel_packet(&async->packet); uhci_async_free(async); @@ -388,9 +489,9 @@ int i; UHCIPort *port; -// trace_usb_uhci_reset(); + trace_usb_uhci_reset(); - // pci_conf = s->dev.config; + pci_conf = s->dev.config; pci_conf[0x6a] = 0x01; /* usb clock */ pci_conf[0x6b] = 0x00; @@ -472,13 +573,13 @@ { UHCIState *s = opaque; -// trace_usb_uhci_mmio_writew(addr, val); + trace_usb_uhci_mmio_writew(addr, val); switch(addr) { case 0x00: if ((val & UHCI_CMD_RS) && !(s->cmd & UHCI_CMD_RS)) { /* start frame processing */ -// trace_usb_uhci_schedule_start(); + trace_usb_uhci_schedule_start(); // s->expire_time = qemu_get_clock_ns(vm_clock) + // (get_ticks_per_sec() / FRAME_TIMER_FREQ); // qemu_mod_timer(s->frame_timer, s->expire_time); @@ -606,7 +707,7 @@ break; } -// trace_usb_uhci_mmio_readw(addr, val); + trace_usb_uhci_mmio_readw(addr, val); return val; } @@ -713,7 +814,7 @@ static int uhci_handle_td_error(UHCIState *s, UHCI_TD *td, uint32_t td_addr, int status, uint32_t *int_mask) { -// uint32_t queue_token = uhci_queue_token(td); + uint32_t queue_token /*= uhci_queue_token(td) */; int ret; switch (status) { @@ -723,14 +824,14 @@ case USB_RET_STALL: td->ctrl |= TD_CTRL_STALL; -// trace_usb_uhci_packet_complete_stall(queue_token, td_addr); + trace_usb_uhci_packet_complete_stall(queue_token, td_addr); ret = TD_RESULT_NEXT_QH; break; case USB_RET_BABBLE: td->ctrl |= TD_CTRL_BABBLE | TD_CTRL_STALL; /* frame interrupted */ -// trace_usb_uhci_packet_complete_babble(queue_token, td_addr); + trace_usb_uhci_packet_complete_babble(queue_token, td_addr); ret = TD_RESULT_STOP_FRAME; break; @@ -739,7 +840,7 @@ default: td->ctrl |= TD_CTRL_TIMEOUT; td->ctrl &= ~(3 << TD_CTRL_ERROR_SHIFT); -// trace_usb_uhci_packet_complete_error(queue_token, td_addr); + trace_usb_uhci_packet_complete_error(queue_token, td_addr); ret = TD_RESULT_NEXT_QH; break; } @@ -784,19 +885,15 @@ if ((td->ctrl & TD_CTRL_SPD) && len < max_len) { *int_mask |= 0x02; /* short packet: do not update QH */ -#if 0 trace_usb_uhci_packet_complete_shortxfer(async->queue->token, async->td_addr); -#endif return TD_RESULT_NEXT_QH; } } /* success */ -#if 0 trace_usb_uhci_packet_complete_success(async->queue->token, async->td_addr); -#endif return TD_RESULT_COMPLETE; } @@ -1008,7 +1105,7 @@ if (uhci_queue_token(&ptd) != q->token) { break; } -// trace_usb_uhci_td_queue(plink & ~0xf, ptd.ctrl, ptd.token); + trace_usb_uhci_td_queue(plink & ~0xf, ptd.ctrl, ptd.token); ret = uhci_handle_td(q->uhci, q, q->qh_addr, &ptd, plink, &int_mask); if (ret == TD_RESULT_ASYNC_CONT) { break; @@ -1043,12 +1140,12 @@ if (!s->completions_only && s->frame_bytes >= s->frame_bandwidth) { /* We've reached the usb 1.1 bandwidth, which is 1280 bytes/frame, stop processing */ -// trace_usb_uhci_frame_stop_bandwidth(); + trace_usb_uhci_frame_stop_bandwidth(); break; } if (is_qh(link)) { /* QH */ -// trace_usb_uhci_qh_load(link & ~0xf); + trace_usb_uhci_qh_load(link & ~0xf); if (qhdb_insert(&qhdb, link)) { /* @@ -1059,10 +1156,10 @@ * since we've been here last time. */ if (td_count == 0) { -// trace_usb_uhci_frame_loop_stop_idle(); + trace_usb_uhci_frame_loop_stop_idle(); break; } else { -// trace_usb_uhci_frame_loop_continue(); + trace_usb_uhci_frame_loop_continue(); td_count = 0; qhdb_reset(&qhdb); qhdb_insert(&qhdb, link); @@ -1087,7 +1184,7 @@ /* TD */ uhci_read_td(s, &td, link); -// trace_usb_uhci_td_load(curr_qh & ~0xf, link & ~0xf, td.ctrl, td.token); + trace_usb_uhci_td_load(curr_qh & ~0xf, link & ~0xf, td.ctrl, td.token); old_td_ctrl = td.ctrl; ret = uhci_handle_td(s, NULL, curr_qh, &td, link, &int_mask); @@ -1103,17 +1200,17 @@ case TD_RESULT_NEXT_QH: case TD_RESULT_ASYNC_CONT: -// trace_usb_uhci_td_nextqh(curr_qh & ~0xf, link & ~0xf); + trace_usb_uhci_td_nextqh(curr_qh & ~0xf, link & ~0xf); link = curr_qh ? qh.link : td.link; continue; case TD_RESULT_ASYNC_START: -// trace_usb_uhci_td_async(curr_qh & ~0xf, link & ~0xf); + trace_usb_uhci_td_async(curr_qh & ~0xf, link & ~0xf); link = curr_qh ? qh.link : td.link; continue; case TD_RESULT_COMPLETE: -// trace_usb_uhci_td_complete(curr_qh & ~0xf, link & ~0xf); + trace_usb_uhci_td_complete(curr_qh & ~0xf, link & ~0xf); link = td.link; td_count++; s->frame_bytes += (td.ctrl & 0x7ff) + 1; @@ -1161,7 +1258,7 @@ if (!(s->cmd & UHCI_CMD_RS)) { /* Full stop */ -// trace_usb_uhci_schedule_stop(); + trace_usb_uhci_schedule_stop(); // qemu_del_timer(s->frame_timer); uhci_async_cancel_all(s); /* set hchalted bit in status - UHCI11D 2.1.2 */ @@ -1187,7 +1284,7 @@ for (i = 0; i < frames; i++) { s->frame_bytes = 0; -// trace_usb_uhci_frame_start(s->frnum); + trace_usb_uhci_frame_start(s->frnum); uhci_async_validate_begin(s); uhci_process_frame(s); uhci_async_validate_end(s); @@ -1226,15 +1323,14 @@ .wakeup = uhci_wakeup, .complete = uhci_async_complete, }; -*/ -#if 0 static USBBusOps uhci_bus_ops = { }; +*/ static int usb_uhci_common_initfn(PCIDevice *dev) { - PCIDeviceClass *pc = PCI_DEVICE_GET_CLASS(dev); - UHCIPCIDeviceClass *u = container_of(pc, UHCIPCIDeviceClass, parent_class); +// PCIDeviceClass *pc = PCI_DEVICE_GET_CLASS(dev); +// UHCIPCIDeviceClass *u = container_of(pc, UHCIPCIDeviceClass, parent_class); UHCIState *s = DO_UPCAST(UHCIState, dev, dev); uint8_t *pci_conf = s->dev.config; int i; @@ -1243,8 +1339,8 @@ /* TODO: reset value should be 0. */ pci_conf[USB_SBRN] = USB_RELEASE_1; // release number - s->irq_pin = u->info.irq_pin; - pci_config_set_interrupt_pin(pci_conf, s->irq_pin + 1); +// s->irq_pin = u->info.irq_pin; +// pci_config_set_interrupt_pin(pci_conf, s->irq_pin + 1); if (s->masterbus) { USBPort *ports[NB_PORTS]; @@ -1252,32 +1348,31 @@ ports[i] = &s->ports[i].port; } if (usb_register_companion(s->masterbus, ports, NB_PORTS, - s->firstport, s, &uhci_port_ops, + s->firstport, s, /*&uhci_port_ops*/ NULL, USB_SPEED_MASK_LOW | USB_SPEED_MASK_FULL) != 0) { return -1; } } else { - usb_bus_new(&s->bus, &uhci_bus_ops, &s->dev.qdev); +// usb_bus_new(&s->bus, &uhci_bus_ops, &s->dev.qdev); for (i = 0; i < NB_PORTS; i++) { - usb_register_port(&s->bus, &s->ports[i].port, s, i, &uhci_port_ops, + usb_register_port(&s->bus, &s->ports[i].port, s, i, /*&uhci_port_ops*/NULL, USB_SPEED_MASK_LOW | USB_SPEED_MASK_FULL); } } - s->bh = qemu_bh_new(uhci_bh, s); - s->frame_timer = qemu_new_timer_ns(vm_clock, uhci_frame_timer, s); +// s->bh = qemu_bh_new(uhci_bh, s); +// s->frame_timer = qemu_new_timer_ns(vm_clock, uhci_frame_timer, s); s->num_ports_vmstate = NB_PORTS; QTAILQ_INIT(&s->queues); - qemu_register_reset(uhci_reset, s); +// qemu_register_reset(uhci_reset, s); - memory_region_init_io(&s->io_bar, &uhci_ioport_ops, s, "uhci", 0x20); +// memory_region_init_io(&s->io_bar, &uhci_ioport_ops, s, "uhci", 0x20); /* Use region 4 for consistency with real hardware. BSD guests seem to rely on this. */ - pci_register_bar(&s->dev, 4, PCI_BASE_ADDRESS_SPACE_IO, &s->io_bar); +// pci_register_bar(&s->dev, 4, PCI_BASE_ADDRESS_SPACE_IO, &s->io_bar); return 0; } -#endif #if 0 static int usb_uhci_vt82c686b_initfn(PCIDevice *dev) { @@ -1295,14 +1390,14 @@ } #endif -#if 0 static void usb_uhci_exit(PCIDevice *dev) { +#if 0 UHCIState *s = DO_UPCAST(UHCIState, dev, dev); memory_region_destroy(&s->io_bar); -} #endif +} #if 0 static Property uhci_properties[] = { Modified: soc2013/syuu/bhyve_usb/usr.sbin/bhyve/usb/include/hw/usb.h ============================================================================== --- soc2013/syuu/bhyve_usb/usr.sbin/bhyve/usb/include/hw/usb.h Sun Jun 30 08:59:33 2013 (r253724) +++ soc2013/syuu/bhyve_usb/usr.sbin/bhyve/usb/include/hw/usb.h Sun Jun 30 10:01:30 2013 (r253725) @@ -30,8 +30,12 @@ #include #include #include +#include #include "qemu/queue.h" +#define container_of(p, stype, field) ((stype *)(((uint8_t *)(p)) - offsetof(stype, field))) +#define DO_UPCAST(type, field, dev) container_of(dev, type, field) + typedef uint64_t hwaddr; /* Constants related to the USB / PCI interaction */ @@ -363,6 +367,14 @@ USB_PACKET_CANCELED, } USBPacketState; +struct IOVector { + struct iovec *iov; + int niov; + int nalloc; + size_t size; +}; +typedef struct IOVector IOVector; + /* Structure used to hold information about an active USB packet. */ struct USBPacket { /* Data fields for use by the driver. */ @@ -370,7 +382,7 @@ uint64_t id; USBEndpoint *ep; unsigned int stream; -// QEMUIOVector iov; + struct IOVector iov; uint64_t parameter; /* control transfers */ bool short_not_ok; bool int_req; @@ -386,7 +398,7 @@ struct USBCombinedPacket { USBPacket *first; QTAILQ_HEAD(packets_head, USBPacket) packets; -// QEMUIOVector iov; + IOVector iov; }; void usb_packet_init(USBPacket *p); From owner-svn-soc-all@FreeBSD.ORG Sun Jun 30 12:04:12 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 53D0FEE7 for ; Sun, 30 Jun 2013 12:04:12 +0000 (UTC) (envelope-from dpl@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 3610C1CEC for ; Sun, 30 Jun 2013 12:04:12 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r5UC4Bj7028662 for ; Sun, 30 Jun 2013 12:04:11 GMT (envelope-from dpl@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r5UC4B9k028650 for svn-soc-all@FreeBSD.org; Sun, 30 Jun 2013 12:04:11 GMT (envelope-from dpl@FreeBSD.org) Date: Sun, 30 Jun 2013 12:04:11 GMT Message-Id: <201306301204.r5UC4B9k028650@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to dpl@FreeBSD.org using -f From: dpl@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r253727 - soc2013/dpl/head/contrib/bzip2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 30 Jun 2013 12:04:12 -0000 Author: dpl Date: Sun Jun 30 12:04:11 2013 New Revision: 253727 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=253727 Log: Changes in debugging messages. Modified: soc2013/dpl/head/contrib/bzip2/bzip2.c Modified: soc2013/dpl/head/contrib/bzip2/bzip2.c ============================================================================== --- soc2013/dpl/head/contrib/bzip2/bzip2.c Sun Jun 30 10:38:20 2013 (r253726) +++ soc2013/dpl/head/contrib/bzip2/bzip2.c Sun Jun 30 12:04:11 2013 (r253727) @@ -233,13 +233,14 @@ { struct msghdr msg; struct cmsghdr cmsg; - char buf = { "!" }; struct iovec io[1]; + char buf = { "!" }; + int ret; io[0].iov_base = buf; io[0].iov_len = 1; - msg.msg_name = NULL; + msg.msg_name = 0; msg.msg_namelen = 0; msg.msg_iov = io; msg.msg_iovlen = 1; @@ -250,8 +251,12 @@ cmsg.cmsg_level = SOL_SOCKET; cmsg.cmsg_type = SCM_RIGHTS; *(int *)CMSG_DATA(&cmsg) = fd; - if(sendmsg(s, &msg, 0) <= 0) + printf("sendmsg(%d, %p, 0)\n",s, &msg); + /* Bad address in args */ + if( (ret = sendmsg(s, &msg, 0)) <= 0){ + printf("sendmsg() returned: %d\n", ret); return -1; + } return 0; } @@ -1397,12 +1402,12 @@ exit(exitValue); case ( 0 ): - /*if ((close(sv[0])) < 0){ - fprintf ( stderr, "%s: Couldn't close socket: %s.\n", - progName, strerror(errno) ); - setExit(1); - exit(exitValue); - }*/ + if ((close(sv[0])) < 0){ + fprintf ( stderr, "%s: Couldn't close socket: %s.\n", + progName, strerror(errno) ); + setExit(1); + exit(exitValue); + } printf("About to recv infd\n"); sleep(1); if ((infd = recvfd(sv[1])) < 0){ @@ -1418,7 +1423,7 @@ setExit(1); exit(exitValue); } - printf("Child: infd:%d, outfd:%d\n", infd, outfd); + printf("Child: infd:%d, outfd:%d\n", infd, outfd); inStr = fdopen(infd, "rb"); outStr = fdopen(outfd, "wb"); @@ -1453,16 +1458,19 @@ default: printf("Parent: infd:%d, outfd:%d\n", infd, outfd); - /*if ((close(sv[1])) < 0){ + printf("Child's pid: %d\n", forkpid); + if ((close(sv[1])) < 0){ fprintf ( stderr, "%s: Couldn't close fd: %s.\n", progName, strerror(errno) ); wait(NULL); setExit(1); exit(exitValue); - }*/ + } if (sendfd(sv[0], infd) < 0){ fprintf ( stderr, "%s: Couldn't send infd: %s.\n", progName, strerror(errno) ); + if (signal(forkpid, SIGTERM) < 0) + printf("Couldn't kill the child process, please press ^C\n"); wait(NULL); setExit(1); exit(exitValue); @@ -2136,7 +2144,7 @@ setExit(1); exit(exitValue); } - printf("socketpair() ended fine: sv[0]:%d sv[1]:%d\n", sv[0], sv[1]); + printf("socketpair(): sv[0]:%d sv[1]:%d\n", sv[0], sv[1]); # endif From owner-svn-soc-all@FreeBSD.ORG Sun Jun 30 12:05:10 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id DC1B3F02 for ; Sun, 30 Jun 2013 12:05:10 +0000 (UTC) (envelope-from jmuniz@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id BF7661CF2 for ; Sun, 30 Jun 2013 12:05:10 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r5UC5A1s050843 for ; Sun, 30 Jun 2013 12:05:10 GMT (envelope-from jmuniz@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r5UC5AUr050836 for svn-soc-all@FreeBSD.org; Sun, 30 Jun 2013 12:05:10 GMT (envelope-from jmuniz@FreeBSD.org) Date: Sun, 30 Jun 2013 12:05:10 GMT Message-Id: <201306301205.r5UC5AUr050836@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to jmuniz@FreeBSD.org using -f From: jmuniz@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r253728 - soc2013/jmuniz/PackageKit-Setter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 30 Jun 2013 12:05:10 -0000 Author: jmuniz Date: Sun Jun 30 12:05:10 2013 New Revision: 253728 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=253728 Log: Corrected spelling errors, updated task list for pk-setter Modified: soc2013/jmuniz/PackageKit-Setter/pk-setter Modified: soc2013/jmuniz/PackageKit-Setter/pk-setter ============================================================================== --- soc2013/jmuniz/PackageKit-Setter/pk-setter Sun Jun 30 12:04:11 2013 (r253727) +++ soc2013/jmuniz/PackageKit-Setter/pk-setter Sun Jun 30 12:05:10 2013 (r253728) @@ -1,135 +1,265 @@ #!/bin/sh + # + # Copyright (C) 2013 Justin Edward Muniz + # + # Licensed under the GNU General Public License Version 2 + # This program is free software; you can redistribute it and/or modify + # it under the terms of the GNU General Public License as published by + # the Free Software Foundation; either version 2 of the License, or + # (at your option) any later version. + # + # Script to list and select from possible PackageKit backends -# There are three argugments that can be provided to this script: + + +# There are three arguments that can be provided to this script: + # Instruction: mandatory; can be either 'list' or 'set' + # Backend Name: mandatory for 'set'; a string that identifies for the set instruction + # Prefix: optional; if included, must be a valid prefix path to the PackageKit installation + + # ENTRY POINT OF SCRIPT -# Make sure there is an appropriate number of arguements + +# Make sure there is an appropriate number of arguments + if [ $# -eq 1 -o $# -eq 2 -o $# -eq 3 ]; then + # Determine if there is a user provided prefix and save it for later + setPrefix + # Determine if the user wants a list of backends, if so print it + listBackends + # Determine if the user wants a backend change, and process it + setBackend + fi + # Let the user know how to use this script + printUsage + # Return to the shell with failure + exit 1 + # EXIT POINT OF SCRIPT -# This function presents the user with a list of available backednds + + +# This function presents the user with a list of available backends + listBackends(){ + # Make sure that the user has requested a list of the available backends + if [ "$1" == "list" ]; then + # Create a string with each line representing the name of one backend + generateBackendList + # Print a header to describe the data to follow + echo "Available PackageKit backends:" + # Print the list of backends + echo "${PK_BACKENDS}" + # Return to the shell with success + exit 0 + fi + # End listBackends + } + + # This function uses the prefix and backend name to configure PackageKit to use the chosen backend + setBackend(){ + # Make sure that the user wants to select the backend + if [ "$1" == "set" ]; then - # Determine if the prefix contains the neccessary configuration file + + # Determine if the prefix contains the necessary configuration file + if [ ! -e "${PK_PREFIX}etc/PackageKit/PackageKit.conf" ]; then + # Let the user know that the path does not lead to the configuration file + echo "Error: could not find PackageKit.conf, check prefix" + # Return to the shell with failure + exit 1 + fi + # Run the algorithm to create a new-line delimited list of available backends + generateBackendList + # Test the backend value provided against the list of valid backend names + if [ ${PK_BACKENDS} != *$2* ]; then + # Let the user know that they made a mistake + echo "The backend provided was not found, please check your entry" + # Give advice to the user since they made a mistake, then return to the shell with failure + printUsage + fi + # Find the first instance of "DefaultBackend" and replace the line to reflect the new backend + sed -i 's/DefaultBackend=.*/DefaultBackend='$2 + # Let the user know that the changes were successful + echo "PackageKit is now using the $2 backend" + # Return to the shell with success + exit 0 + fi + # End setBackend + } + + # This function determines which argument is the prefix, if any, and sets the value of PK_PREFIX for later + setPrefix(){ + # Set PK_PREFIX to default (root) prefix + ${PK_PREFIX}="/" - # Determine if there are three arguements + + # Determine if there are three arguments + if [ $# -eq 3 ]; then + # Set PK_PREFIX for later + ${PK_PREFIX}="$3" - # If there were two arguements given + + # If there were two arguments given + elif [ $# -eq 2 ]; then + # There must be a prefix if the "list" instruction is given + if [ "$1" == "list" ]; then + # Set PK_PREFIX to the third argument for later + ${PK_PREFIX}="$2" + fi + fi + # Find out if the path given does not end with a slash + if [ ${PK_PREFIX} != */ ]; then + # Then add a slash to the end to make a proper prefix + ${PK_PREFIX} .= "${PK_PREFIX}/" + fi + # Determine if the provided prefix even exists and if it refers to a directory + if [ ! -e "${PK_PREFIX}" -o ! -d "${PK_PREFIX}" ]; then + # Inform the user that the prefix provided does not refer to an existing directory + echo "Error: $2 is not a valid directory." + # Return to shell with failure + exit 1 + fi + # End setPrefix + } + + # This function explains to the user how to use this script, then exits + printUsage(){ + # Print the instructions to the user in a easily readable way + echo "pk-setter is used to select the PackageKit backend" + echo "usage: pk-setter list [prefix]" + echo " pk-setter set [backend] [prefix]" + echo "note: prefix is optional and defaults to the root directory" - echo " and refers to the intallation prefix of PackageKit" + + echo " and refers to the installation prefix of PackageKit" + # Returns to the shell with failure + exit 1 + # End printUsage + } + + # Create a list consisting of backend options, each on their own line + generateBackendList(){ + # Until a better way is figured out, a hardcoded set of options for backend selection are stored in PK_BACKENDS + ${PK_BACKENDS}="ports"$'\n'"pkgng"$'\n'"dummy (for debugging)" + # End generateBackendList + } -# TODO for listBackends: might need exception handling for if list cannot be generated + + # TODO: test validation and error handling in general -# TODO: check spelling + # TODO for generateBackendList: generate the list without hardcoding it -# TODO for setBackend: stop and start PackageKitd to load in the new backend \ No newline at end of file + +# TODO for setBackend: stop and start PackageKitd to load in the new backend From owner-svn-soc-all@FreeBSD.ORG Sun Jun 30 12:11:34 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 9A1E1F56 for ; Sun, 30 Jun 2013 12:11:34 +0000 (UTC) (envelope-from jmuniz@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 7D76D1D14 for ; Sun, 30 Jun 2013 12:11:34 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r5UCBYvX088674 for ; Sun, 30 Jun 2013 12:11:34 GMT (envelope-from jmuniz@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r5UCBYi8088672 for svn-soc-all@FreeBSD.org; Sun, 30 Jun 2013 12:11:34 GMT (envelope-from jmuniz@FreeBSD.org) Date: Sun, 30 Jun 2013 12:11:34 GMT Message-Id: <201306301211.r5UCBYi8088672@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to jmuniz@FreeBSD.org using -f From: jmuniz@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r253729 - soc2013/jmuniz/PackageKit-Setter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 30 Jun 2013 12:11:34 -0000 Author: jmuniz Date: Sun Jun 30 12:11:34 2013 New Revision: 253729 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=253729 Log: Fixed strange spacing issue Modified: soc2013/jmuniz/PackageKit-Setter/pk-setter Modified: soc2013/jmuniz/PackageKit-Setter/pk-setter ============================================================================== --- soc2013/jmuniz/PackageKit-Setter/pk-setter Sun Jun 30 12:05:10 2013 (r253728) +++ soc2013/jmuniz/PackageKit-Setter/pk-setter Sun Jun 30 12:11:34 2013 (r253729) @@ -1,265 +1,133 @@ #!/bin/sh - # - # Copyright (C) 2013 Justin Edward Muniz - # - # Licensed under the GNU General Public License Version 2 - # This program is free software; you can redistribute it and/or modify - # it under the terms of the GNU General Public License as published by - # the Free Software Foundation; either version 2 of the License, or - # (at your option) any later version. - # - # Script to list and select from possible PackageKit backends - - # There are three arguments that can be provided to this script: - # Instruction: mandatory; can be either 'list' or 'set' - # Backend Name: mandatory for 'set'; a string that identifies for the set instruction - # Prefix: optional; if included, must be a valid prefix path to the PackageKit installation - - # ENTRY POINT OF SCRIPT - # Make sure there is an appropriate number of arguments - if [ $# -eq 1 -o $# -eq 2 -o $# -eq 3 ]; then - # Determine if there is a user provided prefix and save it for later - setPrefix - # Determine if the user wants a list of backends, if so print it - listBackends - # Determine if the user wants a backend change, and process it - setBackend - fi - # Let the user know how to use this script - printUsage - # Return to the shell with failure - exit 1 - # EXIT POINT OF SCRIPT - - # This function presents the user with a list of available backends - listBackends(){ - # Make sure that the user has requested a list of the available backends - if [ "$1" == "list" ]; then - # Create a string with each line representing the name of one backend - generateBackendList - # Print a header to describe the data to follow - echo "Available PackageKit backends:" - # Print the list of backends - echo "${PK_BACKENDS}" - # Return to the shell with success - exit 0 - fi - # End listBackends - } - - # This function uses the prefix and backend name to configure PackageKit to use the chosen backend - setBackend(){ - # Make sure that the user wants to select the backend - if [ "$1" == "set" ]; then - # Determine if the prefix contains the necessary configuration file - if [ ! -e "${PK_PREFIX}etc/PackageKit/PackageKit.conf" ]; then - # Let the user know that the path does not lead to the configuration file - echo "Error: could not find PackageKit.conf, check prefix" - # Return to the shell with failure - exit 1 - fi - # Run the algorithm to create a new-line delimited list of available backends - generateBackendList - # Test the backend value provided against the list of valid backend names - if [ ${PK_BACKENDS} != *$2* ]; then - # Let the user know that they made a mistake - echo "The backend provided was not found, please check your entry" - # Give advice to the user since they made a mistake, then return to the shell with failure - printUsage - fi - # Find the first instance of "DefaultBackend" and replace the line to reflect the new backend - sed -i 's/DefaultBackend=.*/DefaultBackend='$2 - # Let the user know that the changes were successful - echo "PackageKit is now using the $2 backend" - # Return to the shell with success - exit 0 - fi - # End setBackend - } - - # This function determines which argument is the prefix, if any, and sets the value of PK_PREFIX for later - setPrefix(){ - # Set PK_PREFIX to default (root) prefix - ${PK_PREFIX}="/" - # Determine if there are three arguments - if [ $# -eq 3 ]; then - # Set PK_PREFIX for later - ${PK_PREFIX}="$3" - # If there were two arguments given - elif [ $# -eq 2 ]; then - # There must be a prefix if the "list" instruction is given - if [ "$1" == "list" ]; then - # Set PK_PREFIX to the third argument for later - ${PK_PREFIX}="$2" - fi - fi - # Find out if the path given does not end with a slash - if [ ${PK_PREFIX} != */ ]; then - # Then add a slash to the end to make a proper prefix - ${PK_PREFIX} .= "${PK_PREFIX}/" - fi - # Determine if the provided prefix even exists and if it refers to a directory - if [ ! -e "${PK_PREFIX}" -o ! -d "${PK_PREFIX}" ]; then - # Inform the user that the prefix provided does not refer to an existing directory - echo "Error: $2 is not a valid directory." - # Return to shell with failure - exit 1 - fi - # End setPrefix - } - - # This function explains to the user how to use this script, then exits - printUsage(){ - # Print the instructions to the user in a easily readable way - echo "pk-setter is used to select the PackageKit backend" - echo "usage: pk-setter list [prefix]" - echo " pk-setter set [backend] [prefix]" - echo "note: prefix is optional and defaults to the root directory" - echo " and refers to the installation prefix of PackageKit" - # Returns to the shell with failure - exit 1 - # End printUsage - } - - # Create a list consisting of backend options, each on their own line - generateBackendList(){ - # Until a better way is figured out, a hardcoded set of options for backend selection are stored in PK_BACKENDS - ${PK_BACKENDS}="ports"$'\n'"pkgng"$'\n'"dummy (for debugging)" - # End generateBackendList - } - - # TODO: test validation and error handling in general - # TODO for generateBackendList: generate the list without hardcoding it - # TODO for setBackend: stop and start PackageKitd to load in the new backend From owner-svn-soc-all@FreeBSD.ORG Sun Jun 30 12:46:04 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 45F38633 for ; Sun, 30 Jun 2013 12:46:04 +0000 (UTC) (envelope-from syuu@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 375241DC4 for ; Sun, 30 Jun 2013 12:46:04 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r5UCk44M040262 for ; Sun, 30 Jun 2013 12:46:04 GMT (envelope-from syuu@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r5UCk4te040257 for svn-soc-all@FreeBSD.org; Sun, 30 Jun 2013 12:46:04 GMT (envelope-from syuu@FreeBSD.org) Date: Sun, 30 Jun 2013 12:46:04 GMT Message-Id: <201306301246.r5UCk4te040257@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to syuu@FreeBSD.org using -f From: syuu@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r253730 - in soc2013/syuu/bhyve_usb/usr.sbin/bhyve: . usb MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 30 Jun 2013 12:46:04 -0000 Author: syuu Date: Sun Jun 30 12:46:03 2013 New Revision: 253730 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=253730 Log: initialize config space/IO space handler Modified: soc2013/syuu/bhyve_usb/usr.sbin/bhyve/Makefile soc2013/syuu/bhyve_usb/usr.sbin/bhyve/usb/hcd-uhci.c Modified: soc2013/syuu/bhyve_usb/usr.sbin/bhyve/Makefile ============================================================================== --- soc2013/syuu/bhyve_usb/usr.sbin/bhyve/Makefile Sun Jun 30 12:11:34 2013 (r253729) +++ soc2013/syuu/bhyve_usb/usr.sbin/bhyve/Makefile Sun Jun 30 12:46:03 2013 (r253730) @@ -16,7 +16,7 @@ SRCS+= vmm_instruction_emul.c .PATH: ${.CURDIR}/usb -CFLAGS+=-I${.CURDIR}/usb/include +CFLAGS+=-I${.CURDIR}/usb/include -I${.CURDIR} SRCS+= core.c hcd-uhci.c NO_MAN= Modified: soc2013/syuu/bhyve_usb/usr.sbin/bhyve/usb/hcd-uhci.c ============================================================================== --- soc2013/syuu/bhyve_usb/usr.sbin/bhyve/usb/hcd-uhci.c Sun Jun 30 12:11:34 2013 (r253729) +++ soc2013/syuu/bhyve_usb/usr.sbin/bhyve/usb/hcd-uhci.c Sun Jun 30 12:46:03 2013 (r253730) @@ -25,10 +25,15 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include "hw/usb.h" #include #include #include +#include +#include +#include + +#include "pci_emul.h" +#include "hw/usb.h" #define le32_to_cpus(x) le32toh(x) #define cpu_to_le32(x) htole32(x) @@ -36,12 +41,15 @@ #define PCI_CLASS_PROG PCIR_PROGIF #define PCI_VENDOR_ID_INTEL 0x8086 -#define PCI_DEVICE_ID_INTEL_82801I_UHCI3 0x2936 -#define PCI_DEVICE_ID_INTEL_82801I_UHCI4 0x2937 -#define PCI_DEVICE_ID_INTEL_82801I_UHCI5 0x2938 #define PCI_DEVICE_ID_INTEL_82801I_UHCI6 0x2939 -#define PCI_DEVICE_ID_INTEL_82371SB_2 0x7020 -#define PCI_DEVICE_ID_INTEL_82371AB_2 0x7112 + +/* + * Per-device softc + */ +struct pci_uhci_softc { + struct pci_devinst *sc_pi; + pthread_mutex_t sc_mtx; +}; struct PCIDevice { uint8_t *config; @@ -63,6 +71,9 @@ #define trace_usb_uhci_packet_add(token, td_addr) \ fprintf(stderr, "%s:%d trace_usb_uhci_packet_add token=%x td_addr=%x\n", \ __func__, __LINE__, token, td_addr) +#define trace_usb_uhci_packet_del(token, td_addr) \ + fprintf(stderr, "%s:%d trace_usb_uhci_packet_del token=%x td_addr=%x\n", \ + __func__, __LINE__, token, td_addr) #define trace_usb_uhci_packet_cancel(token, td_addr, done) \ fprintf(stderr, "%s:%d trace_usb_uhci_packet_cancel token=%x td_addr=%x done=%x\n", \ __func__, __LINE__, token, td_addr, done) @@ -136,6 +147,9 @@ //#define DEBUG //#define DEBUG_DUMP_DATA +#define PCI_USBREV 0x60 /* USB protocol revision */ +#define PCI_USB_REV_1_1 0x11 + #define UHCI_CMD_FGR (1 << 4) #define UHCI_CMD_EGSM (1 << 3) #define UHCI_CMD_GRESET (1 << 2) @@ -372,7 +386,7 @@ static void uhci_async_free(UHCIAsync *async) { -// trace_usb_uhci_packet_del(async->queue->token, async->td_addr); + trace_usb_uhci_packet_del(async->queue->token, async->td_addr); usb_packet_cleanup(&async->packet); if (async->buf != async->static_buf) { free(async->buf); @@ -1520,3 +1534,64 @@ } //type_init(uhci_register_types) + +static void +pci_uhci_write(struct vmctx *ctx, int vcpu, struct pci_devinst *pi, + int baridx, uint64_t offset, int size, uint64_t value) +{ + struct pci_uhci_softc *sc = pi->pi_arg; + + pthread_mutex_lock(&sc->sc_mtx); + printf("%s baridx:%d offset:%lx size:%d value:%lx\n", __func__, baridx, offset, size, value); + pthread_mutex_unlock(&sc->sc_mtx); +} + + +uint64_t +pci_uhci_read(struct vmctx *ctx, int vcpu, struct pci_devinst *pi, + int baridx, uint64_t offset, int size) +{ + struct pci_uhci_softc *sc = pi->pi_arg; + uint64_t value; + + pthread_mutex_lock(&sc->sc_mtx); + printf("%s baridx:%d offset:%lx size:%d\n", __func__, baridx, offset, size); + pthread_mutex_unlock(&sc->sc_mtx); + + return (value); +} + +static int +pci_uhci_init(struct vmctx *ctx, struct pci_devinst *pi, char *opts) +{ + struct pci_uhci_softc *sc; + + sc = malloc(sizeof(struct pci_uhci_softc)); + memset(sc, 0, sizeof(struct pci_uhci_softc)); + + pi->pi_arg = sc; + sc->sc_pi = pi; + + pthread_mutex_init(&sc->sc_mtx, NULL); + + /* initialize config space */ + pci_set_cfgdata16(pi, PCIR_DEVICE, PCI_DEVICE_ID_INTEL_82801I_UHCI6); + pci_set_cfgdata16(pi, PCIR_VENDOR, PCI_VENDOR_ID_INTEL); + pci_set_cfgdata8(pi, PCIR_CLASS, PCIC_SERIALBUS); + pci_set_cfgdata8(pi, PCI_USBREV, PCI_USB_REV_1_1); + + /* MSI support */ + pci_emul_add_msicap(pi, 1); + + pci_emul_alloc_bar(pi, 4, PCIBAR_IO, 0x20); + + return (0); +} + +struct pci_devemu pci_hcd_uhci = { + .pe_emu = "hcd-uhci", + .pe_init = pci_uhci_init, + .pe_barwrite = pci_uhci_write, + .pe_barread = pci_uhci_read +}; +PCI_EMUL_SET(pci_hcd_uhci); From owner-svn-soc-all@FreeBSD.ORG Sun Jun 30 13:10:39 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id E9EB89E6 for ; Sun, 30 Jun 2013 13:10:39 +0000 (UTC) (envelope-from syuu@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id D73411E3D for ; Sun, 30 Jun 2013 13:10:39 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r5UDAdCH055591 for ; Sun, 30 Jun 2013 13:10:39 GMT (envelope-from syuu@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r5UDAcgb055407 for svn-soc-all@FreeBSD.org; Sun, 30 Jun 2013 13:10:38 GMT (envelope-from syuu@FreeBSD.org) Date: Sun, 30 Jun 2013 13:10:38 GMT Message-Id: <201306301310.r5UDAcgb055407@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to syuu@FreeBSD.org using -f From: syuu@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r253731 - in soc2013/syuu/bhyve_usb: . bin/ed bin/sh contrib/libstdc++ contrib/libstdc++/libsupc++ contrib/smbfs/mount_smbfs crypto/heimdal crypto/heimdal/lib/gssapi/gssapi crypto/op... MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 30 Jun 2013 13:10:40 -0000 Author: syuu Date: Sun Jun 30 13:10:38 2013 New Revision: 253731 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=253731 Log: sync with head Added: soc2013/syuu/bhyve_usb/etc/rc.d/swap - copied unchanged from r253730, mirror/FreeBSD/head/etc/rc.d/swap soc2013/syuu/bhyve_usb/etc/rc.d/swaplate - copied unchanged from r253730, mirror/FreeBSD/head/etc/rc.d/swaplate soc2013/syuu/bhyve_usb/sbin/nvmecontrol/devlist.c - copied unchanged from r253730, mirror/FreeBSD/head/sbin/nvmecontrol/devlist.c soc2013/syuu/bhyve_usb/sbin/nvmecontrol/firmware.c - copied unchanged from r253730, mirror/FreeBSD/head/sbin/nvmecontrol/firmware.c soc2013/syuu/bhyve_usb/sbin/nvmecontrol/identify.c - copied unchanged from r253730, mirror/FreeBSD/head/sbin/nvmecontrol/identify.c soc2013/syuu/bhyve_usb/sbin/nvmecontrol/logpage.c - copied unchanged from r253730, mirror/FreeBSD/head/sbin/nvmecontrol/logpage.c soc2013/syuu/bhyve_usb/sbin/nvmecontrol/nvmecontrol.h - copied unchanged from r253730, mirror/FreeBSD/head/sbin/nvmecontrol/nvmecontrol.h soc2013/syuu/bhyve_usb/sbin/nvmecontrol/perftest.c - copied unchanged from r253730, mirror/FreeBSD/head/sbin/nvmecontrol/perftest.c soc2013/syuu/bhyve_usb/sbin/nvmecontrol/reset.c - copied unchanged from r253730, mirror/FreeBSD/head/sbin/nvmecontrol/reset.c soc2013/syuu/bhyve_usb/sys/arm/arm/generic_timer.c - copied unchanged from r253730, mirror/FreeBSD/head/sys/arm/arm/generic_timer.c soc2013/syuu/bhyve_usb/sys/arm/conf/ARNDALE - copied unchanged from r253730, mirror/FreeBSD/head/sys/arm/conf/ARNDALE soc2013/syuu/bhyve_usb/sys/arm/samsung/ - copied from r253730, mirror/FreeBSD/head/sys/arm/samsung/ soc2013/syuu/bhyve_usb/sys/boot/fdt/dts/exynos5250-arndale.dts - copied unchanged from r253730, mirror/FreeBSD/head/sys/boot/fdt/dts/exynos5250-arndale.dts soc2013/syuu/bhyve_usb/sys/boot/fdt/dts/exynos5250.dtsi - copied unchanged from r253730, mirror/FreeBSD/head/sys/boot/fdt/dts/exynos5250.dtsi soc2013/syuu/bhyve_usb/sys/kern/subr_vmem.c - copied unchanged from r253730, mirror/FreeBSD/head/sys/kern/subr_vmem.c soc2013/syuu/bhyve_usb/sys/sys/vmem.h - copied unchanged from r253730, mirror/FreeBSD/head/sys/sys/vmem.h Deleted: soc2013/syuu/bhyve_usb/contrib/smbfs/mount_smbfs/Makefile soc2013/syuu/bhyve_usb/etc/rc.d/encswap soc2013/syuu/bhyve_usb/etc/rc.d/swap1 Modified: soc2013/syuu/bhyve_usb/ (props changed) soc2013/syuu/bhyve_usb/bin/ed/re.c soc2013/syuu/bhyve_usb/bin/sh/eval.c soc2013/syuu/bhyve_usb/contrib/libstdc++/ (props changed) soc2013/syuu/bhyve_usb/contrib/libstdc++/libsupc++/unwind-cxx.h soc2013/syuu/bhyve_usb/crypto/heimdal/ (props changed) soc2013/syuu/bhyve_usb/crypto/heimdal/lib/gssapi/gssapi/gssapi_krb5.h soc2013/syuu/bhyve_usb/crypto/openssh/ (props changed) soc2013/syuu/bhyve_usb/crypto/openssh/sshd_config soc2013/syuu/bhyve_usb/crypto/openssh/sshd_config.5 soc2013/syuu/bhyve_usb/etc/defaults/rc.conf soc2013/syuu/bhyve_usb/etc/mtree/BSD.include.dist soc2013/syuu/bhyve_usb/etc/mtree/BSD.usr.dist soc2013/syuu/bhyve_usb/etc/network.subr soc2013/syuu/bhyve_usb/etc/rc.d/Makefile soc2013/syuu/bhyve_usb/etc/rc.d/addswap soc2013/syuu/bhyve_usb/etc/rc.d/fsck soc2013/syuu/bhyve_usb/etc/rc.d/mdconfig soc2013/syuu/bhyve_usb/include/Makefile soc2013/syuu/bhyve_usb/include/gssapi/gssapi.h soc2013/syuu/bhyve_usb/include/paths.h soc2013/syuu/bhyve_usb/lib/Makefile soc2013/syuu/bhyve_usb/lib/libfetch/fetch.c soc2013/syuu/bhyve_usb/lib/libprocstat/Makefile soc2013/syuu/bhyve_usb/lib/libprocstat/common_kvm.h soc2013/syuu/bhyve_usb/lib/libprocstat/libprocstat.c soc2013/syuu/bhyve_usb/lib/librt/sigev_thread.c soc2013/syuu/bhyve_usb/lib/libutil/ (props changed) soc2013/syuu/bhyve_usb/lib/libutil/login_times.c soc2013/syuu/bhyve_usb/rescue/rescue/Makefile soc2013/syuu/bhyve_usb/sbin/ (props changed) soc2013/syuu/bhyve_usb/sbin/hastd/refcnt.h soc2013/syuu/bhyve_usb/sbin/ifconfig/af_nd6.c soc2013/syuu/bhyve_usb/sbin/mdconfig/mdconfig.8 soc2013/syuu/bhyve_usb/sbin/mount/mount.8 soc2013/syuu/bhyve_usb/sbin/mount/mount.c soc2013/syuu/bhyve_usb/sbin/nvmecontrol/Makefile soc2013/syuu/bhyve_usb/sbin/nvmecontrol/nvmecontrol.8 soc2013/syuu/bhyve_usb/sbin/nvmecontrol/nvmecontrol.c soc2013/syuu/bhyve_usb/sbin/swapon/swapon.8 soc2013/syuu/bhyve_usb/sbin/swapon/swapon.c soc2013/syuu/bhyve_usb/share/examples/Makefile soc2013/syuu/bhyve_usb/share/examples/etc/README.examples soc2013/syuu/bhyve_usb/share/examples/etc/make.conf soc2013/syuu/bhyve_usb/share/man/man5/fstab.5 soc2013/syuu/bhyve_usb/share/man/man9/locking.9 soc2013/syuu/bhyve_usb/share/mk/bsd.libnames.mk soc2013/syuu/bhyve_usb/sys/ (props changed) soc2013/syuu/bhyve_usb/sys/amd64/include/acpica_machdep.h soc2013/syuu/bhyve_usb/sys/amd64/vmm/ (props changed) soc2013/syuu/bhyve_usb/sys/amd64/vmm/x86.c soc2013/syuu/bhyve_usb/sys/arm/arm/cpufunc.c soc2013/syuu/bhyve_usb/sys/arm/arm/db_trace.c soc2013/syuu/bhyve_usb/sys/arm/arm/exception.S soc2013/syuu/bhyve_usb/sys/arm/arm/gic.c soc2013/syuu/bhyve_usb/sys/arm/arm/identcpu.c soc2013/syuu/bhyve_usb/sys/arm/include/armreg.h soc2013/syuu/bhyve_usb/sys/arm/include/asmacros.h soc2013/syuu/bhyve_usb/sys/arm/include/intr.h soc2013/syuu/bhyve_usb/sys/arm/ti/am335x/am335x_lcd.c soc2013/syuu/bhyve_usb/sys/arm/versatile/versatile_pci.c soc2013/syuu/bhyve_usb/sys/arm/versatile/versatile_sic.c soc2013/syuu/bhyve_usb/sys/boot/ (props changed) soc2013/syuu/bhyve_usb/sys/cam/cam_ccb.h soc2013/syuu/bhyve_usb/sys/cam/scsi/scsi_xpt.c soc2013/syuu/bhyve_usb/sys/cddl/compat/opensolaris/kern/opensolaris_cmn_err.c soc2013/syuu/bhyve_usb/sys/cddl/contrib/opensolaris/ (props changed) soc2013/syuu/bhyve_usb/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dir.c soc2013/syuu/bhyve_usb/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c soc2013/syuu/bhyve_usb/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c soc2013/syuu/bhyve_usb/sys/cddl/dev/dtmalloc/dtmalloc.c soc2013/syuu/bhyve_usb/sys/conf/ (props changed) soc2013/syuu/bhyve_usb/sys/conf/NOTES soc2013/syuu/bhyve_usb/sys/conf/files soc2013/syuu/bhyve_usb/sys/conf/files.amd64 soc2013/syuu/bhyve_usb/sys/conf/files.arm soc2013/syuu/bhyve_usb/sys/conf/files.i386 soc2013/syuu/bhyve_usb/sys/conf/files.ia64 soc2013/syuu/bhyve_usb/sys/conf/files.mips soc2013/syuu/bhyve_usb/sys/conf/files.pc98 soc2013/syuu/bhyve_usb/sys/conf/files.powerpc soc2013/syuu/bhyve_usb/sys/conf/files.sparc64 soc2013/syuu/bhyve_usb/sys/conf/options soc2013/syuu/bhyve_usb/sys/contrib/dev/acpica/ (props changed) soc2013/syuu/bhyve_usb/sys/contrib/dev/acpica/acpica_prep.sh soc2013/syuu/bhyve_usb/sys/contrib/dev/acpica/changes.txt (contents, props changed) soc2013/syuu/bhyve_usb/sys/contrib/dev/acpica/common/ (props changed) soc2013/syuu/bhyve_usb/sys/contrib/dev/acpica/common/dmrestag.c soc2013/syuu/bhyve_usb/sys/contrib/dev/acpica/common/dmtable.c soc2013/syuu/bhyve_usb/sys/contrib/dev/acpica/common/dmtbdump.c soc2013/syuu/bhyve_usb/sys/contrib/dev/acpica/common/dmtbinfo.c soc2013/syuu/bhyve_usb/sys/contrib/dev/acpica/compiler/ (props changed) soc2013/syuu/bhyve_usb/sys/contrib/dev/acpica/compiler/aslcompile.c soc2013/syuu/bhyve_usb/sys/contrib/dev/acpica/compiler/aslmessages.h soc2013/syuu/bhyve_usb/sys/contrib/dev/acpica/compiler/asltree.c soc2013/syuu/bhyve_usb/sys/contrib/dev/acpica/compiler/aslutils.c soc2013/syuu/bhyve_usb/sys/contrib/dev/acpica/compiler/dtfield.c soc2013/syuu/bhyve_usb/sys/contrib/dev/acpica/compiler/dtio.c soc2013/syuu/bhyve_usb/sys/contrib/dev/acpica/compiler/dttable.c soc2013/syuu/bhyve_usb/sys/contrib/dev/acpica/compiler/dttemplate.h soc2013/syuu/bhyve_usb/sys/contrib/dev/acpica/compiler/dtutils.c soc2013/syuu/bhyve_usb/sys/contrib/dev/acpica/compiler/preprocess.h soc2013/syuu/bhyve_usb/sys/contrib/dev/acpica/compiler/prscan.c soc2013/syuu/bhyve_usb/sys/contrib/dev/acpica/components/debugger/ (props changed) soc2013/syuu/bhyve_usb/sys/contrib/dev/acpica/components/debugger/dbcmds.c soc2013/syuu/bhyve_usb/sys/contrib/dev/acpica/components/debugger/dbdisply.c soc2013/syuu/bhyve_usb/sys/contrib/dev/acpica/components/debugger/dbinput.c soc2013/syuu/bhyve_usb/sys/contrib/dev/acpica/components/debugger/dbnames.c soc2013/syuu/bhyve_usb/sys/contrib/dev/acpica/components/disassembler/ (props changed) soc2013/syuu/bhyve_usb/sys/contrib/dev/acpica/components/disassembler/dmbuffer.c soc2013/syuu/bhyve_usb/sys/contrib/dev/acpica/components/disassembler/dmopcode.c soc2013/syuu/bhyve_usb/sys/contrib/dev/acpica/components/disassembler/dmresrcl.c soc2013/syuu/bhyve_usb/sys/contrib/dev/acpica/components/disassembler/dmresrcl2.c soc2013/syuu/bhyve_usb/sys/contrib/dev/acpica/components/events/ (props changed) soc2013/syuu/bhyve_usb/sys/contrib/dev/acpica/components/events/evgpeinit.c soc2013/syuu/bhyve_usb/sys/contrib/dev/acpica/components/executer/ (props changed) soc2013/syuu/bhyve_usb/sys/contrib/dev/acpica/components/executer/exdump.c soc2013/syuu/bhyve_usb/sys/contrib/dev/acpica/components/namespace/ (props changed) soc2013/syuu/bhyve_usb/sys/contrib/dev/acpica/components/namespace/nsdump.c soc2013/syuu/bhyve_usb/sys/contrib/dev/acpica/components/namespace/nsrepair2.c soc2013/syuu/bhyve_usb/sys/contrib/dev/acpica/components/namespace/nsxfname.c soc2013/syuu/bhyve_usb/sys/contrib/dev/acpica/components/resources/ (props changed) soc2013/syuu/bhyve_usb/sys/contrib/dev/acpica/components/resources/rsdump.c soc2013/syuu/bhyve_usb/sys/contrib/dev/acpica/components/resources/rsutils.c soc2013/syuu/bhyve_usb/sys/contrib/dev/acpica/components/tables/ (props changed) soc2013/syuu/bhyve_usb/sys/contrib/dev/acpica/components/tables/tbxfroot.c soc2013/syuu/bhyve_usb/sys/contrib/dev/acpica/components/utilities/ (props changed) soc2013/syuu/bhyve_usb/sys/contrib/dev/acpica/components/utilities/uteval.c soc2013/syuu/bhyve_usb/sys/contrib/dev/acpica/components/utilities/utstring.c soc2013/syuu/bhyve_usb/sys/contrib/dev/acpica/include/ (props changed) soc2013/syuu/bhyve_usb/sys/contrib/dev/acpica/include/acdisasm.h soc2013/syuu/bhyve_usb/sys/contrib/dev/acpica/include/acpixf.h soc2013/syuu/bhyve_usb/sys/contrib/dev/acpica/include/actables.h soc2013/syuu/bhyve_usb/sys/contrib/dev/acpica/include/actypes.h soc2013/syuu/bhyve_usb/sys/contrib/dev/acpica/include/acutils.h soc2013/syuu/bhyve_usb/sys/contrib/dev/acpica/include/platform/acfreebsd.h soc2013/syuu/bhyve_usb/sys/contrib/dev/acpica/os_specific/ (props changed) soc2013/syuu/bhyve_usb/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_attach.c soc2013/syuu/bhyve_usb/sys/dev/acpi_support/atk0110.c soc2013/syuu/bhyve_usb/sys/dev/acpica/acpi_pcib_acpi.c soc2013/syuu/bhyve_usb/sys/dev/ath/if_ath_rx_edma.c soc2013/syuu/bhyve_usb/sys/dev/bce/if_bce.c soc2013/syuu/bhyve_usb/sys/dev/bce/if_bcereg.h soc2013/syuu/bhyve_usb/sys/dev/bge/if_bge.c soc2013/syuu/bhyve_usb/sys/dev/bge/if_bgereg.h soc2013/syuu/bhyve_usb/sys/dev/cxgbe/t4_main.c soc2013/syuu/bhyve_usb/sys/dev/isci/scil/sati_passthrough.c soc2013/syuu/bhyve_usb/sys/dev/iwn/if_iwn.c soc2013/syuu/bhyve_usb/sys/dev/nvme/nvme.h soc2013/syuu/bhyve_usb/sys/dev/nvme/nvme_ctrlr.c soc2013/syuu/bhyve_usb/sys/dev/nvme/nvme_private.h soc2013/syuu/bhyve_usb/sys/dev/nvme/nvme_qpair.c soc2013/syuu/bhyve_usb/sys/dev/pci/pci.c soc2013/syuu/bhyve_usb/sys/dev/pci/pci_private.h soc2013/syuu/bhyve_usb/sys/dev/re/if_re.c soc2013/syuu/bhyve_usb/sys/dev/uart/uart.h soc2013/syuu/bhyve_usb/sys/dev/uart/uart_bus_fdt.c soc2013/syuu/bhyve_usb/sys/dev/uart/uart_cpu_fdt.c soc2013/syuu/bhyve_usb/sys/dev/uart/uart_subr.c soc2013/syuu/bhyve_usb/sys/dev/usb/serial/u3g.c soc2013/syuu/bhyve_usb/sys/dev/usb/usbdevs soc2013/syuu/bhyve_usb/sys/dev/usb/wlan/if_urtwn.c soc2013/syuu/bhyve_usb/sys/dev/xen/blkfront/blkfront.c soc2013/syuu/bhyve_usb/sys/dev/xen/blkfront/block.h soc2013/syuu/bhyve_usb/sys/fs/ext2fs/ext2_extern.h soc2013/syuu/bhyve_usb/sys/fs/ext2fs/ext2_lookup.c soc2013/syuu/bhyve_usb/sys/fs/ext2fs/ext2_vfsops.c soc2013/syuu/bhyve_usb/sys/fs/smbfs/smbfs_node.c soc2013/syuu/bhyve_usb/sys/fs/smbfs/smbfs_vfsops.c soc2013/syuu/bhyve_usb/sys/fs/smbfs/smbfs_vnops.c soc2013/syuu/bhyve_usb/sys/geom/geom_io.c soc2013/syuu/bhyve_usb/sys/i386/include/acpica_machdep.h soc2013/syuu/bhyve_usb/sys/ia64/include/acpica_machdep.h soc2013/syuu/bhyve_usb/sys/kern/Make.tags.inc soc2013/syuu/bhyve_usb/sys/kern/kern_clock.c soc2013/syuu/bhyve_usb/sys/kern/kern_descrip.c soc2013/syuu/bhyve_usb/sys/kern/kern_synch.c soc2013/syuu/bhyve_usb/sys/kern/subr_bus.c soc2013/syuu/bhyve_usb/sys/kern/sys_generic.c soc2013/syuu/bhyve_usb/sys/kern/vfs_bio.c soc2013/syuu/bhyve_usb/sys/modules/Makefile soc2013/syuu/bhyve_usb/sys/net80211/ieee80211_ioctl.c soc2013/syuu/bhyve_usb/sys/netsmb/smb_conn.c soc2013/syuu/bhyve_usb/sys/sys/bus.h soc2013/syuu/bhyve_usb/sys/sys/malloc.h soc2013/syuu/bhyve_usb/sys/sys/socketvar.h soc2013/syuu/bhyve_usb/sys/sys/stdatomic.h soc2013/syuu/bhyve_usb/sys/vm/uma_core.c soc2013/syuu/bhyve_usb/sys/vm/vm.h soc2013/syuu/bhyve_usb/sys/vm/vm_init.c soc2013/syuu/bhyve_usb/sys/vm/vm_kern.c soc2013/syuu/bhyve_usb/sys/vm/vm_kern.h soc2013/syuu/bhyve_usb/sys/vm/vm_object.c soc2013/syuu/bhyve_usb/sys/vm/vm_pager.c soc2013/syuu/bhyve_usb/sys/vm/vm_pager.h soc2013/syuu/bhyve_usb/usr.bin/Makefile soc2013/syuu/bhyve_usb/usr.bin/Makefile.amd64 soc2013/syuu/bhyve_usb/usr.bin/Makefile.i386 soc2013/syuu/bhyve_usb/usr.bin/Makefile.ia64 soc2013/syuu/bhyve_usb/usr.bin/Makefile.powerpc soc2013/syuu/bhyve_usb/usr.bin/Makefile.sparc64 soc2013/syuu/bhyve_usb/usr.bin/calendar/ (props changed) soc2013/syuu/bhyve_usb/usr.bin/calendar/calendars/calendar.freebsd soc2013/syuu/bhyve_usb/usr.bin/kdump/kdump.c soc2013/syuu/bhyve_usb/usr.sbin/Makefile.amd64 soc2013/syuu/bhyve_usb/usr.sbin/Makefile.i386 soc2013/syuu/bhyve_usb/usr.sbin/Makefile.ia64 soc2013/syuu/bhyve_usb/usr.sbin/Makefile.powerpc soc2013/syuu/bhyve_usb/usr.sbin/Makefile.sparc64 soc2013/syuu/bhyve_usb/usr.sbin/acpi/acpidb/acpidb.c soc2013/syuu/bhyve_usb/usr.sbin/acpi/acpidump/acpi.c soc2013/syuu/bhyve_usb/usr.sbin/bhyve/ (props changed) soc2013/syuu/bhyve_usb/usr.sbin/bhyve/atpic.c soc2013/syuu/bhyve_usb/usr.sbin/bhyve/pci_emul.c soc2013/syuu/bhyve_usb/usr.sbin/newsyslog/newsyslog.c soc2013/syuu/bhyve_usb/usr.sbin/pkg_install/add/extract.c soc2013/syuu/bhyve_usb/usr.sbin/pkg_install/create/pl.c soc2013/syuu/bhyve_usb/usr.sbin/pkg_install/lib/exec.c soc2013/syuu/bhyve_usb/usr.sbin/pw/pw_user.c Modified: soc2013/syuu/bhyve_usb/bin/ed/re.c ============================================================================== --- soc2013/syuu/bhyve_usb/bin/ed/re.c Sun Jun 30 12:46:03 2013 (r253730) +++ soc2013/syuu/bhyve_usb/bin/ed/re.c Sun Jun 30 13:10:38 2013 (r253731) @@ -89,7 +89,7 @@ default: break; case '[': - if ((nd = parse_char_class(++nd)) == NULL) { + if ((nd = parse_char_class(nd + 1)) == NULL) { errmsg = "unbalanced brackets ([])"; return NULL; } Modified: soc2013/syuu/bhyve_usb/bin/sh/eval.c ============================================================================== --- soc2013/syuu/bhyve_usb/bin/sh/eval.c Sun Jun 30 12:46:03 2013 (r253730) +++ soc2013/syuu/bhyve_usb/bin/sh/eval.c Sun Jun 30 13:10:38 2013 (r253731) @@ -589,7 +589,8 @@ pip[1] = -1; if (lp->next) { if (pipe(pip) < 0) { - close(prevfd); + if (prevfd >= 0) + close(prevfd); error("Pipe call failed: %s", strerror(errno)); } } Modified: soc2013/syuu/bhyve_usb/contrib/libstdc++/libsupc++/unwind-cxx.h ============================================================================== --- soc2013/syuu/bhyve_usb/contrib/libstdc++/libsupc++/unwind-cxx.h Sun Jun 30 12:46:03 2013 (r253730) +++ soc2013/syuu/bhyve_usb/contrib/libstdc++/libsupc++/unwind-cxx.h Sun Jun 30 13:10:38 2013 (r253731) @@ -133,7 +133,7 @@ // throws, and if bad_exception needs to be thrown. Called from the // compiler. extern "C" void __cxa_call_unexpected (void *) __attribute__((noreturn)); -extern "C" void __cxa_call_terminate (void*) __attribute__((noreturn)); +extern "C" void __cxa_call_terminate (_Unwind_Exception*) __attribute__((noreturn)); #ifdef __ARM_EABI_UNWINDER__ // Arm EABI specified routines. Modified: soc2013/syuu/bhyve_usb/crypto/heimdal/lib/gssapi/gssapi/gssapi_krb5.h ============================================================================== --- soc2013/syuu/bhyve_usb/crypto/heimdal/lib/gssapi/gssapi/gssapi_krb5.h Sun Jun 30 12:46:03 2013 (r253730) +++ soc2013/syuu/bhyve_usb/crypto/heimdal/lib/gssapi/gssapi/gssapi_krb5.h Sun Jun 30 13:10:38 2013 (r253731) @@ -36,7 +36,7 @@ #ifndef GSSAPI_KRB5_H_ #define GSSAPI_KRB5_H_ -#include +#include GSSAPI_CPP_START Modified: soc2013/syuu/bhyve_usb/crypto/openssh/sshd_config ============================================================================== --- soc2013/syuu/bhyve_usb/crypto/openssh/sshd_config Sun Jun 30 12:46:03 2013 (r253730) +++ soc2013/syuu/bhyve_usb/crypto/openssh/sshd_config Sun Jun 30 13:10:38 2013 (r253731) @@ -105,7 +105,7 @@ #PrintLastLog yes #TCPKeepAlive yes #UseLogin no -#UsePrivilegeSeparation sandbox +#UsePrivilegeSeparation yes #PermitUserEnvironment no #Compression delayed #ClientAliveInterval 0 Modified: soc2013/syuu/bhyve_usb/crypto/openssh/sshd_config.5 ============================================================================== --- soc2013/syuu/bhyve_usb/crypto/openssh/sshd_config.5 Sun Jun 30 12:46:03 2013 (r253730) +++ soc2013/syuu/bhyve_usb/crypto/openssh/sshd_config.5 Sun Jun 30 13:10:38 2013 (r253731) @@ -1169,7 +1169,7 @@ The goal of privilege separation is to prevent privilege escalation by containing any corruption within the unprivileged processes. The default is -.Dq sandbox . +.Dq yes . If .Cm UsePrivilegeSeparation is set to Modified: soc2013/syuu/bhyve_usb/etc/defaults/rc.conf ============================================================================== --- soc2013/syuu/bhyve_usb/etc/defaults/rc.conf Sun Jun 30 12:46:03 2013 (r253730) +++ soc2013/syuu/bhyve_usb/etc/defaults/rc.conf Sun Jun 30 13:10:38 2013 (r253731) @@ -32,8 +32,6 @@ always_force_depends="NO" # Set to check that indicated dependencies are # running during boot (can increase boot time). -swapfile="NO" # Set to name of swapfile if aux swapfile desired. -swapfile_mdunit="99" # Swapfile md(4) unit number created by mdconfig(8). apm_enable="NO" # Set to YES to enable APM BIOS functions (or NO). apmd_enable="NO" # Run apmd to handle APM event from userland. apmd_flags="" # Flags to apmd (if enabled). @@ -85,15 +83,12 @@ #geli_da1_autodetach="NO" #geli_mirror_home_flags="-k /etc/geli/home.keys" -geli_swap_flags="-e aes -l 256 -s 4096 -d" # Options for GELI-encrypted - # swap partitions. - root_rw_mount="YES" # Set to NO to inhibit remounting root read-write. fsck_y_enable="NO" # Set to YES to do fsck -y if the initial preen fails. fsck_y_flags="" # Additional flags for fsck -y background_fsck="YES" # Attempt to run fsck in the background where possible. background_fsck_delay="60" # Time to wait (seconds) before starting the fsck. -netfs_types="nfs:NFS oldnfs:OLDNFS" # Net filesystems. +netfs_types="nfs:NFS oldnfs:OLDNFS smbfs:SMB" # Net filesystems. extra_netfs_types="NO" # List of network extra filesystem types for delayed # mount at startup (or NO). Modified: soc2013/syuu/bhyve_usb/etc/mtree/BSD.include.dist ============================================================================== --- soc2013/syuu/bhyve_usb/etc/mtree/BSD.include.dist Sun Jun 30 12:46:03 2013 (r253730) +++ soc2013/syuu/bhyve_usb/etc/mtree/BSD.include.dist Sun Jun 30 13:10:38 2013 (r253731) @@ -176,6 +176,8 @@ .. procfs .. + smbfs + .. udf .. unionfs Modified: soc2013/syuu/bhyve_usb/etc/mtree/BSD.usr.dist ============================================================================== --- soc2013/syuu/bhyve_usb/etc/mtree/BSD.usr.dist Sun Jun 30 12:46:03 2013 (r253730) +++ soc2013/syuu/bhyve_usb/etc/mtree/BSD.usr.dist Sun Jun 30 13:10:38 2013 (r253731) @@ -309,6 +309,10 @@ srcs .. .. + smbfs + print + .. + .. sunrpc dir .. Modified: soc2013/syuu/bhyve_usb/etc/network.subr ============================================================================== --- soc2013/syuu/bhyve_usb/etc/network.subr Sun Jun 30 12:46:03 2013 (r253730) +++ soc2013/syuu/bhyve_usb/etc/network.subr Sun Jun 30 13:10:38 2013 (r253731) @@ -318,6 +318,15 @@ local _tmpargs _arg _tmpargs=`_ifconfig_getargs $1` + case $1 in + lo[0-9]*|\ + stf[0-9]*|\ + faith[0-9]*|\ + lp[0-9]*|\ + sl[0-9]*) + return 1 + ;; + esac if noafif $1; then return 1 fi @@ -509,7 +518,7 @@ _if=$1 case $_if in - lo0|\ + lo[0-9]*|\ stf[0-9]*|\ faith[0-9]*|\ lp[0-9]*|\ Modified: soc2013/syuu/bhyve_usb/etc/rc.d/Makefile ============================================================================== --- soc2013/syuu/bhyve_usb/etc/rc.d/Makefile Sun Jun 30 12:46:03 2013 (r253730) +++ soc2013/syuu/bhyve_usb/etc/rc.d/Makefile Sun Jun 30 13:10:38 2013 (r253731) @@ -37,7 +37,6 @@ dhclient \ dmesg \ dumpon \ - encswap \ faith \ fsck \ ftp-proxy \ @@ -139,7 +138,8 @@ static_arp \ static_ndp \ stf \ - swap1 \ + swap \ + swaplate \ syscons \ sysctl \ syslogd \ Modified: soc2013/syuu/bhyve_usb/etc/rc.d/addswap ============================================================================== --- soc2013/syuu/bhyve_usb/etc/rc.d/addswap Sun Jun 30 12:46:03 2013 (r253730) +++ soc2013/syuu/bhyve_usb/etc/rc.d/addswap Sun Jun 30 13:10:38 2013 (r253731) @@ -13,57 +13,12 @@ . /etc/rc.subr name="addswap" -start_cmd="addswap_start" -stop_cmd="addswap_stop" +start_cmd=":" +stop_cmd=":" +rcvar= -addswap_start() -{ - case ${swapfile} in - [Nn][Oo] | '') - ;; - *) - if [ -w "${swapfile}" ]; then - check_startmsgs && echo "Adding ${swapfile} as additional swap" - - if [ -n "${swapfile_mdunit}" ]; then - mdev="/dev/md${swapfile_mdunit#md}" - mdconfig -a -t vnode -f "${swapfile}" -u ${swapfile_mdunit} - else - mdev="/dev/`mdconfig -a -t vnode -f "${swapfile}"`" - fi - - if [ $? -eq 0 ]; then - swapon ${mdev} - else - echo "error creating swapfile device" - fi - fi - ;; - esac -} - -addswap_stop() -{ - case ${swapfile} in - [Nn][Oo] | '') - ;; - *) - if [ -n "${swapfile_mdunit}" ]; then - mdev="/dev/md${swapfile_mdunit#md}" - else - mdev="/dev/`mdconfig -lv | grep "${swapfile}" | cut -f1`" - swapfile_mdunit=${mdev#md} - fi - if [ -n "${swapfile_mdunit}" ]; then - swapctl -l | grep -q ${mdev} - if [ $? -eq 0 ]; then - echo "Dismounting swapfile ${swapfile}" - swapoff ${mdev} && mdconfig -d -u ${swapfile_mdunit} - fi - fi - ;; - esac -} +set_rcvar_obsolete swapfile +set_rcvar_obsolete geli_swap_flags load_rc_config $name run_rc_command "$1" Modified: soc2013/syuu/bhyve_usb/etc/rc.d/fsck ============================================================================== --- soc2013/syuu/bhyve_usb/etc/rc.d/fsck Sun Jun 30 12:46:03 2013 (r253730) +++ soc2013/syuu/bhyve_usb/etc/rc.d/fsck Sun Jun 30 13:10:38 2013 (r253731) @@ -4,7 +4,7 @@ # # PROVIDE: fsck -# REQUIRE: localswap +# REQUIRE: swap # KEYWORD: nojail . /etc/rc.subr Modified: soc2013/syuu/bhyve_usb/etc/rc.d/mdconfig ============================================================================== --- soc2013/syuu/bhyve_usb/etc/rc.d/mdconfig Sun Jun 30 12:46:03 2013 (r253730) +++ soc2013/syuu/bhyve_usb/etc/rc.d/mdconfig Sun Jun 30 13:10:38 2013 (r253731) @@ -28,7 +28,7 @@ # # PROVIDE: mdconfig -# REQUIRE: localswap root +# REQUIRE: swap root . /etc/rc.subr Copied: soc2013/syuu/bhyve_usb/etc/rc.d/swap (from r253730, mirror/FreeBSD/head/etc/rc.d/swap) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/syuu/bhyve_usb/etc/rc.d/swap Sun Jun 30 13:10:38 2013 (r253731, copy of r253730, mirror/FreeBSD/head/etc/rc.d/swap) @@ -0,0 +1,17 @@ +#!/bin/sh +# +# $FreeBSD$ +# + +# PROVIDE: swap +# REQUIRE: disks +# KEYWORD: nojail shutdown + +. /etc/rc.subr + +name="swap" +start_cmd='/sbin/swapon -aq' +stop_cmd=':' + +load_rc_config $name +run_rc_command "$1" Copied: soc2013/syuu/bhyve_usb/etc/rc.d/swaplate (from r253730, mirror/FreeBSD/head/etc/rc.d/swaplate) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/syuu/bhyve_usb/etc/rc.d/swaplate Sun Jun 30 13:10:38 2013 (r253731, copy of r253730, mirror/FreeBSD/head/etc/rc.d/swaplate) @@ -0,0 +1,17 @@ +#!/bin/sh +# +# $FreeBSD$ +# + +# PROVIDE: swaplate +# REQUIRE: mountlate +# KEYWORD: nojail shutdown + +. /etc/rc.subr + +name="swaplate" +start_cmd='/sbin/swapon -aLq' +stop_cmd='/sbin/swapoff -aq' + +load_rc_config swap +run_rc_command "$1" Modified: soc2013/syuu/bhyve_usb/include/Makefile ============================================================================== --- soc2013/syuu/bhyve_usb/include/Makefile Sun Jun 30 12:46:03 2013 (r253730) +++ soc2013/syuu/bhyve_usb/include/Makefile Sun Jun 30 13:10:38 2013 (r253731) @@ -37,7 +37,7 @@ syslog.h ucontext.h LDIRS= bsm cam geom net net80211 netatalk netgraph netinet netinet6 \ - netipsec ${_netipx} netnatm \ + netipsec ${_netipx} netnatm netsmb \ nfs nfsclient nfsserver \ sys vm @@ -48,7 +48,7 @@ dev/ofw dev/pbio dev/pci ${_dev_powermac_nvram} dev/ppbus dev/smbus \ dev/speaker dev/usb dev/utopia dev/vkbd dev/wi \ fs/devfs fs/fdescfs fs/msdosfs fs/nandfs fs/nfs fs/nullfs \ - fs/procfs fs/udf fs/unionfs \ + fs/procfs fs/smbfs fs/udf fs/unionfs \ geom/cache geom/concat geom/eli geom/gate geom/journal geom/label \ geom/mirror geom/mountver geom/multipath geom/nop \ geom/raid geom/raid3 geom/shsec geom/stripe geom/virstor \ @@ -80,6 +80,7 @@ LSUBSUBDIRS+= netgraph/bluetooth/include .endif +# XXX unconditionally needed by #.if ${MK_IPX} != "no" _netipx= netipx #.endif Modified: soc2013/syuu/bhyve_usb/include/gssapi/gssapi.h ============================================================================== --- soc2013/syuu/bhyve_usb/include/gssapi/gssapi.h Sun Jun 30 12:46:03 2013 (r253730) +++ soc2013/syuu/bhyve_usb/include/gssapi/gssapi.h Sun Jun 30 13:10:38 2013 (r253731) @@ -44,6 +44,33 @@ #define _SSIZE_T_DECLARED #endif +/* Compatibility with Heimdal 1.5.1 */ +#ifndef GSSAPI_CPP_START +#ifdef __cplusplus +#define GSSAPI_CPP_START extern "C" { +#define GSSAPI_CPP_END } +#else +#define GSSAPI_CPP_START +#define GSSAPI_CPP_END +#endif +#endif + +/* Compatibility with Heimdal 1.5.1 */ +#ifndef BUILD_GSSAPI_LIB +#define GSSAPI_LIB_FUNCTION +#define GSSAPI_LIB_CALL +#define GSSAPI_LIB_VARIABLE +#endif + +/* Compatibility with Heimdal 1.5.1 */ +#ifndef GSSAPI_DEPRECATED_FUNCTION +#if defined(__GNUC__) && ((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1 ))) +#define GSSAPI_DEPRECATED_FUNCTION(X) __attribute__((deprecated)) +#else +#define GSSAPI_DEPRECATED_FUNCTION(X) +#endif +#endif + #if 0 /* * If the platform supports the xom.h header file, it should be Modified: soc2013/syuu/bhyve_usb/include/paths.h ============================================================================== --- soc2013/syuu/bhyve_usb/include/paths.h Sun Jun 30 12:46:03 2013 (r253730) +++ soc2013/syuu/bhyve_usb/include/paths.h Sun Jun 30 13:10:38 2013 (r253731) @@ -57,6 +57,8 @@ #define _PATH_ETC "/etc" #define _PATH_FTPUSERS "/etc/ftpusers" #define _PATH_FWMEM "/dev/fwmem" +#define _PATH_GBDE "/sbin/gbde" +#define _PATH_GELI "/sbin/geli" #define _PATH_HALT "/sbin/halt" #ifdef COMPAT_32BIT #define _PATH_I18NMODULE "/usr/lib32/i18n" Modified: soc2013/syuu/bhyve_usb/lib/Makefile ============================================================================== --- soc2013/syuu/bhyve_usb/lib/Makefile Sun Jun 30 12:46:03 2013 (r253730) +++ soc2013/syuu/bhyve_usb/lib/Makefile Sun Jun 30 13:10:38 2013 (r253731) @@ -102,6 +102,7 @@ ${_librtld_db} \ ${_libsdp} \ ${_libsm} \ + ${_libsmb} \ ${_libsmdb} \ ${_libsmutil} \ libstand \ @@ -205,6 +206,7 @@ .endif .if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64" +_libsmb= libsmb _libvgl= libvgl _libproc= libproc _librtld_db= librtld_db @@ -216,6 +218,7 @@ .if ${MACHINE_CPUARCH} == "ia64" _libefi= libefi +_libsmb= libsmb .endif .if ${MACHINE_CPUARCH} == "mips" @@ -226,6 +229,11 @@ .if ${MACHINE_CPUARCH} == "powerpc" _libproc= libproc _librtld_db= librtld_db +_libsmb= libsmb +.endif + +.if ${MACHINE_CPUARCH} == "sparc64" +_libsmb= libsmb .endif .if ${MK_OPENSSL} != "no" Modified: soc2013/syuu/bhyve_usb/lib/libfetch/fetch.c ============================================================================== --- soc2013/syuu/bhyve_usb/lib/libfetch/fetch.c Sun Jun 30 12:46:03 2013 (r253730) +++ soc2013/syuu/bhyve_usb/lib/libfetch/fetch.c Sun Jun 30 13:10:38 2013 (r253731) @@ -376,7 +376,7 @@ /* password */ if (*q == ':') - q = fetch_pctdecode(u->pwd, ++q, URL_PWDLEN); + q = fetch_pctdecode(u->pwd, q + 1, URL_PWDLEN); p++; } else { Modified: soc2013/syuu/bhyve_usb/lib/libprocstat/Makefile ============================================================================== --- soc2013/syuu/bhyve_usb/lib/libprocstat/Makefile Sun Jun 30 12:46:03 2013 (r253730) +++ soc2013/syuu/bhyve_usb/lib/libprocstat/Makefile Sun Jun 30 13:10:38 2013 (r253731) @@ -9,6 +9,7 @@ core.c \ libprocstat.c \ msdosfs.c \ + smbfs.c \ udf.c VERSION_DEF= ${.CURDIR}/Versions.def Modified: soc2013/syuu/bhyve_usb/lib/libprocstat/common_kvm.h ============================================================================== --- soc2013/syuu/bhyve_usb/lib/libprocstat/common_kvm.h Sun Jun 30 12:46:03 2013 (r253730) +++ soc2013/syuu/bhyve_usb/lib/libprocstat/common_kvm.h Sun Jun 30 13:10:38 2013 (r253731) @@ -41,6 +41,7 @@ int isofs_filestat(kvm_t *kd, struct vnode *vp, struct vnstat *vn); int msdosfs_filestat(kvm_t *kd, struct vnode *vp, struct vnstat *vn); int nfs_filestat(kvm_t *kd, struct vnode *vp, struct vnstat *vn); +int smbfs_filestat(kvm_t *kd, struct vnode *vp, struct vnstat *vn); int udf_filestat(kvm_t *kd, struct vnode *vp, struct vnstat *vn); int ufs_filestat(kvm_t *kd, struct vnode *vp, struct vnstat *vn); int zfs_filestat(kvm_t *kd, struct vnode *vp, struct vnstat *vn); Modified: soc2013/syuu/bhyve_usb/lib/libprocstat/libprocstat.c ============================================================================== --- soc2013/syuu/bhyve_usb/lib/libprocstat/libprocstat.c Sun Jun 30 12:46:03 2013 (r253730) +++ soc2013/syuu/bhyve_usb/lib/libprocstat/libprocstat.c Sun Jun 30 13:10:38 2013 (r253731) @@ -1220,6 +1220,7 @@ FSTYPE(isofs), FSTYPE(msdosfs), FSTYPE(nfs), + FSTYPE(smbfs), FSTYPE(udf), FSTYPE(ufs), #ifdef LIBPROCSTAT_ZFS Modified: soc2013/syuu/bhyve_usb/lib/librt/sigev_thread.c ============================================================================== --- soc2013/syuu/bhyve_usb/lib/librt/sigev_thread.c Sun Jun 30 12:46:03 2013 (r253730) +++ soc2013/syuu/bhyve_usb/lib/librt/sigev_thread.c Sun Jun 30 13:10:38 2013 (r253731) @@ -28,13 +28,13 @@ */ #include -#include #include "namespace.h" #include #include #include #include +#include #include #include #include @@ -51,7 +51,7 @@ static struct sigev_list_head sigev_hash[HASH_QUEUES]; static struct sigev_list_head sigev_all; static LIST_HEAD(,sigev_thread) sigev_threads; -static unsigned int sigev_generation; +static atomic_int sigev_generation; static pthread_mutex_t *sigev_list_mtx; static pthread_once_t sigev_once = PTHREAD_ONCE_INIT; static pthread_once_t sigev_once_default = PTHREAD_ONCE_INIT; @@ -196,7 +196,8 @@ if (sn != NULL) { sn->sn_value = evp->sigev_value; sn->sn_func = evp->sigev_notify_function; - sn->sn_gen = atomic_fetchadd_int(&sigev_generation, 1); + sn->sn_gen = atomic_fetch_add_explicit(&sigev_generation, 1, + memory_order_relaxed); sn->sn_type = type; _pthread_attr_init(&sn->sn_attr); _pthread_attr_setdetachstate(&sn->sn_attr, PTHREAD_CREATE_DETACHED); Modified: soc2013/syuu/bhyve_usb/lib/libutil/login_times.c ============================================================================== --- soc2013/syuu/bhyve_usb/lib/libutil/login_times.c Sun Jun 30 12:46:03 2013 (r253730) +++ soc2013/syuu/bhyve_usb/lib/libutil/login_times.c Sun Jun 30 13:10:38 2013 (r253731) @@ -96,7 +96,7 @@ else m.lt_start = 0; if (*p == '-') - p = parse_time(++p, &m.lt_end); + p = parse_time(p + 1, &m.lt_end); else m.lt_end = 1440; Modified: soc2013/syuu/bhyve_usb/rescue/rescue/Makefile ============================================================================== --- soc2013/syuu/bhyve_usb/rescue/rescue/Makefile Sun Jun 30 12:46:03 2013 (r253730) +++ soc2013/syuu/bhyve_usb/rescue/rescue/Makefile Sun Jun 30 13:10:38 2013 (r253731) @@ -130,6 +130,8 @@ .if ${MACHINE_CPUARCH} == "i386" CRUNCH_PROGS_sbin+= bsdlabel sconfig fdisk CRUNCH_ALIAS_bsdlabel= disklabel +#CRUNCH_PROGS+= mount_smbfs +#CRUNCH_LIBS+= -lsmb .endif .if ${MACHINE} == "pc98" Modified: soc2013/syuu/bhyve_usb/sbin/hastd/refcnt.h ============================================================================== --- soc2013/syuu/bhyve_usb/sbin/hastd/refcnt.h Sun Jun 30 12:46:03 2013 (r253730) +++ soc2013/syuu/bhyve_usb/sbin/hastd/refcnt.h Sun Jun 30 13:10:38 2013 (r253731) @@ -32,24 +32,24 @@ #ifndef __REFCNT_H__ #define __REFCNT_H__ -#include +#include #include "pjdlog.h" -typedef atomic_uint refcnt_t; +typedef unsigned int refcnt_t; static __inline void refcnt_init(refcnt_t *count, unsigned int v) { - atomic_init(count, v); + *count = v; } static __inline void refcnt_acquire(refcnt_t *count) { - atomic_fetch_add_explicit(count, 1, memory_order_acquire); + atomic_add_acq_int(count, 1); } static __inline unsigned int @@ -58,7 +58,7 @@ unsigned int old; /* XXX: Should this have a rel membar? */ - old = atomic_fetch_sub(count, 1); + old = atomic_fetchadd_int(count, -1); PJDLOG_ASSERT(old > 0); return (old - 1); } Modified: soc2013/syuu/bhyve_usb/sbin/ifconfig/af_nd6.c ============================================================================== --- soc2013/syuu/bhyve_usb/sbin/ifconfig/af_nd6.c Sun Jun 30 12:46:03 2013 (r253730) +++ soc2013/syuu/bhyve_usb/sbin/ifconfig/af_nd6.c Sun Jun 30 13:10:38 2013 (r253731) @@ -148,7 +148,7 @@ memset(&nd, 0, sizeof(nd)); strncpy(nd.ifname, ifr.ifr_name, sizeof(nd.ifname)); if ((s6 = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) { - if (errno != EAFNOSUPPORT) + if (errno != EAFNOSUPPORT && error != EPROTONOSUPPORT) warn("socket(AF_INET6, SOCK_DGRAM)"); return; } Modified: soc2013/syuu/bhyve_usb/sbin/mdconfig/mdconfig.8 ============================================================================== --- soc2013/syuu/bhyve_usb/sbin/mdconfig/mdconfig.8 Sun Jun 30 12:46:03 2013 (r253730) +++ soc2013/syuu/bhyve_usb/sbin/mdconfig/mdconfig.8 Sun Jun 30 13:10:38 2013 (r253731) @@ -144,7 +144,7 @@ and .Fl f options are specified, -display devices which match the two conditions. +display devices which match the two conditions. If the .Fl v option is specified, show all details. Modified: soc2013/syuu/bhyve_usb/sbin/mount/mount.8 ============================================================================== --- soc2013/syuu/bhyve_usb/sbin/mount/mount.8 Sun Jun 30 12:46:03 2013 (r253730) +++ soc2013/syuu/bhyve_usb/sbin/mount/mount.8 Sun Jun 30 13:10:38 2013 (r253731) @@ -450,6 +450,7 @@ .Cm nfs , .Cm nullfs , .Cm oldnfs , +.Cm smbfs , .Cm udf , and .Cm unionfs . @@ -544,6 +545,7 @@ .Xr mount_msdosfs 8 , .Xr mount_nfs 8 , .Xr mount_nullfs 8 , +.Xr mount_smbfs 8 , .Xr mount_udf 8 , .Xr mount_unionfs 8 , .Xr umount 8 , Modified: soc2013/syuu/bhyve_usb/sbin/mount/mount.c ============================================================================== --- soc2013/syuu/bhyve_usb/sbin/mount/mount.c Sun Jun 30 12:46:03 2013 (r253730) +++ soc2013/syuu/bhyve_usb/sbin/mount/mount.c Sun Jun 30 13:10:38 2013 (r253731) @@ -143,7 +143,7 @@ unsigned int i; const char *fs[] = { "cd9660", "mfs", "msdosfs", "nfs", - "nullfs", "oldnfs", "udf", "unionfs", + "nullfs", "oldnfs", "smbfs", "udf", "unionfs", NULL }; Modified: soc2013/syuu/bhyve_usb/sbin/nvmecontrol/Makefile ============================================================================== --- soc2013/syuu/bhyve_usb/sbin/nvmecontrol/Makefile Sun Jun 30 12:46:03 2013 (r253730) +++ soc2013/syuu/bhyve_usb/sbin/nvmecontrol/Makefile Sun Jun 30 13:10:38 2013 (r253731) @@ -1,6 +1,8 @@ # $FreeBSD$ PROG= nvmecontrol +SRCS= nvmecontrol.c devlist.c firmware.c identify.c logpage.c \ + perftest.c reset.c MAN= nvmecontrol.8 .include Copied: soc2013/syuu/bhyve_usb/sbin/nvmecontrol/devlist.c (from r253730, mirror/FreeBSD/head/sbin/nvmecontrol/devlist.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/syuu/bhyve_usb/sbin/nvmecontrol/devlist.c Sun Jun 30 13:10:38 2013 (r253731, copy of r253730, mirror/FreeBSD/head/sbin/nvmecontrol/devlist.c) @@ -0,0 +1,115 @@ +/*- + * Copyright (C) 2012-2013 Intel Corporation + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "nvmecontrol.h" + +static void +devlist_usage(void) +{ + fprintf(stderr, "usage:\n"); + fprintf(stderr, DEVLIST_USAGE); + exit(EX_USAGE); +} + +static inline uint32_t +ns_get_sector_size(struct nvme_namespace_data *nsdata) +{ + + return (1 << nsdata->lbaf[0].lbads); +} + +void +devlist(int argc, char *argv[]) +{ + struct nvme_controller_data cdata; + struct nvme_namespace_data nsdata; + char name[64]; + uint32_t i; + int ch, ctrlr, exit_code, fd, found; + + exit_code = EX_OK; + + while ((ch = getopt(argc, argv, "")) != -1) { + switch ((char)ch) { + default: + devlist_usage(); + } + } + + ctrlr = -1; + found = 0; + + while (1) { + ctrlr++; + sprintf(name, "%s%d", NVME_CTRLR_PREFIX, ctrlr); + + exit_code = open_dev(name, &fd, 0, 0); + + if (exit_code == EX_NOINPUT) + break; + else if (exit_code == EX_NOPERM) { + printf("Could not open /dev/%s, errno = %d (%s)\n", + name, errno, strerror(errno)); + continue; + } + + found++; + read_controller_data(fd, &cdata); + printf("%6s: %s\n", name, cdata.mn); + + for (i = 0; i < cdata.nn; i++) { + sprintf(name, "%s%d%s%d", NVME_CTRLR_PREFIX, ctrlr, + NVME_NS_PREFIX, i+1); + read_namespace_data(fd, i+1, &nsdata); + printf(" %10s (%lldGB)\n", + name, + nsdata.nsze * + (long long)ns_get_sector_size(&nsdata) / + 1024 / 1024 / 1024); + } + + close(fd); + } + + if (found == 0) + printf("No NVMe controllers found.\n"); + + exit(EX_OK); +} Copied: soc2013/syuu/bhyve_usb/sbin/nvmecontrol/firmware.c (from r253730, mirror/FreeBSD/head/sbin/nvmecontrol/firmware.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/syuu/bhyve_usb/sbin/nvmecontrol/firmware.c Sun Jun 30 13:10:38 2013 (r253731, copy of r253730, mirror/FreeBSD/head/sbin/nvmecontrol/firmware.c) @@ -0,0 +1,335 @@ +/*- + * Copyright (c) 2013 EMC Corp. + * All rights reserved. + * + * Copyright (C) 2012-2013 Intel Corporation + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "nvmecontrol.h" + +static int +slot_has_valid_firmware(int fd, int slot) +{ + struct nvme_firmware_page fw; + int has_fw = false; + + read_logpage(fd, NVME_LOG_FIRMWARE_SLOT, + NVME_GLOBAL_NAMESPACE_TAG, &fw, sizeof(fw)); + + if (fw.revision[slot-1] != 0LLU) + has_fw = true; + + return (has_fw); +} + +static void +read_image_file(char *path, void **buf, ssize_t *size) +{ + struct stat sb; + int fd; + + *size = 0; + *buf = NULL; + + if ((fd = open(path, O_RDONLY)) < 0) { + fprintf(stderr, "Unable to open '%s'.\n", path); + exit(EX_IOERR); + } + if (fstat(fd, &sb) < 0) { + fprintf(stderr, "Unable to stat '%s'.\n", path); + close(fd); + exit(EX_IOERR); + } + if ((*buf = malloc(sb.st_size)) == NULL) { + fprintf(stderr, "Unable to malloc %zd bytes.\n", + sb.st_size); + close(fd); + exit(EX_IOERR); + } + if ((*size = read(fd, *buf, sb.st_size)) < 0) { + fprintf(stderr, "Error reading '%s', errno=%d (%s)\n", + path, errno, strerror(errno)); + close(fd); + exit(EX_IOERR); + } + if (*size != sb.st_size) { + fprintf(stderr, "Error reading '%s', " + "read %zd bytes, requested %zd bytes\n", + path, *size, sb.st_size); + close(fd); + exit(EX_IOERR); + } +} + +static void +update_firmware(int fd, uint8_t *payload, uint32_t payload_size) +{ + struct nvme_pt_command pt; + size_t size; + void *chunk; + uint32_t off, resid; + int exit_code = EX_OK; + + off = 0; + resid = payload_size; + + if ((chunk = malloc((size_t)NVME_MAX_XFER_SIZE)) == NULL) { + printf("Unable to malloc %d bytes.\n", NVME_MAX_XFER_SIZE); + exit(EX_IOERR); + } + + while (resid > 0) { + size = (resid >= NVME_MAX_XFER_SIZE) ? + NVME_MAX_XFER_SIZE : resid; + memcpy(chunk, payload + off, size); + + memset(&pt, 0, sizeof(pt)); + pt.cmd.opc = NVME_OPC_FIRMWARE_IMAGE_DOWNLOAD; + pt.cmd.cdw10 = (size / sizeof(uint32_t)) - 1; + pt.cmd.cdw11 = (off / sizeof(uint32_t)); + pt.buf = chunk; + pt.len = size; + pt.is_read = 0; + + if (ioctl(fd, NVME_PASSTHROUGH_CMD, &pt) < 0) { + printf("Firmware image download request failed. " + "errno=%d (%s)\n", + errno, strerror(errno)); + exit_code = EX_IOERR; + break; + } + + if (nvme_completion_is_error(&pt.cpl)) { + printf("Passthrough command returned error.\n"); + exit_code = EX_IOERR; + break; + } + + resid -= size; + off += size; + } + + if (exit_code != EX_OK) + exit(exit_code); +} + +static void +activate_firmware(int fd, int slot, int activate_action) +{ + struct nvme_pt_command pt; + + memset(&pt, 0, sizeof(pt)); + pt.cmd.opc = NVME_OPC_FIRMWARE_ACTIVATE; + pt.cmd.cdw10 = (activate_action << 3) | slot; + pt.is_read = 0; + + if (ioctl(fd, NVME_PASSTHROUGH_CMD, &pt) < 0) { + printf("Firmware activate request failed. errno=%d (%s)\n", + errno, strerror(errno)); + exit(EX_IOERR); + } + + if (nvme_completion_is_error(&pt.cpl)) { + printf("Passthrough command returned error.\n"); + exit(EX_IOERR); + } +} + +static void +firmware_usage(void) +{ + fprintf(stderr, "usage:\n"); + fprintf(stderr, FIRMWARE_USAGE); + exit(EX_USAGE); +} + +void +firmware(int argc, char *argv[]) +{ + int fd = -1, slot = 0; + int a_flag, s_flag, f_flag; + char ch, *p, *image = NULL; + char *controller = NULL, prompt[64]; + void *buf = NULL; + ssize_t size; + struct nvme_controller_data cdata; + + a_flag = s_flag = f_flag = false; + + while ((ch = getopt(argc, argv, "af:s:")) != -1) { + switch (ch) { + case 'a': + a_flag = true; + break; + case 's': + slot = strtol(optarg, &p, 0); + if (p != NULL && *p != '\0') { + fprintf(stderr, + "\"%s\" not valid slot.\n", + optarg); + firmware_usage(); + } else if (slot == 0) { + fprintf(stderr, + "0 is not a valid slot number. " + "Slot numbers start at 1.\n"); + firmware_usage(); + } else if (slot > 7) { + fprintf(stderr, + "Slot number %s specified which is " + "greater than max allowed slot number of " + "7.\n", optarg); + firmware_usage(); + } + s_flag = true; + break; + case 'f': + image = optarg; + f_flag = true; + break; + } + } + + /* Check that a controller (and not a namespace) was specified. */ + if (optind >= argc || strstr(argv[optind], NVME_NS_PREFIX) != NULL) + firmware_usage(); + + if (!f_flag && !a_flag) { + fprintf(stderr, + "Neither a replace ([-f path_to_firmware]) nor " + "activate ([-a]) firmware image action\n" + "was specified.\n"); + firmware_usage(); + } + + if (!f_flag && a_flag && slot == 0) { + fprintf(stderr, + "Slot number to activate not specified.\n"); + firmware_usage(); + } + + controller = argv[optind]; + open_dev(controller, &fd, 1, 1); + read_controller_data(fd, &cdata); + + if (cdata.oacs.firmware == 0) { + fprintf(stderr, + "Controller does not support firmware " + "activate/download.\n"); + exit(EX_IOERR); + } + + if (f_flag && slot == 1 && cdata.frmw.slot1_ro) { + fprintf(stderr, "Slot %d is marked as read only.\n", slot); + exit(EX_IOERR); + } + + if (slot > cdata.frmw.num_slots) { + fprintf(stderr, + "Slot %d was specified but controller only " + "supports %d firmware slots.\n", + slot, cdata.frmw.num_slots); + exit(EX_IOERR); *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-soc-all@FreeBSD.ORG Sun Jun 30 17:57:20 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id BA6347E8 for ; Sun, 30 Jun 2013 17:57:20 +0000 (UTC) (envelope-from ambarisha@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 9265316F5 for ; Sun, 30 Jun 2013 17:57:20 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r5UHvJI1010537 for ; Sun, 30 Jun 2013 17:57:19 GMT (envelope-from ambarisha@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r5UHvJtG010536 for svn-soc-all@FreeBSD.org; Sun, 30 Jun 2013 17:57:19 GMT (envelope-from ambarisha@FreeBSD.org) Date: Sun, 30 Jun 2013 17:57:19 GMT Message-Id: <201306301757.r5UHvJtG010536@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to ambarisha@FreeBSD.org using -f From: ambarisha@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r253739 - soc2013/ambarisha/head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 30 Jun 2013 17:57:20 -0000 Author: ambarisha Date: Sun Jun 30 17:57:19 2013 New Revision: 253739 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=253739 Log: Copying head Added: soc2013/ambarisha/head/ (props changed) - copied from r253738, mirror/FreeBSD/head/ From owner-svn-soc-all@FreeBSD.ORG Sun Jun 30 22:35:38 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 6B0DF9FA for ; Sun, 30 Jun 2013 22:35:38 +0000 (UTC) (envelope-from mattbw@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 5C7FF1E41 for ; Sun, 30 Jun 2013 22:35:38 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r5UMZc0v022926 for ; Sun, 30 Jun 2013 22:35:38 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r5UMZcff022920 for svn-soc-all@FreeBSD.org; Sun, 30 Jun 2013 22:35:38 GMT (envelope-from mattbw@FreeBSD.org) Date: Sun, 30 Jun 2013 22:35:38 GMT Message-Id: <201306302235.r5UMZcff022920@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to mattbw@FreeBSD.org using -f From: mattbw@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r253750 - soc2013/mattbw/backend MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 30 Jun 2013 22:35:38 -0000 Author: mattbw Date: Sun Jun 30 22:35:37 2013 New Revision: 253750 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=253750 Log: remove some dead-end bits of dummy code Modified: soc2013/mattbw/backend/pk-backend-pkgng.c Modified: soc2013/mattbw/backend/pk-backend-pkgng.c ============================================================================== --- soc2013/mattbw/backend/pk-backend-pkgng.c Sun Jun 30 21:06:47 2013 (r253749) +++ soc2013/mattbw/backend/pk-backend-pkgng.c Sun Jun 30 22:35:37 2013 (r253750) @@ -43,15 +43,10 @@ static gchar **_package_ids; static gchar **_values; static guint _package_current = 0; -static gboolean _repo_enabled_local = FALSE; -static gboolean _repo_enabled_fedora = TRUE; -static gboolean _repo_enabled_devel = TRUE; -static gboolean _repo_enabled_livna = TRUE; static gboolean _updated_gtkhtml = FALSE; static gboolean _updated_kernel = FALSE; static gboolean _updated_powertop = FALSE; static gboolean _has_signature = FALSE; -static gboolean _use_blocked = FALSE; static gboolean _use_eula = FALSE; static gboolean _use_media = FALSE; static gboolean _use_gpg = FALSE; @@ -355,13 +350,6 @@ { PkBackend *backend = (PkBackend *)data; - if (_use_blocked) { - if (!_updated_powertop && !_updated_kernel && !_updated_gtkhtml) { - pk_backend_package(backend, PK_INFO_ENUM_BLOCKED, - "vino;2.24.2.fc9;i386;fedora", - "Remote desktop server for the desktop"); - } - } if (!_updated_powertop) { pk_backend_package(backend, PK_INFO_ENUM_NORMAL, "powertop;1.8-1.fc8;i386;fedora", @@ -828,12 +816,6 @@ guint sub; if (_progress_percentage == 100) { - if (_use_blocked) { - pk_backend_package(backend, PK_INFO_ENUM_BLOCKED, - "gtkhtml2;2.19.1-4.fc8;i386;fedora", - "An HTML widget for GTK+ 2.0"); - _updated_gtkhtml = FALSE; - } pk_backend_finished(backend); return FALSE; } @@ -858,12 +840,10 @@ pk_backend_message(backend, PK_MESSAGE_ENUM_BROKEN_MIRROR, "fedora-updates-testing-debuginfo metadata is invalid"); pk_backend_message(backend, PK_MESSAGE_ENUM_BROKEN_MIRROR, "fedora-updates-testing-source metadata is invalid"); pk_backend_set_sub_percentage(backend, 100); - if (!_use_blocked) { - pk_backend_package(backend, PK_INFO_ENUM_INSTALLING, + pk_backend_package(backend, PK_INFO_ENUM_INSTALLING, "gtkhtml2;2.19.1-4.fc8;i386;fedora", "An HTML widget for GTK+ 2.0"); - _updated_gtkhtml = TRUE; - } + _updated_gtkhtml = TRUE; pk_backend_set_sub_percentage(backend, 0); } if (_progress_percentage == 40 && !_updated_powertop) { @@ -992,17 +972,10 @@ pk_backend_message(backend, PK_MESSAGE_ENUM_BROKEN_MIRROR, "fedora-updates-testing metadata is invalid"); pk_backend_message(backend, PK_MESSAGE_ENUM_BROKEN_MIRROR, "fedora-updates-testing-debuginfo metadata is invalid"); pk_backend_message(backend, PK_MESSAGE_ENUM_BROKEN_MIRROR, "fedora-updates-testing-source metadata is invalid"); - if (_use_blocked) { - pk_backend_package(backend, PK_INFO_ENUM_BLOCKED, - "gtkhtml2;2.19.1-4.fc8;i386;fedora", - "An HTML widget for GTK+ 2.0"); - _updated_gtkhtml = FALSE; - } else { - pk_backend_package(backend, PK_INFO_ENUM_INSTALLING, + pk_backend_package(backend, PK_INFO_ENUM_INSTALLING, "gtkhtml2;2.19.1-4.fc8;i386;fedora", "An HTML widget for GTK+ 2.0"); - _updated_gtkhtml = TRUE; - } + _updated_gtkhtml = TRUE; } if (_progress_percentage == 40 && !_updated_powertop) { pk_backend_set_status(backend, PK_STATUS_ENUM_UPDATE); @@ -1186,57 +1159,11 @@ pk_backend_finished(backend); } -/** - * pk_backend_repo_enable: - */ -void -pk_backend_repo_enable(PkBackend *backend, const gchar *rid, gboolean enabled) -{ - pk_backend_set_status(backend, PK_STATUS_ENUM_REQUEST); - - if (g_strcmp0(rid, "local") == 0) { - g_debug("local repo: %i", enabled); - _repo_enabled_local = enabled; - } else if (g_strcmp0(rid, "development") == 0) { - g_debug("devel repo: %i", enabled); - _repo_enabled_devel = enabled; - } else if (g_strcmp0(rid, "fedora") == 0) { - g_debug("fedora repo: %i", enabled); - _repo_enabled_fedora = enabled; - } else if (g_strcmp0(rid, "livna-development") == 0) { - g_debug("livna repo: %i", enabled); - _repo_enabled_livna = enabled; - } else { - g_warning("unknown repo: %s", rid); - } - pk_backend_finished(backend); -} - -/** - * pk_backend_repo_set_data: +/* + * Not supported: + * - pk_backend_repo_enable + * - pk_backend_repo_set_data */ -void -pk_backend_repo_set_data(PkBackend *backend, const gchar *rid, const gchar *parameter, const gchar *value) -{ - pk_backend_set_status(backend, PK_STATUS_ENUM_REQUEST); - g_warning("REPO '%s' PARAMETER '%s' TO '%s'", rid, parameter, value); - - if (g_strcmp0(parameter, "use-blocked") == 0) - _use_blocked = atoi(value); - else if (g_strcmp0(parameter, "use-eula") == 0) - _use_eula = atoi(value); - else if (g_strcmp0(parameter, "use-media") == 0) - _use_media = atoi(value); - else if (g_strcmp0(parameter, "use-gpg") == 0) - _use_gpg = atoi(value); - else if (g_strcmp0(parameter, "use-trusted") == 0) - _use_trusted = atoi(value); - else if (g_strcmp0(parameter, "use-distro-upgrade") == 0) - _use_distro_upgrade = atoi(value); - else - pk_backend_message(backend, PK_MESSAGE_ENUM_PARAMETER_INVALID, "invalid parameter %s", parameter); - pk_backend_finished(backend); -} /** * pk_backend_what_provides_timeout: From owner-svn-soc-all@FreeBSD.ORG Mon Jul 1 06:58:02 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 43CC6B5 for ; Mon, 1 Jul 2013 06:58:02 +0000 (UTC) (envelope-from ambarisha@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 351A1119A for ; Mon, 1 Jul 2013 06:58:02 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r616w2KE067810 for ; Mon, 1 Jul 2013 06:58:02 GMT (envelope-from ambarisha@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r616w2g4067805 for svn-soc-all@FreeBSD.org; Mon, 1 Jul 2013 06:58:02 GMT (envelope-from ambarisha@FreeBSD.org) Date: Mon, 1 Jul 2013 06:58:02 GMT Message-Id: <201307010658.r616w2g4067805@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to ambarisha@FreeBSD.org using -f From: ambarisha@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r253769 - soc2013/ambarisha/head/usr.bin/dmget MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Jul 2013 06:58:02 -0000 Author: ambarisha Date: Mon Jul 1 06:58:02 2013 New Revision: 253769 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=253769 Log: Prototype commit of dmGet, a replacement for fetch. Added: soc2013/ambarisha/head/usr.bin/dmget/ soc2013/ambarisha/head/usr.bin/dmget/Makefile soc2013/ambarisha/head/usr.bin/dmget/dmget.c soc2013/ambarisha/head/usr.bin/dmget/dmget.h soc2013/ambarisha/head/usr.bin/dmget/fetch.c Added: soc2013/ambarisha/head/usr.bin/dmget/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/ambarisha/head/usr.bin/dmget/Makefile Mon Jul 1 06:58:02 2013 (r253769) @@ -0,0 +1,16 @@ +# $FreeBSD$ + +.include + +SRCS= fetch.c dmget.c +PROG= dmget +CSTD?= c99 +.if ${MK_OPENSSL} != "no" +DPADD= ${LIBFETCH} ${LIBSSL} ${LIBCRYPTO} +LDADD= -lfetch -lssl -lcrypto +.else +DPADD= ${LIBFETCH} ${LIBMD} +LDADD= -lfetch -lmd +.endif + +.include Added: soc2013/ambarisha/head/usr.bin/dmget/dmget.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/ambarisha/head/usr.bin/dmget/dmget.c Mon Jul 1 06:58:02 2013 (r253769) @@ -0,0 +1,196 @@ + +#include +#include +#include + +#include +#include +#include +#include + + +#include "dmget.h" +auth_t dmAuthMethod; +int dmTimeout; +int dmRestartCalls; +int dmDebug; +int dmLastErrCode; +char dmLastErrString[MAXERRSTRING]; + +static void * +safe_malloc(size_t size) +{ + void *ptr = malloc(size); + if (ptr == NULL) { + /* Notifiy ENOMEM and exit gracefully */ + } + return ptr; +} + +static char +mk_dmflags(void) +{ + char flags = 0; + if (dmRestartCalls != 0) + flags |= DM_RESTART_CALLS; + if (dmDebug != 0) + flags |= DM_DEBUG; + + return flags; +} + +static int +mk_reqbuf(struct url *u, char **reqbuf, char op) +{ + int bufsize = 0; + + bufsize += sizeof(bufsize); // Buffer size + bufsize += 1; // Opcode + bufsize += sizeof(struct url) - 4; // Struct url - doc pointer + bufsize += strlen(u->doc) + 1; // Url document name + bufsize += sizeof(dmTimeout); // Timeout + + *reqbuf = (char *) safe_malloc(bufsize); + + int i = 0; + + memcpy(*reqbuf, &(bufsize), sizeof(bufsize)); + i += sizeof(bufsize); + + reqbuf[i++] = op; + + memcpy(*reqbuf + i, u->scheme, sizeof(u->scheme)); + i += sizeof(u->scheme); + + memcpy(*reqbuf + i, u->user, sizeof(u->user)); + i += sizeof(u->user); + + memcpy(*reqbuf + i, u->pwd, sizeof(u->pwd)); + i += sizeof(u->pwd); + + memcpy(*reqbuf + i, u->host, sizeof(u->host)); + i += sizeof(u->host); + + memcpy(*reqbuf + i, &(u->offset), sizeof(u->offset)); + i += sizeof(u->offset); + + memcpy(*reqbuf + i, &(u->length), sizeof(u->length)); + i += sizeof(u->length); + + memcpy(*reqbuf + i, &(u->ims_time), sizeof(u->ims_time)); + i += sizeof(u->ims_time); + + memcpy(*reqbuf + i, &dmTimeout, sizeof(dmTimeout)); + i += sizeof(dmTimeout); + + char dmFlags = mk_dmflags(); + memcpy(*reqbuf + i, &dmFlags, sizeof(dmFlags)); + i += sizeof(dmFlags); + + strcpy(*reqbuf + i, u->doc); + //Assert i == bufsize - strlen(doc) - 1 + + return bufsize; +} + +static int +send_request(int sock, struct url *u) +{ + char *reqbuf; + int bufsize = mk_reqbuf(u, &reqbuf, 0); + int err = write(sock, reqbuf, bufsize); + if (err == -1) { + perror("send_request write():"); + } + + free(reqbuf); + return (err); +} + +static int +parse_rcvbuf(char *rcvbuf, int bufsize, struct dmres *dmres) +{ + return 0; +} + +static int +recv_response(int sock, struct dmres *dmres) +{ + int bufsize; + int kbytes = read(sock, &bufsize, sizeof(bufsize)); + if (kbytes == -1) { + perror("recv_response read():"); + } + + char *rcvbuf = (char *) safe_malloc(bufsize); + + kbytes = read(sock, &rcvbuf, bufsize); + + return (parse_rcvbuf(rcvbuf, bufsize, dmres)); +} + +FILE * +dmXGet(struct url *u, struct url_stat *us, const char *flags) +{ + int udsock = socket(AF_UNIX, SOCK_STREAM, 0); + struct sockaddr_un dms_addr; + dms_addr.sun_family = AF_UNIX; + strncpy(dms_addr.sun_path, DMS_UDS_PATH, sizeof(dms_addr.sun_path)); + + int err = connect(udsock, (struct sockaddr *) &dms_addr, sizeof(dms_addr)); + if (err == -1) { + if (err == ENOENT) { + /* The DMS server process doesn't exist so start one */ + } else { + perror("dmXGet connect():"); + /* There was some error trying to connect to dms */ + } + } + + err = send_request(udsock, u); + if (err == -1) { + perror("send_request :"); + } + + struct dmres dmres; + for (;;) { + err = recv_response(udsock, &dmres); + + if (err == -1){ + perror("dmXGet read():"); + dmLastErrCode = errno; + strcpy(dmLastErrString, strerror(errno)); + return (NULL); + } + + if (dmres.op == DM_COMPLETE) { + FILE *savedf = fopen(dmres.fname, "r"); + if (savedf == NULL) { + dmLastErrCode = errno; + strcpy(dmLastErrString, strerror(errno)); + } + return (savedf); + } else if (dmres.op == DM_AUTH_REQ) { + err = dmAuthMethod(u); + if (err == -1) { + /* do what libfetch does when auth fails */ + } + send_request(udsock, u); + continue; + } else { + /* Received error code in response */ + } + } + + return (NULL); +} + +int +dmStat(struct url *u, struct url_stat *us, const char *flags) +{ + us->size = -1; + us->mtime = 0; // Epoch + us->atime = us->mtime; + + return (-1); +} Added: soc2013/ambarisha/head/usr.bin/dmget/dmget.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/ambarisha/head/usr.bin/dmget/dmget.h Mon Jul 1 06:58:02 2013 (r253769) @@ -0,0 +1,42 @@ +#ifndef _DMCLIENT_H +#define _DMCLIENT_H + +#include +#include + +#include +#include + +/* TODO : Fix the path, make sure the perms on it are good */ +#define DMS_UDS_PATH "/tmp/dms.uds" + +#define DM_COMPLETE 1 +#define DM_AUTH_REQ 2 + + +struct dmres { + int op; + char fname[]; +}; + +#define DM_RESTART_CALLS 1 +#define DM_DEBUG 2 + +/* Authentication */ +extern auth_t dmAuthMethod; + +/* Last error code */ +extern int dmLastErrCode; +#define MAXERRSTRING 256 +extern char dmLastErrString[MAXERRSTRING]; + +/* I/O timeout */ +extern int dmTimeout; + +/* Restart interrupted syscalls */ +extern int dmRestartCalls; + +/* Extra verbosity */ +extern int dmDebug; + +#endif /* _DMCLIENT_H */ Added: soc2013/ambarisha/head/usr.bin/dmget/fetch.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/ambarisha/head/usr.bin/dmget/fetch.c Mon Jul 1 06:58:02 2013 (r253769) @@ -0,0 +1,1052 @@ +/*- + * Copyright (c) 2000-2011 Dag-Erling Smørgrav + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer + * in this position and unchanged. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "dmget.h" + +#define MINBUFSIZE 4096 +#define TIMEOUT 120 + +/* Option flags */ +static int A_flag; /* -A: do not follow 302 redirects */ +static int a_flag; /* -a: auto retry */ +static off_t B_size; /* -B: buffer size */ +static int b_flag; /*! -b: workaround TCP bug */ +static char *c_dirname; /* -c: remote directory */ +static int d_flag; /* -d: direct connection */ +static int F_flag; /* -F: restart without checking mtime */ +static char *f_filename; /* -f: file to fetch */ +static char *h_hostname; /* -h: host to fetch from */ +static int i_flag; /* -i: specify file for mtime comparison */ +static char *i_filename; /* name of input file */ +static int l_flag; /* -l: link rather than copy file: URLs */ +static int m_flag; /* -[Mm]: mirror mode */ +static char *N_filename; /* -N: netrc file name */ +static int n_flag; /* -n: do not preserve modification time */ +static int o_flag; /* -o: specify output file */ +static int o_directory; /* output file is a directory */ +static char *o_filename; /* name of output file */ +static int o_stdout; /* output file is stdout */ +static int once_flag; /* -1: stop at first successful file */ +static int p_flag; /* -[Pp]: use passive FTP */ +static int R_flag; /* -R: don't delete partial files */ +static int r_flag; /* -r: restart previous transfer */ +static off_t S_size; /* -S: require size to match */ +static int s_flag; /* -s: show size, don't fetch */ +static long T_secs; /* -T: transfer timeout in seconds */ +static int t_flag; /*! -t: workaround TCP bug */ +static int U_flag; /* -U: do not use high ports */ +static int v_level = 1; /* -v: verbosity level */ +static int v_tty; /* stdout is a tty */ +static pid_t pgrp; /* our process group */ +static long w_secs; /* -w: retry delay */ +static int family = PF_UNSPEC; /* -[46]: address family to use */ + +static int sigalrm; /* SIGALRM received */ +static int siginfo; /* SIGINFO received */ +static int sigint; /* SIGINT received */ + +static long ftp_timeout = TIMEOUT; /* default timeout for FTP transfers */ +static long http_timeout = TIMEOUT;/* default timeout for HTTP transfers */ +static char *buf; /* transfer buffer */ + + +/* + * Signal handler + */ +static void +sig_handler(int sig) +{ + switch (sig) { + case SIGALRM: + sigalrm = 1; + break; + case SIGINFO: + siginfo = 1; + break; + case SIGINT: + sigint = 1; + break; + } +} + +struct xferstat { + char name[64]; + struct timeval start; /* start of transfer */ + struct timeval last; /* time of last update */ + struct timeval last2; /* time of previous last update */ + off_t size; /* size of file per HTTP hdr */ + off_t offset; /* starting offset in file */ + off_t rcvd; /* bytes already received */ + off_t lastrcvd; /* bytes received since last update */ +}; + +/* + * Compute and display ETA + */ +static const char * +stat_eta(struct xferstat *xs) +{ + static char str[16]; + long elapsed, eta; + off_t received, expected; + + elapsed = xs->last.tv_sec - xs->start.tv_sec; + received = xs->rcvd - xs->offset; + expected = xs->size - xs->rcvd; + eta = (long)((double)elapsed * expected / received); + if (eta > 3600) + snprintf(str, sizeof str, "%02ldh%02ldm", + eta / 3600, (eta % 3600) / 60); + else if (eta > 0) + snprintf(str, sizeof str, "%02ldm%02lds", + eta / 60, eta % 60); + else + snprintf(str, sizeof str, "%02ldm%02lds", + elapsed / 60, elapsed % 60); + return (str); +} + +/* + * Format a number as "xxxx YB" where Y is ' ', 'k', 'M'... + */ +static const char *prefixes = " kMGTP"; +static const char * +stat_bytes(off_t bytes) +{ + static char str[16]; + const char *prefix = prefixes; + + while (bytes > 9999 && prefix[1] != '\0') { + bytes /= 1024; + prefix++; + } + snprintf(str, sizeof str, "%4jd %cB", (intmax_t)bytes, *prefix); + return (str); +} + +/* + * Compute and display transfer rate + */ +static const char * +stat_bps(struct xferstat *xs) +{ + static char str[16]; + double delta, bps; + + delta = (xs->last.tv_sec + (xs->last.tv_usec / 1.e6)) + - (xs->last2.tv_sec + (xs->last2.tv_usec / 1.e6)); + + if (delta == 0.0) { + snprintf(str, sizeof str, "?? Bps"); + } else { + bps = (xs->rcvd - xs->lastrcvd) / delta; + snprintf(str, sizeof str, "%sps", stat_bytes((off_t)bps)); + } + return (str); +} + +/* + * Update the stats display + */ +static void +stat_display(struct xferstat *xs, int force) +{ + struct timeval now; + int ctty_pgrp; + + /* check if we're the foreground process */ + if (ioctl(STDERR_FILENO, TIOCGPGRP, &ctty_pgrp) == -1 || + (pid_t)ctty_pgrp != pgrp) + return; + + gettimeofday(&now, NULL); + if (!force && now.tv_sec <= xs->last.tv_sec) + return; + xs->last2 = xs->last; + xs->last = now; + + fprintf(stderr, "\r%-46.46s", xs->name); + if (xs->size <= 0) { + setproctitle("%s [%s]", xs->name, stat_bytes(xs->rcvd)); + fprintf(stderr, " %s", stat_bytes(xs->rcvd)); + } else { + setproctitle("%s [%d%% of %s]", xs->name, + (int)((100.0 * xs->rcvd) / xs->size), + stat_bytes(xs->size)); + fprintf(stderr, "%3d%% of %s", + (int)((100.0 * xs->rcvd) / xs->size), + stat_bytes(xs->size)); + } + if (force == 2) { + xs->lastrcvd = xs->offset; + xs->last2 = xs->start; + } + fprintf(stderr, " %s", stat_bps(xs)); + if ((xs->size > 0 && xs->rcvd > 0 && + xs->last.tv_sec >= xs->start.tv_sec + 3) || + force == 2) + fprintf(stderr, " %s", stat_eta(xs)); + xs->lastrcvd = xs->rcvd; +} + +/* + * Initialize the transfer statistics + */ +static void +stat_start(struct xferstat *xs, const char *name, off_t size, off_t offset) +{ + snprintf(xs->name, sizeof xs->name, "%s", name); + gettimeofday(&xs->start, NULL); + xs->last.tv_sec = xs->last.tv_usec = 0; + xs->size = size; + xs->offset = offset; + xs->rcvd = offset; + xs->lastrcvd = offset; + if (v_tty && v_level > 0) + stat_display(xs, 1); + else if (v_level > 0) + fprintf(stderr, "%-46s", xs->name); +} + +/* + * Update the transfer statistics + */ +static void +stat_update(struct xferstat *xs, off_t rcvd) +{ + xs->rcvd = rcvd; + if (v_tty && v_level > 0) + stat_display(xs, 0); +} + +/* + * Finalize the transfer statistics + */ +static void +stat_end(struct xferstat *xs) +{ + gettimeofday(&xs->last, NULL); + if (v_tty && v_level > 0) { + stat_display(xs, 2); + putc('\n', stderr); + } else if (v_level > 0) { + fprintf(stderr, " %s %s\n", + stat_bytes(xs->size), stat_bps(xs)); + } +} + +/* + * Ask the user for authentication details + */ +static int +query_auth(struct url *URL) +{ + struct termios tios; + tcflag_t saved_flags; + int i, nopwd; + + fprintf(stderr, "Authentication required for <%s://%s:%d/>!\n", + URL->scheme, URL->host, URL->port); + + fprintf(stderr, "Login: "); + if (fgets(URL->user, sizeof URL->user, stdin) == NULL) + return (-1); + for (i = strlen(URL->user); i >= 0; --i) + if (URL->user[i] == '\r' || URL->user[i] == '\n') + URL->user[i] = '\0'; + + fprintf(stderr, "Password: "); + if (tcgetattr(STDIN_FILENO, &tios) == 0) { + saved_flags = tios.c_lflag; + tios.c_lflag &= ~ECHO; + tios.c_lflag |= ECHONL|ICANON; + tcsetattr(STDIN_FILENO, TCSAFLUSH|TCSASOFT, &tios); + nopwd = (fgets(URL->pwd, sizeof URL->pwd, stdin) == NULL); + tios.c_lflag = saved_flags; + tcsetattr(STDIN_FILENO, TCSANOW|TCSASOFT, &tios); + } else { + nopwd = (fgets(URL->pwd, sizeof URL->pwd, stdin) == NULL); + } + if (nopwd) + return (-1); + for (i = strlen(URL->pwd); i >= 0; --i) + if (URL->pwd[i] == '\r' || URL->pwd[i] == '\n') + URL->pwd[i] = '\0'; + + return (0); +} + +/* + * Fetch a file + */ +static int +fetch(char *URL, const char *path) +{ + struct url *url; + struct url_stat us; + struct stat sb, nsb; + struct xferstat xs; + FILE *f, *of; + size_t size, readcnt, wr; + off_t count; + char flags[8]; + const char *slash; + char *tmppath; + int r; + unsigned timeout; + char *ptr; + + f = of = NULL; + tmppath = NULL; + + timeout = 0; + *flags = 0; + count = 0; + + /* set verbosity level */ + if (v_level > 1) + strcat(flags, "v"); + if (v_level > 2) + dmDebug = 1; + + /* parse URL */ + url = NULL; + if (*URL == '\0') { + warnx("empty URL"); + goto failure; + } + if ((url = fetchParseURL(URL)) == NULL) { + warnx("%s: parse error", URL); + goto failure; + } + + /* if no scheme was specified, take a guess */ + if (!*url->scheme) { + if (!*url->host) + strcpy(url->scheme, SCHEME_FILE); + else if (strncasecmp(url->host, "ftp.", 4) == 0) + strcpy(url->scheme, SCHEME_FTP); + else if (strncasecmp(url->host, "www.", 4) == 0) + strcpy(url->scheme, SCHEME_HTTP); + } + + /* common flags */ + switch (family) { + case PF_INET: + strcat(flags, "4"); + break; + case PF_INET6: + strcat(flags, "6"); + break; + } + + /* FTP specific flags */ + if (strcmp(url->scheme, SCHEME_FTP) == 0) { + if (p_flag) + strcat(flags, "p"); + if (d_flag) + strcat(flags, "d"); + if (U_flag) + strcat(flags, "l"); + timeout = T_secs ? T_secs : ftp_timeout; + } + + /* HTTP specific flags */ + if (strcmp(url->scheme, SCHEME_HTTP) == 0 || + strcmp(url->scheme, SCHEME_HTTPS) == 0) { + if (d_flag) + strcat(flags, "d"); + if (A_flag) + strcat(flags, "A"); + timeout = T_secs ? T_secs : http_timeout; + if (i_flag) { + if (stat(i_filename, &sb)) { + warn("%s: stat()", i_filename); + goto failure; + } + url->ims_time = sb.st_mtime; + strcat(flags, "i"); + } + } + + /* set the protocol timeout. */ + dmTimeout = timeout; + + /* just print size */ + if (s_flag) { + if (timeout) + alarm(timeout); + r = dmStat(url, &us, flags); + if (timeout) + alarm(0); + if (sigalrm || sigint) + goto signal; + if (r == -1) { + warnx("%s", dmLastErrString); + goto failure; + } + if (us.size == -1) + printf("Unknown\n"); + else + printf("%jd\n", (intmax_t)us.size); + goto success; + } + + /* + * If the -r flag was specified, we have to compare the local + * and remote files, so we should really do a dmStat() + * first, but I know of at least one HTTP server that only + * sends the content size in response to GET requests, and + * leaves it out of replies to HEAD requests. Also, in the + * (frequent) case that the local and remote files match but + * the local file is truncated, we have sufficient information + * before the compare to issue a correct request. Therefore, + * we always issue a GET request as if we were sure the local + * file was a truncated copy of the remote file; we can drop + * the connection later if we change our minds. + */ + sb.st_size = -1; + if (!o_stdout) { + r = stat(path, &sb); + if (r == 0 && r_flag && S_ISREG(sb.st_mode)) { + url->offset = sb.st_size; + } else if (r == -1 || !S_ISREG(sb.st_mode)) { + /* + * Whatever value sb.st_size has now is either + * wrong (if stat(2) failed) or irrelevant (if the + * path does not refer to a regular file) + */ + sb.st_size = -1; + } + if (r == -1 && errno != ENOENT) { + warnx("%s: stat()", path); + goto failure; + } + } + + /* start the transfer */ + if (timeout) + alarm(timeout); + f = dmXGet(url, &us, flags); + if (timeout) + alarm(0); + if (sigalrm || sigint) + goto signal; + if (f == NULL) { + warnx("%s: %s", URL, dmLastErrString); + if (i_flag && strcmp(url->scheme, SCHEME_HTTP) == 0 + && dmLastErrCode == FETCH_OK + && strcmp(dmLastErrString, "Not Modified") == 0) { + /* HTTP Not Modified Response, return OK. */ + r = 0; + goto done; + } else + goto failure; + } + if (sigint) + goto signal; + + /* check that size is as expected */ + if (S_size) { + if (us.size == -1) { + warnx("%s: size unknown", URL); + } else if (us.size != S_size) { + warnx("%s: size mismatch: expected %jd, actual %jd", + URL, (intmax_t)S_size, (intmax_t)us.size); + goto failure; + } + } + + /* symlink instead of copy */ + if (l_flag && strcmp(url->scheme, "file") == 0 && !o_stdout) { + if (symlink(url->doc, path) == -1) { + warn("%s: symlink()", path); + goto failure; + } + goto success; + } + + if (us.size == -1 && !o_stdout && v_level > 0) + warnx("%s: size of remote file is not known", URL); + if (v_level > 1) { + if (sb.st_size != -1) + fprintf(stderr, "local size / mtime: %jd / %ld\n", + (intmax_t)sb.st_size, (long)sb.st_mtime); + if (us.size != -1) + fprintf(stderr, "remote size / mtime: %jd / %ld\n", + (intmax_t)us.size, (long)us.mtime); + } + + /* open output file */ + if (o_stdout) { + /* output to stdout */ + of = stdout; + } else if (r_flag && sb.st_size != -1) { + /* resume mode, local file exists */ + if (!F_flag && us.mtime && sb.st_mtime != us.mtime) { + /* no match! have to refetch */ + fclose(f); + /* if precious, warn the user and give up */ + if (R_flag) { + warnx("%s: local modification time " + "does not match remote", path); + goto failure_keep; + } + } else if (url->offset > sb.st_size) { + /* gap between what we asked for and what we got */ + warnx("%s: gap in resume mode", URL); + fclose(of); + of = NULL; + /* picked up again later */ + } else if (us.size != -1) { + if (us.size == sb.st_size) + /* nothing to do */ + goto success; + if (sb.st_size > us.size) { + /* local file too long! */ + warnx("%s: local file (%jd bytes) is longer " + "than remote file (%jd bytes)", path, + (intmax_t)sb.st_size, (intmax_t)us.size); + goto failure; + } + /* we got it, open local file */ + if ((of = fopen(path, "r+")) == NULL) { + warn("%s: fopen()", path); + goto failure; + } + /* check that it didn't move under our feet */ + if (fstat(fileno(of), &nsb) == -1) { + /* can't happen! */ + warn("%s: fstat()", path); + goto failure; + } + if (nsb.st_dev != sb.st_dev || + nsb.st_ino != nsb.st_ino || + nsb.st_size != sb.st_size) { + warnx("%s: file has changed", URL); + fclose(of); + of = NULL; + sb = nsb; + /* picked up again later */ + } + } + /* seek to where we left off */ + if (of != NULL && fseeko(of, url->offset, SEEK_SET) != 0) { + warn("%s: fseeko()", path); + fclose(of); + of = NULL; + /* picked up again later */ + } + } else if (m_flag && sb.st_size != -1) { + /* mirror mode, local file exists */ + if (sb.st_size == us.size && sb.st_mtime == us.mtime) + goto success; + } + + if (of == NULL) { + /* + * We don't yet have an output file; either this is a + * vanilla run with no special flags, or the local and + * remote files didn't match. + */ + + if (url->offset > 0) { + /* + * We tried to restart a transfer, but for + * some reason gave up - so we have to restart + * from scratch if we want the whole file + */ + url->offset = 0; + if ((f = dmXGet(url, &us, flags)) == NULL) { + warnx("%s: %s", URL, dmLastErrString); + goto failure; + } + if (sigint) + goto signal; + } + + /* construct a temp file name */ + if (sb.st_size != -1 && S_ISREG(sb.st_mode)) { + if ((slash = strrchr(path, '/')) == NULL) + slash = path; + else + ++slash; + asprintf(&tmppath, "%.*s.dm.XXXXXX.%s", + (int)(slash - path), path, slash); + if (tmppath != NULL) { + if (mkstemps(tmppath, strlen(slash) + 1) == -1) { + warn("%s: mkstemps()", path); + goto failure; + } + of = fopen(tmppath, "w"); + chown(tmppath, sb.st_uid, sb.st_gid); + chmod(tmppath, sb.st_mode & ALLPERMS); + } + } + if (of == NULL) + of = fopen(path, "w"); + if (of == NULL) { + warn("%s: open()", path); + goto failure; + } + } + count = url->offset; + + /* start the counter */ + stat_start(&xs, path, us.size, count); + + sigalrm = siginfo = sigint = 0; + + /* suck in the data */ + signal(SIGINFO, sig_handler); + while (!sigint) { + if (us.size != -1 && us.size - count < B_size && + us.size - count >= 0) + size = us.size - count; + else + size = B_size; + if (siginfo) { + stat_end(&xs); + siginfo = 0; + } + + if (size == 0) + break; + + if ((readcnt = fread(buf, 1, size, f)) < size) { + if (ferror(f) && errno == EINTR && !sigint) + clearerr(f); + else if (readcnt == 0) + break; + } + + stat_update(&xs, count += readcnt); + for (ptr = buf; readcnt > 0; ptr += wr, readcnt -= wr) + if ((wr = fwrite(ptr, 1, readcnt, of)) < readcnt) { + if (ferror(of) && errno == EINTR && !sigint) + clearerr(of); + else + break; + } + if (readcnt != 0) + break; + } + if (!sigalrm) + sigalrm = ferror(f) && errno == ETIMEDOUT; + signal(SIGINFO, SIG_DFL); + + stat_end(&xs); + + /* + * If the transfer timed out or was interrupted, we still want to + * set the mtime in case the file is not removed (-r or -R) and + * the user later restarts the transfer. + */ + signal: + /* set mtime of local file */ + if (!n_flag && us.mtime && !o_stdout && of != NULL && + (stat(path, &sb) != -1) && sb.st_mode & S_IFREG) { + struct timeval tv[2]; + + fflush(of); + tv[0].tv_sec = (long)(us.atime ? us.atime : us.mtime); + tv[1].tv_sec = (long)us.mtime; + tv[0].tv_usec = tv[1].tv_usec = 0; + if (utimes(tmppath ? tmppath : path, tv)) + warn("%s: utimes()", tmppath ? tmppath : path); + } + + /* timed out or interrupted? */ + if (sigalrm) + warnx("transfer timed out"); + if (sigint) { + warnx("transfer interrupted"); + goto failure; + } + + /* timeout / interrupt before connection completley established? */ + if (f == NULL) + goto failure; + + if (!sigalrm) { + /* check the status of our files */ + if (ferror(f)) + warn("%s", URL); + if (ferror(of)) + warn("%s", path); + if (ferror(f) || ferror(of)) + goto failure; + } + + /* did the transfer complete normally? */ + if (us.size != -1 && count < us.size) { + warnx("%s appears to be truncated: %jd/%jd bytes", + path, (intmax_t)count, (intmax_t)us.size); + goto failure_keep; + } + + /* *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-soc-all@FreeBSD.ORG Mon Jul 1 08:30:30 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 82EC4784 for ; Mon, 1 Jul 2013 08:30:30 +0000 (UTC) (envelope-from mattbw@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 66334173C for ; Mon, 1 Jul 2013 08:30:30 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r618UUpD073329 for ; Mon, 1 Jul 2013 08:30:30 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r618UUw2073212 for svn-soc-all@FreeBSD.org; Mon, 1 Jul 2013 08:30:30 GMT (envelope-from mattbw@FreeBSD.org) Date: Mon, 1 Jul 2013 08:30:30 GMT Message-Id: <201307010830.r618UUw2073212@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to mattbw@FreeBSD.org using -f From: mattbw@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r253779 - in soc2013/mattbw/backend: . actions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Jul 2013 08:30:30 -0000 Author: mattbw Date: Mon Jul 1 08:30:29 2013 New Revision: 253779 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=253779 Log: (broken) start making way for InstallPackages Added: soc2013/mattbw/backend/actions/install-packages.c Modified: soc2013/mattbw/backend/db.c soc2013/mattbw/backend/pk-backend-pkgng.c Added: soc2013/mattbw/backend/actions/install-packages.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/mattbw/backend/actions/install-packages.c Mon Jul 1 08:30:29 2013 (r253779) @@ -0,0 +1,81 @@ +/*- + * Copyright (C) 2013 Matt Windsor + * + * Licensed under the GNU General Public License Version 2 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include +#include "../pk-backend.h" +#include "pkg.h" + +#include "../db.h" /* db_query_from_id */ +#include "../groups.h" /* group_from_origin */ +#include "../iterate.h" /* Package iteration */ +#include "../licenses.h" /* license_from_pkg */ + +#include "get-details.h" /* get_details_thread prototype */ + +static void emit_pkg(struct pkg *pkg, const gchar *id, PkBackend *backend); +static gboolean get_for(const gchar *id, PkBackend *backend, struct pkgdb *db); + +/* + * The thread that performs an InstallPackages operation. Should be invoked by + * the pk_backend_install_packages hook. + */ +gboolean +install_packages_thread(PkBackend *backend) +{ + return iterate_ids(backend, get_for); +} + +/* + * Look up and attempt to install the given PackageID, if it can be found. + */ +static gboolean +get_for(const gchar *id, PkBackend *backend, struct pkgdb *db) +{ + struct pkg_jobs *jobs; + db_query_to_job(id, backend, db, LOAD_FLAGS, emit_pkg); +} + +/* + * Emits the given package's details. To be used as an iterating function. + */ +static void +emit_pkg(struct pkg *pkg, const gchar *id, PkBackend *backend) +{ + + const char *description; + const char *origin; + const char *www; + int64_t flatsize; + + /* Information not already part of the PackageID */ + pkg_get(pkg, + PKG_DESC, &description, + PKG_FLATSIZE, &flatsize, + PKG_ORIGIN, &origin, + PKG_WWW, &www); + + pk_backend_details(backend, + id, + license_name_from_pkg(pkg), + group_from_origin(origin), + description, + www, + flatsize); +} Modified: soc2013/mattbw/backend/db.c ============================================================================== --- soc2013/mattbw/backend/db.c Mon Jul 1 07:07:35 2013 (r253778) +++ soc2013/mattbw/backend/db.c Mon Jul 1 08:30:29 2013 (r253779) @@ -36,7 +36,16 @@ PkBackend *backend, struct pkgdb *db, int load_flags, - pkg_func_ptr emitter); + gchar **match_id_p, + struct pkg **match_pkg_p); +static gboolean +db_query_match(const gchar *id, + PkBackend *backend, + struct pkgdb *db, + int load_flags, + pkg_func_ptr emitter, + gchar **match_id_p, + struct pkg **match_pkg_p); /* * Opens a pkgdb ready for remote operations. This will always return TRUE if @@ -80,13 +89,9 @@ return success; } - - /* * Performs a package database query against a PackageID, and then hands the * matching results to an emitter function. - * - * The exact type of query depends on the repository given. */ gboolean db_query_with_id(const gchar *id, @@ -95,6 +100,76 @@ int load_flags, pkg_func_ptr emitter) { + gboolean success; + gchar *match_id; + struct pkg *match_pkg; + + success = db_query_match(id, + backend, + db, + load_flags, + &match_id, + &match_pkg); + if (success == TRUE && match_id != NULL && match_pkg != NULL) + emitter(pkg, match_id, backend); + + pkg_free(pkg); + g_free(match_id); +} + +/* + * Performs a package database query against a PackageID, and then adds the + * matching results to a pkg job. + * + * The round trip through the database seems like a strange idea given that + * pkg_jobs takes a package name. At the moment this is done to ensure that + * the package matches the PackageID fully. + */ +gboolean +db_query_to_job(const gchar *id, + PkBackend *backend, + struct pkgdb *db, + int load_flags, + struct pkg_jobs *jobs) +{ + gboolean success; + gchar *match_id; + struct pkg *match_pkg; + + success = db_query_match(id, + backend, + db, + load_flags, + &match_id, + &match_pkg); + if (success == TRUE && match_id != NULL && match_pkg != NULL) { + gchar *name[1]; + + name[0] = NULL; + pkg_get(PKG_NAME, &(name[0])); + + pkg_jobs_add(jobs, MATCH_EXACT, name, 1); + } + + pkg_free(pkg); + g_free(match_id); +} + +/* + * Performs a package database query against a (potentially partial) + * PackageID, retrieving the matched package and its full PackageID. + * + * The exact type of query depends on the repository given. + */ +static gboolean +db_query_match(const gchar *id, + PkBackend *backend, + struct pkgdb *db, + int load_flags, + pkg_func_ptr emitter, + gchar **match_id_p, + struct pkg **match_pkg_p) +{ gboolean query_success; gboolean split_success; const gchar *arch; @@ -132,10 +207,12 @@ backend, db, load_flags, - emitter); + match_id_p, + match_pkg_p); if (query_success == FALSE) query_success = db_query_split(name, version, arch, data, - backend, db, load_flags, emitter); + backend, db, load_flags, match_id_p, + match_pkg_p); /* * Assume any error is due to not finding packages. At time * of writing this is true, but may change. Modified: soc2013/mattbw/backend/pk-backend-pkgng.c ============================================================================== --- soc2013/mattbw/backend/pk-backend-pkgng.c Mon Jul 1 07:07:35 2013 (r253778) +++ soc2013/mattbw/backend/pk-backend-pkgng.c Mon Jul 1 08:30:29 2013 (r253779) @@ -1,5 +1,4 @@ /*- - * * Copyright (C) 2007-2010 Richard Hughes * 2013 Matt Windsor * @@ -33,7 +32,7 @@ #include "groups.h" /* available_groups */ #include "actions/get-files.h" /* get_files_thread */ #include "actions/get-details.h"/* get_details_thread */ -#include "actions/get-repo-list.h"/* get_repo_list_thread */ +#include "actions/get-repo-list.h" /* get_repo_list_thread */ #define INTENTIONALLY_IGNORE(x) (void)(x) @@ -121,38 +120,11 @@ return g_strdup("application/x-rpm;application/x-deb"); } -/** - * pk_backend_cancel_timeout: - */ -static gboolean -pk_backend_cancel_timeout(gpointer data) -{ - PkBackend *backend = (PkBackend *)data; - - /* we can now cancel again */ - _signal_timeout = 0; - - /* now mark as finished */ - pk_backend_error_code(backend, PK_ERROR_ENUM_TRANSACTION_CANCELLED, - "The task was stopped successfully"); - pk_backend_finished(backend); - return FALSE; -} - -/** - * pk_backend_cancel: +/* + * To implement: + * + * - pk_backend_cancel */ -void -pk_backend_cancel(PkBackend *backend) -{ - /* cancel the timeout */ - if (_signal_timeout != 0) { - g_source_remove(_signal_timeout); - - /* emulate that it takes us a few ms to cancel */ - g_timeout_add(1500, pk_backend_cancel_timeout, backend); - } -} /** * pk_backend_get_depends: @@ -177,8 +149,6 @@ pk_backend_finished(backend); } - - /* * Spawns a thread to get the details of the package IDs requested. The * thread code proper is in "get-details.c". @@ -432,74 +402,13 @@ void pk_backend_install_packages(PkBackend *backend, gboolean only_trusted, gchar **package_ids) { - const gchar *license_agreement; - const gchar *eula_id; - gboolean has_eula; + INTENTIONALLY_IGNORE(only_trusted); - /* FIXME: support only_trusted */ + pk_backend_set_status(backend, PK_STATUS_ENUM_QUERY); + pk_backend_set_percentage(backend, PK_BACKEND_PERCENTAGE_INVALID); - if (g_strcmp0(package_ids[0], "vips-doc;7.12.4-2.fc8;noarch;linva") == 0) { - if (_use_gpg && !_has_signature) { - pk_backend_repo_signature_required(backend, package_ids[0], "updates", - "http://example.com/gpgkey", - "Test Key (Fedora) fedora@example.com", - "BB7576AC", - "D8CC 06C2 77EC 9C53 372F C199 B1EE 1799 F24F 1B08", - "2007-10-04", PK_SIGTYPE_ENUM_GPG); - pk_backend_error_code(backend, PK_ERROR_ENUM_GPG_FAILURE, - "GPG signed package could not be verified"); - pk_backend_finished(backend); - return; - } - eula_id = "eula_hughsie_dot_com"; - has_eula = pk_backend_is_eula_valid(backend, eula_id); - if (_use_eula && !has_eula) { - license_agreement = "Narrator: In A.D. 2101, war was beginning.\n" - "Captain: What happen ?\n" - "Mechanic: Somebody set up us the bomb.\n\n" - "Operator: We get signal.\n" - "Captain: What !\n" - "Operator: Main screen turn on.\n" - "Captain: It's you !!\n" - "CATS: How are you gentlemen !!\n" - "CATS: All your base are belong to us.\n" - "CATS: You are on the way to destruction.\n\n" - "Captain: What you say !!\n" - "CATS: You have no chance to survive make your time.\n" - "CATS: Ha Ha Ha Ha ....\n\n" - "Operator: Captain!! *\n" - "Captain: Take off every 'ZIG' !!\n" - "Captain: You know what you doing.\n" - "Captain: Move 'ZIG'.\n" - "Captain: For great justice.\n"; - pk_backend_eula_required(backend, eula_id, package_ids[0], - "CATS Inc.", license_agreement); - pk_backend_error_code(backend, PK_ERROR_ENUM_NO_LICENSE_AGREEMENT, - "licence not installed so cannot install"); - pk_backend_finished(backend); - return; - } - if (_use_media) { - _use_media = FALSE; - pk_backend_media_change_required(backend, PK_MEDIA_TYPE_ENUM_DVD, "linux-disk-1of7", "Linux Disc 1 of 7"); - pk_backend_error_code(backend, PK_ERROR_ENUM_MEDIA_CHANGE_REQUIRED, - "additional media linux-disk-1of7 required"); - pk_backend_finished(backend); - return; - } - } - if (_use_trusted && only_trusted) { - pk_backend_error_code(backend, PK_ERROR_ENUM_CANNOT_INSTALL_REPO_UNSIGNED, - "Can't install as untrusted"); - pk_backend_finished(backend); - return; - } - pk_backend_set_allow_cancel(backend, TRUE); - _progress_percentage = 0; - pk_backend_package(backend, PK_INFO_ENUM_DOWNLOADING, - "gtkhtml2;2.19.1-4.fc8;i386;fedora", - "An HTML widget for GTK+ 2.0"); - _signal_timeout = g_timeout_add(100, pk_backend_install_timeout, backend); + pk_backend_thread_create(backend, get_repo_list_thread); + pk_backend_finished(backend); } /** @@ -841,8 +750,8 @@ pk_backend_message(backend, PK_MESSAGE_ENUM_BROKEN_MIRROR, "fedora-updates-testing-source metadata is invalid"); pk_backend_set_sub_percentage(backend, 100); pk_backend_package(backend, PK_INFO_ENUM_INSTALLING, - "gtkhtml2;2.19.1-4.fc8;i386;fedora", - "An HTML widget for GTK+ 2.0"); + "gtkhtml2;2.19.1-4.fc8;i386;fedora", + "An HTML widget for GTK+ 2.0"); _updated_gtkhtml = TRUE; pk_backend_set_sub_percentage(backend, 0); } @@ -973,8 +882,8 @@ pk_backend_message(backend, PK_MESSAGE_ENUM_BROKEN_MIRROR, "fedora-updates-testing-debuginfo metadata is invalid"); pk_backend_message(backend, PK_MESSAGE_ENUM_BROKEN_MIRROR, "fedora-updates-testing-source metadata is invalid"); pk_backend_package(backend, PK_INFO_ENUM_INSTALLING, - "gtkhtml2;2.19.1-4.fc8;i386;fedora", - "An HTML widget for GTK+ 2.0"); + "gtkhtml2;2.19.1-4.fc8;i386;fedora", + "An HTML widget for GTK+ 2.0"); _updated_gtkhtml = TRUE; } if (_progress_percentage == 40 && !_updated_powertop) { @@ -1160,9 +1069,7 @@ } /* - * Not supported: - * - pk_backend_repo_enable - * - pk_backend_repo_set_data + * Not supported: - pk_backend_repo_enable - pk_backend_repo_set_data */ /** From owner-svn-soc-all@FreeBSD.ORG Mon Jul 1 08:49:16 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 0B7193D0 for ; Mon, 1 Jul 2013 08:49:16 +0000 (UTC) (envelope-from mattbw@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id EFD0219A3 for ; Mon, 1 Jul 2013 08:49:15 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r618nFI0010202 for ; Mon, 1 Jul 2013 08:49:15 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r618nF1i010182 for svn-soc-all@FreeBSD.org; Mon, 1 Jul 2013 08:49:15 GMT (envelope-from mattbw@FreeBSD.org) Date: Mon, 1 Jul 2013 08:49:15 GMT Message-Id: <201307010849.r618nF1i010182@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to mattbw@FreeBSD.org using -f From: mattbw@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r253780 - in soc2013/mattbw/backend: . actions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Jul 2013 08:49:16 -0000 Author: mattbw Date: Mon Jul 1 08:49:15 2013 New Revision: 253780 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=253780 Log: (broken) consolidate action headers; add install-packages to makefile Added: soc2013/mattbw/backend/actions/actions.h Deleted: soc2013/mattbw/backend/actions/get-details.h soc2013/mattbw/backend/actions/get-files.h soc2013/mattbw/backend/actions/get-repo-list.h Modified: soc2013/mattbw/backend/Makefile soc2013/mattbw/backend/actions/get-details.c soc2013/mattbw/backend/actions/get-files.c soc2013/mattbw/backend/actions/get-repo-list.c soc2013/mattbw/backend/actions/install-packages.c soc2013/mattbw/backend/pk-backend-pkgng.c Modified: soc2013/mattbw/backend/Makefile ============================================================================== --- soc2013/mattbw/backend/Makefile Mon Jul 1 08:30:29 2013 (r253779) +++ soc2013/mattbw/backend/Makefile Mon Jul 1 08:49:15 2013 (r253780) @@ -3,7 +3,10 @@ LIB= pk_backend_pkgng SHLIB_MAJOR= 1 SRCS= pk-backend-pkgng.c groups.c db.c licenses.c iterate.c utils.c -SRCS+= actions/get-details.c actions/get-files.c actions/get-repo-list.c +SRCS+= actions/get-details.c \ + actions/get-files.c \ + actions/get-repo-list.c \ + actions/install-packages.c LIBDIR= /usr/local/lib/packagekit-backend Added: soc2013/mattbw/backend/actions/actions.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/mattbw/backend/actions/actions.h Mon Jul 1 08:49:15 2013 (r253780) @@ -0,0 +1,33 @@ +/*- + * Copyright (C) 2013 Matt Windsor + * + * Licensed under the GNU General Public License Version 2 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef _PKGNG_BACKEND_ACTIONS_H_ +#define _PKGNG_BACKEND_ACTIONS_H_ + +#include /* gboolean */ +#include "../pk-backend.h" /* PkBackend */ + +/* Each thread is implemented in its namesake C file. */ +gboolean get_details_thread(PkBackend *backend); +gboolean get_files_thread(PkBackend *backend); +gboolean get_repo_list_thread(PkBackend *backend); +gboolean install_packages_thread(PkBackend *backend); + +#endif /* !_PKGNG_BACKEND_ACTIONS_H_ */ Modified: soc2013/mattbw/backend/actions/get-details.c ============================================================================== --- soc2013/mattbw/backend/actions/get-details.c Mon Jul 1 08:30:29 2013 (r253779) +++ soc2013/mattbw/backend/actions/get-details.c Mon Jul 1 08:49:15 2013 (r253780) @@ -27,7 +27,7 @@ #include "../iterate.h" /* Package iteration */ #include "../licenses.h" /* license_from_pkg */ -#include "get-details.h" /* get_details_thread prototype */ +#include "actions.h" /* get_details_thread prototype */ static const int LOAD_FLAGS = PKG_LOAD_BASIC | PKG_LOAD_LICENSES; Modified: soc2013/mattbw/backend/actions/get-files.c ============================================================================== --- soc2013/mattbw/backend/actions/get-files.c Mon Jul 1 08:30:29 2013 (r253779) +++ soc2013/mattbw/backend/actions/get-files.c Mon Jul 1 08:49:15 2013 (r253780) @@ -28,7 +28,7 @@ #include "../iterate.h" /* Package iteration */ #include "../licenses.h" /* license_from_pkg */ -#include "get-files.h" /* get_files_thread prototype */ +#include "actions.h" /* get_files_thread prototype */ static const int FILE_NAME_STEP = 10; static const int LOAD_FLAGS = PKG_LOAD_BASIC | PKG_LOAD_FILES; Modified: soc2013/mattbw/backend/actions/get-repo-list.c ============================================================================== --- soc2013/mattbw/backend/actions/get-repo-list.c Mon Jul 1 08:30:29 2013 (r253779) +++ soc2013/mattbw/backend/actions/get-repo-list.c Mon Jul 1 08:49:15 2013 (r253780) @@ -23,7 +23,7 @@ #include "pkg.h" #include "../hash_traverse.h" /* HASH_FOR */ -#include "get-repo-list.h" /* Prototypes */ +#include "actions.h" /* get_repo_list_thread prototype */ /* * The thread that performs a GetRepoList operation. Should be invoked by the Modified: soc2013/mattbw/backend/actions/install-packages.c ============================================================================== --- soc2013/mattbw/backend/actions/install-packages.c Mon Jul 1 08:30:29 2013 (r253779) +++ soc2013/mattbw/backend/actions/install-packages.c Mon Jul 1 08:49:15 2013 (r253780) @@ -23,13 +23,10 @@ #include "pkg.h" #include "../db.h" /* db_query_from_id */ -#include "../groups.h" /* group_from_origin */ #include "../iterate.h" /* Package iteration */ -#include "../licenses.h" /* license_from_pkg */ -#include "get-details.h" /* get_details_thread prototype */ +#include "actions.h" /* install_packages_thread prototype */ -static void emit_pkg(struct pkg *pkg, const gchar *id, PkBackend *backend); static gboolean get_for(const gchar *id, PkBackend *backend, struct pkgdb *db); /* @@ -49,33 +46,19 @@ get_for(const gchar *id, PkBackend *backend, struct pkgdb *db) { struct pkg_jobs *jobs; - db_query_to_job(id, backend, db, LOAD_FLAGS, emit_pkg); -} + int err; -/* - * Emits the given package's details. To be used as an iterating function. - */ -static void -emit_pkg(struct pkg *pkg, const gchar *id, PkBackend *backend) -{ - - const char *description; - const char *origin; - const char *www; - int64_t flatsize; - - /* Information not already part of the PackageID */ - pkg_get(pkg, - PKG_DESC, &description, - PKG_FLATSIZE, &flatsize, - PKG_ORIGIN, &origin, - PKG_WWW, &www); - - pk_backend_details(backend, - id, - license_name_from_pkg(pkg), - group_from_origin(origin), - description, - www, - flatsize); + jobs = NULL; + err = pkg_jobs_new(&jobs, PKG_JOBS_INSTALL, db); + + if (err != E_OK) + pk_backend_error_code(backend, + PK_ERROR_ENUM_INTERNAL_ERROR, + "pkg_jobs_new failed"); + else + err = db_query_to_job(id, backend, db, LOAD_FLAGS, jobs); + + /* TODO: actually install */ + pk_backend_error_code(backend, PK_ERROR_ENUM_NOT_SUPPORTED, NULL); + return err; } Modified: soc2013/mattbw/backend/pk-backend-pkgng.c ============================================================================== --- soc2013/mattbw/backend/pk-backend-pkgng.c Mon Jul 1 08:30:29 2013 (r253779) +++ soc2013/mattbw/backend/pk-backend-pkgng.c Mon Jul 1 08:49:15 2013 (r253780) @@ -30,9 +30,7 @@ #include "pkg.h" #include "groups.h" /* available_groups */ -#include "actions/get-files.h" /* get_files_thread */ -#include "actions/get-details.h"/* get_details_thread */ -#include "actions/get-repo-list.h" /* get_repo_list_thread */ +#include "actions/actions.h" /* Actions threads */ #define INTENTIONALLY_IGNORE(x) (void)(x) @@ -407,7 +405,7 @@ pk_backend_set_status(backend, PK_STATUS_ENUM_QUERY); pk_backend_set_percentage(backend, PK_BACKEND_PERCENTAGE_INVALID); - pk_backend_thread_create(backend, get_repo_list_thread); + pk_backend_thread_create(backend, install_packages_thread); pk_backend_finished(backend); } From owner-svn-soc-all@FreeBSD.ORG Mon Jul 1 09:02:18 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 5CD6485C for ; Mon, 1 Jul 2013 09:02:18 +0000 (UTC) (envelope-from jmuniz@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 3FA571ACA for ; Mon, 1 Jul 2013 09:02:18 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6192Ita084408 for ; Mon, 1 Jul 2013 09:02:18 GMT (envelope-from jmuniz@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6192IdQ084398 for svn-soc-all@FreeBSD.org; Mon, 1 Jul 2013 09:02:18 GMT (envelope-from jmuniz@FreeBSD.org) Date: Mon, 1 Jul 2013 09:02:18 GMT Message-Id: <201307010902.r6192IdQ084398@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to jmuniz@FreeBSD.org using -f From: jmuniz@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r253788 - in soc2013/jmuniz: . PackageKit-Setter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Jul 2013 09:02:18 -0000 Author: jmuniz Date: Mon Jul 1 09:02:18 2013 New Revision: 253788 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=253788 Log: Fixed several issues with pk-setter, getting it to a stable point. Updated and moved task list from pk-setter to TODO. Modified: soc2013/jmuniz/PackageKit-Setter/pk-setter soc2013/jmuniz/TODO Modified: soc2013/jmuniz/PackageKit-Setter/pk-setter ============================================================================== --- soc2013/jmuniz/PackageKit-Setter/pk-setter Mon Jul 1 08:38:31 2013 (r253787) +++ soc2013/jmuniz/PackageKit-Setter/pk-setter Mon Jul 1 09:02:18 2013 (r253788) @@ -1,133 +1,141 @@ -#!/bin/sh -# -# Copyright (C) 2013 Justin Edward Muniz -# -# Licensed under the GNU General Public License Version 2 -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# Script to list and select from possible PackageKit backends - -# There are three arguments that can be provided to this script: -# Instruction: mandatory; can be either 'list' or 'set' -# Backend Name: mandatory for 'set'; a string that identifies for the set instruction -# Prefix: optional; if included, must be a valid prefix path to the PackageKit installation - -# ENTRY POINT OF SCRIPT -# Make sure there is an appropriate number of arguments -if [ $# -eq 1 -o $# -eq 2 -o $# -eq 3 ]; then - # Determine if there is a user provided prefix and save it for later - setPrefix - # Determine if the user wants a list of backends, if so print it - listBackends - # Determine if the user wants a backend change, and process it - setBackend -fi -# Let the user know how to use this script -printUsage -# Return to the shell with failure -exit 1 -# EXIT POINT OF SCRIPT - -# This function presents the user with a list of available backends -listBackends(){ - # Make sure that the user has requested a list of the available backends - if [ "$1" == "list" ]; then - # Create a string with each line representing the name of one backend - generateBackendList - # Print a header to describe the data to follow - echo "Available PackageKit backends:" - # Print the list of backends - echo "${PK_BACKENDS}" - # Return to the shell with success - exit 0 - fi -# End listBackends -} - -# This function uses the prefix and backend name to configure PackageKit to use the chosen backend -setBackend(){ - # Make sure that the user wants to select the backend - if [ "$1" == "set" ]; then - # Determine if the prefix contains the necessary configuration file - if [ ! -e "${PK_PREFIX}etc/PackageKit/PackageKit.conf" ]; then - # Let the user know that the path does not lead to the configuration file - echo "Error: could not find PackageKit.conf, check prefix" - # Return to the shell with failure - exit 1 - fi - # Run the algorithm to create a new-line delimited list of available backends - generateBackendList - # Test the backend value provided against the list of valid backend names - if [ ${PK_BACKENDS} != *$2* ]; then - # Let the user know that they made a mistake - echo "The backend provided was not found, please check your entry" - # Give advice to the user since they made a mistake, then return to the shell with failure - printUsage - fi - # Find the first instance of "DefaultBackend" and replace the line to reflect the new backend - sed -i 's/DefaultBackend=.*/DefaultBackend='$2 - # Let the user know that the changes were successful - echo "PackageKit is now using the $2 backend" - # Return to the shell with success - exit 0 - fi -# End setBackend -} - -# This function determines which argument is the prefix, if any, and sets the value of PK_PREFIX for later -setPrefix(){ - # Set PK_PREFIX to default (root) prefix - ${PK_PREFIX}="/" - # Determine if there are three arguments - if [ $# -eq 3 ]; then - # Set PK_PREFIX for later - ${PK_PREFIX}="$3" - # If there were two arguments given - elif [ $# -eq 2 ]; then - # There must be a prefix if the "list" instruction is given - if [ "$1" == "list" ]; then - # Set PK_PREFIX to the third argument for later - ${PK_PREFIX}="$2" - fi - fi - # Find out if the path given does not end with a slash - if [ ${PK_PREFIX} != */ ]; then - # Then add a slash to the end to make a proper prefix - ${PK_PREFIX} .= "${PK_PREFIX}/" - fi - # Determine if the provided prefix even exists and if it refers to a directory - if [ ! -e "${PK_PREFIX}" -o ! -d "${PK_PREFIX}" ]; then - # Inform the user that the prefix provided does not refer to an existing directory - echo "Error: $2 is not a valid directory." - # Return to shell with failure - exit 1 - fi -# End setPrefix -} - -# This function explains to the user how to use this script, then exits -printUsage(){ - # Print the instructions to the user in a easily readable way - echo "pk-setter is used to select the PackageKit backend" - echo "usage: pk-setter list [prefix]" - echo " pk-setter set [backend] [prefix]" - echo "note: prefix is optional and defaults to the root directory" - echo " and refers to the installation prefix of PackageKit" - # Returns to the shell with failure - exit 1 -# End printUsage -} - -# Create a list consisting of backend options, each on their own line -generateBackendList(){ - # Until a better way is figured out, a hardcoded set of options for backend selection are stored in PK_BACKENDS - ${PK_BACKENDS}="ports"$'\n'"pkgng"$'\n'"dummy (for debugging)" -# End generateBackendList -} - -# TODO: test validation and error handling in general -# TODO for generateBackendList: generate the list without hardcoding it -# TODO for setBackend: stop and start PackageKitd to load in the new backend +#!/bin/sh +# +# Copyright (C) 2013 Justin Edward Muniz +# +# Licensed under the GNU General Public License Version 2 +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# Function: List and select from possible PackageKit backends +# +# There are three arguments that can be provided to this script: +# Instruction: mandatory; can be either 'list' or 'set' +# Backend Name: mandatory for 'set' instruction; a string that identifies the backend to use +# Prefix: optional; if included, must be a valid prefix to the PackageKit installation path + +# Determine if the prefix being used is an accurate PackageKit installation prefix +verifyPrefix() { + # Make sure that the necessary configuration file exists given the prefix + if [ ! -e "${PK_PREFIX}etc/PackageKit/PackageKit.conf" ]; then + # Let the user know that the file was not found + echo "Could not find PackageKit.conf, please check your prefix" + # Advise user on usage + printUsage + fi +# End verifyPrefix +} + +# Store either a provided or default installation prefix for later operations +setPrefix() { + # Establish the default prefix + PK_PREFIX="/usr/local/" + # If there are three arguments, the last argument must be the prefix + if [ $# -eq 3 ]; then + # Assign the third argument to be the prefix + PK_PREFIX="$3" + # If there are two arguments and the instruction is "list" the last argument must be the prefix + elif [ $# -eq 2 -a "$1" == "list" ]; then + # Assign the second argument to be the prefix + PK_PREFIX="$2" + fi + # The prefix must end in a slash (/) in order to be well-formed, test to see if the slash is missing + # Evaluate the prefix to determine if it is well-formed + case "${PK_PREFIX}" in + # If the prefix ends with a slash + *"/") + # Do nothing, because the prefix appears to be well-formed + ;; + # For all other cases + *) + # Concatenate the slash onto the end of the prefix + PK_PREFIX="${PK_PREFIX}/" + ;; + esac + # Make sure that the prefix provided is correct + verifyPrefix +# End setPrefix +} + +# Create a list consisting of backend options, each occupying one line and surrounded by spaces +generateBackendList() { + # Until this is developed further, hardcode the option set + PK_BACKENDS=" ports "$'\n'" pkgng "$'\n'" dummy " +# End generateBackendList +} + +# Present the user with a list of available backends +listBackends() { + # Make sure that the user has requested the backend list + if [ "$1" == "list" ]; then + # Generate a list of backends, demarcated by newlines + generateBackendList + # Print a header to describe the following data + echo "Available PackageKit backends:" + # Print the list of backends + echo "${PK_BACKENDS}" + fi +# End listBackends +} + +# Configure PackageKit to use the chosen backend +setBackend() { + # Make sure that the user wants to select the backend + if [ "$1" == "set" ]; then + # Generate the new-line demarcated list of backends + generateBackendList + # Determine if the backend provided is valid, each option is surrounded by spaces + case "${PK_BACKENDS}" in + # If the proved backend is valid + *" $2 "*) + # Find the first instance of "DefaultBackend" in the configuration file and edit it + sed "s/DefaultBackend=.*/DefaultBackend=$2/" ${PK_PREFIX}etc/PackageKit/PackageKit.conf > ${PK_PREFIX}etc/PackageKit/PackageKit.conf + # Inform the user of success + echo "PackageKit is now using the $2 backend" + ;; + # The default case is true if the provided backend name is not on the list of available backends + *) + # Notify the user of their mistake + echo "The backend provided was not found, please check your entry" + # Share usage advice with the user + printUsage + ;; + esac + fi +# End setBackend +} + +# Explain to the user how to use this script, then exit +printUsage() { + # Print the instructions to the user in an easily readable way + echo "pk-setter is used to select the PackageKit backend" + echo "usage: pk-setter list [prefix]" + echo " pk-setter set [backend] [prefix]" + echo "note: prefix is optional and defaults to \"/usr/local/\"," + echo " and refers to the installation prefix of PackageKit" + # Returns to the shell with error code + exit 1 +# End printUsage +} + +# Beginning of execution + +# Make sure there is an appropriate number of arguments +if [ $# -eq 1 -o $# -eq 2 -o $# -eq 3 ]; then + if [ "$1" == "list" -o "$1" == "set" ]; then + # Determine if there is a user defined prefix, save the prefix for later + setPrefix $* + # If the user wants a list of backends then print it + listBackends $* + # Change the current backend if the user wants to + setBackend $* + # Return to the shell with success + exit 0 + fi +fi +# Let the user know how to use this script +printUsage + +# End of execution + Modified: soc2013/jmuniz/TODO ============================================================================== --- soc2013/jmuniz/TODO Mon Jul 1 08:38:31 2013 (r253787) +++ soc2013/jmuniz/TODO Mon Jul 1 09:02:18 2013 (r253788) @@ -0,0 +1,12 @@ +Task list for this repository +----------------------------- + +pk-setter: +- when setting the backend, close packagekitd before, sync(8) and start packagekitd after +- generate backend list without hardcoding it +- make sure file permissions are correct +- move a copy of the license agreement to this directory +- determine if the BSD license can be used this intimately with GPLv2 +- verify that packagekitd starts with new configuration, or roll back to last known good configuration +- create a new port to share this script + From owner-svn-soc-all@FreeBSD.ORG Mon Jul 1 09:53:06 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 99F36659 for ; Mon, 1 Jul 2013 09:53:06 +0000 (UTC) (envelope-from mattbw@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 7D2061DA9 for ; Mon, 1 Jul 2013 09:53:06 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r619r68G077361 for ; Mon, 1 Jul 2013 09:53:06 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r619r6fE077346 for svn-soc-all@FreeBSD.org; Mon, 1 Jul 2013 09:53:06 GMT (envelope-from mattbw@FreeBSD.org) Date: Mon, 1 Jul 2013 09:53:06 GMT Message-Id: <201307010953.r619r6fE077346@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to mattbw@FreeBSD.org using -f From: mattbw@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r253789 - in soc2013/mattbw/backend: . actions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Jul 2013 09:53:06 -0000 Author: mattbw Date: Mon Jul 1 09:53:06 2013 New Revision: 253789 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=253789 Log: (fixed build, untested) finished rehashing the iterator logic ready for supporting jobs, next step is to merge query relaed code into one file Modified: soc2013/mattbw/backend/actions/install-packages.c soc2013/mattbw/backend/db.c soc2013/mattbw/backend/db.h soc2013/mattbw/backend/iterate.c soc2013/mattbw/backend/iterate.h Modified: soc2013/mattbw/backend/actions/install-packages.c ============================================================================== --- soc2013/mattbw/backend/actions/install-packages.c Mon Jul 1 09:02:18 2013 (r253788) +++ soc2013/mattbw/backend/actions/install-packages.c Mon Jul 1 09:53:06 2013 (r253789) @@ -51,12 +51,12 @@ jobs = NULL; err = pkg_jobs_new(&jobs, PKG_JOBS_INSTALL, db); - if (err != E_OK) + if (err != EPKG_OK) pk_backend_error_code(backend, PK_ERROR_ENUM_INTERNAL_ERROR, "pkg_jobs_new failed"); else - err = db_query_to_job(id, backend, db, LOAD_FLAGS, jobs); + err = db_query_to_job(id, backend, db, jobs); /* TODO: actually install */ pk_backend_error_code(backend, PK_ERROR_ENUM_NOT_SUPPORTED, NULL); Modified: soc2013/mattbw/backend/db.c ============================================================================== --- soc2013/mattbw/backend/db.c Mon Jul 1 09:02:18 2013 (r253788) +++ soc2013/mattbw/backend/db.c Mon Jul 1 09:53:06 2013 (r253789) @@ -43,7 +43,6 @@ PkBackend *backend, struct pkgdb *db, int load_flags, - pkg_func_ptr emitter, gchar **match_id_p, struct pkg **match_pkg_p); @@ -111,25 +110,28 @@ &match_id, &match_pkg); if (success == TRUE && match_id != NULL && match_pkg != NULL) - emitter(pkg, match_id, backend); + emitter(match_pkg, match_id, backend); - pkg_free(pkg); + pkg_free(match_pkg); g_free(match_id); + + return success; } /* * Performs a package database query against a PackageID, and then adds the * matching results to a pkg job. - * + * * The round trip through the database seems like a strange idea given that * pkg_jobs takes a package name. At the moment this is done to ensure that * the package matches the PackageID fully. + * + * TODO: do something about the redundancy in both this and the emitter variant. */ gboolean db_query_to_job(const gchar *id, PkBackend *backend, struct pkgdb *db, - int load_flags, struct pkg_jobs *jobs) { gboolean success; @@ -139,20 +141,21 @@ success = db_query_match(id, backend, db, - load_flags, + PKG_LOAD_BASIC, &match_id, &match_pkg); if (success == TRUE && match_id != NULL && match_pkg != NULL) { - gchar *name[1]; + gchar *name[1]; name[0] = NULL; - pkg_get(PKG_NAME, &(name[0])); - + pkg_get(match_pkg, PKG_NAME, &(name[0])); + pkg_jobs_add(jobs, MATCH_EXACT, name, 1); } - - pkg_free(pkg); + pkg_free(match_pkg); g_free(match_id); + + return success; } /* @@ -166,7 +169,6 @@ PkBackend *backend, struct pkgdb *db, int load_flags, - pkg_func_ptr emitter, gchar **match_id_p, struct pkg **match_pkg_p) { @@ -243,7 +245,8 @@ PkBackend *backend, struct pkgdb *db, int load_flags, - pkg_func_ptr emitter) + gchar **match_id_p, + struct pkg **match_pkg_p) { struct pkgdb_it *it; gboolean success; @@ -267,13 +270,14 @@ if (it != NULL) - success = iterate_id_matches(it, - backend, - name, - version, - arch, - reponame, - load_flags, - emitter); + success = match_id_in_it(it, + backend, + name, + version, + arch, + reponame, + load_flags, + match_id_p, + match_pkg_p); return success; } Modified: soc2013/mattbw/backend/db.h ============================================================================== --- soc2013/mattbw/backend/db.h Mon Jul 1 09:02:18 2013 (r253788) +++ soc2013/mattbw/backend/db.h Mon Jul 1 09:53:06 2013 (r253789) @@ -35,5 +35,10 @@ struct pkgdb *db, int load_flags, pkg_func_ptr emitter); +gboolean +db_query_to_job(const gchar *id, + PkBackend *backend, + struct pkgdb *db, + struct pkg_jobs *jobs); #endif /* !_PKGNG_BACKEND_DETAILS_H_ */ Modified: soc2013/mattbw/backend/iterate.c ============================================================================== --- soc2013/mattbw/backend/iterate.c Mon Jul 1 09:02:18 2013 (r253788) +++ soc2013/mattbw/backend/iterate.c Mon Jul 1 09:53:06 2013 (r253789) @@ -37,52 +37,48 @@ gboolean -iterate_id_matches(struct pkgdb_it *iterator, - PkBackend *backend, - const char *name, - const char *version, - const char *arch, - const char *data, - int fetch_flags, - pkg_func_ptr iterate_f) +match_id_in_it(struct pkgdb_it *iterator, + PkBackend *backend, + const char *name, + const char *version, + const char *arch, + const char *data, + int load_flags, + gchar **match_id_p, + struct pkg **match_pkg_p) { /* TODO: Filters */ gboolean found; int err; - struct pkg *pkg; - gchar *match_id; found = FALSE; - pkg = NULL; - match_id = NULL; + *match_pkg_p = NULL; + *match_id_p = NULL; /* * Stop pkg from catching fire if we try to load files from * non-installed packages. */ - if ((fetch_flags & PKG_LOAD_FILES) && g_strcmp0(data, - "installed") != 0) { + if ((load_flags & PKG_LOAD_FILES) && g_strcmp0(data, + "installed") != 0) { pk_backend_error_code(backend, PK_ERROR_ENUM_CANNOT_GET_FILELIST, "Cannot get files for non-installed package." ); err = EPKG_FATAL; } else { - for (HASH_FOR(err, pkgdb_it_next, iterator, &pkg, fetch_flags)) { - if (try_id_match(pkg, + for (HASH_FOR(err, pkgdb_it_next, iterator, match_pkg_p, load_flags)) { + if (try_id_match(*match_pkg_p, name, version, arch, data, - &match_id) == TRUE) { + match_id_p) == TRUE) { found = TRUE; - iterate_f(pkg, match_id, backend); + break; } - if (match_id != NULL) - g_free(match_id); } } - pkg_free(pkg); return found; } Modified: soc2013/mattbw/backend/iterate.h ============================================================================== --- soc2013/mattbw/backend/iterate.h Mon Jul 1 09:02:18 2013 (r253788) +++ soc2013/mattbw/backend/iterate.h Mon Jul 1 09:53:06 2013 (r253789) @@ -31,14 +31,15 @@ typedef gboolean (*ids_func_ptr) (const gchar *id, PkBackend *backend, struct pkgdb *db); gboolean -iterate_id_matches(struct pkgdb_it *iterator, - PkBackend *backend, - const gchar *name, - const gchar *version, - const gchar *arch, - const gchar *data, - int fetch_flags, - pkg_func_ptr iterate_f); +match_id_in_it(struct pkgdb_it *iterator, + PkBackend *backend, + const gchar *name, + const gchar *version, + const gchar *arch, + const gchar *data, + int load_flags, + gchar **match_id_p, + struct pkg **match_pkg_p); gboolean iterate_ids(PkBackend *backend, ids_func_ptr iterate_f); #endif /* !_PKGNG_BACKEND_ITERATE_H_ */ From owner-svn-soc-all@FreeBSD.ORG Mon Jul 1 10:08:38 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 23A33BA4 for ; Mon, 1 Jul 2013 10:08:38 +0000 (UTC) (envelope-from jmuniz@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id F02631E56 for ; Mon, 1 Jul 2013 10:08:37 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r61A8b45020531 for ; Mon, 1 Jul 2013 10:08:37 GMT (envelope-from jmuniz@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r61A8bIR020523 for svn-soc-all@FreeBSD.org; Mon, 1 Jul 2013 10:08:37 GMT (envelope-from jmuniz@FreeBSD.org) Date: Mon, 1 Jul 2013 10:08:37 GMT Message-Id: <201307011008.r61A8bIR020523@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to jmuniz@FreeBSD.org using -f From: jmuniz@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r253790 - in soc2013/jmuniz: . PackageKit-Setter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Jul 2013 10:08:38 -0000 Author: jmuniz Date: Mon Jul 1 10:08:37 2013 New Revision: 253790 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=253790 Log: pk-setter now restarts the daemon. Updated TODO. Modified: soc2013/jmuniz/PackageKit-Setter/pk-setter soc2013/jmuniz/TODO Modified: soc2013/jmuniz/PackageKit-Setter/pk-setter ============================================================================== --- soc2013/jmuniz/PackageKit-Setter/pk-setter Mon Jul 1 09:53:06 2013 (r253789) +++ soc2013/jmuniz/PackageKit-Setter/pk-setter Mon Jul 1 10:08:37 2013 (r253790) @@ -87,10 +87,16 @@ generateBackendList # Determine if the backend provided is valid, each option is surrounded by spaces case "${PK_BACKENDS}" in - # If the proved backend is valid + # If the provided backend is valid *" $2 "*) + # Ask PackageKit to quietly close as soon as it can + gdbus call --system --dest org.freedestop.PackageKit --object-path /org/freedestop/PackageKit --method org.freedestop.PackageKit.SuggestDaemonQuit >/dev/null # Find the first instance of "DefaultBackend" in the configuration file and edit it sed "s/DefaultBackend=.*/DefaultBackend=$2/" ${PK_PREFIX}etc/PackageKit/PackageKit.conf > ${PK_PREFIX}etc/PackageKit/PackageKit.conf + # Sync the disks to make sure the configuration file is updated + sync + # Silently start PackageKit + pkcon >/dev/null # Inform the user of success echo "PackageKit is now using the $2 backend" ;; Modified: soc2013/jmuniz/TODO ============================================================================== --- soc2013/jmuniz/TODO Mon Jul 1 09:53:06 2013 (r253789) +++ soc2013/jmuniz/TODO Mon Jul 1 10:08:37 2013 (r253790) @@ -2,11 +2,10 @@ ----------------------------- pk-setter: -- when setting the backend, close packagekitd before, sync(8) and start packagekitd after - generate backend list without hardcoding it -- make sure file permissions are correct -- move a copy of the license agreement to this directory - determine if the BSD license can be used this intimately with GPLv2 - verify that packagekitd starts with new configuration, or roll back to last known good configuration - create a new port to share this script +- determine if 'pkcon refresh' is needed when changing backends, it doesn't seem to want to work in 0.6.11 +- make script more robust in the face of missing dependencies From owner-svn-soc-all@FreeBSD.ORG Mon Jul 1 15:12:06 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 2AE65D44 for ; Mon, 1 Jul 2013 15:12:06 +0000 (UTC) (envelope-from dpl@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 0B9A21021 for ; Mon, 1 Jul 2013 15:12:06 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r61FC5Cg030634 for ; Mon, 1 Jul 2013 15:12:05 GMT (envelope-from dpl@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r61FC5Fv030624 for svn-soc-all@FreeBSD.org; Mon, 1 Jul 2013 15:12:05 GMT (envelope-from dpl@FreeBSD.org) Date: Mon, 1 Jul 2013 15:12:05 GMT Message-Id: <201307011512.r61FC5Fv030624@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to dpl@FreeBSD.org using -f From: dpl@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r253794 - soc2013/dpl/head/contrib/bzip2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Jul 2013 15:12:06 -0000 Author: dpl Date: Mon Jul 1 15:12:05 2013 New Revision: 253794 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=253794 Log: Modified: soc2013/dpl/head/contrib/bzip2/bzip2.c Modified: soc2013/dpl/head/contrib/bzip2/bzip2.c ============================================================================== --- soc2013/dpl/head/contrib/bzip2/bzip2.c Mon Jul 1 14:49:23 2013 (r253793) +++ soc2013/dpl/head/contrib/bzip2/bzip2.c Mon Jul 1 15:12:05 2013 (r253794) @@ -240,7 +240,7 @@ io[0].iov_base = buf; io[0].iov_len = 1; - msg.msg_name = 0; + msg.msg_name = NULL; msg.msg_namelen = 0; msg.msg_iov = io; msg.msg_iovlen = 1; @@ -252,7 +252,6 @@ cmsg.cmsg_type = SCM_RIGHTS; *(int *)CMSG_DATA(&cmsg) = fd; printf("sendmsg(%d, %p, 0)\n",s, &msg); - /* Bad address in args */ if( (ret = sendmsg(s, &msg, 0)) <= 0){ printf("sendmsg() returned: %d\n", ret); return -1; @@ -1402,7 +1401,7 @@ exit(exitValue); case ( 0 ): - if ((close(sv[0])) < 0){ + if ((close(sv[1])) < 0){ fprintf ( stderr, "%s: Couldn't close socket: %s.\n", progName, strerror(errno) ); setExit(1); @@ -1410,14 +1409,14 @@ } printf("About to recv infd\n"); sleep(1); - if ((infd = recvfd(sv[1])) < 0){ + if ((infd = recvfd(sv[0])) < 0){ fprintf ( stderr, "%s: Couldn't get infd: %s.\n", progName, strerror(errno) ); setExit(1); exit(exitValue); } printf("About to recv outfd\n"); - if ((outfd = recvfd(sv[1])) < 0){ + if ((outfd = recvfd(sv[0])) < 0){ fprintf ( stderr, "%s: Couldn't get outfd: %s.\n", progName, strerror(errno) ); setExit(1); @@ -1459,14 +1458,14 @@ default: printf("Parent: infd:%d, outfd:%d\n", infd, outfd); printf("Child's pid: %d\n", forkpid); - if ((close(sv[1])) < 0){ + if ((close(sv[0])) < 0){ fprintf ( stderr, "%s: Couldn't close fd: %s.\n", progName, strerror(errno) ); wait(NULL); setExit(1); exit(exitValue); } - if (sendfd(sv[0], infd) < 0){ + if (sendfd(sv[1], infd) < 0){ fprintf ( stderr, "%s: Couldn't send infd: %s.\n", progName, strerror(errno) ); if (signal(forkpid, SIGTERM) < 0) @@ -1474,16 +1473,16 @@ wait(NULL); setExit(1); exit(exitValue); - } - if (sendfd(sv[0], outfd) < 0){ + } + if (sendfd(sv[1], outfd) < 0){ fprintf ( stderr, "%s: Couldn't send outfd: %s.\n", progName, strerror(errno) ); wait(NULL); setExit(1); exit(exitValue); - } - wait(NULL); - return; + } + wait(NULL); + return; } # endif } @@ -2136,8 +2135,7 @@ # endif } -# if CAPSICUM - +# if CAPSICUM if ( socketpair(PF_LOCAL, SOCK_STREAM, 0, sv) < 0 ){ fprintf (stderr, "%s: Can't create socket: %s.\n", progName, strerror(errno) ); @@ -2145,7 +2143,6 @@ exit(exitValue); } printf("socketpair(): sv[0]:%d sv[1]:%d\n", sv[0], sv[1]); - # endif if (opMode == OM_Z) { From owner-svn-soc-all@FreeBSD.ORG Mon Jul 1 16:22:46 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 0E025BD7 for ; Mon, 1 Jul 2013 16:22:46 +0000 (UTC) (envelope-from dpl@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id D9D80133F for ; Mon, 1 Jul 2013 16:22:45 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r61GMjKP079159 for ; Mon, 1 Jul 2013 16:22:45 GMT (envelope-from dpl@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r61GMjUJ079152 for svn-soc-all@FreeBSD.org; Mon, 1 Jul 2013 16:22:45 GMT (envelope-from dpl@FreeBSD.org) Date: Mon, 1 Jul 2013 16:22:45 GMT Message-Id: <201307011622.r61GMjUJ079152@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to dpl@FreeBSD.org using -f From: dpl@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r253795 - soc2013/dpl/head/contrib/bzip2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Jul 2013 16:22:46 -0000 Author: dpl Date: Mon Jul 1 16:22:45 2013 New Revision: 253795 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=253795 Log: Changed sendfd to use malloc(). Still not working tough. Modified: soc2013/dpl/head/contrib/bzip2/bzip2.c Modified: soc2013/dpl/head/contrib/bzip2/bzip2.c ============================================================================== --- soc2013/dpl/head/contrib/bzip2/bzip2.c Mon Jul 1 15:12:05 2013 (r253794) +++ soc2013/dpl/head/contrib/bzip2/bzip2.c Mon Jul 1 16:22:45 2013 (r253795) @@ -228,11 +228,13 @@ int sendfd(int, int); int recvfd(int); +#define DATALEN CMSG_LEN(sizeof(int)) + int sendfd(int s, int fd) { struct msghdr msg; - struct cmsghdr cmsg; + struct cmsghdr *cmsg; struct iovec io[1]; char buf = { "!" }; int ret; @@ -240,22 +242,25 @@ io[0].iov_base = buf; io[0].iov_len = 1; + if( (cmsg = malloc(DATALEN) ) == NULL ) + return -1; + msg.msg_name = NULL; msg.msg_namelen = 0; msg.msg_iov = io; msg.msg_iovlen = 1; - msg.msg_control = &cmsg; - msg.msg_controllen = CMSG_LEN(sizeof(int)); + msg.msg_control =cmsg; + msg.msg_controllen = DATALEN; - cmsg.cmsg_len = msg.msg_controllen; - cmsg.cmsg_level = SOL_SOCKET; - cmsg.cmsg_type = SCM_RIGHTS; - *(int *)CMSG_DATA(&cmsg) = fd; - printf("sendmsg(%d, %p, 0)\n",s, &msg); + cmsg->cmsg_len = DATALEN; + cmsg->cmsg_level = SOL_SOCKET; + cmsg->cmsg_type = SCM_RIGHTS; + *(int *)CMSG_DATA(cmsg) = fd; if( (ret = sendmsg(s, &msg, 0)) <= 0){ - printf("sendmsg() returned: %d\n", ret); + printf("sendmsg() returned: %d (%s)\n", ret, strerror(errno)); return -1; } + free(cmsg); return 0; } @@ -276,9 +281,9 @@ msg.msg_iov = io; msg.msg_iovlen = 1; msg.msg_control = &cmsg; - msg.msg_controllen = CMSG_LEN(sizeof(int)); + msg.msg_controllen = DATALEN; - cmsg.cmsg_len = msg.msg_controllen; + cmsg.cmsg_len = DATALEN; cmsg.cmsg_level = SOL_SOCKET; cmsg.cmsg_type = SCM_RIGHTS; /*Why does sendmsg set errno to 9 EBADF??*/ From owner-svn-soc-all@FreeBSD.ORG Mon Jul 1 19:43:20 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id E28CE6F9 for ; Mon, 1 Jul 2013 19:43:20 +0000 (UTC) (envelope-from dpl@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id D45141DE9 for ; Mon, 1 Jul 2013 19:43:20 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r61JhKKq028019 for ; Mon, 1 Jul 2013 19:43:20 GMT (envelope-from dpl@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r61JhKD3028016 for svn-soc-all@FreeBSD.org; Mon, 1 Jul 2013 19:43:20 GMT (envelope-from dpl@FreeBSD.org) Date: Mon, 1 Jul 2013 19:43:20 GMT Message-Id: <201307011943.r61JhKD3028016@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to dpl@FreeBSD.org using -f From: dpl@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r253802 - in soc2013/dpl/head: contrib/bzip2 usr.bin/bzip2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Jul 2013 19:43:20 -0000 Author: dpl Date: Mon Jul 1 19:43:20 2013 New Revision: 253802 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=253802 Log: Cleant some warnings. Modified: soc2013/dpl/head/contrib/bzip2/bzip2.c soc2013/dpl/head/usr.bin/bzip2/Makefile Modified: soc2013/dpl/head/contrib/bzip2/bzip2.c ============================================================================== --- soc2013/dpl/head/contrib/bzip2/bzip2.c Mon Jul 1 18:58:59 2013 (r253801) +++ soc2013/dpl/head/contrib/bzip2/bzip2.c Mon Jul 1 19:43:20 2013 (r253802) @@ -236,7 +236,7 @@ struct msghdr msg; struct cmsghdr *cmsg; struct iovec io[1]; - char buf = { "!" }; + char buf[1] = { "!" }; int ret; io[0].iov_base = buf; @@ -270,7 +270,7 @@ int fd; struct msghdr msg; struct cmsghdr cmsg; - char buf = { "!" }; + char buf[1] = { "!" }; struct iovec io[1]; io[0].iov_base = buf; @@ -1473,7 +1473,7 @@ if (sendfd(sv[1], infd) < 0){ fprintf ( stderr, "%s: Couldn't send infd: %s.\n", progName, strerror(errno) ); - if (signal(forkpid, SIGTERM) < 0) + if (kill(forkpid, SIGTERM) < 0) printf("Couldn't kill the child process, please press ^C\n"); wait(NULL); setExit(1); Modified: soc2013/dpl/head/usr.bin/bzip2/Makefile ============================================================================== --- soc2013/dpl/head/usr.bin/bzip2/Makefile Mon Jul 1 18:58:59 2013 (r253801) +++ soc2013/dpl/head/usr.bin/bzip2/Makefile Mon Jul 1 19:43:20 2013 (r253802) @@ -7,8 +7,7 @@ CFLAGS+= -D_FILE_OFFSET_BITS=64 #TODO: Delete this. CFLAGS+= -fno-color-diagnostics -CFLAGS+= -Wall -CFLAGS+= -g +CFLAGS+= -Wall -Werror -g WARNS?= 3 From owner-svn-soc-all@FreeBSD.ORG Mon Jul 1 22:13:01 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id E5717D66 for ; Mon, 1 Jul 2013 22:13:01 +0000 (UTC) (envelope-from mattbw@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id D65C4166E for ; Mon, 1 Jul 2013 22:13:01 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r61MD1IP098159 for ; Mon, 1 Jul 2013 22:13:01 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r61MD1Nj098150 for svn-soc-all@FreeBSD.org; Mon, 1 Jul 2013 22:13:01 GMT (envelope-from mattbw@FreeBSD.org) Date: Mon, 1 Jul 2013 22:13:01 GMT Message-Id: <201307012213.r61MD1Nj098150@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to mattbw@FreeBSD.org using -f From: mattbw@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r253817 - in soc2013/mattbw/backend: . actions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Jul 2013 22:13:02 -0000 Author: mattbw Date: Mon Jul 1 22:13:01 2013 New Revision: 253817 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=253817 Log: replace iterate.[ch] with query.[ch] and move related functions back in from db. Added: soc2013/mattbw/backend/query.c - copied, changed from r253789, soc2013/mattbw/backend/iterate.c soc2013/mattbw/backend/query.h - copied, changed from r253789, soc2013/mattbw/backend/iterate.h Deleted: soc2013/mattbw/backend/iterate.c soc2013/mattbw/backend/iterate.h Modified: soc2013/mattbw/backend/Makefile soc2013/mattbw/backend/actions/get-details.c soc2013/mattbw/backend/actions/get-files.c soc2013/mattbw/backend/actions/install-packages.c soc2013/mattbw/backend/db.c soc2013/mattbw/backend/db.h Modified: soc2013/mattbw/backend/Makefile ============================================================================== --- soc2013/mattbw/backend/Makefile Mon Jul 1 21:59:17 2013 (r253816) +++ soc2013/mattbw/backend/Makefile Mon Jul 1 22:13:01 2013 (r253817) @@ -2,7 +2,7 @@ LIB= pk_backend_pkgng SHLIB_MAJOR= 1 -SRCS= pk-backend-pkgng.c groups.c db.c licenses.c iterate.c utils.c +SRCS= pk-backend-pkgng.c groups.c db.c licenses.c query.c utils.c SRCS+= actions/get-details.c \ actions/get-files.c \ actions/get-repo-list.c \ Modified: soc2013/mattbw/backend/actions/get-details.c ============================================================================== --- soc2013/mattbw/backend/actions/get-details.c Mon Jul 1 21:59:17 2013 (r253816) +++ soc2013/mattbw/backend/actions/get-details.c Mon Jul 1 22:13:01 2013 (r253817) @@ -22,9 +22,8 @@ #include "../pk-backend.h" #include "pkg.h" -#include "../db.h" /* db_query_from_id */ #include "../groups.h" /* group_from_origin */ -#include "../iterate.h" /* Package iteration */ +#include "../query.h" /* Package querying */ #include "../licenses.h" /* license_from_pkg */ #include "actions.h" /* get_details_thread prototype */ @@ -51,7 +50,7 @@ static gboolean get_for(const gchar *id, PkBackend *backend, struct pkgdb *db) { - return db_query_with_id(id, backend, db, LOAD_FLAGS, emit_pkg); + return query_emit_match(id, backend, db, LOAD_FLAGS, emit_pkg); } /* Modified: soc2013/mattbw/backend/actions/get-files.c ============================================================================== --- soc2013/mattbw/backend/actions/get-files.c Mon Jul 1 21:59:17 2013 (r253816) +++ soc2013/mattbw/backend/actions/get-files.c Mon Jul 1 22:13:01 2013 (r253817) @@ -22,10 +22,9 @@ #include "../pk-backend.h" #include "pkg.h" -#include "../db.h" /* db_query_from_id */ #include "../groups.h" /* group_from_origin */ #include "../hash_traverse.h" /* HASH_FOR */ -#include "../iterate.h" /* Package iteration */ +#include "../query.h" /* Package querying */ #include "../licenses.h" /* license_from_pkg */ #include "actions.h" /* get_files_thread prototype */ @@ -93,5 +92,5 @@ gboolean get_for(const gchar *id, PkBackend *backend, struct pkgdb *db) { - return db_query_with_id(id, backend, db, LOAD_FLAGS, emit_pkg); + return query_emit_match(id, backend, db, LOAD_FLAGS, emit_pkg); } Modified: soc2013/mattbw/backend/actions/install-packages.c ============================================================================== --- soc2013/mattbw/backend/actions/install-packages.c Mon Jul 1 21:59:17 2013 (r253816) +++ soc2013/mattbw/backend/actions/install-packages.c Mon Jul 1 22:13:01 2013 (r253817) @@ -22,8 +22,7 @@ #include "../pk-backend.h" #include "pkg.h" -#include "../db.h" /* db_query_from_id */ -#include "../iterate.h" /* Package iteration */ +#include "../query.h" /* Package querying */ #include "actions.h" /* install_packages_thread prototype */ @@ -56,7 +55,7 @@ PK_ERROR_ENUM_INTERNAL_ERROR, "pkg_jobs_new failed"); else - err = db_query_to_job(id, backend, db, jobs); + err = query_job_match(id, backend, db, jobs); /* TODO: actually install */ pk_backend_error_code(backend, PK_ERROR_ENUM_NOT_SUPPORTED, NULL); Modified: soc2013/mattbw/backend/db.c ============================================================================== --- soc2013/mattbw/backend/db.c Mon Jul 1 21:59:17 2013 (r253816) +++ soc2013/mattbw/backend/db.c Mon Jul 1 22:13:01 2013 (r253817) @@ -25,26 +25,8 @@ #include "pkg.h" #include "db.h" /* prototypes */ -#include "iterate.h" /* pkg_func_ptr */ #include "utils.h" /* null_if_empty, split_id */ -static gboolean -db_query_split(const gchar *name, - const gchar *version, - const gchar *arch, - const gchar *reponame, - PkBackend *backend, - struct pkgdb *db, - int load_flags, - gchar **match_id_p, - struct pkg **match_pkg_p); -static gboolean -db_query_match(const gchar *id, - PkBackend *backend, - struct pkgdb *db, - int load_flags, - gchar **match_id_p, - struct pkg **match_pkg_p); /* * Opens a pkgdb ready for remote operations. This will always return TRUE if @@ -87,197 +69,3 @@ return success; } - -/* - * Performs a package database query against a PackageID, and then hands the - * matching results to an emitter function. - */ -gboolean -db_query_with_id(const gchar *id, - PkBackend *backend, - struct pkgdb *db, - int load_flags, - pkg_func_ptr emitter) -{ - gboolean success; - gchar *match_id; - struct pkg *match_pkg; - - success = db_query_match(id, - backend, - db, - load_flags, - &match_id, - &match_pkg); - if (success == TRUE && match_id != NULL && match_pkg != NULL) - emitter(match_pkg, match_id, backend); - - pkg_free(match_pkg); - g_free(match_id); - - return success; -} - -/* - * Performs a package database query against a PackageID, and then adds the - * matching results to a pkg job. - * - * The round trip through the database seems like a strange idea given that - * pkg_jobs takes a package name. At the moment this is done to ensure that - * the package matches the PackageID fully. - * - * TODO: do something about the redundancy in both this and the emitter variant. - */ -gboolean -db_query_to_job(const gchar *id, - PkBackend *backend, - struct pkgdb *db, - struct pkg_jobs *jobs) -{ - gboolean success; - gchar *match_id; - struct pkg *match_pkg; - - success = db_query_match(id, - backend, - db, - PKG_LOAD_BASIC, - &match_id, - &match_pkg); - if (success == TRUE && match_id != NULL && match_pkg != NULL) { - gchar *name[1]; - - name[0] = NULL; - pkg_get(match_pkg, PKG_NAME, &(name[0])); - - pkg_jobs_add(jobs, MATCH_EXACT, name, 1); - } - pkg_free(match_pkg); - g_free(match_id); - - return success; -} - -/* - * Performs a package database query against a (potentially partial) - * PackageID, retrieving the matched package and its full PackageID. - * - * The exact type of query depends on the repository given. - */ -static gboolean -db_query_match(const gchar *id, - PkBackend *backend, - struct pkgdb *db, - int load_flags, - gchar **match_id_p, - struct pkg **match_pkg_p) -{ - gboolean query_success; - gboolean split_success; - const gchar *arch; - const gchar *data; - const gchar *name; - const gchar *version; - gchar **strv; - - query_success = FALSE; - split_success = FALSE; - strv = NULL; - - split_success = split_id(id, &strv, &name, &version, &arch, &data); - if (split_success == FALSE) - pk_backend_error_code(backend, - PK_ERROR_ENUM_PACKAGE_ID_INVALID, - "invalid package id"); - else { - /* - * If the PackageID has a repository specified (even if it's - * "installed" i.e. currently installed package), running - * "get_details_query" directly should handle remote/local - * queries properly. - * - * If there is no repository specified, however (data is NULL), - * we may need to check both the local and (all) remote - * repositories, in that order. (TODO: local packages?) - */ - if (data == NULL) - /* Try local database first. */ - query_success = db_query_split(name, - version, - arch, - "installed", - backend, - db, - load_flags, - match_id_p, - match_pkg_p); - if (query_success == FALSE) - query_success = db_query_split(name, version, arch, data, - backend, db, load_flags, match_id_p, - match_pkg_p); - /* - * Assume any error is due to not finding packages. At time - * of writing this is true, but may change. - */ - if (query_success == FALSE) - pk_backend_error_code(backend, - PK_ERROR_ENUM_PACKAGE_NOT_FOUND, - "package not found"); - g_strfreev(strv); - } - - return query_success; -} - -/* - * Looks the split PackageID up in the package databases. - * - * Usually, a remote query will be done on the repository named by "reponame". - * If reponame is NULL, a remote check will be done against all repostories. - * If it is "installed", a local check will be done. (This is in keeping - * with the special meaning of the "installed" repository in PackageIDs). - */ -static gboolean -db_query_split(const gchar *name, - const gchar *version, - const gchar *arch, - const gchar *reponame, - PkBackend *backend, - struct pkgdb *db, - int load_flags, - gchar **match_id_p, - struct pkg **match_pkg_p) -{ - struct pkgdb_it *it; - gboolean success; - - success = FALSE; - it = NULL; - - /* Are we doing a local query? */ - /* - * If we got a repository name, then we want to make sure it - * corresponds to a real repository. - */ - if (g_strcmp0(reponame, "installed") == 0) - it = pkgdb_query(db, name, MATCH_EXACT); - else if (pkg_repo_find_ident(reponame) != NULL) - it = pkgdb_rquery(db, name, MATCH_EXACT, reponame); - else - pk_backend_error_code(backend, - PK_ERROR_ENUM_PACKAGE_NOT_FOUND, - "no such repository"); - - - if (it != NULL) - success = match_id_in_it(it, - backend, - name, - version, - arch, - reponame, - load_flags, - match_id_p, - match_pkg_p); - return success; -} Modified: soc2013/mattbw/backend/db.h ============================================================================== --- soc2013/mattbw/backend/db.h Mon Jul 1 21:59:17 2013 (r253816) +++ soc2013/mattbw/backend/db.h Mon Jul 1 22:13:01 2013 (r253817) @@ -26,19 +26,6 @@ #include "pk-backend.h" /* PkBackend */ #include "pkg.h" /* struct pkgdb */ -#include "iterate.h" /* pk_func_ptr */ - gboolean open_remote_db(struct pkgdb **db, PkBackend *backend); -gboolean -db_query_with_id(const gchar *package_id, - PkBackend *backend, - struct pkgdb *db, - int load_flags, - pkg_func_ptr emitter); -gboolean -db_query_to_job(const gchar *id, - PkBackend *backend, - struct pkgdb *db, - struct pkg_jobs *jobs); #endif /* !_PKGNG_BACKEND_DETAILS_H_ */ Copied and modified: soc2013/mattbw/backend/query.c (from r253789, soc2013/mattbw/backend/iterate.c) ============================================================================== --- soc2013/mattbw/backend/iterate.c Mon Jul 1 09:53:06 2013 (r253789, copy source) +++ soc2013/mattbw/backend/query.c Mon Jul 1 22:13:01 2013 (r253817) @@ -23,7 +23,7 @@ #include "pk-backend.h" #include "pkg.h" -#include "iterate.h" /* Prototypes */ +#include "query.h" /* Prototypes */ #include "db.h" /* open_remote_db */ #include "hash_traverse.h" /* HASH_FOR */ @@ -34,7 +34,23 @@ static gboolean try_id_match(struct pkg *pkg, const gchar *name, const gchar *version, const gchar *arch, const gchar *data, gchar **match_id); - +static gboolean +query_split(const gchar *name, + const gchar *version, + const gchar *arch, + const gchar *reponame, + PkBackend *backend, + struct pkgdb *db, + int load_flags, + gchar **match_id_p, + struct pkg **match_pkg_p); +static gboolean +match(const gchar *id, + PkBackend *backend, + struct pkgdb *db, + int load_flags, + gchar **match_id_p, + struct pkg **match_pkg_p); gboolean match_id_in_it(struct pkgdb_it *iterator, @@ -203,3 +219,187 @@ return no_error_yet; } + +/* + * Performs a package database query against a PackageID, and then hands the + * matching result to an emitter function. + */ +gboolean +query_emit_match(const gchar *id, + PkBackend *backend, + struct pkgdb *db, + int load_flags, + emit_ptr emitter) +{ + gboolean success; + gchar *match_id; + struct pkg *match_pkg; + + success = match(id, backend, db, load_flags, &match_id, &match_pkg); + if (success == TRUE && match_id != NULL && match_pkg != NULL) + emitter(match_pkg, match_id, backend); + + pkg_free(match_pkg); + g_free(match_id); + + return success; +} + +/* + * Performs a package database query against a PackageID, and then adds the + * matching results to a pkg job. + * + * The round trip through the database seems like a strange idea given that + * pkg_jobs takes a package name. At the moment this is done to ensure that + * the package matches the PackageID fully. + * + * TODO: do something about the redundancy in both this and the emitter variant. + */ +gboolean +query_job_match(const gchar *id, + PkBackend *backend, + struct pkgdb *db, + struct pkg_jobs *jobs) +{ + gboolean success; + gchar *match_id; + struct pkg *match_pkg; + + success = match(id, backend, db, PKG_LOAD_BASIC, &match_id, &match_pkg); + if (success == TRUE && match_id != NULL && match_pkg != NULL) { + gchar *name[1]; + + name[0] = NULL; + pkg_get(match_pkg, PKG_NAME, &(name[0])); + + pkg_jobs_add(jobs, MATCH_EXACT, name, 1); + } + pkg_free(match_pkg); + g_free(match_id); + + return success; +} + +/* + * Performs a package database query against a (potentially partial) + * PackageID, retrieving the matched package and its full PackageID. + * + * The exact type of query depends on the repository given. + */ +static gboolean +match(const gchar *id, + PkBackend *backend, + struct pkgdb *db, + int load_flags, + gchar **match_id_p, + struct pkg **match_pkg_p) +{ + gboolean query_success; + gboolean split_success; + const gchar *arch; + const gchar *data; + const gchar *name; + const gchar *version; + gchar **strv; + + query_success = FALSE; + split_success = FALSE; + strv = NULL; + + split_success = split_id(id, &strv, &name, &version, &arch, &data); + if (split_success == FALSE) + pk_backend_error_code(backend, + PK_ERROR_ENUM_PACKAGE_ID_INVALID, + "invalid package id"); + else { + /* + * If the PackageID has a repository specified (even if it's + * "installed" i.e. currently installed package), running + * "get_details_query" directly should handle remote/local + * queries properly. + * + * If there is no repository specified, however (data is NULL), + * we may need to check both the local and (all) remote + * repositories, in that order. (TODO: local packages?) + */ + if (data == NULL) + /* Try local database first. */ + query_success = query_split(name, + version, + arch, + "installed", + backend, + db, + load_flags, + match_id_p, + match_pkg_p); + if (query_success == FALSE) + query_success = query_split(name, version, arch, data, + backend, db, load_flags, match_id_p, + match_pkg_p); + /* + * Assume any error is due to not finding packages. At time + * of writing this is true, but may change. + */ + if (query_success == FALSE) + pk_backend_error_code(backend, + PK_ERROR_ENUM_PACKAGE_NOT_FOUND, + "package not found"); + g_strfreev(strv); + } + + return query_success; +} + +/* + * Looks the split PackageID up in the package databases. + * + * Usually, a remote query will be done on the repository named by "reponame". + * If reponame is NULL, a remote check will be done against all repostories. + * If it is "installed", a local check will be done. (This is in keeping + * with the special meaning of the "installed" repository in PackageIDs). + */ +static gboolean +query_split(const gchar *name, + const gchar *version, + const gchar *arch, + const gchar *reponame, + PkBackend *backend, + struct pkgdb *db, + int load_flags, + gchar **match_id_p, + struct pkg **match_pkg_p) +{ + struct pkgdb_it *it; + gboolean success; + + success = FALSE; + it = NULL; + + /* Are we doing a local query? */ + /* + * If we got a repository name, then we want to make sure it + * corresponds to a real repository. + */ + if (g_strcmp0(reponame, "installed") == 0) + it = pkgdb_query(db, name, MATCH_EXACT); + else if (pkg_repo_find_ident(reponame) != NULL) + it = pkgdb_rquery(db, name, MATCH_EXACT, reponame); + else + pk_backend_error_code(backend, + PK_ERROR_ENUM_PACKAGE_NOT_FOUND, + "no such repository"); + + + if (it != NULL) + success = match_id_in_it(it, + backend, + name, + version, + arch, + reponame, + load_flags, + match_id_p, + match_pkg_p); + return success; +} Copied and modified: soc2013/mattbw/backend/query.h (from r253789, soc2013/mattbw/backend/iterate.h) ============================================================================== --- soc2013/mattbw/backend/iterate.h Mon Jul 1 09:53:06 2013 (r253789, copy source) +++ soc2013/mattbw/backend/query.h Mon Jul 1 22:13:01 2013 (r253817) @@ -18,28 +18,29 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#ifndef _PKGNG_BACKEND_ITERATE_H_ -#define _PKGNG_BACKEND_ITERATE_H_ +#ifndef _PKGNG_BACKEND_QUERY_H_ +#define _PKGNG_BACKEND_QUERY_H_ #include #include "pk-backend.h" #include "pkg.h" -typedef void (*pkg_func_ptr) (struct pkg *pkg, - const gchar *id, - PkBackend *backend); +typedef void (*emit_ptr) (struct pkg *pkg, + const gchar *id, + PkBackend *backend); typedef gboolean (*ids_func_ptr) (const gchar *id, PkBackend *backend, struct pkgdb *db); gboolean -match_id_in_it(struct pkgdb_it *iterator, - PkBackend *backend, - const gchar *name, - const gchar *version, - const gchar *arch, - const gchar *data, - int load_flags, - gchar **match_id_p, - struct pkg **match_pkg_p); +query_emit_match(const gchar *id, + PkBackend *backend, + struct pkgdb *db, + int load_flags, + emit_ptr emitter); +gboolean +query_job_match(const gchar *id, + PkBackend *backend, + struct pkgdb *db, + struct pkg_jobs *jobs); gboolean iterate_ids(PkBackend *backend, ids_func_ptr iterate_f); -#endif /* !_PKGNG_BACKEND_ITERATE_H_ */ +#endif /* !_PKGNG_BACKEND_QUERY_H_ */ From owner-svn-soc-all@FreeBSD.ORG Tue Jul 2 00:30:56 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 38619676 for ; Tue, 2 Jul 2013 00:30:56 +0000 (UTC) (envelope-from mattbw@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 1AF231B20 for ; Tue, 2 Jul 2013 00:30:56 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r620Utsv020353 for ; Tue, 2 Jul 2013 00:30:55 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r620UtP9020334 for svn-soc-all@FreeBSD.org; Tue, 2 Jul 2013 00:30:55 GMT (envelope-from mattbw@FreeBSD.org) Date: Tue, 2 Jul 2013 00:30:55 GMT Message-Id: <201307020030.r620UtP9020334@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to mattbw@FreeBSD.org using -f From: mattbw@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r253825 - soc2013/mattbw/backend MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Jul 2013 00:30:56 -0000 Author: mattbw Date: Tue Jul 2 00:30:55 2013 New Revision: 253825 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=253825 Log: (segfaults) large-scale rehashing of query, currently builds but not working Modified: soc2013/mattbw/backend/query.c soc2013/mattbw/backend/query.h Modified: soc2013/mattbw/backend/query.c ============================================================================== --- soc2013/mattbw/backend/query.c Mon Jul 1 23:53:22 2013 (r253824) +++ soc2013/mattbw/backend/query.c Tue Jul 2 00:30:55 2013 (r253825) @@ -29,70 +29,46 @@ #include "hash_traverse.h" /* HASH_FOR */ #include "utils.h" /* string_match */ +struct query { + int load_flags; + const gchar *name; + const gchar *version; + const gchar *arch; + const gchar *data; + gchar **strv; + PkBackend *backend; + struct pkgdb *db; + + gboolean any_repo; + gboolean local_repo; +}; + + static const char *get_repo_of(struct pkg *pkg); static const char *get_repo_of_remote(struct pkg *pkg); -static gboolean -try_id_match(struct pkg *pkg, const gchar *name, const gchar *version, const - gchar *arch, const gchar *data, gchar **match_id); -static gboolean -query_split(const gchar *name, - const gchar *version, - const gchar *arch, - const gchar *reponame, - PkBackend *backend, - struct pkgdb *db, - int load_flags, - gchar **match_id_p, - struct pkg **match_pkg_p); -static gboolean -match(const gchar *id, - PkBackend *backend, - struct pkgdb *db, - int load_flags, - gchar **match_id_p, - struct pkg **match_pkg_p); +static gboolean try_id_match(struct pkg *pkg, struct query *state, gchar **match_id); +static gboolean match(struct query *state, gchar **match_id_p, struct pkg **match_pkg_p); gboolean -match_id_in_it(struct pkgdb_it *iterator, - PkBackend *backend, - const char *name, - const char *version, - const char *arch, - const char *data, - int load_flags, +match_id_in_it(struct pkgdb_it *it, + struct query *state, gchar **match_id_p, struct pkg **match_pkg_p) { /* TODO: Filters */ gboolean found; int err; + int load_flags; found = FALSE; *match_pkg_p = NULL; *match_id_p = NULL; + load_flags = state->load_flags; - /* - * Stop pkg from catching fire if we try to load files from - * non-installed packages. - */ - if ((load_flags & PKG_LOAD_FILES) && g_strcmp0(data, - "installed") != 0) { - pk_backend_error_code(backend, - PK_ERROR_ENUM_CANNOT_GET_FILELIST, - "Cannot get files for non-installed package." - ); - err = EPKG_FATAL; - } else { - for (HASH_FOR(err, pkgdb_it_next, iterator, match_pkg_p, load_flags)) { - if (try_id_match(*match_pkg_p, - name, - version, - arch, - data, - match_id_p) == TRUE) { - found = TRUE; - break; - } + for (HASH_FOR(err, pkgdb_it_next, it, match_pkg_p, load_flags)) { + if (try_id_match(*match_pkg_p, state, match_id_p) == TRUE) { + found = TRUE; + break; } } @@ -155,8 +131,7 @@ } static gboolean -try_id_match(struct pkg *pkg, const char *name, const char *version, const - char *arch, const char *data, char **match_id) +try_id_match(struct pkg *pkg, struct query *state, char **match_id) { const char *p_arch; const char *p_data; @@ -179,10 +154,10 @@ * PackageID. Of course, the original ID might have missing fields * (NULLs), so we treat a comparison involving one as a success. */ - return (string_match(name, p_name) && - string_match(version, p_version) && - string_match(arch, p_arch) && - string_match(data, p_data)) ? TRUE : FALSE; + return (string_match(state->name, p_name) && + string_match(state->version, p_version) && + string_match(state->arch, p_arch) && + string_match(state->data, p_data)) ? TRUE : FALSE; } /* @@ -225,19 +200,15 @@ * matching result to an emitter function. */ gboolean -query_emit_match(const gchar *id, - PkBackend *backend, - struct pkgdb *db, - int load_flags, - emit_ptr emitter) +query_emit_match(struct query *state, int load_flags, emit_ptr emitter) { gboolean success; gchar *match_id; struct pkg *match_pkg; - success = match(id, backend, db, load_flags, &match_id, &match_pkg); + success = match(state, &match_id, &match_pkg); if (success == TRUE && match_id != NULL && match_pkg != NULL) - emitter(match_pkg, match_id, backend); + emitter(match_pkg, match_id, state->backend); pkg_free(match_pkg); g_free(match_id); @@ -256,16 +227,14 @@ * TODO: do something about the redundancy in both this and the emitter variant. */ gboolean -query_job_match(const gchar *id, - PkBackend *backend, - struct pkgdb *db, - struct pkg_jobs *jobs) +query_job_match(struct query *state, struct pkg_jobs *jobs) { gboolean success; gchar *match_id; struct pkg *match_pkg; - success = match(id, backend, db, PKG_LOAD_BASIC, &match_id, &match_pkg); + state->load_flags = PKG_LOAD_BASIC; + success = match(state, &match_id, &match_pkg); if (success == TRUE && match_id != NULL && match_pkg != NULL) { gchar *name[1]; @@ -287,119 +256,130 @@ * The exact type of query depends on the repository given. */ static gboolean -match(const gchar *id, - PkBackend *backend, - struct pkgdb *db, - int load_flags, - gchar **match_id_p, - struct pkg **match_pkg_p) +match(struct query *state, gchar **match_id_p, struct pkg **match_pkg_p) { - gboolean query_success; - gboolean split_success; - const gchar *arch; - const gchar *data; - const gchar *name; - const gchar *version; - gchar **strv; + gboolean success; + gboolean try_local; + gboolean try_remote; + struct pkgdb *db; + struct pkgdb_it *it; - query_success = FALSE; - split_success = FALSE; - strv = NULL; + success = FALSE; + db = state->db; - split_success = split_id(id, &strv, &name, &version, &arch, &data); - if (split_success == FALSE) - pk_backend_error_code(backend, - PK_ERROR_ENUM_PACKAGE_ID_INVALID, - "invalid package id"); + /* + * If we're not given a specific repository in the PackageID, we want + * to try searching locally first and then remotely; otherwise which + * database we query depends on the repository we have been given. + */ + if (state->any_repo == TRUE) + try_local = try_remote = TRUE; else { - /* - * If the PackageID has a repository specified (even if it's - * "installed" i.e. currently installed package), running - * "get_details_query" directly should handle remote/local - * queries properly. - * - * If there is no repository specified, however (data is NULL), - * we may need to check both the local and (all) remote - * repositories, in that order. (TODO: local packages?) - */ - if (data == NULL) - /* Try local database first. */ - query_success = query_split(name, - version, - arch, - "installed", - backend, - db, - load_flags, - match_id_p, - match_pkg_p); - if (query_success == FALSE) - query_success = query_split(name, version, arch, data, - backend, db, load_flags, match_id_p, - match_pkg_p); - /* - * Assume any error is due to not finding packages. At time - * of writing this is true, but may change. - */ - if (query_success == FALSE) - pk_backend_error_code(backend, - PK_ERROR_ENUM_PACKAGE_NOT_FOUND, - "package not found"); - g_strfreev(strv); + try_local = (state->local_repo == TRUE); + try_remote = (state->local_repo == FALSE); } - return query_success; + /* Try a local search first, if applicable. */ + if (try_local == TRUE) + it = pkgdb_query(db, state->name, MATCH_EXACT); + else + it = NULL; + if (it != NULL) + success = match_id_in_it(it, state, match_id_p, match_pkg_p); + + /* Next, try a remote search, again only if applicable. */ + if (success == FALSE && (try_remote == TRUE)) + it = pkgdb_rquery(db, state->name, MATCH_EXACT, state->data); + else + it = NULL; + if (it != NULL) + success = match_id_in_it(it, state, match_id_p, match_pkg_p); + + /* + * Assume any error is due to not finding packages. At time of + * writing this is true, but may change. + */ + if (success == FALSE) + pk_backend_error_code(state->backend, + PK_ERROR_ENUM_PACKAGE_NOT_FOUND, + "package not found"); + + return success; } -/* - * Looks the split PackageID up in the package databases. - * - * Usually, a remote query will be done on the repository named by "reponame". - * If reponame is NULL, a remote check will be done against all repostories. - * If it is "installed", a local check will be done. (This is in keeping - * with the special meaning of the "installed" repository in PackageIDs). - */ -static gboolean -query_split(const gchar *name, - const gchar *version, - const gchar *arch, - const gchar *reponame, - PkBackend *backend, - struct pkgdb *db, - int load_flags, - gchar **match_id_p, - struct pkg **match_pkg_p) +/* Creates a struct query for the given backend and target ID. */ +gboolean +query_init(const gchar *id, PkBackend *backend, int load_flags, + struct query **state_p) { - struct pkgdb_it *it; gboolean success; + gboolean loading_files; + struct query *state; - success = FALSE; - it = NULL; - - /* Are we doing a local query? */ + state = *state_p; + if (state == NULL) + state = g_new0(struct query, 1); + + state->backend = backend; + state->load_flags = load_flags; + + success = open_remote_db(&(state->db), backend); + if (success == TRUE) { + success = split_id(id, + &(state->strv), + &(state->name), + &(state->version), + &(state->arch), + &(state->data)); + if (success == FALSE) + pk_backend_error_code(backend, + PK_ERROR_ENUM_PACKAGE_ID_INVALID, + "invalid package id"); + } /* - * If we got a repository name, then we want to make sure it - * corresponds to a real repository. + * Check the repository to make sure it's sane, and populate the repo + * type flags in the state for later consumption. */ - if (g_strcmp0(reponame, "installed") == 0) - it = pkgdb_query(db, name, MATCH_EXACT); - else if (pkg_repo_find_ident(reponame) != NULL) - it = pkgdb_rquery(db, name, MATCH_EXACT, reponame); - else + if (success == TRUE) { + if (state->data != NULL) + state->any_repo = TRUE; + else if (strcmp(state->data, "installed") == 0) + state->local_repo = TRUE; + else if (pkg_repo_find_ident(state->data) != NULL) { + pk_backend_error_code(backend, + PK_ERROR_ENUM_PACKAGE_ID_INVALID, + "no such repository"); + success = FALSE; + } + } + /* + * Stop pkg from catching fire if we try to load files from + * non-installed packages. + */ + loading_files = (load_flags & PKG_LOAD_FILES) ? TRUE : FALSE; + if (success == TRUE && state->local_repo == FALSE && loading_files) { pk_backend_error_code(backend, - PK_ERROR_ENUM_PACKAGE_NOT_FOUND, - "no such repository"); - - - if (it != NULL) - success = match_id_in_it(it, - backend, - name, - version, - arch, - reponame, - load_flags, - match_id_p, - match_pkg_p); + PK_ERROR_ENUM_CANNOT_GET_FILELIST, + "cannot get files for remote package"); + success = FALSE; + } + if (success == FALSE) { + query_free(state); + state = NULL; + } + *state_p = state; return success; } + +void +query_free(struct query *state) +{ + if (state != NULL) { + if (state->db != NULL) + pkgdb_close(state->db); + if (state->strv != NULL) + g_strfreev(state->strv); + /* This should free the other split ID pointer targets. */ + g_free(state); + } +} Modified: soc2013/mattbw/backend/query.h ============================================================================== --- soc2013/mattbw/backend/query.h Mon Jul 1 23:53:22 2013 (r253824) +++ soc2013/mattbw/backend/query.h Tue Jul 2 00:30:55 2013 (r253825) @@ -30,17 +30,14 @@ PkBackend *backend); typedef gboolean (*ids_func_ptr) (const gchar *id, PkBackend *backend, struct pkgdb *db); -gboolean -query_emit_match(const gchar *id, - PkBackend *backend, - struct pkgdb *db, - int load_flags, - emit_ptr emitter); -gboolean -query_job_match(const gchar *id, - PkBackend *backend, - struct pkgdb *db, - struct pkg_jobs *jobs); +struct query; + +gboolean query_emit_match(struct query *state, int load_flags, emit_ptr emitter); +gboolean query_job_match(struct query *state, struct pkg_jobs *jobs); gboolean iterate_ids(PkBackend *backend, ids_func_ptr iterate_f); +/* Creates a struct query for the given backend and target ID. */ +gboolean query_init(const gchar *id, PkBackend *backend, int load_flags, struct query **state_p); +void query_free(struct query *state); + #endif /* !_PKGNG_BACKEND_QUERY_H_ */ From owner-svn-soc-all@FreeBSD.ORG Tue Jul 2 06:17:33 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 93922E30 for ; Tue, 2 Jul 2013 06:17:33 +0000 (UTC) (envelope-from mattbw@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 769D4189E for ; Tue, 2 Jul 2013 06:17:33 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r626HXXj061860 for ; Tue, 2 Jul 2013 06:17:33 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r626HWqp061853 for svn-soc-all@FreeBSD.org; Tue, 2 Jul 2013 06:17:32 GMT (envelope-from mattbw@FreeBSD.org) Date: Tue, 2 Jul 2013 06:17:32 GMT Message-Id: <201307020617.r626HWqp061853@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to mattbw@FreeBSD.org using -f From: mattbw@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r253829 - in soc2013/mattbw/backend: . actions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Jul 2013 06:17:33 -0000 Author: mattbw Date: Tue Jul 2 06:17:32 2013 New Revision: 253829 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=253829 Log: (still segfaults) we don't need a separate job match if we allow the database to be retrieved from the emitter Modified: soc2013/mattbw/backend/actions/get-details.c soc2013/mattbw/backend/actions/get-files.c soc2013/mattbw/backend/actions/install-packages.c soc2013/mattbw/backend/pk-backend-pkgng.c soc2013/mattbw/backend/query.c soc2013/mattbw/backend/query.h Modified: soc2013/mattbw/backend/actions/get-details.c ============================================================================== --- soc2013/mattbw/backend/actions/get-details.c Tue Jul 2 04:45:51 2013 (r253828) +++ soc2013/mattbw/backend/actions/get-details.c Tue Jul 2 06:17:32 2013 (r253829) @@ -30,8 +30,8 @@ static const int LOAD_FLAGS = PKG_LOAD_BASIC | PKG_LOAD_LICENSES; -static void emit_pkg(struct pkg *pkg, const gchar *id, PkBackend *backend); -static gboolean get_for(const gchar *id, PkBackend *backend, struct pkgdb *db); +static gboolean body(struct query *q); +static void emit(struct pkg *pkg, const gchar *id, struct query *q); /* * The thread that performs a GetDetails operation. Should be invoked by the @@ -40,7 +40,7 @@ gboolean get_details_thread(PkBackend *backend) { - return iterate_ids(backend, get_for); + return query_for_all_ids(backend, LOAD_FLAGS, body); } /* @@ -48,16 +48,16 @@ * found. */ static gboolean -get_for(const gchar *id, PkBackend *backend, struct pkgdb *db) +body(struct query *q) { - return query_emit_match(id, backend, db, LOAD_FLAGS, emit_pkg); + return query_emit_match(q, emit); } /* * Emits the given package's details. To be used as an iterating function. */ static void -emit_pkg(struct pkg *pkg, const gchar *id, PkBackend *backend) +emit(struct pkg *pkg, const gchar *id, struct query *q) { const char *description; const char *origin; @@ -71,7 +71,7 @@ PKG_ORIGIN, &origin, PKG_WWW, &www); - pk_backend_details(backend, + pk_backend_details(query_backend(q), id, license_name_from_pkg(pkg), group_from_origin(origin), Modified: soc2013/mattbw/backend/actions/get-files.c ============================================================================== --- soc2013/mattbw/backend/actions/get-files.c Tue Jul 2 04:45:51 2013 (r253828) +++ soc2013/mattbw/backend/actions/get-files.c Tue Jul 2 06:17:32 2013 (r253829) @@ -32,24 +32,34 @@ static const int FILE_NAME_STEP = 10; static const int LOAD_FLAGS = PKG_LOAD_BASIC | PKG_LOAD_FILES; -static void emit_pkg(struct pkg *pkg, const gchar *id, PkBackend *backend); -static gboolean get_for(const gchar *id, PkBackend *backend, struct pkgdb *db); +static gboolean body(struct query *q); +static void emit(struct pkg *pkg, const gchar *id, struct query *q); /* * The thread that performs a GetDetails operation. Should be invoked by the - * pk_backend_get_files hook. + * pk_backend_get_details hook. */ gboolean get_files_thread(PkBackend *backend) { - return iterate_ids(backend, get_for); + return query_for_all_ids(backend, LOAD_FLAGS, body); +} + +/* + * Look up and emit package details for the given PackageID, if it can be + * found. + */ +static gboolean +body(struct query *q) +{ + return query_emit_match(q, emit); } /* * Emits the given package's files. To be used as an iterating function. */ static void -emit_pkg(struct pkg *pkg, const gchar *id, PkBackend *backend) +emit(struct pkg *pkg, const gchar *id, struct query *q) { struct pkg_file *file; int err; @@ -81,16 +91,6 @@ joined_filenames = g_strjoinv(";", filenames); g_strfreev(filenames); - pk_backend_files(backend, id, joined_filenames); + pk_backend_files(query_backend(q), id, joined_filenames); g_free(joined_filenames); } - -/* - * Look up and emit package files for the given PackageID, if it can be - * found. - */ -gboolean -get_for(const gchar *id, PkBackend *backend, struct pkgdb *db) -{ - return query_emit_match(id, backend, db, LOAD_FLAGS, emit_pkg); -} Modified: soc2013/mattbw/backend/actions/install-packages.c ============================================================================== --- soc2013/mattbw/backend/actions/install-packages.c Tue Jul 2 04:45:51 2013 (r253828) +++ soc2013/mattbw/backend/actions/install-packages.c Tue Jul 2 06:17:32 2013 (r253829) @@ -26,7 +26,8 @@ #include "actions.h" /* install_packages_thread prototype */ -static gboolean get_for(const gchar *id, PkBackend *backend, struct pkgdb *db); +static gboolean body(struct query *q); +/*static void emit(struct pkg *pkg, const gchar *id, PkBackend *backend);*/ /* * The thread that performs an InstallPackages operation. Should be invoked by @@ -35,29 +36,16 @@ gboolean install_packages_thread(PkBackend *backend) { - return iterate_ids(backend, get_for); + return query_for_all_ids(backend, PKG_LOAD_BASIC, body); } /* * Look up and attempt to install the given PackageID, if it can be found. */ static gboolean -get_for(const gchar *id, PkBackend *backend, struct pkgdb *db) +body(struct query *q) { - struct pkg_jobs *jobs; - int err; - - jobs = NULL; - err = pkg_jobs_new(&jobs, PKG_JOBS_INSTALL, db); - - if (err != EPKG_OK) - pk_backend_error_code(backend, - PK_ERROR_ENUM_INTERNAL_ERROR, - "pkg_jobs_new failed"); - else - err = query_job_match(id, backend, db, jobs); - /* TODO: actually install */ - pk_backend_error_code(backend, PK_ERROR_ENUM_NOT_SUPPORTED, NULL); - return err; + pk_backend_error_code(query_backend(q), PK_ERROR_ENUM_NOT_SUPPORTED, NULL); + return FALSE; } Modified: soc2013/mattbw/backend/pk-backend-pkgng.c ============================================================================== --- soc2013/mattbw/backend/pk-backend-pkgng.c Tue Jul 2 04:45:51 2013 (r253828) +++ soc2013/mattbw/backend/pk-backend-pkgng.c Tue Jul 2 06:17:32 2013 (r253829) @@ -45,9 +45,7 @@ static gboolean _updated_powertop = FALSE; static gboolean _has_signature = FALSE; static gboolean _use_eula = FALSE; -static gboolean _use_media = FALSE; static gboolean _use_gpg = FALSE; -static gboolean _use_trusted = TRUE; static gboolean _use_distro_upgrade = FALSE; static PkBitfield _filters = 0; static GSocket *_socket = NULL; @@ -357,43 +355,6 @@ _signal_timeout = g_timeout_add(1000, pk_backend_get_updates_timeout, backend); } -static gboolean -pk_backend_install_timeout(gpointer data) -{ - PkBackend *backend = (PkBackend *)data; - guint sub_percent; - - if (_progress_percentage == 100) { - pk_backend_finished(backend); - return FALSE; - } - if (_progress_percentage == 30) { - pk_backend_set_allow_cancel(backend, FALSE); - pk_backend_package(backend, PK_INFO_ENUM_INSTALLING, - "gtkhtml2;2.19.1-4.fc8;i386;fedora", - "An HTML widget for GTK+ 2.0"); - pk_backend_set_status(backend, PK_STATUS_ENUM_INSTALL); - } - if (_progress_percentage == 50) { - pk_backend_package(backend, PK_INFO_ENUM_INSTALLING, - "gtkhtml2-devel;2.19.1-0.fc8;i386;fedora", - "Devel files for gtkhtml"); - /* this duplicate package should be ignored */ - pk_backend_package(backend, PK_INFO_ENUM_INSTALLING, - "gtkhtml2-devel;2.19.1-0.fc8;i386;fedora", NULL); - pk_backend_set_status(backend, PK_STATUS_ENUM_INSTALL); - } - if (_progress_percentage > 30 && _progress_percentage < 50) { - sub_percent = ((gfloat) (_progress_percentage - 30.0) / 20.0) * 100.0; - pk_backend_set_sub_percentage(backend, sub_percent); - } else { - pk_backend_set_sub_percentage(backend, PK_BACKEND_PERCENTAGE_INVALID); - } - _progress_percentage += 1; - pk_backend_set_percentage(backend, _progress_percentage); - return TRUE; -} - /** * pk_backend_install_packages: */ @@ -401,6 +362,7 @@ pk_backend_install_packages(PkBackend *backend, gboolean only_trusted, gchar **package_ids) { INTENTIONALLY_IGNORE(only_trusted); + INTENTIONALLY_IGNORE(package_ids); pk_backend_set_status(backend, PK_STATUS_ENUM_QUERY); pk_backend_set_percentage(backend, PK_BACKEND_PERCENTAGE_INVALID); Modified: soc2013/mattbw/backend/query.c ============================================================================== --- soc2013/mattbw/backend/query.c Tue Jul 2 04:45:51 2013 (r253828) +++ soc2013/mattbw/backend/query.c Tue Jul 2 06:17:32 2013 (r253829) @@ -43,15 +43,23 @@ gboolean local_repo; }; - static const char *get_repo_of(struct pkg *pkg); static const char *get_repo_of_remote(struct pkg *pkg); -static gboolean try_id_match(struct pkg *pkg, struct query *state, gchar **match_id); -static gboolean match(struct query *state, gchar **match_id_p, struct pkg **match_pkg_p); +static gboolean match(struct query *q, gchar **match_id_p, struct pkg **match_pkg_p); +static gboolean try_id_match(struct pkg *pkg, struct query *q, gchar **match_id); +static gboolean match_id_in_it(struct pkgdb_it *it, struct query *q, gchar **match_id_p, struct pkg **match_pkg_p); +static void query_free_contents(struct query *q); + +/* Returns the backend stored inside the struct query. */ +PkBackend * +query_backend(struct query *q) +{ + return (q == NULL ? NULL : q->backend); +} -gboolean +static gboolean match_id_in_it(struct pkgdb_it *it, - struct query *state, + struct query *q, gchar **match_id_p, struct pkg **match_pkg_p) { @@ -63,10 +71,10 @@ found = FALSE; *match_pkg_p = NULL; *match_id_p = NULL; - load_flags = state->load_flags; + load_flags = q->load_flags; for (HASH_FOR(err, pkgdb_it_next, it, match_pkg_p, load_flags)) { - if (try_id_match(*match_pkg_p, state, match_id_p) == TRUE) { + if (try_id_match(*match_pkg_p, q, match_id_p) == TRUE) { found = TRUE; break; } @@ -131,7 +139,7 @@ } static gboolean -try_id_match(struct pkg *pkg, struct query *state, char **match_id) +try_id_match(struct pkg *pkg, struct query *q, char **match_id) { const char *p_arch; const char *p_data; @@ -154,38 +162,46 @@ * PackageID. Of course, the original ID might have missing fields * (NULLs), so we treat a comparison involving one as a success. */ - return (string_match(state->name, p_name) && - string_match(state->version, p_version) && - string_match(state->arch, p_arch) && - string_match(state->data, p_data)) ? TRUE : FALSE; + return (string_match(q->name, p_name) && + string_match(q->version, p_version) && + string_match(q->arch, p_arch) && + string_match(q->data, p_data)) ? TRUE : FALSE; } /* - * Iterates over a set of PackageIDs provided for this job with a function. + * Iterates a query function over all PackageIDs provided for this job. * - * This provides each iterating function call with an open database connection - * and updates the percentage after each iteration. + * This provides each iterating function call with a query structure ready to + * run and updates the percentage after each iteration. * * It also *finishes* the backend job. */ gboolean -iterate_ids(PkBackend *backend, ids_func_ptr iterate_f) +query_for_all_ids(PkBackend *backend, int load_flags, query_body_ptr body) { gboolean no_error_yet; gchar **package_ids; guint len; guint i; struct pkgdb *db; + struct query *q; package_ids = pk_backend_get_strv(backend, "package_ids"); len = g_strv_length(package_ids); db = NULL; + q = NULL; no_error_yet = open_remote_db(&db, backend); pk_backend_set_percentage(backend, 0); for (i = 0; i < len && no_error_yet; i++) { - no_error_yet = iterate_f(package_ids[i], backend, db); + no_error_yet = query_init(package_ids[i], + backend, + db, + load_flags, + &q); + if (no_error_yet == TRUE) + no_error_yet = body(q); pk_backend_set_percentage(backend, ((i * 100) / len)); } pkgdb_close(db); @@ -200,15 +216,15 @@ * matching result to an emitter function. */ gboolean -query_emit_match(struct query *state, int load_flags, emit_ptr emitter) +query_emit_match(struct query *q, emit_ptr emitter) { gboolean success; gchar *match_id; struct pkg *match_pkg; - success = match(state, &match_id, &match_pkg); + success = match(q, &match_id, &match_pkg); if (success == TRUE && match_id != NULL && match_pkg != NULL) - emitter(match_pkg, match_id, state->backend); + emitter(match_pkg, match_id, q); pkg_free(match_pkg); g_free(match_id); @@ -226,28 +242,28 @@ * * TODO: do something about the redundancy in both this and the emitter variant. */ -gboolean -query_job_match(struct query *state, struct pkg_jobs *jobs) -{ - gboolean success; - gchar *match_id; - struct pkg *match_pkg; - - state->load_flags = PKG_LOAD_BASIC; - success = match(state, &match_id, &match_pkg); - if (success == TRUE && match_id != NULL && match_pkg != NULL) { - gchar *name[1]; - - name[0] = NULL; - pkg_get(match_pkg, PKG_NAME, &(name[0])); - - pkg_jobs_add(jobs, MATCH_EXACT, name, 1); - } - pkg_free(match_pkg); - g_free(match_id); - - return success; -} +/* + * // TODO: salvage something out of this gboolean emit_job(struct pkg *pkg, + * const gchar *id, struct query *q, pkg_jobs_t type, job_ptr user) { + * gboolean success; gchar *match_id; struct pkg *match_pkg; + * struct pkg_jobs *jobs; + * + * success = TRUE; jobs = NULL; + * + * q->load_flags = PKG_LOAD_BASIC; success = match(q, &match_id, &match_pkg); if + * (success == TRUE && match_id != NULL && match_pkg != NULL) { + * + * // Duplicated because pkg_jobs_add is not const correct. // gchar + * *name; int err; + * + * err = pkg_jobs_new(&jobs, type, q->db); if (err != EPKG_OK) { + * pk_backend_error_code(q->backend, PK_ERROR_ENUM_INTERNAL_ERROR, + * "pkg_jobs_new failed"); success = FALSE; } else { name = + * g_strdup(q->name); pkg_jobs_add(jobs, MATCH_EXACT, &name, 1); + * g_free(name); } pkg_free(match_pkg); g_free(match_id); + * + * return success; } + */ /* * Performs a package database query against a (potentially partial) @@ -256,7 +272,7 @@ * The exact type of query depends on the repository given. */ static gboolean -match(struct query *state, gchar **match_id_p, struct pkg **match_pkg_p) +match(struct query *q, gchar **match_id_p, struct pkg **match_pkg_p) { gboolean success; gboolean try_local; @@ -265,42 +281,42 @@ struct pkgdb_it *it; success = FALSE; - db = state->db; + db = q->db; /* * If we're not given a specific repository in the PackageID, we want * to try searching locally first and then remotely; otherwise which * database we query depends on the repository we have been given. */ - if (state->any_repo == TRUE) + if (q->any_repo == TRUE) try_local = try_remote = TRUE; else { - try_local = (state->local_repo == TRUE); - try_remote = (state->local_repo == FALSE); + try_local = (q->local_repo == TRUE); + try_remote = (q->local_repo == FALSE); } /* Try a local search first, if applicable. */ if (try_local == TRUE) - it = pkgdb_query(db, state->name, MATCH_EXACT); + it = pkgdb_query(db, q->name, MATCH_EXACT); else it = NULL; if (it != NULL) - success = match_id_in_it(it, state, match_id_p, match_pkg_p); + success = match_id_in_it(it, q, match_id_p, match_pkg_p); /* Next, try a remote search, again only if applicable. */ if (success == FALSE && (try_remote == TRUE)) - it = pkgdb_rquery(db, state->name, MATCH_EXACT, state->data); + it = pkgdb_rquery(db, q->name, MATCH_EXACT, q->data); else it = NULL; if (it != NULL) - success = match_id_in_it(it, state, match_id_p, match_pkg_p); + success = match_id_in_it(it, q, match_id_p, match_pkg_p); /* * Assume any error is due to not finding packages. At time of * writing this is true, but may change. */ if (success == FALSE) - pk_backend_error_code(state->backend, + pk_backend_error_code(q->backend, PK_ERROR_ENUM_PACKAGE_NOT_FOUND, "package not found"); @@ -309,43 +325,47 @@ /* Creates a struct query for the given backend and target ID. */ gboolean -query_init(const gchar *id, PkBackend *backend, int load_flags, - struct query **state_p) +query_init(const gchar *id, + PkBackend *backend, + struct pkgdb *db, + int load_flags, + struct query **q_p) { gboolean success; gboolean loading_files; - struct query *state; + struct query *q; - state = *state_p; - if (state == NULL) - state = g_new0(struct query, 1); + q = *q_p; + if (q == NULL) + q = g_new0(struct query, 1); + else + query_free_contents(q); - state->backend = backend; - state->load_flags = load_flags; + q->backend = backend; + q->load_flags = load_flags; + q->db = db; + + success = split_id(id, + &(q->strv), + &(q->name), + &(q->version), + &(q->arch), + &(q->data)); + if (success == FALSE) + pk_backend_error_code(backend, + PK_ERROR_ENUM_PACKAGE_ID_INVALID, + "invalid package id"); - success = open_remote_db(&(state->db), backend); - if (success == TRUE) { - success = split_id(id, - &(state->strv), - &(state->name), - &(state->version), - &(state->arch), - &(state->data)); - if (success == FALSE) - pk_backend_error_code(backend, - PK_ERROR_ENUM_PACKAGE_ID_INVALID, - "invalid package id"); - } /* * Check the repository to make sure it's sane, and populate the repo * type flags in the state for later consumption. */ if (success == TRUE) { - if (state->data != NULL) - state->any_repo = TRUE; - else if (strcmp(state->data, "installed") == 0) - state->local_repo = TRUE; - else if (pkg_repo_find_ident(state->data) != NULL) { + if (q->data != NULL) + q->any_repo = TRUE; + else if (strcmp(q->data, "installed") == 0) + q->local_repo = TRUE; + else if (pkg_repo_find_ident(q->data) != NULL) { pk_backend_error_code(backend, PK_ERROR_ENUM_PACKAGE_ID_INVALID, "no such repository"); @@ -357,29 +377,34 @@ * non-installed packages. */ loading_files = (load_flags & PKG_LOAD_FILES) ? TRUE : FALSE; - if (success == TRUE && state->local_repo == FALSE && loading_files) { + if (success == TRUE && q->local_repo == FALSE && loading_files) { pk_backend_error_code(backend, PK_ERROR_ENUM_CANNOT_GET_FILELIST, "cannot get files for remote package"); success = FALSE; } if (success == FALSE) { - query_free(state); - state = NULL; + query_free(q); + q = NULL; } - *state_p = state; + *q_p = q; return success; } void -query_free(struct query *state) +query_free(struct query *q) { - if (state != NULL) { - if (state->db != NULL) - pkgdb_close(state->db); - if (state->strv != NULL) - g_strfreev(state->strv); - /* This should free the other split ID pointer targets. */ - g_free(state); + if (q != NULL) { + query_free_contents(q); + g_free(q); } } + +static void +query_free_contents(struct query *q) +{ + /* The database is owned by the creator and is not freed. */ + /* This should free the other split ID pointer targets. */ + if (q->strv != NULL) + g_strfreev(q->strv); +} Modified: soc2013/mattbw/backend/query.h ============================================================================== --- soc2013/mattbw/backend/query.h Tue Jul 2 04:45:51 2013 (r253828) +++ soc2013/mattbw/backend/query.h Tue Jul 2 06:17:32 2013 (r253829) @@ -25,19 +25,16 @@ #include "pk-backend.h" #include "pkg.h" -typedef void (*emit_ptr) (struct pkg *pkg, - const gchar *id, - PkBackend *backend); -typedef gboolean (*ids_func_ptr) (const gchar *id, PkBackend *backend, struct pkgdb *db); - struct query; -gboolean query_emit_match(struct query *state, int load_flags, emit_ptr emitter); -gboolean query_job_match(struct query *state, struct pkg_jobs *jobs); -gboolean iterate_ids(PkBackend *backend, ids_func_ptr iterate_f); +typedef void (*emit_ptr) (struct pkg *pkg, const gchar *id, struct query *q); +typedef gboolean (*query_body_ptr) (struct query *q); + -/* Creates a struct query for the given backend and target ID. */ -gboolean query_init(const gchar *id, PkBackend *backend, int load_flags, struct query **state_p); -void query_free(struct query *state); +PkBackend *query_backend(struct query *q); +gboolean query_emit_match(struct query *q, emit_ptr emitter); +gboolean query_for_all_ids(PkBackend *backend, int load_flags, query_body_ptr body); +gboolean query_init(const gchar *id, PkBackend *backend, struct pkgdb *db, int load_flags, struct query **q_p); +void query_free(struct query *q); #endif /* !_PKGNG_BACKEND_QUERY_H_ */ From owner-svn-soc-all@FreeBSD.ORG Tue Jul 2 09:03:22 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 2C85B3CF for ; Tue, 2 Jul 2013 09:03:22 +0000 (UTC) (envelope-from mattbw@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 1E6B51E7B for ; Tue, 2 Jul 2013 09:03:22 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6293LUD006734 for ; Tue, 2 Jul 2013 09:03:21 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6293LPM006719 for svn-soc-all@FreeBSD.org; Tue, 2 Jul 2013 09:03:21 GMT (envelope-from mattbw@FreeBSD.org) Date: Tue, 2 Jul 2013 09:03:21 GMT Message-Id: <201307020903.r6293LPM006719@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to mattbw@FreeBSD.org using -f From: mattbw@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r253837 - soc2013/mattbw/backend MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Jul 2013 09:03:22 -0000 Author: mattbw Date: Tue Jul 2 09:03:21 2013 New Revision: 253837 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=253837 Log: (fixed?) clanged out some silly logic errors Modified: soc2013/mattbw/backend/query.c Modified: soc2013/mattbw/backend/query.c ============================================================================== --- soc2013/mattbw/backend/query.c Tue Jul 2 08:44:56 2013 (r253836) +++ soc2013/mattbw/backend/query.c Tue Jul 2 09:03:21 2013 (r253837) @@ -222,6 +222,8 @@ gchar *match_id; struct pkg *match_pkg; + match_id = NULL; + match_pkg = NULL; success = match(q, &match_id, &match_pkg); if (success == TRUE && match_id != NULL && match_pkg != NULL) emitter(match_pkg, match_id, q); @@ -361,11 +363,11 @@ * type flags in the state for later consumption. */ if (success == TRUE) { - if (q->data != NULL) + if (q->data == NULL) q->any_repo = TRUE; else if (strcmp(q->data, "installed") == 0) q->local_repo = TRUE; - else if (pkg_repo_find_ident(q->data) != NULL) { + else if (pkg_repo_find_ident(q->data) == NULL) { pk_backend_error_code(backend, PK_ERROR_ENUM_PACKAGE_ID_INVALID, "no such repository"); From owner-svn-soc-all@FreeBSD.ORG Tue Jul 2 10:08:17 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 5EE1AFE3 for ; Tue, 2 Jul 2013 10:08:17 +0000 (UTC) (envelope-from dpl@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 412AF1201 for ; Tue, 2 Jul 2013 10:08:17 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r62A8G1R033235 for ; Tue, 2 Jul 2013 10:08:16 GMT (envelope-from dpl@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r62A8GD1033233 for svn-soc-all@FreeBSD.org; Tue, 2 Jul 2013 10:08:16 GMT (envelope-from dpl@FreeBSD.org) Date: Tue, 2 Jul 2013 10:08:16 GMT Message-Id: <201307021008.r62A8GD1033233@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to dpl@FreeBSD.org using -f From: dpl@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r253838 - soc2013/dpl/head/contrib/bzip2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Jul 2013 10:08:17 -0000 Author: dpl Date: Tue Jul 2 10:08:16 2013 New Revision: 253838 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=253838 Log: sendfd() and recvfd() are finally working. I also cleant some code inside fork. Right now, it blocks somewhere, and the parent process doesn't send the good fds. Modified: soc2013/dpl/head/contrib/bzip2/bzip2.c Modified: soc2013/dpl/head/contrib/bzip2/bzip2.c ============================================================================== --- soc2013/dpl/head/contrib/bzip2/bzip2.c Tue Jul 2 09:03:21 2013 (r253837) +++ soc2013/dpl/head/contrib/bzip2/bzip2.c Tue Jul 2 10:08:16 2013 (r253838) @@ -232,7 +232,8 @@ int sendfd(int s, int fd) -{ +{ + printf("sendfd sending: %d", fd); struct msghdr msg; struct cmsghdr *cmsg; struct iovec io[1]; @@ -286,11 +287,9 @@ cmsg.cmsg_len = DATALEN; cmsg.cmsg_level = SOL_SOCKET; cmsg.cmsg_type = SCM_RIGHTS; - /*Why does sendmsg set errno to 9 EBADF??*/ if(recvmsg(s, &msg, 0) < 0) return -1; fd = *(int *)CMSG_DATA(&cmsg); - printf("recvfd() fd recieved: %d\n", *((int *)CMSG_DATA(&cmsg))); return 0; } #endif @@ -1379,8 +1378,15 @@ } # if CAPSICUM - infd = fileno(inStr); - outfd = fileno(outStr); + infd = dup(fileno(inStr)); + outfd = dup(fileno(outStr)); + if ( infd == -1 || outfd == -1){ + fprintf ( stderr, "%s: Couldn't close inStr: %s.\n", + progName, strerror(errno) ); + setExit(1); + exit(exitValue); + } + cap_rights_limit(infd, CAP_READ); cap_rights_limit(outfd, CAP_WRITE); @@ -1397,37 +1403,74 @@ exit(exitValue); } - printf("fork()\n"); - /* Pass the limited file descriptors with a unix domain socket. */ - switch( forkpid = fork() ) { - case ( -1 ): + /* Pass the limited file descriptors via unix domain socket. */ + if ( (forkpid = fork()) == -1 ){ fprintf ( stderr, "%s: Couldn't fork: %s.\n", progName, strerror(errno) ); setExit(1); exit(exitValue); + } else if ( forkpid != 0) { + + if ((close(sv[0])) < 0){ + fprintf ( stderr, "%s: Couldn't close fd: %s.\n", + progName, strerror(errno) ); + wait(NULL); + setExit(1); + exit(exitValue); + } + if ((closeinfd)) < 0){ + fprintf ( stderr, "%s: Couldn't close fd: %s.\n", + progName, strerror(errno) ); + setExit(1); + exit(exitValue); + } + if ((close(outfd)) < 0){ + fprintf ( stderr, "%s: Couldn't close fd: %s.\n", + progName, strerror(errno) ); + setExit(1); + exit(exitValue); + } + if (sendfd(sv[1], infd) < 0){ + fprintf ( stderr, "%s: Couldn't send infd: %s.\n", + progName, strerror(errno) ); + if (kill(forkpid, SIGTERM) < 0) + printf("Couldn't kill the child process, please press ^C\n"); + wait(NULL); + setExit(1); + exit(exitValue); + } + if (sendfd(sv[1], outfd) < 0){ + fprintf ( stderr, "%s: Couldn't send outfd: %s.\n", + progName, strerror(errno) ); + if (kill(forkpid, SIGTERM) < 0) + printf("Couldn't kill the child process, please press ^C\n"); + wait(NULL); + setExit(1); + exit(exitValue); + } + /* Let the children compress */ + wait(NULL); + return; - case ( 0 ): - if ((close(sv[1])) < 0){ + } else if (forkpid == 0){ + if ((close(sv[1])) < 0){ fprintf ( stderr, "%s: Couldn't close socket: %s.\n", progName, strerror(errno) ); setExit(1); exit(exitValue); } - printf("About to recv infd\n"); - sleep(1); if ((infd = recvfd(sv[0])) < 0){ fprintf ( stderr, "%s: Couldn't get infd: %s.\n", progName, strerror(errno) ); setExit(1); exit(exitValue); } - printf("About to recv outfd\n"); if ((outfd = recvfd(sv[0])) < 0){ fprintf ( stderr, "%s: Couldn't get outfd: %s.\n", progName, strerror(errno) ); setExit(1); exit(exitValue); } - printf("Child: infd:%d, outfd:%d\n", infd, outfd); + printf("Child: infd:%d, outfd:%d\n", infd, outfd); inStr = fdopen(infd, "rb"); outStr = fdopen(outfd, "wb"); @@ -1437,62 +1480,28 @@ setExit(1); exit(exitValue); } - # endif - /*--- Now the input and output handles are sane. Do the Biz. ---*/ - outputHandleJustInCase = outStr; - deleteOutputOnInterrupt = True; - compressStream ( inStr, outStr ); - outputHandleJustInCase = NULL; - - /*--- If there was an I/O error, we won't get here. ---*/ - if ( srcMode == SM_F2F ) { - applySavedTimeInfoToOutputFile ( outName ); - deleteOutputOnInterrupt = False; - if ( !keepInputFiles ) { - IntNative retVal = remove ( inName ); - ERROR_IF_NOT_ZERO ( retVal ); - } - } - - deleteOutputOnInterrupt = False; -# if CAPSICUM - exit(0); - break; - - default: - printf("Parent: infd:%d, outfd:%d\n", infd, outfd); - printf("Child's pid: %d\n", forkpid); - if ((close(sv[0])) < 0){ - fprintf ( stderr, "%s: Couldn't close fd: %s.\n", - progName, strerror(errno) ); - wait(NULL); - setExit(1); - exit(exitValue); + /*--- Now the input and output handles are sane. Do the Biz. ---*/ + outputHandleJustInCase = outStr; + deleteOutputOnInterrupt = True; + compressStream ( inStr, outStr ); + outputHandleJustInCase = NULL; + + /*--- If there was an I/O error, we won't get here. ---*/ + if ( srcMode == SM_F2F ) { + applySavedTimeInfoToOutputFile ( outName ); + deleteOutputOnInterrupt = False; + if ( !keepInputFiles ) { + IntNative retVal = remove ( inName ); + ERROR_IF_NOT_ZERO ( retVal ); } - if (sendfd(sv[1], infd) < 0){ - fprintf ( stderr, "%s: Couldn't send infd: %s.\n", - progName, strerror(errno) ); - if (kill(forkpid, SIGTERM) < 0) - printf("Couldn't kill the child process, please press ^C\n"); - wait(NULL); - setExit(1); - exit(exitValue); } - if (sendfd(sv[1], outfd) < 0){ - fprintf ( stderr, "%s: Couldn't send outfd: %s.\n", - progName, strerror(errno) ); - wait(NULL); - setExit(1); - exit(exitValue); - } - wait(NULL); + + deleteOutputOnInterrupt = False; return; } -# endif } - /*---------------------------------------------*/ static void uncompress ( Char *name ) @@ -2147,7 +2156,6 @@ setExit(1); exit(exitValue); } - printf("socketpair(): sv[0]:%d sv[1]:%d\n", sv[0], sv[1]); # endif if (opMode == OM_Z) { @@ -2195,7 +2203,7 @@ if (aa->name[0] == '-' && decode) continue; numFilesProcessed++; testf ( aa->name ); - } + } } if (testFailsExist && noisy) { fprintf ( stderr, From owner-svn-soc-all@FreeBSD.ORG Tue Jul 2 10:15:09 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 3A2182BC for ; Tue, 2 Jul 2013 10:15:09 +0000 (UTC) (envelope-from dpl@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 126DB127A for ; Tue, 2 Jul 2013 10:15:09 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r62AF8qf068677 for ; Tue, 2 Jul 2013 10:15:08 GMT (envelope-from dpl@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r62AF8UJ068675 for svn-soc-all@FreeBSD.org; Tue, 2 Jul 2013 10:15:08 GMT (envelope-from dpl@FreeBSD.org) Date: Tue, 2 Jul 2013 10:15:08 GMT Message-Id: <201307021015.r62AF8UJ068675@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to dpl@FreeBSD.org using -f From: dpl@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r253839 - soc2013/dpl/head/contrib/bzip2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Jul 2013 10:15:09 -0000 Author: dpl Date: Tue Jul 2 10:15:08 2013 New Revision: 253839 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=253839 Log: False alarm, sendfd actually returns now "Bad file descriptor" error. Modified: soc2013/dpl/head/contrib/bzip2/bzip2.c Modified: soc2013/dpl/head/contrib/bzip2/bzip2.c ============================================================================== --- soc2013/dpl/head/contrib/bzip2/bzip2.c Tue Jul 2 10:08:16 2013 (r253838) +++ soc2013/dpl/head/contrib/bzip2/bzip2.c Tue Jul 2 10:15:08 2013 (r253839) @@ -233,7 +233,7 @@ int sendfd(int s, int fd) { - printf("sendfd sending: %d", fd); + printf("sendfd sending: %d\n", fd); struct msghdr msg; struct cmsghdr *cmsg; struct iovec io[1]; @@ -243,7 +243,7 @@ io[0].iov_base = buf; io[0].iov_len = 1; - if( (cmsg = malloc(DATALEN) ) == NULL ) + if( (cmsg = malloc(DATALEN)) == NULL ) return -1; msg.msg_name = NULL; @@ -257,10 +257,8 @@ cmsg->cmsg_level = SOL_SOCKET; cmsg->cmsg_type = SCM_RIGHTS; *(int *)CMSG_DATA(cmsg) = fd; - if( (ret = sendmsg(s, &msg, 0)) <= 0){ - printf("sendmsg() returned: %d (%s)\n", ret, strerror(errno)); + if( (ret = sendmsg(s, &msg, 0)) <= 0) return -1; - } free(cmsg); return 0; } @@ -1409,7 +1407,7 @@ setExit(1); exit(exitValue); } else if ( forkpid != 0) { - + printf("Parent= infd:%d, outfd:%d\n", infd, outfd); if ((close(sv[0])) < 0){ fprintf ( stderr, "%s: Couldn't close fd: %s.\n", progName, strerror(errno) ); @@ -1417,7 +1415,7 @@ setExit(1); exit(exitValue); } - if ((closeinfd)) < 0){ + if ((close(infd)) < 0){ fprintf ( stderr, "%s: Couldn't close fd: %s.\n", progName, strerror(errno) ); setExit(1); @@ -1448,7 +1446,6 @@ exit(exitValue); } /* Let the children compress */ - wait(NULL); return; } else if (forkpid == 0){ From owner-svn-soc-all@FreeBSD.ORG Tue Jul 2 13:14:04 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 7254096F for ; Tue, 2 Jul 2013 13:14:04 +0000 (UTC) (envelope-from zcore@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 4A3EF1CB2 for ; Tue, 2 Jul 2013 13:14:04 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r62DE32U092210 for ; Tue, 2 Jul 2013 13:14:03 GMT (envelope-from zcore@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r62DE3Iw092209 for svn-soc-all@FreeBSD.org; Tue, 2 Jul 2013 13:14:03 GMT (envelope-from zcore@FreeBSD.org) Date: Tue, 2 Jul 2013 13:14:03 GMT Message-Id: <201307021314.r62DE3Iw092209@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to zcore@FreeBSD.org using -f From: zcore@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r253841 - soc2013/zcore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Jul 2013 13:14:04 -0000 Author: zcore Date: Tue Jul 2 13:14:03 2013 New Revision: 253841 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=253841 Log: Added: soc2013/zcore/ From owner-svn-soc-all@FreeBSD.ORG Tue Jul 2 13:16:50 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id C825AA22 for ; Tue, 2 Jul 2013 13:16:50 +0000 (UTC) (envelope-from zcore@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id A02CC1CD6 for ; Tue, 2 Jul 2013 13:16:50 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r62DGo5N093337 for ; Tue, 2 Jul 2013 13:16:50 GMT (envelope-from zcore@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r62DGo61093336 for svn-soc-all@FreeBSD.org; Tue, 2 Jul 2013 13:16:50 GMT (envelope-from zcore@FreeBSD.org) Date: Tue, 2 Jul 2013 13:16:50 GMT Message-Id: <201307021316.r62DGo61093336@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to zcore@FreeBSD.org using -f From: zcore@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r253842 - soc2013/zcore/head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Jul 2013 13:16:50 -0000 Author: zcore Date: Tue Jul 2 13:16:50 2013 New Revision: 253842 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=253842 Log: Added: soc2013/zcore/head/ (props changed) - copied from r253841, mirror/FreeBSD/head/ From owner-svn-soc-all@FreeBSD.ORG Wed Jul 3 16:05:54 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 4ECC597C for ; Wed, 3 Jul 2013 16:05:54 +0000 (UTC) (envelope-from dpl@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 2BA1F1667 for ; Wed, 3 Jul 2013 16:05:54 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r63G5sUk087476 for ; Wed, 3 Jul 2013 16:05:54 GMT (envelope-from dpl@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r63G5sTI087469 for svn-soc-all@FreeBSD.org; Wed, 3 Jul 2013 16:05:54 GMT (envelope-from dpl@FreeBSD.org) Date: Wed, 3 Jul 2013 16:05:54 GMT Message-Id: <201307031605.r63G5sTI087469@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to dpl@FreeBSD.org using -f From: dpl@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r253907 - soc2013/dpl/head/contrib/bzip2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Jul 2013 16:05:54 -0000 Author: dpl Date: Wed Jul 3 16:05:53 2013 New Revision: 253907 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=253907 Log: Stop passing fd, start using a new architecture. Modified: soc2013/dpl/head/contrib/bzip2/bzip2.c Modified: soc2013/dpl/head/contrib/bzip2/bzip2.c ============================================================================== --- soc2013/dpl/head/contrib/bzip2/bzip2.c Wed Jul 3 14:58:11 2013 (r253906) +++ soc2013/dpl/head/contrib/bzip2/bzip2.c Wed Jul 3 16:05:53 2013 (r253907) @@ -223,73 +223,7 @@ Int32 workFactor; #if CAPSICUM -int sv[2], len; - -int sendfd(int, int); -int recvfd(int); - -#define DATALEN CMSG_LEN(sizeof(int)) - -int -sendfd(int s, int fd) -{ - printf("sendfd sending: %d\n", fd); - struct msghdr msg; - struct cmsghdr *cmsg; - struct iovec io[1]; - char buf[1] = { "!" }; - int ret; - - io[0].iov_base = buf; - io[0].iov_len = 1; - - if( (cmsg = malloc(DATALEN)) == NULL ) - return -1; - - msg.msg_name = NULL; - msg.msg_namelen = 0; - msg.msg_iov = io; - msg.msg_iovlen = 1; - msg.msg_control =cmsg; - msg.msg_controllen = DATALEN; - - cmsg->cmsg_len = DATALEN; - cmsg->cmsg_level = SOL_SOCKET; - cmsg->cmsg_type = SCM_RIGHTS; - *(int *)CMSG_DATA(cmsg) = fd; - if( (ret = sendmsg(s, &msg, 0)) <= 0) - return -1; - free(cmsg); - return 0; -} - -int -recvfd(int s) -{ - int fd; - struct msghdr msg; - struct cmsghdr cmsg; - char buf[1] = { "!" }; - struct iovec io[1]; - - io[0].iov_base = buf; - io[0].iov_len = 1; - - msg.msg_name = NULL; - msg.msg_namelen = 0; - msg.msg_iov = io; - msg.msg_iovlen = 1; - msg.msg_control = &cmsg; - msg.msg_controllen = DATALEN; - - cmsg.cmsg_len = DATALEN; - cmsg.cmsg_level = SOL_SOCKET; - cmsg.cmsg_type = SCM_RIGHTS; - if(recvmsg(s, &msg, 0) < 0) - return -1; - fd = *(int *)CMSG_DATA(&cmsg); - return 0; -} +int capret; #endif static void panic ( const Char* ) NORETURN; @@ -1218,7 +1152,6 @@ FILE *outStr; Int32 n, i; # if CAPSICUM - Int32 infd, outfd; pid_t forkpid; # endif struct MY_STAT statBuf; @@ -1376,108 +1309,33 @@ } # if CAPSICUM - infd = dup(fileno(inStr)); - outfd = dup(fileno(outStr)); - if ( infd == -1 || outfd == -1){ - fprintf ( stderr, "%s: Couldn't close inStr: %s.\n", - progName, strerror(errno) ); - setExit(1); - exit(exitValue); - } - - cap_rights_limit(infd, CAP_READ); - cap_rights_limit(outfd, CAP_WRITE); - - if(fclose(inStr) < 0){ - fprintf ( stderr, "%s: Couldn't close inStr: %s.\n", - progName, strerror(errno) ); - setExit(1); - exit(exitValue); - } - if(fclose(outStr) < 0){ - fprintf ( stderr, "%s: Couldn't close outStr: %s.\n", - progName, strerror(errno) ); - setExit(1); - exit(exitValue); - } - /* Pass the limited file descriptors via unix domain socket. */ if ( (forkpid = fork()) == -1 ){ fprintf ( stderr, "%s: Couldn't fork: %s.\n", progName, strerror(errno) ); setExit(1); exit(exitValue); } else if ( forkpid != 0) { - printf("Parent= infd:%d, outfd:%d\n", infd, outfd); - if ((close(sv[0])) < 0){ - fprintf ( stderr, "%s: Couldn't close fd: %s.\n", - progName, strerror(errno) ); - wait(NULL); - setExit(1); - exit(exitValue); - } - if ((close(infd)) < 0){ - fprintf ( stderr, "%s: Couldn't close fd: %s.\n", - progName, strerror(errno) ); - setExit(1); - exit(exitValue); - } - if ((close(outfd)) < 0){ - fprintf ( stderr, "%s: Couldn't close fd: %s.\n", - progName, strerror(errno) ); - setExit(1); - exit(exitValue); - } - if (sendfd(sv[1], infd) < 0){ - fprintf ( stderr, "%s: Couldn't send infd: %s.\n", - progName, strerror(errno) ); - if (kill(forkpid, SIGTERM) < 0) - printf("Couldn't kill the child process, please press ^C\n"); - wait(NULL); - setExit(1); - exit(exitValue); - } - if (sendfd(sv[1], outfd) < 0){ - fprintf ( stderr, "%s: Couldn't send outfd: %s.\n", - progName, strerror(errno) ); - if (kill(forkpid, SIGTERM) < 0) - printf("Couldn't kill the child process, please press ^C\n"); - wait(NULL); - setExit(1); - exit(exitValue); - } /* Let the children compress */ + wait(NULL); return; } else if (forkpid == 0){ - if ((close(sv[1])) < 0){ - fprintf ( stderr, "%s: Couldn't close socket: %s.\n", - progName, strerror(errno) ); - setExit(1); - exit(exitValue); - } - if ((infd = recvfd(sv[0])) < 0){ - fprintf ( stderr, "%s: Couldn't get infd: %s.\n", - progName, strerror(errno) ); + capret = cap_rights_limit(fileno(inStr), CAP_READ); + capret |= cap_rights_limit(fileno(outStr), CAP_WRITE); + + if ( capret ){ + fprintf ( stderr, "%s: Couldn't enter capability mode: %s.\n", + progName, strerror(errno) ); setExit(1); exit(exitValue); - } - if ((outfd = recvfd(sv[0])) < 0){ - fprintf ( stderr, "%s: Couldn't get outfd: %s.\n", - progName, strerror(errno) ); + } + if (cap_enter() < 0){ + fprintf ( stderr, "%s: Couldn't enter capability mode: %s.\n", + progName, strerror(errno) ); setExit(1); exit(exitValue); - } - printf("Child: infd:%d, outfd:%d\n", infd, outfd); - inStr = fdopen(infd, "rb"); - outStr = fdopen(outfd, "wb"); - - if (cap_enter() < 0) { - fprintf ( stderr, "%s: Couldn't enter capability mode: %s.\n", - progName, strerror(errno) ); - setExit(1); - exit(exitValue); - } -# endif + } +# endif /*--- Now the input and output handles are sane. Do the Biz. ---*/ outputHandleJustInCase = outStr; deleteOutputOnInterrupt = True; @@ -1486,17 +1344,19 @@ /*--- If there was an I/O error, we won't get here. ---*/ if ( srcMode == SM_F2F ) { - applySavedTimeInfoToOutputFile ( outName ); - deleteOutputOnInterrupt = False; - if ( !keepInputFiles ) { - IntNative retVal = remove ( inName ); - ERROR_IF_NOT_ZERO ( retVal ); - } + applySavedTimeInfoToOutputFile ( outName ); + deleteOutputOnInterrupt = False; + if ( !keepInputFiles ) { + IntNative retVal = remove ( inName ); + ERROR_IF_NOT_ZERO ( retVal ); + } } deleteOutputOnInterrupt = False; - return; +# if CAPSICUM + exit(0); } +# endif } /*---------------------------------------------*/ @@ -2146,15 +2006,6 @@ # endif } -# if CAPSICUM - if ( socketpair(PF_LOCAL, SOCK_STREAM, 0, sv) < 0 ){ - fprintf (stderr, "%s: Can't create socket: %s.\n", - progName, strerror(errno) ); - setExit(1); - exit(exitValue); - } -# endif - if (opMode == OM_Z) { if (srcMode == SM_I2O) { compress ( NULL ); From owner-svn-soc-all@FreeBSD.ORG Thu Jul 4 17:20:48 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 4F508CFF for ; Thu, 4 Jul 2013 17:20:48 +0000 (UTC) (envelope-from dpl@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 310661271 for ; Thu, 4 Jul 2013 17:20:48 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r64HKm8F051445 for ; Thu, 4 Jul 2013 17:20:48 GMT (envelope-from dpl@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r64HKmCB051423 for svn-soc-all@FreeBSD.org; Thu, 4 Jul 2013 17:20:48 GMT (envelope-from dpl@FreeBSD.org) Date: Thu, 4 Jul 2013 17:20:48 GMT Message-Id: <201307041720.r64HKmCB051423@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to dpl@FreeBSD.org using -f From: dpl@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254040 - soc2013/dpl/head/contrib/bzip2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 Jul 2013 17:20:48 -0000 Author: dpl Date: Thu Jul 4 17:20:47 2013 New Revision: 254040 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254040 Log: Several architectural changes done, there's only setting the right FD capabilities left for bzip2. It works transparently without Capsicum. Starting with xz in the meanwhile. Modified: soc2013/dpl/head/contrib/bzip2/bzip2.c Modified: soc2013/dpl/head/contrib/bzip2/bzip2.c ============================================================================== --- soc2013/dpl/head/contrib/bzip2/bzip2.c Thu Jul 4 15:21:27 2013 (r254039) +++ soc2013/dpl/head/contrib/bzip2/bzip2.c Thu Jul 4 17:20:47 2013 (r254040) @@ -223,7 +223,11 @@ Int32 workFactor; #if CAPSICUM -int capret; +#define IN_FILENO fileno(outStr) +#define OUT_FILENO fileno(inStr) +void limitfd(int); +FILE *inStr; +FILE *outStr; #endif static void panic ( const Char* ) NORETURN; @@ -237,7 +241,7 @@ static void copyFileName ( Char*, Char* ); static void* myMalloc ( Int32 ); static void applySavedFileAttrToOutputFile ( IntNative fd ); - +static void setExit ( Int32 v ); /*---------------------------------------------------*/ @@ -669,6 +673,31 @@ if (v > exitValue) exitValue = v; } +#if CAPSICUM +/*---------------------------------------------*/ +void +limitfd(int fd) +{ + cap_rights_t rights = 0; + + if (fd == IN_FILENO) + rights |= CAP_READ; + else if (fd == OUT_FILENO) + rights |= CAP_WRITE; + else if (fd == STDERR_FILENO) + rights |= CAP_WRITE; + else + abort(); +/* + if (cap_rights_limit(fd, rights) < 0 && errno != ENOSYS){ + fprintf ( stderr, "%s: Couldn't limit rights for descriptor %d: %s.\n", + progName, fd, strerror(errno)); + setExit(1); + exit(exitValue); + } +*/ +} +#endif /*---------------------------------------------*/ static @@ -1148,12 +1177,14 @@ static void compress ( Char *name ) { +#ifndef CAPSICUM FILE *inStr; FILE *outStr; - Int32 n, i; -# if CAPSICUM +#endif +#if CAPSICUM pid_t forkpid; -# endif +#endif + Int32 n, i; struct MY_STAT statBuf; deleteOutputOnInterrupt = False; @@ -1309,7 +1340,7 @@ } # if CAPSICUM - /* Pass the limited file descriptors via unix domain socket. */ + /* Fork and compress in sandbox. */ if ( (forkpid = fork()) == -1 ){ fprintf ( stderr, "%s: Couldn't fork: %s.\n", progName, strerror(errno) ); setExit(1); @@ -1318,23 +1349,18 @@ /* Let the children compress */ wait(NULL); return; - } else if (forkpid == 0){ - capret = cap_rights_limit(fileno(inStr), CAP_READ); - capret |= cap_rights_limit(fileno(outStr), CAP_WRITE); - - if ( capret ){ - fprintf ( stderr, "%s: Couldn't enter capability mode: %s.\n", - progName, strerror(errno) ); - setExit(1); - exit(exitValue); - } + limitfd(fileno(inStr)); + limitfd(fileno(outStr)); + limitfd(STDERR_FILENO); +/* if (cap_enter() < 0){ fprintf ( stderr, "%s: Couldn't enter capability mode: %s.\n", progName, strerror(errno) ); setExit(1); exit(exitValue); } +*/ # endif /*--- Now the input and output handles are sane. Do the Biz. ---*/ outputHandleJustInCase = outStr; @@ -1363,8 +1389,13 @@ static void uncompress ( Char *name ) { +#ifndef CAPSICUM FILE *inStr; FILE *outStr; +#endif +#if CAPSICUM + pid_t forkpid; +#endif Int32 n, i; Bool magicNumberOK; Bool cantGuess; @@ -1516,44 +1547,71 @@ fflush ( stderr ); } - /*--- Now the input and output handles are sane. Do the Biz. ---*/ - outputHandleJustInCase = outStr; - deleteOutputOnInterrupt = True; - magicNumberOK = uncompressStream ( inStr, outStr ); - outputHandleJustInCase = NULL; - - /*--- If there was an I/O error, we won't get here. ---*/ - if ( magicNumberOK ) { - if ( srcMode == SM_F2F ) { - applySavedTimeInfoToOutputFile ( outName ); - deleteOutputOnInterrupt = False; - if ( !keepInputFiles ) { - IntNative retVal = remove ( inName ); - ERROR_IF_NOT_ZERO ( retVal ); - } - } - } else { - unzFailsExist = True; - deleteOutputOnInterrupt = False; - if ( srcMode == SM_F2F ) { - IntNative retVal = remove ( outName ); - ERROR_IF_NOT_ZERO ( retVal ); - } - } - deleteOutputOnInterrupt = False; - if ( magicNumberOK ) { - if (verbosity >= 1) - fprintf ( stderr, "done\n" ); - } else { - setExit(2); - if (verbosity >= 1) - fprintf ( stderr, "not a bzip2 file.\n" ); else - fprintf ( stderr, - "%s: %s is not a bzip2 file.\n", - progName, inName ); +# if CAPSICUM + /* Fork and compress in sandbox. */ + if ( (forkpid = fork()) == -1 ){ + fprintf ( stderr, "%s: Couldn't fork: %s.\n", progName, strerror(errno) ); + setExit(1); + exit(exitValue); + } else if ( forkpid != 0) { + /* Let the children compress */ + wait(NULL); + return; + } else if (forkpid == 0){ + limitfd(fileno(inStr)); + limitfd(fileno(outStr)); + limitfd(STDERR_FILENO); +/* + if (cap_enter() < 0){ + fprintf ( stderr, "%s: Couldn't enter capability mode: %s.\n", + progName, strerror(errno) ); + setExit(1); + exit(exitValue); + } +*/ +# endif + /*--- Now the input and output handles are sane. Do the Biz. ---*/ + outputHandleJustInCase = outStr; + deleteOutputOnInterrupt = True; + magicNumberOK = uncompressStream ( inStr, outStr ); + outputHandleJustInCase = NULL; + + /*--- If there was an I/O error, we won't get here. ---*/ + if ( magicNumberOK ) { + if ( srcMode == SM_F2F ) { + applySavedTimeInfoToOutputFile ( outName ); + deleteOutputOnInterrupt = False; + if ( !keepInputFiles ) { + IntNative retVal = remove ( inName ); + ERROR_IF_NOT_ZERO ( retVal ); + } + } + } else { + unzFailsExist = True; + deleteOutputOnInterrupt = False; + if ( srcMode == SM_F2F ) { + IntNative retVal = remove ( outName ); + ERROR_IF_NOT_ZERO ( retVal ); + } + } + deleteOutputOnInterrupt = False; + + if ( magicNumberOK ) { + if (verbosity >= 1) + fprintf ( stderr, "done\n" ); + } else { + setExit(2); + if (verbosity >= 1) + fprintf ( stderr, "not a bzip2 file.\n" ); else + fprintf ( stderr, + "%s: %s is not a bzip2 file.\n", + progName, inName ); + } +# if CAPSICUM + exit(0); } - +# endif } From owner-svn-soc-all@FreeBSD.ORG Fri Jul 5 00:59:10 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id CCB5A93D for ; Fri, 5 Jul 2013 00:59:10 +0000 (UTC) (envelope-from mattbw@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id BD76317B9 for ; Fri, 5 Jul 2013 00:59:10 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r650xAnQ085258 for ; Fri, 5 Jul 2013 00:59:10 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r650xAUS085252 for svn-soc-all@FreeBSD.org; Fri, 5 Jul 2013 00:59:10 GMT (envelope-from mattbw@FreeBSD.org) Date: Fri, 5 Jul 2013 00:59:10 GMT Message-Id: <201307050059.r650xAUS085252@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to mattbw@FreeBSD.org using -f From: mattbw@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254075 - in soc2013/mattbw/backend: . actions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Jul 2013 00:59:10 -0000 Author: mattbw Date: Fri Jul 5 00:59:10 2013 New Revision: 254075 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254075 Log: (builds, regresses) more work on the query system ready for querying to jobs. Modified: soc2013/mattbw/backend/actions/install-packages.c soc2013/mattbw/backend/pk-backend-pkgng.c soc2013/mattbw/backend/query.c soc2013/mattbw/backend/query.h soc2013/mattbw/backend/utils.h Modified: soc2013/mattbw/backend/actions/install-packages.c ============================================================================== --- soc2013/mattbw/backend/actions/install-packages.c Thu Jul 4 23:08:27 2013 (r254074) +++ soc2013/mattbw/backend/actions/install-packages.c Fri Jul 5 00:59:10 2013 (r254075) @@ -22,12 +22,15 @@ #include "../pk-backend.h" #include "pkg.h" +#include "../hash_traverse.h" /* HASH_FOR */ #include "../query.h" /* Package querying */ +#include "../utils.h" /* INTENTIONALLY_IGNORE */ #include "actions.h" /* install_packages_thread prototype */ static gboolean body(struct query *q); -/*static void emit(struct pkg *pkg, const gchar *id, PkBackend *backend);*/ +static void emit(struct pkg *pkg, const gchar *id, struct query *q); +static void job(struct pkg_jobs *jobs, struct query *q); /* * The thread that performs an InstallPackages operation. Should be invoked by @@ -36,6 +39,7 @@ gboolean install_packages_thread(PkBackend *backend) { + return query_for_all_ids(backend, PKG_LOAD_BASIC, body); } @@ -45,7 +49,45 @@ static gboolean body(struct query *q) { - /* TODO: actually install */ - pk_backend_error_code(query_backend(q), PK_ERROR_ENUM_NOT_SUPPORTED, NULL); - return FALSE; + + return query_emit_match(q, emit); +} + +/* + * Tries to install the given package. + */ +static void +emit(struct pkg *pkg, const gchar *id, struct query *q) +{ + + INTENTIONALLY_IGNORE(id); + return query_emit_to_job(pkg, q, PKG_JOBS_INSTALL, job); +} + +/* + * Tries to install the given package. + */ +static void +job(struct pkg_jobs *jobs, struct query *q) +{ + int err; + PkBackend *backend; + + backend = query_backend(q); + + err = pkg_jobs_solve(jobs); + if (err == EPKG_OK) { + struct pkg *pkg; + + pkg = NULL; + for (HASH_FOR(err, pkg_jobs, jobs, &pkg)) { + //pk_backend_package(backend, + // PK_INFO_ENUM_INSTALLING, + ; + + } + } else + pk_backend_error_code(backend, + PK_ERROR_ENUM_DEP_RESOLUTION_FAILED, + "could not solve the job"); } Modified: soc2013/mattbw/backend/pk-backend-pkgng.c ============================================================================== --- soc2013/mattbw/backend/pk-backend-pkgng.c Thu Jul 4 23:08:27 2013 (r254074) +++ soc2013/mattbw/backend/pk-backend-pkgng.c Fri Jul 5 00:59:10 2013 (r254075) @@ -29,11 +29,10 @@ #include "pk-backend.h" #include "pkg.h" +#include "utils.h" /* INTENTIONALLY_IGNORE */ #include "groups.h" /* available_groups */ #include "actions/actions.h" /* Actions threads */ -#define INTENTIONALLY_IGNORE(x) (void)(x) - /* static bodges */ static guint _progress_percentage = 0; static gulong _signal_timeout = 0; Modified: soc2013/mattbw/backend/query.c ============================================================================== --- soc2013/mattbw/backend/query.c Thu Jul 4 23:08:27 2013 (r254074) +++ soc2013/mattbw/backend/query.c Fri Jul 5 00:59:10 2013 (r254075) @@ -46,41 +46,35 @@ static const char *get_repo_of(struct pkg *pkg); static const char *get_repo_of_remote(struct pkg *pkg); static gboolean match(struct query *q, gchar **match_id_p, struct pkg **match_pkg_p); -static gboolean try_id_match(struct pkg *pkg, struct query *q, gchar **match_id); static gboolean match_id_in_it(struct pkgdb_it *it, struct query *q, gchar **match_id_p, struct pkg **match_pkg_p); +static gboolean try_id_match(struct pkg *pkg, struct query *q, gchar **match_id); +static int jobs_add_pkg(struct pkg_jobs *jobs, match_t type, struct pkg *pkg); static void query_free_contents(struct query *q); +static void query_pkg_to_id_through(struct pkg *pkg, gchar **name_p, const gchar **strv); /* Returns the backend stored inside the struct query. */ -PkBackend * +PkBackend * query_backend(struct query *q) { return (q == NULL ? NULL : q->backend); } -static gboolean -match_id_in_it(struct pkgdb_it *it, - struct query *q, - gchar **match_id_p, - struct pkg **match_pkg_p) +/* Converts a package to a PackageID. */ +void +query_pkg_to_id(struct pkg *pkg, gchar **id_p) { - /* TODO: Filters */ - gboolean found; - int err; - int load_flags; + const gchar **id_bits; - found = FALSE; - *match_pkg_p = NULL; - *match_id_p = NULL; - load_flags = q->load_flags; + /* Make sure the initial string vector's pointers are all NULL */ + id_bits = g_new0(const gchar *, 4); - for (HASH_FOR(err, pkgdb_it_next, it, match_pkg_p, load_flags)) { - if (try_id_match(*match_pkg_p, q, match_id_p) == TRUE) { - found = TRUE; - break; - } - } + /* This is split through an intermediate function so the same code + * can be used for the ID-checking logic. + */ + query_pkg_to_id_through(pkg, id_p, id_bits); - return found; + /* AFAIK we don't own any of the strings, so we don't use g_strfreev. */ + g_free(id_bits); } /* Gets the PackageKit repository name for the package. */ @@ -139,33 +133,82 @@ } static gboolean +match_id_in_it(struct pkgdb_it *it, + struct query *q, + gchar **match_id_p, + struct pkg **match_pkg_p) +{ + /* TODO: Filters */ + gboolean found; + int err; + int load_flags; + + found = FALSE; + *match_pkg_p = NULL; + *match_id_p = NULL; + load_flags = q->load_flags; + + for (HASH_FOR(err, pkgdb_it_next, it, match_pkg_p, load_flags)) { + if (try_id_match(*match_pkg_p, q, match_id_p) == TRUE) { + found = TRUE; + break; + } + } + + return found; +} + +static gboolean try_id_match(struct pkg *pkg, struct query *q, char **match_id) { - const char *p_arch; - const char *p_data; - const char *p_name; - const char *p_version; + gboolean cmp; + const gchar **pkg_id_bits; - pkg_get(pkg, - PKG_ARCH, &p_arch, - PKG_NAME, &p_name, - PKG_VERSION, &p_version); - - p_data = get_repo_of(pkg); - - if (*match_id != NULL) - g_free(*match_id); - *match_id = pk_package_id_build(p_name, p_version, p_arch, p_data); + pkg_id_bits = g_new0(const gchar *, 4); + query_pkg_to_id_through(pkg, match_id, pkg_id_bits); + /* * Succeed if this package's PackageID fields match the original * PackageID. Of course, the original ID might have missing fields * (NULLs), so we treat a comparison involving one as a success. */ - return (string_match(q->name, p_name) && - string_match(q->version, p_version) && - string_match(q->arch, p_arch) && - string_match(q->data, p_data)) ? TRUE : FALSE; + cmp = (string_match(q->name, pkg_id_bits[0]) && + string_match(q->version, pkg_id_bits[1]) && + string_match(q->arch, pkg_id_bits[2]) && + string_match(q->data, pkg_id_bits[3])) ? TRUE : FALSE; + g_free(pkg_id_bits); + + return cmp; +} + +/* Adds a single package to a jobs structure. */ +static int +jobs_add_pkg(struct pkg_jobs *jobs, match_t type, struct pkg *pkg) +{ + char *name; + + pkg_get(pkg, PKG_NAME, &name); + return pkg_jobs_add(jobs, type, &name, 1); +} + +/* Converts a package to a PackageID, dumping the intermediate information into + * the pointed-to string vector (which must have at least 4 places, and they + * should be NULL). + */ +static void +query_pkg_to_id_through(struct pkg *pkg, gchar **id_p, const gchar **strv) +{ + pkg_get(pkg, + PKG_NAME, strv, + PKG_ARCH, strv + 1, + PKG_VERSION, strv + 2); + + *(strv + 3) = get_repo_of(pkg); + + if (*id_p != NULL) + g_free(*id_p); + *id_p = pk_package_id_build(strv[0], strv[1], strv[2], strv[3]); } /* @@ -235,37 +278,43 @@ } /* - * Performs a package database query against a PackageID, and then adds the - * matching results to a pkg job. - * - * The round trip through the database seems like a strange idea given that - * pkg_jobs takes a package name. At the moment this is done to ensure that - * the package matches the PackageID fully. - * - * TODO: do something about the redundancy in both this and the emitter variant. - */ -/* - * // TODO: salvage something out of this gboolean emit_job(struct pkg *pkg, - * const gchar *id, struct query *q, pkg_jobs_t type, job_ptr user) { - * gboolean success; gchar *match_id; struct pkg *match_pkg; - * struct pkg_jobs *jobs; - * - * success = TRUE; jobs = NULL; - * - * q->load_flags = PKG_LOAD_BASIC; success = match(q, &match_id, &match_pkg); if - * (success == TRUE && match_id != NULL && match_pkg != NULL) { - * - * // Duplicated because pkg_jobs_add is not const correct. // gchar - * *name; int err; - * - * err = pkg_jobs_new(&jobs, type, q->db); if (err != EPKG_OK) { - * pk_backend_error_code(q->backend, PK_ERROR_ENUM_INTERNAL_ERROR, - * "pkg_jobs_new failed"); success = FALSE; } else { name = - * g_strdup(q->name); pkg_jobs_add(jobs, MATCH_EXACT, &name, 1); - * g_free(name); } pkg_free(match_pkg); g_free(match_id); - * - * return success; } + * For adapting an emitter function into one that solves and applies a job. */ +void +query_emit_to_job(struct pkg *pkg, + struct query *q, + pkg_jobs_t type, + job_emit_ptr job_emitter) +{ + int err; + struct pkg_jobs *jobs; + + jobs = NULL; + err = pkg_jobs_new(&jobs, type, q->db); + if (err == EPKG_OK) { + err = pkg_jobs_set_repository(jobs, q->data); + if (err == EPKG_OK) { + err = jobs_add_pkg(jobs, MATCH_EXACT, pkg); + if (err == EPKG_OK) + job_emitter(jobs, q); + else + pk_backend_error_code(q->backend, + PK_ERROR_ENUM_INTERNAL_ERROR, + "could not add to job"); + + } else + pk_backend_error_code(q->backend, + PK_ERROR_ENUM_INTERNAL_ERROR, + "could not set repo"); + + } else + pk_backend_error_code(q->backend, + PK_ERROR_ENUM_INTERNAL_ERROR, + "could not init pkg_jobs"); + + pkg_jobs_free(jobs); + +} /* * Performs a package database query against a (potentially partial) Modified: soc2013/mattbw/backend/query.h ============================================================================== --- soc2013/mattbw/backend/query.h Thu Jul 4 23:08:27 2013 (r254074) +++ soc2013/mattbw/backend/query.h Fri Jul 5 00:59:10 2013 (r254075) @@ -28,6 +28,7 @@ struct query; typedef void (*emit_ptr) (struct pkg *pkg, const gchar *id, struct query *q); +typedef void (*job_emit_ptr) (struct pkg_jobs *jobs, struct query *q); typedef gboolean (*query_body_ptr) (struct query *q); @@ -35,6 +36,8 @@ gboolean query_emit_match(struct query *q, emit_ptr emitter); gboolean query_for_all_ids(PkBackend *backend, int load_flags, query_body_ptr body); gboolean query_init(const gchar *id, PkBackend *backend, struct pkgdb *db, int load_flags, struct query **q_p); +void query_emit_to_job(struct pkg *pkg, struct query *q, pkg_jobs_t type, job_emit_ptr job_emitter); void query_free(struct query *q); +void query_pkg_to_id(struct pkg *pkg, gchar **id_p); #endif /* !_PKGNG_BACKEND_QUERY_H_ */ Modified: soc2013/mattbw/backend/utils.h ============================================================================== --- soc2013/mattbw/backend/utils.h Thu Jul 4 23:08:27 2013 (r254074) +++ soc2013/mattbw/backend/utils.h Fri Jul 5 00:59:10 2013 (r254075) @@ -24,6 +24,8 @@ #include /* gboolean */ +#define INTENTIONALLY_IGNORE(x) (void)(x) + const char *null_if_empty(const char *in); gboolean split_id(const char *id, From owner-svn-soc-all@FreeBSD.ORG Fri Jul 5 01:01:34 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id CF3FD9C2 for ; Fri, 5 Jul 2013 01:01:34 +0000 (UTC) (envelope-from mattbw@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id C0D2C17D9 for ; Fri, 5 Jul 2013 01:01:34 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6511YFb037703 for ; Fri, 5 Jul 2013 01:01:34 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6511YdL037694 for svn-soc-all@FreeBSD.org; Fri, 5 Jul 2013 01:01:34 GMT (envelope-from mattbw@FreeBSD.org) Date: Fri, 5 Jul 2013 01:01:34 GMT Message-Id: <201307050101.r6511YdL037694@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to mattbw@FreeBSD.org using -f From: mattbw@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254077 - soc2013/mattbw/tests/get-details-output MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Jul 2013 01:01:34 -0000 Author: mattbw Date: Fri Jul 5 01:01:34 2013 New Revision: 254077 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254077 Log: Added initial output test for GetDetails. Added: soc2013/mattbw/tests/get-details-output/ soc2013/mattbw/tests/get-details-output/Makefile soc2013/mattbw/tests/get-details-output/getcat.1 soc2013/mattbw/tests/get-details-output/getcat.c soc2013/mattbw/tests/get-details-output/strip_messages.awk soc2013/mattbw/tests/get-details-output/test-output.sh (contents, props changed) Added: soc2013/mattbw/tests/get-details-output/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/mattbw/tests/get-details-output/Makefile Fri Jul 5 01:01:34 2013 (r254077) @@ -0,0 +1,12 @@ +# $FreeBSD$ + +PROG= getcat +SRCS= getcat.c ../../backend/groups.c + +CFLAGS+= `pkgconf --cflags pkg glib-2.0` +CFLAGS+= -I/usr/local/include/PackageKit -I/usr/local/include/PackageKit/backend +CFLAGS+= -I../../backend +CFLAGS+= -DPK_COMPILATION +LDFLAGS+= `pkgconf --libs pkg glib-2.0` -lpackagekit-glib2 + +.include Added: soc2013/mattbw/tests/get-details-output/getcat.1 ============================================================================== Added: soc2013/mattbw/tests/get-details-output/getcat.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/mattbw/tests/get-details-output/getcat.c Fri Jul 5 01:01:34 2013 (r254077) @@ -0,0 +1,51 @@ +/*- + * + * Copyright (C) 2013 Matt Windsor + * + * Licensed under the GNU General Public License Version 2 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +/* + * Gets the group name of a pkgng origin, eg 'ports-mgmt/pkg' -> 'admin-tools'. + */ +const char *USAGE = "usage: %s origin\n"; + +#include + +#include +#include "pkg.h" +#include "pk-backend.h" + +#include "groups.h" + + +int +main(int argc, char **argv) +{ + int ret; + + ret = 0; + if (argc != 2) { + ret = 1; + fprintf(stderr, USAGE, argv[0]); + } else { + printf("%s\n", + pk_group_enum_to_string(group_from_origin(argv[1]))); + } + + return ret; +} Added: soc2013/mattbw/tests/get-details-output/strip_messages.awk ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/mattbw/tests/get-details-output/strip_messages.awk Fri Jul 5 01:01:34 2013 (r254077) @@ -0,0 +1,4 @@ +# Strips in-band auxiliary messages from a `pkcon` run, leaving only the results +BEGIN { in_description=0 } +!/Message:.*/ && in_description { print } +/Results:/ { in_description=1 } Added: soc2013/mattbw/tests/get-details-output/test-output.sh ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/mattbw/tests/get-details-output/test-output.sh Fri Jul 5 01:01:34 2013 (r254077) @@ -0,0 +1,59 @@ +#!/bin/sh + +# Tests pkcon against pkg to make sure the pkg backend works correctly for GetDetails. +# +# More black-box tests should be written later + +if [ $# -eq 1 ] +then + PACKAGE="$1" +else + PACKAGE="pkg" +fi + +echo "using package ${PACKAGE}" + +# Get the expected ABI through some invasive inspection of the pkg config dump +ARCH="`pkg -vv | grep ABI | sed 's/ *ABI: *//'`" + +CMD_GETCAT="./getcat" + +# Get the PackageKit group of the package +ORIGIN="`pkg query \"%o\" ${PACKAGE}`" +GROUP="`${CMD_GETCAT} ${ORIGIN}`" + +# Get the licences by mashing the `pkg query` licence list and or/and/single identifier +# into one "licence or licence or licence" string. +LICENSE=`\ + pkg query "%L %l" "${PACKAGE}" | # "licence or\nlicence or\n" + tr "\n" " " | # "licence or licence or ", note space + sed 's/ *[^ ]* *$//'` # "licence or licence" + +# Build a format string for the query that mocks up a pkcon GetDetails result +FMT="Package description + package: %n-%v.${ARCH} + license: ${LICENSE} + group: ${GROUP} + description: %e + size: %sb bytes + url: %w" + +# Now run both queries and diff them +PKG_FILE="${PACKAGE}-pkg" +PKCON_FILE="${PACKAGE}-pkcon" + +pkg query "${FMT}" "${PACKAGE}" > "${PKG_FILE}" +pkcon get-details "${PACKAGE};;;installed" | awk -f "strip_messages.awk" > "${PKCON_FILE}" + +DIFF="`diff -rupN \"${PACKAGE}-pkg\" \"${PACKAGE}-pkcon\"`" +if [ -n "${DIFF}" ] +then + echo "test failed with diff:" + echo "${DIFF}" + RETURN=1 +else + echo "test succeeded" + RETURN=0 +fi + +return $RETURN From owner-svn-soc-all@FreeBSD.ORG Fri Jul 5 01:11:57 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 6CD03B20 for ; Fri, 5 Jul 2013 01:11:57 +0000 (UTC) (envelope-from mattbw@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 4DF8E181A for ; Fri, 5 Jul 2013 01:11:57 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r651Bubx059215 for ; Fri, 5 Jul 2013 01:11:56 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r651Butf059212 for svn-soc-all@FreeBSD.org; Fri, 5 Jul 2013 01:11:56 GMT (envelope-from mattbw@FreeBSD.org) Date: Fri, 5 Jul 2013 01:11:56 GMT Message-Id: <201307050111.r651Butf059212@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to mattbw@FreeBSD.org using -f From: mattbw@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254078 - soc2013/mattbw/tests/get-details-output MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Jul 2013 01:11:57 -0000 Author: mattbw Date: Fri Jul 5 01:11:56 2013 New Revision: 254078 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254078 Log: clean up test a bit, add multiple package runner Added: soc2013/mattbw/tests/get-details-output/test-pkg.sh - copied unchanged from r254077, soc2013/mattbw/tests/get-details-output/test-output.sh soc2013/mattbw/tests/get-details-output/test.sh (contents, props changed) Deleted: soc2013/mattbw/tests/get-details-output/test-output.sh Copied: soc2013/mattbw/tests/get-details-output/test-pkg.sh (from r254077, soc2013/mattbw/tests/get-details-output/test-output.sh) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/mattbw/tests/get-details-output/test-pkg.sh Fri Jul 5 01:11:56 2013 (r254078, copy of r254077, soc2013/mattbw/tests/get-details-output/test-output.sh) @@ -0,0 +1,59 @@ +#!/bin/sh + +# Tests pkcon against pkg to make sure the pkg backend works correctly for GetDetails. +# +# More black-box tests should be written later + +if [ $# -eq 1 ] +then + PACKAGE="$1" +else + PACKAGE="pkg" +fi + +echo "using package ${PACKAGE}" + +# Get the expected ABI through some invasive inspection of the pkg config dump +ARCH="`pkg -vv | grep ABI | sed 's/ *ABI: *//'`" + +CMD_GETCAT="./getcat" + +# Get the PackageKit group of the package +ORIGIN="`pkg query \"%o\" ${PACKAGE}`" +GROUP="`${CMD_GETCAT} ${ORIGIN}`" + +# Get the licences by mashing the `pkg query` licence list and or/and/single identifier +# into one "licence or licence or licence" string. +LICENSE=`\ + pkg query "%L %l" "${PACKAGE}" | # "licence or\nlicence or\n" + tr "\n" " " | # "licence or licence or ", note space + sed 's/ *[^ ]* *$//'` # "licence or licence" + +# Build a format string for the query that mocks up a pkcon GetDetails result +FMT="Package description + package: %n-%v.${ARCH} + license: ${LICENSE} + group: ${GROUP} + description: %e + size: %sb bytes + url: %w" + +# Now run both queries and diff them +PKG_FILE="${PACKAGE}-pkg" +PKCON_FILE="${PACKAGE}-pkcon" + +pkg query "${FMT}" "${PACKAGE}" > "${PKG_FILE}" +pkcon get-details "${PACKAGE};;;installed" | awk -f "strip_messages.awk" > "${PKCON_FILE}" + +DIFF="`diff -rupN \"${PACKAGE}-pkg\" \"${PACKAGE}-pkcon\"`" +if [ -n "${DIFF}" ] +then + echo "test failed with diff:" + echo "${DIFF}" + RETURN=1 +else + echo "test succeeded" + RETURN=0 +fi + +return $RETURN Added: soc2013/mattbw/tests/get-details-output/test.sh ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/mattbw/tests/get-details-output/test.sh Fri Jul 5 01:11:56 2013 (r254078) @@ -0,0 +1,13 @@ +#!/bin/sh + +# Main test runner for the GetDetails output test. + +while read LINE +do + ./test-pkg.sh "${LINE}" + if [ $? -ne 0 ] + then + echo "tests failed" + exit 1 + fi +done < "test-pkgs" From owner-svn-soc-all@FreeBSD.ORG Fri Jul 5 02:12:23 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 14A14532 for ; Fri, 5 Jul 2013 02:12:23 +0000 (UTC) (envelope-from mattbw@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id EA29B19EE for ; Fri, 5 Jul 2013 02:12:22 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r652CMgw006337 for ; Fri, 5 Jul 2013 02:12:22 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r652CM2K006327 for svn-soc-all@FreeBSD.org; Fri, 5 Jul 2013 02:12:22 GMT (envelope-from mattbw@FreeBSD.org) Date: Fri, 5 Jul 2013 02:12:22 GMT Message-Id: <201307050212.r652CM2K006327@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to mattbw@FreeBSD.org using -f From: mattbw@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254090 - soc2013/mattbw/backend MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Jul 2013 02:12:23 -0000 Author: mattbw Date: Fri Jul 5 02:12:22 2013 New Revision: 254090 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254090 Log: (fixed?) rearranged and corrected the packageID checks; string_match now works on empty strings as well as null ones so strv comparisons work directly Modified: soc2013/mattbw/backend/query.c soc2013/mattbw/backend/query.h soc2013/mattbw/backend/utils.c Modified: soc2013/mattbw/backend/query.c ============================================================================== --- soc2013/mattbw/backend/query.c Fri Jul 5 01:53:51 2013 (r254089) +++ soc2013/mattbw/backend/query.c Fri Jul 5 02:12:22 2013 (r254090) @@ -59,156 +59,27 @@ return (q == NULL ? NULL : q->backend); } -/* Converts a package to a PackageID. */ -void -query_pkg_to_id(struct pkg *pkg, gchar **id_p) -{ - const gchar **id_bits; - - /* Make sure the initial string vector's pointers are all NULL */ - id_bits = g_new0(const gchar *, 4); - - /* This is split through an intermediate function so the same code - * can be used for the ID-checking logic. - */ - query_pkg_to_id_through(pkg, id_p, id_bits); - - /* AFAIK we don't own any of the strings, so we don't use g_strfreev. */ - g_free(id_bits); -} - -/* Gets the PackageKit repository name for the package. */ -static const char * -get_repo_of(struct pkg *pkg) -{ - const char *repo; - - switch (pkg_type(pkg)) { - case PKG_FILE: - repo = "local"; - break; - case PKG_INSTALLED: - repo = "installed"; - break; - case PKG_REMOTE: - repo = get_repo_of_remote(pkg); - break; - default: - repo = "unknown"; - break; - } - - return repo; -} - /* - * Gets the PackageKit repository name for the (remote) package. - * - * Currently this is actually the pkgng repository ident. This might change. - * - * This does not need to be freed (possibly, TODO: check). + * Performs a package database query against a PackageID, and then hands the + * matching result to an emitter function. */ -static const char * -get_repo_of_remote(struct pkg *pkg) -{ - const char *repo; - const char *repo_name; - struct pkg_repo *repo_struct; - - repo = NULL; - - /* - * We can get the repo NAME directly, but we need the repo IDENT. - * Short of chopping bits of the string off in the assumption that - * the name is repo-IDENT, we'll have to grab it from the repo - * structure itself. - */ - pkg_get(pkg, PKG_REPONAME, &repo_name); - - repo_struct = pkg_repo_find_name(repo_name); - if (repo_struct) - repo = pkg_repo_ident(repo_struct); - - return repo; -} - -static gboolean -match_id_in_it(struct pkgdb_it *it, - struct query *q, - gchar **match_id_p, - struct pkg **match_pkg_p) -{ - /* TODO: Filters */ - gboolean found; - int err; - int load_flags; - - found = FALSE; - *match_pkg_p = NULL; - *match_id_p = NULL; - load_flags = q->load_flags; - - for (HASH_FOR(err, pkgdb_it_next, it, match_pkg_p, load_flags)) { - if (try_id_match(*match_pkg_p, q, match_id_p) == TRUE) { - found = TRUE; - break; - } - } - - return found; -} - -static gboolean -try_id_match(struct pkg *pkg, struct query *q, char **match_id) -{ - gboolean cmp; - const gchar **pkg_id_bits; - - pkg_id_bits = g_new0(const gchar *, 4); - query_pkg_to_id_through(pkg, match_id, pkg_id_bits); - - - /* - * Succeed if this package's PackageID fields match the original - * PackageID. Of course, the original ID might have missing fields - * (NULLs), so we treat a comparison involving one as a success. - */ - cmp = (string_match(q->name, pkg_id_bits[0]) && - string_match(q->version, pkg_id_bits[1]) && - string_match(q->arch, pkg_id_bits[2]) && - string_match(q->data, pkg_id_bits[3])) ? TRUE : FALSE; - g_free(pkg_id_bits); - - return cmp; -} - -/* Adds a single package to a jobs structure. */ -static int -jobs_add_pkg(struct pkg_jobs *jobs, match_t type, struct pkg *pkg) +gboolean +query_emit_match(struct query *q, emit_ptr emitter) { - char *name; - - pkg_get(pkg, PKG_NAME, &name); - return pkg_jobs_add(jobs, type, &name, 1); -} + gboolean success; + gchar *match_id; + struct pkg *match_pkg; -/* Converts a package to a PackageID, dumping the intermediate information into - * the pointed-to string vector (which must have at least 4 places, and they - * should be NULL). - */ -static void -query_pkg_to_id_through(struct pkg *pkg, gchar **id_p, const gchar **strv) -{ - pkg_get(pkg, - PKG_NAME, strv, - PKG_ARCH, strv + 1, - PKG_VERSION, strv + 2); + match_id = NULL; + match_pkg = NULL; + success = match(q, &match_id, &match_pkg); + if (success == TRUE && match_id != NULL && match_pkg != NULL) + emitter(match_pkg, match_id, q); - *(strv + 3) = get_repo_of(pkg); + pkg_free(match_pkg); + g_free(match_id); - if (*id_p != NULL) - g_free(*id_p); - *id_p = pk_package_id_build(strv[0], strv[1], strv[2], strv[3]); + return success; } /* @@ -254,26 +125,71 @@ return no_error_yet; } -/* - * Performs a package database query against a PackageID, and then hands the - * matching result to an emitter function. - */ +/* Creates a struct query for the given backend and target ID. */ gboolean -query_emit_match(struct query *q, emit_ptr emitter) +query_init(const gchar *id, + PkBackend *backend, + struct pkgdb *db, + int load_flags, + struct query **q_p) { gboolean success; - gchar *match_id; - struct pkg *match_pkg; + gboolean loading_files; + struct query *q; - match_id = NULL; - match_pkg = NULL; - success = match(q, &match_id, &match_pkg); - if (success == TRUE && match_id != NULL && match_pkg != NULL) - emitter(match_pkg, match_id, q); + q = *q_p; + if (q == NULL) + q = g_new0(struct query, 1); + else + query_free_contents(q); - pkg_free(match_pkg); - g_free(match_id); + q->backend = backend; + q->load_flags = load_flags; + q->db = db; + + success = split_id(id, + &(q->strv), + &(q->name), + &(q->version), + &(q->arch), + &(q->data)); + if (success == FALSE) + pk_backend_error_code(backend, + PK_ERROR_ENUM_PACKAGE_ID_INVALID, + "invalid package id"); + /* + * Check the repository to make sure it's sane, and populate the repo + * type flags in the state for later consumption. + */ + if (success == TRUE) { + if (q->data == NULL) + q->any_repo = TRUE; + else if (strcmp(q->data, "installed") == 0) + q->local_repo = TRUE; + else if (pkg_repo_find_ident(q->data) == NULL) { + pk_backend_error_code(backend, + PK_ERROR_ENUM_PACKAGE_ID_INVALID, + "no such repository"); + success = FALSE; + } + } + /* + * Stop pkg from catching fire if we try to load files from + * non-installed packages. + */ + loading_files = (load_flags & PKG_LOAD_FILES) ? TRUE : FALSE; + if (success == TRUE && q->local_repo == FALSE && loading_files) { + pk_backend_error_code(backend, + PK_ERROR_ENUM_CANNOT_GET_FILELIST, + "cannot get files for remote package"); + success = FALSE; + } + if (success == FALSE) { + query_free(q); + q = NULL; + } + *q_p = q; return success; } @@ -316,6 +232,90 @@ } +/* Deallocates a struct query and any contents it owns. */ +void +query_free(struct query *q) +{ + if (q != NULL) { + query_free_contents(q); + g_free(q); + } +} + +/* Converts a package to a PackageID. */ +void +query_pkg_to_id(struct pkg *pkg, gchar **id_p) +{ + const gchar **id_bits; + + /* Make sure the initial string vector's pointers are all NULL */ + id_bits = g_new0(const gchar *, 4); + + /* + * This is split through an intermediate function so the same code + * can be used for the ID-checking logic. + */ + query_pkg_to_id_through(pkg, id_p, id_bits); + + /* we don't own any of the strings, so we don't use g_strfreev. */ + g_free(id_bits); +} + +/* Gets the PackageKit repository name for the package. */ +static const char * +get_repo_of(struct pkg *pkg) +{ + const char *repo; + + switch (pkg_type(pkg)) { + case PKG_FILE: + repo = "local"; + break; + case PKG_INSTALLED: + repo = "installed"; + break; + case PKG_REMOTE: + repo = get_repo_of_remote(pkg); + break; + default: + repo = "unknown"; + break; + } + + return repo; +} + +/* + * Gets the PackageKit repository name for the (remote) package. + * + * Currently this is actually the pkgng repository ident. This might change. + * + * This does not need to be freed (possibly, TODO: check). + */ +static const char * +get_repo_of_remote(struct pkg *pkg) +{ + const char *repo; + const char *repo_name; + struct pkg_repo *repo_struct; + + repo = NULL; + + /* + * We can get the repo NAME directly, but we need the repo IDENT. + * Short of chopping bits of the string off in the assumption that + * the name is repo-IDENT, we'll have to grab it from the repo + * structure itself. + */ + pkg_get(pkg, PKG_REPONAME, &repo_name); + + repo_struct = pkg_repo_find_name(repo_name); + if (repo_struct) + repo = pkg_repo_ident(repo_struct); + + return repo; +} + /* * Performs a package database query against a (potentially partial) * PackageID, retrieving the matched package and its full PackageID. @@ -374,81 +374,85 @@ return success; } -/* Creates a struct query for the given backend and target ID. */ -gboolean -query_init(const gchar *id, - PkBackend *backend, - struct pkgdb *db, - int load_flags, - struct query **q_p) +static gboolean +match_id_in_it(struct pkgdb_it *it, + struct query *q, + gchar **match_id_p, + struct pkg **match_pkg_p) { - gboolean success; - gboolean loading_files; - struct query *q; + /* TODO: Filters */ + int err; + int load_flags; - q = *q_p; - if (q == NULL) - q = g_new0(struct query, 1); - else - query_free_contents(q); + *match_pkg_p = NULL; + *match_id_p = NULL; + load_flags = q->load_flags; - q->backend = backend; - q->load_flags = load_flags; - q->db = db; + for (HASH_FOR(err, pkgdb_it_next, it, match_pkg_p, load_flags)) + if (try_id_match(*match_pkg_p, q, match_id_p) == TRUE) + break; - success = split_id(id, - &(q->strv), - &(q->name), - &(q->version), - &(q->arch), - &(q->data)); - if (success == FALSE) - pk_backend_error_code(backend, - PK_ERROR_ENUM_PACKAGE_ID_INVALID, - "invalid package id"); + return (err == EPKG_OK && *match_id_p != NULL) ? TRUE : FALSE; +} + +static gboolean +try_id_match(struct pkg *pkg, struct query *q, char **match_id) +{ + gboolean matches; + int i; + const gchar **pkg_id_bits; + + pkg_id_bits = g_new0(const gchar *, 4); + query_pkg_to_id_through(pkg, match_id, pkg_id_bits); /* - * Check the repository to make sure it's sane, and populate the repo - * type flags in the state for later consumption. - */ - if (success == TRUE) { - if (q->data == NULL) - q->any_repo = TRUE; - else if (strcmp(q->data, "installed") == 0) - q->local_repo = TRUE; - else if (pkg_repo_find_ident(q->data) == NULL) { - pk_backend_error_code(backend, - PK_ERROR_ENUM_PACKAGE_ID_INVALID, - "no such repository"); - success = FALSE; - } - } - /* - * Stop pkg from catching fire if we try to load files from - * non-installed packages. + * Succeed if this package's PackageID fields match the original + * PackageID. Of course, the original ID might have missing fields + * (NULLs), so we treat a comparison involving one as a success. + * This means using our "weak strcmp" instead of normal strcmp or even + * g_strcmp0. */ - loading_files = (load_flags & PKG_LOAD_FILES) ? TRUE : FALSE; - if (success == TRUE && q->local_repo == FALSE && loading_files) { - pk_backend_error_code(backend, - PK_ERROR_ENUM_CANNOT_GET_FILELIST, - "cannot get files for remote package"); - success = FALSE; - } - if (success == FALSE) { - query_free(q); - q = NULL; - } - *q_p = q; - return success; + for (matches = TRUE, i = PK_PACKAGE_ID_NAME; + matches == TRUE && i <= PK_PACKAGE_ID_DATA; + i++) + matches = string_match((q->strv)[i], pkg_id_bits[i]); + + g_free(pkg_id_bits); + return matches; } -void -query_free(struct query *q) +/* Adds a single package to a jobs structure. */ +static int +jobs_add_pkg(struct pkg_jobs *jobs, match_t type, struct pkg *pkg) { - if (q != NULL) { - query_free_contents(q); - g_free(q); - } + char *name; + + pkg_get(pkg, PKG_NAME, &name); + return pkg_jobs_add(jobs, type, &name, 1); +} + +/* + * Converts a package to a PackageID, dumping the intermediate information + * into the pointed-to string vector (which must have at least 4 places, and + * they should be NULL). + */ +static void +query_pkg_to_id_through(struct pkg *pkg, gchar **id_p, const gchar **strv) +{ + + pkg_get(pkg, + PKG_NAME, strv + PK_PACKAGE_ID_NAME, + PKG_VERSION, strv + PK_PACKAGE_ID_VERSION, + PKG_ARCH, strv + PK_PACKAGE_ID_ARCH); + + strv[PK_PACKAGE_ID_DATA] = get_repo_of(pkg); + + if (*id_p != NULL) + g_free(*id_p); + *id_p = pk_package_id_build(strv[PK_PACKAGE_ID_NAME], + strv[PK_PACKAGE_ID_VERSION], + strv[PK_PACKAGE_ID_ARCH], + strv[PK_PACKAGE_ID_DATA]); } static void Modified: soc2013/mattbw/backend/query.h ============================================================================== --- soc2013/mattbw/backend/query.h Fri Jul 5 01:53:51 2013 (r254089) +++ soc2013/mattbw/backend/query.h Fri Jul 5 02:12:22 2013 (r254090) @@ -31,7 +31,6 @@ typedef void (*job_emit_ptr) (struct pkg_jobs *jobs, struct query *q); typedef gboolean (*query_body_ptr) (struct query *q); - PkBackend *query_backend(struct query *q); gboolean query_emit_match(struct query *q, emit_ptr emitter); gboolean query_for_all_ids(PkBackend *backend, int load_flags, query_body_ptr body); Modified: soc2013/mattbw/backend/utils.c ============================================================================== --- soc2013/mattbw/backend/utils.c Fri Jul 5 01:53:51 2013 (r254089) +++ soc2013/mattbw/backend/utils.c Fri Jul 5 02:12:22 2013 (r254090) @@ -78,7 +78,7 @@ /* * Checks two strings with strcmp and emits TRUE if they match. If either - * string is NULL, emit TRUE as well (this is so that missing PackageID + * string is NULL or empty, emit TRUE as well (this is so that missing PackageID * elements trigger matches). */ gboolean @@ -88,6 +88,8 @@ if (left == NULL || right == NULL) result = TRUE; + else if (*left == '\0' || *right == '\0') + result = TRUE; else result = (strcmp(left, right) == 0 ? TRUE : FALSE); From owner-svn-soc-all@FreeBSD.ORG Fri Jul 5 02:34:28 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id D0FDC742 for ; Fri, 5 Jul 2013 02:34:28 +0000 (UTC) (envelope-from mattbw@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id C29121AA5 for ; Fri, 5 Jul 2013 02:34:28 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r652YShc087273 for ; Fri, 5 Jul 2013 02:34:28 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r652YSLB087267 for svn-soc-all@FreeBSD.org; Fri, 5 Jul 2013 02:34:28 GMT (envelope-from mattbw@FreeBSD.org) Date: Fri, 5 Jul 2013 02:34:28 GMT Message-Id: <201307050234.r652YSLB087267@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to mattbw@FreeBSD.org using -f From: mattbw@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254091 - soc2013/mattbw MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Jul 2013 02:34:28 -0000 Author: mattbw Date: Fri Jul 5 02:34:28 2013 New Revision: 254091 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254091 Log: Added README. Added: soc2013/mattbw/README Added: soc2013/mattbw/README ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/mattbw/README Fri Jul 5 02:34:28 2013 (r254091) @@ -0,0 +1,69 @@ +PackageKit backend for pkgng +http://wiki.freebsd.org/SummerOfCode2013/pkgPackagekit +-------------------------------------------------------------------------------- + +This is a Google Summer of Code project to create a PackageKit backend for the +FreeBSD pkgng package manager. + +It is licenced under the GNU General Public License version 2+ (this is because +it links to PackageKit itself, which is under this licence). + +-------------------------------------------------------------------------------- + +REQUIREMENTS + +- PackageKit (currently building against version 0.6.11; the code MAY work with + versions 0.7.x but WILL NOT YET work with 0.8.x due to API incompatibilities) +- pkgng (currently building against version 1.1.3; higher versions might work) +- FreeBSD (tested with 9.1; should work with higher versions) + +Tested primarily with clang in C99 mode; C89 mode likely will not work and C11 +would not work due to header file problems. GNU extensions probably won't break +the build. + +-------------------------------------------------------------------------------- + +COMPILING + +This backend currently builds using the BSD make system. Using GNU Make (gmake) +will *not* work. (Porting to GNU Autotools is an exercise for the reader.) + +To compile and install the backend: + - Ensure you have the correct versions of PackageKit and pkgng installed as + directed above. + - Run `make`, or some variation thereon, in the 'backend' directory. + (I prefer to run `scan-build --use-cc=clang33 make` with WARNS=7 set, but + this involves clang33 being installed.) + - Run `make install` as root to install the backend into PackageKit's backends + directory. + - Edit /usr/local/PackageKit/PackageKit.conf such that "DefaultBackend=pkgng" + (or manually invoke packagekitd with backend=pkgng). + +-------------------------------------------------------------------------------- + +TESTING + +Currently, testing facilities are very limited. Testing will likely occur in +full after the basic featureset has been roughly implemented. + +There is currently one test, in the tests/get-details-output directory; this +checks the GetDetails output from pkcon against a mockup built from `pkg query` +to make sure it outputs sane data. At the time of writing, it is not finished, +but to run it cd to that directory, run `make`, ensure `pkcon` is set up to use +pkgng as its backend, then run `./test.sh`. + +-------------------------------------------------------------------------------- + +KNOWN BUGS + +- InstallPackages is not yet fully implemented. +- Licence emitting is broken; it currently emits only the first licence in a + licence chain, rather than the entire set of licences. +- Minor cosmetic issues (progress bars not updating properly, etc.) may exist. + +-------------------------------------------------------------------------------- + +CONTACT DETAILS + +Student: Matt Windsor +Mentor: Julien Laffaye From owner-svn-soc-all@FreeBSD.ORG Fri Jul 5 20:17:07 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 5DCD857A for ; Fri, 5 Jul 2013 20:17:07 +0000 (UTC) (envelope-from mattbw@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 3EFCE10CC for ; Fri, 5 Jul 2013 20:17:07 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r65KH6Fr052012 for ; Fri, 5 Jul 2013 20:17:06 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r65KH6H5052006 for svn-soc-all@FreeBSD.org; Fri, 5 Jul 2013 20:17:06 GMT (envelope-from mattbw@FreeBSD.org) Date: Fri, 5 Jul 2013 20:17:06 GMT Message-Id: <201307052017.r65KH6H5052006@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to mattbw@FreeBSD.org using -f From: mattbw@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254178 - in soc2013/mattbw/backend: . actions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Jul 2013 20:17:07 -0000 Author: mattbw Date: Fri Jul 5 20:17:06 2013 New Revision: 254178 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254178 Log: use sbufs instead of GLib for composing the filename list Modified: soc2013/mattbw/backend/actions/get-files.c soc2013/mattbw/backend/hash_traverse.h soc2013/mattbw/backend/utils.c soc2013/mattbw/backend/utils.h Modified: soc2013/mattbw/backend/actions/get-files.c ============================================================================== --- soc2013/mattbw/backend/actions/get-files.c Fri Jul 5 19:57:40 2013 (r254177) +++ soc2013/mattbw/backend/actions/get-files.c Fri Jul 5 20:17:06 2013 (r254178) @@ -19,6 +19,8 @@ */ #include +#include + #include "../pk-backend.h" #include "pkg.h" @@ -63,34 +65,29 @@ { struct pkg_file *file; int err; + int sb_err; + struct sbuf *sb; - gchar **filenames; - gchar *joined_filenames; - gint capacity; - gint i; - - /* - * Start off with a small array to hold the file names, and expand it - * if needs be. - */ - capacity = FILE_NAME_STEP; - i = 0; - file = NULL; - filenames = g_new(gchar *, capacity); - for (HASH_FOR(err, pkg_files, pkg, &file)) { - /* Out of capacity (leaving a NULL)? Expand the array. */ - if (i >= (capacity - 1)) { - capacity += FILE_NAME_STEP; - filenames = g_renew(gchar *, filenames, capacity); - } - filenames[i] = g_strdup(pkg_file_path(file)); - i++; + /* Construct a string of the form ";file1;file2;file3;...". + * We'll get rid of the initial ; later. + */ + sb = sbuf_new_auto(); + for (HASH_FOR(err, pkg_files, pkg, &file)) + sbuf_printf(sb, ";%s", pkg_file_path(file)); + sb_err = sbuf_finish(sb); + if (sb_err) + pk_backend_error_code(query_backend(q), + PK_ERROR_ENUM_INTERNAL_ERROR, + "couldn't construct filename string"); + else { + char *filenames; + + filenames = sbuf_data(sb); + /* Skip over any initial ;*/ + if (filenames[0] == ';') + filenames++; + + pk_backend_files(query_backend(q), id, filenames); } - filenames[i] = NULL; - - joined_filenames = g_strjoinv(";", filenames); - g_strfreev(filenames); - - pk_backend_files(query_backend(q), id, joined_filenames); - g_free(joined_filenames); + sbuf_delete(sb); } Modified: soc2013/mattbw/backend/hash_traverse.h ============================================================================== --- soc2013/mattbw/backend/hash_traverse.h Fri Jul 5 19:57:40 2013 (r254177) +++ soc2013/mattbw/backend/hash_traverse.h Fri Jul 5 20:17:06 2013 (r254178) @@ -21,7 +21,8 @@ #ifndef _PKGNG_BACKEND_HASH_TRAVERSE_H_ #define _PKGNG_BACKEND_HASH_TRAVERSE_H_ +/* for loop body for pkgng iterators. */ #define HASH_FOR(err, hash, ...) \ (err) = hash(__VA_ARGS__); (err) == EPKG_OK; (err) = hash(__VA_ARGS__) - + #endif /* !_PKGNG_BACKEND_HASH_TRAVERSE_H_ */ Modified: soc2013/mattbw/backend/utils.c ============================================================================== --- soc2013/mattbw/backend/utils.c Fri Jul 5 19:57:40 2013 (r254177) +++ soc2013/mattbw/backend/utils.c Fri Jul 5 20:17:06 2013 (r254178) @@ -78,8 +78,8 @@ /* * Checks two strings with strcmp and emits TRUE if they match. If either - * string is NULL or empty, emit TRUE as well (this is so that missing PackageID - * elements trigger matches). + * string is NULL or empty, emit TRUE as well (this is so that missing + * PackageID elements trigger matches). */ gboolean string_match(const char *left, const char *right) Modified: soc2013/mattbw/backend/utils.h ============================================================================== --- soc2013/mattbw/backend/utils.h Fri Jul 5 19:57:40 2013 (r254177) +++ soc2013/mattbw/backend/utils.h Fri Jul 5 20:17:06 2013 (r254178) @@ -36,5 +36,4 @@ const char **data_p); gboolean string_match(const char *left, const char *right); - #endif /* !_PKGNG_BACKEND_DETAILS_H_ */ From owner-svn-soc-all@FreeBSD.ORG Fri Jul 5 20:48:47 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id D04F5ECE for ; Fri, 5 Jul 2013 20:48:47 +0000 (UTC) (envelope-from mattbw@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id A70011231 for ; Fri, 5 Jul 2013 20:48:47 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r65Kml3V003288 for ; Fri, 5 Jul 2013 20:48:47 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r65KmlZr003280 for svn-soc-all@FreeBSD.org; Fri, 5 Jul 2013 20:48:47 GMT (envelope-from mattbw@FreeBSD.org) Date: Fri, 5 Jul 2013 20:48:47 GMT Message-Id: <201307052048.r65KmlZr003280@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to mattbw@FreeBSD.org using -f From: mattbw@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254179 - soc2013/mattbw/backend MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Jul 2013 20:48:47 -0000 Author: mattbw Date: Fri Jul 5 20:48:47 2013 New Revision: 254179 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254179 Log: license conjunctions implemented, first test passes! (next: implement install, refine test) Modified: soc2013/mattbw/backend/licenses.c soc2013/mattbw/backend/licenses.h Modified: soc2013/mattbw/backend/licenses.c ============================================================================== --- soc2013/mattbw/backend/licenses.c Fri Jul 5 20:17:06 2013 (r254178) +++ soc2013/mattbw/backend/licenses.c Fri Jul 5 20:48:47 2013 (r254179) @@ -18,27 +18,59 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#include /* errno */ +#include /* strdup, strlen, strerror */ + #include "pkg.h" /* struct pkg, etc */ #include "pk-backend.h" /* PkLicenseEnum, PK_* */ +#include "hash_traverse.h" /* HASH_FOR */ #include "licenses.h" /* prototypes */ -/* Retrieves the name of the FIRST license attached to the package. */ -const char * +/* + * Retrieves the name of the license combination attached to the package. The + * name must be free(3)d when finished with. + */ +char * license_name_from_pkg(struct pkg *pkg) { /* TODO: handle conjunctions and disjunctions */ int err; - const char *match; + int sb_err; + lic_t logic; + char *license_dup; + const char *license; + const char *logic_str; struct pkg_license *lic; + struct sbuf *sb; + + pkg_get(pkg, PKG_LICENSE_LOGIC, &logic); + switch (logic) { + case LICENSE_OR: + logic_str = " or "; + break; + case LICENSE_AND: + logic_str = " and "; + break; + default: + logic_str = " "; + break; + } + /* Join all the licenses together with the logic word above. */ lic = NULL; - match = NULL; - do { - err = pkg_licenses(pkg, &lic); - if (err == EPKG_OK) - match = pkg_license_name(lic); - } while (err == EPKG_OK && match == NULL); + sb = sbuf_new_auto(); + for (HASH_FOR(err, pkg_licenses, pkg, &lic)) { + sbuf_cat(sb, logic_str); + sbuf_cat(sb, pkg_license_name(lic)); + } + sb_err = sbuf_finish(sb); + /* Make sure that we remove the initial logic string instance! */ + license = (sb_err + ? strerror(errno) + : (sbuf_data(sb) + strlen(logic_str))); - return match; + license_dup = strdup(license); + sbuf_delete(sb); + return license_dup; } Modified: soc2013/mattbw/backend/licenses.h ============================================================================== --- soc2013/mattbw/backend/licenses.h Fri Jul 5 20:17:06 2013 (r254178) +++ soc2013/mattbw/backend/licenses.h Fri Jul 5 20:48:47 2013 (r254179) @@ -23,6 +23,6 @@ #include "pk-backend.h" -const char *license_name_from_pkg(struct pkg *pkg); +char *license_name_from_pkg(struct pkg *pkg); #endif /* _PKGNG_BACKEND_LICENSES_H_ */ From owner-svn-soc-all@FreeBSD.ORG Fri Jul 5 22:02:02 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id E2F29494 for ; Fri, 5 Jul 2013 22:02:02 +0000 (UTC) (envelope-from dpl@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id D4635179E for ; Fri, 5 Jul 2013 22:02:02 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r65M22qv053463 for ; Fri, 5 Jul 2013 22:02:02 GMT (envelope-from dpl@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r65M22Lf053454 for svn-soc-all@FreeBSD.org; Fri, 5 Jul 2013 22:02:02 GMT (envelope-from dpl@FreeBSD.org) Date: Fri, 5 Jul 2013 22:02:02 GMT Message-Id: <201307052202.r65M22Lf053454@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to dpl@FreeBSD.org using -f From: dpl@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254192 - soc2013/dpl/head/contrib/bzip2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Jul 2013 22:02:03 -0000 Author: dpl Date: Fri Jul 5 22:02:02 2013 New Revision: 254192 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254192 Log: Start adapting stat,lstat and utime to be used with fds, fstatat() and futimes() Modified: soc2013/dpl/head/contrib/bzip2/bzip2.c Modified: soc2013/dpl/head/contrib/bzip2/bzip2.c ============================================================================== --- soc2013/dpl/head/contrib/bzip2/bzip2.c Fri Jul 5 21:41:05 2013 (r254191) +++ soc2013/dpl/head/contrib/bzip2/bzip2.c Fri Jul 5 22:02:02 2013 (r254192) @@ -75,8 +75,9 @@ # include # define PATH_SEP '/' -# define MY_LSTAT lstat -# define MY_STAT stat +# define MY_LSTAT fstatat +# define MY_STAT fstatat +# define MY_STATS stat # define MY_S_ISREG S_ISREG # define MY_S_ISDIR S_ISDIR @@ -223,8 +224,8 @@ Int32 workFactor; #if CAPSICUM -#define IN_FILENO fileno(outStr) -#define OUT_FILENO fileno(inStr) +#define IN_FILENO fileno(inStr) +#define OUT_FILENO fileno(outStr) void limitfd(int); FILE *inStr; FILE *outStr; @@ -678,24 +679,21 @@ void limitfd(int fd) { - cap_rights_t rights = 0; + cap_rights_t rights; - if (fd == IN_FILENO) - rights |= CAP_READ; - else if (fd == OUT_FILENO) - rights |= CAP_WRITE; + if (fd == OUT_FILENO) + rights = CAP_READ|CAP_FSTAT|CAP_WRITE|CAP_FCHMOD|CAP_FCHOWN|CAP_FUTIMES; + else if (fd == IN_FILENO) + rights = CAP_WRITE|CAP_READ|CAP_FSTAT; else if (fd == STDERR_FILENO) - rights |= CAP_WRITE; - else - abort(); -/* + rights = CAP_WRITE; + if (cap_rights_limit(fd, rights) < 0 && errno != ENOSYS){ fprintf ( stderr, "%s: Couldn't limit rights for descriptor %d: %s.\n", progName, fd, strerror(errno)); setExit(1); exit(exitValue); } -*/ } #endif @@ -732,7 +730,7 @@ void cleanUpAndFail ( Int32 ec ) { IntNative retVal; - struct MY_STAT statBuf; + struct MY_STATS statBuf; if ( srcMode == SM_F2F && opMode != OM_TEST @@ -1023,12 +1021,12 @@ if in doubt, return True --*/ static -Bool notAStandardFile ( Char* name ) +Bool notAStandardFile (int fd ) { IntNative i; - struct MY_STAT statBuf; + struct MY_STATS statBuf; - i = MY_LSTAT ( name, &statBuf ); + i = MY_LSTAT ( fd, &statBuf ); if (i != 0) return True; if (MY_S_ISREG(statBuf.st_mode)) return False; return True; @@ -1040,12 +1038,12 @@ rac 11/21/98 see if file has hard links to it --*/ static -Int32 countHardLinks ( Char* name ) +Int32 countHardLinks ( int fd ) { IntNative i; struct MY_STAT statBuf; - i = MY_LSTAT ( name, &statBuf ); + i = MY_LSTAT ( fd, &statBuf ); if (i != 0) return 0; return (statBuf.st_nlink - 1); } @@ -1241,7 +1239,7 @@ return; } } - if ( srcMode == SM_F2F && !forceOverwrite && notAStandardFile ( inName )) { + if ( srcMode == SM_F2F && !forceOverwrite && notAStandardFile ( IN_FILENO )) { if (noisy) fprintf ( stderr, "%s: Input file %s is not a normal file.\n", progName, inName ); @@ -1259,7 +1257,7 @@ } } if ( srcMode == SM_F2F && !forceOverwrite && - (n=countHardLinks ( inName )) > 0) { + (n=countHardLinks ( IN_FILENO )) > 0) { fprintf ( stderr, "%s: Input file %s has %d other link%s.\n", progName, inName, n, n > 1 ? "s" : "" ); setExit(1); @@ -1350,17 +1348,15 @@ wait(NULL); return; } else if (forkpid == 0){ - limitfd(fileno(inStr)); - limitfd(fileno(outStr)); + limitfd(IN_FILENO)); + limitfd(OUT_FILENO); limitfd(STDERR_FILENO); -/* - if (cap_enter() < 0){ + if (cap_enter() < 0 && errno != ENOSYS){ fprintf ( stderr, "%s: Couldn't enter capability mode: %s.\n", progName, strerror(errno) ); setExit(1); exit(exitValue); } -*/ # endif /*--- Now the input and output handles are sane. Do the Biz. ---*/ outputHandleJustInCase = outStr; @@ -1451,7 +1447,7 @@ return; } } - if ( srcMode == SM_F2F && !forceOverwrite && notAStandardFile ( inName )) { + if ( srcMode == SM_F2F && !forceOverwrite && notAStandardFile ( IN_FILENO )) { if (noisy) fprintf ( stderr, "%s: Input file %s is not a normal file.\n", progName, inName ); @@ -1476,7 +1472,7 @@ } } if ( srcMode == SM_F2F && !forceOverwrite && - (n=countHardLinks ( inName ) ) > 0) { + (n=countHardLinks ( IN_FILENO ) ) > 0) { fprintf ( stderr, "%s: Input file %s has %d other link%s.\n", progName, inName, n, n > 1 ? "s" : "" ); setExit(1); @@ -1559,17 +1555,16 @@ wait(NULL); return; } else if (forkpid == 0){ - limitfd(fileno(inStr)); - limitfd(fileno(outStr)); + limitfd(IN_FILENO); + limitfd(OUT_FILENO); limitfd(STDERR_FILENO); -/* - if (cap_enter() < 0){ + if (cap_enter() < 0 && errno != ENOSYS){ fprintf ( stderr, "%s: Couldn't enter capability mode: %s.\n", progName, strerror(errno) ); setExit(1); exit(exitValue); + } -*/ # endif /*--- Now the input and output handles are sane. Do the Biz. ---*/ outputHandleJustInCase = outStr; From owner-svn-soc-all@FreeBSD.ORG Fri Jul 5 23:12:28 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id B45C465A for ; Fri, 5 Jul 2013 23:12:28 +0000 (UTC) (envelope-from mattbw@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id A57EC1A19 for ; Fri, 5 Jul 2013 23:12:28 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r65NCSlm096333 for ; Fri, 5 Jul 2013 23:12:28 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r65NCSaM096331 for svn-soc-all@FreeBSD.org; Fri, 5 Jul 2013 23:12:28 GMT (envelope-from mattbw@FreeBSD.org) Date: Fri, 5 Jul 2013 23:12:28 GMT Message-Id: <201307052312.r65NCSaM096331@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to mattbw@FreeBSD.org using -f From: mattbw@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254198 - soc2013/mattbw/backend/actions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Jul 2013 23:12:28 -0000 Author: mattbw Date: Fri Jul 5 23:12:28 2013 New Revision: 254198 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254198 Log: readded summary emits for install-packages but more work here will have to wait until no-license bug is fixed Modified: soc2013/mattbw/backend/actions/install-packages.c Modified: soc2013/mattbw/backend/actions/install-packages.c ============================================================================== --- soc2013/mattbw/backend/actions/install-packages.c Fri Jul 5 22:42:10 2013 (r254197) +++ soc2013/mattbw/backend/actions/install-packages.c Fri Jul 5 23:12:28 2013 (r254198) @@ -77,15 +77,21 @@ err = pkg_jobs_solve(jobs); if (err == EPKG_OK) { + char *desc; + gchar *id; struct pkg *pkg; pkg = NULL; + id = NULL; for (HASH_FOR(err, pkg_jobs, jobs, &pkg)) { - //pk_backend_package(backend, - // PK_INFO_ENUM_INSTALLING, - ; - + pkg_get(pkg, PKG_DESC, &desc); + query_pkg_to_id(pkg, &id); + pk_backend_package(backend, + PK_INFO_ENUM_INSTALLING, + id, + desc); } + g_free(id); } else pk_backend_error_code(backend, PK_ERROR_ENUM_DEP_RESOLUTION_FAILED, From owner-svn-soc-all@FreeBSD.ORG Sat Jul 6 01:07:30 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id A62F2ECF for ; Sat, 6 Jul 2013 01:07:30 +0000 (UTC) (envelope-from mattbw@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 96FD91E29 for ; Sat, 6 Jul 2013 01:07:30 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6617UGc051434 for ; Sat, 6 Jul 2013 01:07:30 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6617Ugb051426 for svn-soc-all@FreeBSD.org; Sat, 6 Jul 2013 01:07:30 GMT (envelope-from mattbw@FreeBSD.org) Date: Sat, 6 Jul 2013 01:07:30 GMT Message-Id: <201307060107.r6617Ugb051426@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to mattbw@FreeBSD.org using -f From: mattbw@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254205 - soc2013/mattbw/tests/get-details-output MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 06 Jul 2013 01:07:30 -0000 Author: mattbw Date: Sat Jul 6 01:07:30 2013 New Revision: 254205 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254205 Log: make test able to handle remote packages; update README Modified: soc2013/mattbw/tests/get-details-output/test-pkg.sh soc2013/mattbw/tests/get-details-output/test.sh Modified: soc2013/mattbw/tests/get-details-output/test-pkg.sh ============================================================================== --- soc2013/mattbw/tests/get-details-output/test-pkg.sh Sat Jul 6 00:13:08 2013 (r254204) +++ soc2013/mattbw/tests/get-details-output/test-pkg.sh Sat Jul 6 01:07:30 2013 (r254205) @@ -1,17 +1,87 @@ #!/bin/sh -# Tests pkcon against pkg to make sure the pkg backend works correctly for GetDetails. +################################################################################ +# Tests pkcon against pkg to make sure the pkg backend works correctly for +# GetDetails for one package. # # More black-box tests should be written later +# +# Usage: ./test-pkg [PACKAGE] [PK_REPO] +# or ./test.sh (runs this over a set of packages) +# +# TODO: Specific version/arch requirements in the PackageID + +################################################################################ +# Retrieve the arguments. -if [ $# -eq 1 ] +if [ $# -gt 0 ] then PACKAGE="$1" else PACKAGE="pkg" fi +# Translate into an evaluation condition so we can use it with a specific +# rquery repository +ECOND="-e \"%n==${PACKAGE}\"" -echo "using package ${PACKAGE}" +if [ $# -gt 1 ] +then + PK_REPO="$2" +else + PK_REPO="" +fi + +################################################################################ +# Convert from PackageKit repository to pkgng repository and query type. + +if [ -z "${PK_REPO}" ] # Wildcard (local or any remote repo) +then + TRY_LOCAL=1 + TRY_REMOTE=1 + REPO="" +elif [ "${PK_REPO}" == "installed" ] # Locally installed package +then + TRY_LOCAL=1 + TRY_REMOTE=0 +else # Specific remote repo + TRY_LOCAL=0 + TRY_REMOTE=1 + REPO="-r \"${PK_REPO}\"" +fi + +FOUND=0 +if [ ${TRY_LOCAL} -gt 0 ] +then + # Does the package exist locally? + TEST=`eval pkg query ${ECOND} \"%n\"` + if [ -n "${TEST}" ] + then + FOUND=1 + TRY_REMOTE=0 + QTYPE="pkg query" + fi +fi +if [ ${TRY_REMOTE} -gt 0 ] +then + # Does it exist remotely? + TEST="`eval pkg rquery ${REPO} ${ECOND} \"%n\"`" + if [ -n "${TEST}" ] + then + FOUND=1 + QTYPE="pkg rquery ${REPO}" + fi +fi +PKGCMD="${QTYPE} ${ECOND}" + +# TODO: behave if FOUND is 0 + +PK_ID="${PACKAGE};;;${PK_REPO}" +echo "testing with package ${PACKAGE}" +echo " pkg invocation: ${PKGCMD} ..." +echo " pkcon invocation: pkcon get-details ${PK_ID}" + +################################################################################ +# Infer data not available from a query string but used in PackageKit. # Get the expected ABI through some invasive inspection of the pkg config dump ARCH="`pkg -vv | grep ABI | sed 's/ *ABI: *//'`" @@ -19,31 +89,38 @@ CMD_GETCAT="./getcat" # Get the PackageKit group of the package -ORIGIN="`pkg query \"%o\" ${PACKAGE}`" +ORIGIN="`eval ${PKGCMD} \"%o\"`" GROUP="`${CMD_GETCAT} ${ORIGIN}`" -# Get the licences by mashing the `pkg query` licence list and or/and/single identifier -# into one "licence or licence or licence" string. +# Get the licences by mashing the `pkg query` licence list and or/and/single +# identifier into one "licence or licence or licence" string. LICENSE=`\ - pkg query "%L %l" "${PACKAGE}" | # "licence or\nlicence or\n" - tr "\n" " " | # "licence or licence or ", note space - sed 's/ *[^ ]* *$//'` # "licence or licence" + eval ${PKGCMD} \"%L %l\" | # "GPL or\nBSD or\n" + tr "\n" " " | # "GPL or BSD or ", + sed 's/ *[^ ]* *$//'` # "GPL or BSD" + +################################################################################ +# Build and run the queries. # Build a format string for the query that mocks up a pkcon GetDetails result -FMT="Package description +# This has to be done in such an ugly way because we're eval'ing. +FMT='Package description package: %n-%v.${ARCH} license: ${LICENSE} group: ${GROUP} description: %e size: %sb bytes - url: %w" + url: %w' # Now run both queries and diff them PKG_FILE="${PACKAGE}-pkg" PKCON_FILE="${PACKAGE}-pkcon" -pkg query "${FMT}" "${PACKAGE}" > "${PKG_FILE}" -pkcon get-details "${PACKAGE};;;installed" | awk -f "strip_messages.awk" > "${PKCON_FILE}" +eval ${PKGCMD} \""${FMT}"\" > "${PKG_FILE}" +pkcon get-details "${PK_ID}" | awk -f "strip_messages.awk" > "${PKCON_FILE}" + +################################################################################ +# Diff the results. DIFF="`diff -rupN \"${PACKAGE}-pkg\" \"${PACKAGE}-pkcon\"`" if [ -n "${DIFF}" ] Modified: soc2013/mattbw/tests/get-details-output/test.sh ============================================================================== --- soc2013/mattbw/tests/get-details-output/test.sh Sat Jul 6 00:13:08 2013 (r254204) +++ soc2013/mattbw/tests/get-details-output/test.sh Sat Jul 6 01:07:30 2013 (r254205) @@ -4,7 +4,7 @@ while read LINE do - ./test-pkg.sh "${LINE}" + ./test-pkg.sh ${LINE} if [ $? -ne 0 ] then echo "tests failed" From owner-svn-soc-all@FreeBSD.ORG Sat Jul 6 01:07:57 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 99FE6EE3 for ; Sat, 6 Jul 2013 01:07:57 +0000 (UTC) (envelope-from mattbw@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 8BECB1E2D for ; Sat, 6 Jul 2013 01:07:57 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6617v0Q056609 for ; Sat, 6 Jul 2013 01:07:57 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6617vBL056604 for svn-soc-all@FreeBSD.org; Sat, 6 Jul 2013 01:07:57 GMT (envelope-from mattbw@FreeBSD.org) Date: Sat, 6 Jul 2013 01:07:57 GMT Message-Id: <201307060107.r6617vBL056604@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to mattbw@FreeBSD.org using -f From: mattbw@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254206 - soc2013/mattbw MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 06 Jul 2013 01:07:57 -0000 Author: mattbw Date: Sat Jul 6 01:07:57 2013 New Revision: 254206 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254206 Log: *actually* update README Modified: soc2013/mattbw/README Modified: soc2013/mattbw/README ============================================================================== --- soc2013/mattbw/README Sat Jul 6 01:07:30 2013 (r254205) +++ soc2013/mattbw/README Sat Jul 6 01:07:57 2013 (r254206) @@ -57,8 +57,9 @@ KNOWN BUGS - InstallPackages is not yet fully implemented. -- Licence emitting is broken; it currently emits only the first licence in a - licence chain, rather than the entire set of licences. +- Behaviour when a repository has multiple versions of a package is currently + ill-defined (the first one in the iterator will be emitted). This requires + further work. - Minor cosmetic issues (progress bars not updating properly, etc.) may exist. -------------------------------------------------------------------------------- From owner-svn-soc-all@FreeBSD.ORG Sat Jul 6 01:34:44 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 8EAF5627 for ; Sat, 6 Jul 2013 01:34:44 +0000 (UTC) (envelope-from mattbw@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 66AF91F09 for ; Sat, 6 Jul 2013 01:34:44 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r661YitP060242 for ; Sat, 6 Jul 2013 01:34:44 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r661YifN060232 for svn-soc-all@FreeBSD.org; Sat, 6 Jul 2013 01:34:44 GMT (envelope-from mattbw@FreeBSD.org) Date: Sat, 6 Jul 2013 01:34:44 GMT Message-Id: <201307060134.r661YifN060232@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to mattbw@FreeBSD.org using -f From: mattbw@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254207 - in soc2013/mattbw: . backend MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 06 Jul 2013 01:34:44 -0000 Author: mattbw Date: Sat Jul 6 01:34:44 2013 New Revision: 254207 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254207 Log: added subdir makefile; fixed no-license problem. Modified: soc2013/mattbw/Makefile soc2013/mattbw/README soc2013/mattbw/backend/licenses.c Modified: soc2013/mattbw/Makefile ============================================================================== --- soc2013/mattbw/Makefile Sat Jul 6 01:07:57 2013 (r254206) +++ soc2013/mattbw/Makefile Sat Jul 6 01:34:44 2013 (r254207) @@ -1,12 +1,6 @@ -# To be BSD-ified later. +# $FreeBSD$ -PKGS= pkg packagekit-plugin -CC= clang -CFLAGS= `pkg-config --cflags $(PKGS)` -LIBS= `pkg-config --libs $(PKGS)` +SUBDIR= backend \ + tests/get-details-output -test: test.o - $(CC) $(LIBS) -o test test.o - -test.o: test.c - $(CC) $(CFLAGS) -c -o test.o test.c +.include Modified: soc2013/mattbw/README ============================================================================== --- soc2013/mattbw/README Sat Jul 6 01:07:57 2013 (r254206) +++ soc2013/mattbw/README Sat Jul 6 01:34:44 2013 (r254207) @@ -39,6 +39,9 @@ - Edit /usr/local/PackageKit/PackageKit.conf such that "DefaultBackend=pkgng" (or manually invoke packagekitd with backend=pkgng). +One can also use the Makefile in the root directory; this will build the +backend as well as any utilities and tests included with it. + -------------------------------------------------------------------------------- TESTING Modified: soc2013/mattbw/backend/licenses.c ============================================================================== --- soc2013/mattbw/backend/licenses.c Sat Jul 6 01:07:57 2013 (r254206) +++ soc2013/mattbw/backend/licenses.c Sat Jul 6 01:34:44 2013 (r254207) @@ -64,6 +64,12 @@ sbuf_cat(sb, logic_str); sbuf_cat(sb, pkg_license_name(lic)); } + /* Stop the following code from bombing if there was no license + * available. + */ + if (sbuf_len(sb) == 0) + sbuf_cat(sb, logic_str); + sb_err = sbuf_finish(sb); /* Make sure that we remove the initial logic string instance! */ license = (sb_err From owner-svn-soc-all@FreeBSD.ORG Sat Jul 6 07:09:03 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 3AAA2517 for ; Sat, 6 Jul 2013 07:09:03 +0000 (UTC) (envelope-from mattbw@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 27C901B52 for ; Sat, 6 Jul 2013 07:09:03 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r66792ZP016129 for ; Sat, 6 Jul 2013 07:09:02 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r66792Wm016125 for svn-soc-all@FreeBSD.org; Sat, 6 Jul 2013 07:09:02 GMT (envelope-from mattbw@FreeBSD.org) Date: Sat, 6 Jul 2013 07:09:02 GMT Message-Id: <201307060709.r66792Wm016125@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to mattbw@FreeBSD.org using -f From: mattbw@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254218 - soc2013/mattbw/tests/install MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 06 Jul 2013 07:09:03 -0000 Author: mattbw Date: Sat Jul 6 07:09:02 2013 New Revision: 254218 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254218 Log: adds more testbed code for checking why install-packages isn't working Added: soc2013/mattbw/tests/install/ soc2013/mattbw/tests/install/Makefile soc2013/mattbw/tests/install/insttest.1 soc2013/mattbw/tests/install/insttest.c Added: soc2013/mattbw/tests/install/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/mattbw/tests/install/Makefile Sat Jul 6 07:09:02 2013 (r254218) @@ -0,0 +1,7 @@ +# $FreeBSD$ + +PROG= insttest +CFLAGS+= `pkgconf --cflags pkg` -g +LDFLAGS+= `pkgconf --libs pkg` + +.include Added: soc2013/mattbw/tests/install/insttest.1 ============================================================================== Added: soc2013/mattbw/tests/install/insttest.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/mattbw/tests/install/insttest.c Sat Jul 6 07:09:02 2013 (r254218) @@ -0,0 +1,102 @@ +#include +#include +#include +#include "pkg.h" + +void handle_it(struct pkgdb_it *it); +int getdb(struct pkgdb **db); + +int +getdb(struct pkgdb **db) +{ + int err; + + err = pkgdb_access(PKGDB_MODE_READ, PKGDB_DB_REPO); + + if (err == EPKG_ENOACCESS) + fprintf(stderr, "check your privilege: %i\n", err); + else if (err != EPKG_OK) + fprintf(stderr, "access error: %i\n", err); + else { + err = pkgdb_open(db, PKGDB_REMOTE); + if (err != EPKG_OK) + fprintf(stderr, "open error: %i\n", err); + } + return err; +} + +int +main(int argc, char **argv) +{ + struct pkg *pkg; + struct pkgdb *db; + struct pkg_jobs *jobs; + int err; + + db = NULL; + pkg = NULL; + jobs = NULL; + + err = ((argc == 2 || argc == 3) ? EPKG_OK : EPKG_FATAL); + if (err == EPKG_OK) { + err = pkg_init(NULL); + if (err != EPKG_OK) + fprintf(stderr, "could not parse config file\n"); + } else + fprintf(stderr, "usage: %s name [repo]\n", argv[0]); + + if (err == EPKG_OK) + err = getdb(&db); + + if (err == EPKG_OK) { + err = pkg_jobs_new(&jobs, PKG_JOBS_INSTALL, db); + if (err != EPKG_OK) + fprintf(stderr, "couldn't create jobs\n"); + } + + if (err == EPKG_OK && argc == 3) { + char *rep; + + /* Test what happens to set_repository if it's passed NULL */ + if (strcmp(argv[2], "null") == 0) { + rep = NULL; + printf("using null\n"); + } else + rep = argv[2]; + + err = pkg_jobs_set_repository(jobs, rep); + if (err != EPKG_OK) + fprintf(stderr, "couldn't set repo\n"); + } + + if (err == EPKG_OK) { + err = pkg_jobs_add(jobs, MATCH_EXACT, argv + 1, 1); + if (err != EPKG_OK) + fprintf(stderr, "couldn't add to job\n"); + } + + if (err == EPKG_OK) { + err = pkg_jobs_solve(jobs); + if (err != EPKG_OK) + fprintf(stderr, "couldn't solve: %u\n", err); + } + + if (err == EPKG_OK) { + int c; + + c = pkg_jobs_count(jobs); + if (c > 0) { + printf("%i jobs\n", c); + while (pkg_jobs(jobs, &pkg) == EPKG_OK) + pkg_printf("%n\n", pkg); + } else + fprintf(stderr, "nothing to do\n"); + } + + printf("shutting down\n"); + pkg_jobs_free(jobs); + pkg_free(pkg); + pkgdb_close(db); + pkg_shutdown(); + printf("shutdown\n"); +} From owner-svn-soc-all@FreeBSD.ORG Sat Jul 6 07:38:41 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id B23AA840 for ; Sat, 6 Jul 2013 07:38:41 +0000 (UTC) (envelope-from mattbw@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id A23BF1C01 for ; Sat, 6 Jul 2013 07:38:41 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r667cfpo059699 for ; Sat, 6 Jul 2013 07:38:41 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r667cfv8059686 for svn-soc-all@FreeBSD.org; Sat, 6 Jul 2013 07:38:41 GMT (envelope-from mattbw@FreeBSD.org) Date: Sat, 6 Jul 2013 07:38:41 GMT Message-Id: <201307060738.r667cfv8059686@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to mattbw@FreeBSD.org using -f From: mattbw@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254219 - in soc2013/mattbw/backend: . actions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 06 Jul 2013 07:38:41 -0000 Author: mattbw Date: Sat Jul 6 07:38:41 2013 New Revision: 254219 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254219 Log: bash simulate-install-packages to the point where it sometimes shows the correct information Modified: soc2013/mattbw/backend/actions/actions.h soc2013/mattbw/backend/actions/install-packages.c soc2013/mattbw/backend/pk-backend-pkgng.c soc2013/mattbw/backend/query.c Modified: soc2013/mattbw/backend/actions/actions.h ============================================================================== --- soc2013/mattbw/backend/actions/actions.h Sat Jul 6 07:09:02 2013 (r254218) +++ soc2013/mattbw/backend/actions/actions.h Sat Jul 6 07:38:41 2013 (r254219) @@ -24,10 +24,14 @@ #include /* gboolean */ #include "../pk-backend.h" /* PkBackend */ -/* Each thread is implemented in its namesake C file. */ +/* + * Each thread is implemented in its namesake C file, except simulations + * which are stored with their non-simulated counterparts. + */ gboolean get_details_thread(PkBackend *backend); gboolean get_files_thread(PkBackend *backend); gboolean get_repo_list_thread(PkBackend *backend); gboolean install_packages_thread(PkBackend *backend); +gboolean simulate_install_packages_thread(PkBackend *backend); #endif /* !_PKGNG_BACKEND_ACTIONS_H_ */ Modified: soc2013/mattbw/backend/actions/install-packages.c ============================================================================== --- soc2013/mattbw/backend/actions/install-packages.c Sat Jul 6 07:09:02 2013 (r254218) +++ soc2013/mattbw/backend/actions/install-packages.c Sat Jul 6 07:38:41 2013 (r254219) @@ -29,12 +29,17 @@ #include "actions.h" /* install_packages_thread prototype */ static gboolean body(struct query *q); +static gboolean sim_body(struct query *q); +static void do_install_packages(struct pkg_jobs *jobs, struct query *q, gboolean simulate); static void emit(struct pkg *pkg, const gchar *id, struct query *q); -static void job(struct pkg_jobs *jobs, struct query *q); +static void job (struct pkg_jobs *jobs, struct query *q); +static void sim_emit(struct pkg *pkg, const gchar *id, struct query *q); +static void sim_job(struct pkg_jobs *jobs, struct query *q); + /* - * The thread that performs an InstallPackages operation. Should be invoked by - * the pk_backend_install_packages hook. + * The thread that performs an InstallPackages operation. Should be invoked + * by the pk_backend_install_packages hook. */ gboolean install_packages_thread(PkBackend *backend) @@ -44,6 +49,17 @@ } /* + * The thread that performs a Simulate InstallPackages operation. Should be + * invoked by the pk_backend_simulate_install_packages hook. + */ +gboolean +simulate_install_packages_thread(PkBackend *backend) +{ + + return query_for_all_ids(backend, PKG_LOAD_BASIC, sim_body); +} + +/* * Look up and attempt to install the given PackageID, if it can be found. */ static gboolean @@ -54,46 +70,99 @@ } /* - * Tries to install the given package. + * Look up and attempt to simulate installing the given PackageID, if it can + * be found. */ -static void -emit(struct pkg *pkg, const gchar *id, struct query *q) +static gboolean +sim_body(struct query *q) { - INTENTIONALLY_IGNORE(id); - return query_emit_to_job(pkg, q, PKG_JOBS_INSTALL, job); + return query_emit_match(q, sim_emit); } -/* - * Tries to install the given package. - */ static void -job(struct pkg_jobs *jobs, struct query *q) +do_install_packages(struct pkg_jobs *jobs, struct query *q, gboolean simulate) { - int err; - PkBackend *backend; + int err; + PkBackend *backend; backend = query_backend(q); + pk_backend_set_status(backend, PK_STATUS_ENUM_DEP_RESOLVE); err = pkg_jobs_solve(jobs); if (err == EPKG_OK) { - char *desc; - gchar *id; - struct pkg *pkg; + char *desc; + gchar *id; + struct pkg *pkg; pkg = NULL; id = NULL; - for (HASH_FOR(err, pkg_jobs, jobs, &pkg)) { - pkg_get(pkg, PKG_DESC, &desc); - query_pkg_to_id(pkg, &id); - pk_backend_package(backend, - PK_INFO_ENUM_INSTALLING, - id, - desc); + if (pkg_jobs_count(jobs) == 0) + pk_backend_error_code(backend, + PK_ERROR_ENUM_INTERNAL_ERROR, + "job contains no packages"); + else { + while (pkg_jobs(jobs, &pkg) == EPKG_OK) { + pkg_get(pkg, PKG_COMMENT, &desc); + query_pkg_to_id(pkg, &id); + pk_backend_package(backend, + PK_INFO_ENUM_INSTALLING, + id, + desc); + } + g_free(id); } - g_free(id); } else pk_backend_error_code(backend, - PK_ERROR_ENUM_DEP_RESOLUTION_FAILED, - "could not solve the job"); + PK_ERROR_ENUM_DEP_RESOLUTION_FAILED, + "could not solve the job"); + + /* TODO: actual install */ + if (err == EPKG_OK && simulate == FALSE) + pk_backend_error_code(backend, + PK_ERROR_ENUM_NOT_SUPPORTED, + "not implemented yet"); + +} + +/* + * Tries to install the given package. + */ +static void +emit(struct pkg *pkg, const gchar *id, struct query *q) +{ + + INTENTIONALLY_IGNORE(id); + return query_emit_to_job(pkg, q, PKG_JOBS_INSTALL, job); +} + +/* + * Tries to process the given solved installation jobs. + */ +static void +job(struct pkg_jobs *jobs, struct query *q) +{ + + do_install_packages(jobs, q, FALSE); +} + +/* + * Tries to install the given package. + */ +static void +sim_emit(struct pkg *pkg, const gchar *id, struct query *q) +{ + + INTENTIONALLY_IGNORE(id); + return query_emit_to_job(pkg, q, PKG_JOBS_INSTALL, sim_job); +} + +/* + * Tries to simulate processing the given installation jobs. + */ +static void +sim_job(struct pkg_jobs *jobs, struct query *q) +{ + + do_install_packages(jobs, q, TRUE); } Modified: soc2013/mattbw/backend/pk-backend-pkgng.c ============================================================================== --- soc2013/mattbw/backend/pk-backend-pkgng.c Sat Jul 6 07:09:02 2013 (r254218) +++ soc2013/mattbw/backend/pk-backend-pkgng.c Sat Jul 6 07:38:41 2013 (r254219) @@ -367,7 +367,6 @@ pk_backend_set_percentage(backend, PK_BACKEND_PERCENTAGE_INVALID); pk_backend_thread_create(backend, install_packages_thread); - pk_backend_finished(backend); } /** @@ -1142,35 +1141,13 @@ void pk_backend_simulate_install_packages(PkBackend *backend, gchar **package_ids) { - INTENTIONALLY_IGNORE(package_ids); - - pk_backend_set_status(backend, PK_STATUS_ENUM_DEP_RESOLVE); - - pk_backend_package(backend, PK_INFO_ENUM_REMOVING, - "powertop;1.8-1.fc8;i386;fedora", "Power consumption monitor"); - - pk_backend_package(backend, PK_INFO_ENUM_INSTALLING, - "gtk2;2.11.6-6.fc8;i386;fedora", "GTK+ Libraries for GIMP"); - - pk_backend_package(backend, PK_INFO_ENUM_UPDATING, - "lib7;7.0.1-6.fc13;i386;fedora", "C Libraries"); - - pk_backend_package(backend, PK_INFO_ENUM_REINSTALLING, - "libssl;3.5.7-2.fc13;i386;fedora", "SSL Libraries"); - pk_backend_package(backend, PK_INFO_ENUM_AVAILABLE, - "vips-doc;7.12.4-2.fc8;noarch;linva", "The vips documentation package."); - - pk_backend_package(backend, PK_INFO_ENUM_INSTALLED, - "glib2;2.14.0;i386;fedora", "The GLib library"); - - pk_backend_package(backend, PK_INFO_ENUM_DOWNGRADING, - "kernel;2.6.23-0.115.rc3.git1.fc8;i386;installed", "The Linux kernel (the core of the Linux operating system)"); + INTENTIONALLY_IGNORE(package_ids); - pk_backend_package(backend, PK_INFO_ENUM_UPDATING, - "gtkhtml2;2.19.1-4.fc8;i386;fedora", "An HTML widget for GTK+ 2.0"); + pk_backend_set_status(backend, PK_STATUS_ENUM_RUNNING); + pk_backend_set_percentage(backend, PK_BACKEND_PERCENTAGE_INVALID); - pk_backend_finished(backend); + pk_backend_thread_create(backend, simulate_install_packages_thread); } Modified: soc2013/mattbw/backend/query.c ============================================================================== --- soc2013/mattbw/backend/query.c Sat Jul 6 07:09:02 2013 (r254218) +++ soc2013/mattbw/backend/query.c Sat Jul 6 07:38:41 2013 (r254219) @@ -208,7 +208,8 @@ jobs = NULL; err = pkg_jobs_new(&jobs, type, q->db); if (err == EPKG_OK) { - err = pkg_jobs_set_repository(jobs, q->data); + if (q->data != NULL) + err = pkg_jobs_set_repository(jobs, q->data); if (err == EPKG_OK) { err = jobs_add_pkg(jobs, MATCH_EXACT, pkg); if (err == EPKG_OK) @@ -217,10 +218,9 @@ pk_backend_error_code(q->backend, PK_ERROR_ENUM_INTERNAL_ERROR, "could not add to job"); - } else pk_backend_error_code(q->backend, - PK_ERROR_ENUM_INTERNAL_ERROR, + PK_ERROR_ENUM_REPO_NOT_FOUND, "could not set repo"); } else @@ -427,6 +427,7 @@ { char *name; + name = NULL; pkg_get(pkg, PKG_NAME, &name); return pkg_jobs_add(jobs, type, &name, 1); } From owner-svn-soc-all@FreeBSD.ORG Sat Jul 6 09:03:23 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 0CE5B4B6 for ; Sat, 6 Jul 2013 09:03:23 +0000 (UTC) (envelope-from mattbw@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id F1D0E1EA3 for ; Sat, 6 Jul 2013 09:03:22 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6693M1L014206 for ; Sat, 6 Jul 2013 09:03:22 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6693MES014168 for svn-soc-all@FreeBSD.org; Sat, 6 Jul 2013 09:03:22 GMT (envelope-from mattbw@FreeBSD.org) Date: Sat, 6 Jul 2013 09:03:22 GMT Message-Id: <201307060903.r6693MES014168@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to mattbw@FreeBSD.org using -f From: mattbw@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254230 - in soc2013/mattbw/backend: . actions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 06 Jul 2013 09:03:23 -0000 Author: mattbw Date: Sat Jul 6 09:03:22 2013 New Revision: 254230 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254230 Log: split off package utility functions; properly determine info enum from package; for some silly reason this seems to be failing to unlock the database Added: soc2013/mattbw/backend/pkgutils.c soc2013/mattbw/backend/pkgutils.h Modified: soc2013/mattbw/backend/Makefile soc2013/mattbw/backend/actions/install-packages.c soc2013/mattbw/backend/db.c soc2013/mattbw/backend/query.c Modified: soc2013/mattbw/backend/Makefile ============================================================================== --- soc2013/mattbw/backend/Makefile Sat Jul 6 08:59:27 2013 (r254229) +++ soc2013/mattbw/backend/Makefile Sat Jul 6 09:03:22 2013 (r254230) @@ -2,8 +2,16 @@ LIB= pk_backend_pkgng SHLIB_MAJOR= 1 -SRCS= pk-backend-pkgng.c groups.c db.c licenses.c query.c utils.c -SRCS+= actions/get-details.c \ +SRCS= pk-backend-pkgng.c +SRCS+= \ + db.c \ + groups.c \ + licenses.c \ + pkgutils.c \ + query.c \ + utils.c +SRCS+= \ + actions/get-details.c \ actions/get-files.c \ actions/get-repo-list.c \ actions/install-packages.c Modified: soc2013/mattbw/backend/actions/install-packages.c ============================================================================== --- soc2013/mattbw/backend/actions/install-packages.c Sat Jul 6 08:59:27 2013 (r254229) +++ soc2013/mattbw/backend/actions/install-packages.c Sat Jul 6 09:03:22 2013 (r254230) @@ -23,6 +23,7 @@ #include "pkg.h" #include "../hash_traverse.h" /* HASH_FOR */ +#include "../pkgutils.h" /* pkgutils_... */ #include "../query.h" /* Package querying */ #include "../utils.h" /* INTENTIONALLY_IGNORE */ @@ -90,39 +91,28 @@ pk_backend_set_status(backend, PK_STATUS_ENUM_DEP_RESOLVE); err = pkg_jobs_solve(jobs); - if (err == EPKG_OK) { - char *desc; - gchar *id; - struct pkg *pkg; - - pkg = NULL; - id = NULL; - if (pkg_jobs_count(jobs) == 0) - pk_backend_error_code(backend, - PK_ERROR_ENUM_INTERNAL_ERROR, - "job contains no packages"); - else { - while (pkg_jobs(jobs, &pkg) == EPKG_OK) { - pkg_get(pkg, PKG_COMMENT, &desc); - query_pkg_to_id(pkg, &id); - pk_backend_package(backend, - PK_INFO_ENUM_INSTALLING, - id, - desc); - } - g_free(id); - } - } else + if (err != EPKG_OK) pk_backend_error_code(backend, PK_ERROR_ENUM_DEP_RESOLUTION_FAILED, "could not solve the job"); - - /* TODO: actual install */ - if (err == EPKG_OK && simulate == FALSE) + else if (pkg_jobs_count(jobs) == 0) pk_backend_error_code(backend, - PK_ERROR_ENUM_NOT_SUPPORTED, - "not implemented yet"); + PK_ERROR_ENUM_INTERNAL_ERROR, + "job contains no packages"); + else { + struct pkg *pkg; + + pkg = NULL; + while (pkg_jobs(jobs, &pkg) == EPKG_OK) + pkgutils_emit(pkg, + backend, + pkgutils_pkg_install_state(pkg)); + if (simulate == FALSE) + pk_backend_error_code(backend, + PK_ERROR_ENUM_NOT_SUPPORTED, + "not implemented yet"); + } } /* Modified: soc2013/mattbw/backend/db.c ============================================================================== --- soc2013/mattbw/backend/db.c Sat Jul 6 08:59:27 2013 (r254229) +++ soc2013/mattbw/backend/db.c Sat Jul 6 09:03:22 2013 (r254230) @@ -47,24 +47,28 @@ success = FALSE; + pk_backend_set_status(backend, PK_STATUS_ENUM_WAITING_FOR_AUTH); access_return = pkgdb_access(PKGDB_MODE_READ | PKGDB_MODE_WRITE, PKGDB_DB_LOCAL | PKGDB_DB_REPO); if (access_return != EPKG_OK) pk_backend_error_code(backend, - PK_ERROR_ENUM_INTERNAL_ERROR, + PK_ERROR_ENUM_NOT_AUTHORIZED, "cannot access database"); else { + pk_backend_set_status(backend, PK_STATUS_ENUM_WAITING_FOR_LOCK); open_return = pkgdb_open(db, PKGDB_REMOTE); if (open_return != EPKG_OK) pk_backend_error_code(backend, - PK_ERROR_ENUM_INTERNAL_ERROR, - "pkgdb_open returned an error"); + PK_ERROR_ENUM_CANNOT_GET_LOCK, + "cannot open database"); else if (*db == NULL) pk_backend_error_code(backend, PK_ERROR_ENUM_INTERNAL_ERROR, "pkgdb_open gave us a null pointer"); - else + else { + pk_backend_set_status(backend, PK_STATUS_ENUM_RUNNING); success = TRUE; + } } return success; Added: soc2013/mattbw/backend/pkgutils.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/mattbw/backend/pkgutils.c Sat Jul 6 09:03:22 2013 (r254230) @@ -0,0 +1,182 @@ +/*- + * Copyright (C) 2013 Matt Windsor + * + * Licensed under the GNU General Public License Version 2 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include +#include +#include "pk-backend.h" +#include "pkg.h" + +#include "pkgutils.h" /* Prototypes */ + +static const char *repo_of_remote(struct pkg *pkg); + +/* + * Infers the correct PkInfoEnum to emit for this package if it is being + * installed, mainly from its current installation information. + */ +PkInfoEnum +pkgutils_pkg_install_state(struct pkg *pkg) +{ + PkInfoEnum info; + const char *old; + + /* Sane default */ + info = PK_INFO_ENUM_INSTALLING; + + /* Does this package already have a version installed? */ + old = NULL; + pkg_get(pkg, PKG_OLD_VERSION, &old); + + if (old != NULL) { + /* Yes, but how does it compare to the new one? */ + switch (pkg_version_change(pkg)) { + case PKG_DOWNGRADE: + info = PK_INFO_ENUM_DOWNGRADING; + break; + case PKG_REINSTALL: + info = PK_INFO_ENUM_REINSTALLING; + break; + case PKG_UPGRADE: + info = PK_INFO_ENUM_UPDATING; + break; + default: + /* Stick with the above default. */ + break; + } + } + return info; +} + +/* + * Gets the PackageKit repository name for the package. + */ +const char * +pkgutils_pk_repo_of(struct pkg *pkg) +{ + const char *repo; + + switch (pkg_type(pkg)) { + case PKG_FILE: + repo = "local"; + break; + case PKG_INSTALLED: + repo = "installed"; + break; + case PKG_REMOTE: + repo = repo_of_remote(pkg); + break; + default: + repo = "unknown"; + break; + } + + return repo; +} + +/* + * Emits a package through the backend with the given info enum. + */ +void +pkgutils_emit(struct pkg *pkg, PkBackend *backend, PkInfoEnum info) +{ + char *comment; + gchar *id; + + pkg_get(pkg, PKG_COMMENT, &comment); + id = pkgutils_pkg_to_id(pkg); + pk_backend_package(backend, info, id, comment); + g_free(id); +} + +/* + * Converts a package to a PackageID. + */ +gchar * +pkgutils_pkg_to_id(struct pkg *pkg) +{ + gchar *id; + const gchar **id_bits; + + /* Make sure the initial string vector's pointers are all NULL */ + id_bits = g_new0(const gchar *, 4); + + /* + * This is split through an intermediate function so the same code + * can be used for the ID-checking logic. + */ + id = pkgutils_pkg_to_id_through(pkg, id_bits); + + /* we don't own any of the strings, so we don't use g_strfreev. */ + g_free(id_bits); + + return id; +} + +/* + * Converts a package to a PackageID, dumping the intermediate information + * into the pointed-to string vector (which must have at least 4 places, and + * they should be NULL). + */ +gchar * +pkgutils_pkg_to_id_through(struct pkg *pkg, const gchar **strv) +{ + pkg_get(pkg, + PKG_NAME, strv + PK_PACKAGE_ID_NAME, + PKG_VERSION, strv + PK_PACKAGE_ID_VERSION, + PKG_ARCH, strv + PK_PACKAGE_ID_ARCH); + + strv[PK_PACKAGE_ID_DATA] = pkgutils_pk_repo_of(pkg); + + return pk_package_id_build(strv[PK_PACKAGE_ID_NAME], + strv[PK_PACKAGE_ID_VERSION], + strv[PK_PACKAGE_ID_ARCH], + strv[PK_PACKAGE_ID_DATA]); +} + +/* + * Gets the PackageKit repository name for the (remote) package. + * + * Currently this is actually the pkgng repository ident. This might change. + * + * This does not need to be freed (possibly, TODO: check). + */ +static const char * +repo_of_remote(struct pkg *pkg) +{ + const char *repo; + const char *repo_name; + struct pkg_repo *repo_struct; + + repo = NULL; + + /* + * We can get the repo NAME directly, but we need the repo IDENT. + * Short of chopping bits of the string off in the assumption that + * the name is repo-IDENT, we'll have to grab it from the repo + * structure itself. + */ + pkg_get(pkg, PKG_REPONAME, &repo_name); + + repo_struct = pkg_repo_find_name(repo_name); + if (repo_struct) + repo = pkg_repo_ident(repo_struct); + + return repo; +} Added: soc2013/mattbw/backend/pkgutils.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/mattbw/backend/pkgutils.h Sat Jul 6 09:03:22 2013 (r254230) @@ -0,0 +1,34 @@ +/*- + * Copyright (C) 2013 Matt Windsor + * + * Licensed under the GNU General Public License Version 2 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef _PKGNG_BACKEND_PKGUTILS_H_ +#define _PKGNG_BACKEND_PKGUTILS_H_ + +#include +#include "pk-backend.h" +#include "pkg.h" + +PkInfoEnum pkgutils_pkg_install_state(struct pkg *pkg); +const char *pkgutils_pk_repo_of(struct pkg *pkg); +gchar *pkgutils_pkg_to_id(struct pkg *pkg); +gchar *pkgutils_pkg_to_id_through(struct pkg *pkg, const gchar **strv); +void pkgutils_emit(struct pkg *pkg, PkBackend *backend, PkInfoEnum info); + +#endif /* !_PKGNG_BACKEND_PKGUTILS_H_ */ Modified: soc2013/mattbw/backend/query.c ============================================================================== --- soc2013/mattbw/backend/query.c Sat Jul 6 08:59:27 2013 (r254229) +++ soc2013/mattbw/backend/query.c Sat Jul 6 09:03:22 2013 (r254230) @@ -28,6 +28,7 @@ #include "db.h" /* open_remote_db */ #include "hash_traverse.h" /* HASH_FOR */ #include "utils.h" /* string_match */ +#include "pkgutils.h" /* pkgutils_... */ struct query { int load_flags; @@ -43,14 +44,11 @@ gboolean local_repo; }; -static const char *get_repo_of(struct pkg *pkg); -static const char *get_repo_of_remote(struct pkg *pkg); static gboolean match(struct query *q, gchar **match_id_p, struct pkg **match_pkg_p); static gboolean match_id_in_it(struct pkgdb_it *it, struct query *q, gchar **match_id_p, struct pkg **match_pkg_p); static gboolean try_id_match(struct pkg *pkg, struct query *q, gchar **match_id); static int jobs_add_pkg(struct pkg_jobs *jobs, match_t type, struct pkg *pkg); static void query_free_contents(struct query *q); -static void query_pkg_to_id_through(struct pkg *pkg, gchar **name_p, const gchar **strv); /* Returns the backend stored inside the struct query. */ PkBackend * @@ -105,6 +103,7 @@ db = NULL; q = NULL; + no_error_yet = open_remote_db(&db, backend); pk_backend_set_percentage(backend, 0); @@ -118,6 +117,7 @@ no_error_yet = body(q); pk_backend_set_percentage(backend, ((i * 100) / len)); } + query_free(q); pkgdb_close(db); pk_backend_finished(backend); @@ -169,7 +169,7 @@ q->local_repo = TRUE; else if (pkg_repo_find_ident(q->data) == NULL) { pk_backend_error_code(backend, - PK_ERROR_ENUM_PACKAGE_ID_INVALID, + PK_ERROR_ENUM_REPO_NOT_FOUND, "no such repository"); success = FALSE; } @@ -229,7 +229,6 @@ "could not init pkg_jobs"); pkg_jobs_free(jobs); - } /* Deallocates a struct query and any contents it owns. */ @@ -242,80 +241,6 @@ } } -/* Converts a package to a PackageID. */ -void -query_pkg_to_id(struct pkg *pkg, gchar **id_p) -{ - const gchar **id_bits; - - /* Make sure the initial string vector's pointers are all NULL */ - id_bits = g_new0(const gchar *, 4); - - /* - * This is split through an intermediate function so the same code - * can be used for the ID-checking logic. - */ - query_pkg_to_id_through(pkg, id_p, id_bits); - - /* we don't own any of the strings, so we don't use g_strfreev. */ - g_free(id_bits); -} - -/* Gets the PackageKit repository name for the package. */ -static const char * -get_repo_of(struct pkg *pkg) -{ - const char *repo; - - switch (pkg_type(pkg)) { - case PKG_FILE: - repo = "local"; - break; - case PKG_INSTALLED: - repo = "installed"; - break; - case PKG_REMOTE: - repo = get_repo_of_remote(pkg); - break; - default: - repo = "unknown"; - break; - } - - return repo; -} - -/* - * Gets the PackageKit repository name for the (remote) package. - * - * Currently this is actually the pkgng repository ident. This might change. - * - * This does not need to be freed (possibly, TODO: check). - */ -static const char * -get_repo_of_remote(struct pkg *pkg) -{ - const char *repo; - const char *repo_name; - struct pkg_repo *repo_struct; - - repo = NULL; - - /* - * We can get the repo NAME directly, but we need the repo IDENT. - * Short of chopping bits of the string off in the assumption that - * the name is repo-IDENT, we'll have to grab it from the repo - * structure itself. - */ - pkg_get(pkg, PKG_REPONAME, &repo_name); - - repo_struct = pkg_repo_find_name(repo_name); - if (repo_struct) - repo = pkg_repo_ident(repo_struct); - - return repo; -} - /* * Performs a package database query against a (potentially partial) * PackageID, retrieving the matched package and its full PackageID. @@ -403,7 +328,9 @@ const gchar **pkg_id_bits; pkg_id_bits = g_new0(const gchar *, 4); - query_pkg_to_id_through(pkg, match_id, pkg_id_bits); + + g_free(*match_id); + *match_id = pkgutils_pkg_to_id_through(pkg, pkg_id_bits); /* * Succeed if this package's PackageID fields match the original @@ -432,30 +359,6 @@ return pkg_jobs_add(jobs, type, &name, 1); } -/* - * Converts a package to a PackageID, dumping the intermediate information - * into the pointed-to string vector (which must have at least 4 places, and - * they should be NULL). - */ -static void -query_pkg_to_id_through(struct pkg *pkg, gchar **id_p, const gchar **strv) -{ - - pkg_get(pkg, - PKG_NAME, strv + PK_PACKAGE_ID_NAME, - PKG_VERSION, strv + PK_PACKAGE_ID_VERSION, - PKG_ARCH, strv + PK_PACKAGE_ID_ARCH); - - strv[PK_PACKAGE_ID_DATA] = get_repo_of(pkg); - - if (*id_p != NULL) - g_free(*id_p); - *id_p = pk_package_id_build(strv[PK_PACKAGE_ID_NAME], - strv[PK_PACKAGE_ID_VERSION], - strv[PK_PACKAGE_ID_ARCH], - strv[PK_PACKAGE_ID_DATA]); -} - static void query_free_contents(struct query *q) { From owner-svn-soc-all@FreeBSD.ORG Sat Jul 6 09:22:42 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id A9606C5C for ; Sat, 6 Jul 2013 09:22:42 +0000 (UTC) (envelope-from mattbw@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 99D3C1F27 for ; Sat, 6 Jul 2013 09:22:42 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r669MgjR064595 for ; Sat, 6 Jul 2013 09:22:42 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r669MgKE064590 for svn-soc-all@FreeBSD.org; Sat, 6 Jul 2013 09:22:42 GMT (envelope-from mattbw@FreeBSD.org) Date: Sat, 6 Jul 2013 09:22:42 GMT Message-Id: <201307060922.r669MgKE064590@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to mattbw@FreeBSD.org using -f From: mattbw@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254231 - soc2013/mattbw/backend MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 06 Jul 2013 09:22:42 -0000 Author: mattbw Date: Sat Jul 6 09:22:42 2013 New Revision: 254231 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254231 Log: fix locking database issue Modified: soc2013/mattbw/backend/query.c Modified: soc2013/mattbw/backend/query.c ============================================================================== --- soc2013/mattbw/backend/query.c Sat Jul 6 09:03:22 2013 (r254230) +++ soc2013/mattbw/backend/query.c Sat Jul 6 09:22:42 2013 (r254231) @@ -278,6 +278,7 @@ it = NULL; if (it != NULL) success = match_id_in_it(it, q, match_id_p, match_pkg_p); + pkgdb_it_free(it); /* Next, try a remote search, again only if applicable. */ if (success == FALSE && (try_remote == TRUE)) @@ -286,6 +287,7 @@ it = NULL; if (it != NULL) success = match_id_in_it(it, q, match_id_p, match_pkg_p); + pkgdb_it_free(it); /* * Assume any error is due to not finding packages. At time of From owner-svn-soc-all@FreeBSD.ORG Sat Jul 6 09:35:57 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 928B6FFC for ; Sat, 6 Jul 2013 09:35:57 +0000 (UTC) (envelope-from mattbw@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 755ED1F97 for ; Sat, 6 Jul 2013 09:35:57 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r669Zvkv044824 for ; Sat, 6 Jul 2013 09:35:57 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r669ZvHo044817 for svn-soc-all@FreeBSD.org; Sat, 6 Jul 2013 09:35:57 GMT (envelope-from mattbw@FreeBSD.org) Date: Sat, 6 Jul 2013 09:35:57 GMT Message-Id: <201307060935.r669ZvHo044817@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to mattbw@FreeBSD.org using -f From: mattbw@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254232 - soc2013/mattbw/backend/actions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 06 Jul 2013 09:35:57 -0000 Author: mattbw Date: Sat Jul 6 09:35:57 2013 New Revision: 254232 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254232 Log: install-packages seems to work enough to install packages now Modified: soc2013/mattbw/backend/actions/install-packages.c Modified: soc2013/mattbw/backend/actions/install-packages.c ============================================================================== --- soc2013/mattbw/backend/actions/install-packages.c Sat Jul 6 09:22:42 2013 (r254231) +++ soc2013/mattbw/backend/actions/install-packages.c Sat Jul 6 09:35:57 2013 (r254232) @@ -32,6 +32,8 @@ static gboolean body(struct query *q); static gboolean sim_body(struct query *q); static void do_install_packages(struct pkg_jobs *jobs, struct query *q, gboolean simulate); +static void do_install_solved_job(struct pkg_jobs *jobs, PkBackend *backend, gboolean simulate); +static void do_install_solved_job_real(struct pkg_jobs *jobs, PkBackend *backend); static void emit(struct pkg *pkg, const gchar *id, struct query *q); static void job (struct pkg_jobs *jobs, struct query *q); static void sim_emit(struct pkg *pkg, const gchar *id, struct query *q); @@ -81,17 +83,18 @@ return query_emit_match(q, sim_emit); } +/* + * Installs (or pretends to install) an unsolved installation job. + */ static void do_install_packages(struct pkg_jobs *jobs, struct query *q, gboolean simulate) { - int err; PkBackend *backend; backend = query_backend(q); pk_backend_set_status(backend, PK_STATUS_ENUM_DEP_RESOLVE); - err = pkg_jobs_solve(jobs); - if (err != EPKG_OK) + if (pkg_jobs_solve(jobs) != EPKG_OK) pk_backend_error_code(backend, PK_ERROR_ENUM_DEP_RESOLUTION_FAILED, "could not solve the job"); @@ -99,20 +102,42 @@ pk_backend_error_code(backend, PK_ERROR_ENUM_INTERNAL_ERROR, "job contains no packages"); - else { - struct pkg *pkg; + else + do_install_solved_job(jobs, backend, simulate); +} + +/* + * Installs (or pretends to install) a fully solved installation job. + */ +static void +do_install_solved_job(struct pkg_jobs *jobs, + PkBackend *backend, + gboolean simulate) +{ + struct pkg *pkg; - pkg = NULL; - while (pkg_jobs(jobs, &pkg) == EPKG_OK) - pkgutils_emit(pkg, - backend, - pkgutils_pkg_install_state(pkg)); - - if (simulate == FALSE) - pk_backend_error_code(backend, - PK_ERROR_ENUM_NOT_SUPPORTED, - "not implemented yet"); - } + pkg = NULL; + while (pkg_jobs(jobs, &pkg) == EPKG_OK) + pkgutils_emit(pkg, + backend, + pkgutils_pkg_install_state(pkg)); + + if (simulate == FALSE) + do_install_solved_job_real(jobs, backend); +} + +/* + * Actually installs a fully solved installation job. + */ +static void +do_install_solved_job_real(struct pkg_jobs *jobs, PkBackend *backend) +{ + + pk_backend_set_status(backend, PK_STATUS_ENUM_INSTALL); + if (pkg_jobs_apply(jobs) != EPKG_OK) + pk_backend_error_code(backend, + PK_ERROR_ENUM_PACKAGE_FAILED_TO_INSTALL, + "job failed"); } /* From owner-svn-soc-all@FreeBSD.ORG Sat Jul 6 10:05:33 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 1D864797 for ; Sat, 6 Jul 2013 10:05:33 +0000 (UTC) (envelope-from mattbw@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id F39061067 for ; Sat, 6 Jul 2013 10:05:32 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r66A5WhV020135 for ; Sat, 6 Jul 2013 10:05:32 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r66A5WGK020130 for svn-soc-all@FreeBSD.org; Sat, 6 Jul 2013 10:05:32 GMT (envelope-from mattbw@FreeBSD.org) Date: Sat, 6 Jul 2013 10:05:32 GMT Message-Id: <201307061005.r66A5WGK020130@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to mattbw@FreeBSD.org using -f From: mattbw@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254241 - soc2013/mattbw/backend/actions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 06 Jul 2013 10:05:33 -0000 Author: mattbw Date: Sat Jul 6 10:05:32 2013 New Revision: 254241 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254241 Log: add events callback, doesn't seem to do a whole lot Modified: soc2013/mattbw/backend/actions/install-packages.c Modified: soc2013/mattbw/backend/actions/install-packages.c ============================================================================== --- soc2013/mattbw/backend/actions/install-packages.c Sat Jul 6 09:49:01 2013 (r254240) +++ soc2013/mattbw/backend/actions/install-packages.c Sat Jul 6 10:05:32 2013 (r254241) @@ -31,6 +31,7 @@ static gboolean body(struct query *q); static gboolean sim_body(struct query *q); +static int install_event_cb(void *backend_v, struct pkg_event *event); static void do_install_packages(struct pkg_jobs *jobs, struct query *q, gboolean simulate); static void do_install_solved_job(struct pkg_jobs *jobs, PkBackend *backend, gboolean simulate); static void do_install_solved_job_real(struct pkg_jobs *jobs, PkBackend *backend); @@ -84,6 +85,70 @@ } /* + * Event handler for events emitted by pkg during an installation. + */ +static int +install_event_cb(void *backend_v, struct pkg_event *event) +{ + PkBackend *backend; + + backend = (PkBackend *)backend_v; + + /* TODO: percentage bar */ + switch(event->type) { + case PKG_EVENT_INSTALL_BEGIN: + pkgutils_emit(event->e_install_begin.pkg, + backend, + PK_INFO_ENUM_INSTALLING); + break; + case PKG_EVENT_INSTALL_FINISHED: + pkgutils_emit(event->e_install_finished.pkg, + backend, + PK_INFO_ENUM_FINISHED); + break; + case PKG_EVENT_DEINSTALL_BEGIN: + pkgutils_emit(event->e_deinstall_begin.pkg, + backend, + PK_INFO_ENUM_REMOVING); + break; + case PKG_EVENT_DEINSTALL_FINISHED: + pkgutils_emit(event->e_deinstall_finished.pkg, + backend, + PK_INFO_ENUM_FINISHED); + break; + case PKG_EVENT_UPGRADE_BEGIN: + pkgutils_emit(event->e_upgrade_begin.pkg, + backend, + PK_INFO_ENUM_UPDATING); + break; + case PKG_EVENT_UPGRADE_FINISHED: + pkgutils_emit(event->e_upgrade_finished.pkg, + backend, + PK_INFO_ENUM_FINISHED); + break; + case PKG_EVENT_ERROR: + pk_backend_error_code(backend, + PK_ERROR_ENUM_PACKAGE_FAILED_TO_INSTALL, + event->e_pkg_error.msg); + break; + case PKG_EVENT_FILE_MISMATCH: + pk_backend_error_code(backend, + PK_ERROR_ENUM_PACKAGE_CORRUPT, + pkg_file_path(event->e_file_mismatch.file)); + break; + case PKG_EVENT_NOT_FOUND: + pk_backend_error_code(backend, + PK_ERROR_ENUM_PACKAGE_DOWNLOAD_FAILED, + event->e_not_found.pkg_name); + default: + /* Do nothing for unrecognised events */ + break; + } + + return EPKG_OK; +} + +/* * Installs (or pretends to install) an unsolved installation job. */ static void @@ -133,11 +198,15 @@ do_install_solved_job_real(struct pkg_jobs *jobs, PkBackend *backend) { + pkg_event_register(install_event_cb, backend); + pk_backend_set_status(backend, PK_STATUS_ENUM_INSTALL); if (pkg_jobs_apply(jobs) != EPKG_OK) pk_backend_error_code(backend, PK_ERROR_ENUM_PACKAGE_FAILED_TO_INSTALL, "job failed"); + + pkg_event_register(NULL, NULL); } /* From owner-svn-soc-all@FreeBSD.ORG Sat Jul 6 16:11:11 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 6939DA5C for ; Sat, 6 Jul 2013 16:11:11 +0000 (UTC) (envelope-from dpl@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 4A7A81BED for ; Sat, 6 Jul 2013 16:11:11 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r66GBAkX074943 for ; Sat, 6 Jul 2013 16:11:10 GMT (envelope-from dpl@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r66GBAu4074921 for svn-soc-all@FreeBSD.org; Sat, 6 Jul 2013 16:11:10 GMT (envelope-from dpl@FreeBSD.org) Date: Sat, 6 Jul 2013 16:11:10 GMT Message-Id: <201307061611.r66GBAu4074921@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to dpl@FreeBSD.org using -f From: dpl@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254245 - soc2013/dpl/head/contrib/bzip2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 06 Jul 2013 16:11:11 -0000 Author: dpl Date: Sat Jul 6 16:11:10 2013 New Revision: 254245 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254245 Log: Everything is adapted, but I get SIGSEGV. Searching for the cause. Modified: soc2013/dpl/head/contrib/bzip2/bzip2.c Modified: soc2013/dpl/head/contrib/bzip2/bzip2.c ============================================================================== --- soc2013/dpl/head/contrib/bzip2/bzip2.c Sat Jul 6 14:21:22 2013 (r254244) +++ soc2013/dpl/head/contrib/bzip2/bzip2.c Sat Jul 6 16:11:10 2013 (r254245) @@ -114,6 +114,7 @@ # undef MY_STAT # define MY_LSTAT stat # define MY_STAT stat +# define MY_STATS stat # undef SET_BINARY_MODE # define SET_BINARY_MODE(fd) \ do { \ @@ -143,10 +144,11 @@ # include # include -# define NORETURN /**/ -# define PATH_SEP '\\' -# define MY_LSTAT _stat +# define NORETURN /**/ +# define PATH_SEP '\\' +# define MY_LSTAT _stat # define MY_STAT _stat +# define MY_STATS _stat # define MY_S_ISREG(x) ((x) & _S_IFREG) # define MY_S_ISDIR(x) ((x) & _S_IFDIR) @@ -741,7 +743,7 @@ January 2002. (JRS 06-Jan-2002: other changes in 1.0.2 mean this is less likely to happen. But to be ultra-paranoid, we do the check anyway.) */ - retVal = MY_STAT ( inName, &statBuf ); + retVal = MY_STAT ( IN_FILENO, inName, &statBuf, 0 ); if (retVal == 0) { if (noisy) fprintf ( stderr, @@ -1021,12 +1023,12 @@ if in doubt, return True --*/ static -Bool notAStandardFile (int fd ) +Bool notAStandardFile (int fd, Char* name ) { IntNative i; struct MY_STATS statBuf; - i = MY_LSTAT ( fd, &statBuf ); + i = MY_LSTAT ( fd, name, &statBuf, AT_SYMLINK_NOFOLLOW ); if (i != 0) return True; if (MY_S_ISREG(statBuf.st_mode)) return False; return True; @@ -1038,12 +1040,12 @@ rac 11/21/98 see if file has hard links to it --*/ static -Int32 countHardLinks ( int fd ) +Int32 countHardLinks ( int fd, Char* name ) { IntNative i; - struct MY_STAT statBuf; + struct MY_STATS statBuf; - i = MY_LSTAT ( fd, &statBuf ); + i = MY_LSTAT ( fd, name, &statBuf, AT_SYMLINK_NOFOLLOW ); if (i != 0) return 0; return (statBuf.st_nlink - 1); } @@ -1074,16 +1076,16 @@ */ #if BZ_UNIX static -struct MY_STAT fileMetaInfo; +struct MY_STATS fileMetaInfo; #endif static -void saveInputFileMetaInfo ( Char *srcName ) +void saveInputFileMetaInfo ( int fd, Char *srcName ) { # if BZ_UNIX IntNative retVal; /* Note use of stat here, not lstat. */ - retVal = MY_STAT( srcName, &fileMetaInfo ); + retVal = MY_STAT( fd, srcName, &fileMetaInfo, 0 ); ERROR_IF_NOT_ZERO ( retVal ); # endif } @@ -1183,7 +1185,7 @@ pid_t forkpid; #endif Int32 n, i; - struct MY_STAT statBuf; + struct MY_STATS statBuf; deleteOutputOnInterrupt = False; @@ -1230,7 +1232,7 @@ } } if ( srcMode == SM_F2F || srcMode == SM_F2O ) { - MY_STAT(inName, &statBuf); + MY_STAT( IN_FILENO, inName, &statBuf, 0); if ( MY_S_ISDIR(statBuf.st_mode) ) { fprintf( stderr, "%s: Input file %s is a directory.\n", @@ -1239,7 +1241,7 @@ return; } } - if ( srcMode == SM_F2F && !forceOverwrite && notAStandardFile ( IN_FILENO )) { + if ( srcMode == SM_F2F && !forceOverwrite && notAStandardFile ( inName, IN_FILENO )) { if (noisy) fprintf ( stderr, "%s: Input file %s is not a normal file.\n", progName, inName ); @@ -1257,7 +1259,7 @@ } } if ( srcMode == SM_F2F && !forceOverwrite && - (n=countHardLinks ( IN_FILENO )) > 0) { + (n=countHardLinks ( IN_FILENO, inName )) > 0) { fprintf ( stderr, "%s: Input file %s has %d other link%s.\n", progName, inName, n, n > 1 ? "s" : "" ); setExit(1); @@ -1267,7 +1269,7 @@ if ( srcMode == SM_F2F ) { /* Save the file's meta-info before we open it. Doing it later means we mess up the access times. */ - saveInputFileMetaInfo ( inName ); + saveInputFileMetaInfo ( IN_FILENO, inName ); } switch ( srcMode ) { @@ -1348,7 +1350,7 @@ wait(NULL); return; } else if (forkpid == 0){ - limitfd(IN_FILENO)); + limitfd(IN_FILENO); limitfd(OUT_FILENO); limitfd(STDERR_FILENO); if (cap_enter() < 0 && errno != ENOSYS){ @@ -1395,7 +1397,7 @@ Int32 n, i; Bool magicNumberOK; Bool cantGuess; - struct MY_STAT statBuf; + struct MY_STATS statBuf; deleteOutputOnInterrupt = False; @@ -1438,7 +1440,7 @@ return; } if ( srcMode == SM_F2F || srcMode == SM_F2O ) { - MY_STAT(inName, &statBuf); + MY_STAT(IN_FILENO, inName, &statBuf, 0); if ( MY_S_ISDIR(statBuf.st_mode) ) { fprintf( stderr, "%s: Input file %s is a directory.\n", @@ -1447,7 +1449,7 @@ return; } } - if ( srcMode == SM_F2F && !forceOverwrite && notAStandardFile ( IN_FILENO )) { + if ( srcMode == SM_F2F && !forceOverwrite && notAStandardFile ( inName, IN_FILENO )) { if (noisy) fprintf ( stderr, "%s: Input file %s is not a normal file.\n", progName, inName ); @@ -1472,7 +1474,7 @@ } } if ( srcMode == SM_F2F && !forceOverwrite && - (n=countHardLinks ( IN_FILENO ) ) > 0) { + (n=countHardLinks ( IN_FILENO, inName ) ) > 0) { fprintf ( stderr, "%s: Input file %s has %d other link%s.\n", progName, inName, n, n > 1 ? "s" : "" ); setExit(1); @@ -1482,7 +1484,7 @@ if ( srcMode == SM_F2F ) { /* Save the file's meta-info before we open it. Doing it later means we mess up the access times. */ - saveInputFileMetaInfo ( inName ); + saveInputFileMetaInfo ( IN_FILENO, inName ); } switch ( srcMode ) { @@ -1616,7 +1618,7 @@ { FILE *inStr; Bool allOK; - struct MY_STAT statBuf; + struct MY_STATS statBuf; deleteOutputOnInterrupt = False; @@ -1644,7 +1646,7 @@ return; } if ( srcMode != SM_I2O ) { - MY_STAT(inName, &statBuf); + MY_STAT(inName, IN_FILENO, &statBuf, 0); if ( MY_S_ISDIR(statBuf.st_mode) ) { fprintf( stderr, "%s: Input file %s is a directory.\n", From owner-svn-soc-all@FreeBSD.ORG Sat Jul 6 17:34:34 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 25CCC9B0 for ; Sat, 6 Jul 2013 17:34:34 +0000 (UTC) (envelope-from mattbw@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 15F2D1DEB for ; Sat, 6 Jul 2013 17:34:34 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r66HYXSW062222 for ; Sat, 6 Jul 2013 17:34:33 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r66HYXsw062205 for svn-soc-all@FreeBSD.org; Sat, 6 Jul 2013 17:34:33 GMT (envelope-from mattbw@FreeBSD.org) Date: Sat, 6 Jul 2013 17:34:33 GMT Message-Id: <201307061734.r66HYXsw062205@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to mattbw@FreeBSD.org using -f From: mattbw@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254247 - in soc2013/mattbw/backend: . actions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 06 Jul 2013 17:34:34 -0000 Author: mattbw Date: Sat Jul 6 17:34:33 2013 New Revision: 254247 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254247 Log: tidy up query system interface Modified: soc2013/mattbw/backend/actions/get-details.c soc2013/mattbw/backend/actions/get-files.c soc2013/mattbw/backend/actions/install-packages.c soc2013/mattbw/backend/query.c soc2013/mattbw/backend/query.h Modified: soc2013/mattbw/backend/actions/get-details.c ============================================================================== --- soc2013/mattbw/backend/actions/get-details.c Sat Jul 6 16:51:30 2013 (r254246) +++ soc2013/mattbw/backend/actions/get-details.c Sat Jul 6 17:34:33 2013 (r254247) @@ -30,7 +30,6 @@ static const int LOAD_FLAGS = PKG_LOAD_BASIC | PKG_LOAD_LICENSES; -static gboolean body(struct query *q); static void emit(struct pkg *pkg, const gchar *id, struct query *q); /* @@ -40,17 +39,7 @@ gboolean get_details_thread(PkBackend *backend) { - return query_for_all_ids(backend, LOAD_FLAGS, body); -} - -/* - * Look up and emit package details for the given PackageID, if it can be - * found. - */ -static gboolean -body(struct query *q) -{ - return query_emit_match(q, emit); + return query_match_id_to_emitter(backend, LOAD_FLAGS, emit); } /* Modified: soc2013/mattbw/backend/actions/get-files.c ============================================================================== --- soc2013/mattbw/backend/actions/get-files.c Sat Jul 6 16:51:30 2013 (r254246) +++ soc2013/mattbw/backend/actions/get-files.c Sat Jul 6 17:34:33 2013 (r254247) @@ -34,7 +34,6 @@ static const int FILE_NAME_STEP = 10; static const int LOAD_FLAGS = PKG_LOAD_BASIC | PKG_LOAD_FILES; -static gboolean body(struct query *q); static void emit(struct pkg *pkg, const gchar *id, struct query *q); /* @@ -44,17 +43,8 @@ gboolean get_files_thread(PkBackend *backend) { - return query_for_all_ids(backend, LOAD_FLAGS, body); -} -/* - * Look up and emit package details for the given PackageID, if it can be - * found. - */ -static gboolean -body(struct query *q) -{ - return query_emit_match(q, emit); + return query_match_id_to_emitter(backend, LOAD_FLAGS, emit); } /* @@ -66,27 +56,28 @@ struct pkg_file *file; int err; int sb_err; - struct sbuf *sb; + struct sbuf *sb; - /* Construct a string of the form ";file1;file2;file3;...". - * We'll get rid of the initial ; later. - */ + /* + * Construct a string of the form ";file1;file2;file3;...". We'll get + * rid of the initial ; later. + */ sb = sbuf_new_auto(); for (HASH_FOR(err, pkg_files, pkg, &file)) sbuf_printf(sb, ";%s", pkg_file_path(file)); sb_err = sbuf_finish(sb); if (sb_err) pk_backend_error_code(query_backend(q), - PK_ERROR_ENUM_INTERNAL_ERROR, - "couldn't construct filename string"); + PK_ERROR_ENUM_INTERNAL_ERROR, + "couldn't construct filename string"); else { - char *filenames; + char *filenames; filenames = sbuf_data(sb); - /* Skip over any initial ;*/ + /* Skip over any initial ; */ if (filenames[0] == ';') filenames++; - + pk_backend_files(query_backend(q), id, filenames); } sbuf_delete(sb); Modified: soc2013/mattbw/backend/actions/install-packages.c ============================================================================== --- soc2013/mattbw/backend/actions/install-packages.c Sat Jul 6 16:51:30 2013 (r254246) +++ soc2013/mattbw/backend/actions/install-packages.c Sat Jul 6 17:34:33 2013 (r254247) @@ -29,15 +29,11 @@ #include "actions.h" /* install_packages_thread prototype */ -static gboolean body(struct query *q); -static gboolean sim_body(struct query *q); static int install_event_cb(void *backend_v, struct pkg_event *event); static void do_install_packages(struct pkg_jobs *jobs, struct query *q, gboolean simulate); static void do_install_solved_job(struct pkg_jobs *jobs, PkBackend *backend, gboolean simulate); static void do_install_solved_job_real(struct pkg_jobs *jobs, PkBackend *backend); -static void emit(struct pkg *pkg, const gchar *id, struct query *q); -static void job (struct pkg_jobs *jobs, struct query *q); -static void sim_emit(struct pkg *pkg, const gchar *id, struct query *q); +static void job(struct pkg_jobs *jobs, struct query *q); static void sim_job(struct pkg_jobs *jobs, struct query *q); @@ -49,7 +45,7 @@ install_packages_thread(PkBackend *backend) { - return query_for_all_ids(backend, PKG_LOAD_BASIC, body); + return query_match_id_to_job(backend, PKG_JOBS_INSTALL, job); } /* @@ -60,28 +56,7 @@ simulate_install_packages_thread(PkBackend *backend) { - return query_for_all_ids(backend, PKG_LOAD_BASIC, sim_body); -} - -/* - * Look up and attempt to install the given PackageID, if it can be found. - */ -static gboolean -body(struct query *q) -{ - - return query_emit_match(q, emit); -} - -/* - * Look up and attempt to simulate installing the given PackageID, if it can - * be found. - */ -static gboolean -sim_body(struct query *q) -{ - - return query_emit_match(q, sim_emit); + return query_match_id_to_job(backend, PKG_JOBS_INSTALL, sim_job); } /* @@ -210,17 +185,6 @@ } /* - * Tries to install the given package. - */ -static void -emit(struct pkg *pkg, const gchar *id, struct query *q) -{ - - INTENTIONALLY_IGNORE(id); - return query_emit_to_job(pkg, q, PKG_JOBS_INSTALL, job); -} - -/* * Tries to process the given solved installation jobs. */ static void @@ -231,17 +195,6 @@ } /* - * Tries to install the given package. - */ -static void -sim_emit(struct pkg *pkg, const gchar *id, struct query *q) -{ - - INTENTIONALLY_IGNORE(id); - return query_emit_to_job(pkg, q, PKG_JOBS_INSTALL, sim_job); -} - -/* * Tries to simulate processing the given installation jobs. */ static void Modified: soc2013/mattbw/backend/query.c ============================================================================== --- soc2013/mattbw/backend/query.c Sat Jul 6 16:51:30 2013 (r254246) +++ soc2013/mattbw/backend/query.c Sat Jul 6 17:34:33 2013 (r254247) @@ -42,12 +42,20 @@ gboolean any_repo; gboolean local_repo; + + /* Query result routing */ + emit_ptr emitter; + job_emit_ptr job_emitter; + pkg_jobs_t job_type; }; static gboolean match(struct query *q, gchar **match_id_p, struct pkg **match_pkg_p); static gboolean match_id_in_it(struct pkgdb_it *it, struct query *q, gchar **match_id_p, struct pkg **match_pkg_p); static gboolean try_id_match(struct pkg *pkg, struct query *q, gchar **match_id); +static gboolean query_do(PkBackend *backend, int load_flags, emit_ptr emitter, pkg_jobs_t job_type, job_emit_ptr job_emitter, query_body_ptr body); +static gboolean query_match(struct query *q); static int jobs_add_pkg(struct pkg_jobs *jobs, match_t type, struct pkg *pkg); +static void query_emit_to_job(struct pkg *pkg, const gchar *id, struct query *q); static void query_free_contents(struct query *q); /* Returns the backend stored inside the struct query. */ @@ -57,80 +65,15 @@ return (q == NULL ? NULL : q->backend); } -/* - * Performs a package database query against a PackageID, and then hands the - * matching result to an emitter function. - */ -gboolean -query_emit_match(struct query *q, emit_ptr emitter) -{ - gboolean success; - gchar *match_id; - struct pkg *match_pkg; - - match_id = NULL; - match_pkg = NULL; - success = match(q, &match_id, &match_pkg); - if (success == TRUE && match_id != NULL && match_pkg != NULL) - emitter(match_pkg, match_id, q); - - pkg_free(match_pkg); - g_free(match_id); - - return success; -} - -/* - * Iterates a query function over all PackageIDs provided for this job. - * - * This provides each iterating function call with a query structure ready to - * run and updates the percentage after each iteration. - * - * It also *finishes* the backend job. - */ -gboolean -query_for_all_ids(PkBackend *backend, int load_flags, query_body_ptr body) -{ - gboolean no_error_yet; - gchar **package_ids; - guint len; - guint i; - struct pkgdb *db; - struct query *q; - - package_ids = pk_backend_get_strv(backend, "package_ids"); - len = g_strv_length(package_ids); - - db = NULL; - q = NULL; - - no_error_yet = open_remote_db(&db, backend); - - pk_backend_set_percentage(backend, 0); - for (i = 0; i < len && no_error_yet; i++) { - no_error_yet = query_init(package_ids[i], - backend, - db, - load_flags, - &q); - if (no_error_yet == TRUE) - no_error_yet = body(q); - pk_backend_set_percentage(backend, ((i * 100) / len)); - } - query_free(q); - pkgdb_close(db); - - pk_backend_finished(backend); - - return no_error_yet; -} - /* Creates a struct query for the given backend and target ID. */ gboolean query_init(const gchar *id, PkBackend *backend, struct pkgdb *db, int load_flags, + emit_ptr emitter, + pkg_jobs_t job_type, + job_emit_ptr job_emitter, struct query **q_p) { gboolean success; @@ -146,6 +89,9 @@ q->backend = backend; q->load_flags = load_flags; q->db = db; + q->emitter = emitter; + q->job_type = job_type; + q->job_emitter = job_emitter; success = split_id(id, &(q->strv), @@ -194,26 +140,134 @@ } /* + * Runs a query over the PackageIDs selected in the backend that sends the first + * match to an emitting function. + */ +gboolean +query_match_id_to_emitter(PkBackend *backend, int load_flags, emit_ptr emitter) +{ + + return query_do(backend, + load_flags, + emitter, + PKG_JOBS_INSTALL, + NULL, + query_match); +} + +/* + * Runs a query over the PackageIDs selected in the backend that converts the + * first match into a job of the given type and hands it to a function for + * solving and applying. + */ +gboolean +query_match_id_to_job(PkBackend *backend, pkg_jobs_t type, job_emit_ptr emitter) +{ + + return query_do(backend, + PKG_LOAD_BASIC, + query_emit_to_job, + type, + emitter, + query_match); +} + +/* + * Performs a package database query against a PackageID, and then emits + * the first matching result. + */ +static gboolean +query_match(struct query *q) +{ + gboolean success; + gchar *match_id; + struct pkg *match_pkg; + + match_id = NULL; + match_pkg = NULL; + success = match(q, &match_id, &match_pkg); + if (success == TRUE && match_id != NULL && match_pkg != NULL) + q->emitter(match_pkg, match_id, q); + + pkg_free(match_pkg); + g_free(match_id); + + return success; +} + +/* + * Iterates a query function over all PackageIDs provided for this job. + * + * This provides each iterating function call with a query structure ready to + * run and updates the percentage after each iteration. + * + * It also *finishes* the backend job. + */ +static gboolean +query_do(PkBackend *backend, + int load_flags, + emit_ptr emitter, + pkg_jobs_t job_type, + job_emit_ptr job_emitter, + query_body_ptr body) +{ + gboolean no_error_yet; + gchar **package_ids; + guint len; + guint i; + struct pkgdb *db; + struct query *q; + + package_ids = pk_backend_get_strv(backend, "package_ids"); + len = g_strv_length(package_ids); + + db = NULL; + q = NULL; + + no_error_yet = open_remote_db(&db, backend); + + pk_backend_set_percentage(backend, 0); + for (i = 0; i < len && no_error_yet; i++) { + no_error_yet = query_init(package_ids[i], + backend, + db, + load_flags, + emitter, + job_type, + job_emitter, + &q); + if (no_error_yet == TRUE) + no_error_yet = body(q); + pk_backend_set_percentage(backend, ((i * 100) / len)); + } + query_free(q); + pkgdb_close(db); + + pk_backend_finished(backend); + + return no_error_yet; +} + +/* * For adapting an emitter function into one that solves and applies a job. */ -void -query_emit_to_job(struct pkg *pkg, - struct query *q, - pkg_jobs_t type, - job_emit_ptr job_emitter) +static void +query_emit_to_job(struct pkg *pkg, const gchar *id, struct query *q) { int err; struct pkg_jobs *jobs; + INTENTIONALLY_IGNORE(id); + jobs = NULL; - err = pkg_jobs_new(&jobs, type, q->db); + err = pkg_jobs_new(&jobs, q->job_type, q->db); if (err == EPKG_OK) { if (q->data != NULL) err = pkg_jobs_set_repository(jobs, q->data); if (err == EPKG_OK) { err = jobs_add_pkg(jobs, MATCH_EXACT, pkg); if (err == EPKG_OK) - job_emitter(jobs, q); + q->job_emitter(jobs, q); else pk_backend_error_code(q->backend, PK_ERROR_ENUM_INTERNAL_ERROR, @@ -222,7 +276,6 @@ pk_backend_error_code(q->backend, PK_ERROR_ENUM_REPO_NOT_FOUND, "could not set repo"); - } else pk_backend_error_code(q->backend, PK_ERROR_ENUM_INTERNAL_ERROR, Modified: soc2013/mattbw/backend/query.h ============================================================================== --- soc2013/mattbw/backend/query.h Sat Jul 6 16:51:30 2013 (r254246) +++ soc2013/mattbw/backend/query.h Sat Jul 6 17:34:33 2013 (r254247) @@ -32,10 +32,11 @@ typedef gboolean (*query_body_ptr) (struct query *q); PkBackend *query_backend(struct query *q); -gboolean query_emit_match(struct query *q, emit_ptr emitter); -gboolean query_for_all_ids(PkBackend *backend, int load_flags, query_body_ptr body); -gboolean query_init(const gchar *id, PkBackend *backend, struct pkgdb *db, int load_flags, struct query **q_p); -void query_emit_to_job(struct pkg *pkg, struct query *q, pkg_jobs_t type, job_emit_ptr job_emitter); +gboolean query_init(const gchar *id, PkBackend *backend, struct pkgdb *db, int load_flags, emit_ptr emitter, pkg_jobs_t job_type, job_emit_ptr job_emitter, struct query **q_p); + +gboolean query_match_id_to_emitter(PkBackend *backend, int load_flags, emit_ptr emitter); +gboolean query_match_id_to_job(PkBackend *backend, pkg_jobs_t type, job_emit_ptr job_emitter); + void query_free(struct query *q); void query_pkg_to_id(struct pkg *pkg, gchar **id_p); From owner-svn-soc-all@FreeBSD.ORG Sat Jul 6 17:40:46 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 5724CA66 for ; Sat, 6 Jul 2013 17:40:46 +0000 (UTC) (envelope-from dpl@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 49E9B1E15 for ; Sat, 6 Jul 2013 17:40:46 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r66HekJI037126 for ; Sat, 6 Jul 2013 17:40:46 GMT (envelope-from dpl@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r66HekM6037110 for svn-soc-all@FreeBSD.org; Sat, 6 Jul 2013 17:40:46 GMT (envelope-from dpl@FreeBSD.org) Date: Sat, 6 Jul 2013 17:40:46 GMT Message-Id: <201307061740.r66HekM6037110@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to dpl@FreeBSD.org using -f From: dpl@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254248 - soc2013/dpl/head/contrib/bzip2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 06 Jul 2013 17:40:46 -0000 Author: dpl Date: Sat Jul 6 17:40:46 2013 New Revision: 254248 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254248 Log: Little changes, I get SIGSEGV at line 1234. Modified: soc2013/dpl/head/contrib/bzip2/bzip2.c Modified: soc2013/dpl/head/contrib/bzip2/bzip2.c ============================================================================== --- soc2013/dpl/head/contrib/bzip2/bzip2.c Sat Jul 6 17:34:33 2013 (r254247) +++ soc2013/dpl/head/contrib/bzip2/bzip2.c Sat Jul 6 17:40:46 2013 (r254248) @@ -1177,12 +1177,11 @@ static void compress ( Char *name ) { -#ifndef CAPSICUM - FILE *inStr; - FILE *outStr; -#endif #if CAPSICUM pid_t forkpid; +#elif + FILE *inStr; + FILE *outStr; #endif Int32 n, i; struct MY_STATS statBuf; @@ -1387,13 +1386,13 @@ static void uncompress ( Char *name ) { -#ifndef CAPSICUM - FILE *inStr; - FILE *outStr; -#endif #if CAPSICUM pid_t forkpid; +#elif + FILE *inStr; + FILE *outStr; #endif + Int32 n, i; Bool magicNumberOK; Bool cantGuess; @@ -1616,7 +1615,9 @@ static void testf ( Char *name ) { +# ifndef CAPSICUM FILE *inStr; +# endif Bool allOK; struct MY_STATS statBuf; From owner-svn-soc-all@FreeBSD.ORG Sat Jul 6 21:11:01 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id ADA68260 for ; Sat, 6 Jul 2013 21:11:01 +0000 (UTC) (envelope-from mattbw@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 8F3CC160C for ; Sat, 6 Jul 2013 21:11:01 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r66LB18a054627 for ; Sat, 6 Jul 2013 21:11:01 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r66LB1s4054602 for svn-soc-all@FreeBSD.org; Sat, 6 Jul 2013 21:11:01 GMT (envelope-from mattbw@FreeBSD.org) Date: Sat, 6 Jul 2013 21:11:01 GMT Message-Id: <201307062111.r66LB1s4054602@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to mattbw@FreeBSD.org using -f From: mattbw@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254258 - in soc2013/mattbw/backend: . actions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 06 Jul 2013 21:11:01 -0000 Author: mattbw Date: Sat Jul 6 21:11:01 2013 New Revision: 254258 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254258 Log: some cleanup and splinting Modified: soc2013/mattbw/backend/actions/get-details.c soc2013/mattbw/backend/actions/get-files.c soc2013/mattbw/backend/actions/install-packages.c soc2013/mattbw/backend/db.c soc2013/mattbw/backend/query.c soc2013/mattbw/backend/query.h Modified: soc2013/mattbw/backend/actions/get-details.c ============================================================================== --- soc2013/mattbw/backend/actions/get-details.c Sat Jul 6 20:39:44 2013 (r254257) +++ soc2013/mattbw/backend/actions/get-details.c Sat Jul 6 21:11:01 2013 (r254258) @@ -28,9 +28,9 @@ #include "actions.h" /* get_details_thread prototype */ -static const int LOAD_FLAGS = PKG_LOAD_BASIC | PKG_LOAD_LICENSES; +static const unsigned int LOAD_FLAGS = PKG_LOAD_BASIC | PKG_LOAD_LICENSES; -static void emit(struct pkg *pkg, const gchar *id, struct query *q); +static gboolean emit(struct pkg *pkg, const gchar *id, struct query *q); /* * The thread that performs a GetDetails operation. Should be invoked by the @@ -39,13 +39,14 @@ gboolean get_details_thread(PkBackend *backend) { + return query_match_id_to_emitter(backend, LOAD_FLAGS, emit); } /* * Emits the given package's details. To be used as an iterating function. */ -static void +static gboolean emit(struct pkg *pkg, const gchar *id, struct query *q) { const char *description; @@ -54,17 +55,19 @@ int64_t flatsize; /* Information not already part of the PackageID */ + description = origin = www = NULL; + flatsize = 0; pkg_get(pkg, PKG_DESC, &description, PKG_FLATSIZE, &flatsize, PKG_ORIGIN, &origin, PKG_WWW, &www); - pk_backend_details(query_backend(q), - id, - license_name_from_pkg(pkg), - group_from_origin(origin), - description, - www, - flatsize); + return pk_backend_details(query_backend(q), + id, + license_name_from_pkg(pkg), + group_from_origin(origin), + description, + www, + flatsize); } Modified: soc2013/mattbw/backend/actions/get-files.c ============================================================================== --- soc2013/mattbw/backend/actions/get-files.c Sat Jul 6 20:39:44 2013 (r254257) +++ soc2013/mattbw/backend/actions/get-files.c Sat Jul 6 21:11:01 2013 (r254258) @@ -32,9 +32,9 @@ #include "actions.h" /* get_files_thread prototype */ static const int FILE_NAME_STEP = 10; -static const int LOAD_FLAGS = PKG_LOAD_BASIC | PKG_LOAD_FILES; +static const unsigned int LOAD_FLAGS = PKG_LOAD_BASIC | PKG_LOAD_FILES; -static void emit(struct pkg *pkg, const gchar *id, struct query *q); +static gboolean emit(struct pkg *pkg, const gchar *id, struct query *q); /* * The thread that performs a GetDetails operation. Should be invoked by the @@ -50,14 +50,18 @@ /* * Emits the given package's files. To be used as an iterating function. */ -static void +static gboolean emit(struct pkg *pkg, const gchar *id, struct query *q) { - struct pkg_file *file; + gboolean success; int err; int sb_err; + char *filenames; + struct pkg_file *file; struct sbuf *sb; + success = FALSE; + /* * Construct a string of the form ";file1;file2;file3;...". We'll get * rid of the initial ; later. @@ -65,20 +69,23 @@ sb = sbuf_new_auto(); for (HASH_FOR(err, pkg_files, pkg, &file)) sbuf_printf(sb, ";%s", pkg_file_path(file)); + sb_err = sbuf_finish(sb); - if (sb_err) + if (sb_err) { pk_backend_error_code(query_backend(q), PK_ERROR_ENUM_INTERNAL_ERROR, "couldn't construct filename string"); - else { - char *filenames; + goto cleanup; + } - filenames = sbuf_data(sb); - /* Skip over any initial ; */ - if (filenames[0] == ';') - filenames++; + filenames = sbuf_data(sb); + /* Skip over any initial ; */ + if (filenames[0] == ';') + filenames++; - pk_backend_files(query_backend(q), id, filenames); - } + success = pk_backend_files(query_backend(q), id, filenames); + +cleanup: sbuf_delete(sb); + return success; } Modified: soc2013/mattbw/backend/actions/install-packages.c ============================================================================== --- soc2013/mattbw/backend/actions/install-packages.c Sat Jul 6 20:39:44 2013 (r254257) +++ soc2013/mattbw/backend/actions/install-packages.c Sat Jul 6 21:11:01 2013 (r254258) @@ -29,12 +29,12 @@ #include "actions.h" /* install_packages_thread prototype */ +static gboolean do_install_packages(struct pkg_jobs *jobs, struct query *q, gboolean simulate); +static gboolean do_install_solved_job(struct pkg_jobs *jobs, PkBackend *backend, gboolean simulate); +static gboolean do_install_solved_job_real(struct pkg_jobs *jobs, PkBackend *backend); +static gboolean job (struct pkg_jobs *jobs, struct query *q); +static gboolean sim_job(struct pkg_jobs *jobs, struct query *q); static int install_event_cb(void *backend_v, struct pkg_event *event); -static void do_install_packages(struct pkg_jobs *jobs, struct query *q, gboolean simulate); -static void do_install_solved_job(struct pkg_jobs *jobs, PkBackend *backend, gboolean simulate); -static void do_install_solved_job_real(struct pkg_jobs *jobs, PkBackend *backend); -static void job(struct pkg_jobs *jobs, struct query *q); -static void sim_job(struct pkg_jobs *jobs, struct query *q); /* @@ -60,77 +60,15 @@ } /* - * Event handler for events emitted by pkg during an installation. - */ -static int -install_event_cb(void *backend_v, struct pkg_event *event) -{ - PkBackend *backend; - - backend = (PkBackend *)backend_v; - - /* TODO: percentage bar */ - switch(event->type) { - case PKG_EVENT_INSTALL_BEGIN: - pkgutils_emit(event->e_install_begin.pkg, - backend, - PK_INFO_ENUM_INSTALLING); - break; - case PKG_EVENT_INSTALL_FINISHED: - pkgutils_emit(event->e_install_finished.pkg, - backend, - PK_INFO_ENUM_FINISHED); - break; - case PKG_EVENT_DEINSTALL_BEGIN: - pkgutils_emit(event->e_deinstall_begin.pkg, - backend, - PK_INFO_ENUM_REMOVING); - break; - case PKG_EVENT_DEINSTALL_FINISHED: - pkgutils_emit(event->e_deinstall_finished.pkg, - backend, - PK_INFO_ENUM_FINISHED); - break; - case PKG_EVENT_UPGRADE_BEGIN: - pkgutils_emit(event->e_upgrade_begin.pkg, - backend, - PK_INFO_ENUM_UPDATING); - break; - case PKG_EVENT_UPGRADE_FINISHED: - pkgutils_emit(event->e_upgrade_finished.pkg, - backend, - PK_INFO_ENUM_FINISHED); - break; - case PKG_EVENT_ERROR: - pk_backend_error_code(backend, - PK_ERROR_ENUM_PACKAGE_FAILED_TO_INSTALL, - event->e_pkg_error.msg); - break; - case PKG_EVENT_FILE_MISMATCH: - pk_backend_error_code(backend, - PK_ERROR_ENUM_PACKAGE_CORRUPT, - pkg_file_path(event->e_file_mismatch.file)); - break; - case PKG_EVENT_NOT_FOUND: - pk_backend_error_code(backend, - PK_ERROR_ENUM_PACKAGE_DOWNLOAD_FAILED, - event->e_not_found.pkg_name); - default: - /* Do nothing for unrecognised events */ - break; - } - - return EPKG_OK; -} - -/* * Installs (or pretends to install) an unsolved installation job. */ -static void +static gboolean do_install_packages(struct pkg_jobs *jobs, struct query *q, gboolean simulate) { + gboolean success; PkBackend *backend; + success = FALSE; backend = query_backend(q); pk_backend_set_status(backend, PK_STATUS_ENUM_DEP_RESOLVE); @@ -143,19 +81,23 @@ PK_ERROR_ENUM_INTERNAL_ERROR, "job contains no packages"); else - do_install_solved_job(jobs, backend, simulate); + success = do_install_solved_job(jobs, backend, simulate); + + return success; } /* * Installs (or pretends to install) a fully solved installation job. */ -static void +static gboolean do_install_solved_job(struct pkg_jobs *jobs, PkBackend *backend, gboolean simulate) { + gboolean success; struct pkg *pkg; + success = TRUE; pkg = NULL; while (pkg_jobs(jobs, &pkg) == EPKG_OK) pkgutils_emit(pkg, @@ -163,43 +105,118 @@ pkgutils_pkg_install_state(pkg)); if (simulate == FALSE) - do_install_solved_job_real(jobs, backend); + success = do_install_solved_job_real(jobs, backend); + + return success; } /* * Actually installs a fully solved installation job. */ -static void +static gboolean do_install_solved_job_real(struct pkg_jobs *jobs, PkBackend *backend) { - + gboolean success; + + success = FALSE; + pkg_event_register(install_event_cb, backend); pk_backend_set_status(backend, PK_STATUS_ENUM_INSTALL); - if (pkg_jobs_apply(jobs) != EPKG_OK) + if (pkg_jobs_apply(jobs) == EPKG_OK) + success = TRUE; + else pk_backend_error_code(backend, - PK_ERROR_ENUM_PACKAGE_FAILED_TO_INSTALL, + PK_ERROR_ENUM_PACKAGE_FAILED_TO_INSTALL, "job failed"); pkg_event_register(NULL, NULL); + + return success; } /* * Tries to process the given solved installation jobs. */ -static void +static gboolean job(struct pkg_jobs *jobs, struct query *q) { - do_install_packages(jobs, q, FALSE); + return do_install_packages(jobs, q, FALSE); } /* * Tries to simulate processing the given installation jobs. */ -static void +static gboolean sim_job(struct pkg_jobs *jobs, struct query *q) { - do_install_packages(jobs, q, TRUE); + return do_install_packages(jobs, q, TRUE); +} + +/* + * Event handler for events emitted by pkg during an installation. + */ +static int +install_event_cb(void *backend_v, struct pkg_event *event) +{ + PkBackend *backend; + + backend = (PkBackend *)backend_v; + + /* TODO: percentage bar */ + switch (event->type) { + case PKG_EVENT_INSTALL_BEGIN: + pkgutils_emit(event->e_install_begin.pkg, + backend, + PK_INFO_ENUM_INSTALLING); + break; + case PKG_EVENT_INSTALL_FINISHED: + pkgutils_emit(event->e_install_finished.pkg, + backend, + PK_INFO_ENUM_FINISHED); + break; + case PKG_EVENT_DEINSTALL_BEGIN: + pkgutils_emit(event->e_deinstall_begin.pkg, + backend, + PK_INFO_ENUM_REMOVING); + break; + case PKG_EVENT_DEINSTALL_FINISHED: + pkgutils_emit(event->e_deinstall_finished.pkg, + backend, + PK_INFO_ENUM_FINISHED); + break; + case PKG_EVENT_UPGRADE_BEGIN: + pkgutils_emit(event->e_upgrade_begin.pkg, + backend, + PK_INFO_ENUM_UPDATING); + break; + case PKG_EVENT_UPGRADE_FINISHED: + pkgutils_emit(event->e_upgrade_finished.pkg, + backend, + PK_INFO_ENUM_FINISHED); + break; + case PKG_EVENT_ERROR: + pk_backend_error_code(backend, + PK_ERROR_ENUM_PACKAGE_FAILED_TO_INSTALL, + event->e_pkg_error.msg); + break; + case PKG_EVENT_FILE_MISMATCH: + pk_backend_error_code(backend, + PK_ERROR_ENUM_PACKAGE_CORRUPT, + pkg_file_path(event->e_file_mismatch.file)); + break; + case PKG_EVENT_NOT_FOUND: + pk_backend_error_code(backend, + PK_ERROR_ENUM_PACKAGE_DOWNLOAD_FAILED, + event->e_not_found.pkg_name); + default: + /* Do nothing for unrecognised events */ + break; + } + + return EPKG_OK; } + + Modified: soc2013/mattbw/backend/db.c ============================================================================== --- soc2013/mattbw/backend/db.c Sat Jul 6 20:39:44 2013 (r254257) +++ soc2013/mattbw/backend/db.c Sat Jul 6 21:11:01 2013 (r254258) @@ -27,6 +27,10 @@ #include "db.h" /* prototypes */ #include "utils.h" /* null_if_empty, split_id */ +static const unsigned int ACCESS_MODE = (unsigned int)(PKGDB_MODE_READ | + PKGDB_MODE_WRITE); +static const unsigned int ACCESS_DB = (unsigned int)(PKGDB_DB_LOCAL | + PKGDB_DB_REPO); /* * Opens a pkgdb ready for remote operations. This will always return TRUE if @@ -39,37 +43,35 @@ * "pk_backend_initialize" and before "pk_backend_destroy". */ gboolean -open_remote_db(struct pkgdb **db, PkBackend *backend) +open_remote_db(struct pkgdb **db_p, PkBackend *backend) { gboolean success; - int access_return; - int open_return; success = FALSE; - pk_backend_set_status(backend, PK_STATUS_ENUM_WAITING_FOR_AUTH); - access_return = pkgdb_access(PKGDB_MODE_READ | PKGDB_MODE_WRITE, - PKGDB_DB_LOCAL | PKGDB_DB_REPO); - if (access_return != EPKG_OK) - pk_backend_error_code(backend, - PK_ERROR_ENUM_NOT_AUTHORIZED, - "cannot access database"); - else { - pk_backend_set_status(backend, PK_STATUS_ENUM_WAITING_FOR_LOCK); - open_return = pkgdb_open(db, PKGDB_REMOTE); - if (open_return != EPKG_OK) - pk_backend_error_code(backend, - PK_ERROR_ENUM_CANNOT_GET_LOCK, - "cannot open database"); - else if (*db == NULL) - pk_backend_error_code(backend, - PK_ERROR_ENUM_INTERNAL_ERROR, + (void)pk_backend_set_status(backend, PK_STATUS_ENUM_WAITING_FOR_AUTH); + if (pkgdb_access(ACCESS_MODE, ACCESS_DB) != EPKG_OK) { + (void)pk_backend_error_code(backend, + PK_ERROR_ENUM_NOT_AUTHORIZED, + "cannot access database"); + goto cleanup; + } + (void)pk_backend_set_status(backend, PK_STATUS_ENUM_WAITING_FOR_LOCK); + if (pkgdb_open(db_p, PKGDB_REMOTE) != EPKG_OK) { + (void)pk_backend_error_code(backend, + PK_ERROR_ENUM_CANNOT_GET_LOCK, + "cannot open database"); + goto cleanup; + } + if (*db_p == NULL) { + (void)pk_backend_error_code(backend, + PK_ERROR_ENUM_INTERNAL_ERROR, "pkgdb_open gave us a null pointer"); - else { - pk_backend_set_status(backend, PK_STATUS_ENUM_RUNNING); - success = TRUE; - } + goto cleanup; } + (void)pk_backend_set_status(backend, PK_STATUS_ENUM_RUNNING); + success = TRUE; +cleanup: return success; } Modified: soc2013/mattbw/backend/query.c ============================================================================== --- soc2013/mattbw/backend/query.c Sat Jul 6 20:39:44 2013 (r254257) +++ soc2013/mattbw/backend/query.c Sat Jul 6 21:11:01 2013 (r254258) @@ -51,17 +51,18 @@ static gboolean match(struct query *q, gchar **match_id_p, struct pkg **match_pkg_p); static gboolean match_id_in_it(struct pkgdb_it *it, struct query *q, gchar **match_id_p, struct pkg **match_pkg_p); +static gboolean query_do(PkBackend *backend, unsigned int load_flags, emit_ptr emitter, pkg_jobs_t job_type, job_emit_ptr job_emitter, query_body_ptr body); +static gboolean query_emit_to_job(struct pkg *pkg, const gchar *id, struct query *q); +static gboolean query_match(struct query *q); static gboolean try_id_match(struct pkg *pkg, struct query *q, gchar **match_id); -static gboolean query_do(PkBackend *backend, int load_flags, emit_ptr emitter, pkg_jobs_t job_type, job_emit_ptr job_emitter, query_body_ptr body); -static gboolean query_match(struct query *q); static int jobs_add_pkg(struct pkg_jobs *jobs, match_t type, struct pkg *pkg); -static void query_emit_to_job(struct pkg *pkg, const gchar *id, struct query *q); static void query_free_contents(struct query *q); /* Returns the backend stored inside the struct query. */ PkBackend * query_backend(struct query *q) { + return (q == NULL ? NULL : q->backend); } @@ -70,7 +71,7 @@ query_init(const gchar *id, PkBackend *backend, struct pkgdb *db, - int load_flags, + unsigned int load_flags, emit_ptr emitter, pkg_jobs_t job_type, job_emit_ptr job_emitter, @@ -99,38 +100,42 @@ &(q->version), &(q->arch), &(q->data)); - if (success == FALSE) + if (success == FALSE) { pk_backend_error_code(backend, PK_ERROR_ENUM_PACKAGE_ID_INVALID, "invalid package id"); + goto cleanup; + } /* * Check the repository to make sure it's sane, and populate the repo * type flags in the state for later consumption. */ - if (success == TRUE) { - if (q->data == NULL) - q->any_repo = TRUE; - else if (strcmp(q->data, "installed") == 0) - q->local_repo = TRUE; - else if (pkg_repo_find_ident(q->data) == NULL) { - pk_backend_error_code(backend, - PK_ERROR_ENUM_REPO_NOT_FOUND, - "no such repository"); - success = FALSE; - } + if (q->data == NULL) + q->any_repo = TRUE; + else if (strcmp(q->data, "installed") == 0) + q->local_repo = TRUE; + else if (pkg_repo_find_ident(q->data) == NULL) { + pk_backend_error_code(backend, + PK_ERROR_ENUM_REPO_NOT_FOUND, + "no such repository"); + success = FALSE; + goto cleanup; } /* * Stop pkg from catching fire if we try to load files from * non-installed packages. */ loading_files = (load_flags & PKG_LOAD_FILES) ? TRUE : FALSE; - if (success == TRUE && q->local_repo == FALSE && loading_files) { + if (q->local_repo == FALSE && loading_files) { pk_backend_error_code(backend, PK_ERROR_ENUM_CANNOT_GET_FILELIST, "cannot get files for remote package"); success = FALSE; + goto cleanup; } + +cleanup: if (success == FALSE) { query_free(q); q = NULL; @@ -140,11 +145,11 @@ } /* - * Runs a query over the PackageIDs selected in the backend that sends the first - * match to an emitting function. + * Runs a query over the PackageIDs selected in the backend that sends the + * first match to an emitting function. */ gboolean -query_match_id_to_emitter(PkBackend *backend, int load_flags, emit_ptr emitter) +query_match_id_to_emitter(PkBackend *backend, unsigned int load_flags, emit_ptr emitter) { return query_do(backend, @@ -173,8 +178,8 @@ } /* - * Performs a package database query against a PackageID, and then emits - * the first matching result. + * Performs a package database query against a PackageID, and then emits the + * first matching result. */ static gboolean query_match(struct query *q) @@ -205,11 +210,11 @@ */ static gboolean query_do(PkBackend *backend, - int load_flags, - emit_ptr emitter, + unsigned int load_flags, + emit_ptr emitter, pkg_jobs_t job_type, - job_emit_ptr job_emitter, - query_body_ptr body) + job_emit_ptr job_emitter, + query_body_ptr body) { gboolean no_error_yet; gchar **package_ids; @@ -251,43 +256,60 @@ /* * For adapting an emitter function into one that solves and applies a job. */ -static void +static gboolean query_emit_to_job(struct pkg *pkg, const gchar *id, struct query *q) { + gboolean success; int err; struct pkg_jobs *jobs; + PkBackend *backend; INTENTIONALLY_IGNORE(id); + success = FALSE; jobs = NULL; + + if (q == NULL) + goto cleanup; + + backend = query_backend(q); + err = pkg_jobs_new(&jobs, q->job_type, q->db); - if (err == EPKG_OK) { - if (q->data != NULL) - err = pkg_jobs_set_repository(jobs, q->data); - if (err == EPKG_OK) { - err = jobs_add_pkg(jobs, MATCH_EXACT, pkg); - if (err == EPKG_OK) - q->job_emitter(jobs, q); - else - pk_backend_error_code(q->backend, - PK_ERROR_ENUM_INTERNAL_ERROR, - "could not add to job"); - } else - pk_backend_error_code(q->backend, + if (err != EPKG_OK) { + pk_backend_error_code(backend, + PK_ERROR_ENUM_INTERNAL_ERROR, + "could not init pkg_jobs"); + goto cleanup; + } + if (q->data != NULL) { + err = pkg_jobs_set_repository(jobs, q->data); + if (err != EPKG_OK) { + pk_backend_error_code(backend, PK_ERROR_ENUM_REPO_NOT_FOUND, "could not set repo"); - } else - pk_backend_error_code(q->backend, + goto cleanup; + } + } + err = jobs_add_pkg(jobs, MATCH_EXACT, pkg); + if (err != EPKG_OK) { + pk_backend_error_code(backend, PK_ERROR_ENUM_INTERNAL_ERROR, - "could not init pkg_jobs"); + "could not add to job"); + goto cleanup; + } + + success = q->job_emitter(jobs, q); +cleanup: pkg_jobs_free(jobs); + return success; } /* Deallocates a struct query and any contents it owns. */ void query_free(struct query *q) { + if (q != NULL) { query_free_contents(q); g_free(q); @@ -306,11 +328,15 @@ gboolean success; gboolean try_local; gboolean try_remote; + int match; + const char *name; struct pkgdb *db; struct pkgdb_it *it; success = FALSE; + match = MATCH_EXACT; db = q->db; + name = q->name; /* * If we're not given a specific repository in the PackageID, we want @@ -325,19 +351,16 @@ } /* Try a local search first, if applicable. */ - if (try_local == TRUE) - it = pkgdb_query(db, q->name, MATCH_EXACT); - else - it = NULL; + it = (try_local ? pkgdb_query(db, name, match) : NULL); if (it != NULL) success = match_id_in_it(it, q, match_id_p, match_pkg_p); pkgdb_it_free(it); + if (success == TRUE) + try_remote = FALSE; + /* Next, try a remote search, again only if applicable. */ - if (success == FALSE && (try_remote == TRUE)) - it = pkgdb_rquery(db, q->name, MATCH_EXACT, q->data); - else - it = NULL; + it = (try_remote ? pkgdb_rquery(db, name, match, q->data) : NULL); if (it != NULL) success = match_id_in_it(it, q, match_id_p, match_pkg_p); pkgdb_it_free(it); @@ -360,10 +383,11 @@ gchar **match_id_p, struct pkg **match_pkg_p) { - /* TODO: Filters */ int err; int load_flags; + /* TODO: Filters */ + *match_pkg_p = NULL; *match_id_p = NULL; load_flags = q->load_flags; @@ -390,8 +414,8 @@ /* * Succeed if this package's PackageID fields match the original * PackageID. Of course, the original ID might have missing fields - * (NULLs), so we treat a comparison involving one as a success. - * This means using our "weak strcmp" instead of normal strcmp or even + * (NULLs), so we treat a comparison involving one as a success. This + * means using our "weak strcmp" instead of normal strcmp or even * g_strcmp0. */ for (matches = TRUE, i = PK_PACKAGE_ID_NAME; @@ -414,9 +438,11 @@ return pkg_jobs_add(jobs, type, &name, 1); } +/* Frees the owned contents of a struct query, but not the struct itself. */ static void query_free_contents(struct query *q) { + /* The database is owned by the creator and is not freed. */ /* This should free the other split ID pointer targets. */ if (q->strv != NULL) Modified: soc2013/mattbw/backend/query.h ============================================================================== --- soc2013/mattbw/backend/query.h Sat Jul 6 20:39:44 2013 (r254257) +++ soc2013/mattbw/backend/query.h Sat Jul 6 21:11:01 2013 (r254258) @@ -27,14 +27,14 @@ struct query; -typedef void (*emit_ptr) (struct pkg *pkg, const gchar *id, struct query *q); -typedef void (*job_emit_ptr) (struct pkg_jobs *jobs, struct query *q); +typedef gboolean (*emit_ptr) (struct pkg *pkg, const gchar *id, struct query *q); +typedef gboolean (*job_emit_ptr) (struct pkg_jobs *jobs, struct query *q); typedef gboolean (*query_body_ptr) (struct query *q); PkBackend *query_backend(struct query *q); -gboolean query_init(const gchar *id, PkBackend *backend, struct pkgdb *db, int load_flags, emit_ptr emitter, pkg_jobs_t job_type, job_emit_ptr job_emitter, struct query **q_p); +gboolean query_init(const gchar *id, PkBackend *backend, struct pkgdb *db, unsigned int load_flags, emit_ptr emitter, pkg_jobs_t job_type, job_emit_ptr job_emitter, struct query **q_p); -gboolean query_match_id_to_emitter(PkBackend *backend, int load_flags, emit_ptr emitter); +gboolean query_match_id_to_emitter(PkBackend *backend, unsigned int load_flags, emit_ptr emitter); gboolean query_match_id_to_job(PkBackend *backend, pkg_jobs_t type, job_emit_ptr job_emitter); void query_free(struct query *q); From owner-svn-soc-all@FreeBSD.ORG Sat Jul 6 21:57:34 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id A65CD8B6 for ; Sat, 6 Jul 2013 21:57:34 +0000 (UTC) (envelope-from dpl@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 96C9E173D for ; Sat, 6 Jul 2013 21:57:34 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r66LvXVM085841 for ; Sat, 6 Jul 2013 21:57:33 GMT (envelope-from dpl@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r66LvXgZ085839 for svn-soc-all@FreeBSD.org; Sat, 6 Jul 2013 21:57:33 GMT (envelope-from dpl@FreeBSD.org) Date: Sat, 6 Jul 2013 21:57:33 GMT Message-Id: <201307062157.r66LvXgZ085839@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to dpl@FreeBSD.org using -f From: dpl@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254259 - soc2013/dpl/head/contrib/bzip2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 06 Jul 2013 21:57:34 -0000 Author: dpl Date: Sat Jul 6 21:57:33 2013 New Revision: 254259 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254259 Log: Cleaning bugs in compressStream/uncompressStream. Modified: soc2013/dpl/head/contrib/bzip2/bzip2.c Modified: soc2013/dpl/head/contrib/bzip2/bzip2.c ============================================================================== --- soc2013/dpl/head/contrib/bzip2/bzip2.c Sat Jul 6 21:11:01 2013 (r254258) +++ soc2013/dpl/head/contrib/bzip2/bzip2.c Sat Jul 6 21:57:33 2013 (r254259) @@ -75,9 +75,8 @@ # include # define PATH_SEP '/' -# define MY_LSTAT fstatat -# define MY_STAT fstatat -# define MY_STATS stat +# define MY_LSTAT lstat +# define MY_STAT stat # define MY_S_ISREG S_ISREG # define MY_S_ISDIR S_ISDIR @@ -114,7 +113,6 @@ # undef MY_STAT # define MY_LSTAT stat # define MY_STAT stat -# define MY_STATS stat # undef SET_BINARY_MODE # define SET_BINARY_MODE(fd) \ do { \ @@ -148,7 +146,6 @@ # define PATH_SEP '\\' # define MY_LSTAT _stat # define MY_STAT _stat -# define MY_STATS _stat # define MY_S_ISREG(x) ((x) & _S_IFREG) # define MY_S_ISDIR(x) ((x) & _S_IFDIR) @@ -732,7 +729,7 @@ void cleanUpAndFail ( Int32 ec ) { IntNative retVal; - struct MY_STATS statBuf; + struct MY_STAT statBuf; if ( srcMode == SM_F2F && opMode != OM_TEST @@ -743,7 +740,7 @@ January 2002. (JRS 06-Jan-2002: other changes in 1.0.2 mean this is less likely to happen. But to be ultra-paranoid, we do the check anyway.) */ - retVal = MY_STAT ( IN_FILENO, inName, &statBuf, 0 ); + retVal = MY_STAT ( inName, &statBuf ); if (retVal == 0) { if (noisy) fprintf ( stderr, @@ -1023,12 +1020,12 @@ if in doubt, return True --*/ static -Bool notAStandardFile (int fd, Char* name ) +Bool notAStandardFile ( Char* name ) { IntNative i; - struct MY_STATS statBuf; + struct MY_STAT statBuf; - i = MY_LSTAT ( fd, name, &statBuf, AT_SYMLINK_NOFOLLOW ); + i = MY_LSTAT ( name, &statBuf ); if (i != 0) return True; if (MY_S_ISREG(statBuf.st_mode)) return False; return True; @@ -1040,12 +1037,12 @@ rac 11/21/98 see if file has hard links to it --*/ static -Int32 countHardLinks ( int fd, Char* name ) +Int32 countHardLinks ( Char* name ) { IntNative i; - struct MY_STATS statBuf; + struct MY_STAT statBuf; - i = MY_LSTAT ( fd, name, &statBuf, AT_SYMLINK_NOFOLLOW ); + i = MY_LSTAT ( name, &statBuf ); if (i != 0) return 0; return (statBuf.st_nlink - 1); } @@ -1076,7 +1073,7 @@ */ #if BZ_UNIX static -struct MY_STATS fileMetaInfo; +struct MY_STAT fileMetaInfo; #endif static @@ -1085,23 +1082,29 @@ # if BZ_UNIX IntNative retVal; /* Note use of stat here, not lstat. */ - retVal = MY_STAT( fd, srcName, &fileMetaInfo, 0 ); + retVal = MY_STAT( srcName, &fileMetaInfo ); ERROR_IF_NOT_ZERO ( retVal ); # endif } static -void applySavedTimeInfoToOutputFile ( Char *dstName ) +void applySavedTimeInfoToOutputFile ( int fd ) { # if BZ_UNIX IntNative retVal; - struct utimbuf uTimBuf; +/* struct utimbuf uTimBuf;*/ + struct timeval fdTime[2]; - uTimBuf.actime = fileMetaInfo.st_atime; - uTimBuf.modtime = fileMetaInfo.st_mtime; - - retVal = utime ( dstName, &uTimBuf ); + fdTime[0].tv_sec = fileMetaInfo.st_atime; + fdTime[0].tv_usec = 0; + fdTime[1].tv_sec = fileMetaInfo.st_mtime; + fdTime[1].tv_usec = 0; + +/* uTimBuf.actime = fileMetaInfo.st_atime;*/ +/* uTimBuf.modtime = fileMetaInfo.st_mtime;*/ + printf("fd:%d\n", fd); + retVal = futimes ( fd, fdTime ); ERROR_IF_NOT_ZERO ( retVal ); # endif } @@ -1184,7 +1187,7 @@ FILE *outStr; #endif Int32 n, i; - struct MY_STATS statBuf; + struct MY_STAT statBuf; deleteOutputOnInterrupt = False; @@ -1207,6 +1210,12 @@ break; } + if (verbosity >= 1) { + fprintf ( stderr, " %s: ", inName ); + pad ( inName ); + fflush ( stderr ); + } + if ( srcMode != SM_I2O && containsDubiousChars ( inName ) ) { if (noisy) fprintf ( stderr, "%s: There are no files matching `%s'.\n", @@ -1231,7 +1240,7 @@ } } if ( srcMode == SM_F2F || srcMode == SM_F2O ) { - MY_STAT( IN_FILENO, inName, &statBuf, 0); + MY_STAT( inName, &statBuf ); if ( MY_S_ISDIR(statBuf.st_mode) ) { fprintf( stderr, "%s: Input file %s is a directory.\n", @@ -1240,7 +1249,7 @@ return; } } - if ( srcMode == SM_F2F && !forceOverwrite && notAStandardFile ( inName, IN_FILENO )) { + if ( srcMode == SM_F2F && !forceOverwrite && notAStandardFile ( inName )) { if (noisy) fprintf ( stderr, "%s: Input file %s is not a normal file.\n", progName, inName ); @@ -1258,7 +1267,7 @@ } } if ( srcMode == SM_F2F && !forceOverwrite && - (n=countHardLinks ( IN_FILENO, inName )) > 0) { + (n=countHardLinks ( inName )) > 0) { fprintf ( stderr, "%s: Input file %s has %d other link%s.\n", progName, inName, n, n > 1 ? "s" : "" ); setExit(1); @@ -1332,12 +1341,6 @@ break; } - if (verbosity >= 1) { - fprintf ( stderr, " %s: ", inName ); - pad ( inName ); - fflush ( stderr ); - } - # if CAPSICUM /* Fork and compress in sandbox. */ if ( (forkpid = fork()) == -1 ){ @@ -1364,10 +1367,10 @@ deleteOutputOnInterrupt = True; compressStream ( inStr, outStr ); outputHandleJustInCase = NULL; - + /*--- If there was an I/O error, we won't get here. ---*/ if ( srcMode == SM_F2F ) { - applySavedTimeInfoToOutputFile ( outName ); + applySavedTimeInfoToOutputFile ( OUT_FILENO ); deleteOutputOnInterrupt = False; if ( !keepInputFiles ) { IntNative retVal = remove ( inName ); @@ -1396,7 +1399,7 @@ Int32 n, i; Bool magicNumberOK; Bool cantGuess; - struct MY_STATS statBuf; + struct MY_STAT statBuf; deleteOutputOnInterrupt = False; @@ -1439,7 +1442,7 @@ return; } if ( srcMode == SM_F2F || srcMode == SM_F2O ) { - MY_STAT(IN_FILENO, inName, &statBuf, 0); + MY_STAT( inName, &statBuf ); if ( MY_S_ISDIR(statBuf.st_mode) ) { fprintf( stderr, "%s: Input file %s is a directory.\n", @@ -1448,7 +1451,7 @@ return; } } - if ( srcMode == SM_F2F && !forceOverwrite && notAStandardFile ( inName, IN_FILENO )) { + if ( srcMode == SM_F2F && !forceOverwrite && notAStandardFile ( inName )) { if (noisy) fprintf ( stderr, "%s: Input file %s is not a normal file.\n", progName, inName ); @@ -1473,7 +1476,7 @@ } } if ( srcMode == SM_F2F && !forceOverwrite && - (n=countHardLinks ( IN_FILENO, inName ) ) > 0) { + (n=countHardLinks ( inName ) ) > 0) { fprintf ( stderr, "%s: Input file %s has %d other link%s.\n", progName, inName, n, n > 1 ? "s" : "" ); setExit(1); @@ -1576,7 +1579,7 @@ /*--- If there was an I/O error, we won't get here. ---*/ if ( magicNumberOK ) { if ( srcMode == SM_F2F ) { - applySavedTimeInfoToOutputFile ( outName ); + applySavedTimeInfoToOutputFile ( OUT_FILENO ); deleteOutputOnInterrupt = False; if ( !keepInputFiles ) { IntNative retVal = remove ( inName ); @@ -1619,7 +1622,7 @@ FILE *inStr; # endif Bool allOK; - struct MY_STATS statBuf; + struct MY_STAT statBuf; deleteOutputOnInterrupt = False; @@ -1647,7 +1650,7 @@ return; } if ( srcMode != SM_I2O ) { - MY_STAT(inName, IN_FILENO, &statBuf, 0); + MY_STAT( inName, &statBuf ); if ( MY_S_ISDIR(statBuf.st_mode) ) { fprintf( stderr, "%s: Input file %s is a directory.\n", From owner-svn-soc-all@FreeBSD.ORG Sat Jul 6 22:53:48 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 08F9A360 for ; Sat, 6 Jul 2013 22:53:48 +0000 (UTC) (envelope-from mattbw@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id ED69D18BA for ; Sat, 6 Jul 2013 22:53:47 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r66MrlwF012773 for ; Sat, 6 Jul 2013 22:53:47 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r66Mrl2u012760 for svn-soc-all@FreeBSD.org; Sat, 6 Jul 2013 22:53:47 GMT (envelope-from mattbw@FreeBSD.org) Date: Sat, 6 Jul 2013 22:53:47 GMT Message-Id: <201307062253.r66Mrl2u012760@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to mattbw@FreeBSD.org using -f From: mattbw@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254261 - in soc2013/mattbw/backend: . actions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 06 Jul 2013 22:53:48 -0000 Author: mattbw Date: Sat Jul 6 22:53:47 2013 New Revision: 254261 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254261 Log: split off high-level querying functions Added: soc2013/mattbw/backend/query_match.c soc2013/mattbw/backend/query_match.h Modified: soc2013/mattbw/backend/.indent.pro soc2013/mattbw/backend/Makefile soc2013/mattbw/backend/actions/actions.h soc2013/mattbw/backend/actions/get-details.c soc2013/mattbw/backend/actions/get-files.c soc2013/mattbw/backend/actions/install-packages.c soc2013/mattbw/backend/pk-backend-pkgng.c soc2013/mattbw/backend/pkgutils.c soc2013/mattbw/backend/query.c soc2013/mattbw/backend/query.h Modified: soc2013/mattbw/backend/.indent.pro ============================================================================== --- soc2013/mattbw/backend/.indent.pro Sat Jul 6 21:38:55 2013 (r254260) +++ soc2013/mattbw/backend/.indent.pro Sat Jul 6 22:53:47 2013 (r254261) @@ -1,3 +1,6 @@ -TPkBackend -Tgchar -Tgboolean +-sob +-nlp +-ci4 Modified: soc2013/mattbw/backend/Makefile ============================================================================== --- soc2013/mattbw/backend/Makefile Sat Jul 6 21:38:55 2013 (r254260) +++ soc2013/mattbw/backend/Makefile Sat Jul 6 22:53:47 2013 (r254261) @@ -9,6 +9,7 @@ licenses.c \ pkgutils.c \ query.c \ + query_match.c \ utils.c SRCS+= \ actions/get-details.c \ Modified: soc2013/mattbw/backend/actions/actions.h ============================================================================== --- soc2013/mattbw/backend/actions/actions.h Sat Jul 6 21:38:55 2013 (r254260) +++ soc2013/mattbw/backend/actions/actions.h Sat Jul 6 22:53:47 2013 (r254261) @@ -32,6 +32,7 @@ gboolean get_files_thread(PkBackend *backend); gboolean get_repo_list_thread(PkBackend *backend); gboolean install_packages_thread(PkBackend *backend); +gboolean install_files_thread(PkBackend *backend); gboolean simulate_install_packages_thread(PkBackend *backend); #endif /* !_PKGNG_BACKEND_ACTIONS_H_ */ Modified: soc2013/mattbw/backend/actions/get-details.c ============================================================================== --- soc2013/mattbw/backend/actions/get-details.c Sat Jul 6 21:38:55 2013 (r254260) +++ soc2013/mattbw/backend/actions/get-details.c Sat Jul 6 22:53:47 2013 (r254261) @@ -23,7 +23,7 @@ #include "pkg.h" #include "../groups.h" /* group_from_origin */ -#include "../query.h" /* Package querying */ +#include "../query_match.h" /* query_match_... */ #include "../licenses.h" /* license_from_pkg */ #include "actions.h" /* get_details_thread prototype */ Modified: soc2013/mattbw/backend/actions/get-files.c ============================================================================== --- soc2013/mattbw/backend/actions/get-files.c Sat Jul 6 21:38:55 2013 (r254260) +++ soc2013/mattbw/backend/actions/get-files.c Sat Jul 6 22:53:47 2013 (r254261) @@ -26,7 +26,7 @@ #include "../groups.h" /* group_from_origin */ #include "../hash_traverse.h" /* HASH_FOR */ -#include "../query.h" /* Package querying */ +#include "../query_match.h" /* query_match_... */ #include "../licenses.h" /* license_from_pkg */ #include "actions.h" /* get_files_thread prototype */ Modified: soc2013/mattbw/backend/actions/install-packages.c ============================================================================== --- soc2013/mattbw/backend/actions/install-packages.c Sat Jul 6 21:38:55 2013 (r254260) +++ soc2013/mattbw/backend/actions/install-packages.c Sat Jul 6 22:53:47 2013 (r254261) @@ -24,7 +24,7 @@ #include "../hash_traverse.h" /* HASH_FOR */ #include "../pkgutils.h" /* pkgutils_... */ -#include "../query.h" /* Package querying */ +#include "../query_match.h" /* query_match_... */ #include "../utils.h" /* INTENTIONALLY_IGNORE */ #include "actions.h" /* install_packages_thread prototype */ @@ -32,7 +32,7 @@ static gboolean do_install_packages(struct pkg_jobs *jobs, struct query *q, gboolean simulate); static gboolean do_install_solved_job(struct pkg_jobs *jobs, PkBackend *backend, gboolean simulate); static gboolean do_install_solved_job_real(struct pkg_jobs *jobs, PkBackend *backend); -static gboolean job (struct pkg_jobs *jobs, struct query *q); +static gboolean job(struct pkg_jobs *jobs, struct query *q); static gboolean sim_job(struct pkg_jobs *jobs, struct query *q); static int install_event_cb(void *backend_v, struct pkg_event *event); @@ -74,12 +74,12 @@ pk_backend_set_status(backend, PK_STATUS_ENUM_DEP_RESOLVE); if (pkg_jobs_solve(jobs) != EPKG_OK) pk_backend_error_code(backend, - PK_ERROR_ENUM_DEP_RESOLUTION_FAILED, - "could not solve the job"); + PK_ERROR_ENUM_DEP_RESOLUTION_FAILED, + "could not solve the job"); else if (pkg_jobs_count(jobs) == 0) pk_backend_error_code(backend, - PK_ERROR_ENUM_INTERNAL_ERROR, - "job contains no packages"); + PK_ERROR_ENUM_INTERNAL_ERROR, + "job contains no packages"); else success = do_install_solved_job(jobs, backend, simulate); @@ -91,8 +91,8 @@ */ static gboolean do_install_solved_job(struct pkg_jobs *jobs, - PkBackend *backend, - gboolean simulate) + PkBackend *backend, + gboolean simulate) { gboolean success; struct pkg *pkg; @@ -101,8 +101,8 @@ pkg = NULL; while (pkg_jobs(jobs, &pkg) == EPKG_OK) pkgutils_emit(pkg, - backend, - pkgutils_pkg_install_state(pkg)); + backend, + pkgutils_pkg_install_state(pkg)); if (simulate == FALSE) success = do_install_solved_job_real(jobs, backend); @@ -127,8 +127,8 @@ success = TRUE; else pk_backend_error_code(backend, - PK_ERROR_ENUM_PACKAGE_FAILED_TO_INSTALL, - "job failed"); + PK_ERROR_ENUM_PACKAGE_FAILED_TO_INSTALL, + "job failed"); pkg_event_register(NULL, NULL); @@ -169,48 +169,48 @@ switch (event->type) { case PKG_EVENT_INSTALL_BEGIN: pkgutils_emit(event->e_install_begin.pkg, - backend, - PK_INFO_ENUM_INSTALLING); + backend, + PK_INFO_ENUM_INSTALLING); break; case PKG_EVENT_INSTALL_FINISHED: pkgutils_emit(event->e_install_finished.pkg, - backend, - PK_INFO_ENUM_FINISHED); + backend, + PK_INFO_ENUM_FINISHED); break; case PKG_EVENT_DEINSTALL_BEGIN: pkgutils_emit(event->e_deinstall_begin.pkg, - backend, - PK_INFO_ENUM_REMOVING); + backend, + PK_INFO_ENUM_REMOVING); break; case PKG_EVENT_DEINSTALL_FINISHED: pkgutils_emit(event->e_deinstall_finished.pkg, - backend, - PK_INFO_ENUM_FINISHED); + backend, + PK_INFO_ENUM_FINISHED); break; case PKG_EVENT_UPGRADE_BEGIN: pkgutils_emit(event->e_upgrade_begin.pkg, - backend, - PK_INFO_ENUM_UPDATING); + backend, + PK_INFO_ENUM_UPDATING); break; case PKG_EVENT_UPGRADE_FINISHED: pkgutils_emit(event->e_upgrade_finished.pkg, - backend, - PK_INFO_ENUM_FINISHED); + backend, + PK_INFO_ENUM_FINISHED); break; case PKG_EVENT_ERROR: pk_backend_error_code(backend, - PK_ERROR_ENUM_PACKAGE_FAILED_TO_INSTALL, - event->e_pkg_error.msg); + PK_ERROR_ENUM_PACKAGE_FAILED_TO_INSTALL, + event->e_pkg_error.msg); break; case PKG_EVENT_FILE_MISMATCH: pk_backend_error_code(backend, - PK_ERROR_ENUM_PACKAGE_CORRUPT, - pkg_file_path(event->e_file_mismatch.file)); + PK_ERROR_ENUM_PACKAGE_CORRUPT, + pkg_file_path(event->e_file_mismatch.file)); break; case PKG_EVENT_NOT_FOUND: pk_backend_error_code(backend, - PK_ERROR_ENUM_PACKAGE_DOWNLOAD_FAILED, - event->e_not_found.pkg_name); + PK_ERROR_ENUM_PACKAGE_DOWNLOAD_FAILED, + event->e_not_found.pkg_name); default: /* Do nothing for unrecognised events */ break; @@ -218,5 +218,3 @@ return EPKG_OK; } - - Modified: soc2013/mattbw/backend/pk-backend-pkgng.c ============================================================================== --- soc2013/mattbw/backend/pk-backend-pkgng.c Sat Jul 6 21:38:55 2013 (r254260) +++ soc2013/mattbw/backend/pk-backend-pkgng.c Sat Jul 6 22:53:47 2013 (r254261) @@ -65,9 +65,9 @@ if (!pkg_initialized()) err = pkg_init(NULL); if (err) - pk_backend_error_code(backend, - PK_ERROR_ENUM_INTERNAL_ERROR, - "could not initialise pkg"); + (void)pk_backend_error_code(backend, + PK_ERROR_ENUM_INTERNAL_ERROR, + "could not initialise pkg"); } /** @@ -76,6 +76,7 @@ void pk_backend_destroy(PkBackend *backend) { + INTENTIONALLY_IGNORE(backend); pkg_shutdown(); } @@ -88,6 +89,7 @@ PkBitfield pk_backend_get_groups(PkBackend *backend) { + INTENTIONALLY_IGNORE(backend); return available_groups(); } @@ -98,11 +100,12 @@ PkBitfield pk_backend_get_filters(PkBackend *backend) { + INTENTIONALLY_IGNORE(backend); return pk_bitfield_from_enums(PK_FILTER_ENUM_GUI, - PK_FILTER_ENUM_INSTALLED, - PK_FILTER_ENUM_DEVELOPMENT, - -1); + PK_FILTER_ENUM_INSTALLED, + PK_FILTER_ENUM_DEVELOPMENT, + -1); } /** @@ -111,6 +114,7 @@ gchar * pk_backend_get_mime_types(PkBackend *backend) { + INTENTIONALLY_IGNORE(backend); return g_strdup("application/x-rpm;application/x-deb"); } @@ -134,12 +138,12 @@ if (g_strcmp0(package_ids[0], "scribus;1.3.4-1.fc8;i386;fedora") == 0) { pk_backend_package(backend, PK_INFO_ENUM_AVAILABLE, - "scribus-clipart;1.3.4-1.fc8;i386;fedora", "Clipart for scribus"); + "scribus-clipart;1.3.4-1.fc8;i386;fedora", "Clipart for scribus"); } else { pk_backend_package(backend, PK_INFO_ENUM_INSTALLED, - "glib2;2.14.0;i386;fedora", "The GLib library"); + "glib2;2.14.0;i386;fedora", "The GLib library"); pk_backend_package(backend, PK_INFO_ENUM_AVAILABLE, - "gtk2;gtk2-2.11.6-6.fc8;i386;fedora", "GTK+ Libraries for GIMP"); + "gtk2;gtk2-2.11.6-6.fc8;i386;fedora", "GTK+ Libraries for GIMP"); } pk_backend_finished(backend); } @@ -170,9 +174,9 @@ if (!_use_distro_upgrade) goto out; pk_backend_distro_upgrade(backend, PK_DISTRO_UPGRADE_ENUM_STABLE, - "fedora-9", "Fedora 9"); + "fedora-9", "Fedora 9"); pk_backend_distro_upgrade(backend, PK_DISTRO_UPGRADE_ENUM_UNSTABLE, - "fedora-10-rc1", "Fedora 10 RC1"); + "fedora-10-rc1", "Fedora 10 RC1"); out: pk_backend_finished(backend); } @@ -204,9 +208,9 @@ pk_backend_set_status(backend, PK_STATUS_ENUM_QUERY); pk_backend_package(backend, PK_INFO_ENUM_INSTALLED, - "glib2;2.14.0;i386;fedora", "The GLib library"); + "glib2;2.14.0;i386;fedora", "The GLib library"); pk_backend_package(backend, PK_INFO_ENUM_INSTALLED, - "gtk2;gtk2-2.11.6-6.fc8;i386;fedora", "GTK+ Libraries for GIMP"); + "gtk2;gtk2-2.11.6-6.fc8;i386;fedora", "GTK+ Libraries for GIMP"); pk_backend_finished(backend); } @@ -224,22 +228,22 @@ /* dummy */ changelog = "**Thu Mar 12 2009** Adam Jackson 1.6.0-13\n" - "- xselinux-1.6.0-selinux-nlfd.patch: Acquire the netlink socket from selinux,\n" - " check it ourselves rather than having libselinux bang on it all the time.\n" - "\n" - "**Wed Mar 11 2009** Adam Jackson 1.6.0-10\n" - "- xserver-1.6.0-selinux-less.patch: Don't init selinux unless the policy\n" - " says to be an object manager.\n" - "\n" - "**Wed Mar 11 2009** Adam Jackson 1.6.0-11\n" - "- xserver-1.6.0-less-acpi-brokenness.patch: Don't build the (broken)\n" - " ACPI code.\n" - "\n" - "**Wed Mar 11 2009** Adam Jackson 1.6.0-12\n" - "- Requires: pixman >= 0.14.0\n" - "\n" - "**Fri Mar 6 2009** Adam Jackson 1.6.0-8\n" - "- xserver-1.6.0-primary.patch: Really, only look at VGA devices. (#488869)\n"; + "- xselinux-1.6.0-selinux-nlfd.patch: Acquire the netlink socket from selinux,\n" + " check it ourselves rather than having libselinux bang on it all the time.\n" + "\n" + "**Wed Mar 11 2009** Adam Jackson 1.6.0-10\n" + "- xserver-1.6.0-selinux-less.patch: Don't init selinux unless the policy\n" + " says to be an object manager.\n" + "\n" + "**Wed Mar 11 2009** Adam Jackson 1.6.0-11\n" + "- xserver-1.6.0-less-acpi-brokenness.patch: Don't build the (broken)\n" + " ACPI code.\n" + "\n" + "**Wed Mar 11 2009** Adam Jackson 1.6.0-12\n" + "- Requires: pixman >= 0.14.0\n" + "\n" + "**Fri Mar 6 2009** Adam Jackson 1.6.0-8\n" + "- xserver-1.6.0-primary.patch: Really, only look at VGA devices. (#488869)\n"; /* each one has a different detail for testing */ pk_backend_set_percentage(backend, 0); @@ -248,43 +252,43 @@ package_id = _package_ids[i]; if (g_strcmp0(package_id, "powertop;1.8-1.fc8;i386;fedora") == 0) { pk_backend_update_detail(backend, package_id, - "powertop;1.7-1.fc8;i386;installed", "", - "http://www.distro-update.org/page?moo;Bugfix release for powertop", - "http://bgzilla.fd.org/result.php?#12344;Freedesktop Bugzilla #12344", - "", PK_RESTART_ENUM_NONE, "Update to newest upstream source", - changelog, PK_UPDATE_STATE_ENUM_STABLE, "2009-11-17T09:19:00", "2009-11-19T09:19:00"); + "powertop;1.7-1.fc8;i386;installed", "", + "http://www.distro-update.org/page?moo;Bugfix release for powertop", + "http://bgzilla.fd.org/result.php?#12344;Freedesktop Bugzilla #12344", + "", PK_RESTART_ENUM_NONE, "Update to newest upstream source", + changelog, PK_UPDATE_STATE_ENUM_STABLE, "2009-11-17T09:19:00", "2009-11-19T09:19:00"); } else if (g_strcmp0(package_id, "kernel;2.6.23-0.115.rc3.git1.fc8;i386;installed") == 0) { pk_backend_update_detail(backend, package_id, - "kernel;2.6.22-0.104.rc3.git6.fc8;i386;installed" - PK_PACKAGE_IDS_DELIM - "kernel;2.6.22-0.105.rc3.git7.fc8;i386;installed", "", - "http://www.distro-update.org/page?moo;Bugfix release for kernel", - "http://bgzilla.fd.org/result.php?#12344;Freedesktop Bugzilla #12344;" - "http://bgzilla.gnome.org/result.php?#9876;GNOME Bugzilla #9876", - "http://nvd.nist.gov/nvd.cfm?cvename=CVE-2007-3381;CVE-2007-3381", - PK_RESTART_ENUM_SYSTEM, - "Update to newest upstream version.\n" - "* This should fix many driver bugs when using nouveau\n" - " * This also introduces the new `frobnicator` driver for *vibrating* rabbit hardware.", - changelog, PK_UPDATE_STATE_ENUM_UNSTABLE, "2008-06-28T09:19:00", NULL); + "kernel;2.6.22-0.104.rc3.git6.fc8;i386;installed" + PK_PACKAGE_IDS_DELIM + "kernel;2.6.22-0.105.rc3.git7.fc8;i386;installed", "", + "http://www.distro-update.org/page?moo;Bugfix release for kernel", + "http://bgzilla.fd.org/result.php?#12344;Freedesktop Bugzilla #12344;" + "http://bgzilla.gnome.org/result.php?#9876;GNOME Bugzilla #9876", + "http://nvd.nist.gov/nvd.cfm?cvename=CVE-2007-3381;CVE-2007-3381", + PK_RESTART_ENUM_SYSTEM, + "Update to newest upstream version.\n" + "* This should fix many driver bugs when using nouveau\n" + " * This also introduces the new `frobnicator` driver for *vibrating* rabbit hardware.", + changelog, PK_UPDATE_STATE_ENUM_UNSTABLE, "2008-06-28T09:19:00", NULL); } else if (g_strcmp0(package_id, "gtkhtml2;2.19.1-4.fc8;i386;fedora") == 0) { pk_backend_update_detail(backend, package_id, - "gtkhtml2;2.18.1-22.fc8;i386;installed", "", - "http://www.distro-update.org/page?moo;Bugfix release for gtkhtml", - "http://bgzilla.gnome.org/result.php?#9876;GNOME Bugzilla #9876", - NULL, PK_RESTART_ENUM_SESSION, - "Update to latest *whizz* **bang** version\n" - "* support this new thing\n" - "* something else\n" - "- and that new thing", - changelog, PK_UPDATE_STATE_ENUM_UNKNOWN, "2008-07-25T09:19:00", NULL); + "gtkhtml2;2.18.1-22.fc8;i386;installed", "", + "http://www.distro-update.org/page?moo;Bugfix release for gtkhtml", + "http://bgzilla.gnome.org/result.php?#9876;GNOME Bugzilla #9876", + NULL, PK_RESTART_ENUM_SESSION, + "Update to latest *whizz* **bang** version\n" + "* support this new thing\n" + "* something else\n" + "- and that new thing", + changelog, PK_UPDATE_STATE_ENUM_UNKNOWN, "2008-07-25T09:19:00", NULL); } else if (g_strcmp0(package_id, "vino;2.24.2.fc9;i386;fedora") == 0) { pk_backend_update_detail(backend, package_id, - "vino;2.24.1.fc9;i386;fedora", "", - "", "", NULL, PK_RESTART_ENUM_NONE, - "Cannot get update as update conflics with vncviewer", - changelog, PK_UPDATE_STATE_ENUM_UNKNOWN, "2008-07-25", NULL); + "vino;2.24.1.fc9;i386;fedora", "", + "", "", NULL, PK_RESTART_ENUM_NONE, + "Cannot get update as update conflics with vncviewer", + changelog, PK_UPDATE_STATE_ENUM_UNKNOWN, "2008-07-25", NULL); } else { /* signal to UI */ pk_backend_error_code(backend, PK_ERROR_ENUM_INTERNAL_ERROR, "the package update detail was not found for %s", package_id); @@ -317,18 +321,18 @@ if (!_updated_powertop) { pk_backend_package(backend, PK_INFO_ENUM_NORMAL, - "powertop;1.8-1.fc8;i386;fedora", - "Power consumption monitor"); + "powertop;1.8-1.fc8;i386;fedora", + "Power consumption monitor"); } if (!_updated_kernel) { pk_backend_package(backend, PK_INFO_ENUM_BUGFIX, - "kernel;2.6.23-0.115.rc3.git1.fc8;i386;installed", - "The Linux kernel (the core of the Linux operating system)"); + "kernel;2.6.23-0.115.rc3.git1.fc8;i386;installed", + "The Linux kernel (the core of the Linux operating system)"); } if (!_updated_gtkhtml) { pk_backend_package(backend, PK_INFO_ENUM_SECURITY, - "gtkhtml2;2.19.1-4.fc8;i386;fedora", - "An HTML widget for GTK+ 2.0"); + "gtkhtml2;2.19.1-4.fc8;i386;fedora", + "An HTML widget for GTK+ 2.0"); } pk_backend_finished(backend); _signal_timeout = 0; @@ -374,7 +378,7 @@ */ void pk_backend_install_signature(PkBackend *backend, PkSigTypeEnum type, - const gchar *key_id, const gchar *package_id) + const gchar *key_id, const gchar *package_id) { pk_backend_set_status(backend, PK_STATUS_ENUM_INSTALL); if (type == PK_SIGTYPE_ENUM_GPG && @@ -384,8 +388,8 @@ _has_signature = TRUE; } else { pk_backend_error_code(backend, PK_ERROR_ENUM_GPG_FAILURE, - "GPG key %s not recognised for package_id %s", - key_id, package_id); + "GPG key %s not recognised for package_id %s", + key_id, package_id); } pk_backend_finished(backend); } @@ -473,22 +477,22 @@ if (g_strcmp0(packages[i], "vips-doc") == 0 || g_strcmp0(packages[i], "vips-doc;7.12.4-2.fc8;noarch;linva") == 0) { if (!pk_bitfield_contain(_filters, PK_FILTER_ENUM_INSTALLED)) { pk_backend_package(backend, PK_INFO_ENUM_AVAILABLE, - "vips-doc;7.12.4-2.fc8;noarch;linva", "The vips documentation package."); + "vips-doc;7.12.4-2.fc8;noarch;linva", "The vips documentation package."); } } else if (g_strcmp0(packages[i], "glib2") == 0 || g_strcmp0(packages[i], "glib2;2.14.0;i386;fedora") == 0) { if (!pk_bitfield_contain(_filters, PK_FILTER_ENUM_NOT_INSTALLED)) { pk_backend_package(backend, PK_INFO_ENUM_INSTALLED, - "glib2;2.14.0;i386;fedora", "The GLib library"); + "glib2;2.14.0;i386;fedora", "The GLib library"); } } else if (g_strcmp0(packages[i], "powertop") == 0 || g_strcmp0(packages[i], "powertop;1.8-1.fc8;i386;fedora") == 0) pk_backend_package(backend, PK_INFO_ENUM_INSTALLED, - "powertop;1.8-1.fc8;i386;fedora", "Power consumption monitor"); + "powertop;1.8-1.fc8;i386;fedora", "Power consumption monitor"); else if (g_strcmp0(packages[i], "kernel") == 0 || g_strcmp0(packages[i], "kernel;2.6.23-0.115.rc3.git1.fc8;i386;installed") == 0) pk_backend_package(backend, PK_INFO_ENUM_INSTALLED, - "kernel;2.6.23-0.115.rc3.git1.fc8;i386;installed", "The Linux kernel (the core of the Linux operating system)"); + "kernel;2.6.23-0.115.rc3.git1.fc8;i386;installed", "The Linux kernel (the core of the Linux operating system)"); else if (g_strcmp0(packages[i], "gtkhtml2") == 0 || g_strcmp0(packages[i], "gtkhtml2;2.19.1-4.fc8;i386;fedora") == 0) pk_backend_package(backend, PK_INFO_ENUM_INSTALLED, - "gtkhtml2;2.19.1-4.fc8;i386;fedora", "An HTML widget for GTK+ 2.0"); + "gtkhtml2;2.19.1-4.fc8;i386;fedora", "An HTML widget for GTK+ 2.0"); } pk_backend_set_percentage(backend, 100); pk_backend_finished(backend); @@ -579,8 +583,8 @@ pk_backend_set_status(backend, PK_STATUS_ENUM_QUERY); pk_backend_set_allow_cancel(backend, TRUE); pk_backend_package(backend, PK_INFO_ENUM_AVAILABLE, - "vips-doc;7.12.4-2.fc8;noarch;linva", - "The vips \"documentation\" package."); + "vips-doc;7.12.4-2.fc8;noarch;linva", + "The vips \"documentation\" package."); pk_backend_finished(backend); } @@ -596,12 +600,12 @@ pk_backend_set_allow_cancel(backend, TRUE); if (!pk_bitfield_contain(filters, PK_FILTER_ENUM_INSTALLED)) pk_backend_package(backend, PK_INFO_ENUM_AVAILABLE, - "vips-doc;7.12.4-2.fc8;noarch;linva", - "The vips documentation package"); + "vips-doc;7.12.4-2.fc8;noarch;linva", + "The vips documentation package"); else pk_backend_package(backend, PK_INFO_ENUM_INSTALLED, - "vips-doc;7.12.4-2.fc8;noarch;linva", - "The vips documentation package"); + "vips-doc;7.12.4-2.fc8;noarch;linva", + "The vips documentation package"); pk_backend_finished(backend); } @@ -617,11 +621,11 @@ pk_backend_set_status(backend, PK_STATUS_ENUM_QUERY); pk_backend_set_allow_cancel(backend, TRUE); pk_backend_package(backend, PK_INFO_ENUM_AVAILABLE, - "vips-doc;7.12.4-2.fc8;noarch;linva", - "The vips documentation package."); + "vips-doc;7.12.4-2.fc8;noarch;linva", + "The vips documentation package."); pk_backend_package(backend, PK_INFO_ENUM_AVAILABLE, - "bǣwulf-utf8;0.1;noarch;hughsie", - "The bǣwulf server test name."); + "bǣwulf-utf8;0.1;noarch;hughsie", + "The bǣwulf server test name."); pk_backend_finished(backend); } @@ -638,22 +642,22 @@ g_debug("locale is %s", locale); if (g_strcmp0(locale, "en_GB.utf8") != 0) { pk_backend_package(backend, PK_INFO_ENUM_INSTALLED, - "evince;0.9.3-5.fc8;i386;installed", - "PDF Dokument Ƥrŏgrȃɱ"); + "evince;0.9.3-5.fc8;i386;installed", + "PDF Dokument Ƥrŏgrȃɱ"); } else { pk_backend_package(backend, PK_INFO_ENUM_INSTALLED, - "evince;0.9.3-5.fc8;i386;installed", - "PDF Document viewer"); + "evince;0.9.3-5.fc8;i386;installed", + "PDF Document viewer"); } pk_backend_package(backend, PK_INFO_ENUM_INSTALLED, - "tetex;3.0-41.fc8;i386;fedora", + "tetex;3.0-41.fc8;i386;fedora", "TeTeX is an implementation of TeX for Linux or UNIX systems."); pk_backend_package(backend, PK_INFO_ENUM_AVAILABLE, - "scribus;1.3.4-1.fc8;i386;fedora", - "Scribus is an desktop open source page layout program"); + "scribus;1.3.4-1.fc8;i386;fedora", + "Scribus is an desktop open source page layout program"); pk_backend_package(backend, PK_INFO_ENUM_AVAILABLE, - "vips-doc;7.12.4-2.fc8;noarch;linva", - "The vips documentation package."); + "vips-doc;7.12.4-2.fc8;noarch;linva", + "The vips documentation package."); pk_backend_finished(backend); return FALSE; } @@ -688,15 +692,15 @@ } if (_progress_percentage == 0 && !_updated_powertop) { pk_backend_package(backend, PK_INFO_ENUM_DOWNLOADING, - "powertop;1.8-1.fc8;i386;fedora", - "Power consumption monitor"); + "powertop;1.8-1.fc8;i386;fedora", + "Power consumption monitor"); pk_backend_set_sub_percentage(backend, 0); } if (_progress_percentage == 20 && !_updated_kernel) { pk_backend_set_sub_percentage(backend, 100); pk_backend_package(backend, PK_INFO_ENUM_DOWNLOADING, - "kernel;2.6.23-0.115.rc3.git1.fc8;i386;installed", - "The Linux kernel (the core of the Linux operating system)"); + "kernel;2.6.23-0.115.rc3.git1.fc8;i386;installed", + "The Linux kernel (the core of the Linux operating system)"); pk_backend_set_sub_percentage(backend, 0); pk_backend_require_restart(backend, PK_RESTART_ENUM_SYSTEM, "kernel;2.6.23-0.115.rc3.git1.fc8;i386;installed"); } @@ -708,8 +712,8 @@ pk_backend_message(backend, PK_MESSAGE_ENUM_BROKEN_MIRROR, "fedora-updates-testing-source metadata is invalid"); pk_backend_set_sub_percentage(backend, 100); pk_backend_package(backend, PK_INFO_ENUM_INSTALLING, - "gtkhtml2;2.19.1-4.fc8;i386;fedora", - "An HTML widget for GTK+ 2.0"); + "gtkhtml2;2.19.1-4.fc8;i386;fedora", + "An HTML widget for GTK+ 2.0"); _updated_gtkhtml = TRUE; pk_backend_set_sub_percentage(backend, 0); } @@ -718,24 +722,24 @@ pk_backend_set_allow_cancel(backend, FALSE); pk_backend_set_sub_percentage(backend, 100); pk_backend_package(backend, PK_INFO_ENUM_INSTALLING, - "powertop;1.8-1.fc8;i386;fedora", - "Power consumption monitor"); + "powertop;1.8-1.fc8;i386;fedora", + "Power consumption monitor"); _updated_powertop = TRUE; pk_backend_set_sub_percentage(backend, 0); } if (_progress_percentage == 60 && !_updated_kernel) { pk_backend_set_sub_percentage(backend, 100); pk_backend_package(backend, PK_INFO_ENUM_UPDATING, - "kernel;2.6.23-0.115.rc3.git1.fc8;i386;installed", - "The Linux kernel (the core of the Linux operating system)"); + "kernel;2.6.23-0.115.rc3.git1.fc8;i386;installed", + "The Linux kernel (the core of the Linux operating system)"); _updated_kernel = TRUE; pk_backend_set_sub_percentage(backend, 0); } if (_progress_percentage == 80 && !_updated_kernel) { pk_backend_set_sub_percentage(backend, 100); pk_backend_package(backend, PK_INFO_ENUM_CLEANUP, - "kernel;2.6.23-0.115.rc3.git1.fc8;i386;installed", - "The Linux kernel (the core of the Linux operating system)"); + "kernel;2.6.23-0.115.rc3.git1.fc8;i386;installed", + "The Linux kernel (the core of the Linux operating system)"); pk_backend_set_sub_percentage(backend, 0); } _progress_percentage += 1; @@ -761,13 +765,13 @@ if (_use_gpg && !_has_signature) { pk_backend_repo_signature_required(backend, package_ids[0], "updates", - "http://example.com/gpgkey", - "Test Key (Fedora) fedora@example.com", - "BB7576AC", - "D8CC 06C2 77EC 9C53 372F C199 B1EE 1799 F24F 1B08", - "2007-10-04", PK_SIGTYPE_ENUM_GPG); + "http://example.com/gpgkey", + "Test Key (Fedora) fedora@example.com", + "BB7576AC", + "D8CC 06C2 77EC 9C53 372F C199 B1EE 1799 F24F 1B08", + "2007-10-04", PK_SIGTYPE_ENUM_GPG); pk_backend_error_code(backend, PK_ERROR_ENUM_GPG_FAILURE, - "GPG signed package could not be verified"); + "GPG signed package could not be verified"); pk_backend_finished(backend); return; } @@ -775,27 +779,27 @@ has_eula = pk_backend_is_eula_valid(backend, eula_id); if (_use_eula && !has_eula) { license_agreement = "Narrator: In A.D. 2101, war was beginning.\n" - "Captain: What happen ?\n" - "Mechanic: Somebody set up us the bomb.\n\n" - "Operator: We get signal.\n" - "Captain: What !\n" - "Operator: Main screen turn on.\n" - "Captain: It's you !!\n" - "CATS: How are you gentlemen !!\n" - "CATS: All your base are belong to us.\n" - "CATS: You are on the way to destruction.\n\n" - "Captain: What you say !!\n" - "CATS: You have no chance to survive make your time.\n" - "CATS: Ha Ha Ha Ha ....\n\n" - "Operator: Captain!! *\n" - "Captain: Take off every 'ZIG' !!\n" - "Captain: You know what you doing.\n" - "Captain: Move 'ZIG'.\n" - "Captain: For great justice.\n"; + "Captain: What happen ?\n" + "Mechanic: Somebody set up us the bomb.\n\n" + "Operator: We get signal.\n" + "Captain: What !\n" + "Operator: Main screen turn on.\n" + "Captain: It's you !!\n" + "CATS: How are you gentlemen !!\n" + "CATS: All your base are belong to us.\n" + "CATS: You are on the way to destruction.\n\n" + "Captain: What you say !!\n" + "CATS: You have no chance to survive make your time.\n" + "CATS: Ha Ha Ha Ha ....\n\n" + "Operator: Captain!! *\n" + "Captain: Take off every 'ZIG' !!\n" + "Captain: You know what you doing.\n" + "Captain: Move 'ZIG'.\n" + "Captain: For great justice.\n"; pk_backend_eula_required(backend, eula_id, package_ids[0], - "CATS Inc.", license_agreement); + "CATS Inc.", license_agreement); pk_backend_error_code(backend, PK_ERROR_ENUM_NO_LICENSE_AGREEMENT, - "licence not installed so cannot install"); + "licence not installed so cannot install"); pk_backend_finished(backend); return; } @@ -825,13 +829,13 @@ } if (_progress_percentage == 0 && !_updated_powertop) { pk_backend_package(backend, PK_INFO_ENUM_DOWNLOADING, - "powertop;1.8-1.fc8;i386;fedora", - "Power consumption monitor"); + "powertop;1.8-1.fc8;i386;fedora", + "Power consumption monitor"); } if (_progress_percentage == 20 && !_updated_kernel) { pk_backend_package(backend, PK_INFO_ENUM_DOWNLOADING, - "kernel;2.6.23-0.115.rc3.git1.fc8;i386;installed", - "The Linux kernel (the core of the Linux operating system)"); + "kernel;2.6.23-0.115.rc3.git1.fc8;i386;installed", + "The Linux kernel (the core of the Linux operating system)"); } if (_progress_percentage == 30 && !_updated_gtkhtml) { pk_backend_message(backend, PK_MESSAGE_ENUM_NEWER_PACKAGE_EXISTS, "A newer package preupgrade is available in fedora-updates-testing"); @@ -840,28 +844,28 @@ pk_backend_message(backend, PK_MESSAGE_ENUM_BROKEN_MIRROR, "fedora-updates-testing-debuginfo metadata is invalid"); pk_backend_message(backend, PK_MESSAGE_ENUM_BROKEN_MIRROR, "fedora-updates-testing-source metadata is invalid"); pk_backend_package(backend, PK_INFO_ENUM_INSTALLING, - "gtkhtml2;2.19.1-4.fc8;i386;fedora", - "An HTML widget for GTK+ 2.0"); + "gtkhtml2;2.19.1-4.fc8;i386;fedora", + "An HTML widget for GTK+ 2.0"); _updated_gtkhtml = TRUE; } if (_progress_percentage == 40 && !_updated_powertop) { pk_backend_set_status(backend, PK_STATUS_ENUM_UPDATE); pk_backend_set_allow_cancel(backend, FALSE); pk_backend_package(backend, PK_INFO_ENUM_INSTALLING, - "powertop;1.8-1.fc8;i386;fedora", - "Power consumption monitor"); + "powertop;1.8-1.fc8;i386;fedora", + "Power consumption monitor"); _updated_powertop = TRUE; } if (_progress_percentage == 60 && !_updated_kernel) { pk_backend_package(backend, PK_INFO_ENUM_UPDATING, - "kernel;2.6.23-0.115.rc3.git1.fc8;i386;installed", - "The Linux kernel (the core of the Linux operating system)"); + "kernel;2.6.23-0.115.rc3.git1.fc8;i386;installed", + "The Linux kernel (the core of the Linux operating system)"); _updated_kernel = TRUE; } if (_progress_percentage == 80 && !_updated_kernel) { pk_backend_package(backend, PK_INFO_ENUM_CLEANUP, - "kernel;2.6.23-0.115.rc3.git1.fc8;i386;installed", - "The Linux kernel (the core of the Linux operating system)"); + "kernel;2.6.23-0.115.rc3.git1.fc8;i386;installed", + "The Linux kernel (the core of the Linux operating system)"); } _progress_percentage += 1; pk_backend_set_percentage(backend, _progress_percentage); @@ -885,7 +889,7 @@ /* the helper process exited */ if ((condition & G_IO_HUP) > 0) { pk_backend_error_code(backend, PK_ERROR_ENUM_INTERNAL_ERROR, - "socket was disconnected"); + "socket was disconnected"); pk_backend_finished(backend); ret = FALSE; goto out; @@ -895,7 +899,7 @@ len = g_socket_receive(socket, buffer, 1024, NULL, &error); if (error != NULL) { pk_backend_error_code(backend, PK_ERROR_ENUM_INTERNAL_ERROR, - "failed to read: %s", error->message); + "failed to read: %s", error->message); pk_backend_finished(backend); g_error_free(error); ret = FALSE; @@ -912,14 +916,14 @@ wrote = g_socket_send(_socket, "invalid\n", 8, NULL, &error); if (error != NULL) { pk_backend_error_code(backend, PK_ERROR_ENUM_INTERNAL_ERROR, - "failed to write to socket: %s", error->message); + "failed to write to socket: %s", error->message); pk_backend_finished(backend); g_error_free(error); goto out; } if (wrote != 8) { pk_backend_error_code(backend, PK_ERROR_ENUM_INTERNAL_ERROR, - "failed to write, only %i bytes", wrote); + "failed to write, only %i bytes", wrote); pk_backend_finished(backend); goto out; } @@ -927,7 +931,7 @@ g_debug("ignoring invalid data (one is good)"); } else { pk_backend_error_code(backend, PK_ERROR_ENUM_INTERNAL_ERROR, - "unexpected data: %s", buffer); + "unexpected data: %s", buffer); g_source_remove(_signal_timeout); pk_backend_finished(backend); goto out; @@ -963,7 +967,7 @@ frontend_socket = pk_backend_get_frontend_socket(backend); if (frontend_socket == NULL) { pk_backend_error_code(backend, PK_ERROR_ENUM_INTERNAL_ERROR, - "failed to get frontend socket"); + "failed to get frontend socket"); pk_backend_finished(backend); goto out; } @@ -971,7 +975,7 @@ _socket = g_socket_new(G_SOCKET_FAMILY_UNIX, G_SOCKET_TYPE_STREAM, G_SOCKET_PROTOCOL_DEFAULT, &error); if (_socket == NULL) { pk_backend_error_code(backend, PK_ERROR_ENUM_INTERNAL_ERROR, - "failed to create socket: %s", error->message); + "failed to create socket: %s", error->message); pk_backend_finished(backend); g_error_free(error); goto out; @@ -984,7 +988,7 @@ ret = g_socket_connect(_socket, address, NULL, &error); if (!ret) { pk_backend_error_code(backend, PK_ERROR_ENUM_INTERNAL_ERROR, - "failed to open socket: %s", error->message); + "failed to open socket: %s", error->message); pk_backend_finished(backend); g_error_free(error); goto out; @@ -998,7 +1002,7 @@ wrote = g_socket_send(_socket, "ping\n", 5, NULL, &error); if (wrote != 5) { pk_backend_error_code(backend, PK_ERROR_ENUM_INTERNAL_ERROR, - "failed to write, only %i bytes", wrote); + "failed to write, only %i bytes", wrote); pk_backend_finished(backend); goto out; } @@ -1040,12 +1044,12 @@ if (_progress_percentage == 100) { if (g_strcmp0(_values[0], "gstreamer0.10(decoder-audio/x-wma)(wmaversion=3)") == 0) { pk_backend_package(backend, PK_INFO_ENUM_AVAILABLE, - "gstreamer-plugins-bad;0.10.3-5.lvn;i386;available", - "GStreamer streaming media framework \"bad\" plug-ins"); + "gstreamer-plugins-bad;0.10.3-5.lvn;i386;available", + "GStreamer streaming media framework \"bad\" plug-ins"); } else if (g_strcmp0(_values[0], "gstreamer0.10(decoder-video/x-wma)(wmaversion=3)") == 0) { pk_backend_package(backend, PK_INFO_ENUM_AVAILABLE, - "gstreamer-plugins-flumpegdemux;0.10.15-5.lvn;i386;available", - "MPEG demuxer for GStreamer"); + "gstreamer-plugins-flumpegdemux;0.10.15-5.lvn;i386;available", + "MPEG demuxer for GStreamer"); } else { /* * pkcon install vips-doc says it's installed cause @@ -1054,13 +1058,13 @@ if (g_strcmp0(_values[0], "vips-doc") != 0) { if (!pk_bitfield_contain(_filters, PK_FILTER_ENUM_NOT_INSTALLED)) { pk_backend_package(backend, PK_INFO_ENUM_INSTALLED, - "evince;0.9.3-5.fc8;i386;installed", - "PDF Document viewer"); + "evince;0.9.3-5.fc8;i386;installed", + "PDF Document viewer"); } if (!pk_bitfield_contain(_filters, PK_FILTER_ENUM_INSTALLED)) { pk_backend_package(backend, PK_INFO_ENUM_AVAILABLE, - "scribus;1.3.4-1.fc8;i386;fedora", - "Scribus is an desktop open source page layout program"); + "scribus;1.3.4-1.fc8;i386;fedora", + "Scribus is an desktop open source page layout program"); } } } @@ -1099,8 +1103,8 @@ pk_backend_set_status(backend, PK_STATUS_ENUM_REQUEST); pk_backend_package(backend, PK_INFO_ENUM_INSTALLED, - "update1;2.19.1-4.fc8;i386;fedora", - "The first update"); + "update1;2.19.1-4.fc8;i386;fedora", + "The first update"); pk_backend_finished(backend); } @@ -1120,7 +1124,7 @@ filename = g_build_filename(directory, "powertop-1.8-1.fc8.rpm", NULL); g_file_set_contents(filename, "powertop data", -1, NULL); pk_backend_package(backend, PK_INFO_ENUM_DOWNLOADING, - "powertop;1.8-1.fc8;i386;fedora", "Power consumption monitor"); + "powertop;1.8-1.fc8;i386;fedora", "Power consumption monitor"); pk_backend_files(backend, "powertop;1.8-1.fc8;i386;fedora", filename); g_free(filename); @@ -1128,7 +1132,7 @@ filename = g_build_filename(directory, "powertop-common-1.8-1.fc8.rpm", NULL); g_file_set_contents(filename, "powertop-common data", -1, NULL); pk_backend_package(backend, PK_INFO_ENUM_DOWNLOADING, - "powertop-common;1.8-1.fc8;i386;fedora", "Power consumption monitor"); + "powertop-common;1.8-1.fc8;i386;fedora", "Power consumption monitor"); pk_backend_files(backend, "powertop-common;1.8-1.fc8;i386;fedora", filename); g_free(filename); @@ -1165,30 +1169,30 @@ } if (_progress_percentage == 20) { pk_backend_package(backend, PK_INFO_ENUM_DOWNLOADING, - "kernel;2.6.23-0.115.rc3.git1.fc8;i386;installed", - "The Linux kernel (the core of the Linux operating system)"); + "kernel;2.6.23-0.115.rc3.git1.fc8;i386;installed", + "The Linux kernel (the core of the Linux operating system)"); } if (_progress_percentage == 30) { pk_backend_package(backend, PK_INFO_ENUM_DOWNLOADING, - "gtkhtml2;2.19.1-4.fc8;i386;fedora", - "An HTML widget for GTK+ 2.0"); + "gtkhtml2;2.19.1-4.fc8;i386;fedora", + "An HTML widget for GTK+ 2.0"); } if (_progress_percentage == 40) { pk_backend_set_allow_cancel(backend, FALSE); pk_backend_package(backend, PK_INFO_ENUM_DOWNLOADING, - "powertop;1.8-1.fc8;i386;fedora", - "Power consumption monitor"); + "powertop;1.8-1.fc8;i386;fedora", + "Power consumption monitor"); } if (_progress_percentage == 60) { pk_backend_set_allow_cancel(backend, TRUE); pk_backend_package(backend, PK_INFO_ENUM_DOWNLOADING, - "kernel;2.6.23-0.115.rc3.git1.fc8;i386;installed", - "The Linux kernel (the core of the Linux operating system)"); + "kernel;2.6.23-0.115.rc3.git1.fc8;i386;installed", + "The Linux kernel (the core of the Linux operating system)"); } if (_progress_percentage == 80) { pk_backend_package(backend, PK_INFO_ENUM_DOWNLOADING, - "powertop;1.8-1.fc8;i386;fedora", - "Power consumption monitor"); + "powertop;1.8-1.fc8;i386;fedora", + "Power consumption monitor"); } _progress_percentage += 1; pk_backend_set_percentage(backend, _progress_percentage); Modified: soc2013/mattbw/backend/pkgutils.c ============================================================================== --- soc2013/mattbw/backend/pkgutils.c Sat Jul 6 21:38:55 2013 (r254260) +++ soc2013/mattbw/backend/pkgutils.c Sat Jul 6 22:53:47 2013 (r254261) @@ -99,6 +99,8 @@ char *comment; gchar *id; + comment = id = NULL; + pkg_get(pkg, PKG_COMMENT, &comment); id = pkgutils_pkg_to_id(pkg); pk_backend_package(backend, info, id, comment); @@ -115,7 +117,7 @@ const gchar **id_bits; /* Make sure the initial string vector's pointers are all NULL */ - id_bits = g_new0(const gchar *, 4); + id_bits = calloc(4, sizeof(const gchar *)); /* * This is split through an intermediate function so the same code @@ -123,8 +125,8 @@ */ id = pkgutils_pkg_to_id_through(pkg, id_bits); - /* we don't own any of the strings, so we don't use g_strfreev. */ - g_free(id_bits); + /* we don't own any of the strings, so we don't free those. */ + free(id_bits); return id; } @@ -137,17 +139,18 @@ gchar * pkgutils_pkg_to_id_through(struct pkg *pkg, const gchar **strv) { + pkg_get(pkg, - PKG_NAME, strv + PK_PACKAGE_ID_NAME, - PKG_VERSION, strv + PK_PACKAGE_ID_VERSION, - PKG_ARCH, strv + PK_PACKAGE_ID_ARCH); + PKG_NAME, strv + PK_PACKAGE_ID_NAME, + PKG_VERSION, strv + PK_PACKAGE_ID_VERSION, + PKG_ARCH, strv + PK_PACKAGE_ID_ARCH); strv[PK_PACKAGE_ID_DATA] = pkgutils_pk_repo_of(pkg); return pk_package_id_build(strv[PK_PACKAGE_ID_NAME], - strv[PK_PACKAGE_ID_VERSION], - strv[PK_PACKAGE_ID_ARCH], - strv[PK_PACKAGE_ID_DATA]); + strv[PK_PACKAGE_ID_VERSION], + strv[PK_PACKAGE_ID_ARCH], + strv[PK_PACKAGE_ID_DATA]); } /* @@ -164,7 +167,8 @@ const char *repo_name; struct pkg_repo *repo_struct; - repo = NULL; + repo = repo_name = NULL; + repo_struct = NULL; /* * We can get the repo NAME directly, but we need the repo IDENT. Modified: soc2013/mattbw/backend/query.c ============================================================================== --- soc2013/mattbw/backend/query.c Sat Jul 6 21:38:55 2013 (r254260) +++ soc2013/mattbw/backend/query.c Sat Jul 6 22:53:47 2013 (r254261) @@ -49,13 +49,11 @@ pkg_jobs_t job_type; }; -static gboolean match(struct query *q, gchar **match_id_p, struct pkg **match_pkg_p); -static gboolean match_id_in_it(struct pkgdb_it *it, struct query *q, gchar **match_id_p, struct pkg **match_pkg_p); -static gboolean query_do(PkBackend *backend, unsigned int load_flags, emit_ptr emitter, pkg_jobs_t job_type, job_emit_ptr job_emitter, query_body_ptr body); -static gboolean query_emit_to_job(struct pkg *pkg, const gchar *id, struct query *q); -static gboolean query_match(struct query *q); +static gboolean match_id_in_it(struct pkgdb_it *it, struct query *q, struct pkg +**match_pkg_p, gchar **match_id_p); static gboolean try_id_match(struct pkg *pkg, struct query *q, gchar **match_id); *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-soc-all@FreeBSD.ORG Sat Jul 6 23:59:28 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 177521F5 for ; Sat, 6 Jul 2013 23:59:28 +0000 (UTC) (envelope-from mattbw@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 077C31A02 for ; Sat, 6 Jul 2013 23:59:28 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r66NxRXC039643 for ; Sat, 6 Jul 2013 23:59:27 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r66NxROm039636 for svn-soc-all@FreeBSD.org; Sat, 6 Jul 2013 23:59:27 GMT (envelope-from mattbw@FreeBSD.org) Date: Sat, 6 Jul 2013 23:59:27 GMT Message-Id: <201307062359.r66NxROm039636@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to mattbw@FreeBSD.org using -f From: mattbw@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254265 - in soc2013/mattbw/backend: . actions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 06 Jul 2013 23:59:28 -0000 Author: mattbw Date: Sat Jul 6 23:59:27 2013 New Revision: 254265 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254265 Log: major cleanup and removal of dummy stubs Modified: soc2013/mattbw/backend/Makefile soc2013/mattbw/backend/actions/get-files.c soc2013/mattbw/backend/actions/get-repo-list.c soc2013/mattbw/backend/actions/install-packages.c soc2013/mattbw/backend/pk-backend-pkgng.c soc2013/mattbw/backend/query.c Modified: soc2013/mattbw/backend/Makefile ============================================================================== --- soc2013/mattbw/backend/Makefile Sat Jul 6 22:51:56 2013 (r254264) +++ soc2013/mattbw/backend/Makefile Sat Jul 6 23:59:27 2013 (r254265) @@ -15,6 +15,7 @@ actions/get-details.c \ actions/get-files.c \ actions/get-repo-list.c \ + actions/install-files.c \ actions/install-packages.c LIBDIR= /usr/local/lib/packagekit-backend Modified: soc2013/mattbw/backend/actions/get-files.c ============================================================================== --- soc2013/mattbw/backend/actions/get-files.c Sat Jul 6 22:51:56 2013 (r254264) +++ soc2013/mattbw/backend/actions/get-files.c Sat Jul 6 23:59:27 2013 (r254265) @@ -44,6 +44,7 @@ get_files_thread(PkBackend *backend) { + (void)pk_backend_set_status(backend, PK_STATUS_ENUM_QUERY); return query_match_id_to_emitter(backend, LOAD_FLAGS, emit); } Modified: soc2013/mattbw/backend/actions/get-repo-list.c ============================================================================== --- soc2013/mattbw/backend/actions/get-repo-list.c Sat Jul 6 22:51:56 2013 (r254264) +++ soc2013/mattbw/backend/actions/get-repo-list.c Sat Jul 6 23:59:27 2013 (r254265) @@ -37,11 +37,17 @@ repo = NULL; + (void)pk_backend_set_status(backend, PK_STATUS_ENUM_QUERY); + (void)pk_backend_set_percentage(backend, + PK_BACKEND_PERCENTAGE_INVALID); + for (HASH_FOR(err, pkg_repos, &repo)) pk_backend_repo_detail(backend, pkg_repo_ident(repo), pkg_repo_name(repo), pkg_repo_enabled(repo)); + (void)pk_backend_finished(backend); + return (err == EPKG_END ? TRUE : FALSE); } Modified: soc2013/mattbw/backend/actions/install-packages.c ============================================================================== --- soc2013/mattbw/backend/actions/install-packages.c Sat Jul 6 22:51:56 2013 (r254264) +++ soc2013/mattbw/backend/actions/install-packages.c Sat Jul 6 23:59:27 2013 (r254265) @@ -45,6 +45,7 @@ install_packages_thread(PkBackend *backend) { + pk_backend_set_status(backend, PK_STATUS_ENUM_QUERY); return query_match_id_to_job(backend, PKG_JOBS_INSTALL, job); } Modified: soc2013/mattbw/backend/pk-backend-pkgng.c ============================================================================== --- soc2013/mattbw/backend/pk-backend-pkgng.c Sat Jul 6 22:51:56 2013 (r254264) +++ soc2013/mattbw/backend/pk-backend-pkgng.c Sat Jul 6 23:59:27 2013 (r254265) @@ -23,8 +23,6 @@ #include #include #include -#include -#include #include "pk-backend.h" #include "pkg.h" @@ -33,23 +31,6 @@ #include "groups.h" /* available_groups */ #include "actions/actions.h" /* Actions threads */ -/* static bodges */ -static guint _progress_percentage = 0; -static gulong _signal_timeout = 0; -static gchar **_package_ids; -static gchar **_values; -static guint _package_current = 0; -static gboolean _updated_gtkhtml = FALSE; -static gboolean _updated_kernel = FALSE; -static gboolean _updated_powertop = FALSE; -static gboolean _has_signature = FALSE; -static gboolean _use_eula = FALSE; -static gboolean _use_gpg = FALSE; -static gboolean _use_distro_upgrade = FALSE; -static PkBitfield _filters = 0; -static GSocket *_socket = NULL; -static guint _socket_listen_id = 0; - /** * pk_backend_initialize: */ @@ -58,8 +39,6 @@ { int err; - _progress_percentage = 0; - err = EPKG_OK; if (!pkg_initialized()) @@ -81,1190 +60,120 @@ pkg_shutdown(); } -/* - * Return all groups available from this backend. - * - * The business end of this function is in "groups.c". - */ -PkBitfield -pk_backend_get_groups(PkBackend *backend) -{ - - INTENTIONALLY_IGNORE(backend); - return available_groups(); -} - -/** - * pk_backend_get_filters: - */ -PkBitfield -pk_backend_get_filters(PkBackend *backend) +gchar * +pk_backend_get_description(PkBackend *backend) { INTENTIONALLY_IGNORE(backend); - return pk_bitfield_from_enums(PK_FILTER_ENUM_GUI, - PK_FILTER_ENUM_INSTALLED, - PK_FILTER_ENUM_DEVELOPMENT, - -1); + return g_strdup("pkgng"); } -/** - * pk_backend_get_mime_types: - */ gchar * -pk_backend_get_mime_types(PkBackend *backend) +pk_backend_get_author(PkBackend *backend) { INTENTIONALLY_IGNORE(backend); - return g_strdup("application/x-rpm;application/x-deb"); + return g_strdup("Matt Windsor "); } -/* - * To implement: - * - * - pk_backend_cancel - */ - /** - * pk_backend_get_depends: + * ACTION STUBS + * + * In roughly alphabetical order; usually the thread code corresponding to these + * can be found in actions/name_of_action.c. + * + * If an action is missing here and not otherwise mentioned, it is probably + * awaiting implementation. + * + * Not supported due to unavailable pkgng features: + * - pk_backend_get_files on a non-installed package + * - pk_backend_repo_enable + * - pk_backend_repo_set_data */ -void -pk_backend_get_depends(PkBackend *backend, PkBitfield filters, gchar **package_ids, gboolean recursive) -{ - INTENTIONALLY_IGNORE(filters); - INTENTIONALLY_IGNORE(recursive); - - pk_backend_set_status(backend, PK_STATUS_ENUM_QUERY); - - if (g_strcmp0(package_ids[0], "scribus;1.3.4-1.fc8;i386;fedora") == 0) { - pk_backend_package(backend, PK_INFO_ENUM_AVAILABLE, - "scribus-clipart;1.3.4-1.fc8;i386;fedora", "Clipart for scribus"); - } else { - pk_backend_package(backend, PK_INFO_ENUM_INSTALLED, - "glib2;2.14.0;i386;fedora", "The GLib library"); - pk_backend_package(backend, PK_INFO_ENUM_AVAILABLE, - "gtk2;gtk2-2.11.6-6.fc8;i386;fedora", "GTK+ Libraries for GIMP"); - } - pk_backend_finished(backend); -} -/* - * Spawns a thread to get the details of the package IDs requested. The - * thread code proper is in "get-details.c". - */ void pk_backend_get_details(PkBackend *backend, gchar **package_ids) { - INTENTIONALLY_IGNORE(package_ids); /* can be retrieved from - * backend */ - - pk_backend_set_status(backend, PK_STATUS_ENUM_QUERY); - pk_backend_set_percentage(backend, PK_BACKEND_PERCENTAGE_INVALID); + INTENTIONALLY_IGNORE(package_ids); /* retrieved from backend */ pk_backend_thread_create(backend, get_details_thread); } -/** - * pk_backend_get_distro_upgrades: - */ -void -pk_backend_get_distro_upgrades(PkBackend *backend) -{ - pk_backend_set_status(backend, PK_STATUS_ENUM_QUERY); - if (!_use_distro_upgrade) - goto out; - pk_backend_distro_upgrade(backend, PK_DISTRO_UPGRADE_ENUM_STABLE, - "fedora-9", "Fedora 9"); - pk_backend_distro_upgrade(backend, PK_DISTRO_UPGRADE_ENUM_UNSTABLE, - "fedora-10-rc1", "Fedora 10 RC1"); -out: - pk_backend_finished(backend); -} - -/** - * pk_backend_get_files: - */ void pk_backend_get_files(PkBackend *backend, gchar **package_ids) { - INTENTIONALLY_IGNORE(package_ids); /* can be retrieved from - * backend */ - - pk_backend_set_status(backend, PK_STATUS_ENUM_QUERY); - pk_backend_set_percentage(backend, PK_BACKEND_PERCENTAGE_INVALID); + INTENTIONALLY_IGNORE(package_ids); /* retrieved from backend */ pk_backend_thread_create(backend, get_files_thread); } -/** - * pk_backend_get_requires: - */ -void -pk_backend_get_requires(PkBackend *backend, PkBitfield filters, gchar **package_ids, gboolean recursive) -{ - INTENTIONALLY_IGNORE(filters); - INTENTIONALLY_IGNORE(package_ids); - INTENTIONALLY_IGNORE(recursive); - - pk_backend_set_status(backend, PK_STATUS_ENUM_QUERY); - pk_backend_package(backend, PK_INFO_ENUM_INSTALLED, - "glib2;2.14.0;i386;fedora", "The GLib library"); - pk_backend_package(backend, PK_INFO_ENUM_INSTALLED, - "gtk2;gtk2-2.11.6-6.fc8;i386;fedora", "GTK+ Libraries for GIMP"); - pk_backend_finished(backend); -} - -/** - * pk_backend_get_update_detail_timeout: - **/ -static gboolean -pk_backend_get_update_detail_timeout(gpointer data) -{ - guint i; - guint len; - const gchar *package_id; - PkBackend *backend = (PkBackend *)data; - const gchar *changelog; - - /* dummy */ - changelog = "**Thu Mar 12 2009** Adam Jackson 1.6.0-13\n" - "- xselinux-1.6.0-selinux-nlfd.patch: Acquire the netlink socket from selinux,\n" - " check it ourselves rather than having libselinux bang on it all the time.\n" - "\n" - "**Wed Mar 11 2009** Adam Jackson 1.6.0-10\n" - "- xserver-1.6.0-selinux-less.patch: Don't init selinux unless the policy\n" - " says to be an object manager.\n" - "\n" - "**Wed Mar 11 2009** Adam Jackson 1.6.0-11\n" - "- xserver-1.6.0-less-acpi-brokenness.patch: Don't build the (broken)\n" - " ACPI code.\n" - "\n" - "**Wed Mar 11 2009** Adam Jackson 1.6.0-12\n" - "- Requires: pixman >= 0.14.0\n" - "\n" - "**Fri Mar 6 2009** Adam Jackson 1.6.0-8\n" - "- xserver-1.6.0-primary.patch: Really, only look at VGA devices. (#488869)\n"; - - /* each one has a different detail for testing */ - pk_backend_set_percentage(backend, 0); - len = g_strv_length(_package_ids); - for (i = 0; i < len; i++) { - package_id = _package_ids[i]; - if (g_strcmp0(package_id, "powertop;1.8-1.fc8;i386;fedora") == 0) { - pk_backend_update_detail(backend, package_id, - "powertop;1.7-1.fc8;i386;installed", "", - "http://www.distro-update.org/page?moo;Bugfix release for powertop", - "http://bgzilla.fd.org/result.php?#12344;Freedesktop Bugzilla #12344", - "", PK_RESTART_ENUM_NONE, "Update to newest upstream source", - changelog, PK_UPDATE_STATE_ENUM_STABLE, "2009-11-17T09:19:00", "2009-11-19T09:19:00"); - } else if (g_strcmp0(package_id, "kernel;2.6.23-0.115.rc3.git1.fc8;i386;installed") == 0) { - pk_backend_update_detail(backend, package_id, - "kernel;2.6.22-0.104.rc3.git6.fc8;i386;installed" - PK_PACKAGE_IDS_DELIM - "kernel;2.6.22-0.105.rc3.git7.fc8;i386;installed", "", - "http://www.distro-update.org/page?moo;Bugfix release for kernel", - "http://bgzilla.fd.org/result.php?#12344;Freedesktop Bugzilla #12344;" - "http://bgzilla.gnome.org/result.php?#9876;GNOME Bugzilla #9876", - "http://nvd.nist.gov/nvd.cfm?cvename=CVE-2007-3381;CVE-2007-3381", - PK_RESTART_ENUM_SYSTEM, - "Update to newest upstream version.\n" - "* This should fix many driver bugs when using nouveau\n" - " * This also introduces the new `frobnicator` driver for *vibrating* rabbit hardware.", - changelog, PK_UPDATE_STATE_ENUM_UNSTABLE, "2008-06-28T09:19:00", NULL); - } else if (g_strcmp0(package_id, "gtkhtml2;2.19.1-4.fc8;i386;fedora") == 0) { - pk_backend_update_detail(backend, package_id, - "gtkhtml2;2.18.1-22.fc8;i386;installed", "", - "http://www.distro-update.org/page?moo;Bugfix release for gtkhtml", - "http://bgzilla.gnome.org/result.php?#9876;GNOME Bugzilla #9876", - NULL, PK_RESTART_ENUM_SESSION, - "Update to latest *whizz* **bang** version\n" - "* support this new thing\n" - "* something else\n" - "- and that new thing", - changelog, PK_UPDATE_STATE_ENUM_UNKNOWN, "2008-07-25T09:19:00", NULL); - - } else if (g_strcmp0(package_id, "vino;2.24.2.fc9;i386;fedora") == 0) { - pk_backend_update_detail(backend, package_id, - "vino;2.24.1.fc9;i386;fedora", "", - "", "", NULL, PK_RESTART_ENUM_NONE, - "Cannot get update as update conflics with vncviewer", - changelog, PK_UPDATE_STATE_ENUM_UNKNOWN, "2008-07-25", NULL); - } else { - /* signal to UI */ - pk_backend_error_code(backend, PK_ERROR_ENUM_INTERNAL_ERROR, "the package update detail was not found for %s", package_id); - } - } - pk_backend_set_percentage(backend, 100); - pk_backend_finished(backend); - _signal_timeout = 0; - return FALSE; -} - -/** - * pk_backend_get_update_detail: - */ -void -pk_backend_get_update_detail(PkBackend *backend, gchar **package_ids) -{ - pk_backend_set_status(backend, PK_STATUS_ENUM_QUERY); - _package_ids = package_ids; - _signal_timeout = g_timeout_add(500, pk_backend_get_update_detail_timeout, backend); -} - -/** - * pk_backend_get_updates_timeout: - **/ -static gboolean -pk_backend_get_updates_timeout(gpointer data) -{ - PkBackend *backend = (PkBackend *)data; - - if (!_updated_powertop) { - pk_backend_package(backend, PK_INFO_ENUM_NORMAL, - "powertop;1.8-1.fc8;i386;fedora", - "Power consumption monitor"); - } - if (!_updated_kernel) { - pk_backend_package(backend, PK_INFO_ENUM_BUGFIX, - "kernel;2.6.23-0.115.rc3.git1.fc8;i386;installed", - "The Linux kernel (the core of the Linux operating system)"); - } - if (!_updated_gtkhtml) { - pk_backend_package(backend, PK_INFO_ENUM_SECURITY, - "gtkhtml2;2.19.1-4.fc8;i386;fedora", - "An HTML widget for GTK+ 2.0"); - } - pk_backend_finished(backend); - _signal_timeout = 0; - return FALSE; -} - -/** - * pk_backend_get_updates: - */ -void -pk_backend_get_updates(PkBackend *backend, PkBitfield filters) -{ - INTENTIONALLY_IGNORE(filters); - - pk_backend_set_status(backend, PK_STATUS_ENUM_QUERY); - pk_backend_set_percentage(backend, PK_BACKEND_PERCENTAGE_INVALID); - /* check network state */ - if (!pk_backend_is_online(backend)) { - pk_backend_error_code(backend, PK_ERROR_ENUM_NO_NETWORK, "Cannot check when offline"); - pk_backend_finished(backend); - return; - } - _signal_timeout = g_timeout_add(1000, pk_backend_get_updates_timeout, backend); -} - -/** - * pk_backend_install_packages: - */ -void -pk_backend_install_packages(PkBackend *backend, gboolean only_trusted, gchar **package_ids) -{ - INTENTIONALLY_IGNORE(only_trusted); - INTENTIONALLY_IGNORE(package_ids); - - pk_backend_set_status(backend, PK_STATUS_ENUM_QUERY); - pk_backend_set_percentage(backend, PK_BACKEND_PERCENTAGE_INVALID); - - pk_backend_thread_create(backend, install_packages_thread); -} - -/** - * pk_backend_install_signature: - */ -void -pk_backend_install_signature(PkBackend *backend, PkSigTypeEnum type, - const gchar *key_id, const gchar *package_id) -{ - pk_backend_set_status(backend, PK_STATUS_ENUM_INSTALL); - if (type == PK_SIGTYPE_ENUM_GPG && - /* egg_strequal (package_id, "vips-doc;7.12.4-2.fc8;noarch;linva") && */ - g_strcmp0(key_id, "BB7576AC") == 0) { - g_debug("installed signature %s for %s", key_id, package_id); - _has_signature = TRUE; - } else { - pk_backend_error_code(backend, PK_ERROR_ENUM_GPG_FAILURE, - "GPG key %s not recognised for package_id %s", - key_id, package_id); - } - pk_backend_finished(backend); -} - -/** - * pk_backend_refresh_cache_timeout: - */ -static gboolean -pk_backend_install_files_timeout(gpointer data) -{ - PkBackend *backend = (PkBackend *)data; - pk_backend_finished(backend); - return FALSE; -} - -/** - * pk_backend_install_files: - */ -void -pk_backend_install_files(PkBackend *backend, gboolean only_trusted, gchar **full_paths) -{ - INTENTIONALLY_IGNORE(only_trusted); - INTENTIONALLY_IGNORE(full_paths); - - pk_backend_set_status(backend, PK_STATUS_ENUM_INSTALL); - pk_backend_set_percentage(backend, 101); - _signal_timeout = g_timeout_add(2000, pk_backend_install_files_timeout, backend); -} - -/** - * pk_backend_refresh_cache_timeout: - */ -static gboolean -pk_backend_refresh_cache_timeout(gpointer data) -{ - PkBackend *backend = (PkBackend *)data; - if (_progress_percentage == 100) { - pk_backend_finished(backend); - return FALSE; - } - if (_progress_percentage == 80) - pk_backend_set_allow_cancel(backend, FALSE); - _progress_percentage += 10; - pk_backend_set_percentage(backend, _progress_percentage); - return TRUE; -} - -/** - * pk_backend_refresh_cache: - */ -void -pk_backend_refresh_cache(PkBackend *backend, gboolean force) -{ - INTENTIONALLY_IGNORE(force); - - _progress_percentage = 0; - - /* reset */ - _updated_gtkhtml = FALSE; - _updated_kernel = FALSE; - _updated_powertop = FALSE; - - pk_backend_set_allow_cancel(backend, TRUE); - pk_backend_set_status(backend, PK_STATUS_ENUM_REFRESH_CACHE); - _signal_timeout = g_timeout_add(500, pk_backend_refresh_cache_timeout, backend); -} - -/** - * pk_backend_resolve_timeout: - */ -static gboolean -pk_backend_resolve_timeout(gpointer data) -{ - PkBackend *backend = (PkBackend *)data; - guint i; - guint len; - gchar **packages = _package_ids; - - pk_backend_set_status(backend, PK_STATUS_ENUM_QUERY); - pk_backend_set_percentage(backend, 0); - - /* each one has a different detail for testing */ - len = g_strv_length(packages); - for (i = 0; i < len; i++) { - if (g_strcmp0(packages[i], "vips-doc") == 0 || g_strcmp0(packages[i], "vips-doc;7.12.4-2.fc8;noarch;linva") == 0) { - if (!pk_bitfield_contain(_filters, PK_FILTER_ENUM_INSTALLED)) { - pk_backend_package(backend, PK_INFO_ENUM_AVAILABLE, - "vips-doc;7.12.4-2.fc8;noarch;linva", "The vips documentation package."); - } - } else if (g_strcmp0(packages[i], "glib2") == 0 || g_strcmp0(packages[i], "glib2;2.14.0;i386;fedora") == 0) { - if (!pk_bitfield_contain(_filters, PK_FILTER_ENUM_NOT_INSTALLED)) { - pk_backend_package(backend, PK_INFO_ENUM_INSTALLED, - "glib2;2.14.0;i386;fedora", "The GLib library"); - } - } else if (g_strcmp0(packages[i], "powertop") == 0 || g_strcmp0(packages[i], "powertop;1.8-1.fc8;i386;fedora") == 0) - pk_backend_package(backend, PK_INFO_ENUM_INSTALLED, - "powertop;1.8-1.fc8;i386;fedora", "Power consumption monitor"); - else if (g_strcmp0(packages[i], "kernel") == 0 || g_strcmp0(packages[i], "kernel;2.6.23-0.115.rc3.git1.fc8;i386;installed") == 0) - pk_backend_package(backend, PK_INFO_ENUM_INSTALLED, - "kernel;2.6.23-0.115.rc3.git1.fc8;i386;installed", "The Linux kernel (the core of the Linux operating system)"); - else if (g_strcmp0(packages[i], "gtkhtml2") == 0 || g_strcmp0(packages[i], "gtkhtml2;2.19.1-4.fc8;i386;fedora") == 0) - pk_backend_package(backend, PK_INFO_ENUM_INSTALLED, - "gtkhtml2;2.19.1-4.fc8;i386;fedora", "An HTML widget for GTK+ 2.0"); - } - pk_backend_set_percentage(backend, 100); - pk_backend_finished(backend); - - /* never repeat */ - return FALSE; -} - -/** - * pk_backend_resolve: - */ -void -pk_backend_resolve(PkBackend *backend, PkBitfield filters, gchar **packages) -{ - _filters = filters; - _package_ids = packages; - _signal_timeout = g_timeout_add(20, pk_backend_resolve_timeout, backend); -} - -/** - * pk_backend_rollback_timeout: - */ -static gboolean -pk_backend_rollback_timeout(gpointer data) -{ - PkBackend *backend = (PkBackend *)data; - if (_progress_percentage == 0) { - _updated_gtkhtml = FALSE; - _updated_kernel = FALSE; - _updated_powertop = FALSE; - pk_backend_set_status(backend, PK_STATUS_ENUM_ROLLBACK); - } - if (_progress_percentage == 20) - pk_backend_set_allow_cancel(backend, FALSE); - if (_progress_percentage == 100) { - pk_backend_finished(backend); - return FALSE; - } - _progress_percentage += 10; - pk_backend_set_percentage(backend, _progress_percentage); - return TRUE; -} - - -/** - * pk_backend_rollback: - */ -void -pk_backend_rollback(PkBackend *backend, const gchar *transaction_id) -{ - /* allow testing error condition */ - if (g_strcmp0(transaction_id, "/397_eeecadad_data") == 0) { - pk_backend_error_code(backend, PK_ERROR_ENUM_TRANSACTION_ERROR, "invalid transaction_id"); - pk_backend_finished(backend); - return; - } - _progress_percentage = 0; - pk_backend_set_percentage(backend, PK_BACKEND_PERCENTAGE_INVALID); - pk_backend_set_allow_cancel(backend, TRUE); - pk_backend_set_status(backend, PK_STATUS_ENUM_QUERY); - _signal_timeout = g_timeout_add(2000, pk_backend_rollback_timeout, backend); -} - -/** - * pk_backend_remove_packages: - */ -void -pk_backend_remove_packages(PkBackend *backend, gchar **package_ids, gboolean allow_deps, gboolean autoremove) -{ - INTENTIONALLY_IGNORE(package_ids); - INTENTIONALLY_IGNORE(allow_deps); - INTENTIONALLY_IGNORE(autoremove); - - pk_backend_set_status(backend, PK_STATUS_ENUM_REMOVE); - pk_backend_error_code(backend, PK_ERROR_ENUM_NO_NETWORK, "No network connection available"); - pk_backend_finished(backend); -} - -/** - * pk_backend_search_details: - */ -void -pk_backend_search_details(PkBackend *backend, PkBitfield filters, gchar **values) -{ - INTENTIONALLY_IGNORE(filters); - INTENTIONALLY_IGNORE(values); - - pk_backend_set_status(backend, PK_STATUS_ENUM_QUERY); - pk_backend_set_allow_cancel(backend, TRUE); - pk_backend_package(backend, PK_INFO_ENUM_AVAILABLE, - "vips-doc;7.12.4-2.fc8;noarch;linva", - "The vips \"documentation\" package."); - pk_backend_finished(backend); -} - -/** - * pk_backend_search_files: - */ -void -pk_backend_search_files(PkBackend *backend, PkBitfield filters, gchar **values) -{ - INTENTIONALLY_IGNORE(values); - - pk_backend_set_status(backend, PK_STATUS_ENUM_QUERY); - pk_backend_set_allow_cancel(backend, TRUE); - if (!pk_bitfield_contain(filters, PK_FILTER_ENUM_INSTALLED)) - pk_backend_package(backend, PK_INFO_ENUM_AVAILABLE, - "vips-doc;7.12.4-2.fc8;noarch;linva", - "The vips documentation package"); - else - pk_backend_package(backend, PK_INFO_ENUM_INSTALLED, - "vips-doc;7.12.4-2.fc8;noarch;linva", - "The vips documentation package"); - pk_backend_finished(backend); -} - -/** - * pk_backend_search_groups: - */ -void -pk_backend_search_groups(PkBackend *backend, PkBitfield filters, gchar **values) -{ - INTENTIONALLY_IGNORE(filters); - INTENTIONALLY_IGNORE(values); - - pk_backend_set_status(backend, PK_STATUS_ENUM_QUERY); - pk_backend_set_allow_cancel(backend, TRUE); - pk_backend_package(backend, PK_INFO_ENUM_AVAILABLE, - "vips-doc;7.12.4-2.fc8;noarch;linva", - "The vips documentation package."); - pk_backend_package(backend, PK_INFO_ENUM_AVAILABLE, - "bǣwulf-utf8;0.1;noarch;hughsie", - "The bǣwulf server test name."); - pk_backend_finished(backend); -} - -/** - * pk_backend_search_name_timeout: - **/ -static gboolean -pk_backend_search_name_timeout(gpointer data) +PkBitfield +pk_backend_get_filters(PkBackend *backend) { - gchar *locale; - PkBackend *backend = (PkBackend *)data; - locale = pk_backend_get_locale(backend); - - g_debug("locale is %s", locale); - if (g_strcmp0(locale, "en_GB.utf8") != 0) { - pk_backend_package(backend, PK_INFO_ENUM_INSTALLED, - "evince;0.9.3-5.fc8;i386;installed", - "PDF Dokument Ƥrŏgrȃɱ"); - } else { - pk_backend_package(backend, PK_INFO_ENUM_INSTALLED, - "evince;0.9.3-5.fc8;i386;installed", - "PDF Document viewer"); - } - pk_backend_package(backend, PK_INFO_ENUM_INSTALLED, - "tetex;3.0-41.fc8;i386;fedora", - "TeTeX is an implementation of TeX for Linux or UNIX systems."); - pk_backend_package(backend, PK_INFO_ENUM_AVAILABLE, - "scribus;1.3.4-1.fc8;i386;fedora", - "Scribus is an desktop open source page layout program"); - pk_backend_package(backend, PK_INFO_ENUM_AVAILABLE, - "vips-doc;7.12.4-2.fc8;noarch;linva", - "The vips documentation package."); - pk_backend_finished(backend); - return FALSE; -} -/** - * pk_backend_search_names: - */ -void -pk_backend_search_names(PkBackend *backend, PkBitfield filters, gchar **values) -{ - INTENTIONALLY_IGNORE(filters); - INTENTIONALLY_IGNORE(values); + INTENTIONALLY_IGNORE(backend); - pk_backend_set_percentage(backend, PK_BACKEND_PERCENTAGE_INVALID); - pk_backend_set_allow_cancel(backend, TRUE); - pk_backend_set_status(backend, PK_STATUS_ENUM_QUERY); - _signal_timeout = g_timeout_add(2000, pk_backend_search_name_timeout, backend); + /* TODO: support more filters */ + return pk_bitfield_from_enums(PK_FILTER_ENUM_INSTALLED, + -1); } -/** - * pk_backend_update_packages_download_timeout: - **/ -static gboolean -pk_backend_update_packages_download_timeout(gpointer data) +PkBitfield +pk_backend_get_groups(PkBackend *backend) { - PkBackend *backend = (PkBackend *)data; - guint sub; - if (_progress_percentage == 100) { - pk_backend_finished(backend); - return FALSE; - } - if (_progress_percentage == 0 && !_updated_powertop) { - pk_backend_package(backend, PK_INFO_ENUM_DOWNLOADING, - "powertop;1.8-1.fc8;i386;fedora", - "Power consumption monitor"); - pk_backend_set_sub_percentage(backend, 0); - } - if (_progress_percentage == 20 && !_updated_kernel) { - pk_backend_set_sub_percentage(backend, 100); - pk_backend_package(backend, PK_INFO_ENUM_DOWNLOADING, - "kernel;2.6.23-0.115.rc3.git1.fc8;i386;installed", - "The Linux kernel (the core of the Linux operating system)"); - pk_backend_set_sub_percentage(backend, 0); - pk_backend_require_restart(backend, PK_RESTART_ENUM_SYSTEM, "kernel;2.6.23-0.115.rc3.git1.fc8;i386;installed"); - } - if (_progress_percentage == 30 && !_updated_gtkhtml) { - pk_backend_message(backend, PK_MESSAGE_ENUM_NEWER_PACKAGE_EXISTS, "A newer package preupgrade is available in fedora-updates-testing"); - pk_backend_message(backend, PK_MESSAGE_ENUM_CONFIG_FILES_CHANGED, "/etc/X11/xorg.conf has been auto-merged, please check before rebooting"); - pk_backend_message(backend, PK_MESSAGE_ENUM_BROKEN_MIRROR, "fedora-updates-testing metadata is invalid"); - pk_backend_message(backend, PK_MESSAGE_ENUM_BROKEN_MIRROR, "fedora-updates-testing-debuginfo metadata is invalid"); - pk_backend_message(backend, PK_MESSAGE_ENUM_BROKEN_MIRROR, "fedora-updates-testing-source metadata is invalid"); - pk_backend_set_sub_percentage(backend, 100); - pk_backend_package(backend, PK_INFO_ENUM_INSTALLING, - "gtkhtml2;2.19.1-4.fc8;i386;fedora", - "An HTML widget for GTK+ 2.0"); - _updated_gtkhtml = TRUE; - pk_backend_set_sub_percentage(backend, 0); - } - if (_progress_percentage == 40 && !_updated_powertop) { - pk_backend_set_status(backend, PK_STATUS_ENUM_UPDATE); - pk_backend_set_allow_cancel(backend, FALSE); - pk_backend_set_sub_percentage(backend, 100); - pk_backend_package(backend, PK_INFO_ENUM_INSTALLING, - "powertop;1.8-1.fc8;i386;fedora", - "Power consumption monitor"); - _updated_powertop = TRUE; - pk_backend_set_sub_percentage(backend, 0); - } - if (_progress_percentage == 60 && !_updated_kernel) { - pk_backend_set_sub_percentage(backend, 100); - pk_backend_package(backend, PK_INFO_ENUM_UPDATING, - "kernel;2.6.23-0.115.rc3.git1.fc8;i386;installed", - "The Linux kernel (the core of the Linux operating system)"); - _updated_kernel = TRUE; - pk_backend_set_sub_percentage(backend, 0); - } - if (_progress_percentage == 80 && !_updated_kernel) { - pk_backend_set_sub_percentage(backend, 100); - pk_backend_package(backend, PK_INFO_ENUM_CLEANUP, - "kernel;2.6.23-0.115.rc3.git1.fc8;i386;installed", - "The Linux kernel (the core of the Linux operating system)"); - pk_backend_set_sub_percentage(backend, 0); - } - _progress_percentage += 1; - pk_backend_set_percentage(backend, _progress_percentage); - sub = (_progress_percentage % 10) * 10; - if (sub != 0) - pk_backend_set_sub_percentage(backend, sub); - return TRUE; -} - -/** - * pk_backend_update_packages: - */ -void -pk_backend_update_packages(PkBackend *backend, gboolean only_trusted, gchar **package_ids) -{ - const gchar *eula_id; - const gchar *license_agreement; - gboolean has_eula; - - /* FIXME: support only_trusted */ - INTENTIONALLY_IGNORE(only_trusted); - - if (_use_gpg && !_has_signature) { - pk_backend_repo_signature_required(backend, package_ids[0], "updates", - "http://example.com/gpgkey", - "Test Key (Fedora) fedora@example.com", - "BB7576AC", - "D8CC 06C2 77EC 9C53 372F C199 B1EE 1799 F24F 1B08", - "2007-10-04", PK_SIGTYPE_ENUM_GPG); - pk_backend_error_code(backend, PK_ERROR_ENUM_GPG_FAILURE, - "GPG signed package could not be verified"); - pk_backend_finished(backend); - return; - } - eula_id = "eula_hughsie_dot_com"; - has_eula = pk_backend_is_eula_valid(backend, eula_id); - if (_use_eula && !has_eula) { - license_agreement = "Narrator: In A.D. 2101, war was beginning.\n" - "Captain: What happen ?\n" - "Mechanic: Somebody set up us the bomb.\n\n" - "Operator: We get signal.\n" - "Captain: What !\n" - "Operator: Main screen turn on.\n" - "Captain: It's you !!\n" - "CATS: How are you gentlemen !!\n" - "CATS: All your base are belong to us.\n" - "CATS: You are on the way to destruction.\n\n" - "Captain: What you say !!\n" - "CATS: You have no chance to survive make your time.\n" - "CATS: Ha Ha Ha Ha ....\n\n" - "Operator: Captain!! *\n" - "Captain: Take off every 'ZIG' !!\n" - "Captain: You know what you doing.\n" - "Captain: Move 'ZIG'.\n" - "Captain: For great justice.\n"; - pk_backend_eula_required(backend, eula_id, package_ids[0], - "CATS Inc.", license_agreement); - pk_backend_error_code(backend, PK_ERROR_ENUM_NO_LICENSE_AGREEMENT, - "licence not installed so cannot install"); - pk_backend_finished(backend); - return; - } - _package_ids = package_ids; - _package_current = 0; - _progress_percentage = 0; - pk_backend_set_allow_cancel(backend, TRUE); - pk_backend_set_percentage(backend, 0); - pk_backend_set_status(backend, PK_STATUS_ENUM_DOWNLOAD); - _signal_timeout = g_timeout_add(200, pk_backend_update_packages_download_timeout, backend); + INTENTIONALLY_IGNORE(backend); + return available_groups(); } -static gboolean -pk_backend_update_system_timeout(gpointer data) +gchar * +pk_backend_get_mime_types(PkBackend *backend) { - PkBackend *backend = (PkBackend *)data; - if (_progress_percentage == 100) { - - /* cleanup socket stuff */ - if (_socket != NULL) - g_object_unref(_socket); - if (_socket_listen_id != 0) - g_source_remove(_socket_listen_id); - - pk_backend_finished(backend); - return FALSE; - } - if (_progress_percentage == 0 && !_updated_powertop) { - pk_backend_package(backend, PK_INFO_ENUM_DOWNLOADING, - "powertop;1.8-1.fc8;i386;fedora", - "Power consumption monitor"); - } - if (_progress_percentage == 20 && !_updated_kernel) { - pk_backend_package(backend, PK_INFO_ENUM_DOWNLOADING, - "kernel;2.6.23-0.115.rc3.git1.fc8;i386;installed", - "The Linux kernel (the core of the Linux operating system)"); - } - if (_progress_percentage == 30 && !_updated_gtkhtml) { - pk_backend_message(backend, PK_MESSAGE_ENUM_NEWER_PACKAGE_EXISTS, "A newer package preupgrade is available in fedora-updates-testing"); - pk_backend_message(backend, PK_MESSAGE_ENUM_CONFIG_FILES_CHANGED, "/etc/X11/xorg.conf has been auto-merged, please check before rebooting"); - pk_backend_message(backend, PK_MESSAGE_ENUM_BROKEN_MIRROR, "fedora-updates-testing metadata is invalid"); - pk_backend_message(backend, PK_MESSAGE_ENUM_BROKEN_MIRROR, "fedora-updates-testing-debuginfo metadata is invalid"); - pk_backend_message(backend, PK_MESSAGE_ENUM_BROKEN_MIRROR, "fedora-updates-testing-source metadata is invalid"); - pk_backend_package(backend, PK_INFO_ENUM_INSTALLING, - "gtkhtml2;2.19.1-4.fc8;i386;fedora", - "An HTML widget for GTK+ 2.0"); - _updated_gtkhtml = TRUE; - } - if (_progress_percentage == 40 && !_updated_powertop) { - pk_backend_set_status(backend, PK_STATUS_ENUM_UPDATE); - pk_backend_set_allow_cancel(backend, FALSE); - pk_backend_package(backend, PK_INFO_ENUM_INSTALLING, - "powertop;1.8-1.fc8;i386;fedora", - "Power consumption monitor"); - _updated_powertop = TRUE; - } - if (_progress_percentage == 60 && !_updated_kernel) { - pk_backend_package(backend, PK_INFO_ENUM_UPDATING, - "kernel;2.6.23-0.115.rc3.git1.fc8;i386;installed", - "The Linux kernel (the core of the Linux operating system)"); - _updated_kernel = TRUE; - } - if (_progress_percentage == 80 && !_updated_kernel) { - pk_backend_package(backend, PK_INFO_ENUM_CLEANUP, - "kernel;2.6.23-0.115.rc3.git1.fc8;i386;installed", - "The Linux kernel (the core of the Linux operating system)"); - } - _progress_percentage += 1; - pk_backend_set_percentage(backend, _progress_percentage); - pk_backend_set_sub_percentage(backend, (_progress_percentage % 10) * 10); - return TRUE; -} + INTENTIONALLY_IGNORE(backend); -/** - * pk_backend_socket_has_data_cb: - **/ -static gboolean -pk_backend_socket_has_data_cb(GSocket * socket, GIOCondition condition, PkBackend *backend) -{ - GError *error = NULL; - gsize len; - gchar buffer [1024]; - gboolean ret = TRUE; - gint wrote = 0; - - /* the helper process exited */ - if ((condition & G_IO_HUP) > 0) { - pk_backend_error_code(backend, PK_ERROR_ENUM_INTERNAL_ERROR, - "socket was disconnected"); - pk_backend_finished(backend); - ret = FALSE; - goto out; - } - /* there is data */ - if ((condition & G_IO_IN) > 0) { - len = g_socket_receive(socket, buffer, 1024, NULL, &error); - if (error != NULL) { - pk_backend_error_code(backend, PK_ERROR_ENUM_INTERNAL_ERROR, - "failed to read: %s", error->message); - pk_backend_finished(backend); - g_error_free(error); - ret = FALSE; - goto out; - } - if (len == 0) - goto out; - buffer[len] = '\0'; - if (g_strcmp0(buffer, "pong\n") == 0) { - /* send a message so we can verify in the self checks */ - pk_backend_message(backend, PK_MESSAGE_ENUM_PARAMETER_INVALID, buffer); - - /* verify we can write into the socket */ - wrote = g_socket_send(_socket, "invalid\n", 8, NULL, &error); - if (error != NULL) { - pk_backend_error_code(backend, PK_ERROR_ENUM_INTERNAL_ERROR, - "failed to write to socket: %s", error->message); - pk_backend_finished(backend); - g_error_free(error); - goto out; - } - if (wrote != 8) { - pk_backend_error_code(backend, PK_ERROR_ENUM_INTERNAL_ERROR, - "failed to write, only %i bytes", wrote); - pk_backend_finished(backend); - goto out; - } - } else if (g_strcmp0(buffer, "you said to me: invalid\n") == 0) { - g_debug("ignoring invalid data (one is good)"); - } else { - pk_backend_error_code(backend, PK_ERROR_ENUM_INTERNAL_ERROR, - "unexpected data: %s", buffer); - g_source_remove(_signal_timeout); - pk_backend_finished(backend); - goto out; - } - } -out: - return ret; + /* (Backformed from pkg.h: pkg_formats) */ + return g_strdup("application/x-gzip;" + "application/x-tar;" + "application/x-bzip2;" + "application/x-xz;"); } -/** - * pk_backend_update_system: - */ -void -pk_backend_update_system(PkBackend *backend, gboolean only_trusted) *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-soc-all@FreeBSD.ORG Sat Jul 6 23:59:51 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id EE40120D for ; Sat, 6 Jul 2013 23:59:51 +0000 (UTC) (envelope-from mattbw@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id C6E211A03 for ; Sat, 6 Jul 2013 23:59:51 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r66Nxp5k039708 for ; Sat, 6 Jul 2013 23:59:51 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r66NxpJ2039706 for svn-soc-all@FreeBSD.org; Sat, 6 Jul 2013 23:59:51 GMT (envelope-from mattbw@FreeBSD.org) Date: Sat, 6 Jul 2013 23:59:51 GMT Message-Id: <201307062359.r66NxpJ2039706@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to mattbw@FreeBSD.org using -f From: mattbw@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254266 - soc2013/mattbw/backend/actions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 06 Jul 2013 23:59:52 -0000 Author: mattbw Date: Sat Jul 6 23:59:51 2013 New Revision: 254266 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254266 Log: forgot (unusable) implementation of installfiles Added: soc2013/mattbw/backend/actions/install-files.c Added: soc2013/mattbw/backend/actions/install-files.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/mattbw/backend/actions/install-files.c Sat Jul 6 23:59:51 2013 (r254266) @@ -0,0 +1,49 @@ +/*- + * Copyright (C) 2013 Matt Windsor + * + * Licensed under the GNU General Public License Version 2 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include +#include "../pk-backend.h" +#include "pkg.h" + +#include "../db.h" /* open_remote_db */ +#include "../hash_traverse.h" /* HASH_FOR */ +#include "../pkgutils.h" /* pkgutils_... */ +#include "../query_match.h" /* query_match_... */ +#include "../utils.h" /* INTENTIONALLY_IGNORE */ + +#include "actions.h" /* install_files_thread prototype */ + +/* + * The thread that performs an InstallFiles operation. Should be invoked + * by the pk_backend_install_files hook. + */ +gboolean +install_files_thread(PkBackend *backend) +{ + guint len; + gchar **package_ids; + + package_ids = pk_backend_get_strv(backend, "package_ids"); + len = g_strv_length(package_ids); + + pk_backend_finished(backend); + + return FALSE; +}